From ee947014884ab0079b4e49fbf60873e142653cfc Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 7 May 2002 02:25:24 +0000 Subject: [PATCH] Partial AIX .so support [SVN r13702] --- boost-base.jam | 16 +++--- gen_aix_import_file.py | 107 ++++++++++++++++++++++++++++++++++++++ kcc-tools.jam | 2 +- python.jam | 6 --- v1/boost-base.jam | 16 +++--- v1/gen_aix_import_file.py | 107 ++++++++++++++++++++++++++++++++++++++ v1/kcc-tools.jam | 2 +- v1/python.jam | 6 --- 8 files changed, 236 insertions(+), 26 deletions(-) create mode 100644 gen_aix_import_file.py create mode 100644 v1/gen_aix_import_file.py diff --git a/boost-base.jam b/boost-base.jam index c3b3b6064..e5102736f 100644 --- a/boost-base.jam +++ b/boost-base.jam @@ -188,21 +188,25 @@ rule Link-EXE rule Link-DLL { - if $(<[2]) - { - MODE on $(<[2]) = $(IMPMODE) ; - Chmod $(<[2]) ; - } - gRUN_PATH($(<)) += $(gLOCATE($(<[1]))) ; if $(UNIX) { RUN_LD_LIBRARY_PATH on $(<) = [ join $(gRUN_LD_LIBRARY_PATH($(<))) $(RUN_LD_LIBRARY_PATH) : $(SPLITPATH) ] ; gRUN_LD_LIBRARY_PATH($(<)) += $(gLOCATE($(<[1]))) ; } + + if $(OS) = AIX + { + Aix-Implib-Action $(<) : $(>) ; + } Link-action $(<) : $(>) : DLL ; } +actions Aix-Implib-Action bind import-generator-script +{ + "$(BOOST_ROOT)/tools/build/gen_aix_import_file.py" $(<[1]:BD=) $(>:D=) "-directory=$(<[1]:D)" -verbose=1 +} + # store the shell's PATH again, just in case someone uses PATH. # This also allows the user to customize the base path for running built # products from the command-line diff --git a/gen_aix_import_file.py b/gen_aix_import_file.py new file mode 100644 index 000000000..34fc4d8a8 --- /dev/null +++ b/gen_aix_import_file.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python + +# Valid arguments +setValueArgs = {"-ld" : "LD", + "-ldflags" : "LDFLAGS", + "-optldflags" : "OPTLDFLAGS", + "-impfilename" : "IMPFILENAME", + "-expflag" : "EXPFLAG", + "-maxlinelength" : "maxlinelength", + "-verbose" : "chatty", + "-directory" : "CHDIR" } +validArgs = setValueArgs.keys() + +# Little function to generate a usage statement. +def printUsage(): + print "Usage: generateImportFile " + +# Helper to execute the given command string in the host OS. +def execCommand(command, chatty): + if chatty: + print command + import os + os.system(command) + +# Default values for the important vars +LD = "xlC_r" +LDFLAGS = "-G -qmkshrobj" +OPTLDFLAGS = "" +EXPFLAG = "-qexpfile" +maxlinelength = 4095 +OBJS = "" +chatty = None + +import sys +nargs = len(sys.argv) +if nargs < 2: + printUsage() + exit(1) + +# Get the name of the lib target. +LIBTARGET = sys.argv[1] +if LIBTARGET[-3:] != ".so": + LIBTARGET += ".so" + +# The default name for the export and import files we'll be generating. +EXPFILENAME = LIBTARGET[:-3] + ".exp" +IMPFILENAME = LIBTARGET[:-3] + ".imp" + +CHDIR = "." + +# Parse optional arguments +for iarg in xrange(2, nargs): + arg = sys.argv[iarg] + + # Is this a -thingy=thingyValue argument? + if arg[0] == "-": + assert arg.count("=") == 1 + argKey, argValue = arg.split("=") + if argKey not in validArgs: + printUsage() + exit(1) + + exec("%s = '%s'" % (setValueArgs[argKey], argValue)) + print "Setting " + setValueArgs[argKey] + " to " + argValue + + # Is this an object file/lib that needs to be linked in? + elif arg[-2:] == ".o" or arg[-2:] == ".a" or arg[-3:] == ".so": + OBJS += arg + " " + + else: + printUsage() + exit() + +import os +os.chdir(CHDIR) + +# Generate the export file by creating the shared obj library, which we then +# promptly delete. +command = LD + " " + LDFLAGS + " " + OPTLDFLAGS + " " + \ + EXPFLAG + "=" + EXPFILENAME + " " + \ + OBJS + " -o " + LIBTARGET +execCommand(command, chatty) +execCommand("rm -f " + LIBTARGET, chatty) + +# Create the import file, and put the required tag as the first line indicating +# the name of the archive which is exporting these symbols. +impfile = open(IMPFILENAME, 'w') +impfile.write("#!" + LIBTARGET + "\n") + +# Attach the list of symbols being exported to the import file. +expfile = open(EXPFILENAME, 'r') +symbol = expfile.readline() +while symbol: + if maxlinelength: + symbol = symbol[:maxlinelength] + if symbol[-1] != '\n': + symbol += '\n' + impfile.write(symbol) + symbol = expfile.readline() +impfile.close() +expfile.close() + +#command = "cat " + EXPFILENAME + " >> " + IMPFILENAME +#execCommand(command, chatty) + +# Remove the export file. +execCommand("rm -f " + EXPFILENAME, chatty) diff --git a/kcc-tools.jam b/kcc-tools.jam index ac0bd4fad..1ab10bbb1 100644 --- a/kcc-tools.jam +++ b/kcc-tools.jam @@ -48,7 +48,7 @@ rule Link-action actions kcc-Link-action bind NEEDLIBS { - $(kcc.bin-directory)KCC $(LINKFLAGS) -o "$(<)" -L$(STDLIBPATH) "$(>)" $(NEEDLIBS) -lm + $(kcc.bin-directory)KCC $(LINKFLAGS) -o "$(<[1])" -L$(STDLIBPATH) "$(>)" $(NEEDLIBS) -lm } #### Cc ##### diff --git a/python.jam b/python.jam index 9b094ed05..90e0d4e71 100644 --- a/python.jam +++ b/python.jam @@ -241,12 +241,6 @@ if $(NT) rule Link-PYD { - if $(<[2]) - { - MODE on $(<[2]) = $(IMPMODE) ; - Chmod $(<[2]) ; - } - gRUN_PATH($(<)) += $(gLOCATE($(<[1]))) ; if $(UNIX) { diff --git a/v1/boost-base.jam b/v1/boost-base.jam index c3b3b6064..e5102736f 100644 --- a/v1/boost-base.jam +++ b/v1/boost-base.jam @@ -188,21 +188,25 @@ rule Link-EXE rule Link-DLL { - if $(<[2]) - { - MODE on $(<[2]) = $(IMPMODE) ; - Chmod $(<[2]) ; - } - gRUN_PATH($(<)) += $(gLOCATE($(<[1]))) ; if $(UNIX) { RUN_LD_LIBRARY_PATH on $(<) = [ join $(gRUN_LD_LIBRARY_PATH($(<))) $(RUN_LD_LIBRARY_PATH) : $(SPLITPATH) ] ; gRUN_LD_LIBRARY_PATH($(<)) += $(gLOCATE($(<[1]))) ; } + + if $(OS) = AIX + { + Aix-Implib-Action $(<) : $(>) ; + } Link-action $(<) : $(>) : DLL ; } +actions Aix-Implib-Action bind import-generator-script +{ + "$(BOOST_ROOT)/tools/build/gen_aix_import_file.py" $(<[1]:BD=) $(>:D=) "-directory=$(<[1]:D)" -verbose=1 +} + # store the shell's PATH again, just in case someone uses PATH. # This also allows the user to customize the base path for running built # products from the command-line diff --git a/v1/gen_aix_import_file.py b/v1/gen_aix_import_file.py new file mode 100644 index 000000000..34fc4d8a8 --- /dev/null +++ b/v1/gen_aix_import_file.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python + +# Valid arguments +setValueArgs = {"-ld" : "LD", + "-ldflags" : "LDFLAGS", + "-optldflags" : "OPTLDFLAGS", + "-impfilename" : "IMPFILENAME", + "-expflag" : "EXPFLAG", + "-maxlinelength" : "maxlinelength", + "-verbose" : "chatty", + "-directory" : "CHDIR" } +validArgs = setValueArgs.keys() + +# Little function to generate a usage statement. +def printUsage(): + print "Usage: generateImportFile " + +# Helper to execute the given command string in the host OS. +def execCommand(command, chatty): + if chatty: + print command + import os + os.system(command) + +# Default values for the important vars +LD = "xlC_r" +LDFLAGS = "-G -qmkshrobj" +OPTLDFLAGS = "" +EXPFLAG = "-qexpfile" +maxlinelength = 4095 +OBJS = "" +chatty = None + +import sys +nargs = len(sys.argv) +if nargs < 2: + printUsage() + exit(1) + +# Get the name of the lib target. +LIBTARGET = sys.argv[1] +if LIBTARGET[-3:] != ".so": + LIBTARGET += ".so" + +# The default name for the export and import files we'll be generating. +EXPFILENAME = LIBTARGET[:-3] + ".exp" +IMPFILENAME = LIBTARGET[:-3] + ".imp" + +CHDIR = "." + +# Parse optional arguments +for iarg in xrange(2, nargs): + arg = sys.argv[iarg] + + # Is this a -thingy=thingyValue argument? + if arg[0] == "-": + assert arg.count("=") == 1 + argKey, argValue = arg.split("=") + if argKey not in validArgs: + printUsage() + exit(1) + + exec("%s = '%s'" % (setValueArgs[argKey], argValue)) + print "Setting " + setValueArgs[argKey] + " to " + argValue + + # Is this an object file/lib that needs to be linked in? + elif arg[-2:] == ".o" or arg[-2:] == ".a" or arg[-3:] == ".so": + OBJS += arg + " " + + else: + printUsage() + exit() + +import os +os.chdir(CHDIR) + +# Generate the export file by creating the shared obj library, which we then +# promptly delete. +command = LD + " " + LDFLAGS + " " + OPTLDFLAGS + " " + \ + EXPFLAG + "=" + EXPFILENAME + " " + \ + OBJS + " -o " + LIBTARGET +execCommand(command, chatty) +execCommand("rm -f " + LIBTARGET, chatty) + +# Create the import file, and put the required tag as the first line indicating +# the name of the archive which is exporting these symbols. +impfile = open(IMPFILENAME, 'w') +impfile.write("#!" + LIBTARGET + "\n") + +# Attach the list of symbols being exported to the import file. +expfile = open(EXPFILENAME, 'r') +symbol = expfile.readline() +while symbol: + if maxlinelength: + symbol = symbol[:maxlinelength] + if symbol[-1] != '\n': + symbol += '\n' + impfile.write(symbol) + symbol = expfile.readline() +impfile.close() +expfile.close() + +#command = "cat " + EXPFILENAME + " >> " + IMPFILENAME +#execCommand(command, chatty) + +# Remove the export file. +execCommand("rm -f " + EXPFILENAME, chatty) diff --git a/v1/kcc-tools.jam b/v1/kcc-tools.jam index ac0bd4fad..1ab10bbb1 100644 --- a/v1/kcc-tools.jam +++ b/v1/kcc-tools.jam @@ -48,7 +48,7 @@ rule Link-action actions kcc-Link-action bind NEEDLIBS { - $(kcc.bin-directory)KCC $(LINKFLAGS) -o "$(<)" -L$(STDLIBPATH) "$(>)" $(NEEDLIBS) -lm + $(kcc.bin-directory)KCC $(LINKFLAGS) -o "$(<[1])" -L$(STDLIBPATH) "$(>)" $(NEEDLIBS) -lm } #### Cc ##### diff --git a/v1/python.jam b/v1/python.jam index 9b094ed05..90e0d4e71 100644 --- a/v1/python.jam +++ b/v1/python.jam @@ -241,12 +241,6 @@ if $(NT) rule Link-PYD { - if $(<[2]) - { - MODE on $(<[2]) = $(IMPMODE) ; - Chmod $(<[2]) ; - } - gRUN_PATH($(<)) += $(gLOCATE($(<[1]))) ; if $(UNIX) {