From fa3e80eb7cc603489d71ca1fae2b95c16e29c7bd Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 15 Apr 2014 11:02:05 +0100 Subject: [PATCH] Build and install a shared library on unix platforms. Copied from Perforce Change: 185543 ServerID: perforce.ravenbrook.com --- mps/Makefile.in | 6 +- mps/code/comm.gmk | 20 ++-- mps/code/mps.xcodeproj/project.pbxproj | 153 +++++++++++++++++++++++++ 3 files changed, 169 insertions(+), 10 deletions(-) diff --git a/mps/Makefile.in b/mps/Makefile.in index 2d558588673..ccc56ff2bd4 100644 --- a/mps/Makefile.in +++ b/mps/Makefile.in @@ -1,7 +1,7 @@ # Makefile.in -- source for autoconf Makefile # # $Id$ -# Copyright (C) 2012-2013 Ravenbrook Limited. See end of file for license. +# Copyright (C) 2012-2014 Ravenbrook Limited. See end of file for license. # # YOU DON'T NEED AUTOCONF TO BUILD THE MPS # This is just here for people who want or expect a configure script. @@ -30,7 +30,9 @@ clean-make-build: install-make-build: make-install-dirs build-via-make $(INSTALL_DATA) code/mps*.h $(prefix)/include/ $(INSTALL_DATA) code/$(MPS_TARGET_NAME)/cool/mps.a $(prefix)/lib/libmps-debug.a + $(INSTALL_DATA) code/$(MPS_TARGET_NAME)/cool/libmps.so $(prefix)/lib/libmps-debug.so $(INSTALL_DATA) code/$(MPS_TARGET_NAME)/hot/mps.a $(prefix)/lib/libmps.a + $(INSTALL_DATA) code/$(MPS_TARGET_NAME)/hot/libmps.so $(prefix)/lib/libmps.so $(INSTALL_PROGRAM) $(addprefix code/$(MPS_TARGET_NAME)/hot/Release/,$(EXTRA_TARGETS)) $(prefix)/bin build-via-xcode: @@ -44,7 +46,9 @@ clean-xcode-build: install-xcode-build: make-install-dirs build-via-xcode $(INSTALL_DATA) code/mps*.h $(prefix)/include/ $(INSTALL_DATA) code/xc/Debug/libmps.a $(prefix)/lib/libmps-debug.a + $(INSTALL_DATA) code/xc/Debug/libmps.dylib $(prefix)/lib/libmps-debug.dylib $(INSTALL_DATA) code/xc/Release/libmps.a $(prefix)/lib/libmps.a + $(INSTALL_DATA) code/xc/Release/libmps.dylib $(prefix)/lib/libmps.dylib $(INSTALL_PROGRAM) $(addprefix code/xc/Release/,$(EXTRA_TARGETS)) $(prefix)/bin Makefile: Makefile.in config.status diff --git a/mps/code/comm.gmk b/mps/code/comm.gmk index 70fed15d507..ce46bba68f4 100644 --- a/mps/code/comm.gmk +++ b/mps/code/comm.gmk @@ -170,7 +170,7 @@ MPMCOMMON = abq.c arena.c arenacl.c arenavm.c arg.c boot.c bt.c \ global.c ld.c locus.c message.c meter.c mpm.c mpsi.c nailboard.c \ pool.c poolabs.c poolmfs.c poolmrg.c poolmv.c protocol.c range.c \ ref.c reserv.c ring.c root.c sa.c sac.c seg.c shield.c splay.c ss.c \ - table.c trace.c traceanc.c tract.c tree.c walk.c + table.c trace.c traceanc.c tract.c tree.c version.c walk.c MPM = $(MPMCOMMON) $(MPMPF) @@ -223,7 +223,7 @@ endif # %%TARGET: When adding a new target, add it to one of the variables # in this section. Library components go in LIB_TARGETS. -LIB_TARGETS=mps.a mpsplan.a +LIB_TARGETS=mps.a libmps.so # Test executables go in TEST_TARGETS. @@ -352,10 +352,10 @@ endif # %%VARIETY: When adding a new variety, add a rule for how to build the # MPS library for the variety. -$(PFM)/rash/mps.a: $(PFM)/rash/mps.o -$(PFM)/hot/mps.a: $(PFM)/hot/mps.o +$(PFM)/rash/libmps.so $(PFM)/rash/mps.a: $(PFM)/rash/mps.o +$(PFM)/hot/libmps.so $(PFM)/hot/mps.a: $(PFM)/hot/mps.o -$(PFM)/cool/mps.a: \ +$(PFM)/cool/libmps.so $(PFM)/cool/mps.a: \ $(MPMOBJ) $(AMCOBJ) $(AMSOBJ) $(AWLOBJ) $(LOOBJ) $(SNCOBJ) \ $(MV2OBJ) $(MVFFOBJ) $(PLINTHOBJ) $(POOLNOBJ) @@ -508,8 +508,6 @@ $(PFM)/$(VARIETY)/replay: $(PFM)/$(VARIETY)/replay.o \ $(PFM)/$(VARIETY)/table.o \ $(PFM)/$(VARIETY)/mps.a -$(PFM)/$(VARIETY)/mpsplan.a: $(PLINTHOBJ) - endif @@ -604,10 +602,14 @@ endif $(PFM)/$(VARIETY)/%.a: $(ECHO) "$(PFM): $@" rm -f $@ - $(CC) $(CFLAGS) -c -o $(PFM)/$(VARIETY)/version.o version.c - $(AR) $(ARFLAGS) $@ $^ $(PFM)/$(VARIETY)/version.o + $(AR) $(ARFLAGS) $@ $^ $(RANLIB) $@ +$(PFM)/$(VARIETY)/%.so: + $(ECHO) "$(PFM): $@" + rm -f $@ + $(CC) $(CFLAGS) $(LINKFLAGS) -shared -o $@ $^ + # Executable $(PFM)/$(VARIETY)/%: diff --git a/mps/code/mps.xcodeproj/project.pbxproj b/mps/code/mps.xcodeproj/project.pbxproj index 88f110bab01..b3547175c39 100644 --- a/mps/code/mps.xcodeproj/project.pbxproj +++ b/mps/code/mps.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ ); dependencies = ( 3104AFF6156D37BC000A585A /* PBXTargetDependency */, + 223A19AB18FD2CF300AF81C1 /* PBXTargetDependency */, 3114A644156E94FB001E0AA3 /* PBXTargetDependency */, 22FACEF1188809B5000FDBC1 /* PBXTargetDependency */, 3104AFF8156D37BE000A585A /* PBXTargetDependency */, @@ -85,6 +86,7 @@ 2231BB6118CA97DC002D6322 /* libmps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 31EEABFB156AAF9D00714D05 /* libmps.a */; }; 2231BB6A18CA984F002D6322 /* locusss.c in Sources */ = {isa = PBXBuildFile; fileRef = 2231BB6918CA983C002D6322 /* locusss.c */; }; 2231BB6B18CA9861002D6322 /* locbwcss.c in Sources */ = {isa = PBXBuildFile; fileRef = 2231BB6818CA9834002D6322 /* locbwcss.c */; }; + 223A19AC18FD2D2900AF81C1 /* mps.c in Sources */ = {isa = PBXBuildFile; fileRef = 31A47BA3156C1E130039B1C2 /* mps.c */; }; 224CC791175E1821002FF81B /* testlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 31EEAC9E156AB73400714D05 /* testlib.c */; }; 224CC793175E1821002FF81B /* libmps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 31EEABFB156AAF9D00714D05 /* libmps.a */; }; 224CC79F175E321C002FF81B /* mv2test.c in Sources */ = {isa = PBXBuildFile; fileRef = 3114A686156E9674001E0AA3 /* mv2test.c */; }; @@ -315,6 +317,13 @@ remoteGlobalIDString = 2231BB5A18CA97DC002D6322; remoteInfo = locusss; }; + 223A19AA18FD2CF300AF81C1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 31EEABDA156AAE9E00714D05 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 223A19A418FD2CE200AF81C1; + remoteInfo = "mps-shared"; + }; 224CC78E175E1821002FF81B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 31EEABDA156AAE9E00714D05 /* Project object */; @@ -1327,6 +1336,7 @@ 2231BB6718CA97DC002D6322 /* locusss */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = locusss; sourceTree = BUILT_PRODUCTS_DIR; }; 2231BB6818CA9834002D6322 /* locbwcss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = locbwcss.c; sourceTree = ""; }; 2231BB6918CA983C002D6322 /* locusss.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = locusss.c; sourceTree = ""; }; + 223A19A518FD2CE200AF81C1 /* libmps.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libmps.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 224CC799175E1821002FF81B /* fotest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fotest; sourceTree = BUILT_PRODUCTS_DIR; }; 224CC79E175E3202002FF81B /* fotest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fotest.c; sourceTree = ""; }; 22561A9618F4263300372C66 /* testthr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testthr.h; sourceTree = ""; }; @@ -1652,6 +1662,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 223A19A218FD2CE200AF81C1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 224CC792175E1821002FF81B /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -2266,6 +2283,7 @@ 22FACEED18880983000FDBC1 /* airtest */, 22C2ACAF18BE400A006B3677 /* nailboardtest */, 22F846BD18F437B900982BA7 /* lockut */, + 223A19A518FD2CE200AF81C1 /* libmps.dylib */, ); name = Products; sourceTree = ""; @@ -2441,6 +2459,13 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 223A19A318FD2CE200AF81C1 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 31EEABF9156AAF9D00714D05 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -2487,6 +2512,23 @@ productReference = 2231BB6718CA97DC002D6322 /* locusss */; productType = "com.apple.product-type.tool"; }; + 223A19A418FD2CE200AF81C1 /* mps-shared */ = { + isa = PBXNativeTarget; + buildConfigurationList = 223A19A918FD2CE300AF81C1 /* Build configuration list for PBXNativeTarget "mps-shared" */; + buildPhases = ( + 223A19A118FD2CE200AF81C1 /* Sources */, + 223A19A218FD2CE200AF81C1 /* Frameworks */, + 223A19A318FD2CE200AF81C1 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "mps-shared"; + productName = "mps-shared"; + productReference = 223A19A518FD2CE200AF81C1 /* libmps.dylib */; + productType = "com.apple.product-type.library.dynamic"; + }; 224CC78C175E1821002FF81B /* fotest */ = { isa = PBXNativeTarget; buildConfigurationList = 224CC795175E1821002FF81B /* Build configuration list for PBXNativeTarget "fotest" */; @@ -3313,6 +3355,7 @@ 3104AFF1156D37A0000A585A /* all */, 22CDE8EF16E9E97D00366D0A /* testrun */, 31EEABFA156AAF9D00714D05 /* mps */, + 223A19A418FD2CE200AF81C1 /* mps-shared */, 3114A632156E94DB001E0AA3 /* abqtest */, 22FACEE018880983000FDBC1 /* airtest */, 3124CAEA156BE7F300753214 /* amcss */, @@ -3399,6 +3442,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 223A19A118FD2CE200AF81C1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 223A19AC18FD2D2900AF81C1 /* mps.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 224CC78F175E1821002FF81B /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3896,6 +3947,11 @@ target = 2231BB5A18CA97DC002D6322 /* locusss */; targetProxy = 2231BB6E18CA986D002D6322 /* PBXContainerItemProxy */; }; + 223A19AB18FD2CF300AF81C1 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 223A19A418FD2CE200AF81C1 /* mps-shared */; + targetProxy = 223A19AA18FD2CF300AF81C1 /* PBXContainerItemProxy */; + }; 224CC78D175E1821002FF81B /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 31EEABFA156AAF9D00714D05 /* mps */; @@ -4361,6 +4417,94 @@ }; name = RASH; }; + 223A19A618FD2CE200AF81C1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + EXECUTABLE_PREFIX = lib; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + MACOSX_DEPLOYMENT_TARGET = 10.9; + PRODUCT_NAME = mps; + }; + name = Debug; + }; + 223A19A718FD2CE200AF81C1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + EXECUTABLE_PREFIX = lib; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + MACOSX_DEPLOYMENT_TARGET = 10.9; + PRODUCT_NAME = mps; + }; + name = Release; + }; + 223A19A818FD2CE200AF81C1 /* RASH */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + EXECUTABLE_PREFIX = lib; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + MACOSX_DEPLOYMENT_TARGET = 10.9; + PRODUCT_NAME = mps; + }; + name = RASH; + }; 224CC796175E1821002FF81B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -5577,6 +5721,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 223A19A918FD2CE300AF81C1 /* Build configuration list for PBXNativeTarget "mps-shared" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 223A19A618FD2CE200AF81C1 /* Debug */, + 223A19A718FD2CE200AF81C1 /* Release */, + 223A19A818FD2CE200AF81C1 /* RASH */, + ); + defaultConfigurationIsVisible = 0; + }; 224CC795175E1821002FF81B /* Build configuration list for PBXNativeTarget "fotest" */ = { isa = XCConfigurationList; buildConfigurations = (