Browse Source

support OSX bundle linking (for Python)

David Rose 20 years ago
parent
commit
a23eb2d733
6 changed files with 21 additions and 3 deletions
  1. 1 0
      dtool/Config.Irix.pp
  2. 1 0
      dtool/Config.Linux.pp
  3. 1 0
      dtool/Config.Win32.pp
  4. 1 0
      dtool/Config.osx.pp
  5. 2 0
      dtool/Config.pp
  6. 15 3
      dtool/pptempl/Template.unix.pp

+ 1 - 0
dtool/Config.Irix.pp

@@ -136,3 +136,4 @@
 
 // The dynamic library file extension (usually .so .dll or .dylib):
 #define DYNAMIC_LIB_EXT .so
+#define BUNDLE_EXT

+ 1 - 0
dtool/Config.Linux.pp

@@ -142,3 +142,4 @@
 
 // The dynamic library file extension (usually .so .dll or .dylib):
 #define DYNAMIC_LIB_EXT .so
+#define BUNDLE_EXT

+ 1 - 0
dtool/Config.Win32.pp

@@ -139,5 +139,6 @@
 
 // The dynamic library file extension (usually .so .dll or .dylib):
 #define DYNAMIC_LIB_EXT .dll
+#define BUNDLE_EXT
   
 

+ 1 - 0
dtool/Config.osx.pp

@@ -176,3 +176,4 @@
 
 // The dynamic library file extension (usually .so .dll or .dylib):
 #define DYNAMIC_LIB_EXT .dylib
+#define BUNDLE_EXT .so

+ 2 - 0
dtool/Config.pp

@@ -881,9 +881,11 @@
 #if $[eq $[PLATFORM], osx]
   #defer SHARED_LIB_C $[cc_ld] -o $[target] -install_name $[notdir $[target]] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]]
   #defer SHARED_LIB_C++ $[cxx_ld] -dynamic -dynamiclib -o $[target] -install_name $[notdir $[target]] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]]
+  #defer BUNDLE_LIB_C++ $[cxx_ld] -bundle -o $[target] -install_name $[notdir $[target]] $[sources] $[lpath:%=-L%] $[libs:%=-l%] $[patsubst %,-framework %, $[frameworks]]
 #else
   #defer SHARED_LIB_C $[cc_ld] -shared -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
   #defer SHARED_LIB_C++ $[cxx_ld] -shared -o $[target] $[sources] $[lpath:%=-L%] $[libs:%=-l%]
+  #define BUNDLE_LIB_C++
 #endif
 
 // How to install a data file or executable file.  $[local] is the

+ 15 - 3
dtool/pptempl/Template.unix.pp

@@ -41,6 +41,10 @@
   // list of binaries that are to be built only when specifically asked
   // for.
   #define lib_targets $[active_target(metalib_target lib_target ss_lib_target noinst_lib_target):%=$[ODIR]/lib%$[DYNAMIC_LIB_EXT]]
+  #define bundle_targets
+  #if $[BUNDLE_EXT]
+    #define bundle_targets $[active_target(metalib_target):%=$[ODIR]/lib%$[BUNDLE_EXT]]
+  #endif
 
   #define static_lib_targets $[active_target(static_lib_target):%=$[ODIR]/lib%.a]
   #define bin_targets $[active_target(bin_target noinst_bin_target sed_bin_target):%=$[ODIR]/%]
@@ -188,7 +192,7 @@
 #define all_targets \
     Makefile \
     $[if $[dep_sources],$[DEPENDENCY_CACHE_FILENAME]] \
-    $[sort $[lib_targets] $[static_lib_targets] $[bin_targets]]
+    $[sort $[lib_targets] $[bundle_targets] $[static_lib_targets] $[bin_targets]]
 all : $[all_targets]
 
 // The 'test' rule makes all the test_bin_targets.
@@ -200,8 +204,8 @@ clean : clean-igate
 $[TAB] rm -f $[patsubst %,$[%_obj],$[compile_sources]]
 #endif
 #end metalib_target lib_target noinst_lib_target static_lib_target ss_lib_target bin_target noinst_bin_target test_bin_target test_lib_target
-#if $[lib_targets] $[static_lib_targets] $[bin_targets] $[test_bin_targets]
-$[TAB] rm -f $[lib_targets] $[static_lib_targets] $[bin_targets] $[test_bin_targets]
+#if $[lib_targets] $[bundle_targets] $[static_lib_targets] $[bin_targets] $[test_bin_targets]
+$[TAB] rm -f $[lib_targets] $[bundle_targets] $[static_lib_targets] $[bin_targets] $[test_bin_targets]
 #endif
 #if $[yxx_st_sources] $[lxx_st_sources]
 $[TAB] rm -f $[patsubst %.yxx,%.cxx %.h,$[yxx_st_sources]] $[patsubst %.lxx,%.cxx,$[lxx_st_sources]]
@@ -345,12 +349,20 @@ $[TAB] $[SHARED_LIB_C++]
 $[TAB] $[SHARED_LIB_C]
   #endif
 
+  #if $[BUNDLE_EXT]
+    // Also generate the bundles (on OSX only).
+    #define target $[ODIR]/lib$[TARGET]$[BUNDLE_EXT]
+
+$[target] : $[sources] $[static_lib_dependencies]
+$[TAB] $[BUNDLE_LIB_C++]
+  #endif  // BUNDLE_EXT
 #endif
 
 // Here are the rules to install and uninstall the library and
 // everything that goes along with it.
 #define installed_files \
     $[install_lib_dir]/lib$[TARGET]$[DYNAMIC_LIB_EXT] \
+    $[if $[BUNDLE_EXT],$[install_lib_dir]/lib$[TARGET]$[BUNDLE_EXT]] \
     $[INSTALL_SCRIPTS:%=$[install_bin_dir]/%] \
     $[INSTALL_HEADERS:%=$[install_headers_dir]/%] \
     $[INSTALL_DATA:%=$[install_data_dir]/%] \