6574b8fe1ded9371112def5d42a277d55ae2470a
[olsrd.git] / lib / pud / Makefile
1 NMEALIB_PATH = nmealib
2 LIBRARY_PATH = wireformat
3 JAVA_PATH = wireformat-java
4 include $(LIBRARY_PATH)/Makefile.inc
5 NMEALIB_NAME := nmea
6 LIBRARY_NAME := $(PROJECT)
7
8
9 include Makefile.inc
10
11 TOPDIR = ../..
12 include $(TOPDIR)/Makefile.inc
13
14
15 CFLAGS += -D_GNU_SOURCE
16
17
18 RESOURCESDIR = ./resources
19 NMEALIB_INC = $(NMEALIB_PATH)/include
20 NMEALIB_LIB = $(NMEALIB_PATH)/lib
21 LIBRARY_INC = $(LIBRARY_PATH)/include
22 LIBRARY_LIB = $(LIBRARY_PATH)/lib
23
24 CFLAGS += -I $(NMEALIB_INC) -I $(LIBRARY_INC)
25 LIBS += -L $(NMEALIB_LIB) -L $(LIBRARY_LIB) -l$(NMEALIB_NAME) -lm -l$(LIBRARY_NAME)
26
27
28 SUPPORTED = 0
29 ifeq ($(OS),linux)
30 SUPPORTED = 1
31 endif
32 ifeq ($(OS),android)
33 SUPPORTED = 1
34 endif
35
36
37 ifeq ($(SUPPORTED),0)
38
39 .PHONY: all default_target install clean
40
41 all: default_target
42
43 default_target install clean:
44         @echo "*** $(PLUGIN_NAME) plugin not supported on $(OS), sorry!"
45
46 else
47
48 GIT_SHA = $(shell git describe 2> /dev/null || echo "Unknown")
49 CFLAGS += -DGIT_SHA=\"$(GIT_SHA)\" -DPLUGIN_VER=\"$(PLUGIN_VER)\"
50
51 .PHONY: all default_target install uninstall clean doc doc-clean nmealib library java java-instal java-uninstall
52
53 all: default_target
54
55 default_target: nmealib library $(PLUGIN_FULLNAME)
56
57 # repeat from toplevel Makefile.inc, and adjust: we need the library includes
58 %.d: %.c
59         @$(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' >"$@"
60
61 $(PLUGIN_FULLNAME): $(OBJS) version-script.txt
62         @echo "[LD] $@"
63         @$(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(LIBS)
64
65 install: all
66         @$(MAKE) -C "$(NMEALIB_PATH)" DESTDIR="$(DESTDIR)" install
67         @$(MAKE) -C "$(LIBRARY_PATH)" DESTDIR="$(DESTDIR)" install
68         $(INSTALL_LIB)
69         mkdir -p "$(DOCDIR_OLSRD)"
70         cp "$(RESOURCESDIR)/olsrd.pud.position.conf" "$(DOCDIR_OLSRD)"
71         $(STRIP) "$(LIBDIR)/$(PLUGIN_FULLNAME)"
72
73 uninstall:
74         @$(MAKE) -C "$(NMEALIB_PATH)" DESTDIR="$(DESTDIR)" uninstall
75         @$(MAKE) -C "$(LIBRARY_PATH)" DESTDIR="$(DESTDIR)" uninstall
76         rm -f "$(LIBDIR)/lib$(PLUGIN_NAME).so" "$(LIBDIR)/$(PLUGIN_NAME)" "$(DOCDIR_OLSRD)/olsrd.pud.position.conf"
77         $(UNINSTALL_LIB)
78         rmdir -v -p --ignore-fail-on-non-empty "$(LIBDIR)" "$(DOCDIR_OLSRD)"
79
80 clean:
81         @echo "[$@]"
82         @rm -f $(OBJS) $(SRCS:%.c=%.d) "$(PLUGIN_FULLNAME)"
83         @$(MAKE) -C doc clean
84         @$(MAKE) -C "$(NMEALIB_PATH)" clean
85         @$(MAKE) -C "$(LIBRARY_PATH)" clean
86         @$(MAKE) -C "$(JAVA_PATH)" clean
87
88 doc:
89         @$(MAKE) -C doc all
90         @$(MAKE) -C "$(NMEALIB_PATH)" doc
91         @$(MAKE) -C "$(LIBRARY_PATH)" doc
92         @$(MAKE) -C "$(JAVA_PATH)" doc
93
94 doc-clean:
95         @$(MAKE) -C doc clean
96         @$(MAKE) -C "$(NMEALIB_PATH)" doc clean
97         @$(MAKE) -C "$(LIBRARY_PATH)" doc clean
98         @$(MAKE) -C "$(JAVA_PATH)" doc clean
99
100 nmealib:
101         @$(MAKE) -C "$(NMEALIB_PATH)" all
102
103 library:
104         @$(MAKE) -C "$(LIBRARY_PATH)" all
105
106 java:
107         @$(MAKE) -C "$(JAVA_PATH)" all
108
109 java-install: java
110         @$(MAKE) -C "$(JAVA_PATH)" DESTDIR="$(DESTDIR)" install
111
112 java-uninstall:
113         @$(MAKE) -C "$(JAVA_PATH)" DESTDIR="$(DESTDIR)" uninstall
114
115 endif