X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=Makefile;h=65a38c776ab333a4923f0138bdd487a14a023562;hp=c136915a734565b736d66bacbd41245e3feff79c;hb=402b084b1e5417dc2fb7d84373c1b9fb8642696a;hpb=a8c552f656dcc429f03de36f3067522d51bb0b68 diff --git a/Makefile b/Makefile index c136915..65a38c7 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,54 @@ +VERSION=0.1 + COPTS=-O2 -CFLAGS=$(COPTS) -fPIC -Wall -pedantic -std=gnu99 -Wno-unused -Werror -ifneq ($(DEBUG),) - COPTS = -O0 - CFLAGS += -g3 -DDEBUG_ALL -endif +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) + SHLIB_EXT=dylib + SHLIB_FLAGS=-dylib +else + 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 file.c uci.h list.c err.h util.c -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 + $(LD) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $^ $(LIBS) + ln -sf $(SHLIB_FILE) $@ + clean: - rm -f uci *.[oa] + rm -f uci uci-static *.[oa] *.so* *.dylib*