Permalink
Browse files

Bug 7003: Adapt posix-build.jam for the C back-end on Linux and FreeBSD

* configure.ac: Use AC_PROG_CC to obtain @CC@ and @CFLAGS@. Move config.jam
  to sources/jamfiles.

* sources/dfmc/c-run-time/config.jam.in: Remove from here.

* sources/jamfiles/config.jam.in: Move to here.

* sources/jamfiles/Makefile.in: Install generated *.jam files.

* sources/lib/run-time/mini-jambase.jam: Remove from here.

* sources/jamfiles/posix-build.jam: Refactor to support C back-end.

* sources/dfmc/c-run-time/c-freebsd-build.jam,
  sources/dfmc/c-run-time/c-linux-build.jam,
  sources/dfmc/c-run-time/x86-linux-build.jam,
  sources/dfmc/c-run-time/x86_64-linux-build.jam: Removed from here.

* sources/jamfiles/x86-freebsd-build.jam,
  sources/jamfiles/x86-linux-build.jam: Move common code out of
  platform-specific files, and move potentially platform-specific code
  into them.

* sources/jamfiles/x86_64-linux-build.jam: Moved here and harmonized
  with other posix target-specific build scripts.

* sources/dfmc/c-run-time/Makefile.in: Remove references to deleted
  build scripts.
  • Loading branch information...
