summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-06-17 21:41:26 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-06-17 21:41:26 +0200
commitba07cbb24bd226ead1f8f96b0e969822aa734076 (patch)
treeb7a89cbc9731bbf71b46532c8f3672871645dbaf
parent7d392652bae52b76cb5fe907cc1e86e0e0c4ced9 (diff)
downloadmtdev-git-ba07cbb24bd226ead1f8f96b0e969822aa734076.tar.gz
Output both a static and a dynamic library
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--Makefile29
1 files changed, 18 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 0d81f7a..a8ead25 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ VERSION = 1
PATCHLEVEL = 0
EXTRAVERSION = beta1
-LIBRARY = libmtdev.so
+LIBRARY = libmtdev
MODULES = src
o_src = match iobuf caps core
@@ -15,12 +15,13 @@ OBJECTS = $(addsuffix .o,\
$(addprefix $(mod)/,$(o_$(mod)))))
TBIN = $(addprefix bin/,$(TARGETS))
-TLIB = $(addprefix obj/,$(LIBRARY))
+SLIB = $(addprefix obj/,$(LIBRARY).a)
+DLIB = $(addprefix obj/,$(LIBRARY).so)
TOBJ = $(addprefix obj/,$(addsuffix .o,$(TARGETS)))
OBJS = $(addprefix obj/,$(OBJECTS))
LIBS =
-DLIB = usr/lib
+DESTLIB = usr/lib
INCLUDE = -Iinclude
OPTS = -O3 -fPIC
@@ -28,14 +29,18 @@ OPTS = -O3 -fPIC
.PHONY: all clean
.PRECIOUS: obj/%.o
-all: $(OBJS) $(TLIB) $(TOBJ) $(TBIN)
+all: $(OBJS) $(SLIB) $(DLIB) $(TOBJ) $(TBIN)
-bin/%: obj/%.o $(TLIB)
+bin/%: obj/%.o $(SLIB)
@mkdir -p $(@D)
- gcc $< -o $@ $(TLIB) $(LIBS)
+ gcc $< -o $@ $(SLIB) $(LIBS)
-$(TLIB): $(OBJS) $(XOBJS)
- @rm -f $(TLIB)
+$(SLIB): $(OBJS) $(XOBJS)
+ @rm -f $(SLIB)
+ ar qc $@ $(OBJS) $(XOBJS)
+
+$(DLIB): $(OBJS) $(XOBJS)
+ @rm -f $(DLIB)
gcc -shared $(OBJS) $(XOBJS) -Wl,-soname -Wl,$(LIBRARY) -o $@
obj/%.o: %.c
@@ -48,6 +53,8 @@ clean:
distclean: clean
rm -rf debian/*.log debian/files
-install: $(TLIB) $(TFDI)
- install -d "$(DESTDIR)/$(DLIB)"
- install -m 755 $(TLIB) "$(DESTDIR)/$(DLIB)"
+install: $(SLIB) $(DLIB)
+ install -d $(DESTDIR)/$(DESTLIB)
+ install -m 755 $(SLIB) $(DESTDIR)/$(DESTLIB)
+ install -m 755 $(DLIB) $(DESTDIR)/$(DESTLIB)
+ ldconfig -n $(DESTDIR)/$(DESTLIB)