PUD: improve unsupported OS reporting
[olsrd.git] / lib / pud / Makefile
index b2defe9..901adca 100644 (file)
@@ -1,6 +1,8 @@
+NMEALIB_PATH = nmealib
 LIBRARY_PATH = wireformat
 JAVA_PATH = wireformat-java
 include $(LIBRARY_PATH)/Makefile.inc
+NMEALIB_NAME := nmea
 LIBRARY_NAME := $(PROJECT)
 
 
@@ -10,28 +12,17 @@ TOPDIR = ../..
 include $(TOPDIR)/Makefile.inc
 
 
-#CFLAGS += -DPUD_DUMP_GPS_PACKETS_RX_NON_OLSR
-#CFLAGS += -DPUD_DUMP_GPS_PACKETS_TX_OLSR
-#CFLAGS += -DPUD_DUMP_GPS_PACKETS_TX_UPLINK
-#CFLAGS += -DPUD_DUMP_GPS_PACKETS_RX_DOWNLINK
-#CFLAGS += -DPUD_DUMP_GPS_PACKETS_TX_DOWNLINK
-
-#CFLAGS += -DPUD_DUMP_GPS_PACKETS_RX_OLSR
-#CFLAGS += -DPUD_DUMP_GPS_PACKETS_TX_NON_OLSR
-
-#CFLAGS += -DPUD_DUMP_AVERAGING
-#CFLAGS += -DPUD_DUMP_DEDUP
-
-
 CFLAGS += -Werror -D_GNU_SOURCE
 
 
-VERSION_FILE = ./src/version.h
+RESOURCESDIR = ./resources
+NMEALIB_INC = $(NMEALIB_PATH)/include
+NMEALIB_LIB = $(NMEALIB_PATH)/lib
 LIBRARY_INC = $(LIBRARY_PATH)/include
 LIBRARY_LIB = $(LIBRARY_PATH)/lib
 
-CFLAGS += -I $(LIBRARY_INC)
-LIBS += -L $(LIBRARY_LIB) -lnmea -lm -l$(LIBRARY_NAME)
+CFLAGS += -I $(NMEALIB_INC) -I $(LIBRARY_INC)
+LIBS += -L $(NMEALIB_LIB) -L $(LIBRARY_LIB) -l$(NMEALIB_NAME) -lm -l$(LIBRARY_NAME)
 
 ifneq ($(OS),linux)
 
@@ -40,65 +31,75 @@ ifneq ($(OS),linux)
 all: default_target
 
 default_target install clean:
-       @echo "*** $(PLUGIN_NAME) plugin only supported on Linux, sorry!"
+       @echo "*** $(PLUGIN_NAME) plugin not supported on $(OS), sorry!"
 
 else
 
-.PHONY: all default_target install uninstall clean doc doc-clean library java java-instal java-uninstall
+GIT_SHA = $(shell git describe 2> /dev/null || echo "Unknown")
+CFLAGS += -DGIT_SHA=\"$(GIT_SHA)\" -DPLUGIN_VER=\"$(PLUGIN_VER)\"
+
+.PHONY: all default_target install uninstall clean doc doc-clean nmealib library java java-instal java-uninstall
 
 all: default_target
 
-default_target: library $(VERSION_FILE) $(PLUGIN_FULLNAME)
+default_target: nmealib library $(PLUGIN_FULLNAME)
 
 # repeat from toplevel Makefile.inc, and adjust: we need the library includes
 %.d: %.c
