remove ucimap-example during make clean
[project/uci.git] / Makefile
1 VERSION=0.8
2
3 # optional features
4 PLUGIN_SUPPORT=1
5 DEBUG=0
6 DEBUG_TYPECAST=0
7
8 include Makefile.inc
9
10 LIBS=-lc -ldl
11 SHLIB_FILE=libuci.$(SHLIB_EXT).$(VERSION)
12
13 define add_feature
14 @echo "$(if $(findstring 1,$($(1))),#define UCI_$(1) 1,#undef UCI_$(1))" >> $@.tmp
15 endef
16
17 LIBUCI_DEPS=file.c history.c list.c util.c uci.h uci_config.h uci_internal.h
18
19 all: uci-static uci libuci.$(SHLIB_EXT) libucimap.a
20
21 cli.o: cli.c uci.h uci_config.h
22 ucimap.o: ucimap.c uci.h uci_config.h ucimap.h uci_list.h
23
24 uci_config.h: FORCE
25 @rm -f "$@.tmp"
26 @echo "#define UCI_PREFIX \"$(prefix)\"" > "$@.tmp"
27 $(call add_feature,PLUGIN_SUPPORT)
28 $(call add_feature,DEBUG)
29 $(call add_feature,DEBUG_TYPECAST)
30 @if [ \! -f "$@" ] || ! cmp "$@.tmp" "$@" >/dev/null; then \
31 mv "$@.tmp" "$@"; \
32 else \
33 rm -f "$@.tmp"; \
34 fi
35
36 uci: cli.o libuci.$(SHLIB_EXT)
37 $(CC) -o $@ $< -L. -luci $(LIBS)
38
39 uci-static: cli.o libuci.a
40 $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
41
42 libuci-static.o: libuci.c $(LIBUCI_DEPS)
43 $(CC) $(CFLAGS) -c -o $@ $<
44
45 libuci-shared.o: libuci.c $(LIBUCI_DEPS)
46 $(CC) $(CFLAGS) $(FPIC) -c -o $@ $<
47
48 libuci.a: libuci-static.o
49 rm -f $@
50 $(AR) rc $@ $^
51 $(RANLIB) $@
52
53 libucimap.a: ucimap.o
54 rm -f $@
55 $(AR) rc $@ $^
56 $(RANLIB) $@
57
58 libuci.$(SHLIB_EXT): libuci-shared.o
59 $(LINK) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $^ $(LIBS)
60 ln -sf $(SHLIB_FILE) $@
61
62 ucimap-example: ucimap-example.c libuci.a libucimap.a
63 $(CC) $(CFLAGS) -I. -o $@ $^
64
65 clean:
66 rm -f uci uci-static *.[oa] *.so* *.dylib* uci_config.h ucimap-example
67
68 install: install-bin install-dev
69
70 install-dev: all
71 $(MKDIR) -p $(DESTDIR)$(prefix)/lib
72 $(MKDIR) -p $(DESTDIR)$(prefix)/include
73 $(INSTALL) -m0644 libuci.a libucimap.a $(DESTDIR)$(prefix)/lib/
74 $(INSTALL) -m0644 uci_config.h uci.h uci_list.h ucimap.h $(DESTDIR)$(prefix)/include/
75
76 install-bin: all
77 $(MKDIR) -p $(DESTDIR)$(prefix)/lib
78 $(INSTALL) -m0755 $(SHLIB_FILE) $(DESTDIR)$(prefix)/lib/
79 ln -sf $(SHLIB_FILE) $(DESTDIR)$(prefix)/lib/libuci.$(SHLIB_EXT)
80 $(MKDIR) -p $(DESTDIR)$(prefix)/bin
81 $(INSTALL) -m0755 uci $(DESTDIR)$(prefix)/bin/
82
83 test: all ucimap-example
84 make -C test
85
86 FORCE: ;
87 .PHONY: FORCE