diff options
-rw-r--r-- | build.conf | 23 | ||||
-rw-r--r-- | build/apr_rules.mk.in | 6 | ||||
-rwxr-xr-x | build/gen-build.py | 93 | ||||
-rw-r--r-- | configure.in | 8 |
4 files changed, 95 insertions, 35 deletions
diff --git a/build.conf b/build.conf index 8d9c84181..0522a1bb7 100644 --- a/build.conf +++ b/build.conf @@ -4,26 +4,19 @@ [options] +# paths to platform-independent .c files to build paths = - atomic/{platform}/*.c - dso/{platform}/*.c - file_io/{platform}/*.c - locks/{platform}/*.c - memory/{platform}/*.c - misc/{platform}/*.c - mmap/{platform}/*.c - network_io/{platform}/*.c passwd/*.c - poll/{platform}/*.c - random/{platform}/*.c - shmem/{platform}/*.c strings/*.c - support/{platform}/*.c tables/*.c - threadproc/{platform}/*.c - time/{platform}/*.c - user/{platform}/*.c +# directories that have platform-specific code in them. the resulting +# pattern will be: SUBDIR/PLATFORM/*.c +platform_dirs = + atomic dso file_io locks memory misc mmap network_io poll random + shmem support threadproc time user + +# all the public headers headers = include/*.h # aplibtool is manually built by the configure process diff --git a/build/apr_rules.mk.in b/build/apr_rules.mk.in index 392efa141..747adb1a3 100644 --- a/build/apr_rules.mk.in +++ b/build/apr_rules.mk.in @@ -115,6 +115,12 @@ ALL_INCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) LTFLAGS = @LTFLAGS@ LT_LDFLAGS = @LT_LDFLAGS@ +# The set of object files that will be linked into the target library. +# The build-outputs.mk specifies a different set for each platform. The +# configure script will select the appropriate set. +# +OBJECTS = @OBJECTS_PLATFORM@ + # # Basic macro setup # diff --git a/build/gen-build.py b/build/gen-build.py index 3c92b2c12..8582741de 100755 --- a/build/gen-build.py +++ b/build/gen-build.py @@ -18,13 +18,26 @@ import re #import ezt +# +# legal platforms: aix, beos, netware, os2, os390, unix, win32 +# 'make' users: aix, beos, os2, os390, unix +# +PLATFORMS = [ 'aix', 'beos', 'netware', 'os2', 'os390', 'unix', 'win32' ] +MAKE_PLATFORMS = [ + ('unix', None), + ('aix', 'unix'), + ('beos', 'unix'), + ('os2', 'unix'), + ('os390', 'unix'), + ] +# note: MAKE_PLATFORMS is an ordered set. we want to generate unix symbols +# first, so that the later platforms can reference them. + def main(): parser = ConfigParser.ConfigParser() parser.read('build.conf') - dirs = { } - files = get_files(parser.get('options', 'paths')) headers = get_files(parser.get('options', 'headers')) # compute the relevant headers, along with the implied includes @@ -40,22 +53,45 @@ def main(): f = open('build-outputs.mk', 'w') f.write('# DO NOT EDIT. AUTOMATICALLY GENERATED.\n\n') - objects = [ ] - for file in files: - assert file[-2:] == '.c' - obj = file[:-2] + '.lo' - objects.append(obj) + # write out the platform-independent files + files = get_files(parser.get('options', 'paths')) + objects, dirs = write_objects(f, legal_deps, h_deps, files) + f.write('\nOBJECTS_all = %s\n\n' % string.join(objects)) - dirs[os.path.dirname(file)] = None + # for each platform and each subdirectory holding platform-specific files, + # write out their compilation rules, and an OBJECT_<subdir>_<plat> symbol. + for platform, parent in MAKE_PLATFORMS: - # what headers does this file include, along with the implied headers - deps = extract_deps(file, legal_deps) - for hdr in deps.keys(): - deps.update(h_deps.get(hdr, {})) + # record the object symbols to build for each platform + group = [ '$(OBJECTS_all)' ] - f.write('%s: %s .make.dirs %s\n' % (obj, file, string.join(deps.values()))) + for subdir in string.split(parser.get('options', 'platform_dirs')): + path = '%s/%s' % (subdir, platform) + if not os.path.exists(path): + # this subdir doesn't have a subdir for this platform, so we'll + # use the parent-platform's set of symbols + if parent: + group.append('$(OBJECTS_%s_%s)' % (subdir, parent)) + continue + + # remember that this directory has files/objects + dirs[path] = None + + # write out the compilation lines for this subdir + files = get_files(path + '/*.c') + objects, _unused = write_objects(f, legal_deps, h_deps, files) + + symname = 'OBJECTS_%s_%s' % (subdir, platform) + + # and write the symbol for the whole group + f.write('\n%s = %s\n\n' % (symname, string.join(objects))) + + # and include that symbol in the group + group.append('$(%s)' % symname) + + # write out a symbol which contains the necessary files + f.write('OBJECTS_%s = %s\n\n' % (platform, string.join(group))) - f.write('\nOBJECTS = %s\n\n' % string.join(objects)) f.write('HEADERS = $(top_srcdir)/%s\n\n' % string.join(headers, ' $(top_srcdir)/')) f.write('SOURCE_DIRS = %s $(EXTRA_SOURCE_DIRS)\n\n' % string.join(dirs.keys())) @@ -76,6 +112,28 @@ def main(): '\t@for d in $(BUILD_DIRS); do test -d $$d || mkdir $$d; done\n' \ '\t@echo timestamp > $@\n') + +def write_objects(f, legal_deps, h_deps, files): + dirs = { } + objects = [ ] + + for file in files: + assert file[-2:] == '.c' + obj = file[:-2] + '.lo' + objects.append(obj) + + dirs[os.path.dirname(file)] = None + + # what headers does this file include, along with the implied headers + deps = extract_deps(file, legal_deps) + for hdr in deps.keys(): + deps.update(h_deps.get(hdr, {})) + + f.write('%s: %s .make.dirs %s\n' % (obj, file, string.join(deps.values()))) + + return objects, dirs + + def extract_deps(fname, legal_deps): "Extract the headers this file includes." deps = { } @@ -104,16 +162,11 @@ def resolve_deps(header_deps): def get_files(patterns): - patterns = string.replace(patterns, '{platform}', get_platform()) - patterns = string.split(string.strip(patterns)) files = [ ] - for pat in patterns: + for pat in string.split(patterns): files.extend(glob.glob(pat)) return files -def get_platform(): - return 'unix' - if __name__ == '__main__': main() diff --git a/configure.in b/configure.in index 956bfd161..70c167477 100644 --- a/configure.in +++ b/configure.in @@ -349,11 +349,14 @@ proc_mutex_is_global=0 config_subdirs="none" INSTALL_SUBDIRS="none" +OBJECTS_PLATFORM='$(OBJECTS_unix)' + case $host in i386-ibm-aix* | *-ibm-aix[1-2].* | *-ibm-aix3.* | *-ibm-aix4.1 | *-ibm-aix4.1.* | *-ibm-aix4.2 | *-ibm-aix4.2.*) OSDIR="aix" APR_ADDTO(LDFLAGS,-lld) eolstr="\\n" + OBJECTS_PLATFORM='$(OBJECTS_aix)' ;; *-os2*) APR_ADDTO(CPPFLAGS,-DOS2) @@ -364,6 +367,7 @@ case $host in eolstr="\\r\\n" file_as_socket="0" proc_mutex_is_global=1 + OBJECTS_PLATFORM='$(OBJECTS_os2)' ;; *beos*) OSDIR="beos" @@ -374,6 +378,7 @@ case $host in eolstr="\\n" osver=`uname -r` proc_mutex_is_global=1 + OBJECTS_PLATFORM='$(OBJECTS_beos)' case $osver in 5.0.4) file_as_socket="1" @@ -385,6 +390,7 @@ case $host in ;; *os390) OSDIR="os390" + OBJECTS_PLATFORM='$(OBJECTS_os390)' eolstr="\\n" ;; *os400) @@ -408,6 +414,8 @@ case $host in ;; esac +AC_SUBST(OBJECTS_PLATFORM) + AC_ARG_ENABLE(nonportable-atomics, [ --enable-nonportable-atomics Use optimized atomic code which may produce nonportable binaries], [if test $enableval = yes; then |