PUD: improve build integration of nmealib
[olsrd.git] / lib / pud / nmealib / Makefile
1 include ../Makefile.inc
2 OLSRD_PLUGIN = false
3
4 TOPDIR = ../../..
5 include $(TOPDIR)/Makefile.inc
6
7
8 include Makefile.inc
9
10 #
11 # Settings
12 #
13
14 LIBNAME = libnmea.so
15
16 DESTDIR ?=
17
18 MACHINE=$(shell uname -m)
19 LIBDIR_INSTALL = usr/lib
20 INCLUDEDIR = usr/include
21
22 MODULES = context generate generator gmath info parse parser sentence time tok util
23 OBJ = $(MODULES:%=build/%.o)
24
25 LIBRARIES = -lm
26 INCLUDES = -I ./include
27
28
29 #
30 # Targets
31 #
32
33 all: default_target
34
35 default_target: all-before lib/$(LIBNAME)
36
37 remake: clean all
38
39 lib/$(LIBNAME): $(OBJ)
40         @echo "[LD] $@"
41         @$(CC) -shared -Wl,-soname=$(LIBNAME) -o "$@" $(LIBRARIES) $(OBJ)
42
43 build/%.o: src/%.c Makefile Makefile.inc
44         @echo "[CC] $<"
45         @$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
46
47 samples: all
48         @$(MAKE) -C samples all
49
50
51 #
52 # Phony Targets
53 #
54
55 .PHONY: all default_target all-before clean doc install install-headers uninstall uninstall-headers
56
57 all-before:
58         @mkdir -p build lib
59
60 clean:
61         @$(MAKE) -C doc clean
62         @$(MAKE) -C samples clean
63         rm -fr build lib
64
65 doc:
66         $(MAKE) -C doc all
67
68 install: all
69         @mkdir -v -p "$(DESTDIR)/$(LIBDIR_INSTALL)"
70         cp "lib/$(LIBNAME)" "$(DESTDIR)/$(LIBDIR_INSTALL)/$(LIBNAME).$(VERSION)"
71         $(STRIP) "$(DESTDIR)/$(LIBDIR_INSTALL)/$(LIBNAME).$(VERSION)"
72         ldconfig -n "$(DESTDIR)/$(LIBDIR_INSTALL)"
73
74 install-headers: all
75         @mkdir -v -p "$(DESTDIR)/$(INCLUDEDIR)"
76         @rm -fr "$(DESTDIR)/$(INCLUDEDIR)/nmea"
77         cp -r include/nmea "$(DESTDIR)/$(INCLUDEDIR)"
78
79 uninstall:
80         rm -f "$(DESTDIR)/$(LIBDIR_INSTALL)/$(LIBNAME)" "$(DESTDIR)/$(LIBDIR_INSTALL)/$(LIBNAME).$(VERSION)"
81         ldconfig -n "$(DESTDIR)/$(LIBDIR_INSTALL)"
82         @rmdir -v -p --ignore-fail-on-non-empty "$(DESTDIR)/$(LIBDIR_INSTALL)"
83
84 uninstall-headers:
85         rm -fr "$(DESTDIR)/$(INCLUDEDIR)/nmea"
86         @rmdir -v -p --ignore-fail-on-non-empty "$(DESTDIR)/$(INCLUDEDIR)"