X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=Makefile;h=989f89056c577dd416225e5296193cfdbed42c99;hp=1e0fce371d132da92cec2d35ef4d34bf2327c1a8;hb=2b4872345ab2b49b521f2d7a70a8ed91dbcf7732;hpb=23a794e9c2e3bf39550e46c0bafe544cf6c617e8 diff --git a/Makefile b/Makefile index 1e0fce3..989f890 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,56 @@ -COPTS=-g -O2 -CFLAGS=$(COPTS) -fPIC -Wall -pedantic -std=gnu99 -Wno-unused -Werror +VERSION=0.1 + +COPTS=-O2 +WOPTS=-pedantic -Wno-unused -Werror +FPIC=-fPIC +CFLAGS=$(COPTS) $(WOPTS) -Wall -std=gnu99 AR=ar +LD=ld CC=gcc +LIBS=-lc RANLIB=ranlib -all: uci +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) + +all: uci-static uci libuci.$(SHLIB_EXT) cli.o: cli.c uci.h -uci: cli.o libuci.a + +uci: cli.o libuci.$(SHLIB_EXT) + $(CC) -o $@ $< -L. -luci + +uci-static: cli.o libuci.a $(CC) $(CFLAGS) -o $@ $^ -libuci.o: libuci.c parse.c uci.h list.c err.h -libuci.a: libuci.o +libuci-static.o: libuci.c file.c uci.h list.c err.h util.c + $(CC) $(CFLAGS) -c -o $@ $< + +libuci-shared.o: libuci.c file.c uci.h list.c err.h util.c + $(CC) $(CFLAGS) $(FPIC) -c -o $@ $< + +libuci.a: libuci-static.o rm -f $@ $(AR) rc $@ $^ $(RANLIB) $@ +libuci.$(SHLIB_EXT): libuci-shared.o + $(LINK) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $^ $(LIBS) + ln -sf $(SHLIB_FILE) $@ + clean: - rm -f uci *.[oa] + rm -f uci uci-static *.[oa] *.so* *.dylib*