<pre style='margin:0'>
Ken (kencu) pushed a commit to branch master
in repository macports-legacy-support.
</pre>
<p><a href="https://github.com/macports/macports-legacy-support/commit/df3f57a915de5cfc538ffccb474fcb70ed2ac765">https://github.com/macports/macports-legacy-support/commit/df3f57a915de5cfc538ffccb474fcb70ed2ac765</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit df3f57a915de5cfc538ffccb474fcb70ed2ac765
</span>Author: Christian Cornelssen <ccorn@1tein.de>
AuthorDate: Sat Jan 26 02:24:38 2019 +0100
<span style='display:block; white-space:pre;color:#404040;'> Makefile: Build/install a static library in addition to the dylib.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> New convenience sub-targets: `slib`, `dlib`, `install-slib`, `install-dlib`.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> It is possible to add specific CFLAGS for the static resp. dynamic lib.
</span><span style='display:block; white-space:pre;color:#404040;'> This is now used to compile with -fPIC for the dylib (although -fPIC is
</span><span style='display:block; white-space:pre;color:#404040;'> the default on Darwin anyway). Dylib object files are named *.dl.o now.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Note: test programs are linked against the dylib.
</span><span style='display:block; white-space:pre;color:#404040;'> To test the static library, you could run the following command:
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> make clean all check TESTLIBS=lib/lib*.a
</span>---
Makefile | 77 +++++++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 55 insertions(+), 22 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/Makefile b/Makefile
</span><span style='display:block; white-space:pre;color:#808080;'>index 3cc72a7..422fa57 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/Makefile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/Makefile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -18,24 +18,33 @@ PREFIX ?= /usr/local
</span> INCSUBDIR = LegacySupport
PKGINCDIR = $(PREFIX)/include/$(INCSUBDIR)
LIBDIR = $(PREFIX)/lib
<span style='display:block; white-space:pre;background:#e0ffe0;'>+AREXT = .a
</span> SOEXT = .dylib
LIBNAME = MacportsLegacySupport
<span style='display:block; white-space:pre;background:#ffe0e0;'>-LIBFILE = lib$(LIBNAME)$(SOEXT)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-LIBPATH = $(LIBDIR)/$(LIBFILE)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-BUILDLIBDIR = lib
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-BUILDLIBPATH = $(BUILDLIBDIR)/$(LIBFILE)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-BUILDLIBFLAGS = -dynamiclib -headerpad_max_install_names \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- -install_name @executable_path/../$(BUILDLIBPATH) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+DLIBFILE = lib$(LIBNAME)$(SOEXT)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SLIBFILE = lib$(LIBNAME)$(AREXT)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+DLIBPATH = $(LIBDIR)/$(DLIBFILE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SLIBPATH = $(LIBDIR)/$(SLIBFILE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+BUILDDLIBDIR = lib
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+BUILDSLIBDIR = lib
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+BUILDDLIBPATH = $(BUILDDLIBDIR)/$(DLIBFILE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+BUILDSLIBPATH = $(BUILDSLIBDIR)/$(SLIBFILE)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+BUILDDLIBFLAGS = -dynamiclib -headerpad_max_install_names \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ -install_name @executable_path/../$(BUILDDLIBPATH) \
</span> -current_version 1.0 -compatibility_version 1.0
<span style='display:block; white-space:pre;background:#e0ffe0;'>+BUILDSLIBFLAGS = -qs
</span> POSTINSTALL = install_name_tool
<span style='display:block; white-space:pre;background:#ffe0e0;'>-POSTINSTALLFLAGS = -id $(LIBPATH)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+POSTINSTALLFLAGS = -id $(DLIBPATH)
</span>
ARCHFLAGS ?=
CC ?= cc $(ARCHFLAGS)
CFLAGS ?= -Os -Wall
<span style='display:block; white-space:pre;background:#e0ffe0;'>+DLIBCFLAGS ?= -fPIC
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SLIBCFLAGS ?=
</span> CXX ?= c++ $(ARCHFLAGS)
CXXFLAGS ?= -Os -Wall
LDFLAGS ?=
<span style='display:block; white-space:pre;background:#e0ffe0;'>+AR ?= ar
</span>
MKINSTALLDIRS = install -d -m 755
INSTALL_PROGRAM = install -c -m 755
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -50,12 +59,16 @@ FIND_LIBHEADERS := find $(SRCINCDIR) -type f \( -name '*.h' -o \
</span> \( -name 'c*' ! -name '*.*' \) \)
LIBHEADERS := $(shell $(FIND_LIBHEADERS))
ALLHEADERS := $(LIBHEADERS) $(wildcard $(SRCDIR)/*.h)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-LIBOBJECTS := $(patsubst %.c,%.o,$(wildcard $(SRCDIR)/*.c))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+LIBSRCS := $(wildcard $(SRCDIR)/*.c)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+DLIBOBJEXT = .dl.o
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SLIBOBJEXT = .o
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+DLIBOBJS := $(patsubst %.c,%$(DLIBOBJEXT),$(LIBSRCS))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SLIBOBJS := $(patsubst %.c,%$(SLIBOBJEXT),$(LIBSRCS))
</span>
TESTDIR = test
TESTNAMEPREFIX = $(TESTDIR)/test_
TESTRUNPREFIX = run_
<span style='display:block; white-space:pre;background:#ffe0e0;'>-TESTLDFLAGS = -L$(BUILDLIBDIR) $(LDFLAGS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+TESTLDFLAGS = -L$(BUILDDLIBDIR) $(LDFLAGS)
</span> TESTLIBS = -l$(LIBNAME)
TESTSRCS_C := $(wildcard $(TESTNAMEPREFIX)*.c)
TESTSRCS_CPP := $(wildcard $(TESTNAMEPREFIX)*.cpp)
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -66,23 +79,36 @@ TESTPRGS_CPP := $(patsubst %.cpp,%,$(TESTSRCS_CPP))
</span> TESTPRGS = $(TESTPRGS_C) $(TESTPRGS_CPP)
TESTRUNS := $(patsubst $(TESTNAMEPREFIX)%,$(TESTRUNPREFIX)%,$(TESTPRGS))
<span style='display:block; white-space:pre;background:#ffe0e0;'>-all: $(BUILDLIBPATH)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+all: dlib slib
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+dlib: $(BUILDDLIBPATH)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+slib: $(BUILDSLIBPATH)
</span>
# Generously marking all header files as potential dependencies
<span style='display:block; white-space:pre;background:#ffe0e0;'>-$(LIBOBJECTS) $(TESTOBJS_C): %.o: %.c $(ALLHEADERS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+$(DLIBOBJS): %$(DLIBOBJEXT): %.c $(ALLHEADERS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(DLIBCFLAGS) $< -o $@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+$(SLIBOBJS): %$(SLIBOBJEXT): %.c $(ALLHEADERS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(CC) -c -I$(SRCINCDIR) $(CFLAGS) $(SLIBCFLAGS) $< -o $@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+$(TESTOBJS_C): %.o: %.c $(ALLHEADERS)
</span> $(CC) -c -I$(SRCINCDIR) $(CFLAGS) $< -o $@
$(TESTOBJS_CPP): %.o: %.cpp $(ALLHEADERS)
$(CXX) -c -I$(SRCINCDIR) $(CXXFLAGS) $< -o $@
<span style='display:block; white-space:pre;background:#ffe0e0;'>-$(BUILDLIBPATH): $(LIBOBJECTS)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- $(MKINSTALLDIRS) $(BUILDLIBDIR)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- $(CC) $(BUILDLIBFLAGS) $(LDFLAGS) $^ -o $@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+$(BUILDDLIBPATH): $(DLIBOBJS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(MKINSTALLDIRS) $(BUILDDLIBDIR)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(CC) $(BUILDDLIBFLAGS) $(LDFLAGS) $^ -o $@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+$(BUILDSLIBPATH): $(SLIBOBJS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(MKINSTALLDIRS) $(BUILDSLIBDIR)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(RM) $@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(AR) $(BUILDSLIBFLAGS) $@ $^
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-$(TESTPRGS_C): %: %.o $(BUILDLIBPATH)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+$(TESTPRGS_C): %: %.o $(BUILDDLIBPATH)
</span> $(CC) $(TESTLDFLAGS) $< $(TESTLIBS) -o $@
<span style='display:block; white-space:pre;background:#ffe0e0;'>-$(TESTPRGS_CPP): %: %.o $(BUILDLIBPATH)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+$(TESTPRGS_CPP): %: %.o $(BUILDDLIBPATH)
</span> $(CXX) $(TESTLDFLAGS) $< $(TESTLIBS) -o $@
$(TESTRUNS): $(TESTRUNPREFIX)%: $(TESTNAMEPREFIX)%
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -97,16 +123,23 @@ install-headers:
</span> $(INSTALL_DATA) $(SRCINCDIR)/"$$h" $(DESTDIR)$(PKGINCDIR)/"$$h"; \
done
<span style='display:block; white-space:pre;background:#ffe0e0;'>-install-lib: $(BUILDLIBPATH)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+install-lib: install-dlib install-slib
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+install-dlib: $(BUILDDLIBPATH)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(MKINSTALLDIRS) $(DESTDIR)$(LIBDIR)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(INSTALL_PROGRAM) $(BUILDDLIBPATH) $(DESTDIR)$(LIBDIR)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(POSTINSTALL) $(POSTINSTALLFLAGS) $(DESTDIR)$(DLIBPATH)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+install-slib: $(BUILDSLIBPATH)
</span> $(MKINSTALLDIRS) $(DESTDIR)$(LIBDIR)
<span style='display:block; white-space:pre;background:#ffe0e0;'>- $(INSTALL_PROGRAM) $(BUILDLIBPATH) $(DESTDIR)$(LIBDIR)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- $(POSTINSTALL) $(POSTINSTALLFLAGS) $(DESTDIR)$(LIBPATH)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(INSTALL_DATA) $(BUILDSLIBPATH) $(DESTDIR)$(LIBDIR)
</span>
test check: $(TESTRUNS)
clean:
$(RM) $(foreach D,$(SRCDIR) $(TESTDIR),$D/*.o $D/*.d)
<span style='display:block; white-space:pre;background:#ffe0e0;'>- $(RM) $(BUILDLIBPATH) $(TESTPRGS)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- @$(RMDIR) $(BUILDLIBDIR)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(RM) $(BUILDDLIBPATH) $(BUILDSLIBPATH) $(TESTPRGS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ @$(RMDIR) $(BUILDDLIBDIR) $(BUILDSLIBDIR)
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-.PHONY: all clean install install-headers install-lib test check $(TESTRUNS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+.PHONY: all dlib slib clean check test $(TESTRUNS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+.PHONY: install install-headers install-lib install-dlib install-slib
</span></pre><pre style='margin:0'>
</pre>