adf7b756701041bd3dc8fa0e1f9d3d9dba63e4ca
[olsrd.git] / lib / pud / wireformat / Makefile
1 include Makefile.inc
2
3 include ../Makefile.inc
4 OLSRD_PLUGIN = false
5
6 TOPDIR = ../../..
7 include $(TOPDIR)/Makefile.inc
8
9 ######################
10 #
11 # Settings
12 #
13 ######################
14
15 DESTDIR ?=
16 USRDIR ?= $(DESTDIR)/usr
17 INCLUDEDIR ?= $(DESTDIR)/usr/include
18 LIBDIR ?= $(USRDIR)/lib
19
20 BUILD_DIR = build
21 LIBDIR_BUILD = lib
22
23
24 INC_DIR_BASE_C = ./include
25 INC_DIR_C = $(INC_DIR_BASE_C)/$(PROJECT)
26 INC_DIR_OLSRD = ../../../src
27
28 MODULES = nodeIdConversion wireFormat
29
30 SRC_DIR_C = src
31 OBJECTS_C = $(MODULES:%=$(BUILD_DIR)/%.o)
32
33 INCLUDES = -I "$(INC_DIR_BASE_C)" -I "$(INC_DIR_OLSRD)"
34 LIBRARIES = -lm
35
36
37 .PHONY: all default_target prepare clean doc doc-clean install install-headers uninstall uninstall-headers
38
39 #
40 # Targets
41 #
42
43 all: default_target
44
45 default_target: prepare $(LIBDIR_BUILD)/$(SONAME)
46
47 $(LIBDIR_BUILD)/$(SONAME): $(OBJECTS_C)
48         @echo "[LD] $@"
49         @$(CC) -shared -Wl,-soname=$(SONAME) $(LIBRARIES) -o "$@" $(OBJECTS_C)
50
51 $(BUILD_DIR)/%.o: $(SRC_DIR_C)/%.c $(INC_DIR_C)/compiler.h
52         @echo "[CC] $<"
53         @$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c -o "$@" "$<"
54
55 .gitignore:
56         @echo "[$@]"
57         @echo "/$(BUILD_DIR)/" > $@
58         @echo "/$(LIBDIR_BUILD)/" >> $@
59         @$(MAKE) -C doc $@
60
61
62 #
63 # Phony Targets
64 #
65
66 prepare:
67         @mkdir -p "$(BUILD_DIR)" "$(LIBDIR_BUILD)"
68
69 clean: doc-clean
70         @echo "[$@]"
71         @rm -fr "$(BUILD_DIR)" "$(LIBDIR_BUILD)" "$(SRC_DIR_C)/"*.d
72
73 doc:
74         @$(MAKE) -C doc all
75
76 doc-clean:
77         @$(MAKE) -C doc clean
78
79 install: all
80         mkdir -v -p "$(LIBDIR)"
81         cp "$(LIBDIR_BUILD)/$(SONAME)" "$(LIBDIR)/$(SONAME).$(PLUGIN_VER)"
82         $(STRIP) "$(LIBDIR)/$(SONAME).$(PLUGIN_VER)"
83         /sbin/ldconfig -n "$(LIBDIR)"
84
85 install-headers:
86         rm -fr "$(INCLUDEDIR)/$(PROJECT)"
87         mkdir -v -p "$(INCLUDEDIR)/$(PROJECT)"
88         cp -t "$(INCLUDEDIR)/$(PROJECT)" $(INC_DIR_C)/*.h
89
90 uninstall:
91         rm -f "$(LIBDIR)/$(SONAME)" \
92               "$(LIBDIR)/$(SONAME).$(PLUGIN_VER)"
93         /sbin/ldconfig -n "$(LIBDIR)"
94         rmdir -v -p --ignore-fail-on-non-empty \
95           "$(LIBDIR)"
96
97 uninstall-headers:
98         rm -fr "$(INCLUDEDIR)/$(PROJECT)/"*.h
99         rmdir -v -p --ignore-fail-on-non-empty \
100           "$(INCLUDEDIR)/$(PROJECT)"