From 2f97ef57d330df4047cf14f5d3f854df1b75e8e0 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Tue, 27 Jan 2015 15:05:53 +0100 Subject: [PATCH] Change Makefile to differentiate between static and shared library Previously, just the static libraries (libwren*.a) were created. In the Makefile documentation these were mentioned in the comments as shared. Now both variants will be created. --- .gitignore | 4 +++- Makefile | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 02fbb5f0..8830ad32 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ wrend wren-cpp libwren.a libwrend.a +libwren.so +libwrend.so libwren-cpp.a # XCode user-specific stuff. @@ -23,4 +25,4 @@ benchmark/baseline.txt # built docs get copied here, which is presumed to be a separate checkout of # the repo so they can be pushed to GitHub Pages. -gh-pages/ \ No newline at end of file +gh-pages/ diff --git a/Makefile b/Makefile index 32d86a10..153ef4cc 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ SOURCES := $(wildcard src/*.c) HEADERS := $(wildcard src/*.h) OBJECTS := $(SOURCES:.c=.o) -# Don't include main.c in the shared library. +# Don't include main.c in the libraries. DEBUG_OBJECTS := $(addprefix build/debug/, $(notdir $(OBJECTS))) RELEASE_OBJECTS := $(addprefix build/release/, $(notdir $(OBJECTS))) RELEASE_CPP_OBJECTS := $(addprefix build/release-cpp/, $(notdir $(OBJECTS))) @@ -38,18 +38,22 @@ RELEASE_CPP_LIB_OBJECTS := $(subst build/release-cpp/main.o,,$(RELEASE_CPP_OBJEC all: release clean: - @rm -rf build wren wrend libwren.a libwrend.a + @rm -rf build wren wrend libwren.a libwrend.a libwren.so libwrend.so prep: @mkdir -p build/debug build/release build/release-cpp # Debug build. -debug: prep wrend libwrend.a +debug: prep wrend libwrend.a libwrend.so -# Debug shared library. +# Debug static library. libwrend.a: $(DEBUG_LIB_OBJECTS) $(AR) $@ $^ +# Debug shared library. +libwrend.so: $(DEBUG_LIB_OBJECTS) + $(CC) $(DEBUG_CFLAGS) -shared -Wl,-soname,$@ -o $@ $^ + # Debug command-line interpreter. wrend: $(DEBUG_OBJECTS) $(CC) $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -o $@ $^ -lm @@ -59,12 +63,16 @@ build/debug/%.o: src/%.c include/wren.h $(HEADERS) $(CC) -c $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -o $@ $< # Release build. -release: prep wren libwren.a +release: prep wren libwren.a libwren.so -# Release shared library. +# Release static library. libwren.a: $(RELEASE_LIB_OBJECTS) $(AR) $@ $^ +# Release shared library. +libwren.so: $(RELEASE_LIB_OBJECTS) + $(CC) $(RELEASE_CFLAGS) -shared -Wl,-soname,$@ -o $@ $^ + # Release command-line interpreter. wren: $(RELEASE_OBJECTS) $(CC) $(CFLAGS) $(RELEASE_CFLAGS) -Iinclude -o $@ $^ -lm @@ -76,7 +84,7 @@ build/release/%.o: src/%.c include/wren.h $(HEADERS) # Release C++ build. release-cpp: prep wren-cpp libwren-cpp.a -# Release C++ shared lib +# Release C++ static lib libwren-cpp.a: $(RELEASE_CPP_LIB_OBJECTS) $(AR) $@ $^