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