X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=Makefile;h=db690e75a68fef38e645239273bdf2c57229cbf3;hp=645ec65a53a725726bd9b19763d0dfee1d808671;hb=031b620e1f3a16078da45ce00352508764902786;hpb=25424d34314f5da11305104c78cc82beff801e16 diff --git a/Makefile b/Makefile index 645ec65..db690e7 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,58 @@ +VERSION=0.1 + +COPTS=-O2 +WOPTS=-pedantic -Wno-unused -Werror +FPIC=-fPIC +CFLAGS=$(COPTS) $(WOPTS) -Wall -std=gnu99 + +AR=ar +LD=ld CC=gcc -CFLAGS=-g -O2 -Wall -pedantic -std=gnu99 -Wno-unused -Werror +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 + +all: uci-static uci libuci.$(SHLIB_EXT) -all: parsetest -parsetest: libuci.o test.o +cli.o: cli.c uci.h + +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 -test.o: test.c uci.h +libuci-static.o: libuci.c $(LIBUCI_DEPS) + $(CC) $(CFLAGS) -c -o $@ $< + +libuci-shared.o: libuci.c $(LIBUCI_DEPS) + $(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 parsetest *.o + rm -f uci uci-static *.[oa] *.so* *.dylib*