X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=Makefile;h=3e1d7ac74f3175a69e845454bbbae6737d61319a;hp=8f1371d1882ff3294cd2209ed2da44866bfb3fc3;hb=c7430fd3578af03d9fe998f3195756603295ce2f;hpb=d11b68d88492b776de59a3ecf5536fb92539a70c diff --git a/Makefile b/Makefile index 8f1371d..3e1d7ac 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,35 @@ -VERSION=0.3 +VERSION=0.6 -COPTS=-O2 -WOPTS=-pedantic -Wno-unused -Werror -FPIC=-fPIC -CFLAGS=$(COPTS) $(WOPTS) -Wall -std=gnu99 +# optional features +PLUGIN_SUPPORT=1 +DEBUG=0 +DEBUG_TYPECAST=0 + +include Makefile.inc -AR=ar -LD=ld -CC=gcc LIBS=-lc -RANLIB=ranlib - -ifneq ($(DEBUG),) - COPTS = -O0 - CFLAGS += -g3 -DDEBUG_ALL -endif -OS=$(shell uname) -ifeq ($(OS),Darwin) - LINK=$(LD) - SHLIB_EXT=dylib - SHLIB_FLAGS=-dylib -else - LINK=$(CC) - SHLIB_EXT=so - SHLIB_FLAGS=-shared -Wl,-soname,$(SHLIB_FILE) -endif SHLIB_FILE=libuci.$(SHLIB_EXT).$(VERSION) -LIBUCI_DEPS=file.c history.c list.c util.c err.h uci.h +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 all: uci-static uci libuci.$(SHLIB_EXT) -cli.o: cli.c uci.h +cli.o: cli.c uci.h uci_config.h + +uci_config.h: FORCE + @rm -f "$@.tmp" + $(call add_feature,PLUGIN_SUPPORT) + $(call add_feature,DEBUG) + $(call add_feature,DEBUG_TYPECAST) + @if [ \! -f "$@" ] || ! cmp "$@.tmp" "$@" >/dev/null; then \ + mv "$@.tmp" "$@"; \ + else \ + rm -f "$@.tmp"; \ + fi uci: cli.o libuci.$(SHLIB_EXT) $(CC) -o $@ $< -L. -luci @@ -55,4 +53,18 @@ libuci.$(SHLIB_EXT): libuci-shared.o ln -sf $(SHLIB_FILE) $@ clean: - rm -f uci uci-static *.[oa] *.so* *.dylib* + rm -f uci uci-static *.[oa] *.so* *.dylib* uci_config.h + +install: all + $(MKDIR) -p $(DESTDIR)$(prefix)/lib + $(INSTALL) -m0644 libuci.a $(DESTDIR)$(prefix)/lib/ + $(INSTALL) -m0755 $(SHLIB_FILE) $(DESTDIR)$(prefix)/lib/ + ln -sf $(SHLIB_FILE) $(DESTDIR)$(prefix)/lib/libuci.$(SHLIB_EXT) + $(MKDIR) -p $(DESTDIR)$(prefix)/bin + $(INSTALL) -m0755 uci $(DESTDIR)$(prefix)/bin/ + +test: all + make -C test + +FORCE: ; +.PHONY: FORCE