1 parent 71596bd commit 0fe321bd35c72e4cd984582ab3febd8cb9b0f764 @housel housel committed Mar 14, 2012
View
@@ -71,6 +71,8 @@ AC_SUBST(DYLANCOMPILER)
bootstrap_target=1-stage-bootstrap
AC_SUBST(bootstrap_target)
+AC_PROG_CC
+
AC_ARG_WITH(arch,
AC_HELP_STRING([--with-arch=ARCH],
[Runtime architecture, e.g., i386 or x86_64.]),
@@ -119,9 +121,9 @@ AC_SUBST(with_library_source)
# gc is also replaced in sources/dfmc/c-run-time
AC_CONFIG_FILES(Makefile
sources/jamfiles/Makefile
+ sources/jamfiles/config.jam
sources/lib/run-time/pentium-linux/Makefile
sources/lib/run-time/pentium-freebsd/Makefile
- sources/dfmc/c-run-time/Makefile
- sources/dfmc/c-run-time/config.jam)
+ sources/dfmc/c-run-time/Makefile)
AC_OUTPUT
@@ -31,13 +31,7 @@ OBJS = posix-threads.o \
trace.o
JAMFILES = \
- $(top_srcdir)/sources/lib/run-time/mini-jambase.jam \
- config.jam \
$(runtime_srcdir)/common.jam \
- $(runtime_srcdir)/c-freebsd-build.jam \
- $(runtime_srcdir)/c-linux-build.jam \
- $(runtime_srcdir)/x86-linux-build.jam \
- $(runtime_srcdir)/x86_64-linux-build.jam \
$(runtime_srcdir)/ppc-darwin-build.jam \
$(runtime_srcdir)/x86-darwin-build.jam \
$(runtime_srcdir)/x86_64-darwin-build.jam
@@ -1,338 +0,0 @@
-
-#
-# Include the common jam library
-#
-
-include $(SYSTEM_ROOT)/lib/common.jam ;
-
-#
-# Configuration variables
-#
-
-CC ?= gcc $(GC_CFLAGS) -fPIC -L/usr/local/lib -I/usr/local/include -O0 ;
-
-SUFDLL ?= .so ; # shared library suffix
-
-DEFINES += GC_LINUX_THREADS _REENTRANT ;
-
-#
-# Jambase
-#
-
-include $(SYSTEM_LIBDIR)/mini-jambase.jam ;
-
-#
-# Pseudo-targets
-#
-
-NotFile all lib dll exe unify-dll unify-exe release dirs clean clean-all ;
-Always clean clean-all ;
-
-#
-# Rules called from jam-build
-#
-
-# In each of the following rules, $(image[1]) contains the name from
-# the Library: header, and $(image[2]) contains the name from
-# the Executable: header (if present).
-
-rule DylanLibrary image : version {
- # DylanLibrary image : version ;
- #Echo DylanLibrary $(image) ":" $(version) ;
-
- # Link a Dylan library as a shared library or executable image.
-
- local _dll = [ FDLLName $(image) ] ;
- local _exe = [ FEXEName $(image) ] ;
-
- # Here we save the name and search directory of the DLL for this library.
-
- _dll_$(image[1]:L) = $(_dll) ;
- if ! $(SYSTEM) && ! $(PERSONAL_ROOT) {
- _dir_$(image[1]:L) = $(LIBDIR) ;
- }
-
- # Shared libraries and executable images
-
- MakeLocate $(_dll) : $(LIBDIR) ;
- MakeLocate $(_exe) : $(BINDIR) ;
-
- # Initial library search path
-
- LIBPATH on $(_dll) = $(PERSONAL_LIBDIR) ;
- LIBPATH on $(_exe) = $(PERSONAL_LIBDIR:E=$(LIBDIR)) ;
-
- # We'll use the library name as the grist to identify referenced
- # source and object files.
-
- SOURCE_GRIST = $(image[1]:L) ;
-
- # Save the current dylanmakefile.mkf for reference by other libraries
- # in the event that it later becomes a system library.
-
- local _mkf = $(image[1]:LS=$(SUFMKF)) ;
- MakeLocate $(_mkf) : $(LIBDIR) ;
- if ! $(SYSTEM) {
- File $(_mkf) : [ FGristFiles $(MKF) ] ;
- Depends $(_dll) : $(_mkf) ;
- }
-
- # The executable depends only on _main.o and the DLL.
-
- local _obj = [ FGristFiles _main$(SUFOBJ) ] ;
- local _c = [ FGristFiles _main.c ] ;
- SEARCH on $(_obj) $(_c) = $(SEARCH_SOURCE) ;
-
- Cc $(_obj) : $(_c) ;
- Depends $(_exe) : $(_dll) ;
- LINKLIBS on $(_exe) += -l$(image[1]:L) ;
- LinkEXE $(_exe) : $(_obj) ;
-
- # If this is the top-level project, make the dll, exe, and clean
- # targets depend on its build products.
-
- if ! $(PARENT) {
- Depends dll : $(_dll) ;
- Depends exe : $(_exe) ;
-
- Clean clean : $(_dll) $(_exe) $(_mkf) $(_obj) ;
- }
- Clean clean-all : $(_dll) $(_exe) $(_mkf) $(_obj) ;
-
- # Mark the library version
-
- VERSION on $(_dll) ?= $(version:J=.) ;
- VERSION on $(_exe) ?= $(version:J=.) ;
-}
-
-rule DylanLibraryFiles image : files {
- # DylanLibraryFiles image : files ;
- #Echo DylanLibraryFiles $(image) ":" $(files) ;
-
- # Link Dylan-derived object files into the resulting shared library.
- if ! $(SYSTEM) {
- local _dll = [ FDLLName $(image) ] ;
-
- local _obj = [ FGristFiles _glue$(SUFOBJ) $(files:S=$(SUFOBJ)) ] ;
- local _c = [ FGristFiles _glue.c $(files:S=.c) ] ;
- local _el = [ FGristFiles $(files:S=.el) ] ;
- SEARCH on $(_obj) $(_c) $(_el) = $(SEARCH_SOURCE) ;
-
- local _i ;
- for _i in [ FGristFiles _glue.c $(files:S=.c) ] {
- SEARCH on $(_i) = $(SEARCH_SOURCE) ;
- local _mobj = [ FGristFiles $(_i:S=$(SUFOBJ)) ] ;
- MakeLocate $(_mobj) : $(LOCATE_TARGET) ;
-
- Cc $(_mobj) : $(_i) ;
-
- LinkDLL $(_dll) : $(_mobj) ;
- }
-
- if ! $(PARENT) {
- Clean clean : $(_obj) $(_el) ;
- }
- Clean clean-all : $(_obj) $(_el) ;
- }
-}
-
-rule DylanLibraryLinkerOptions image : options {
- # DylanLibraryLinkerOptions image : options ;
- #Echo DylanLibraryLinkerOptions $(image) ":" $(options) ;
-
- # Add the given options to the link command line of the shared library
- # and executable images.
-
- local _dll = [ FDLLName $(image) ] ;
- local _exe = [ FEXEName $(image) ] ;
-
- LINKLIBS on $(_dll) += $(options) ;
- LINKLIBS on $(_exe) += $(options) ;
-}
-
-rule DylanLibraryBaseAddress image : address {
- # DylanLibraryBaseAddress image : address ;
- #Echo DylanLibraryBaseAddress $(image) ":" $(address) ;
-
- # Set the base address of the shared library.
-
- local _dll = [ FDLLName $(image) ] ;
- BASE on $(_dll) ?= $(address) ;
-}
-
-rule DylanLibraryCLibraries image : libraries {
- # DylanLibraryCLibraries image : libraries ;
- #Echo DylanLibraryCLibraries $(image) ":" $(libraries) ;
-
- # Link C (or other externally-derived) libraries into the shared library.
-
- local _dll = [ FDLLName $(image) ] ;
-
- for lib in $(libraries) {
- switch $(lib) {
- case -L* : LINKLIBS on $(_dll) += $(lib) ;
- case -l* : LINKLIBS on $(_dll) += $(lib) ;
- case *.a : lib = [ FGristFiles $(lib) ] ;
- SEARCH on $(lib) = $(SEARCH_SOURCE) ;
- Depends $(_dll) : $(lib) ;
- NEEDLIBS on $(_dll) += $(lib) ;
- case * : Exit Unknown C library $(lib) ;
- }
- }
-}
-
-rule DylanLibraryCObjects image : objects {
- # DylanLibraryCObjects image : objects ;
- #Echo DylanLibraryCObjects $(image) ":" $(objects) ;
-
- # Link C (or other externally-derived) object files into the shared library.
- if ! $(SYSTEM) {
- local _dll = [ FDLLName $(image) ] ;
- SEARCH on $(objects) = $(SEARCH_SOURCE) ;
- LinkDLL $(_dll) : $(objects) ;
- }
-}
-
-rule DylanLibraryCSources image : sources {
- # DylanLibraryCSources image : sources ;
- #Echo DylanLibraryCSources $(image) ":" $(sources) ;
-
- # Link C source files into the shared library.
- if ! $(SYSTEM) {
- local _dll = [ FDLLName $(image) ] ;
- local _exe = [ FEXEName $(image) ] ;
-
- local _i ;
- for _i in [ FGristFiles $(sources) ] {
- SEARCH on $(_i) = $(SEARCH_SOURCE) ;
- local _obj = [ FGristFiles $(_i:S=$(SUFOBJ)) ] ;
- MakeLocate $(_obj) : $(LOCATE_TARGET) ;
-
- Cc $(_obj) : $(_i) ;
-
- LinkDLL $(_dll) : $(_obj) ;
- }
- }
-}
-
-rule DylanLibraryCHeaders image : headers {
- # DylanLibraryCHeaders image : headers ;
- #Echo DylanLibraryCHeaders $(image) ":" $(headers) ;
-
- # Mark the shared library as depending on the given header files.
- # TODO: The original build-system didn't do anything with this either.
-}
-
-rule DylanLibraryRCFiles image : rcfiles {
- # DylanLibraryRCFiles image : rcfiles ;
- #Echo DylanLibraryRCFiles $(image) ":" $(rcfiles) ;
-
- # Link Win32 resource files into the shared library and executable.
-
- Echo Ignoring RC file(s) $(rcfiles) ;
-}
-
-rule DylanLibraryJamIncludes image : includes {
- # DylanLibraryJamIncludes image : includes ;
-
- Echo Ignoring Jam include file(s) $(includes) ;
-}
-
-rule DylanLibraryUses image : library : dir {
- # DylanLibraryUses image : library : dir ;
- #Echo DylanLibraryUses $(image) ":" $(library) ":" $(dir) ;
-
- # Link other Dylan libraries into the shared library.
-
- if ! $(_dll_$(library:L)) {
- local PARENT = $(image[1]:L) ;
-
- if $(dir) = system || $(SYSTEM) {
- # This is a system library; read $(SYSTEM_LIBDIR)/$(library:L).mkf
-
- local SYSTEM = true ;
- local LIBDIR = $(SYSTEM_LIBDIR) ;
- local BINDIR = $(SYSTEM_BINDIR) ;
-
- local SEARCH_SOURCE LOCATE_SOURCE LOCATE_TARGET = $(SYSTEM_LIBDIR) ;
- local SOURCE_GRIST ;
-
- local _mkf = $(library:LS=$(SUFMKF)) ;
- SEARCH on $(_mkf) ?= $(SYSTEM_LIBDIR) ;
- IncludeMKF $(_mkf) ;
- }
- else {
- # Another personal library; read its mkf from its build directory.
-
- local SEARCH_SOURCE LOCATE_SOURCE LOCATE_TARGET
- = $(dir:R=$(LOCATE_TARGET:E=$(DOT))) ;
- local SOURCE_GRIST ;
-
- local LIBDIR BINDIR ;
- {
- local _lib = lib ;
- local _bin = bin ;
-
- LIBDIR = $(_lib:P=$(PERSONAL_ROOT:E=$(LOCATE_TARGET:P))) ;
- BINDIR = $(_bin:P=$(PERSONAL_ROOT:E=$(LOCATE_TARGET:P))) ;
- }
-
- local _mkf = $(MKF:G=$(library:L)) ;
- SEARCH on $(_mkf) ?= $(SEARCH_SOURCE) ;
- IncludeMKF $(_mkf) ;
- }
- }
-
- DylanLibraryClosure $(image) : $(library:L) ;
-}
-
-rule DylanLibraryClosure image : libraries {
- local _dll = [ FDLLName $(image) ] ;
- local _exe = [ FEXEName $(image) ] ;
-
- local _i ;
- for _i in $(libraries) {
- if ! $(_i) in $(_use_$(image[1]:L)) {
- _use_$(image[1]:L) += $(_i) ;
- Depends $(_dll) $(_exe) : $(_dll_$(_i)) ;
- LINKLIBS on $(_dll) $(_exe) += -l$(_i) ;
-
- LIBPATH on $(_dll) $(_exe) += $(_dir_$(_i)) ;
-
- DylanLibraryClosure $(image) : $(_use_$(_i)) ;
- }
- }
-}
-
-#
-# Build rules and actions
-#
-
-rule LinkDLL {
- Depends $(<) : $(>) ;
-}
-
-actions together LinkDLL bind NEEDLIBS {
- $(CC) -shared -o $(<) $(LINKFLAGS) $(>) -L"$(LIBPATH)" $(NEEDLIBS) $(LINKLIBS)
-}
-
-rule LinkEXE {
- Depends $(<) : $(>) ;
-}
-
-actions LinkEXE bind NEEDLIBS {
- # Link GC here as well as in rtlibs because it might not be statically linked
- $(CC) -o $(<) -Wl,-z,origin -Wl,-rpath,"\$ORIGIN/../lib/" $(LINKFLAGS) $(>) -L"$(LIBPATH)" $(NEEDLIBS) $(LINKLIBS)
-}
-
-#
-# Utility rules
-#
-
-rule FDLLName {
- return lib$(<[1]:LS=$(SUFDLL)) ;
-}
-
-rule FEXEName {
- return $(<[1]:L) ;
-}
Oops, something went wrong.

0 comments on commit 0fe321b

Please sign in to comment.