From 78660b2d49322d67c7d90b83e79be875ac5edf66 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 24 Nov 2011 11:16:13 +0100 Subject: build: build static lib and make shared lib optional --- Makefile | 26 +++++++++++++++++++++----- README | 8 ++++++++ 2 files changed, 29 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) diff --git a/README b/README index 083ad31..2a39bce 100644 --- a/README +++ b/README @@ -1,2 +1,10 @@ libuniso is a simple C library to extract iso9660 images on the fly +To build: + + make + +To build with shared library: + + make ENABLE_SHARED_LIB=yes + -- cgit v1.2.3