improve VERBOSE handling
[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 ifeq ($(VERBOSE),0)
49         @echo "[LD] $@"
50 endif
51         $(MAKECMDPREFIX)$(CC) -shared -Wl,-soname=$(SONAME) $(LIBRARIES) -o "$@" $(OBJECTS_C)
52
53 $(BUILD_DIR)/%.o: $(SRC_DIR_C)/%.c $(INC_DIR_C)/compiler.h
54 ifeq ($(VERBOSE),0)
55         @echo "[CC] $<"
56 endif
57         $(MAKECMDPREFIX)$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c -o "$@" "$<"
58
59 .gitignore:
60 ifeq ($(VERBOSE),0)
61         @echo "[$@]"
62 endif
63         $(MAKECMDPREFIX)echo "/$(BUILD_DIR)/" > $@
64         $(MAKECMDPREFIX)echo "/$(LIBDIR_BUILD)/" >> $@
65         $(MAKECMDPREFIX)$(MAKE) -C doc $@
66
67
68 #
69 # Phony Targets
70 #
71
72 prepare:
73         $(MAKECMDPREFIX)mkdir -p "$(BUILD_DIR)" "$(LIBDIR_BUILD)"
74
75 clean: doc-clean
76 ifeq ($(VERBOSE),0)
77         @echo "[$@]"
78 endif
79         $(MAKECMDPREFIX)rm -fr "$(BUILD_DIR)" "$(LIBDIR_BUILD)" "$(SRC_DIR_C)/"*.d
80
81 doc:
82         $(MAKECMDPREFIX)$(MAKE) -C doc all
83
84 doc-clean:
85         $(MAKECMDPREFIX)$(MAKE) -C doc clean
86
87 install: all
88         mkdir -v -p "$(LIBDIR)"
89         cp "$(LIBDIR_BUILD)/$(SONAME)" "$(LIBDIR)/$(SONAME).$(PLUGIN_VER)"
90         $(STRIP) "$(LIBDIR)/$(SONAME).$(PLUGIN_VER)"
91         /sbin/ldconfig -n "$(LIBDIR)"
92
93 install-headers:
94         rm -fr "$(INCLUDEDIR)/$(PROJECT)"
95         mkdir -v -p "$(INCLUDEDIR)/$(PROJECT)"
96         cp -t "$(INCLUDEDIR)/$(PROJECT)" $(INC_DIR_C)/*.h
97
98 uninstall:
99         rm -f "$(LIBDIR)/$(SONAME)" \
100               "$(LIBDIR)/$(SONAME).$(PLUGIN_VER)"
101         /sbin/ldconfig -n "$(LIBDIR)"
102         rmdir -v -p --ignore-fail-on-non-empty \
103           "$(LIBDIR)"
104
105 uninstall-headers:
106         rm -fr "$(INCLUDEDIR)/$(PROJECT)/"*.h
107         rmdir -v -p --ignore-fail-on-non-empty \
108           "$(INCLUDEDIR)/$(PROJECT)"