jsoninfo: use the function to initialise the config
[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 ifeq ($(OS),android)
63 # On Android Google forgot to include regex engine code for Froyo version (but also there was
64 # no support in older versions for it) so we have here this missing code.
65 # http://groups.google.com/group/android-ndk/browse_thread/thread/5ea6f0650f0e3fc
66 OBJS +=     $(REGEX_LIB)
67 CFLAGS += -D__POSIX_VISIBLE
68 endif
69
70 default_target: nmealib library $(PLUGIN_FULLNAME)
71
72 # repeat from toplevel Makefile.inc, and adjust: we need the library includes
73 %.d: %.c
74         $(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' >"$@"
75
76 $(PLUGIN_FULLNAME): $(OBJS) version-script.txt
77 ifeq ($(PUD_NMEALIB_STATICALLY_LINKED),)
78 ifeq ($(VERBOSE),0)
79         @echo "[LD] $@ (nmealib dynamically linked)"
80 endif
81         $(MAKECMDPREFIX)$(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(LIBS)
82 else
83 ifeq ($(VERBOSE),0)
84         @echo "[LD] $@ (nmealib statically linked)"
85 endif
86         $(MAKECMDPREFIX)$(CC) $(LDFLAGS) -o $(PLUGIN_FULLNAME) $(OBJS) $(NMEALIB_LIB_STATIC) $(LIBS)
87 endif
88
89 install: all
90         $(MAKECMDPREFIX)$(MAKE) -C "$(NMEALIB_PATH)" DESTDIR="$(DESTDIR)" install
91         $(MAKECMDPREFIX)$(MAKE) -C "$(LIBRARY_PATH)" DESTDIR="$(DESTDIR)" install
92         $(INSTALL_LIB)
93         mkdir -p "$(ETCDIR)"
94         cp "$(RESOURCESDIR)/olsrd.pud.position.conf" "$(ETCDIR)"
95         $(STRIP) "$(LIBDIR)/$(PLUGIN_FULLNAME)"
96
97 uninstall:
98         $(MAKECMDPREFIX)$(MAKE) -C "$(NMEALIB_PATH)" DESTDIR="$(DESTDIR)" uninstall
99         $(MAKECMDPREFIX)$(MAKE) -C "$(LIBRARY_PATH)" DESTDIR="$(DESTDIR)" uninstall
100         rm -f "$(LIBDIR)/lib$(PLUGIN_NAME).so" "$(LIBDIR)/$(PLUGIN_NAME)" "$(ETCDIR)/olsrd.pud.position.conf"
101         $(UNINSTALL_LIB)
102         rmdir -v -p --ignore-fail-on-non-empty "$(LIBDIR)" "$(ETCDIR)"
103
104 clean:
105 ifeq ($(VERBOSE),0)
106         @echo "[$@]"
107 endif
108         $(MAKECMDPREFIX)rm -f $(OBJS) $(SRCS:%.c=%.d) "$(PLUGIN_FULLNAME)"
109         $(MAKECMDPREFIX)$(MAKE) -C doc clean
110         $(MAKECMDPREFIX)$(MAKE) -C "$(NMEALIB_PATH)" clean
111         $(MAKECMDPREFIX)$(MAKE) -C "$(LIBRARY_PATH)" clean
112         $(MAKECMDPREFIX)$(MAKE) -C "$(JAVA_PATH)" clean
113
114 doc:
115         $(MAKECMDPREFIX)$(MAKE) -C doc all
116         $(MAKECMDPREFIX)$(MAKE) -C "$(NMEALIB_PATH)" doc
117         $(MAKECMDPREFIX)$(MAKE) -C "$(LIBRARY_PATH)" doc
118         $(MAKECMDPREFIX)$(MAKE) -C "$(JAVA_PATH)" doc
119
120 doc-clean:
121         $(MAKECMDPREFIX)$(MAKE) -C doc clean
122         $(MAKECMDPREFIX)$(MAKE) -C "$(NMEALIB_PATH)" doc clean
123         $(MAKECMDPREFIX)$(MAKE) -C "$(LIBRARY_PATH)" doc clean
124         $(MAKECMDPREFIX)$(MAKE) -C "$(JAVA_PATH)" doc clean
125
126 nmealib:
127         $(MAKECMDPREFIX)$(MAKE) -C "$(NMEALIB_PATH)" all
128
129 library:
130         $(MAKECMDPREFIX)$(MAKE) -C "$(LIBRARY_PATH)" all
131
132 java:   library
133         $(MAKECMDPREFIX)$(MAKE) -C "$(JAVA_PATH)" all
134
135 java-install: java
136         $(MAKECMDPREFIX)$(MAKE) -C "$(JAVA_PATH)" DESTDIR="$(DESTDIR)" install
137
138 java-uninstall:
139         $(MAKECMDPREFIX)$(MAKE) -C "$(JAVA_PATH)" DESTDIR="$(DESTDIR)" uninstall
140
141 endif