summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-11-24 11:16:13 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2011-11-24 11:17:49 +0100
commit78660b2d49322d67c7d90b83e79be875ac5edf66 (patch)
treed06d3a354913543882bee232aef02e15878b55fc /Makefile
parente77b89cfe05730f09428e81c1775bf21c0846640 (diff)
downloadlibuniso-78660b2d49322d67c7d90b83e79be875ac5edf66.tar.bz2
libuniso-78660b2d49322d67c7d90b83e79be875ac5edf66.tar.xz
build: build static lib and make shared lib optional
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile26
1 files changed, 21 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index e046c3b..63987bb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,35 +1,51 @@
+-include config.mk
ABI_VERSION := 0
SONAME := libuniso.so.$(ABI_VERSION)
-TARGETS := $(SONAME) libuniso.so uniso
+TARGETS := libuniso.a uniso
CFLAGS ?= -g -Wall -Werror
CFLAGS += -fPIC
CFLAGS += -I.
-$(SONAME)_OBJS = libuniso.o
+libuniso.a_OBJS = libuniso.o
+
+$(SONAME)_OBJS = $(libuniso.a_OBJS)
$(SONAME)_LDFLAGS = -shared -Wl,-soname,$(SONAME)
uniso_OBJS := uniso.o
-uniso_LIBS := -luniso
uniso_LDFLAGS += -L.
all: $(TARGETS)
+ifneq ($(ENABLE_SHARED_LIB),)
+shlibs-y += $(SONAME) libuniso.so
+uniso_LIBS := -luniso
+else
+uniso_LIBS := libuniso.a
+endif
+TARGETS += $(shlibs-y)
+
$(SONAME): $($(SONAME)_OBJS)
libuniso.so: $(SONAME)
ln -s $< $@
+uniso: $(shlib-y)
+
+libuniso.a: $(libuniso.a_OBJS)
+ $(AR) rcs $@ $^
+
%.o: %.c
$(CC) $(CFLAGS) $($@_CFLAGS) -c $^
-uniso: $(uniso_OBJS) libuniso.so
+uniso: $(uniso_OBJS) $(shlibs-y)
uniso $(SONAME):
$(CC) $(LDFLAGS) $($@_LDFLAGS) -o $@ $($@_OBJS) $($@_LIBS)
clean:
- rm -f $(TARGETS) *.o
+ rm -f $(TARGETS) *.o *.a *.so *.so.$(ABI_VERSION)
+shared: $(SONAME)