cli: don't commit, if the savedir was overwritten
[project/uci.git] / Makefile
1 VERSION=0.1
2
3 COPTS=-O2
4 WOPTS=-pedantic -Wno-unused -Werror
5 FPIC=-fPIC
6 CFLAGS=$(COPTS) $(WOPTS) -Wall -std=gnu99
7
8 AR=ar
9 LD=ld
10 CC=gcc
11 LIBS=-lc
12 RANLIB=ranlib
13
14 ifneq ($(DEBUG),)
15   COPTS = -O0
16   CFLAGS += -g3 -DDEBUG_ALL
17 endif
18 OS=$(shell uname)
19 ifeq ($(OS),Darwin)
20   LINK=$(LD)
21   SHLIB_EXT=dylib
22   SHLIB_FLAGS=-dylib
23 else
24   LINK=$(CC)
25   SHLIB_EXT=so
26   SHLIB_FLAGS=-shared -Wl,-soname,$(SHLIB_FILE)
27 endif
28 SHLIB_FILE=libuci.$(SHLIB_EXT).$(VERSION)
29
30 all: uci-static uci libuci.$(SHLIB_EXT)
31
32 cli.o: cli.c uci.h
33
34 uci: cli.o libuci.$(SHLIB_EXT)
35         $(CC) -o $@ $< -L. -luci
36
37 uci-static: cli.o libuci.a
38         $(CC) $(CFLAGS) -o $@ $^
39
40 libuci-static.o: libuci.c file.c uci.h list.c err.h util.c
41         $(CC) $(CFLAGS) -c -o $@ $<
42
43 libuci-shared.o: libuci.c file.c uci.h list.c err.h util.c
44         $(CC) $(CFLAGS) $(FPIC) -c -o $@ $<
45
46 libuci.a: libuci-static.o
47         rm -f $@
48         $(AR) rc $@ $^
49         $(RANLIB) $@
50
51 libuci.$(SHLIB_EXT): libuci-shared.o
52         $(LINK) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $^ $(LIBS)
53         ln -sf $(SHLIB_FILE) $@
54
55 clean:
56         rm -f uci uci-static *.[oa] *.so* *.dylib*