X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=Makefile;h=8062bd410042dfa254787dfbb57fbf700a733aa1;hp=11bb472bd63d4fada38667fc53e9d2ba5122aef5;hb=862bdfa26c2f016e2db67dc700d87ca4cf24a6e9;hpb=c81b25ffd34632dc6ac56fe61faaf44eca822259 diff --git a/Makefile b/Makefile index 11bb472..8062bd4 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,19 @@ define add_feature @echo "$(if $(findstring 1,$($(1))),#define UCI_$(1) 1,#undef UCI_$(1))" >> $@.tmp endef -LIBUCI_DEPS=file.c history.c list.c util.c uci.h uci_config.h uci_internal.h +define add_dep +$(1).shared.o: $(2) +$(1).static.o: $(2) +endef + +SOURCES = libuci.c file.c ucimap.c util.c delta.c all: uci libuci.$(SHLIB_EXT) uci-static ucimap-example +$(eval $(call add_dep,libuci,list.c uci.h uci_config.h uci_internal.h)) +$(eval $(call add_dep,ucimap,uci.h uci_config.h ucimap.h)) + cli.o: cli.c uci.h uci_config.h -ucimap.o: ucimap.c uci.h uci_config.h ucimap.h uci_config.h: FORCE @rm -f "$@.tmp" @@ -36,33 +43,30 @@ uci_config.h: FORCE %.o: %.c $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $< -%-shared.o: %.c - $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(FPIC) $< - -%-static.o: %.c +%.static.o: %.c $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $< +%.shared.o: %.c + $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(FPIC) $< + uci: cli.o libuci.$(SHLIB_EXT) $(CC) -o $@ $< -L. -luci $(LIBS) uci-static: cli.o libuci.a $(CC) $(CFLAGS) -o $@ $^ $(LIBS) -libuci-static.o: libuci.c $(LIBUCI_DEPS) -libuci-shared.o: libuci.c $(LIBUCI_DEPS) -ucimap-static.o: ucimap.c $(LIBUCI_DEPS) ucimap.h -ucimap-shared.o: ucimap.c $(LIBUCI_DEPS) ucimap.h +ucimap.c: ucimap.h uci.h -libuci.a: libuci-static.o ucimap-static.o +libuci.a: $(patsubst %.c,%.static.o, $(SOURCES)) rm -f $@ $(AR) rc $@ $^ $(RANLIB) $@ -libuci.$(SHLIB_EXT): libuci-shared.o ucimap-shared.o +libuci.$(SHLIB_EXT): $(patsubst %.c,%.shared.o, $(SOURCES)) $(LINK) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $^ $(LIBS) ln -sf $(SHLIB_FILE) $@ -ucimap-example.o: ucimap-example.c list.h +ucimap-example.c: list.h ucimap-example: ucimap-example.o libuci.a $(CC) $(CFLAGS) -o $@ $^ $(LIBS) @@ -72,15 +76,15 @@ clean: install: install-bin install-dev install-dev: all - $(MKDIR) -p $(DESTDIR)$(prefix)/lib + $(MKDIR) -p $(DESTDIR)$(prefix)/$(LIBDIRNAME) $(MKDIR) -p $(DESTDIR)$(prefix)/include - $(INSTALL) -m0644 libuci.a $(DESTDIR)$(prefix)/lib/ + $(INSTALL) -m0644 libuci.a $(DESTDIR)$(prefix)/$(LIBDIRNAME)/ $(INSTALL) -m0644 uci_config.h uci.h ucimap.h $(DESTDIR)$(prefix)/include/ install-bin: all - $(MKDIR) -p $(DESTDIR)$(prefix)/lib - $(INSTALL) -m0755 $(SHLIB_FILE) $(DESTDIR)$(prefix)/lib/ - ln -sf $(SHLIB_FILE) $(DESTDIR)$(prefix)/lib/libuci.$(SHLIB_EXT) + $(MKDIR) -p $(DESTDIR)$(prefix)/$(LIBDIRNAME) + $(INSTALL) -m0755 $(SHLIB_FILE) $(DESTDIR)$(prefix)/$(LIBDIRNAME)/ + ln -sf $(SHLIB_FILE) $(DESTDIR)$(prefix)/$(LIBDIRNAME)/libuci.$(SHLIB_EXT) $(MKDIR) -p $(DESTDIR)$(prefix)/bin $(INSTALL) -m0755 uci $(DESTDIR)$(prefix)/bin/