X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=Makefile;h=051426998e900d28c7c14516b9dae5d3806a5e05;hp=bf194d141faa42773220901e0641c4d06cfc3d84;hb=b12bd89466dfb7adf38b71c039a0d56704492e95;hpb=5f28711b07ec0952720300d8561cfb47774a09db diff --git a/Makefile b/Makefile index bf194d1..0514269 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,55 @@ +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=-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) + SHLIB_EXT=dylib + SHLIB_FLAGS=-dylib +else + LD=$(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 -all: parsetest -parsetest: libuci.o test.o +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 libuci.h list.c err.h -test.o: test.c libuci.h +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 + $(LD) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $^ $(LIBS) + ln -sf $(SHLIB_FILE) $@ clean: - rm -f parsetest *.o + rm -f uci uci-static *.[oa] *.so* *.dylib*