diff --git a/Jamfile b/Jamfile index 9f86d73427..4da9015185 100644 --- a/Jamfile +++ b/Jamfile @@ -1,6 +1,4 @@ -SubDir OBOS_TOP ; - -InstallFloppy installfloppy : $(OBOS_FLOPPY) ; +SubDir HAIKU_TOP ; NotFile alltests ; Depends alltests : r5tests obostests ; @@ -132,4 +130,4 @@ Depends ScreenSaverKit : Haiku ; -SubInclude OBOS_TOP src ; +SubInclude HAIKU_TOP src ; diff --git a/Jamrules b/Jamrules index ffd0bd85a5..f99d8c9258 100644 --- a/Jamrules +++ b/Jamrules @@ -1,2502 +1,49 @@ -# Haiku main build rules +# Haiku Jamrules -# Vanilla Jam compatibility -if ! $(INVOCATION_SUBDIR_SET) { - rule FIsPrefix - { - # FIsPrefix : ; - # Returns true, if list is a prefix (a proper one or equal) of - # list , an empty list otherwise. - local a = $(1) ; - local b = $(2) ; - while $(a) && $(a[1]) = $(b[1]) { - a = $(a[2-]) ; - b = $(b[2-]) ; - } - - if $(a) { - return ; - } else { - return true ; - } - } - - rule LocalClean { Clean $(1) : $(2) ; } - - rule LocalDepends { Depends $(1) : $(2) ; } - -} # vanilla Jam compatibility - -BUILD_PLATFORM_DEFINES = $(DEFINES) ; - -# The directory for build system specific files -OBOS_BUILD_DIR = [ FDirName $(OBOS_TOP) build ] ; +# Main directories used by the build. +HAIKU_OUTPUT_DIR ?= [ FDirName $(HAIKU_TOP) generated ] ; +HAIKU_BUILD_OUTPUT_DIR = [ FDirName $(HAIKU_OUTPUT_DIR) build ] ; +HAIKU_BUILD_DIR = [ FDirName $(HAIKU_TOP) build ] ; +HAIKU_BUILD_RULES_DIR = [ FDirName $(HAIKU_BUILD_DIR) jam ] ; +HAIKU_OBJECT_DIR = [ FDirName $(HAIKU_OUTPUT_DIR) objects ] ; +HAIKU_COMMON_PLATFORM_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_DIR) common ] ; # Cache files for header scanning and jamfile caching HCACHEFILE = header_cache ; JCACHEFILE = jamfile_cache ; -LOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(OBOS_BUILD_DIR) ; +LOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(HAIKU_BUILD_OUTPUT_DIR) ; -# Include BuildConfig/Timezones/libgccObjects +# The build setup and rules are neatly organized in several files. Include +# them now. Start with the side-effect-less rules, since they are the most +# likely to be used in the top level context (i.e. not only in rules). +# At the end include BuildSetup that sets up global variables etc. The +# optional user-defined UserBuildConfig is included thereafter. +include [ FDirName $(HAIKU_BUILD_RULES_DIR) HelperRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) BeOSRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) ConfigRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) DocumentationRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) FileRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) FreetypeRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) HeadersRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) KernelRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) ImageRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) MainBuildRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) MiscRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) OverriddenJamRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) PackageRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) TestsRules ] ; +include [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildSetup ] ; + +# Include UserBuildConfig. { - local buildConfig = [ GLOB $(OBOS_BUILD_DIR) : BuildConfig ] ; - local timezones = [ GLOB $(OBOS_BUILD_DIR) : Timezones ] ; - local libgccObjects = [ GLOB $(OBOS_BUILD_DIR) : libgccObjects ] ; - - if ! $(buildConfig) { - ECHO "No `BuildConfig' found in $(OBOS_BUILD_DIR)!" ; - EXIT "Run ./configure in the source tree's root directory first!" ; - } - if ! ( $(timezones) && $(libgccObjects) ) { - ECHO "No `Timezones' or `libgccObjects' found in $(OBOS_BUILD_DIR)!" ; - EXIT "Please run ./configure in the source tree's root directory again!" ; - } - - LOCATE on BuildConfig = $(OBOS_BUILD_DIR) ; - LOCATE on Timezones = $(OBOS_BUILD_DIR) ; - LOCATE on libgccObjects = $(OBOS_BUILD_DIR) ; - - include BuildConfig ; - include Timezones ; - include libgccObjects ; -} - -# analyze GCC version -if ! $(GCC_RAW_VERSION) { - ECHO "Variable GCC_RAW_VERSION not set. Please run ./configure or" ; - EXIT "specify it manually." ; -} -GCC_VERSION = ; -{ - # split the raw version string at `.' and `-' characters - local version = $(GCC_RAW_VERSION) ; - while $(version) { - local split = [ Match "([^.-]*)[.-](.*)" : $(version) ] ; - if $(split) { - GCC_VERSION += $(split[1]) ; - version = $(split[2]) ; - } else { - GCC_VERSION += $(version) ; - version = ; - } + local userBuildConfig + = [ GLOB $(HAIKU_BUILD_RULES_DIR) : UserBuildConfig ] ; + if $(userBuildConfig) { + include $(userBuildConfig) ; } } -# Save the platform default headers. -PLATFORM_DEFAULT_HEADERS = $(HDRS) ; - -# Add some grist to the libgcc objects -LIBGCC_OBJECTS = $(LIBGCC_OBJECTS:G=libgcc) ; - -# We do not include any local BeOS system headers by default -CCFLAGS += -nostdinc ; -C++FLAGS += -nostdinc ; - -# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() -# issues, they deprecated that nice function. This will enable it again: -C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; - -if ! $(TARGET_PLATFORM) { - ECHO "Variable TARGET_PLATFORM not set. Please run ./configure or" ; - EXIT "specify it manually." ; -} -switch $(TARGET_PLATFORM) -{ - case r5 : - { - # "everything" is r5 compatible - } - case bone : - { - BONE_COMPATIBLE = true ; - } - case dano : - { - BONE_COMPATIBLE = true ; - DANO_COMPATIBLE = true ; - } - case haiku : - { - BONE_COMPATIBLE = true ; - DANO_COMPATIBLE = true ; - HAIKU_COMPATIBLE = true ; - DEFINES += __HAIKU__ ; - } -} -if $(BONE_COMPATIBLE) { - NETWORK_LIBS = libsocket.so libbind.so ; - NETAPI_LIB = libbnetapi.so ; - SELECT_UNAME_ETC_LIB = libroot.so ; -} else { - NETWORK_LIBS = libnet.so ; - NETAPI_LIB = libnetapi.so ; - SELECT_UNAME_ETC_LIB = libnet.so ; -} - -# Determine if we're building on PPC or x86 -# Determine mimetype of executable -# Cross compiling can come later - -TARGET_CPU ?= $(OSPLAT:L) ; - -switch $(TARGET_CPU) { - case ppc : - { - if $(METROWERKS) { - # at least parts of OpenBeOS still can be compiled with - # the Metrowerks compiler on BeOS/PPC - OBOS_TARGET_TYPE ?= "application/x-be-executable" ; - } else { - OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; - } - DEFINES += __POWERPC__ ARCH_ppc ; - OBOS_BOOT_PLATFORM = openfirmware ; - } - case x86 : - { - # nothing special to do here... - DEFINES += __INTEL__ ARCH_x86 ; - OBOS_BOOT_PLATFORM = bios_ia32 ; - } - case * : - Exit "Currently unsupported build platform:" $(TARGET_CPU) ; -} - -# We might later want to introduce debug levels or handle the whole issue -# differently. For now there's only on or off. -# -DEBUG ?= 0 ; -if $(DEBUG) != 0 { - OPTIM ?= -O0 ; - TARGET_DEBUG ?= debug_$(DEBUG) ; -} else { - OPTIM ?= -O2 ; - TARGET_DEBUG ?= release ; -} - -# set target specific variables -{ - #Echo "Building for" $(TARGET_CPU) ; - - OBOS_TARGET ?= $(TARGET_CPU).$(TARGET_DEBUG).$(TARGET_PLATFORM) ; - OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; - OBOS_ARCH ?= $(TARGET_CPU) ; - OBOS_TARGET_DEFINE ?= "ARCH_"$(TARGET_CPU) ; -} - -# Disable warnings only if WARNINGS is set to 0 -# Should be enabled by default later -# -WARNINGS ?= 1 ; -if $(WARNINGS) = 1 { - # For an explanation of the different warning options, see: - # http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html - # to get even more warnings, add: - # -Wwrite-strings (doesn't work well with some Be headers) - # -Wundef (dito) - # -Wconversion (gets you many warnings about implicit conversions) - # -W (gets you even more warnigs) - CCFLAGS += -Wall -Wno-multichar -Wmissing-prototypes ; - CCFLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; - C++FLAGS += -Wall -Wno-multichar -Wmissing-prototypes -Wno-ctor-dtor-privacy -Woverloaded-virtual ; - C++FLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; -} else { - CCFLAGS += -Wno-multichar ; - C++FLAGS += -Wno-multichar ; -} - -# standard kernel C/C++ flags -KERNEL_CCFLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; -KERNEL_CCFLAGS += -fno-builtin -D$(OBOS_TARGET_DEFINE) -D__HAIKU__ ; -KERNEL_CCFLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; -KERNEL_C++FLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; -KERNEL_C++FLAGS += -fno-builtin -fno-exceptions -D$(OBOS_TARGET_DEFINE) -D__HAIKU__ ; -KERNEL_C++FLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; -if $(GCC_VERSION[1]) >= 3 { - KERNEL_C++FLAGS += -fno-use-cxa-atexit ; -} -DEBUG_FLAGS ?= -g ; -if $(DEBUG) != 0 { - CCFLAGS += $(DEBUG_FLAGS) [ FDefines DEBUG=$(DEBUG) ] ; - C++FLAGS += $(DEBUG_FLAGS) [ FDefines DEBUG=$(DEBUG) ] ; - KERNEL_CCFLAGS += $(DEBUG_FLAGS) [ FDefines DEBUG=$(DEBUG) ] ; - KERNEL_C++FLAGS += $(DEBUG_FLAGS) [ FDefines DEBUG=$(DEBUG) ] ; - LINKFLAGS += $(DEBUG_FLAGS) ; -} - -# define NDEBUG to a non-zero value to suppress asserts -NDEBUG ?= 0 ; -if $(NDEBUG) != 0 { - CCFLAGS += [ FDefines NDEBUG=$(NDEBUG) ] ; - C++FLAGS += [ FDefines NDEBUG=$(NDEBUG) ] ; - KERNEL_CCFLAGS += [ FDefines NDEBUG=$(NDEBUG) ] ; - KERNEL_C++FLAGS += [ FDefines NDEBUG=$(NDEBUG) ] ; -} - -# -# To disable for the tests OPTIM and DEBUG are overridden, set the environment -# variable NO_TEST_DEBUG. - -# If the environment variable DEBUG_PRINTF is defined we define an equally -# named macro to the variable value. Some components use the macro to allow -# another function than printf() to print the debug output. The variable should -# be set to the name of the alternative function. -# -if $(DEBUG_PRINTF) { - CCFLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; - C++FLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; -} - -# Instructs the Library rule to not make its object files temporary. -# This is needed as some objects are used in a static library and for an -# executable. -KEEPOBJS = true ; - -# under BeOS use copyattr instead of cp -if $(OS) = BEOS -{ - CP = copyattr --data ; -} - -# for builds of tools in the current environment -if $(OS) = BEOS { - BUILD_LIBSTDC++ = stdc++.r4 ; -} else { - BUILD_LIBSTDC++ = stdc++ ; -} - -if $(GCC_VERSION[1]) >= 3 { - C++_SUPPORT_LIBS = supc++ ; - KERNEL_C++_SUPPORT_LIBS = -L/usr/lib -l$(C++_SUPPORT_LIBS) -lgcc_eh ; - # TODO: -L/usr/lib is a bit Linux specific. - STL_HEADERS = /usr/include/g++ ; - # TODO: Also a bit Linux specific. -} else { - C++_SUPPORT_LIBS = ; - KERNEL_C++_SUPPORT_LIBS = ; - STL_HEADERS = [ FDirName $(OBOS_TOP) headers cpp ] ; -} - - -# If no OBOS_OBJECT_TARGET is not defined yet, use our default directory and -# include our "OBOS_TARGET" as subdirectory in there (to prevent different -# builds mixing objects from different targets). -if ! $(OBOS_OBJECT_TARGET) { - OBOS_OBJECT_TARGET ?= [ FDirName $(OBOS_TOP) objects $(OBOS_TARGET) ] ; -} - -# If no OBOS_DISTRO_TARGET is not defined yet, use our default directory and -# include our "OBOS_TARGET" as subdirectory in there (to prevent different -# builds mixing executables from different targets). -if ! $(OBOS_DISTRO_TARGET) { - OBOS_DISTRO_TARGET ?= [ FDirName $(OBOS_TOP) distro $(OBOS_TARGET) ] ; -} - -# Set our version number if not already set and mark it as a developer build -if ! $(OBOS_BUILD_VERSION) { - OBOS_BUILD_VERSION ?= "1 0 0 a 1" ; - OBOS_BUILD_DESCRIPTION ?= "Developer Build" ; -} - -# If OBOS_BUILD_VERSION is set, but OBOS_BUILD_DESCRIPTION isn't, mark it as -# an unknown build. -if ! $(OBOS_BUILD_DESCRIPTION) { - OBOS_BUILD_DESCRIPTION ?= "Unknown Build" ; -} - -# Relative subdirs for distro dir -OBOS_ADDON_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system add-ons ] ; -OBOS_APPS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos apps ] ; -OBOS_BIN_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos bin ] ; -OBOS_ETC_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos etc ] ; -OBOS_FONTS_DIR ?= [ FDirName $(OBOS_ETC_DIR) fonts ] ; -OBOS_KERNEL_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system ] ; -OBOS_PREFS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos preferences ] ; -OBOS_SERVER_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system servers ] ; -OBOS_SHLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ; -OBOS_STLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) develop lib - $(OBOS_ARCH) ] ; -OBOS_TEST_DIR ?= [ FDirName $(OBOS_TOP) tests ] ; - -OBOS_PACKAGE_DIR ?= [ FDirName $(OBOS_TOP) packages $(OBOS_TARGET) ] ; -OBOS_PACKAGE_OBJECT_DIR ?= [ FDirName $(OBOS_OBJECT_TARGET) packages ] ; - -OBOS_KERNEL_CONFIG = config.$(OBOS_ARCH).ini ; -OBOS_KERNEL = kernel.$(OBOS_ARCH) ; -OBOS_FLOPPY = floppy.$(OBOS_ARCH) ; - -rule SetupIncludes -{ - local os_includes = add-ons add-ons/file_system add-ons/graphics - add-ons/input_server add-ons/screen_saver - add-ons/tracker app device drivers game interface - kernel media mail midi midi2 net opengl storage support - translation ; - - # Overwrite any exiting content when changing HDRS. This rule may be invoked multiple times. - - # Use headers directory, to allow to do things like include - HDRS = [ FDirName $(OBOS_TOP) headers ] ; - - # Use posix headers directory - HDRS += [ FDirName $(OBOS_TOP) headers posix ] ; - -# TODO: This is actually more correct. Under BeOS -# /boot/develop/headers/posix/_G_config.h is included, which is not correct, -# since we use another glibc version. This might even be a reason why STL -# string has problems (see strace sources). The problem is just that there -# are conflicts with STL/gcc headers, if we do that. -# # This is nasty, but we don't get around it, since some public headers -# # include _G_config.h which in turn includes other private headers. -# HDRS += [ FDirName $(OBOS_TOP) src kernel libroot posix glibc include ] ; -# HDRS += [ FDirName $(OBOS_TOP) src kernel libroot posix glibc include arch -# $(OBOS_ARCH) ] ; -# HDRS += [ FDirName $(OBOS_TOP) src kernel libroot posix glibc ] ; -# HDRS += [ FDirName $(OBOS_TOP) src kernel libroot posix glibc libio ] ; -# # for _G_config.h - - HDRS += $(STL_HEADERS) ; - - # Use public OS header directories - HDRS += [ PublicHeaders $(os_includes) ] ; - - # Use the root of the private headers -- not so nice, but simplifies things. - HDRS += [ PrivateHeaders $(DOT) ] ; - - # Used as a fallback, the R5 header directories (we should remove this as soon as possible) - HDRS += /boot/develop/headers/posix /boot/develop/headers/cpp ; - - # The platform dependent headers. - HDRS += $(PLATFORM_HEADERS) ; -} - -rule SetupR5Includes -{ - # Unsets HDRS, so that the OBOS headers do not `shadow' the system headers. - HDRS = ; -} - -rule SetupDefaultIncludes -{ - # Resets HDRS to the default headers for the build platform. - HDRS = $(PLATFORM_DEFAULT_HEADERS) ; -} - -#------------------------------------------------------------------------------- -# Things Jam needs in order to work :) -#------------------------------------------------------------------------------- - -rule Object -{ - # This is basically the original Jambase 2.4 Object rule stripped by - # comments. Only the final switch statement has been changed to allow - # intermediate C++ files for Yacc and Lex. - - LocalClean clean : $(<) ; - - MakeLocate $(<) : $(LOCATE_TARGET) ; - SEARCH on $(>) = $(SEARCH_SOURCE) ; - - HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ; - - HDRRULE on $(>) = HdrRule ; - HDRSCAN on $(>) = $(HDRPATTERN) ; - HDRSEARCH on $(>) = - $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ; - - HDRGRIST on $(>) = $(HDRGRIST) ; - - DEFINES on $(<) += $(DEFINES) ; - - # if source is not .c, generate .c with specific rule - - switch $(>:S) - { - case .asm : As $(<) : $(>) ; - case .c : Cc $(<) : $(>) ; - case .C : C++ $(<) : $(>) ; - case .cc : C++ $(<) : $(>) ; - case .cpp : C++ $(<) : $(>) ; - case .f : Fortran $(<) : $(>) ; - case .l : if [ on $(2) return $(GENERATE_C++) ] { - C++ $(<) : $(<:S=.cpp) ; - LexC++ $(<:S=.cpp) : $(>) ; - } else { - Cc $(<) : $(<:S=.c) ; - Lex $(<:S=.c) : $(>) ; - } - case .s : As $(<) : $(>) ; - case .y : if [ on $(2) return $(GENERATE_C++) ] { - C++ $(<) : $(<:S=.cpp) ; - Bison $(<:S=.cpp) : $(>) ; - } else { - Cc $(<) : $(<:S=$(YACCGEN)) ; - Yacc $(<:S=$(YACCGEN)) : $(>) ; - } - case * : UserObject $(<) : $(>) ; - } -} - -rule UserObject -{ - switch $(2) - { - case *.S : assemble $(1) : $(2) ; - case *.o : return ; - case * : ECHO "unknown suffix on" $(2) ; - } -} - -# Override the default to give "prettier" command lines. -actions Cc -{ - $(CC) $(CCFLAGS) -c "$(2)" $(CCDEFS) $(CCHDRS) -o "$(1)" ; -} - -actions C++ -{ - $(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; -} - - -#------------------------------------------------------------------------------- -# General High-level OBOS target rules -#------------------------------------------------------------------------------- - -rule App -{ - # App : : : ; - SetupIncludes ; - SetupObjectsDir ; - AddResources $(1) : $(4) ; - Main $(1) : $(2) ; - MakeLocate $(1) : $(OBOS_APPS_DIR) ; - LinkSharedOSLibs $(1) : $(3) ; - LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] - -Xlinker -soname=_APP_ ; -} - -rule BinCommand -{ - # BinCommand : : : ; - SetupIncludes ; - SetupObjectsDir ; - AddResources $(1) : $(4) ; - Main $(1) : $(2) ; - MakeLocate $(1) : $(OBOS_BIN_DIR) ; - LinkSharedOSLibs $(1) : $(3) ; - LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] - -Xlinker -soname=_APP_ ; -} - -rule StdBinCommands -{ - # StdBinCommands : : ; - SetupIncludes ; - SetupObjectsDir ; - local libs = $(2) ; - local ress = $(3) ; - local source ; - for source in $(1) - { - local target = $(source:S=) ; - - BinCommand $(target) : $(source) : $(libs) : $(ress) ; - } -} - -rule Preference -{ - # Preference : : : ; - SetupIncludes ; - SetupObjectsDir ; - AddResources $(1) : $(4) ; - Main $(1) : $(2) ; - MakeLocate $(1) : $(OBOS_PREFS_DIR) ; - LinkSharedOSLibs $(1) : $(3) ; - LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] - -Xlinker -soname=_APP_ ; -} - -rule Server -{ - # Server : : ; - - SetupIncludes ; - SetupObjectsDir ; - Main $(1) : $(2) ; - MakeLocate $(1) : $(OBOS_SERVER_DIR) ; - LinkSharedOSLibs $(1) : $(3) ; - LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] - -Xlinker -soname=_APP_ ; -} - -# test pseudo targets -NOTFILE obostests ; -NOTFILE r5tests ; - -rule CommonTestLib -{ - # CommonTestLib : : - # : : : ; - # Builds a unit test for both OBOS and R5 modules. - # The name of the target. - # The list of sources. - # A list of link libraries for the OBOS tests (as passed - # to LinkSharedOSLibs). - # A list of link libraries for the R5 tests (as passed - # to LinkSharedOSLibs). - # A list of link libraries for both OBOS tests and R5 tests - # that have a common name (i.e. specify libx.so and the OBOS tests will link - # to libx.so and the R5 tests will link to libx_r5.so). - # A list of public header dirs (as passed to - # UsePublicHeaders). - - TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester lib ] : $(3) $(5) : $(6) ; - R5TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester_r5 lib ] : $(4) [ R5SharedLibraryNames $(5) ] ; -} - -rule TestLib -{ - # TestLib : : : : - # Builds a unit test library for an OBOS module. - # The name of the target. - # The list of sources. - # The directory for the target (as passed to FDirName). - # A list of link libraries (as passed to LinkSharedOSLibs). - # A list of public header dirs (as passed to - # UsePublicHeaders). - - local target = $(1) ; - local sources = $(2) ; - local dest = $(3) ; - local libraries = $(4) ; - local headerDirs = $(5) ; - local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; - - # Our Main replacement. - MainFromObjects $(target) : $(objects) ; - TestObjects $(sources) : $(headerDirs) ; - - MakeLocate $(target) : $(dest) ; - Depends $(target) : libcppunit.so ; - Depends obostests : $(target) ; - LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; - LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; -} - -rule R5TestLib -{ - # R5TestLib : : : - # Builds a unit test for an R5 module. "_r5" is appended to the object - # and the target name. - # The name of the target. - # The list of sources. - # The directory for the target (as passed to FDirName). - # A list of link libraries (as passed to LinkSharedOSLibs). - - local target = $(1:B)_r5$(1:S) ; - local sources = $(2) ; - local dest = $(3) ; - local libraries = $(4) ; - local objects = [ R5ObjectNames $(sources) ] ; - - # Our Main replacement. - MainFromObjects $(target) : $(objects) ; - TestObjects $(sources) : : true ; - - MakeLocate $(target) : $(dest) ; - Depends $(target) : libcppunit.so ; - Depends r5tests : $(target) ; - LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; - LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; -} - -rule CommonUnitTest -{ - # CommonUnitTest : : : - # : : ; - # Builds a unit test for both OBOS and R5 modules. - # The name of the target. - # The list of sources. - # The directory for the target (as passed to FDirName). - # A list of link libraries for the OBOS tests (as passed - # to LinkSharedOSLibs). - # A list of link libraries for the R5 tests (as passed - # to LinkSharedOSLibs). - # A list of public header dirs (as passed to - # UsePublicHeaders). - - UnitTest $(1) : $(2) : $(3) : $(4) : $(6) ; - R5UnitTest $(1) : $(2) : $(3) : $(5) ; -} - -rule UnitTest -{ - # UnitTest : : : : - # Builds a unit test for an OBOS module. - # The name of the target. - # The list of sources. - # The directory for the target (as passed to FDirName). - # A list of link libraries (as passed to LinkSharedOSLibs). - # A list of public header dirs (as passed to - # UsePublicHeaders). - - local target = $(1) ; - local sources = $(2) ; - local dest = $(3) ; - local libraries = $(4) ; - local headerDirs = $(5) ; - local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; - - # Our Main replacement. - MainFromObjects $(target) : $(objects) ; - TestObjects $(sources) : $(headerDirs) ; - - MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; - Depends $(target) : libcppunit.so ; - Depends obostests : $(target) ; - LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; -} - -rule R5UnitTest -{ - # R5UnitTest : : : - # Builds a unit test for an R5 module. "_r5" is appended to the object - # and the target name. - # The name of the target. - # The list of sources. - # The directory for the target (as passed to FDirName). - # A list of link libraries (as passed to LinkSharedOSLibs). - - local target = $(1)_r5 ; - local sources = $(2) ; - local dest = $(3) ; - local libraries = $(4) ; - local objects = [ R5ObjectNames $(sources) ] ; - - # Our Main replacement. - MainFromObjects $(target) : $(objects) ; - TestObjects $(sources) : : true ; - - MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; - Depends $(target) : libcppunit.so ; - Depends r5tests : $(target) ; - LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; -} - -rule R5ObjectNames -{ - # R5ObjectNames ; - # Returns a list of gristed object names given a list of source file names. - # Moreover each object names gets "_r5" inserted before the object suffix. - local objects = $(1:S=)_r5 ; - return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ; -} - -rule R5Objects -{ - # R5Objects - # Similar to Objects, but appends "_r5" to the object file names and - # removes `-nostdinc' from the CC and C++ flags to enable system headers. - # The source files. - - # Remove `-nostdinc' from CCFLAGS and C++FLAGS. - local oldCCFLAGS = $(CCFLAGS) ; - local oldC++FLAGS = $(C++FLAGS) ; - CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; - C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; - - local sources = $(1) ; - local source ; - for source in [ FGristFiles $(sources) ] - { - local object = [ R5ObjectNames $(source) ] ; - Object $(object) : $(source) ; - LocalDepends obj : $(object) ; - } - - # Reset CCFLAGS and C++FLAGS to original values. - CCFLAGS = $(oldCCFLAGS) ; - C++FLAGS = $(oldC++FLAGS) ; -} - -rule TestObjects -{ - # TestLib : : - # Compiles objects for tests. - # The list of sources. - # A list of public header dirs (as passed to - # UsePublicHeaders). - # If set, "_r5" is appended to the object file names and - # is ignored. Furthermore the pre-processor macro - # TEST_R5 is defined, TEST_OBOS otherwise. - - local sources = $(1) ; - local headerDirs = $(2) ; - local r5 = $(3) ; - local objects ; - - # Turn optimization off. - if ! $(NO_TEST_DEBUG) { - local optim = $(OPTIM) ; - OPTIM = ; - } - - SetupObjectsDir ; - - # compile - if $(r5) { - SetupR5Includes ; - objects = [ R5ObjectNames $(sources) ] ; - R5Objects $(sources) ; - } else { - SetupIncludes ; - objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; - Objects $(sources) ; - } - - # set headers/defines - UseCppUnitObjectHeaders $(sources) : $(objects) ; - if $(r5) { - ObjectsDefines $(objects) : TEST_R5 ; - } else { - UsePublicObjectHeaders $(sources) : $(headerDirs) : $(objects) ; - ObjectsDefines $(objects) : TEST_OBOS ; - } - - if ! $(NO_TEST_DEBUG) { - # Turn debugging on. That is usually desired for test code. - ObjectCcFlags $(objects) : $(DEBUG_FLAGS) ; - ObjectC++Flags $(objects) : $(DEBUG_FLAGS) ; - - # Turn optimization on again. - OPTIM = $(optim) ; - } -} - -rule R5SharedLibraryNames -{ - # R5SharedLibraryNames ; - # Returns a list of shared library names given a list of file names. NO - # GRISTING IS PERFORMED :-) However, each library names gets "_r5" inserted - # before the shared lib suffix. - return $(1:S=)_r5.so ; -} - -rule SimpleTest -{ - # UnitTest : : - # Builds a unit test for an OBOS module. - # The name of the target. - # The list of sources. - # The directory for the target (as passed to FDirName). - # A list of link libraries (as passed to LinkSharedOSLibs). - # A list of public header dirs (as passed to - # UsePublicHeaders). - - local target = $(1) ; - local sources = $(2) ; - local libraries = $(3) ; - local relPath = [ FRelPath src tests : $(SUBDIR_TOKENS) ] ; - - # Turn optimization off. - if ! $(NO_TEST_DEBUG) { - local optim = $(OPTIM) ; - OPTIM = ; - } - - SetupIncludes ; - SetupObjectsDir ; - MakeLocateObjects $(sources) ; - Main $(target) : $(sources) ; - MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; - Depends obostests : $(target) ; - LinkSharedOSLibs $(target) : $(libraries) ; - ObjectsDefines $(sources) : TEST_OBOS ; - if ! $(NO_TEST_DEBUG) { - # Turn debugging on. That is usually desired for test code. - ObjectCcFlags $(sources) : $(DEBUG_FLAGS) ; - ObjectC++Flags $(sources) : $(DEBUG_FLAGS) ; - - # Turn optimization on again. - OPTIM = $(optim) ; - } -} - -rule Addon -{ - # Addon : : : : ; - # : Name of the add-on. - # : Path where the add-on shall live relative to the add-on dir. - # : Source files. - # : true, if the target shall be executable as well. - # : Libraries to be linked against. - - local isExecutable = $(4) ; - - SetupIncludes ; - SetupObjectsDir ; - Main $(1) : $(3) ; - - # Create output dir path for addon - local targetdir; - targetdir = [ FDirName $(OBOS_ADDON_DIR) $(2) ] ; - - MakeLocate $(1) : $(targetdir) ; - - local linkFlags = -Xlinker -soname=\"$(1)\" ; - if $(isExecutable) != true { - linkFlags = -nostart $(linkFlags) ; - } - LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] $(linkFlags) ; - LinkSharedOSLibs $(1) : $(5) ; -} - -rule R5KernelAddon -{ - # R5KernelAddon : : : ; - - local sources = $(3) ; - - Addon $(1) : $(2) : $(3) ; - ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -fno-pic ; - ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -fno-pic -fno-exceptions ; - LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; - LinkSharedOSLibs $(1) : $(4) /boot/develop/lib/x86/_KERNEL_ ; -} - -rule Translator -{ - # Translator : : ; - SetupIncludes ; - SetupObjectsDir ; - Main $(1) : $(2) ; - LinkSharedOSLibs $(1) : $(3) ; - - # Create output dir path for translator - local targetdir; - targetdir = [ FDirName $(OBOS_ADDON_DIR) Translators ] ; - MakeLocate $(1) : $(targetdir) ; -} - -rule ScreenSaver -{ - # ScreenSaver : : ; - Addon $(1) : screen_savers : $(2) : false : $(3) ; -} - -rule MakeLocateObjects -{ - # MakeLocateObjects ; - - local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; - - for o in $(_objs) - { - local dir = $(o:D) ; - if $(dir) { - MakeLocate $(o) : [ FDirName $(LOCATE_TARGET) $(dir) ] ; - } else { - MakeLocate $(o) : $(LOCATE_TARGET) ; - } - } -} - -rule StaticLibrary -{ - # StaticLibrary : [ : [ : ] ] ; - # Creates a static library from sources. - # : Basename of the library, without leading "lib" and trailing ".a". - # Grist is allowed -- it will be re-prepended after constructing - # the complete library name. - # : List of source files. - # : Directory into which the library shall be placed. Defaults - # to the objects directory for this subdir. If - # STATIC_LIBRARY_DIR is supplied (the literal string) - # the standard directory for static libs is used, otherwise - # the parameter is interpreted as directory path. - # : static libraries to include (ie: libmesa_x86.a) - - local lib = lib$(1:B)$(SUFLIB) ; - lib = $(lib:G=$(1:G)) ; - SetupIncludes ; - SetupObjectsDir ; - MakeLocateObjects $(2) ; - StaticLibraryFromObjects $(lib) : [ FGristFiles $(2:S=$(SUFOBJ)) ] ; - Objects $(2) ; - if $(4) { - StaticLibraryFromObjects $(lib) : $(4) ; - } - local targetDir = $(3) ; - if $(targetDir) { - if $(targetDir) = STATIC_LIBRARY_DIR { - targetDir = $(OBOS_STLIB_DIR) ; - } - MakeLocate $(lib) : $(targetDir) ; - } else { - # nothing to do, since the Library rule already located the library - # in $(LOCATE_TARGET) - } - - # If KEEPOBJS is set, Library doesn't make the library depend on - # `lib'. - if $(KEEPOBJS) { - LocalDepends lib : $(lib) ; - } -} - -rule StaticLibraryFromObjects -{ - local _i _l _s ; - - # Add grist to file names - - _s = $(>) ; - _l = $(<:S=$(SUFLIB)) ; - - # library depends on its member objects - - if $(KEEPOBJS) - { - LocalDepends obj : $(_s) ; - } - else - { - LocalDepends lib : $(_l) ; - } - - # Set LOCATE for the library and its contents. The bound - # value shows up as $(NEEDLIBS) on the Link actions. - # For compatibility, we only do this if the library doesn't - # already have a path. - - if ! $(_l:D) - { - MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_TARGET) ; - } - - if $(NOARSCAN) - { - # If we can't scan the library to timestamp its contents, - # we have to just make the library depend directly on the - # on-disk object files. - - Depends $(_l) : $(_s) ; - } - else - { - # If we can scan the library, we make the library depend - # on its members and each member depend on the on-disk - # object file. - - Depends $(_l) : $(_l)($(_s:BS)) ; - - for _i in $(_s) - { - Depends $(_l)($(_i:BS)) : $(_i) ; - } - } - - LocalClean clean : $(_l) ; - - if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; } - - Archive $(_l) : $(_s) ; - - if $(RANLIB) { Ranlib $(_l) ; } - - # If we can't scan the library, we have to leave the .o's around. - - if ! ( $(NOARSCAN) || $(NOARUPDATE) ) { RmTemps $(_l) : $(_s) ; } -} - -rule R5KernelStaticLibrary -{ - # R5KernelStaticLibrary : ; - - local lib = lib$(1)$(SUFLIB) ; - local sources = $(2) ; - - SetupIncludes ; - SetupObjectsDir ; - MakeLocateObjects $(sources) ; - Library $(lib) : $(sources) ; - ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -fno-pic ; - ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -fno-pic -fno-exceptions ; -} - -rule MergeObjectFromObjects -{ - # MergeObjectFromObjects : : ; - # Merges object files to an object file. - # : Name of the object file to create. No grist will be added. - # : Object files to be merged. Grist will be added. - # : Object files or static libraries to be merged. No grist - # will be added. - # - local objects = [ FGristFiles $(2) ] ; - MakeLocate $(1) : $(LOCATE_TARGET) ; - Depends $(1) : $(objects) ; - Depends $(1) : $(3) ; - LocalDepends obj : $(1) ; - LINK on $(1) = ld ; - MergeObjectFromObjects1 $(1) : $(objects) $(3) ; -} - -actions MergeObjectFromObjects1 -{ - $(LINK) -r $(2) -o $(1) ; -} - -rule MergeObject -{ - # MergeObject : : ; - # Compiles source files and merges the object files to an object file. - # : Name of the object file to create. No grist will be added. - # : Sources to be compiled. Grist will be added. - # : Object files or static libraries to be merged. No grist - # will be added. - # - SetupIncludes ; - SetupObjectsDir ; - MakeLocateObjects $(2) ; - Objects $(2) ; - MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; -} - -rule SharedLibraryFromObjects -{ - # SharedLibraryFromObjects : : ; - local _lib = lib$(1:B).so ; - _lib = $(_lib:G=$(1:G)) ; - MainFromObjects $(_lib) : $(2) ; - MakeLocate $(_lib) : $(OBOS_SHLIB_DIR) ; - LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ] - -nostart -Xlinker -soname=\"$(_lib)\" ; - LinkSharedOSLibs $(_lib) : $(3) ; -} - -rule SharedLibrary -{ - # SharedLibrary : : ; - SetupIncludes ; - SetupObjectsDir ; - MakeLocateObjects $(2) ; - Objects $(2) ; - SharedLibraryFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; -} - -rule LinkSharedOSLibs -{ - # LinkSharedOSLibs : ; - # Valid elements for are e.g. "be" or "libopenbeos.so" or - # "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy - # has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the - # file will be bound!), otherwise it is prefixed "-l" and added to - # LINKLIBS. If you want to specify a target that isn't a library and - # also has neither grist nor a dirname, you can prepend "" as - # grist; it will be stripped by this rule. - - for i in $(>) - { - local isfile = ; - if $(i:D) || $(i:G) { - isfile = true ; - if $(i:G) = { - i = $(i:G=) ; - } - } else { - switch $(i:B) - { - # XXX: _APP_ and _KERNEL_ should not be needed for ELF. - case _APP_ : isfile = true ; - case _KERNEL_ : isfile = true ; - case lib* : isfile = true ; - case * : isfile = ; - } - if ! $(isfile) && ( $(i:S) = .so || $(i:S) = .a ) { - isfile = true ; - } - } - if $(isfile) { - NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(i) ; - if ! $(NO_LIBRARY_DEPENDENCIES) { - Depends $(1) : $(i) ; - } - } else { - LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] -l$(i) ; - } - } -} - -rule AddResources -{ - # AddResources : ; - - local resfiles = [ FGristFiles $(2) ] ; - SEARCH on $(resfiles) += $(SEARCH_SOURCE) ; - - for file in $(resfiles) { - if $(file:S) = .rdef { - local rdef = $(file) ; - file = $(rdef:S=.rsrc) ; - ResComp $(file) : $(rdef) ; - } - RESFILES on $(1) += $(file) ; - } -} - -if $(OS) = BEOS { - -rule ResComp -{ - # ResComp : ; - # - # and must be gristed. - - SetupObjectsDir ; - - SEARCH on $(2) += $(SEARCH_SOURCE) ; - MakeLocate $(1) : $(LOCATE_TARGET) ; - Depends $(1) : $(2) rc ; - LocalClean clean : $(1) ; - ResComp1 $(1) : rc $(2) ; -} - -} else { - -rule ResComp -{ -} - -} - -actions ResComp1 -{ - $(2[1]) -o $(1) $(2[2-]) -} - -rule ObjectsDefines -{ - # Like ObjectDefines, but allows multiple files to be supplied - local file ; - for file in $(1) { - ObjectDefines $(file) : $(2) ; - } -} - -rule SourceHdrs -{ - # SourceHdrs : [ : ] ; - # - # Is a wrapper for ObjectHdrs, that passes and or, - # if supplied and , and also adjusts HDRSEARCH (not - # done by ObjectHdrs). - - local sources = [ FGristFiles $(1) ] ; - local headers = $(2) ; - local objects = $(3) ; - - local file ; - if $(objects) { - for file in $(objects) { - ObjectHdrs $(file) : $(headers) ; - # also reformat the assembler headers - ASHDRS on $(file) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) - [ on $(file) return $(HDRS) ] ] ; - } - } else { - for file in $(sources:S=$(SUFOBJ)) { - ObjectHdrs $(file) : $(headers) ; - # also reformat the assembler headers - ASHDRS on $(file) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) - [ on $(file) return $(HDRS) ] ] ; - } - } - - # Also add the header search dirs to HDRSEARCH. Note, that these dirs - # will be listed after the STDHDRS (if any), but that's better than not - # being listed at all. - HDRSEARCH on $(sources) += $(headers) ; -} - -rule PublicHeaders -{ - # PublicHeaders - # - # Returns the directory names for the public header dirs identified by - # . - - local list = $(1) ; - local dirs = [ FDirName $(OBOS_TOP) headers os ] ; - - for i in $(list) { - dirs += [ FDirName $(OBOS_TOP) headers os $(i) ] ; - } - return $(dirs) ; -} - -rule PrivateHeaders -{ - # PrivateHeaders - # - # Returns the directory names for the private header dirs identified by - # . - - local list = $(1) ; - local dirs ; - for i in $(list) { - dirs += [ FDirName $(OBOS_TOP) headers private $(i) ] ; - } - return $(dirs) ; -} - -rule LibraryHeaders -{ - # LibraryHeaders - # - # Returns the directory names for the library header dirs identified by - # . - - local list = $(1) ; - local dirs ; - for i in $(list) { - dirs += [ FDirName $(OBOS_TOP) headers libs $(i) ] ; - } - return $(dirs) ; -} - -rule ArchHeaders -{ - # usage: ArchHeaders ; - # - # specifies the architecture (e.g. x86). - - return [ FDirName $(OBOS_TOP) headers private kernel arch $(1) ] ; -} - -rule UsePublicHeaders -{ - # UsePublicHeaders ; - # - # Adds the public C header dirs given by to the header search - # dirs of the subdirectory. - # NOTE: This rule must be invoked *before* the rule that builds the - # objects. - - UseHeaders [ PublicHeaders $(1) ] ; -} - -rule UsePublicObjectHeaders -{ - # UsePublicObjectHeaders : [ : ] ; - # - # Adds the public C header dirs given by to the header search - # dirs of either the object targets of or if supplied to - # . Also adjusts HDRSEARCH of . - # NOTE: This rule must be invoked *after* the rule that builds the objects. - - SourceHdrs $(1) : [ PublicHeaders $(2) ] : $(3) ; -} - -rule UsePrivateHeaders -{ - # UsePrivateHeaders ; - # - # Adds the private C header dirs given by to the header search - # dirs of the subdirectory. - # NOTE: This rule must be invoked *before* the rule that builds the objects. - - UseHeaders [ PrivateHeaders $(1) ] ; -} - -rule UsePrivateObjectHeaders -{ - # UsePrivateObjectHeaders : [ : ] ; - # - # Adds the private C header dirs given by to the header search - # dirs of either the object targets of or if supplied to - # . Also adjusts HDRSEARCH of . - # NOTE: This rule must be invoked *after* the rule that builds the objects. - - SourceHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; -} - -rule UseHeaders -{ - # UseHeaders ; - # - # Adds the C header dirs to the header search - # dirs of the subdirectory. - # NOTE: This rule must be invoked *before* the rule that builds the objects. - - local header ; - for header in $(1) { - SubDirHdrs $(header) ; - } -} - -rule UseCppUnitHeaders -{ - SubDirHdrs [ FDirName $(OBOS_TOP) headers tools cppunit ] ; -} - -rule UseCppUnitObjectHeaders -{ - # UseCppUnitObjectHeaders [ : ] ; - SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers tools cppunit ] : $(2) ; -} - -rule UseArchHeaders -{ - # usage: UseArchHeaders ; - # - # specifies the architecture (e.g. x86). - # NOTE: This rule must be invoked *before* the rule that builds the objects. - - local headers = [ ArchHeaders $(1) ] ; - local opt = -D$(OBOS_TARGET_DEFINE) ; - - SubDirCcFlags $(opt) ; - SubDirC++Flags $(opt) ; - UseHeaders $(headers) ; -} - -rule UseArchObjectHeaders -{ - # usage: UseArchObjectHeaders : : [ ] ; - # - # specifies the architecture (e.g. x86). - # Source or object files. - # NOTE: This rule must be invoked *after* the rule that builds the objects. - - local sources = $(1) ; - local headers = [ ArchHeaders $(2) ] ; - local objects = $(3) ; - local targets ; - if $(objects) { - targets = $(objects) ; - } else { - targets = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; - } - local opt = -D$(OBOS_TARGET_DEFINE) ; - - ObjectCcFlags $(targets) : $(opt) ; - ObjectC++Flags $(targets) : $(opt) ; - SourceHdrs $(sources) : $(headers) : $(objects) ; -} - -rule UsePosixHeaders -{ - # XXX changed to do nothing -} - -rule UsePosixObjectHeaders -{ - # UsePosixObjectHeaders [ : ] ; - # - # Adds the POSIX header dir to the header search - # dirs of either the object targets of or if supplied to - # . Also adjusts HDRSEARCH of . - # NOTE: This rule must be invoked *after* the rule that builds the objects. - - SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers posix ] : $(2) ; -} - -rule UseLibraryHeaders -{ - # UseLibraryHeaders ; - # - # Adds the library header dirs given by to the header search - # dirs of the subdirectory. - # NOTE: This rule must be invoked *before* the rule that builds the objects. - - UseHeaders [ LibraryHeaders $(1) ] ; -} - -rule SplitPath -{ - # SplitPath ; - # Decomposes a path into its components. - local path = $(1:G=) ; - local components ; - # $(path:D) for "/" is "/". Therefore the second condition. - while $(path:D) && $(path:D) != $(path) - { - # Note: $(path:B) returns "." for "..", but $(path:D=) is fine. - components = $(path:D=) $(components) ; - path = $(path:D) ; - } - components = $(path) $(components) ; - return $(components) ; -} - -rule PrependObjectHdrs -{ - # PrependObjectHdrs : ; - # Prepends to the list of header search dirs of the objects - # specified by . The HDRS variable will not be - # changed, only CCHDRS. - # Note: A subsequent ObjectHdrs invocation will therefore undo the - # effect of this rule. - # NOTE: This is a hack. - - local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; - local dirs = $(2) ; - for object in $(objects) { - # Don't change HDRS to avoid screwing up the header scanning. - PREPENDED_HDRS on $(object) - = $(dirs) [ on $(object) return $(PREPENDED_HDRS) ] ; - CCHDRS on $(object) - = [ FIncludes [ on $(object) return $(PREPENDED_HDRS) $(HDRS) ] ] ; - } -} - -rule SymLink -{ - # SymLink : : ; - # Links to . - # is the exact link contents. No binding is done. - # If true, will be made a dependency - # of the `all' pseudo target, i.e. it will be made by default, and removed - # on `jam clean'. - - local target = $(1) ; - local source = $(2) ; - local makeDefaultDependencies = $(3) ; - if ! $(makeDefaultDependencies) { - makeDefaultDependencies = true ; - } - LINKCONTENTS on $(target) = $(source) ; - SymLink1 $(target) ; - if $(makeDefaultDependencies) = true { - LocalDepends files : $(target) ; - LocalClean clean : $(target) ; - } -} - -actions SymLink1 -{ - $(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)" -} - -rule RelSymLink -{ - # RelSymLink : : ; - # Creates a relative symbolic link from to . - # and can be usual targets. They may have a grist - # and don't need to have any dirname. Their LOCATE variables are used to - # find their locations. - # If true (which is the default), will be - # made a dependency of the `files' pseudo target, i.e. it will be made by - # default, and removed on `jam clean'. - - local target = $(1) ; - local source = $(2) ; - local makeDefaultDependencies = $(3) ; - local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ; - local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ; - local sourcePath = $(source:G=) ; - sourcePath = $(sourcePath:D=$(sourceDir)) ; - local targetDirComponents = [ SplitPath $(targetDir) ] ; - local sourceComponents = [ SplitPath $(sourcePath) ] ; - - SymLink $(target) - : [ FRelPath $(targetDirComponents) : $(sourceComponents) ] - : $(makeDefaultDependencies) ; - NOUPDATE $(target) ; - Depends $(target) : $(source) ; -} - -rule AbsSymLink -{ - # AbsSymLink : : - # : ; - # Creates an absolute symbolic link from to . - # and must be usual targets. If is - # given, then it is set as LOCATE directory on . - # If true (which is the default), will be - # made a dependency of the `files' pseudo target, i.e. it will be made by - # default, and removed on `jam clean'. - - local makeDefaultDependencies = $(4) ; - if ! $(makeDefaultDependencies) { - makeDefaultDependencies = true ; - } - - Depends $(1) : $(2) ; - if $(3) { - MakeLocate $(1) : $(3) ; - } - SEARCH on $(2) += $(SEARCH_SOURCE) ; - if $(makeDefaultDependencies) = true { - LocalDepends files : $(1) ; - LocalClean clean : $(1) ; - } -} - -actions AbsSymLink -{ - target="$(2)" - case "$target" in - /*) ;; - *) target=`pwd`/"$target";; - esac - $(RM) "$(1)" && $(LN) -s "$target" "$(1)" -} - -rule OBOSInstall -{ - # Usage: OBOSInstall <[ install [ and uninstall ] pseudotarget ]> - # : : - # : [ ] : [ ] ; - local install = $(1[1]) ; - install ?= install ; - local uninstall = $(1[2]) ; - uninstall ?= un$(install) ; - local dir = $(2) ; - local sources = $(3) ; - local installgrist = $(4) ; - installgrist ?= $(INSTALLGRIST) ; - local installRule = $(5) ; - installRule ?= Install ; - local targets = $(sources:G=$(installgrist)) ; - - NotFile $(install) ; - NotFile $(uninstall) ; - Depends $(install) : $(targets) ; - Clean $(uninstall) : $(targets) ; - - SEARCH on $(sources) += $(SEARCH_SOURCE) ; - MakeLocate $(targets) : $(dir) ; - - local source ; - for source in $(sources) { - local target = $(source:G=$(installgrist)) ; - - Depends $(target) : $(source) ; - $(installRule) $(target) : $(source) ; - - if [ on $(target) return $(MODE) ] { - Chmod $(target) ; - } - - if $(OWNER) && $(CHOWN) { - Chown $(target) ; - OWNER on $(target) = $(OWNER) ; - } - - if $(GROUP) && $(CHGRP) { - Chgrp $(target) ; - GROUP on $(target) = $(GROUP) ; - } - } -} - -rule InstallAbsSymLinkAdapter -{ - # InstallAbsSymLinkAdapter : - if ! [ on $(2) return $(TARGET) ] { - TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; - } - AbsSymLink $(1) : $(2) : : false ; -} - -rule OBOSInstallAbsSymLink -{ - # Usage: OBOSInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]> - # : : - # : [ ] ; - OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallAbsSymLinkAdapter ; -} - -rule InstallRelSymLinkAdapter -{ - # InstallRelSymLinkAdapter : - if ! [ on $(2) return $(TARGET) ] { - TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; - } - RelSymLink $(1) : $(2) : false ; -} - -rule OBOSInstallRelSymLink -{ - # Usage: OBOSInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]> - # : : - # : [ ] ; - OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ; -} - - -#------------------------------------------------------------------------------- -# Low-level OBOS utility rules -#------------------------------------------------------------------------------- -rule FObjectsDir -{ - # FObjectsDir - # - # Returns the output directory for object files the specified - # subdirectory. - # - # : The tokens of the subdir relative to the top. - # - - return [ FDirName $(OBOS_OBJECT_TARGET) $(1[2-]) ] ; -} - -rule FCurrentObjectsDir -{ - # FCurrentObjectsDir - # - # Returns the output directory for object files for the current - # subdirectory. - - return [ FObjectsDir $(SUBDIR_TOKENS) ] ; -} - -rule SetupObjectsDir -{ - LOCATE_TARGET = [ FCurrentObjectsDir ] ; - LOCATE_SOURCE = $(LOCATE_TARGET) ; - SEARCH_SOURCE = [ Filter $(SEARCH_SOURCE) : $(LOCATE_TARGET) ] - $(LOCATE_TARGET) ; -} - -#------------------------------------------------------------------------------- -# Link rule/action are overwritten as they don't handle linking files who's name -# contain spaces very well. Also adds resources and version to executable. -#------------------------------------------------------------------------------- -rule Link -{ - # Note: RESFILES must be set before invocation. - MODE on $(<) = $(EXEMODE) ; - on $(1) XRes $(1) : $(RESFILES) ; - Chmod $(<) ; - SetType $(1) ; - MimeSet $(1) ; - SetVersion $(1) ; -} - -actions Link bind NEEDLIBS -{ - $(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(2)" "$(NEEDLIBS)" $(LINKLIBS) ; -} - -rule LexC++ -{ - Depends $(1) : $(2) ; - MakeLocate $(1) : $(LOCATE_SOURCE) ; - LocalClean clean : $(1) ; -} - -actions LexC++ -{ - $(LEX) -o$(1) $(2) -} - -rule Bison -{ - local _h ; - - _h = $(1:S=.hpp) ; - - MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ; - - Depends $(<) $(_h) : $(>) ; - Bison1 $(<) $(_h) : $(>) ; - LocalClean clean : $(<) $(_h) ; - - # make sure someone includes $(_h) else it will be - # a deadly independent target - - Includes $(<) : $(_h) ; -} - -actions Bison1 -{ - bison $(YACCFLAGS) -o $(1[1]) $(2) - [ -f $(1[1]).h ] && mv $(1[1]).h $(1[2]) || true -} - -rule UnarchiveObjects -{ - # UnarchiveObjects : - - MakeLocate $(1) : $(LOCATE_TARGET) ; - Depends $(2) : $(1) ; - SEARCH on $(2) = $(SEARCH_SOURCE) ; -} - -actions UnarchiveObjects -{ - cd $(1[1]:D) - ar -x "$(2)" $(1:BS) - cd - -} - -# BeOS specific rules - -rule XRes -{ - # XRes : - if $(2) - { - Depends $(1) : $(2) ; - XRes1 $(1) : $(2) ; - } -} - -rule XRes1 { } - -rule SetVersion -{ - # SetVersion -} - -rule SetType -{ - # SetType -} - -rule MimeSet -{ - # SetType -} - - -if $(OS) = BEOS -{ - -actions XRes1 -{ - xres -o "$(1)" "$(2)" ; -} - -actions SetVersion -{ - setversion "$(1)" -system $(OBOS_BUILD_VERSION) -short "$(OBOS_BUILD_DESCRIPTION)" ; -} - -actions SetType -{ - settype -t $(OBOS_TARGET_TYPE) "$(1)" ; -} - -actions MimeSet -{ - mimeset -f "$(1)" ; -} - -} # if BEOS - - -rule assemble -{ - Depends $(<) : $(>) ; - ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ; - ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ; -} - -actions assemble -{ - $(CC) -c "$(2)" -O2 $(ASFLAGS) -D_ASSEMBLER $(KERNEL_CCFLAGS) $(ASHDRS) -o "$(1)" ; -} - -# Overridden to allow spaces in file names. -actions Chmod1 -{ - $(CHMOD) "$(MODE)" "$(1)" -} - -# Overridden to allow spaces in file names. -actions piecemeal together existing Clean -{ - $(RM) "$(>)" -} - -rule ObjectReference -{ - # ObjectReference : - # Makes refer to the same file as . - # The filenames must of course be identical. - # must have already been LOCATEd. - - local ref = $(1) ; - local source = $(2) ; - if $(ref) != $(source) { - Depends $(ref) : $(source) ; - LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ; - } -} - -rule ObjectReferences -{ - # ObjectReferences - # Creates local references to , i.e. identifiers with the - # current grist referring to the same files. must have - # already been LOCATEd. - - local source ; - for source in $(1) { - ObjectReference [ FGristFiles $(source) ] : $(source) ; - } -} - -rule Filter -{ - # Filter : ; - # Removes all occurrences of in . - - local list = $(1) ; - local excludes = $(2) ; - local newList ; - local item ; - for item in $(list) { - local skip ; - local exclude ; - for exclude in $(excludes) { - if $(item) = $(exclude) { - skip = true ; - } - } - if ! $(skip) { - newList += $(item) ; - } - } - return $(newList) ; -} - - -## Kernel stuff! - -rule SetupKernel -{ - # Usage SetupKernel : ; - # - # - Ideally sources, otherwise HDRSEARCH can not be - # set for the sources and the sources some header - # dependencies might be missing. - - local sources = [ FGristFiles $(1) ] ; - local _objs = $(sources:S=$(SUFOBJ)) ; - - #Setup Kernel header directories - local public_kernel_includes = add-ons/file_system add-ons/graphics app device drivers kernel storage support ; - local private_kernel_includes = $(DOT) kernel libroot kernel/boot/platform/$(OBOS_BOOT_PLATFORM) ; - # Use posix headers directory - local headers = [ FDirName $(OBOS_TOP) headers posix ] ; - # Use public OS header directories - headers += [ PublicHeaders $(public_kernel_includes) ] ; - # Use private directories - headers += [ PrivateHeaders $(private_kernel_includes) ] ; - # The platform dependent headers. - headers += $(PLATFORM_HEADERS) ; - - SourceHdrs $(sources) : $(headers) ; - UseArchObjectHeaders $(sources) : $(OBOS_ARCH) ; - - local object ; - for object in $(_objs) { - ObjectCcFlags $(object) : $(KERNEL_CCFLAGS) $(2) ; - ObjectC++Flags $(object) : $(KERNEL_C++FLAGS) $(2) ; - } -} - -rule KernelObjects -{ - SetupObjectsDir ; - - Objects $(1) ; - - SetupKernel $(1) : $(2) ; -} - -rule KernelLd -{ - # KernelLd : : : : : ; - - SetupObjectsDir ; - LINK on $(1) = ld ; - - LINKFLAGS on $(1) = $(4) ; - if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } - - # Remove any preset LINKLIBS - LINKLIBS on $(1) = ; - - # Show that we depend on the libraries we need - LocalClean clean : $(1) ; - LocalDepends all : $(1) ; - Depends $(1) : $(2) ; - - if $(6) { - for i in $(6) { - KernelConfigSection $(i) : elf32 : $(1) ; - } - } - - MakeLocate $(1) : $(LOCATE_TARGET) ; - - # Add the platform specific static libs (libgcc.a). - if ! $(5) { - LINKLIBS on $(1) += $(PLATFORM_LINKLIBS) ; - } - - SetupKernel $(2) ; -} - -actions KernelLd -{ - $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ; -} - -rule KernelAddon -{ - # KernelAddon : : : ; - - local sources = $(3) ; - - SetupObjectsDir ; - Addon $(1) : $(2) : $(sources) ; - ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -fno-pic ; - ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -fno-pic -fno-exceptions ; - LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; - LinkSharedOSLibs $(1) : $(4) kernel.so ; - SetupKernel $(sources) ; -} - -rule KernelMergeObject -{ - # KernelMergeObject : : : ; - # Compiles source files and merges the object files to an object file. - # : Name of the object file to create. No grist will be added. - # : Sources to be compiled. Grist will be added. - # : Additional flags for compilation. - # : Object files or static libraries to be merged. No grist - # will be added. - # - - SetupObjectsDir ; - - MakeLocateObjects $(2) ; - Objects $(2) ; - MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; - - SetupKernel $(2) : $(3) ; -} - -rule KernelStaticLibrary -{ - # Usage KernelStaticLibrary : : ; - # This is designed to take a set of sources and libraries and create - # a file called lib.a - - SetupObjectsDir ; - - MakeLocateObjects $(2) ; - Library $(1) : $(2) ; - - SetupKernel $(2) : $(3) ; -} - -rule KernelStaticLibraryObjects -{ - # Usage KernelStaticLibrary : ; - # This is designed to take a set of sources and libraries and create - # a file called - - SetupObjectsDir ; - - # Show that we depend on the libraries we need - LocalClean clean : $(1) ; - LocalDepends all : $(1) ; - Depends $(1) : $(2) ; - - MakeLocate $(1) : $(LOCATE_TARGET) ; - - SetupKernel $(2) ; -} - -actions KernelStaticLibraryObjects -{ - ar -r "$(1)" "$(2)" ; -} - -rule BuildPlatformMain -{ - # Usage BuildPlatformMain : [ : ] ; - # The executable. - # The sources. - # "false", if header search dirs shall not be reset to the - # platform defaults. Defaults to "true". - # - SetupObjectsDir ; - if $(3) != false { - SetupDefaultIncludes ; - } - - # Remove `-nostdinc' from CCFLAGS and C++FLAGS. Set DEFINES back to what - # was originally defined for the build platform. - local oldCCFLAGS = $(CCFLAGS) ; - local oldC++FLAGS = $(C++FLAGS) ; - local oldDefines = $(DEFINES) ; - CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; - C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; - DEFINES = $(BUILD_PLATFORM_DEFINES) ; - - Main $(1) : $(2) ; - - ObjectsDefines $(2) : _NO_INLINE_ASM ; - # Be careful with find_thread() and the like. - - # Reset CCFLAGS and C++FLAGS to original values. - CCFLAGS = $(oldCCFLAGS) ; - C++FLAGS = $(oldC++FLAGS) ; - DEFINES = $(oldDefines) ; -} - -rule BuildPlatformTest -{ - # Usage BuildPlatformTest : ; - - local target = $(1) ; - local sources = $(2) ; - - BuildPlatformMain $(target) : $(sources) ; - local relPath ; - if [ FIsPrefix src tests : $(SUBDIR_TOKENS) ] { - relPath = $(SUBDIR_TOKENS[3-]) ; - } else { - relPath = $(SUBDIR_TOKENS[2-]) ; - } - MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; -} - -rule KernelConfigSection -{ - # KernelConfigSection
: : ; - - SECTION_NAMES on $(OBOS_KERNEL_CONFIG) += $(1) ; - SECTION_TYPES on $(OBOS_KERNEL_CONFIG) += $(2) ; - SECTION_FILES on $(OBOS_KERNEL_CONFIG) += $(3) ; - - Depends $(OBOS_KERNEL_CONFIG) : $(3) ; -} - -rule WriteKernelConfig -{ - # usage: WriteKernelConfig ; - - LocalDepends files : $(1) ; - - MakeLocate $(1) : $(OBOS_OBJECT_TARGET) ; - - LocalClean clean : $(1) ; -} - -actions WriteKernelConfig bind SECTION_FILES -{ - target="$(1)" - echo "# OpenBeOS Kernel Config File" > "$target" - echo "# Automatically generated - do not edit!" >> "$target" - count=0 - for section in "$(SECTION_NAMES)" ; do - count=`expr $count + 1` - eval section$count="$section" - done - i=1 - for type in "$(SECTION_TYPES)" ; do - eval type$i="$type" - i=`expr $i + 1` - done - i=1 - for file in "$(SECTION_FILES)" ; do - eval file$i="$file" - i=`expr $i + 1` - done - for i in `seq $count` ; do - eval section="\$section$i" - eval type="\$type$i" - eval file="\$file$i" - echo "" >> "$target" - echo "["$section"]" >> "$target" - echo "type="$type >> "$target" - case "$file" in - /*) ;; - *) file=`pwd`/"$file";; - esac - echo "file="$file >> "$target" - done -} - -rule BuildKernel -{ - # Usage BuildKernel : ; - local kernel = $(1) ; - local configFile = $(2) ; - local bootmaker = bootmaker ; - - LocalDepends all : $(kernel) ; - Depends $(kernel) : $(configFile) $(bootmaker) ; - LocalClean clean : $(kernel) ; - MakeLocate $(kernel) : $(LOCATE_TARGET) ; - - BOOT_MAKER on $(kernel) = $(bootmaker) ; -} - -actions BuildKernel bind BOOT_MAKER -{ - "$(BOOT_MAKER)" --strip-debug --strip-binary strip "$(2)" -o "$(1)" ; - echo "" - echo "Kernel linked!" - echo "" -} - -rule KernelFloppyImage -{ - # Usage KernelFloppyImage : : ; - local floppy = $(1) ; - local kernel = $(2) ; - local bootblock = $(3) ; - local makeflop = makeflop ; - - LocalDepends all : $(floppy) ; - Depends $(floppy) : $(kernel) $(bootblock) $(makeflop) ; - LocalClean clean : $(floppy) ; - MakeLocate $(floppy) : $(OBOS_OBJECT_TARGET) ; - - BOOT_BLOCK on $(floppy) = $(bootblock) ; - MAKE_FLOP on $(floppy) = $(makeflop) ; -} - -# This may be a bit verbose, but I think it's useful to show what's -# going on, at least in this early stage of development. -actions KernelFloppyImage bind BOOT_BLOCK bind MAKE_FLOP -{ - "$(MAKE_FLOP)" "-p $(shell expr 18 \* 2 \* 512)" "$(BOOT_BLOCK)" "$(2)" "$(1)" ; - - echo "" - echo "*************************************************" - echo "* Kernel build completed! *" - echo "* Boot image for a 1.44M floppy created *" - echo "*************************************************" - echo "" - echo "Floppy image is $(1)" - echo "The following command will write it to a floppy on BeOS" - echo " dd if=$(1) of=/dev/disk/floppy/raw bs=18k" - echo "Alternatively you can run" - echo " ./configure --floppy /dev/disk/floppy/raw" - echo "once and build + write the image subsequently via" - echo " jam installfloppy" - echo "" -} - -rule InstallFloppy -{ - # InstallFloppy : - # "dd"s to $(FLOPPY_PATH). - - local target = $(1) ; - local floppy = $(2) ; - - NotFile $(target) ; - Always $(target) ; - Depends $(target) : $(floppy) ; -} - -actions InstallFloppy -{ - if [ -z $(FLOPPY_PATH) ] ; then - echo "Can't install floppy: FLOPPY_PATH not set." - echo "run: ./configure --floppy " - echo - exit 0 - fi - dd if=$(2) of=$(FLOPPY_PATH) bs=18k -} - -#------------------------------------------------------------------------------- -# FreeType 2 specific rules and variables -#------------------------------------------------------------------------------- - -FT2_INCLUDE = [ FDirName $(OBOS_TOP) headers libs freetype2 ] ; -FT2_SRC = [ FDirName $(OBOS_TOP) src libs freetype2 ] ; - -FT2_LIB = freetype ; - -FT2_COMPONENTS ?= gzip # support for gzip-compressed files. - autohint # auto-hinter - autofit - base # base component (public APIs) - bdf # BDF font driver - cache # cache sub-system - cff # CFF/CEF font driver - cid # Postscript CID-keyed font driver - lzw # LZW routines - otvalid - pcf # PCF font driver - pfr # PFR/TrueDoc font driver - psaux # Common Postscript routines module - pshinter # Postscript hinter module - psnames # Postscript names handling - raster # Monochrome rasterizer - smooth # Anti-aliased rasterizer - sfnt # SFNT-based format support routines - truetype # TrueType font driver - type1 # Postscript Type 1 font driver - type42 # Postscript Type 42 (embedded TrueType) driver - winfonts # Windows FON/FNT font driver - ; - -rule UseFreeTypeHeaders -{ - SubDirHdrs $(FT2_INCLUDE) ; -} - -rule UseFreeTypeObjectHeaders -{ - # UseFreeTypeObjectHeaders [ : ] ; - SourceHdrs $(1) : $(FT2_INCLUDE) : $(2) ; -} - -rule FT2_SubDir -{ - # FT2_SubDir - # : Components of a directory in the original hierarchy. - local dir = $(1) ; - local topDir ; - switch $(dir[1]) - { - case "include" : topDir = $(FT2_INCLUDE) ; - case src : topDir = $(FT2_SRC) ; - case * : ECHO "Unknown FreeType2 directory: " $(dir) ; - } - return [ FDirName $(topDir) $(dir[2-]) ] ; -} - -rule FT2_Library -{ - # FT2_Library : - # Builds objects from sources and adds the objects to the list of objects - # to be linked into the library. - # The name of the library. - # The sources. - - local library = lib$(1).so ; - local sources = $(2) ; - SetupIncludes ; - SetupObjectsDir ; - MakeLocateObjects $(sources) ; - Objects $(sources) ; - LIBRARY_OBJECTS on $(library) += [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; -} - -rule FT2_LinkLibrary -{ - # FT2_LinkLibrary - # Links the library from the objects build with FT2_LIBRARY before. - - local library = lib$(1).so ; - local objects = [ on $(library) return $(LIBRARY_OBJECTS) ] ; - ObjectReferences $(objects) ; - objects = [ FGristFiles $(objects) ] ; - SharedLibraryFromObjects $(1) : $(objects) ; -} - -#------------------------------------------------------------------------------- -# Packages for OBOS alpha/beta testers -#------------------------------------------------------------------------------- - -rule Copy -{ - Depends $(<) : $(>) ; - SEARCH on $(>) = $(SEARCH_SOURCE) ; -} - -actions Copy -{ - cp -dp "$(>)" "$(<)" ; - if [ -f "$(>)" ] ; then copyattr "$(>)" "$(<)" ; fi ; -} - -rule Packages -{ - local packagenames = $(1) ; - local packagefiles = $(2) ; - local path = $(3) ; - for name in $(packagenames) { - Package $(name) : $(packagefiles) : $(path) ; - } -} - -rule Package -{ - local packagename = $(1) ; - local packagefiles = $(2) ; - local path = $(3) ; - - local packagezip = $(packagename:S=.zip:G=_packages) ; - local packagedir = [ FDirName $(OBOS_PACKAGE_DIR) $(packagename) ] ; - - local installscript = install.sh ; - local packageinstallscript = $(installscript:G=_packages!$(packagename)) ; - local installzip = install.zip ; - local packageinstallzip = $(installzip:G=_packages!$(packagename)) ; - - local packageobjectdir - = [ FDirName $(OBOS_PACKAGE_OBJECT_DIR) $(packagename) ] ; - local packagefiledir = [ FDirName $(packageobjectdir) $(path) ] ; - local packagefileinstallzip - = $(installzip:G=_package_objects!$(packagename)) ; - - # add the files to the install.zip - local packagefilegrist = [ FGrist _package_files $(packagename) $(path) ] ; - for file in $(packagefiles) { - if $(3[0]) = "boot" { - local packagefile = $(file:G=$(packagefilegrist)) ; - MakeLocate $(packagefile) : $(packagefiledir) ; - Copy $(packagefile) : $(file) ; - Clean cleanPackages : $(packagefile) ; - PackageInstallZip $(packagefileinstallzip) : $(packagefile) ; - } else { - local packagefile = $(file:G=_packages!$(packagename)) ; - MakeLocate $(packagefile) : $(packagedir) ; - Copy $(packagefile) : [ FGristFiles $(file) ] ; - Clean cleanPackages : $(packagefile) ; - Depends $(packagezip) : $(packagefile) ; - } - } - - # general setup for this packages -- only on first invocation - if ! $(_setup_$(packagename)) { - _setup_$(packagename) = true ; - - NotFile $(packagename) ; - LocalDepends packages : $(packagename) ; - - MakeLocate $(packagezip) : $(OBOS_PACKAGE_DIR) ; - MakeLocate $(packageinstallscript) : $(packagedir) ; - MakeLocate $(packageinstallzip) : $(packagedir) ; - MakeLocate $(packagefileinstallzip) : $(packageobjectdir) ; - - PackageInstallScript $(packageinstallscript) : $(packagedir) ; - LinkInstallZip $(packageinstallzip) : $(packagefileinstallzip) ; - Depends $(packagename) : $(packagezip) ; - PackageZip $(packagezip) : $(packagedir) - : $(packageinstallscript) $(packageinstallzip) ; - } - -} - -rule PackageZip -{ - local dir = $(2:G=dir) ; - Depends $(1) : $(dir) $(3) ; - Clean cleanPackages : $(1) ; - PackageZip1 $(1) : $(dir) ; -} - -actions together PackageZip1 { - cd "$(OBOS_PACKAGE_DIR)" ; - zip -rq "$(1:BS)" "$(2:BS)" ; -} - -rule PackageInstallScript -{ - MakeLocate $(1) : $(2) ; - Clean cleanPackages : $(1) ; - PackageInstallScript1 $(1) : $(2:G=dir) ; -} - -actions together PackageInstallScript1 -{ -echo '#!/bin/sh -base=`dirname "$0"` -cd "$base" -if [ -n "$TTY" ] -then - unzip -d / install.zip -else - response=`alert "Would you like to automatically overwrite existing files, or receive a prompt?" "Overwrite" "Prompt"` - if [ $response == "Overwrite" ] - then - unzip -od / install.zip - alert "Finished installing" "Thanks" - else - if [ -e /boot/beos/apps/Terminal ] - then - terminal=/boot/beos/apps/Terminal - else - terminal=`query Terminal | head -1` - fi - $terminal -t "installer" /bin/sh "$0" - fi -fi' > "$(1)" ; - chmod 755 "$(1)" ; -} - -rule PackageInstallZip -{ - Depends $(1) : $(2) ; - Clean cleanPackages : $(1) ; -} - -actions together PackageInstallZip -{ - cd "$(1:P)" ; - zip -rqy "$(1:BS)" boot ; -} - -rule LinkInstallZip -{ - Depends $(1) : $(2) ; - Clean cleanPackages : $(1) ; -} - -actions together LinkInstallZip -{ - ln -sf "`pwd`/$(2)" "$(1)" ; -} - -rule SubIncludeGPL -{ - # SubInclude rule that can be used to conditionally include GPL licensed add-ons - if $(INCLUDE_GPL_ADDONS) = 1 { - SubInclude $(1) ; - } -} - -rule Man2Doc -{ - local source = [ FGristFiles $(2) ] ; - local binary = $(1) ; - - SEARCH on $(source) = $(SEARCH_SOURCE) ; - - MakeLocate $(binary) : [ FDirName $(OBOS_OBJECT_TARGET) documentation Shell_Tools ] ; - - Depends $(binary) : $(source) rman ; - - LocalDepends doc_files : $(binary) ; - Man2Doc1 $(binary) : rman $(source) ; - LocalClean clean : $(binary) ; -} - -actions Man2Doc1 -{ - $(2[1]) -f XML "$(2[2])" > "$(1)" ; -} - -rule Man2Docs -{ - # Man2Docs ; - local source ; - for source in [ FGristFiles $(1) ] - { - local target = $(source:S=.xml) ; - - Man2Doc $(target) : $(source) ; - } -} +PrepareConfigVariables ; +# specify the Haiku image contents +include [ FDirName $(HAIKU_BUILD_RULES_DIR) HaikuImage ] ; diff --git a/build/jam/BeOSRules b/build/jam/BeOSRules new file mode 100644 index 0000000000..0a8bf6420b --- /dev/null +++ b/build/jam/BeOSRules @@ -0,0 +1,157 @@ +# BeOS specific rules + + +rule AddStringDataResource +{ + # AddStringDataResource : : + # Adds a single resource to the resources of an executable/library. + # : The executable/library. + # : A resource ID string as understood by xres (type:id[:name]). + # : The string will be written to the resource. + # Defaults to "". + # + local target = $(1) ; + local resourceID = $(2) ; + local dataString = $(3:E="") ; + + # the resource file + local resources + = [ FGristFiles $(target:B)-added-string-data-resources.rsrc ] ; + + # add the resource file to the target, if not yet done + if ! [ on $(resources) return $(RESOURCES_ADDED) ] { + RESOURCES_ADDED on $(resources) = true ; + MakeLocateArch $(resources) ; + Depends $(resources) : xres ; + AddStringDataResource1 $(resources) : xres ; + AddResources $(target) : $(resources) ; + } + + RESOURCE_STRINGS on $(resources) + += "-a "$(resourceID)" -s \""$(dataString)"\"" ; +} + +actions together AddStringDataResource1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + $(2[1]) -o "$(1)" $(RESOURCE_STRINGS) +} + + +rule AddFileDataResource +{ + # AddFileDataResource : : [ ] + # : [ ] + # Adds a single resource to the resources of an executable/library. + # : The executable/library. + # : A resource ID string as understood by xres (type:id[:name]). + # : The data to be written into the resource will be read from + # that file. + # + local target = $(1) ; + local resourceID = $(2) ; + local dataFile = $(3) ; + + # the resource file + local resources + = file-data-$(resourceID)-$(dataFile).rsrc ; + + # add it to the resources of the given target + AddResources $(target) : $(resources) ; + + # if the rule for creating the resource file has not been invoked yet, do it + if ! [ on $(resources) return $(RESOURCES_DEFINED) ] { + RESOURCES_DEFINED on $(resources) = true ; + RESOURCE_ID on $(resources) = $(resourceID) ; + MakeLocateArch $(resources) ; + + Depends $(resources) : xres $(dataFile) ; + AddFileDataResource1 $(resources) : xres $(dataFile) ; + } +} + +actions AddFileDataResource1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + $(2[1]) -o "$(1)" -a "$(RESOURCE_ID)" "$(2[2])" ; +} + +rule XRes +{ + # XRes : + if $(2) + { + Depends $(1) : xres $(2) ; + XRes1 $(1) : xres $(2) ; + } +} + +actions XRes1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + $(2[1]) -o "$(1)" "$(2[2-])" ; +} + +rule SetVersion +{ + # SetVersion + + Depends $(1) : setversion ; + SetVersion1 $(1) : setversion ; +} + +actions SetVersion1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + $(2[1]) "$(1)" -system $(HAIKU_BUILD_VERSION) -short "$(HAIKU_BUILD_DESCRIPTION)" ; +} + +rule SetType +{ + # SetType + + Depends $(1) : settype ; + SetType1 $(1) : settype ; +} + +actions SetType1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + $(2[1]) -t $(TARGET_EXECUTABLE_MIME_TYPE) "$(1)" ; +} + +rule MimeSet +{ + # MimeSet +} + +rule ResComp +{ + # ResComp : ; + # + # and must be gristed. + + SEARCH on $(2) += $(SEARCH_SOURCE) ; + MakeLocateArch $(1) ; + Depends $(1) : $(2) rc ; + LocalClean clean : $(1) ; + ResComp1 $(1) : rc $(2) ; +} + +actions ResComp1 +{ + $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) + $(2[1]) --auto-names -o $(1) $(2[2-]) +} + + +if $(OS) = BEOS +{ + +actions MimeSet +{ + mimeset -f "$(1)" ; +} + +} # if BEOS + diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup new file mode 100644 index 0000000000..35c20846a6 --- /dev/null +++ b/build/jam/BuildSetup @@ -0,0 +1,577 @@ + +# Variable naming conventions: +# TARGET_*: A build system variable specifying a property for building for +# the target platform (usually Haiku). E.g. TARGET_CC specifies the +# compiler when building a target for the target platform. +# HOST_*: A build system variable specifying a property of the platform +# hosting the build. E.g. HOST_CC specifies the compiler when +# building a target for the host platform (a build tool for +# instance). +# HAIKU_*: A build system variable specifying a build system property. Usually +# directory paths and the like. + + +# Include BuildConfig/Timezones/libgccObjects +{ + local buildConfig = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : BuildConfig ] ; + local timezones = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : Timezones ] ; + local libgccObjects = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : libgccObjects ] ; + + if ! $(buildConfig) { + ECHO "No `BuildConfig' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ; + EXIT "Run ./configure in the source tree's root directory first!" ; + } + if ! ( $(timezones) && $(libgccObjects) ) { + ECHO "No `Timezones' or `libgccObjects' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ; + EXIT "Please run ./configure in the source tree's root directory again!" ; + } + + LOCATE on BuildConfig = $(HAIKU_BUILD_OUTPUT_DIR) ; + LOCATE on Timezones = $(HAIKU_BUILD_OUTPUT_DIR) ; + LOCATE on libgccObjects = $(HAIKU_BUILD_OUTPUT_DIR) ; + + include BuildConfig ; + include Timezones ; + include libgccObjects ; +} + + +# supported debug levels +HAIKU_DEBUG_LEVELS = 0 1 2 3 4 5 ; + +# BeOS, BONE, Dan0 compatible platforms +HAIKU_BEOS_COMPATIBLE_PLATFORMS = haiku r5 bone dano ; +HAIKU_BONE_COMPATIBLE_PLATFORMS = haiku bone dano ; +HAIKU_DANO_COMPATIBLE_PLATFORMS = haiku dano ; + + +#pragma mark - + +# haiku target platform settings + +# initial state for flags etc. +HAIKU_C++ ?= $(HAIKU_CC) ; +HAIKU_LINK = $(HAIKU_CC) ; +HAIKU_LINKFLAGS = ; + +HAIKU_HDRS = [ FStandardHeaders ] ; +HAIKU_CCFLAGS = -nostdinc ; +HAIKU_C++FLAGS = -nostdinc ; +HAIKU_DEFINES = __HAIKU__ ; + +# analyze the gcc machine spec to determine HAIKU_CPU +switch $(HAIKU_GCC_MACHINE) { + case i386-* : HAIKU_CPU = x86 ; + case i486-* : HAIKU_CPU = x86 ; + case i586-* : HAIKU_CPU = x86 ; + case i686-* : HAIKU_CPU = x86 ; + # TODO: PPC? + case * : Exit "Unsupported gcc target machine:" $(HAIKU_GCC_MACHINE) ; +} + +switch $(HAIKU_CPU) { + case ppc : + { + HAIKU_DEFINES += __POWERPC__ ; + HAIKU_BOOT_PLATFORM = openfirmware ; + } + case x86 : + { + HAIKU_DEFINES += __INTEL__ ; + HAIKU_BOOT_PLATFORM = bios_ia32 ; + } + case * : + Exit "Currently unsupported target CPU:" $(HAIKU_CPU) ; +} +HAIKU_ARCH ?= $(HAIKU_CPU) ; +HAIKU_ARCH_MACRO_DEFINE = ARCH_$(HAIKU_ARCH) ; +HAIKU_DEFINES += $(HAIKU_ARCH_MACRO_DEFINE) ; + +# directories +HAIKU_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) haiku ] ; +HAIKU_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) common ] ; +HAIKU_ARCH_OBJECT_DIR = [ FDirName $(HAIKU_OBJECT_BASE_DIR) $(HAIKU_ARCH) ] ; +HAIKU_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) common ] ; +HAIKU_DEBUG_0_OBJECT_DIR = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) release ] ; + +local level ; +for level in $(HAIKU_DEBUG_LEVELS[2-]) { + HAIKU_DEBUG_$(level)_OBJECT_DIR + = [ FDirName $(HAIKU_ARCH_OBJECT_DIR) debug_$(level) ] ; +} + +# analyze GCC version +if ! $(HAIKU_GCC_RAW_VERSION) { + ECHO "Variable HAIKU_GCC_RAW_VERSION not set. Please run ./configure or" ; + EXIT "specify it manually." ; +} +HAIKU_GCC_VERSION = ; +{ + # split the raw version string at `.' and `-' characters + local version = $(HAIKU_GCC_RAW_VERSION) ; + while $(version) { + local split = [ Match "([^.-]*)[.-](.*)" : $(version) ] ; + if $(split) { + HAIKU_GCC_VERSION += $(split[1]) ; + version = $(split[2]) ; + } else { + HAIKU_GCC_VERSION += $(version) ; + version = ; + } + } +} + +# assembler flags +HAIKU_ASFLAGS = ; + +# C/C++ flags +HAIKU_CCFLAGS += -Wno-multichar ; +HAIKU_C++FLAGS += -Wno-multichar ; + +HAIKU_KERNEL_CCFLAGS += -finline -fno-builtin + -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; +HAIKU_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions + -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; + +if $(HAIKU_GCC_VERSION[1]) >= 3 { + HAIKU_KERNEL_C++FLAGS += -fno-use-cxa-atexit ; +} + +# If the environment variable DEBUG_PRINTF is defined we define an equally +# named macro to the variable value. Some components use the macro to allow +# another function than printf() to print the debug output. The variable should +# be set to the name of the alternative function. +# +if $(DEBUG_PRINTF) { + HAIKU_CCFLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; + HAIKU_C++FLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; +} + +# warning flags +HAIKU_WARNING_CCFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wcast-align + -Wsign-compare ; +HAIKU_WARNING_C++FLAGS = -Wall -Wmissing-prototypes -Wno-ctor-dtor-privacy + -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ; + +HAIKU_KERNEL_WARNING_CCFLAGS = -Wall -Wmissing-prototypes ; +HAIKU_KERNEL_WARNING_C++FLAGS = -Wall -Wmissing-prototypes ; + +# debug flags +HAIKU_DEBUG_FLAGS ?= -ggdb ; + +# debug 0: suppress asserts +HAIKU_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; +HAIKU_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; + +HAIKU_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; +HAIKU_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; + +local level ; +for level in $(HAIKU_DEBUG_LEVELS[2-]) { + local flags = $(HAIKU_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; + HAIKU_DEBUG_$(level)_CCFLAGS = $(flags) ; + HAIKU_DEBUG_$(level)_C++FLAGS = $(flags) ; + HAIKU_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ; + HAIKU_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ; +} + +# private kernel headers do be used when compiling kernel code +HAIKU_PRIVATE_KERNEL_HEADERS = + [ PrivateHeaders $(DOT) kernel libroot + kernel/boot/platform/$(HAIKU_BOOT_PLATFORM) ] + [ ArchHeaders $(HAIKU_ARCH) ] +; + +# Add some grist to the libgcc objects +HAIKU_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS:G=libgcc) ; + +# the C++ library +HAIKU_LIBSTDC++ = libstdc++.r4.so ; + +# library and executable glue code +local commonGlueCode = + init_term_dyn.o + crti.o + crtn.o +; +HAIKU_LIBRARY_BEGIN_GLUE_CODE = + crti.o + crtbegin.o + init_term_dyn.o +; +HAIKU_LIBRARY_END_GLUE_CODE = + crtend.o + crtn.o +; +HAIKU_EXECUTABLE_BEGIN_GLUE_CODE = + crti.o + crtbegin.o + start_dyn.o + init_term_dyn.o +; +HAIKU_EXECUTABLE_END_GLUE_CODE = $(HAIKU_LIBRARY_END_GLUE_CODE) ; + +SEARCH on crtbegin.o crtend.o = $(HAIKU_GCC_LIB_DIR) ; + +HAIKU_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; + +# TODO: The version stuff should probably go into a separate file and be made +# available as macro, too. +# Set our version number if not already set and mark it as a developer build +if ! $(HAIKU_BUILD_VERSION) { + HAIKU_BUILD_VERSION ?= "1 0 0 a 1" ; + HAIKU_BUILD_DESCRIPTION ?= "Developer Build" ; +} + +# If HAIKU_BUILD_VERSION is set, but HAIKU_BUILD_DESCRIPTION isn't, mark it as +# an unknown build. +HAIKU_BUILD_DESCRIPTION ?= "Unknown Build" ; + +# init library name map +{ + local i ; + for i in be game mail media midi midi2 net netapi opengl screensaver root z + textencoding tracker translation { + HAIKU_LIBRARY_NAME_MAP_$(i) = lib$(i).so ; + } +} + + +#pragma mark - + +# host platform settings + +# save jam's variables for the build platform +HOST_AR ?= $(AR) ; +HOST_CC ?= $(CC) ; +HOST_C++ ?= $(C++) ; +HOST_LINK ?= $(LINK) ; +HOST_LD ?= ld ; # TODO: Fix this! +HOST_OBJCOPY ?= objcopy ; # +HOST_RANLIB ?= $(RANLIB) ; +HOST_CPPFLAGS ?= $(CPPFLAGS) ; +HOST_CCFLAGS ?= $(CCFLAGS) ; +HOST_C++FLAGS ?= $(C++FLAGS) ; +HOST_LDFLAGS ?= $(LDFLAGS) ; +HOST_LINKFLAGS ?= $(LINKFLAGS) ; +HOST_DEFINES ?= $(DEFINES) ; +HOST_HDRS ?= $(HDRS) ; + +# split up HOST_AR into the command name and flags +HOST_AR = [ Match "([^ ]*) *(.*)" : $(HOST_AR[1]) ] + $(HOST_AR[2-]) ; +HOST_ARFLAGS = $(HOST_AR[2-]) ; +HOST_AR = $(HOST_AR[1]) ; +HOST_UNARFLAGS ?= x ; + +# check the host platform compatibility +SetPlatformCompatibilityFlagVariables HOST_PLATFORM : HOST : host : linux ; + +if $(HOST_PLATFORM) = linux { + # don't use lex: otherwise rc will not work correctly + if $(LEX) = lex { + LEX = flex ; + } +} + +HOST_CPU ?= $(OSPLAT:L) ; + +HOST_ARCH ?= $(HOST_CPU) ; +HOST_ARCH_MACRO_DEFINE = ARCH_$(HOST_CPU) ; + +# directories +HOST_OBJECT_BASE_DIR = [ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) ] ; +HOST_COMMON_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) common ] ; +HOST_ARCH_OBJECT_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) $(HOST_ARCH) ] ; +HOST_COMMON_DEBUG_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) common ] ; +HOST_DEBUG_0_OBJECT_DIR = [ FDirName $(HOST_ARCH_OBJECT_DIR) release ] ; + +local level ; +for level in $(HAIKU_DEBUG_LEVELS[2-]) { + HOST_DEBUG_$(level)_OBJECT_DIR + = [ FDirName $(HOST_ARCH_OBJECT_DIR) debug_$(level) ] ; +} + +# assembler flags +HOST_ASFLAGS = ; + +# C/C++ flags +HOST_CCFLAGS += -Wno-multichar ; +HOST_C++FLAGS += -Wno-multichar ; + +HOST_KERNEL_CCFLAGS += -finline -fno-builtin + -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; +HOST_KERNEL_C++FLAGS += -finline -fno-builtin -fno-exceptions + -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; + +# warning flags +HOST_WARNING_CCFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wcast-align + -Wsign-compare ; +HOST_WARNING_C++FLAGS = -Wall -Wmissing-prototypes -Wno-ctor-dtor-privacy + -Woverloaded-virtual -Wpointer-arith -Wcast-align -Wsign-compare ; + +HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wmissing-prototypes ; +HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wmissing-prototypes ; + +# debug flags +switch $(HOST_PLATFORM) { + case haiku : HOST_DEBUG_FLAGS ?= -ggdb ; + case linux : HOST_DEBUG_FLAGS ?= -ggdb ; + case * : HOST_DEBUG_FLAGS ?= -g ; +} + +# debug 0: suppress asserts +HOST_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; +HOST_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; + +HOST_KERNEL_DEBUG_0_CCFLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; +HOST_KERNEL_DEBUG_0_C++FLAGS = [ FDefines NDEBUG=$(NDEBUG) ] ; + +local level ; +for level in $(HAIKU_DEBUG_LEVELS[2-]) { + local flags = $(HOST_DEBUG_FLAGS) [ FDefines DEBUG=$(level) ] ; + HOST_DEBUG_$(level)_CCFLAGS = $(flags) ; + HOST_DEBUG_$(level)_C++FLAGS = $(flags) ; + HOST_KERNEL_DEBUG_$(level)_CCFLAGS = $(flags) ; + HOST_KERNEL_DEBUG_$(level)_C++FLAGS = $(flags) ; +} + +# private kernel headers do be used when compiling kernel code +HOST_PRIVATE_KERNEL_HEADERS = ; + +# under BeOS use copyattr instead of cp +if $(HOST_PLATFORM_BEOS_COMPATIBLE) +{ + CP = copyattr --data ; +} + +HOST_DEFINES += $(HOST_ARCH_MACRO_DEFINE) ; +HOST_DEFINES += _NO_INLINE_ASM ; + +if $(HOST_PLATFORM_BEOS_COMPATIBLE) { + # TODO: That's obviously not correct, but in the way the COMPILE_FOR_R5 + # macro is used, it actually seems to mean r5/bone/dano. + HOST_DEFINES += COMPILE_FOR_R5 ; +} + +# for builds of tools in the current environment +HOST_BUILD_COMPATIBILITY_LIB_DIR = [ FDirName $(HOST_OBJECT_BASE_DIR) lib ] ; + +if $(HOST_PLATFORM_BEOS_COMPATIBLE) { + HOST_LIBSTDC++ = stdc++.r4 ; + HOST_LIBROOT = root ; + HOST_LIBBE = be ; + HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR = ; +} else { + HOST_LIBSTDC++ = stdc++ ; + HOST_LIBROOT = libroot_build.so ; + HOST_LIBBE = libbe_build.so ; + HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR + = "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(HOST_BUILD_COMPATIBILITY_LIB_DIR)" ; + + # The BeOS compilers define __INTEL__ respectively __POWERPC__. On the + # build platform we need to make sure, this is also defined. + if $(HOST_CPU) = x86 { + HOST_DEFINES += __INTEL__ ; + } else if $(HOST_CPU) = ppc { + HOST_DEFINES += __POWERPC__ ; + } + + # Supposing this is a glibc platform, let's try to get large file support + HOST_DEFINES += + _LARGEFILE_SOURCE _LARGEFILE64_SOURCE _FILE_OFFSET_BITS=64 + ; +} + +# define the executable MIME type +HOST_EXECUTABLE_MIME_TYPE = "application/x-vnd.Be-elfexecutable" ; + +if $(METROWERKS) { + # at least parts of Haiku still can be compiled with + # the Metrowerks compiler on BeOS/PPC + HOST_EXECUTABLE_MIME_TYPE = "application/x-be-executable" ; +} + +# Be API compatibility +HOST_BE_API_HEADERS = ; +HOST_BE_API_CCFLAGS = ; +HOST_BE_API_C++FLAGS = ; + +if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { + HOST_BE_API_HEADERS = + [ FDirName $(HAIKU_TOP) headers build ] + [ FDirName $(HAIKU_TOP) headers build os ] + [ FDirName $(HAIKU_TOP) headers build os app ] + [ FDirName $(HAIKU_TOP) headers build os drivers ] + [ FDirName $(HAIKU_TOP) headers build os kernel ] + [ FDirName $(HAIKU_TOP) headers build os interface ] + [ FDirName $(HAIKU_TOP) headers build os storage ] + [ FDirName $(HAIKU_TOP) headers build os support ] + ; + HOST_BE_API_CCFLAGS = -include HaikuBuildCompatibility.h ; + HOST_BE_API_C++FLAGS = $(HOST_BE_API_CCFLAGS) ; +} + + +#pragma mark - + +# target platform settings + +# check the target platform compatibility +SetPlatformCompatibilityFlagVariables TARGET_PLATFORM : TARGET : target ; + +# check the compatibility between host and target platform +if $(TARGET_PLATFORM) != haiku { + if ! $(HOST_PLATFORM_($(TARGET_PLATFORM))_COMPATIBLE) { + Exit ERROR: The host platform is not compatible with target platform + $(TARGET_PLATFORM). ; + } +} + +# TODO: Fix the naming! +if $(TARGET_PLATFORM_BONE_COMPATIBLE) { + NETWORK_LIBS = libsocket.so libbind.so ; + NETAPI_LIB = libbnetapi.so ; + SELECT_UNAME_ETC_LIB = libroot.so ; +} else { + NETWORK_LIBS = libnet.so ; + NETAPI_LIB = libnetapi.so ; + SELECT_UNAME_ETC_LIB = libnet.so ; +} + +# TODO: For compatibility only. Remove when no longer used. +R5_COMPATIBLE = $(TARGET_PLATFORM_BEOS_COMPATIBLE) ; +BONE_COMPATIBLE = $(TARGET_PLATFORM_BONE_COMPATIBLE) ; +DANO_COMPATIBLE = $(TARGET_PLATFORM_DANO_COMPATIBLE) ; +HAIKU_COMPATIBLE = $(TARGET_PLATFORM_HAIKU_COMPATIBLE) ; + +# Set TARGET_* variables either from HAIKU_* or HOST_* depending on the +# specified TARGET_PLATFORM. + +local buildVars = + ARCH CPU + + AR CC C++ LD OBJCOPY RANLIB + + HDRS CPPFLAGS CCFLAGS C++FLAGS LDFLAGS LINK LINKFLAGS DEFINES + ARFLAGS UNARFLAGS + + KERNEL_CCFLAGS KERNEL_C++FLAGS + WARNING_CCFLAGS WARNING_C++FLAGS + + KERNEL_WARNING_CCFLAGS KERNEL_WARNING_C++FLAGS + + DEBUG_FLAGS + + DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS + + KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS + KERNEL_DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS + + PRIVATE_KERNEL_HEADERS + + LIBSTDC++ + + ARCH_MACRO_DEFINE EXECUTABLE_MIME_TYPE + + OBJECT_BASE_DIR COMMON_ARCH_OBJECT_DIR COMMON_DEBUG_OBJECT_DIR + DEBUG_$(HAIKU_DEBUG_LEVELS)_OBJECT_DIR +; + +if $(TARGET_PLATFORM) = haiku { + local var ; + for var in $(buildVars) { + TARGET_$(var) = $(HAIKU_$(var)) ; + } + + TARGET_GCC_LIB_DIR = $(HAIKU_GCC_LIB_DIR) ; + TARGET_GCC_HEADERS_DIR = $(HAIKU_GCC_HEADERS_DIR) ; + TARGET_GCC_LIBGCC = $(HAIKU_GCC_LIBGCC) ; + TARGET_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS) ; + + TARGET_BOOT_PLATFORM = $(HAIKU_BOOT_PLATFORM) ; + +} else { + local var ; + for var in $(buildVars) { + TARGET_$(var) = $(HOST_$(var)) ; + } + + TARGET_GCC_LIB_DIR = ; + TARGET_GCC_HEADERS_DIR = ; + TARGET_GCC_LIBGCC = ; + TARGET_GCC_LIBGCC_OBJECTS = ; + + TARGET_BOOT_PLATFORM = ; +} + + +#pragma mark - + +# common stuff + +# start with a clean slate +CCFLAGS = ; +C++FLAGS = ; +DEFINES = ; + +# Set CC, C++, LINK to invalid values, so that we realize early, that we use +# the wrong compiler. +CC = bad-cc ; +C++ = bad-c++ ; +LINK = bad-link ; + +# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() +# issues, they deprecated that nice function. This will enable it again: +C++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; + # TODO: Doesn't really belong here. + + +# Defaults for warnings, optimization, and debugging. +# +WARNINGS ?= 1 ; +OPTIM ?= -O2 ; +DEBUG ?= 0 ; + + +# Set the defaults for PLATFORM and SUPPORTED_PLATFORMS. PLATFORM is only +# overridden for targets to be built for the host platform. SUPPORTED_PLATFORMS +# can be overridden by the author of a component. +PLATFORM = $(TARGET_PLATFORM) ; +SUPPORTED_PLATFORMS = haiku ; + + +# Instructs the Library rule to not make its object files temporary. +# This is needed as some objects are used in a static library and for an +# executable. +KEEPOBJS = true ; + + +# output directories +# TODO: Review this. +HAIKU_DOCUMENTATION_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) documentation ] ; +HAIKU_DOCUMENTATION_OBJECT_DIR ?= [ FDirName $(HAIKU_COMMON_PLATFORM_DIR) + documentation ] ; + +# TODO: Rethink test stuff. +HAIKU_TEST_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tests ] ; +HAIKU_APP_TEST_DIR ?= [ FDirName $(HAIKU_TEST_DIR) apps ] ; +HAIKU_APP_TEST_LIB_DIR ?= [ FDirName $(HAIKU_APP_TEST_DIR) lib ] ; +HAIKU_TMP_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) tmp ] ; + +HAIKU_PACKAGE_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) packages ] ; +HAIKU_PACKAGE_OBJECT_DIR ?= [ FDirName $(HAIKU_OBJECT_DIR) packages ] ; + +# automatically setup the objects directory per subdirectory +SUBDIRRULES += SetupObjectsDir ; + +# Add the standard (userland) warning flags variables to the ones restored in +# every subdirectory. Thus we can easily meddle with them in subdirectories +# with imported sources. +AUTO_SET_UP_CONFIG_VARIABLES += + HOST_WARNING_CCFLAGS HOST_WARNING_C++FLAGS + TARGET_WARNING_CCFLAGS TARGET_WARNING_C++FLAGS + + # also add PLATFORM and SUPPORTED_PLATFORMS + PLATFORM SUPPORTED_PLATFORMS +; diff --git a/build/jam/ConfigRules b/build/jam/ConfigRules new file mode 100644 index 0000000000..6e9429852a --- /dev/null +++ b/build/jam/ConfigRules @@ -0,0 +1,168 @@ +# ConfigRules +# +# Contains rules providing the config variable feature. It allows to set the +# values for certain variables for subdirectories in a central place. That is +# one can, for instance, specify in a file like UserBuildConfig for which +# directories to enable debugging, warnings, set special defines, compiler +# flags and the like without needing to edit the Jamfiles for the respective +# dirs. + +rule ConfigObject +{ + # ConfigObject [ : ] ; + # + # Private rule. Returns the dummy object on which the config variables are + # set for a given subdir. + # + # : Parameters as passed to the SubDir rule, i.e. the name of the + # TOP variable and the subdir tokens. + # + local config = $(2:E=__config__) ; + local grist = [ FGrist root $(1) ] ; + return $(config:G=$(grist)) ; +} + +rule SetConfigVar +{ + # SetConfigVar : : [ : ] ; + # + # Sets a config variable for a specified directory to the given value. + # + # : The name of the variable to be set. + # : Parameters as passed to the SubDir rule, i.e. the name of the + # TOP variable and the subdir tokens. + # : The value to which the variable shall be set. + # : Either "global" or "local". The former implies that the variable + # value shall also be used for subdirectories (recursively), if + # for them the variable has not been set. The latter has the same + # effect regarding subdirs as if the variable for the directory + # is not set. Defaults to "global". + # + local var = $(1[1]) ; + local config = [ ConfigObject $(2) ] ; + local scope = $(4:E=global) ; + + $(var) on $(config) = $(3) ; + __set_$(var) on $(config) = $(scope) ; + + if $(scope) = global { + $(var) on [ ConfigObject $(2) : __inherited_config__ ] = $(3) ; + } + + if ! [ on $(config) return $(__configured) ] { + __configured on $(config) = true ; + __dir_tokens on $(config) = $(2) ; + + HAIKU_EXISTING_SUBDIR_CONFIGS += $(config) ; + } +} + +rule AppendToConfigVar +{ + # AppendToConfigVar : : [ : ] ; + # + # Appends a value to a config variable for a specified directory. Shortcut + # for + # SetConfigVar : : [ ConfigVar : ] ; + # + # : The name of the variable to be set. + # : Parameters as passed to the SubDir rule, i.e. the name of the + # TOP variable and the subdir tokens. + # : The value which to append to the variables current value. + # : Either "global" or "local". The former implies that the variable + # value shall also be used for subdirectories (recursively), if + # for them the variable has not been set. The latter has the same + # effect regarding subdirs as if the variable for the directory + # is not set. Defaults to "global". + # + SetConfigVar $(1) : $(2) : [ ConfigVar $(1) : $(2) ] $(3) : $(4) ; +} + +rule ConfigVar +{ + # ConfigVar : [ : ] ; + # + # Returns the value of a configuration variable for a given subdir. + # If the variable is not set for the subdir, the rule is invoked + # recursively for the parent directory with the scope "global". When + # the root is reached without yielding a value, the value of the global + # variable is returned. + # + # : The name of the variable whose value shall be returned. + # : Parameters as passed to the SubDir rule, i.e. the name of the + # TOP variable and the subdir tokens. + # : If not given any scope passed to SetConfigVar for the given + # directory will be accepted, otherwise it must match the scope + # passed to SetConfigVar. + # + local var = $(1[1]) ; + local dir = $(2) ; + local config = [ ConfigObject $(dir) ] ; + local scope = $(3) ; + local varScope = [ on $(config) return $(__set_$(var)) ] ; + if ( ! $(scope) && $(varScope) ) + || ( $(scope) && $(scope) = $(varScope) ) + || ! $(dir) { + on $(config) return $($(var)) ; + } else { + dir = [ FReverse $(dir) ] ; + return [ ConfigVar $(var) : [ FReverse $(dir[2-]) ] : global ] ; + } +} + +rule PrepareSubDirConfigVariables +{ + local dirTokens = $(1) ; + local config = [ ConfigObject $(dirTokens) ] ; + + if ! [ on $(config) return $(__prepared) ] { + # prepare config for parent dir + local parentDir = [ FReverse $(dirTokens) ] ; + parentDir = [ FReverse $(parentDir[2-]) ] ; + PrepareSubDirConfigVariables $(parentDir) ; + + # set values for all config variables for the config and the inherited + # config for this directory + local inheritedConfig = [ ConfigObject $(dirTokens) + : __inherited_config__ ] ; + + on [ ConfigObject $(parentDir) : __inherited_config__ ] { + for var in $(AUTO_SET_UP_CONFIG_VARIABLES) { + $(var) on $(config) ?= $($(var)) ; + $(var) on $(inheritedConfig) ?= $($(var)) ; + } + } + + HAIKU_INHERITED_SUBDIR_CONFIG on $(config) = $(inheritedConfig) ; + + __prepared on $(config) = true ; + } +} + +rule PrepareConfigVariables +{ + # initialize variables on the root config and the root inherited config + # objects to the global values + local rootConfig = [ ConfigObject ] ; # the root config object + local inheritedRootConfig = [ ConfigObject : __inherited_config__ ] ; + + for var in $(AUTO_SET_UP_CONFIG_VARIABLES) { + $(var) on $(rootConfig) = $($(var)) ; + $(var) on $(inheritedRootConfig) = $($(var)) ; + } + __prepared on $(rootConfig) = true ; + + HAIKU_INHERITED_SUBDIR_CONFIG = $(rootConfig) ; + + local config ; + for config in $(HAIKU_EXISTING_SUBDIR_CONFIGS) { + PrepareSubDirConfigVariables [ on $(config) return $(__dir_tokens) ] ; + } +} + +# Some config variables that should be set up automatically for subdirs. +AUTO_SET_UP_CONFIG_VARIABLES += + CCFLAGS C++FLAGS DEBUG DEFINES HDRS LINKFLAGS OPTIM OPTIMIZE + SYSHDRS WARNINGS +; diff --git a/build/jam/DocumentationRules b/build/jam/DocumentationRules new file mode 100644 index 0000000000..d838e3ff54 --- /dev/null +++ b/build/jam/DocumentationRules @@ -0,0 +1,72 @@ +rule Man2Doc +{ + local source = [ FGristFiles $(2) ] ; + local binary = $(1) ; + + SEARCH on $(source) = $(SEARCH_SOURCE) ; + + MakeLocate $(binary) + : [ FDirName $(HAIKU_DOCUMENTATION_OBJECT_DIR) Shell_Tools ] ; + + Depends $(binary) : $(source) rman ; + + LocalDepends doc_files : $(binary) ; + Man2Doc1 $(binary) : rman $(source) ; + LocalClean clean : $(binary) ; +} + +actions Man2Doc1 +{ + $(2[1]) -f XML "$(2[2])" > "$(1)" ; +} + +rule Man2Docs +{ + # Man2Docs ; + local source ; + for source in [ FGristFiles $(1) ] + { + local target = $(source:S=.xml) ; + + Man2Doc $(target) : $(source) ; + } +} + +XSLTPROC ?= xsltproc ; + +rule Doc2HTML +{ + local source = [ FGristFiles $(1) ] ; + local target = $(2) ; + local xslsheet = $(3) ; + local basedir = [ FDirName $(HAIKU_DOCUMENTATION_DIR) $(4) ] ; + local paths = $(5) ; + local options = $(6) ; + + if ! $(target) { + target = $(1:S=.html) ; + } + + SEARCH on $(source) = $(SEARCH_SOURCE) ; + + MakeLocate $(target) : $(basedir) ; + if $(2) { + XSLBASEDIR on $(target) = -stringparam base.dir \"$(basedir)/\" ; + } + XSLSHEET on $(target) = $(xslsheet) ; + XSLOPTIONS on $(target) = $(options) ; + if $(2) = "" { + XSLOUTPUT on $(target) = "-o "\"$(target:D=$(basedir))\" ; + } + + Depends $(target) : $(source) ; + LocalDepends doc_files : $(target) ; + XSLPROCPATHS on $(target) = -path \" $(paths:J=\ ) \" ; + Doc2HTML1 $(target) : $(source) ; + LocalClean clean : $(target) ; +} + +actions Doc2HTML1 +{ + $(XSLTPROC) -xinclude $(XSLPROCPATHS) $(XSLBASEDIR) $(XSLOPTIONS) $(XSLOUTPUT) $(XSLSHEET) $(2) +} diff --git a/build/jam/FileRules b/build/jam/FileRules new file mode 100644 index 0000000000..ce7c32693a --- /dev/null +++ b/build/jam/FileRules @@ -0,0 +1,219 @@ +rule SymLink +{ + # SymLink : : ; + # Links to . + # is the exact link contents. No binding is done. + # If true, will be made a dependency + # of the `all' pseudo target, i.e. it will be made by default, and removed + # on `jam clean'. + + local target = $(1) ; + local source = $(2) ; + local makeDefaultDependencies = $(3) ; + if ! $(makeDefaultDependencies) { + makeDefaultDependencies = true ; + } + LINKCONTENTS on $(target) = $(source) ; + SymLink1 $(target) ; + if $(makeDefaultDependencies) = true { + LocalDepends files : $(target) ; + LocalClean clean : $(target) ; + } +} + +actions SymLink1 +{ + $(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)" +} + +rule RelSymLink +{ + # RelSymLink : : ; + # Creates a relative symbolic link from to . + # and can be usual targets. They may have a grist + # and don't need to have any dirname. Their LOCATE variables are used to + # find their locations. + # If true (which is the default), will be + # made a dependency of the `files' pseudo target, i.e. it will be made by + # default, and removed on `jam clean'. + + local target = $(1) ; + local source = $(2) ; + local makeDefaultDependencies = $(3) ; + local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ; + local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ; + local sourcePath = $(source:G=) ; + sourcePath = $(sourcePath:D=$(sourceDir)) ; + local targetDirComponents = [ FSplitPath $(targetDir) ] ; + local sourceComponents = [ FSplitPath $(sourcePath) ] ; + + SymLink $(target) + : [ FRelPath $(targetDirComponents) : $(sourceComponents) ] + : $(makeDefaultDependencies) ; + NOUPDATE $(target) ; + Depends $(target) : $(source) ; +} + +rule AbsSymLink +{ + # AbsSymLink : : + # : ; + # Creates an absolute symbolic link from to . + # and must be usual targets. If is + # given, then it is set as LOCATE directory on . + # If true (which is the default), will be + # made a dependency of the `files' pseudo target, i.e. it will be made by + # default, and removed on `jam clean'. + + local makeDefaultDependencies = $(4) ; + if ! $(makeDefaultDependencies) { + makeDefaultDependencies = true ; + } + + Depends $(1) : $(2) ; + if $(3) { + MakeLocate $(1) : $(3) ; + } + SEARCH on $(2) += $(SEARCH_SOURCE) ; + if $(makeDefaultDependencies) = true { + LocalDepends files : $(1) ; + LocalClean clean : $(1) ; + } +} + +actions AbsSymLink +{ + target="$(2)" + case "$target" in + /*) ;; + *) target=`pwd`/"$target";; + esac + $(RM) "$(1)" && $(LN) -s "$target" "$(1)" +} + +rule HaikuInstall +{ + # Usage: HaikuInstall <[ install [ and uninstall ] pseudotarget ]> + # : : + # : [ ] : [ ] ; + local install = $(1[1]) ; + install ?= install ; + local uninstall = $(1[2]) ; + uninstall ?= un$(install) ; + local dir = $(2) ; + local sources = $(3) ; + local installgrist = $(4) ; + installgrist ?= $(INSTALLGRIST) ; + local installRule = $(5) ; + installRule ?= Install ; + local targets = $(sources:G=$(installgrist)) ; + + NotFile $(install) ; + NotFile $(uninstall) ; + Depends $(install) : $(targets) ; + Clean $(uninstall) : $(targets) ; + + SEARCH on $(sources) += $(SEARCH_SOURCE) ; + MakeLocate $(targets) : $(dir) ; + + local source ; + for source in $(sources) { + local target = $(source:G=$(installgrist)) ; + + Depends $(target) : $(source) ; + $(installRule) $(target) : $(source) ; + + if [ on $(target) return $(MODE) ] { + Chmod $(target) ; + } + + if $(OWNER) && $(CHOWN) { + Chown $(target) ; + OWNER on $(target) = $(OWNER) ; + } + + if $(GROUP) && $(CHGRP) { + Chgrp $(target) ; + GROUP on $(target) = $(GROUP) ; + } + } +} + +rule InstallAbsSymLinkAdapter +{ + # InstallAbsSymLinkAdapter : + if ! [ on $(2) return $(TARGET) ] { + TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; + } + AbsSymLink $(1) : $(2) : : false ; +} + +rule HaikuInstallAbsSymLink +{ + # Usage: HaikuInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]> + # : : + # : [ ] ; + HaikuInstall $(1) : $(2) : $(3) : $(4) : InstallAbsSymLinkAdapter ; +} + +rule InstallRelSymLinkAdapter +{ + # InstallRelSymLinkAdapter : + if ! [ on $(2) return $(TARGET) ] { + TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; + } + RelSymLink $(1) : $(2) : false ; +} + +rule HaikuInstallRelSymLink +{ + # Usage: HaikuInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]> + # : : + # : [ ] ; + HaikuInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ; +} + + +rule UnarchiveObjects +{ + # UnarchiveObjects : + + MakeLocateArch $(1) ; + Depends $(1) : $(2) ; + SEARCH on $(2) = $(SEARCH_SOURCE) ; +} + +actions UnarchiveObjects +{ + ( cd $(1[1]:D) && $(TARGET_AR) $(TARGET_UNARFLAGS) "$(2)" $(1:BS) ) +} + + +rule ObjectReference +{ + # ObjectReference : + # Makes refer to the same file as . + # The filenames must of course be identical. + # must have already been LOCATEd. + + local ref = $(1) ; + local source = $(2) ; + if $(ref) != $(source) { + Depends $(ref) : $(source) ; + LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ; + } +} + +rule ObjectReferences +{ + # ObjectReferences + # Creates local references to , i.e. identifiers with the + # current grist referring to the same files. must have + # already been LOCATEd. + + local source ; + for source in $(1) { + ObjectReference [ FGristFiles $(source) ] : $(source) ; + } +} + diff --git a/build/jam/FreetypeRules b/build/jam/FreetypeRules new file mode 100644 index 0000000000..1eed2714dc --- /dev/null +++ b/build/jam/FreetypeRules @@ -0,0 +1,85 @@ +#------------------------------------------------------------------------------- +# FreeType 2 specific rules and variables +#------------------------------------------------------------------------------- + +FT2_INCLUDE = [ FDirName $(HAIKU_TOP) headers libs freetype2 ] ; +FT2_SRC = [ FDirName $(HAIKU_TOP) src libs freetype2 ] ; + +FT2_LIB = freetype ; + +FT2_COMPONENTS ?= gzip # support for gzip-compressed files. + autohint # auto-hinter + autofit + base # base component (public APIs) + bdf # BDF font driver + cache # cache sub-system + cff # CFF/CEF font driver + cid # Postscript CID-keyed font driver + lzw # LZW routines + otvalid + pcf # PCF font driver + pfr # PFR/TrueDoc font driver + psaux # Common Postscript routines module + pshinter # Postscript hinter module + psnames # Postscript names handling + raster # Monochrome rasterizer + smooth # Anti-aliased rasterizer + sfnt # SFNT-based format support routines + truetype # TrueType font driver + type1 # Postscript Type 1 font driver + type42 # Postscript Type 42 (embedded TrueType) driver + winfonts # Windows FON/FNT font driver + ; + +rule UseFreeTypeHeaders +{ + SubDirSysHdrs $(FT2_INCLUDE) ; +} + +rule UseFreeTypeObjectHeaders +{ + # UseFreeTypeObjectHeaders [ : ] ; + SourceSysHdrs $(1) : $(FT2_INCLUDE) : $(2) ; +} + +rule FT2_SubDir +{ + # FT2_SubDir + # : Components of a directory in the original hierarchy. + local dir = $(1) ; + local topDir ; + switch $(dir[1]) + { + case "include" : topDir = $(FT2_INCLUDE) ; + case src : topDir = $(FT2_SRC) ; + case * : ECHO "Unknown FreeType2 directory: " $(dir) ; + } + return [ FDirName $(topDir) $(dir[2-]) ] ; +} + +rule FT2_Library +{ + # FT2_Library : + # Builds objects from sources and adds the objects to the list of objects + # to be linked into the library. + # The name of the library. + # The sources. + + local library = lib$(1).so ; + local sources = $(2) ; + + Objects $(sources) ; + LIBRARY_OBJECTS on $(library) += [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; +} + +rule FT2_LinkLibrary +{ + # FT2_LinkLibrary + # Links the library from the objects build with FT2_LIBRARY before. + + local library = lib$(1).so ; + local objects = [ on $(library) return $(LIBRARY_OBJECTS) ] ; + ObjectReferences $(objects) ; + objects = [ FGristFiles $(objects) ] ; + SharedLibraryFromObjects $(library) : $(objects) ; +} diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage new file mode 100644 index 0000000000..a3c3257412 --- /dev/null +++ b/build/jam/HaikuImage @@ -0,0 +1,303 @@ + +# create directories that will remain empty +AddDirectoryToHaikuImage home Desktop ; +AddDirectoryToHaikuImage var log ; +AddDirectoryToHaikuImage var tmp ; + +# TODO: Remove the variables we don't need. +BEOS_BIN = touch sync ln listarea listattr listsem listport + true false ls df mount unmount cp mv ps sh mkdir sleep + grep cat less clockconfig du rm date find locate xargs + isvolume shutdown safemode sysinfo kill diff cmp + renice rmattr addattr listdev pwd chmod chown chgrp dd + tee md5sum catattr query lsindex mkindex roster listimage + quit open translate setvolume waitfor uname iroster keymap + strace rmdir error ifconfig ping traceroute arp pppconfig + ppp_up gdb tail head zip unzip mountvolume top finddir groups + id env basename factor tty dstcheck comm modifiers version + csplit cut beep screen_blanker fortune play eject uptime sed gawk mimeset + dirname +; + +BEOS_APPS = MiniTerminal Terminal Expander People ShowImage Clock Pulse + Playground SoundRecorder BitmapDrawing Magnify DiskProbe AboutHaiku + StyledEdit CDPlayer +; +BEOS_PREFERENCES = Backgrounds DataTranslations FileTypes Fonts Media Menu + Mouse Keyboard Keymap Screen ScrollBar Sounds Time VirtualMemory + Workspaces ScreenSaver +; +BEOS_SYSTEM_LIB = libbe.so libstdc++.r4.so libnet.so libmedia.so libtracker.so + libtranslation.so libbind.so libnetapi.so libsocket.so libdebug.so + libtextencoding.so libz.so libfreetype.so libpng.so libappserver.so + libdevice.so libgame.so libscreensaver.so libroot.so +; +BEOS_SYSTEM_SERVERS = registrar debug_server syslog_daemon media_server + media_addon_server input_server app_server fake_app_server +; + +BEOS_NETWORK_CORE = core ; +BEOS_NETWORK_INTERFACES = ethernet loopback ppp ; +BEOS_NETWORK_PPP = ipcp modem pap pppoe ; +BEOS_NETWORK_PROTOCOLS = icmp ipv4 raw route tcp udp ; + +BEOS_ADD_ONS_ACCELERANTS = radeon.accelerant nv.accelerant mga.accelerant + nm.accelerant vesa.accelerant +; +BEOS_ADD_ONS_TRANSLATORS = STXTTranslator RTF-Translator PNGTranslator + JPEGTranslator GIFTranslator +; +BEOS_ADD_ONS_MEDIA = mixer.media_addon legacy.media_addon + multi_audio.media_addon +; +BEOS_ADD_ONS_MEDIA_PLUGINS = aiff_reader avcodec mp3_decoder musepack + raw_decoder wav_reader mov_reader au_reader avi_reader mp3_reader ogg + speex vorbis + # ac3_decoder theora matroska +; +BEOS_ADD_ONS_INPUT = keyboard mouse canna screen_saver ; +BEOS_ADD_ONS_SCREENSAVERS = Haiku ; +BEOS_ADD_ONS_DRIVERS_AUDIO = ich_ac97 auvia emuxki ; +BEOS_ADD_ONS_DRIVERS_GRAPHICS = radeon.driver nv.driver nm.driver mga.driver + vesa +; +BEOS_ADD_ONS_DRIVERS_MISC = keyboard scsi_dsk scsi_cd dprintf null zero random + ps2_hid tty console config +; +BEOS_ADD_ONS_DRIVERS_NET = ipro1000 rtl8139 rtl8169 sis900 + via-rhine wb840 net_stack_driver + # bcm440x bcm570x (only available with GPLd add-ons) +; +BEOS_ADD_ONS_BUS_MANAGERS = pci isa ide scsi config_manager ; +BEOS_ADD_ONS_KERNEL_MISC = ide_isa generic_ide_pci block_io fast_log + ide_adapter locked_pool scsi_periph intel keyboard vga_text +; +BEOS_ADD_ONS_FILESYSTEMS = bfs ; +BEOS_DATA_FILES = timezone_files keymap_files ; + + +# modules +AddFilesToHaikuImage beos system add-ons kernel bus_managers + : $(BEOS_ADD_ONS_BUS_MANAGERS) ; +AddFilesToHaikuImage beos system add-ons kernel busses ide + : generic_ide_pci ide_isa ; +AddFilesToHaikuImage beos system add-ons kernel console : vga_text ; +AddFilesToHaikuImage beos system add-ons kernel file_systems : bfs ; +AddFilesToHaikuImage beos system add-ons kernel generic + : block_io fast_log ide_adapter locked_pool scsi_periph ; +AddFilesToHaikuImage beos system add-ons kernel partitioning_systems : intel ; + +# drivers +AddDriversToHaikuImage : console dprintf keyboard null random + tty zero ; +AddDriversToHaikuImage audio multi : $(BEOS_ADD_ONS_DRIVERS_AUDIO) ; +AddDriversToHaikuImage disk scsi : scsi_cd scsi_dsk ; +AddDriversToHaikuImage graphics : $(BEOS_ADD_ONS_DRIVERS_GRAPHICS) ; +AddDriversToHaikuImage input : ps2_hid ; +AddDriversToHaikuImage misc : config ; +AddDriversToHaikuImage net : $(BEOS_ADD_ONS_DRIVERS_NET) ; + +# kernel +AddFilesToHaikuImage beos system : kernel_$(TARGET_ARCH) ; + +# libs +AddFilesToHaikuImage beos system lib : $(BEOS_SYSTEM_LIB) rld.so ; + +# servers +AddFilesToHaikuImage beos system servers : $(BEOS_SYSTEM_SERVERS) ; + +# apps +AddFilesToHaikuImage beos : Deskbar Tracker ; +AddFilesToHaikuImage beos bin : $(BEOS_BIN) consoled route ; +AddFilesToHaikuImage beos apps : $(BEOS_APPS) ; +AddFilesToHaikuImage beos preferences : $(BEOS_PREFERENCES) ; + +AddSymlinkToHaikuImage beos bin : more : less ; + + +# scripts and data files +local bootScripts = Bootscript SetupEnvironment Netscript ; +SEARCH on $(bootScripts) = [ FDirName $(HAIKU_TOP) data system boot ] ; +AddFilesToHaikuImage beos system boot : $(bootScripts) ; + +# TODO: Use data/etc/termcap or src/libs/termcap.src? +local etcFiles = fortunes profile termcap ; +etcFiles = $(etcFiles:G=etc) ; +SEARCH on $(etcFiles) = [ FDirName $(HAIKU_TOP) data etc ] ; +AddFilesToHaikuImage beos etc : $(etcFiles) ; + +local fontDir = [ FDirName $(HAIKU_TOP) data etc fonts ] ; +local psFonts = [ Glob $(fontDir)/psfonts : *.afm *.pfb ] ; +local ttFonts = [ Glob $(fontDir)/ttfonts : *.ttf ] ; +AddFilesToHaikuImage beos etc fonts psfonts : $(psFonts) ; +AddFilesToHaikuImage beos etc fonts ttfonts : $(ttFonts) ; + +local kanbeDir = [ FDirName $(HAIKU_TOP) data etc KanBe ] ; +local kanbeDefault = [ Glob $(kanbeDir)/default : *.canna *.gz ] ; +local kanbeDic = [ Glob $(kanbeDir)/dic : *.cbp ] ; +local kanbeDicCanna = [ Glob $(kanbeDir)/dic/canna + : *.cld *.ctd *.cbd *.dir ] ; +AddFilesToHaikuImage beos etc KanBe default : $(kanbeDefault) ; +AddFilesToHaikuImage beos etc KanBe dic : $(kanbeDic) ; +AddFilesToHaikuImage beos etc KanBe dic canna : $(kanbeDicCanna) ; +AddDirectoryToHaikuImage beos etc KanBe dic group ; +AddDirectoryToHaikuImage beos etc KanBe dic user ; + +# TODO: We must get rid of this earlier or later. +# +# if [ -e /boot/beos/etc/fonts/ttfonts/Swiss721.ttf ]; then +# $cp ${sPrefix}/boot/beos/etc/fonts/ttfonts/Courier10Pitch.ttf $targetDir/beos/etc/fonts/ttfonts/ +# $cp ${sPrefix}/boot/beos/etc/fonts/ttfonts/Swiss721_Bold.ttf $targetDir/beos/etc/fonts/ttfonts/ +# $cp ${sPrefix}/boot/beos/etc/fonts/ttfonts/Swiss721.ttf $targetDir/beos/etc/fonts/ttfonts/ +# fi + +local libnetFiles = networks protocols resolv.conf services ; +libnetFiles = $(libnetFiles:G=libnet-files) ; +SEARCH on $(libnetFiles) = [ FDirName $(HAIKU_TOP) src kits network libnet ] ; +AddFilesToHaikuImage beos etc : $(libnetFiles) ; + +local keymapFiles = [ GLOB $(SUBDIR) : *.keymap ] ; +keymapFiles = $(keymapFiles:BG=keymap) ; +AddFilesToHaikuImage beos etc Keymap : $(libnetFiles) ; + +local timezones = [ FTimeZoneBinaries $(HAIKU_TIME_ZONE_SOURCES) : : true ] ; +for timezone in $(timezones) { + local dir = [ on $(timezone) return $(RELATIVE_TIMEZONE_DIR) ] ; + AddFilesToHaikuImage beos etc timezones $(dir) : $(timezone) ; +} + +local driverSettingsFiles = kernel ; +SEARCH on $(driverSettingsFiles) + = [ FDirName $(HAIKU_TOP) data settings kernel drivers ] ; +AddFilesToHaikuImage home config settings kernel drivers + : $(driverSettingsFiles) ; +# TODO: This looks like it belongs to someones UserBuildConfig. +# if [ -e data/settings/kernel/drivers/vesa ]; then +# $cp ${sPrefix}data/settings/kernel/drivers/vesa \ +# $targetDir/home/config/settings/kernel/drivers/ +# fi + +AddSymlinkToHaikuImage home config settings + : /boot/beos/etc/timezones/Europe/Paris : timezone ; + +AddFilesToHaikuImage home config settings kernel drivers + : US-International : Key_map ; + +# boot loader +AddFilesToHaikuImage beos system : zbeos ; + +# boot module links +AddBootModuleSymlinks config_manager bfs block_io fast_log generic_ide_pci isa + ide ide_adapter ide_isa intel locked_pool pci scsi scsi_cd scsi_dsk + scsi_periph +; + +# add-ons +AddFilesToHaikuImage beos system add-ons accelerants + : $(BEOS_ADD_ONS_ACCELERANTS) ; +AddFilesToHaikuImage beos system add-ons Translators + : $(BEOS_ADD_ONS_TRANSLATORS) ; +AddFilesToHaikuImage beos system add-ons media : $(BEOS_ADD_ONS_MEDIA) ; +AddFilesToHaikuImage beos system add-ons media plugins + : $(BEOS_ADD_ONS_MEDIA_PLUGINS) ; +AddFilesToHaikuImage beos system add-ons input_server devices + : keyboard mouse ; +AddFilesToHaikuImage beos system add-ons input_server filters : screen_saver ; +AddFilesToHaikuImage beos system add-ons input_server methods : canna ; +AddFilesToHaikuImage beos system add-ons kernel network + : $(BEOS_NETWORK_CORE) ; +AddFilesToHaikuImage beos system add-ons kernel network interfaces + : $(BEOS_NETWORK_INTERFACES) ; +AddFilesToHaikuImage beos system add-ons kernel network ppp + : $(BEOS_NETWORK_PPP) ; +AddFilesToHaikuImage beos system add-ons kernel network protocols + : $(BEOS_NETWORK_PROTOCOLS) ; +AddFilesToHaikuImage beos system add-ons Screen\ Savers + : $(BEOS_ADD_ONS_SCREENSAVERS) ; + + +#pragma mark - + +# Set image name and directory defaults and locate the image. +HAIKU_IMAGE_NAME ?= haiku.image ; +HAIKU_IMAGE_DIR ?= $(HAIKU_OUTPUT_DIR) ; +HAIKU_IMAGE ?= $(HAIKU_IMAGE_NAME) ; +HAIKU_IMAGE_SIZE ?= 80 ; # 80 MB +MakeLocate $(HAIKU_IMAGE) : $(HAIKU_IMAGE_DIR) ; + +# Set the default installation directory. +HAIKU_INSTALL_DIR ?= /haiku ; + +# the pseudo target all image contents is attached to +NotFile haiku-image-contents ; + +# prepare the script that initializes the shell variables +HAIKU_IMAGE_INIT_VARIABLES_SCRIPT = haiku.image-init-vars ; +local script = $(HAIKU_IMAGE_INIT_VARIABLES_SCRIPT) ; +MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ; +Always $(script) ; + +AddVariableToScript $(script) : sourceDir : $(HAIKU_TOP) ; +AddVariableToScript $(script) : outputDir : $(HAIKU_OUTPUT_DIR) ; +AddVariableToScript $(script) : tmpDir : $(HAIKU_TMP_DIR) ; +AddVariableToScript $(script) : installDir : $(HAIKU_INSTALL_DIR) ; +#AddVariableToScript $(script) : isImage : 1 ; +AddVariableToScript $(script) : imageSize : $(HAIKU_IMAGE_SIZE) ; +AddVariableToScript $(script) : addBuildCompatibilityLibDir + : $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ; +AddTargetVariableToScript $(script) : bfs_shell : bfsShell ; +AddTargetVariableToScript $(script) : fs_shell_command : fsShellCommand ; +AddTargetVariableToScript $(script) : copyattr ; +AddTargetVariableToScript $(script) : makebootable ; +AddTargetVariableToScript $(script) : rc ; +AddTargetVariableToScript $(script) : resattr ; +#AddTargetVariableToScript $(script) : $(HAIKU_IMAGE) : imagePath ; + # causes a cyclic dependency +AddVariableToScript $(script) : imagePath + : [ FDirName $(HAIKU_IMAGE_DIR) $(HAIKU_IMAGE_NAME) ] ; + +# create the other scripts +HAIKU_IMAGE_MAKE_DIRS_SCRIPT = haiku.image-make-dirs ; +HAIKU_IMAGE_COPY_FILES_SCRIPT = haiku.image-copy-files ; +MakeLocate $(HAIKU_IMAGE_MAKE_DIRS_SCRIPT) $(HAIKU_IMAGE_COPY_FILES_SCRIPT) + : $(HAIKU_OUTPUT_DIR) ; + +CreateHaikuImageMakeDirectoriesScript $(HAIKU_IMAGE_MAKE_DIRS_SCRIPT) ; +CreateHaikuImageCopyFilesScript $(HAIKU_IMAGE_COPY_FILES_SCRIPT) ; + +# Convenience wrapper rule around BuildHaikuImage. +rule _BuildHaikuImage +{ + # _BuildHaikuImage : ; + # + local image = $(1) ; + local isImage = $(2) ; + + # build the image + # HAIKU_IMAGE_EARLY_USER_SCRIPTS, HAIKU_IMAGE_LATE_USER_SCRIPTS can be + # specified by the user. + BuildHaikuImage $(image) : + $(HAIKU_IMAGE_INIT_VARIABLES_SCRIPT) + $(HAIKU_IMAGE_EARLY_USER_SCRIPTS) + $(HAIKU_IMAGE_MAKE_DIRS_SCRIPT) + $(HAIKU_IMAGE_COPY_FILES_SCRIPT) + $(HAIKU_IMAGE_LATE_USER_SCRIPTS) + : $(isImage) + ; + + # remove the scripts we have generated + RmTemps $(image) : + $(HAIKU_IMAGE_INIT_VARIABLES_SCRIPT) + $(HAIKU_IMAGE_MAKE_DIRS_SCRIPT) + $(HAIKU_IMAGE_COPY_FILES_SCRIPT) + ; +} + +# build the image +_BuildHaikuImage $(HAIKU_IMAGE) : true ; +NotFile haiku-image ; +Depends haiku-image : $(HAIKU_IMAGE) ; + +# install Haiku into a directory +NotFile install-haiku ; +_BuildHaikuImage install-haiku : 0 ; diff --git a/build/jam/HeadersRules b/build/jam/HeadersRules new file mode 100644 index 0000000000..357cfb109e --- /dev/null +++ b/build/jam/HeadersRules @@ -0,0 +1,358 @@ + +# FSysIncludes ; +# +# Counterpart of FIncludes for system include search paths. +# +#if $(OSPLAT) = X86 { + rule FSysIncludes { return -I$(<) ; } + HDRS_INCLUDES_SEPARATOR = -I- ; +# } else { +# rule FSysIncludes { return "-i "$(<) ; } +# HDRS_INCLUDES_SEPARATOR = -i- ; +# } +# mwcc support commented out + +rule SubDirSysHdrs +{ + # SubDirSysHdrs ; + # + # Adds directories to the system include search paths for the current + # subdirectory. Counterpart of SubDirHdrs which adds non-system include + # search paths. + # + # : The directories to be added to the current subdir's system + # include search paths. + # + SUBDIRSYSHDRS += [ FDirName $(1) ] ; +} + +rule ObjectSysHdrs +{ + # ObjectSysHdrs : : + # + # Adds directories to the system include search paths for the given + # sources or objects. Counterpart of ObjectHdrs which adds non-system + # include search paths. + # + # NOTE: With this incarnation of the Haiku build system this rule doesn't + # need to be invoked *after* the rule that generates the objects anymore. + # Actually it is even encouraged to do that *before*. Same for ObjectHdrs. + # + # : The targets for which to add system include + # search paths. + # : The directories to be added to the given objects' system + # include search paths. + # + + local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] $(3) ; + local headers = $(2) ; + + local file ; + for file in $(objects) { + on $(file) { + local sysHeaders = $(SYSHDRS) $(headers) ; + SYSHDRS on $(file) = $(sysHeaders) ; + + # reformat ASHDRS and CCHDRS + local fileHeaders = [ FIncludes $(HDRS) ] + $(HDRS_INCLUDES_SEPARATOR) [ FIncludes $(sysHeaders) ] ; + ASHDRS on $(file) = $(fileHeaders) ; + CCHDRS on $(file) = $(fileHeaders) ; + } + } +} + +rule SourceHdrs +{ + # SourceHdrs : [ : ] ; + # + # Is a wrapper for ObjectHdrs, that passes and or, + # if supplied and , and also adjusts HDRSEARCH (not + # done by ObjectHdrs). + + local sources = [ FGristFiles $(1) ] ; + local headers = $(2) ; + local objects = $(3) ; + + ObjectHdrs $(sources) : $(headers) : $(objects) ; + + # Also add the header search dirs to HDRSEARCH. Note, that these dirs + # will be listed after the STDHDRS (if any), but that's better than not + # being listed at all. + HDRSEARCH on $(sources) += $(headers) ; +} + +rule SourceSysHdrs +{ + # SourceSysHdrs : [ : ] ; + # + # Is a wrapper for ObjectSysHdrs, that passes and or, + # if supplied and , and also adjusts HDRSEARCH (not + # done by ObjectSysHdrs). + + local sources = [ FGristFiles $(1) ] ; + local headers = $(2) ; + local objects = $(3) ; + + ObjectSysHdrs $(sources) : $(headers) : $(objects) ; + + # Also add the header search dirs to HDRSEARCH. Note, that these dirs + # will be listed after the STDHDRS (if any), but that's better than not + # being listed at all. + HDRSEARCH on $(sources) += $(headers) ; +} + +rule PublicHeaders +{ + # PublicHeaders + # + # Returns the directory names for the public header dirs identified by + # . + + local list = $(1) ; + local dirs = [ FDirName $(HAIKU_TOP) headers os ] ; + + for i in $(list) { + dirs += [ FDirName $(HAIKU_TOP) headers os $(i) ] ; + } + return $(dirs) ; +} + +rule PrivateHeaders +{ + # PrivateHeaders + # + # Returns the directory names for the private header dirs identified by + # . + + local list = $(1) ; + local dirs ; + for i in $(list) { + dirs += [ FDirName $(HAIKU_TOP) headers private $(i) ] ; + } + return $(dirs) ; +} + +rule LibraryHeaders +{ + # LibraryHeaders + # + # Returns the directory names for the library header dirs identified by + # . + + local list = $(1) ; + local dirs ; + for i in $(list) { + dirs += [ FDirName $(HAIKU_TOP) headers libs $(i) ] ; + } + return $(dirs) ; +} + +rule ArchHeaders +{ + # usage: ArchHeaders ; + # + # specifies the architecture (e.g. x86). + + return [ FDirName $(HAIKU_TOP) headers private kernel arch $(1) ] ; +} + +rule UseHeaders +{ + # UseHeaders [ : ] ; + # + # Adds the C header dirs to the header search + # dirs of the subdirectory. + # If is "true", the dirs are added as system otherwise local + # search dirs. + # NOTE: This rule must be invoked *before* the rule that builds the objects. + + local header ; + if $(2) = true { + for header in $(1) { + SubDirSysHdrs $(header) ; + } + } else { + for header in $(1) { + SubDirHdrs $(header) ; + } + } +} + +rule UsePublicHeaders +{ + # UsePublicHeaders ; + # + # Adds the public C header dirs given by to the header search + # dirs of the subdirectory. + # NOTE: This rule must be invoked *before* the rule that builds the + # objects. + + UseHeaders [ PublicHeaders $(1) ] : true ; +} + +rule UsePublicObjectHeaders +{ + # UsePublicObjectHeaders : [ : ] ; + # + # Adds the public C header dirs given by to the header search + # dirs of either the object targets of or if supplied to + # . Also adjusts HDRSEARCH of . + # NOTE: This rule must be invoked *after* the rule that builds the objects. + + SourceSysHdrs $(1) : [ PublicHeaders $(2) ] : $(3) ; +} + +rule UsePrivateHeaders +{ + # UsePrivateHeaders [ : ] ; + # + # Adds the private C header dirs given by to the header search + # dirs of the subdirectory. + # specifies whether to add the dirs as system or local header + # search dirs. Defaults to "true". + # NOTE: This rule must be invoked *before* the rule that builds the objects. + + local system = $(2) ; + system ?= true ; + + UseHeaders [ PrivateHeaders $(1) ] : $(system) ; +} + +rule UsePrivateObjectHeaders +{ + # UsePrivateObjectHeaders : [ : + # [ : ] ] ; + # + # Adds the private C header dirs given by to the header search + # dirs of either the object targets of or if supplied to + # . Also adjusts HDRSEARCH of . + # specifies whether to add the dirs as system or local header + # search dirs. Defaults to "true". + # NOTE: This rule must be invoked *after* the rule that builds the objects. + + local system = $(4) ; + system ?= true ; + + if $(system) = true { + SourceSysHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; + } else { + SourceHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; + } +} + +rule UseCppUnitHeaders +{ + SubDirSysHdrs [ FDirName $(HAIKU_TOP) headers tools cppunit ] ; +} + +rule UseCppUnitObjectHeaders +{ + # UseCppUnitObjectHeaders [ : ] ; + SourceSysHdrs $(1) : [ FDirName $(HAIKU_TOP) headers tools cppunit ] + : $(2) ; +} + +rule UseArchHeaders +{ + # usage: UseArchHeaders ; + # + # specifies the architecture (e.g. x86). + # NOTE: This rule must be invoked *before* the rule that builds the objects. + + local headers = [ ArchHeaders $(1) ] ; + + UseHeaders $(headers) : true ; +} + +rule UseArchObjectHeaders +{ + # usage: UseArchObjectHeaders : : [ ] ; + # + # specifies the architecture (e.g. x86). + # Source or object files. + # NOTE: This rule must be invoked *after* the rule that builds the objects. + + local sources = $(1) ; + local headers = [ ArchHeaders $(2) ] ; + local objects = $(3) ; + local targets ; + if $(objects) { + targets = $(objects) ; + } else { + targets = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; + } + + SourceSysHdrs $(sources) : $(headers) : $(objects) ; +} + +rule UsePosixObjectHeaders +{ + # UsePosixObjectHeaders [ : ] ; + # + # Adds the POSIX header dir to the header search + # dirs of either the object targets of or if supplied to + # . Also adjusts HDRSEARCH of . + # NOTE: This rule must be invoked *after* the rule that builds the objects. + + SourceSysHdrs $(1) : [ FDirName $(HAIKU_TOP) headers posix ] : $(2) ; +} + +rule UseLibraryHeaders +{ + # UseLibraryHeaders ; + # + # Adds the library header dirs given by to the header search + # dirs of the subdirectory. + # NOTE: This rule must be invoked *before* the rule that builds the objects. + + UseHeaders [ LibraryHeaders $(1) ] : true ; +} + +rule FStandardOSHeaders +{ + local osIncludes = add-ons add-ons/file_system add-ons/graphics + add-ons/input_server add-ons/screen_saver + add-ons/tracker app device drivers game interface + kernel media mail midi midi2 net opengl storage support + translation ; + + return [ PublicHeaders $(osIncludes) ] ; +} + +rule FStandardHeaders +{ + local osIncludes = add-ons add-ons/file_system add-ons/graphics + add-ons/input_server add-ons/screen_saver + add-ons/tracker app device drivers game interface + kernel media mail midi midi2 net opengl storage support + translation ; + + # Use headers directory, to allow to do things like include + local headers = [ FDirName $(HAIKU_TOP) headers ] ; + + # Use posix headers directory + headers += [ FDirName $(HAIKU_TOP) headers posix ] ; + + # Use GNU headers directory + headers += [ FDirName $(HAIKU_TOP) headers gnu ] ; + + # Use glibc headers + headers += [ FDirName $(HAIKU_TOP) headers glibc ] ; + + headers += [ FDirName $(HAIKU_TOP) headers cpp ] ; + + # Use public OS header directories + headers += [ PublicHeaders $(osIncludes) ] ; + + # Use the root of the private headers -- not so nice, but simplifies things. + headers += [ PrivateHeaders $(DOT) ] ; + + # The platform (compiler actually) dependent headers. + headers += $(HAIKU_GCC_HEADERS_DIR) ; + + return $(headers) ; +} + +# SUBDIRSYSHDRS shall be reset automatically for each subdir +SUBDIRRESET += SYSHDRS ; diff --git a/build/jam/HelperRules b/build/jam/HelperRules new file mode 100644 index 0000000000..3967cc91ae --- /dev/null +++ b/build/jam/HelperRules @@ -0,0 +1,248 @@ +# Rules without side effects. + +# Vanilla Jam compatibility +if ! $(INVOCATION_SUBDIR_SET) { + rule FIsPrefix + { + # FIsPrefix : ; + # Returns true, if list is a prefix (a proper one or equal) of + # list , an empty list otherwise. + local a = $(1) ; + local b = $(2) ; + while $(a) && $(a[1]) = $(b[1]) { + a = $(a[2-]) ; + b = $(b[2-]) ; + } + + if $(a) { + return ; + } else { + return true ; + } + } + + rule LocalClean { Clean $(1) : $(2) ; } + + rule LocalDepends { Depends $(1) : $(2) ; } + +} # vanilla Jam compatibility + +rule FFilter +{ + # FFilter : ; + # Removes all occurrences of in . + + local list = $(1) ; + local excludes = $(2) ; + local newList ; + local item ; + for item in $(list) { + local skip ; + local exclude ; + for exclude in $(excludes) { + if $(item) = $(exclude) { + skip = true ; + } + } + if ! $(skip) { + newList += $(item) ; + } + } + return $(newList) ; +} + +rule FSplitPath +{ + # SplitPath ; + # Decomposes a path into its components. + local path = $(1:G=) ; + local components ; + # $(path:D) for "/" is "/". Therefore the second condition. + while $(path:D) && $(path:D) != $(path) + { + # Note: $(path:B) returns "." for "..", but $(path:D=) is fine. + components = $(path:D=) $(components) ; + path = $(path:D) ; + } + components = $(path) $(components) ; + return $(components) ; +} + +rule FTimeZoneBinaries +{ + local sources = $(1:G=timezone-source) ; + local locate = $(2) ; + local setRelativeTimezoneDir = $(3) ; + + local gristedBinaries ; + + local source ; + for source in $(sources) { + local binaries = [ on $(source) return $(TZ_OBJECTS) ] ; + + local targetDir = [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) + data etc timezones ] ; + + local binary ; + for binary in $(binaries) { + local dir = $(binary:D) ; + if $(dir) { + binary = $(binary:BSG=timezone!$(dir)) ; + if $(locate) { + LOCATE on $(binary) = [ FDirName $(targetDir) $(dir) ] ; + } + } else { + binary = $(binary:BSG=timezone) ; + if $(locate) { + LOCATE on $(binary) = $(targetDir) ; + } + } + + if $(setRelativeTimezoneDir) { + RELATIVE_TIMEZONE_DIR on $(binary) = $(dir) ; + } + + gristedBinaries += $(binary) ; + } + } + + return $(gristedBinaries) ; +} + + +rule SetPlatformCompatibilityFlagVariables +{ + # SetPlatformCompatibilityFlagVariables : + # : [ : other platforms ] ; + + local platformVar = $(1) ; + local platform = $($(platformVar)) ; + local varPrefix = $(2) ; + local platformKind = $(3) ; + local otherPlatforms = $(4) ; + + if ! $(platform) { + ECHO "Variable $(platformVar) not set. Please run ./configure or" ; + EXIT "specify it manually." ; + } + + $(varPrefix)_PLATFORM_BEOS_COMPATIBLE = ; + $(varPrefix)_PLATFORM_BONE_COMPATIBLE = ; + $(varPrefix)_PLATFORM_DANO_COMPATIBLE = ; + $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE = ; + + switch $(platform) + { + case r5 : + { + $(varPrefix)_PLATFORM_BEOS_COMPATIBLE = true ; + } + + case bone : + { + $(varPrefix)_PLATFORM_BONE_COMPATIBLE = true ; + } + + case dano : + { + $(varPrefix)_PLATFORM_DANO_COMPATIBLE = true ; + } + + case haiku : + { + $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE = true ; + } + + case * : + { + if ! ( $(platform) in $(otherPlatforms) ) { + Exit Unsupported $(platformKind) platform: $(platform) ; + } + } + } + + # set lesser flags, e.g. "DANO" for "HAIKU" and "BEOS" for "BONE" + $(varPrefix)_PLATFORM_DANO_COMPATIBLE + ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ; + $(varPrefix)_PLATFORM_BONE_COMPATIBLE + ?= $($(varPrefix)_PLATFORM_DANO_COMPATIBLE) ; + $(varPrefix)_PLATFORM_BEOS_COMPATIBLE + ?= $($(varPrefix)_PLATFORM_BONE_COMPATIBLE) ; + + # set the machine friendly flags + $(varPrefix)_PLATFORM_(haiku)_COMPATIBLE + ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ; + $(varPrefix)_PLATFORM_(dano)_COMPATIBLE + ?= $($(varPrefix)_PLATFORM_DANO_COMPATIBLE) ; + $(varPrefix)_PLATFORM_(bone)_COMPATIBLE + ?= $($(varPrefix)_PLATFORM_BONE_COMPATIBLE) ; + $(varPrefix)_PLATFORM_(r5)_COMPATIBLE + ?= $($(varPrefix)_PLATFORM_BEOS_COMPATIBLE) ; +} + + +#pragma mark - + +rule SetPlatformForTarget +{ + # SetPlatformForTarget : ; + + PLATFORM on $(1) = $(2) ; +} + +rule SetSubDirPlatform +{ + # SetSubDirPlatform ; + + PLATFORM = $(1) ; +} + +rule SetSupportedPlatformsForTarget +{ + # SetSupportedPlatformsForTarget : ; + + SUPPORTED_PLATFORMS on $(1) = $(2) ; +} + +rule SetSubDirSupportedPlatforms +{ + # SetSubDirSupportedPlatforms ; + + SUPPORTED_PLATFORMS = $(1) ; +} + +rule SetSubDirSupportedPlatformsBeOSCompatible +{ + # SetSubDirSupportedPlatformsBeOSCompatible ; + + SUPPORTED_PLATFORMS = $(HAIKU_BEOS_COMPATIBLE_PLATFORMS) ; +} + +rule IsPlatformSupportedForTarget +{ + # IsPlatformSupportedForTarget [ : ] + # + + on $(1) { + if $(PLATFORM) in $(SUPPORTED_PLATFORMS) { + return true ; + } else { + return ; + } + } +} + +rule InheritPlatform +{ + # InheritPlatform : ; + # PLATFORM and SUPPORTED_PLATFORMS are set on to their value + # on . + # + local children = $(1) ; + local parent = $(2) ; + + on $(parent) { + PLATFORM on $(children) = $(PLATFORM) ; + SUPPORTED_PLATFORMS on $(children) = $(SUPPORTED_PLATFORMS) ; + } +} diff --git a/build/jam/ImageRules b/build/jam/ImageRules new file mode 100644 index 0000000000..d7b4c27ca2 --- /dev/null +++ b/build/jam/ImageRules @@ -0,0 +1,341 @@ +rule FSameTargetWithPrependedGrist +{ + # SameTargetWithPrependedGrist : ; + # + local target = $(1) ; + local gristToPrepend = $(2) ; + local grist = $(target:G) ; + + if $(grist) { + grist = $(gristToPrepend)!$(grist) ; + } else { + grist = $(gristToPrepend) ; + } + + return $(target:G=$(grist)) ; +} + +rule InitScript +{ + # Note: The script must have been LOCATEd before. + local script = $(1) ; + local initScript + = [ FSameTargetWithPrependedGrist $(script) : init-script ] ; + + if ! [ on $(script) return $(__is_initialized) ] { + __is_initialized on $(script) = true ; + + MakeLocate $(initScript) : [ on $(script) return $(LOCATE) ] ; + Always $(initScript) ; + Depends $(script) : $(initScript) ; + + InitScript1 $(initScript) ; + } + + return $(initScript) ; +} + +actions InitScript1 +{ + rm -f $(1) + echo -n > $(1) +} + +rule AddVariableToScript +{ + # AddVariableToScript