projects
/
project
/
uci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
333ef9e
)
add shared library support
author
Felix Fietkau
<nbd@openwrt.org>
Sat, 2 Feb 2008 23:41:32 +0000
(
00:41
+0100)
committer
Felix Fietkau
<nbd@openwrt.org>
Sat, 2 Feb 2008 23:41:32 +0000
(
00:41
+0100)
.gitignore
patch
|
blob
|
history
Makefile
patch
|
blob
|
history
diff --git
a/.gitignore
b/.gitignore
index cfeb965b38795b6fd7f3719bd53bedffbe6568a5..67a25641d564d3321065586c2b06c3fc73534f32 100644
(file)
--- a/
.gitignore
+++ b/
.gitignore
@@
-1,4
+1,7
@@
uci
uci
+uci-static
*.[oa]
*.[oa]
+*.so*
+*.dylib*
.*.swp
.gdb*
.*.swp
.gdb*
diff --git
a/Makefile
b/Makefile
index bcd5676285989f0834520f5a1ea504e655cc38ca..2a072c4f30fc75c940859c0ff7e52fc5ab881d26 100644
(file)
--- a/
Makefile
+++ b/
Makefile
@@
-1,26
+1,54
@@
+VERSION=0.1
+
COPTS=-O2
WOPTS=-pedantic -Wno-unused -Werror
COPTS=-O2
WOPTS=-pedantic -Wno-unused -Werror
-CFLAGS=$(COPTS) -fPIC -Wall -std=gnu99
-ifneq ($(DEBUG),)
- COPTS = -O0
- CFLAGS += -g3 -DDEBUG_ALL
-endif
+FPIC=-fPIC
+CFLAGS=$(COPTS) -Wall -std=gnu99
AR=ar
AR=ar
+LD=ld
CC=gcc
CC=gcc
+LIBS=-lc
RANLIB=ranlib
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
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 $@ $^
$(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) $@
rm -f $@
$(AR) rc $@ $^
$(RANLIB) $@
+libuci.$(SHLIB_EXT): libuci-shared.o
+ $(LD) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $^ $(LIBS)
+ ln -sf $(SHLIB_FILE) $@
+
clean:
clean:
- rm -f uci
*.[oa]
+ rm -f uci
uci-static *.[oa] *.so* *.dylib*