-       @$(filter-out $(CCACHE),$(CC)) -M $(strip $(CPPFLAGS)) -I $(LIBRARY_INC) "$<" | sed -e '1s/\($(call quote,$(*F))\.o\)[ :]*/$(call quote,$(*D)/\1 $@: Makefile $(TOPDIR)$(if $(TOPDIR),/)Makefile.inc) /g' >"$@"
+       @$(filter-out $(CCACHE),$(CC)) -M $(strip $(CPPFLAGS)) -I $(NMEALIB_INC) -I $(LIBRARY_INC) "$<" | sed -e '1s/\($(call quote,$(*F))\.o\)[ :]*/$(call quote,$(*D)/\1 $@: Makefile $(TOPDIR)$(if $(TOPDIR),/)Makefile.inc) /g' >"$@"
 
 $(PLUGIN_FULLNAME): $(OBJS) version-script.txt
        @echo "[LD] $@"
        @$(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(LIBS)
 
-$(VERSION_FILE): library scripts/makeVersionH
-       @./scripts/makeVersionH "$(VERSION_FILE)" "$(PLUGIN_VER)"
-
 install: all
-       @$(MAKE) -C $(LIBRARY_PATH) DESTDIR=$(DESTDIR) install
+       @$(MAKE) -C "$(NMEALIB_PATH)" DESTDIR="$(DESTDIR)" install
+       @$(MAKE) -C "$(LIBRARY_PATH)" DESTDIR="$(DESTDIR)" install
        $(INSTALL_LIB)
+       mkdir -p "$(DOCDIR_OLSRD)"
+       cp "$(RESOURCESDIR)/olsrd.pud.position.conf" "$(DOCDIR_OLSRD)"
        $(STRIP) "$(LIBDIR)/$(PLUGIN_FULLNAME)"
 
 uninstall:
-       @$(MAKE) -C $(LIBRARY_PATH) DESTDIR=$(DESTDIR) uninstall
-       rm -f "$(LIBDIR)/lib$(PLUGIN_NAME).so" "$(LIBDIR)/$(PLUGIN_NAME)"
+       @$(MAKE) -C "$(NMEALIB_PATH)" DESTDIR="$(DESTDIR)" uninstall
+       @$(MAKE) -C "$(LIBRARY_PATH)" DESTDIR="$(DESTDIR)" uninstall
+       rm -f "$(LIBDIR)/lib$(PLUGIN_NAME).so" "$(LIBDIR)/$(PLUGIN_NAME)" "$(DOCDIR_OLSRD)/olsrd.pud.position.conf"
        $(UNINSTALL_LIB)
-       rmdir -v -p --ignore-fail-on-non-empty "$(LIBDIR)"
+       rmdir -v -p --ignore-fail-on-non-empty "$(LIBDIR)" "$(DOCDIR_OLSRD)"
 
 clean:
        @echo "[$@]"
        @rm -f $(OBJS) $(SRCS:%.c=%.d) "$(PLUGIN_FULLNAME)"
        @$(MAKE) -C doc clean
-       @$(MAKE) -C $(LIBRARY_PATH) clean
-       @$(MAKE) -C $(JAVA_PATH) clean
+       @$(MAKE) -C "$(NMEALIB_PATH)" clean
+       @$(MAKE) -C "$(LIBRARY_PATH)" clean
+       @$(MAKE) -C "$(JAVA_PATH)" clean
 
 doc:
        @$(MAKE) -C doc all
-       @$(MAKE) -C $(LIBRARY_PATH) doc
-       @$(MAKE) -C $(JAVA_PATH) doc
+       @$(MAKE) -C "$(NMEALIB_PATH)" doc
+       @$(MAKE) -C "$(LIBRARY_PATH)" doc
+       @$(MAKE) -C "$(JAVA_PATH)" doc
 
 doc-clean:
        @$(MAKE) -C doc clean
-       @$(MAKE) -C $(LIBRARY_PATH) doc clean
-       @$(MAKE) -C $(JAVA_PATH) doc clean
+       @$(MAKE) -C "$(NMEALIB_PATH)" doc clean
+       @$(MAKE) -C "$(LIBRARY_PATH)" doc clean
+       @$(MAKE) -C "$(JAVA_PATH)" doc clean
+
+nmealib:
+       @$(MAKE) -C "$(NMEALIB_PATH)" all
 
 library:
-       @$(MAKE) -C $(LIBRARY_PATH) all
+       @$(MAKE) -C "$(LIBRARY_PATH)" all
 
 java:
-       @$(MAKE) -C $(JAVA_PATH) all
+       @$(MAKE) -C "$(JAVA_PATH)" all
 
 java-install: java
-       @$(MAKE) -C $(JAVA_PATH) DESTDIR=$(DESTDIR) install
+       @$(MAKE) -C "$(JAVA_PATH)" DESTDIR="$(DESTDIR)" install
 
 java-uninstall:
-       @$(MAKE) -C $(JAVA_PATH) DESTDIR=$(DESTDIR) uninstall
+       @$(MAKE) -C "$(JAVA_PATH)" DESTDIR="$(DESTDIR)" uninstall
 
 endif