1*979afc6fSAxel Dörfler# Haiku main build rules 2*979afc6fSAxel Dörfler 39eea4522SIngo Weinhold# Vanilla Jam compatibility 49eea4522SIngo Weinholdif ! $(INVOCATION_SUBDIR_SET) { 59eea4522SIngo Weinhold rule FIsPrefix 69eea4522SIngo Weinhold { 79eea4522SIngo Weinhold # FIsPrefix <a> : <b> ; 89eea4522SIngo Weinhold # Returns true, if list <a> is a prefix (a proper one or equal) of 99eea4522SIngo Weinhold # list <b>, an empty list otherwise. 109eea4522SIngo Weinhold local a = $(1) ; 119eea4522SIngo Weinhold local b = $(2) ; 129eea4522SIngo Weinhold while $(a) && $(a[1]) = $(b[1]) { 139eea4522SIngo Weinhold a = $(a[2-]) ; 149eea4522SIngo Weinhold b = $(b[2-]) ; 159eea4522SIngo Weinhold } 169eea4522SIngo Weinhold 179eea4522SIngo Weinhold if $(a) { 189eea4522SIngo Weinhold return ; 199eea4522SIngo Weinhold } else { 209eea4522SIngo Weinhold return true ; 219eea4522SIngo Weinhold } 229eea4522SIngo Weinhold } 239eea4522SIngo Weinhold 249eea4522SIngo Weinhold rule LocalClean { Clean $(1) : $(2) ; } 259eea4522SIngo Weinhold 269eea4522SIngo Weinhold rule LocalDepends { Depends $(1) : $(2) ; } 279eea4522SIngo Weinhold 289eea4522SIngo Weinhold} # vanilla Jam compatibility 299eea4522SIngo Weinhold 304ff6d49fSIngo Weinhold# The directory for build system specific files 314ff6d49fSIngo WeinholdOBOS_BUILD_DIR = [ FDirName $(OBOS_TOP) build ] ; 324ff6d49fSIngo Weinhold 334ff6d49fSIngo Weinhold# Cache files for header scanning and jamfile caching 344ff6d49fSIngo WeinholdHCACHEFILE = header_cache ; 354ff6d49fSIngo WeinholdJCACHEFILE = jamfile_cache ; 364ff6d49fSIngo WeinholdLOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(OBOS_BUILD_DIR) ; 379eea4522SIngo Weinhold 38b1e5b60cSAxel Dörfler# Include BuildConfig/Timezones/libgccObjects 3952a38012Sejakowatz{ 404ff6d49fSIngo Weinhold local buildConfig = [ GLOB $(OBOS_BUILD_DIR) : BuildConfig ] ; 41b1e5b60cSAxel Dörfler local timezones = [ GLOB $(OBOS_BUILD_DIR) : Timezones ] ; 42b1e5b60cSAxel Dörfler local libgccObjects = [ GLOB $(OBOS_BUILD_DIR) : libgccObjects ] ; 43b1e5b60cSAxel Dörfler 44b1e5b60cSAxel Dörfler if ! $(buildConfig) { 45b1e5b60cSAxel Dörfler ECHO "No `BuildConfig' found in $(OBOS_BUILD_DIR)!" ; 464ff6d49fSIngo Weinhold EXIT "Run ./configure in the source tree's root directory first!" ; 4752a38012Sejakowatz } 48b1e5b60cSAxel Dörfler if ! ( $(timezones) && $(libgccObjects) ) { 49b1e5b60cSAxel Dörfler ECHO "No `Timezones' or `libgccObjects' found in $(OBOS_BUILD_DIR)!" ; 50b1e5b60cSAxel Dörfler EXIT "Please run ./configure in the source tree's root directory again!" ; 51b1e5b60cSAxel Dörfler } 52b1e5b60cSAxel Dörfler 534ff6d49fSIngo Weinhold LOCATE on BuildConfig = $(OBOS_BUILD_DIR) ; 54b1e5b60cSAxel Dörfler LOCATE on Timezones = $(OBOS_BUILD_DIR) ; 55b1e5b60cSAxel Dörfler LOCATE on libgccObjects = $(OBOS_BUILD_DIR) ; 56b1e5b60cSAxel Dörfler 574ff6d49fSIngo Weinhold include BuildConfig ; 58b1e5b60cSAxel Dörfler include Timezones ; 59b1e5b60cSAxel Dörfler include libgccObjects ; 6052a38012Sejakowatz} 6152a38012Sejakowatz 628c17a26bSIngo Weinhold# analyze GCC version 638c17a26bSIngo Weinholdif ! $(GCC_RAW_VERSION) { 648c17a26bSIngo Weinhold ECHO "Variable GCC_RAW_VERSION not set. Please run ./configure or" ; 658c17a26bSIngo Weinhold EXIT "specify it manually." ; 668c17a26bSIngo Weinhold} 678c17a26bSIngo WeinholdGCC_VERSION = ; 688c17a26bSIngo Weinhold{ 698c17a26bSIngo Weinhold # split the raw version string at `.' and `-' characters 708c17a26bSIngo Weinhold local version = $(GCC_RAW_VERSION) ; 718c17a26bSIngo Weinhold while $(version) { 728c17a26bSIngo Weinhold local split = [ Match "([^.-]*)[.-](.*)" : $(version) ] ; 738c17a26bSIngo Weinhold if $(split) { 748c17a26bSIngo Weinhold GCC_VERSION += $(split[1]) ; 758c17a26bSIngo Weinhold version = $(split[2]) ; 768c17a26bSIngo Weinhold } else { 778c17a26bSIngo Weinhold GCC_VERSION += $(version) ; 788c17a26bSIngo Weinhold version = ; 798c17a26bSIngo Weinhold } 808c17a26bSIngo Weinhold } 818c17a26bSIngo Weinhold} 828c17a26bSIngo Weinhold 835dc4e1efSIngo Weinhold# Save the platform default headers. 845dc4e1efSIngo WeinholdPLATFORM_DEFAULT_HEADERS = $(HDRS) ; 855dc4e1efSIngo Weinhold 86705fc998SAxel Dörfler# Add some grist to the libgcc objects 87705fc998SAxel DörflerLIBGCC_OBJECTS = $(LIBGCC_OBJECTS:G=libgcc) ; 88705fc998SAxel Dörfler 89a6c008e1Sbeveloper# We do not include any local BeOS system headers by default 90dd9f8062SIngo WeinholdCCFLAGS += -nostdinc ; 91dd9f8062SIngo WeinholdC++FLAGS += -nostdinc ; 92a6c008e1Sbeveloper 932abad45eSbeveloper# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() 942abad45eSbeveloper# issues, they deprecated that nice function. This will enable it again: 952abad45eSbeveloperC++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; 962abad45eSbeveloper 974bb19442Sshattyif ! $(TARGET_PLATFORM) { 984bb19442Sshatty ECHO "Variable TARGET_PLATFORM not set. Please run ./configure or" ; 994bb19442Sshatty EXIT "specify it manually." ; 1004bb19442Sshatty} 101a17b9c0cSshattyswitch $(TARGET_PLATFORM) 102a17b9c0cSshatty{ 103a17b9c0cSshatty case r5 : 104a17b9c0cSshatty { 1054bb19442Sshatty # "everything" is r5 compatible 106be1aef42Sshatty } 107a17b9c0cSshatty case bone : 108a17b9c0cSshatty { 109a17b9c0cSshatty BONE_COMPATIBLE = true ; 110a17b9c0cSshatty } 111a17b9c0cSshatty case dano : 112a17b9c0cSshatty { 113a17b9c0cSshatty BONE_COMPATIBLE = true ; 114a17b9c0cSshatty DANO_COMPATIBLE = true ; 115a17b9c0cSshatty } 116a17b9c0cSshatty case haiku : 117a17b9c0cSshatty { 118a17b9c0cSshatty BONE_COMPATIBLE = true ; 119a17b9c0cSshatty DANO_COMPATIBLE = true ; 120a17b9c0cSshatty HAIKU_COMPATIBLE = true ; 121a104c31bSshatty DEFINES += __HAIKU__ ; 122a17b9c0cSshatty } 123a17b9c0cSshatty} 1246040be99Sshattyif $(BONE_COMPATIBLE) { 125bc10030eSPhilippe Houdoin # FIXME: we don't have our own "libbnetapi.so" yet :-( 126bc10030eSPhilippe Houdoin # NETWORK_LIBS = libsocket.so libbind.so libbnetapi.so ; 127bc10030eSPhilippe Houdoin NETWORK_LIBS = libsocket.so libbind.so bnetapi ; 1282506bbb6Sshatty SELECT_UNAME_ETC_LIB = libroot.so ; 1296040be99Sshatty} else { 130bc10030eSPhilippe Houdoin NETWORK_LIBS = libnet.so libnetapi.so ; 1312506bbb6Sshatty SELECT_UNAME_ETC_LIB = libnet.so ; 1326040be99Sshatty} 133be1aef42Sshatty 13452a38012Sejakowatz# Determine if we're building on PPC or x86 13552a38012Sejakowatz# Determine mimetype of executable 13652a38012Sejakowatz# Cross compiling can come later 13752a38012Sejakowatz 138c9882d9eSAxel DörflerTARGET_CPU ?= $(OSPLAT:L) ; 1391f622a7bSAxel DörflerOBOS_VERSION ?= R1 ; 1401f622a7bSAxel Dörfler 1411f622a7bSAxel Dörflerswitch $(TARGET_CPU) { 1421f622a7bSAxel Dörfler case ppc : 1431f622a7bSAxel Dörfler { 14452a38012Sejakowatz if $(METROWERKS) { 1451f622a7bSAxel Dörfler # at least parts of OpenBeOS still can be compiled with 1461f622a7bSAxel Dörfler # the Metrowerks compiler on BeOS/PPC 14752a38012Sejakowatz OBOS_TARGET_TYPE ?= "application/x-be-executable" ; 14852a38012Sejakowatz } else { 14952a38012Sejakowatz OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; 1501f622a7bSAxel Dörfler } 151894d1636Sshatty DEFINES += __POWERPC__ ARCH_ppc ; 152e29d8533SAxel Dörfler OBOS_BOOT_PLATFORM = openfirmware ; 1531f622a7bSAxel Dörfler } 1541f622a7bSAxel Dörfler case x86 : 1551f622a7bSAxel Dörfler { 1561f622a7bSAxel Dörfler # nothing special to do here... 157894d1636Sshatty DEFINES += __INTEL__ ARCH_x86 ; 158e29d8533SAxel Dörfler OBOS_BOOT_PLATFORM = bios_ia32 ; 1591f622a7bSAxel Dörfler } 1601f622a7bSAxel Dörfler case * : 1611f622a7bSAxel Dörfler Exit "Currently unsupported build platform:" $(TARGET_CPU) ; 1621f622a7bSAxel Dörfler} 1631f622a7bSAxel Dörfler 1641f622a7bSAxel Dörfler# set target specific variables 1651f622a7bSAxel Dörfler{ 1661f622a7bSAxel Dörfler #Echo "Building for" $(TARGET_CPU) ; 1671f622a7bSAxel Dörfler 1681f622a7bSAxel Dörfler OBOS_TARGET ?= $(TARGET_CPU).$(OBOS_VERSION) ; 1691f622a7bSAxel Dörfler OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; 1701f622a7bSAxel Dörfler OBOS_ARCH ?= $(TARGET_CPU) ; 1711f622a7bSAxel Dörfler OBOS_TARGET_DEFINE ?= "ARCH_"$(TARGET_CPU) ; 17252a38012Sejakowatz} 17352a38012Sejakowatz 17465c62a01SIngo Weinhold# Disable warnings only if WARNINGS is set to 0 175e5dc2d93Sbeveloper# Should be enabled by default later 17696d27465SIngo Weinhold# 17765c62a01SIngo WeinholdWARNINGS ?= 1 ; 17865c62a01SIngo Weinholdif $(WARNINGS) = 1 { 179e5dc2d93Sbeveloper # For an explanation of the different warning options, see: 180e5dc2d93Sbeveloper # http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html 181e5dc2d93Sbeveloper # to get even more warnings, add: 182e5dc2d93Sbeveloper # -Wwrite-strings (doesn't work well with some Be headers) 183e5dc2d93Sbeveloper # -Wundef (dito) 184e5dc2d93Sbeveloper # -Wconversion (gets you many warnings about implicit conversions) 185e5dc2d93Sbeveloper # -W (gets you even more warnigs) 186dd9f8062SIngo Weinhold CCFLAGS += -Wall -Wno-multichar -Wmissing-prototypes ; 187dd9f8062SIngo Weinhold CCFLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; 188dd9f8062SIngo Weinhold C++FLAGS += -Wall -Wno-multichar -Wmissing-prototypes -Wno-ctor-dtor-privacy -Woverloaded-virtual ; 189dd9f8062SIngo Weinhold C++FLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; 19098cc804cSAxel Dörfler} else { 19198cc804cSAxel Dörfler CCFLAGS += -Wno-multichar ; 19298cc804cSAxel Dörfler C++FLAGS += -Wno-multichar ; 193e5dc2d93Sbeveloper} 194e5dc2d93Sbeveloper 19598cc804cSAxel Dörfler# standard kernel C/C++ flags 1960ff867c2SbeveloperKERNEL_CCFLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; 1974d74cda3SAxel DörflerKERNEL_CCFLAGS += -fno-builtin -D$(OBOS_TARGET_DEFINE) -D__HAIKU__ ; 198ea7627e5SAxel DörflerKERNEL_CCFLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 19998cc804cSAxel DörflerKERNEL_C++FLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; 2004d74cda3SAxel DörflerKERNEL_C++FLAGS += -fno-builtin -fno-exceptions -D$(OBOS_TARGET_DEFINE) -D__HAIKU__ ; 201ea7627e5SAxel DörflerKERNEL_C++FLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 202bbb6f2d4SAxel Dörflerif $(GCC_VERSION[1]) >= 3 { 203bbb6f2d4SAxel Dörfler KERNEL_C++FLAGS += -fno-use-cxa-atexit ; 204bbb6f2d4SAxel Dörfler} 2050ff867c2Sbeveloper 2063844cf70SIngo WeinholdDEBUG_FLAGS ?= -g ; 2073844cf70SIngo Weinhold 2089eea4522SIngo Weinhold# We might later want to introduce debug levels or handle the whole issue 2099eea4522SIngo Weinhold# differently. For now there's only on or off. 2109eea4522SIngo Weinhold# 21165c62a01SIngo WeinholdDEBUG ?= 0 ; 21265c62a01SIngo Weinholdif $(DEBUG) != 0 { 2139eea4522SIngo Weinhold OPTIM ?= -O0 ; 2143844cf70SIngo Weinhold CCFLAGS += $(DEBUG_FLAGS) [ FDefines DEBUG=$(DEBUG) ] ; 2153844cf70SIngo Weinhold C++FLAGS += $(DEBUG_FLAGS) [ FDefines DEBUG=$(DEBUG) ] ; 2163844cf70SIngo Weinhold KERNEL_CCFLAGS += $(DEBUG_FLAGS) [ FDefines DEBUG=$(DEBUG) ] ; 2173844cf70SIngo Weinhold KERNEL_C++FLAGS += $(DEBUG_FLAGS) [ FDefines DEBUG=$(DEBUG) ] ; 2183844cf70SIngo Weinhold LINKFLAGS += $(DEBUG_FLAGS) ; 2199eea4522SIngo Weinhold} else { 2209eea4522SIngo Weinhold OPTIM ?= -O2 ; 2219eea4522SIngo Weinhold} 22296d27465SIngo Weinhold# 22396d27465SIngo Weinhold# To disable for the tests OPTIM and DEBUG are overridden, set the environment 22496d27465SIngo Weinhold# variable NO_TEST_DEBUG. 2259eea4522SIngo Weinhold 226d5807053SIngo Weinhold# If the environment variable DEBUG_PRINTF is defined we define an equally 227d5807053SIngo Weinhold# named macro to the variable value. Some components use the macro to allow 228d5807053SIngo Weinhold# another function than printf() to print the debug output. The variable should 229d5807053SIngo Weinhold# be set to the name of the alternative function. 230d5807053SIngo Weinhold# 231d5807053SIngo Weinholdif $(DEBUG_PRINTF) { 232d5807053SIngo Weinhold CCFLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; 233d5807053SIngo Weinhold C++FLAGS += [ FDefines DEBUG_PRINTF=$(DEBUG_PRINTF) ] ; 234d5807053SIngo Weinhold} 235d5807053SIngo Weinhold 23616fa4445SIngo Weinhold# Instructs the Library rule to not make its object files temporary. 237f1e077f8SIngo Weinhold# This is needed as some objects are used in a static library and for an 23816fa4445SIngo Weinhold# executable. 23916fa4445SIngo WeinholdKEEPOBJS = true ; 24016fa4445SIngo Weinhold 2417bc56df1SIngo Weinhold# under BeOS use copyattr instead of cp 2427bc56df1SIngo Weinholdif $(OS) = BEOS 2437bc56df1SIngo Weinhold{ 2447bc56df1SIngo Weinhold CP = copyattr --data ; 2457bc56df1SIngo Weinhold} 2467bc56df1SIngo Weinhold 24753cf6d7aSAxel Dörfler# for builds of tools in the current environment 24853cf6d7aSAxel Dörflerif $(OS) = BEOS { 24953cf6d7aSAxel Dörfler BUILD_LIBSTDC++ = stdc++.r4 ; 25053cf6d7aSAxel Dörfler} else { 25153cf6d7aSAxel Dörfler BUILD_LIBSTDC++ = stdc++ ; 25253cf6d7aSAxel Dörfler} 25353cf6d7aSAxel Dörfler 2543844cf70SIngo Weinholdif $(GCC_VERSION[1]) >= 3 { 2553844cf70SIngo Weinhold C++_SUPPORT_LIBS = supc++ ; 2563844cf70SIngo Weinhold} else { 2573844cf70SIngo Weinhold C++_SUPPORT_LIBS = ; 2583844cf70SIngo Weinhold} 2593844cf70SIngo Weinhold 2603844cf70SIngo Weinhold 26152a38012Sejakowatz# If no OBOS_OBJECT_TARGET is not defined yet, use our default directory and 26252a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 26352a38012Sejakowatz# builds mixing objects from different targets). 26452a38012Sejakowatzif ! $(OBOS_OBJECT_TARGET) { 26552a38012Sejakowatz OBOS_OBJECT_TARGET ?= [ FDirName $(OBOS_TOP) objects $(OBOS_TARGET) ] ; 26652a38012Sejakowatz} 26752a38012Sejakowatz 26852a38012Sejakowatz# If no OBOS_DISTRO_TARGET is not defined yet, use our default directory and 26952a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 27052a38012Sejakowatz# builds mixing executables from different targets). 27152a38012Sejakowatzif ! $(OBOS_DISTRO_TARGET) { 27252a38012Sejakowatz OBOS_DISTRO_TARGET ?= [ FDirName $(OBOS_TOP) distro $(OBOS_TARGET) ] ; 27352a38012Sejakowatz} 27452a38012Sejakowatz 27552a38012Sejakowatz# Set our version number if not already set and mark it as a developer build 27652a38012Sejakowatzif ! $(OBOS_BUILD_VERSION) { 27752a38012Sejakowatz OBOS_BUILD_VERSION ?= "1 0 0 a 1" ; 27852a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Developer Build" ; 27952a38012Sejakowatz} 28052a38012Sejakowatz 28152a38012Sejakowatz# If OBOS_BUILD_VERSION is set, but OBOS_BUILD_DESCRIPTION isn't, mark it as 28252a38012Sejakowatz# an unknown build. 28352a38012Sejakowatzif ! $(OBOS_BUILD_DESCRIPTION) { 28452a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Unknown Build" ; 28552a38012Sejakowatz} 28652a38012Sejakowatz 287505554b4SIngo Weinhold# Relative subdirs for distro dir 288505554b4SIngo WeinholdOBOS_ADDON_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system add-ons ] ; 2895f281ed5SejakowatzOBOS_APPS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos apps ] ; 290f06de7f3SIngo WeinholdOBOS_BIN_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos bin ] ; 291505554b4SIngo WeinholdOBOS_ETC_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos etc ] ; 292505554b4SIngo WeinholdOBOS_FONTS_DIR ?= [ FDirName $(OBOS_ETC_DIR) fonts ] ; 293505554b4SIngo WeinholdOBOS_KERNEL_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system ] ; 29452a38012SejakowatzOBOS_PREFS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos preferences ] ; 29552a38012SejakowatzOBOS_SERVER_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system servers ] ; 29652a38012SejakowatzOBOS_SHLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ; 297e9230d05SIngo WeinholdOBOS_STLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) develop lib 298e9230d05SIngo Weinhold $(OBOS_ARCH) ] ; 29952a38012SejakowatzOBOS_TEST_DIR ?= [ FDirName $(OBOS_TOP) tests ] ; 30052a38012Sejakowatz 301c06f365fSIngo WeinholdOBOS_PACKAGE_DIR ?= [ FDirName $(OBOS_TOP) packages $(OBOS_TARGET) ] ; 302c06f365fSIngo WeinholdOBOS_PACKAGE_OBJECT_DIR ?= [ FDirName $(OBOS_OBJECT_TARGET) packages ] ; 303c06f365fSIngo Weinhold 30452a38012SejakowatzOBOS_KERNEL_CONFIG = config.$(OBOS_ARCH).ini ; 30552a38012SejakowatzOBOS_KERNEL = kernel.$(OBOS_ARCH) ; 30652a38012SejakowatzOBOS_FLOPPY = floppy.$(OBOS_ARCH) ; 30752a38012Sejakowatz 30852a38012Sejakowatzrule SetupIncludes 30952a38012Sejakowatz{ 310cfc7b456Sshatty # XXX add "opengl" later 311cfc7b456Sshatty 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 storage support translation ; 312a6c008e1Sbeveloper 31328d2a30eSDaniel Reinhold # Overwrite any exiting content when changing HDRS. This rule may be invoked multiple times. 314a6c008e1Sbeveloper 315a6c008e1Sbeveloper # Use headers directory, to allow to do things like include <posix/string.h> 31628d2a30eSDaniel Reinhold HDRS = [ FDirName $(OBOS_TOP) headers ] ; 317a6c008e1Sbeveloper 3183844cf70SIngo Weinhold HDRS = [ FDirName $(OBOS_TOP) headers cpp ] ; 3193844cf70SIngo Weinhold 320a6c008e1Sbeveloper # Use posix headers directory 32128d2a30eSDaniel Reinhold HDRS += [ FDirName $(OBOS_TOP) headers posix ] ; 322a6c008e1Sbeveloper 323a6c008e1Sbeveloper # Use public OS header directories 32428d2a30eSDaniel Reinhold HDRS += [ PublicHeaders $(os_includes) ] ; 325a6c008e1Sbeveloper 326c0e501e0SIngo Weinhold # Use the root of the private headers -- not so nice, but simplifies things. 327c0e501e0SIngo Weinhold HDRS += [ PrivateHeaders $(DOT) ] ; 328c0e501e0SIngo Weinhold 329a6c008e1Sbeveloper # Used as a fallback, the R5 header directories (we should remove this as soon as possible) 33028d2a30eSDaniel Reinhold HDRS += /boot/develop/headers/posix /boot/develop/headers/cpp ; 33109c5682dSIngo Weinhold 33209c5682dSIngo Weinhold # The platform dependent headers. 33309c5682dSIngo Weinhold HDRS += $(PLATFORM_HEADERS) ; 33452a38012Sejakowatz} 33552a38012Sejakowatz 336dd9f8062SIngo Weinholdrule SetupR5Includes 337dd9f8062SIngo Weinhold{ 338dd9f8062SIngo Weinhold # Unsets HDRS, so that the OBOS headers do not `shadow' the system headers. 339dd9f8062SIngo Weinhold HDRS = ; 340dd9f8062SIngo Weinhold} 341dd9f8062SIngo Weinhold 3425dc4e1efSIngo Weinholdrule SetupDefaultIncludes 3435dc4e1efSIngo Weinhold{ 3445dc4e1efSIngo Weinhold # Resets HDRS to the default headers for the build platform. 3455dc4e1efSIngo Weinhold HDRS = $(PLATFORM_DEFAULT_HEADERS) ; 3465dc4e1efSIngo Weinhold} 3475dc4e1efSIngo Weinhold 34852a38012Sejakowatz#------------------------------------------------------------------------------- 34952a38012Sejakowatz# Things Jam needs in order to work :) 35052a38012Sejakowatz#------------------------------------------------------------------------------- 35152a38012Sejakowatz 352c06f365fSIngo Weinhold# TODO: back-ported from jam 2.5: remove when not longer needed 353c06f365fSIngo Weinholdrule MakeLocate 354c06f365fSIngo Weinhold{ 355c06f365fSIngo Weinhold if $(>) 356c06f365fSIngo Weinhold { 357c06f365fSIngo Weinhold LOCATE on $(<) = $(>) ; 358c06f365fSIngo Weinhold Depends $(<) : $(>[1]:G=dir) ; 359c06f365fSIngo Weinhold MkDir $(>[1]:G=dir) ; 360c06f365fSIngo Weinhold } 361c06f365fSIngo Weinhold} 362c06f365fSIngo Weinhold 3638d3308d9SIngo Weinholdrule Object 3648d3308d9SIngo Weinhold{ 3658d3308d9SIngo Weinhold # This is basically the original Jambase 2.4 Object rule stripped by 3668d3308d9SIngo Weinhold # comments. Only the final switch statement has been changed to allow 3678d3308d9SIngo Weinhold # intermediate C++ files for Yacc and Lex. 3688d3308d9SIngo Weinhold 3698d3308d9SIngo Weinhold LocalClean clean : $(<) ; 3708d3308d9SIngo Weinhold 3718d3308d9SIngo Weinhold MakeLocate $(<) : $(LOCATE_TARGET) ; 3728d3308d9SIngo Weinhold SEARCH on $(>) = $(SEARCH_SOURCE) ; 3738d3308d9SIngo Weinhold 3748d3308d9SIngo Weinhold HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ; 3758d3308d9SIngo Weinhold 3768d3308d9SIngo Weinhold HDRRULE on $(>) = HdrRule ; 3778d3308d9SIngo Weinhold HDRSCAN on $(>) = $(HDRPATTERN) ; 3788d3308d9SIngo Weinhold HDRSEARCH on $(>) = 3798d3308d9SIngo Weinhold $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ; 3808d3308d9SIngo Weinhold 3818d3308d9SIngo Weinhold HDRGRIST on $(>) = $(HDRGRIST) ; 3828d3308d9SIngo Weinhold 3838d3308d9SIngo Weinhold DEFINES on $(<) += $(DEFINES) ; 3848d3308d9SIngo Weinhold 3858d3308d9SIngo Weinhold # if source is not .c, generate .c with specific rule 3868d3308d9SIngo Weinhold 3878d3308d9SIngo Weinhold switch $(>:S) 3888d3308d9SIngo Weinhold { 3898d3308d9SIngo Weinhold case .asm : As $(<) : $(>) ; 3908d3308d9SIngo Weinhold case .c : Cc $(<) : $(>) ; 3918d3308d9SIngo Weinhold case .C : C++ $(<) : $(>) ; 3928d3308d9SIngo Weinhold case .cc : C++ $(<) : $(>) ; 3938d3308d9SIngo Weinhold case .cpp : C++ $(<) : $(>) ; 3948d3308d9SIngo Weinhold case .f : Fortran $(<) : $(>) ; 3958d3308d9SIngo Weinhold case .l : if [ on $(2) return $(GENERATE_C++) ] { 3968d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 3978d3308d9SIngo Weinhold LexC++ $(<:S=.cpp) : $(>) ; 3988d3308d9SIngo Weinhold } else { 3998d3308d9SIngo Weinhold Cc $(<) : $(<:S=.c) ; 4008d3308d9SIngo Weinhold Lex $(<:S=.c) : $(>) ; 4018d3308d9SIngo Weinhold } 4028d3308d9SIngo Weinhold case .s : As $(<) : $(>) ; 4038d3308d9SIngo Weinhold case .y : if [ on $(2) return $(GENERATE_C++) ] { 4048d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 4058d3308d9SIngo Weinhold Bison $(<:S=.cpp) : $(>) ; 4068d3308d9SIngo Weinhold } else { 4078d3308d9SIngo Weinhold Cc $(<) : $(<:S=$(YACCGEN)) ; 4088d3308d9SIngo Weinhold Yacc $(<:S=$(YACCGEN)) : $(>) ; 4098d3308d9SIngo Weinhold } 4108d3308d9SIngo Weinhold case * : UserObject $(<) : $(>) ; 4118d3308d9SIngo Weinhold } 4128d3308d9SIngo Weinhold} 4138d3308d9SIngo Weinhold 41452a38012Sejakowatzrule UserObject 41552a38012Sejakowatz{ 41652a38012Sejakowatz switch $(2) 41752a38012Sejakowatz { 41852a38012Sejakowatz case *.S : assemble $(1) : $(2) ; 41908125d07SIngo Weinhold case *.o : return ; 42052a38012Sejakowatz case * : ECHO "unknown suffix on" $(2) ; 42152a38012Sejakowatz } 42252a38012Sejakowatz} 42352a38012Sejakowatz 42452a38012Sejakowatz# Override the default to give "prettier" command lines. 42552a38012Sejakowatzactions Cc 42652a38012Sejakowatz{ 427025d0733SJérôme Duval $(CC) $(CCFLAGS) -c "$(2)" $(CCDEFS) $(CCHDRS) -o "$(1)" ; 42852a38012Sejakowatz} 42952a38012Sejakowatz 43052a38012Sejakowatzactions C++ 43152a38012Sejakowatz{ 4320931b8f9SIngo Weinhold $(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; 43352a38012Sejakowatz} 43452a38012Sejakowatz 43552a38012Sejakowatz 43652a38012Sejakowatz#------------------------------------------------------------------------------- 43752a38012Sejakowatz# General High-level OBOS target rules 43852a38012Sejakowatz#------------------------------------------------------------------------------- 43952a38012Sejakowatz 4405f281ed5Sejakowatzrule App 4415f281ed5Sejakowatz{ 44239a01fbbSshatty # App <name> : <sources> : <libraries> : <res> ; 443a6c008e1Sbeveloper SetupIncludes ; 4445f281ed5Sejakowatz SetupObjectsDir ; 44539a01fbbSshatty AddResources $(1) : $(4) ; 446007eb5f2SIngo Weinhold Main $(1) : $(2) ; 447007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_APPS_DIR) ; 448007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 449007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 450007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 4515f281ed5Sejakowatz} 4525f281ed5Sejakowatz 453f06de7f3SIngo Weinholdrule BinCommand 454f06de7f3SIngo Weinhold{ 45511fa3682SJérôme Duval # BinCommand <name> : <sources> : <libraries> : <res> ; 456a6c008e1Sbeveloper SetupIncludes ; 457f06de7f3SIngo Weinhold SetupObjectsDir ; 45811fa3682SJérôme Duval AddResources $(1) : $(4) ; 459f06de7f3SIngo Weinhold Main $(1) : $(2) ; 460f06de7f3SIngo Weinhold MakeLocate $(1) : $(OBOS_BIN_DIR) ; 461f06de7f3SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 462007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 463007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 464f06de7f3SIngo Weinhold} 465f06de7f3SIngo Weinhold 466f06de7f3SIngo Weinholdrule StdBinCommands 467f06de7f3SIngo Weinhold{ 46811fa3682SJérôme Duval # StdBinCommands <sources> : <libs> : <res> ; 469a6c008e1Sbeveloper SetupIncludes ; 470a6c008e1Sbeveloper SetupObjectsDir ; 471f06de7f3SIngo Weinhold local libs = $(2) ; 47211fa3682SJérôme Duval local ress = $(3) ; 4739342c27aSIngo Weinhold local source ; 474f06de7f3SIngo Weinhold for source in $(1) 475f06de7f3SIngo Weinhold { 476f06de7f3SIngo Weinhold local target = $(source:S=) ; 477a6c008e1Sbeveloper 47811fa3682SJérôme Duval BinCommand $(target) : $(source) : $(libs) : $(ress) ; 479f06de7f3SIngo Weinhold } 480f06de7f3SIngo Weinhold} 481f06de7f3SIngo Weinhold 48252a38012Sejakowatzrule Preference 48352a38012Sejakowatz{ 484007eb5f2SIngo Weinhold # Preference <name> : <sources> : <libraries> ; 485a6c008e1Sbeveloper SetupIncludes ; 48652a38012Sejakowatz SetupObjectsDir ; 487007eb5f2SIngo Weinhold Main $(1) : $(2) ; 488007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_PREFS_DIR) ; 489007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 490007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 491007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 49252a38012Sejakowatz} 49352a38012Sejakowatz 49452a38012Sejakowatzrule Server 49552a38012Sejakowatz{ 496007eb5f2SIngo Weinhold # Server <name> : <sources> : <libraries> ; 49752a38012Sejakowatz 498a6c008e1Sbeveloper SetupIncludes ; 49952a38012Sejakowatz SetupObjectsDir ; 500007eb5f2SIngo Weinhold Main $(1) : $(2) ; 501007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_SERVER_DIR) ; 502007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 503007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 504007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 50552a38012Sejakowatz} 50652a38012Sejakowatz 50752a38012Sejakowatz# test pseudo targets 50852a38012SejakowatzNOTFILE obostests ; 50952a38012SejakowatzNOTFILE r5tests ; 51052a38012Sejakowatz 511d1f6c38fSTyler Dauwalderrule CommonTestLib 512d1f6c38fSTyler Dauwalder{ 513c5ff4aa6STyler Dauwalder # CommonTestLib <target> : <sources> : <obos libraries> 5149285de51STyler Dauwalder # : <r5 libraries> : <test libraries> : <public headers>; 515d1f6c38fSTyler Dauwalder # Builds a unit test for both OBOS and R5 modules. 516d1f6c38fSTyler Dauwalder # <target> The name of the target. 517d1f6c38fSTyler Dauwalder # <sources> The list of sources. 518d1f6c38fSTyler Dauwalder # <obos libraries> A list of link libraries for the OBOS tests (as passed 519d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 520d1f6c38fSTyler Dauwalder # <r5 libraries> A list of link libraries for the R5 tests (as passed 521d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 5229285de51STyler Dauwalder # <test libraries> A list of link libraries for both OBOS tests and R5 tests 5239285de51STyler Dauwalder # that have a common name (i.e. specify libx.so and the OBOS tests will link 5249285de51STyler Dauwalder # to libx.so and the R5 tests will link to libx_r5.so). 525d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 526d1f6c38fSTyler Dauwalder # UsePublicHeaders). 527d1f6c38fSTyler Dauwalder 528c5ff4aa6STyler Dauwalder TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester lib ] : $(3) $(5) : $(6) ; 529c5ff4aa6STyler Dauwalder R5TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester_r5 lib ] : $(4) [ R5SharedLibraryNames $(5) ] ; 530d1f6c38fSTyler Dauwalder} 531d1f6c38fSTyler Dauwalder 532d1f6c38fSTyler Dauwalderrule TestLib 533d1f6c38fSTyler Dauwalder{ 534d1f6c38fSTyler Dauwalder # TestLib <target> : <sources> : <dest> : <libraries> : <public headers> 535d1f6c38fSTyler Dauwalder # Builds a unit test library for an OBOS module. 536d1f6c38fSTyler Dauwalder # <target> The name of the target. 537d1f6c38fSTyler Dauwalder # <sources> The list of sources. 538d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 539d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 540d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 541d1f6c38fSTyler Dauwalder # UsePublicHeaders). 542d1f6c38fSTyler Dauwalder 543d1f6c38fSTyler Dauwalder local target = $(1) ; 544d1f6c38fSTyler Dauwalder local sources = $(2) ; 545d1f6c38fSTyler Dauwalder local dest = $(3) ; 546d1f6c38fSTyler Dauwalder local libraries = $(4) ; 547d1f6c38fSTyler Dauwalder local headerDirs = $(5) ; 5489342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 549d1f6c38fSTyler Dauwalder 5509342c27aSIngo Weinhold # Our Main replacement. 5519342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 5529342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 553d1f6c38fSTyler Dauwalder 554d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 5550d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 5560d1cdd94SIngo Weinhold Depends obostests : $(target) ; 557d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 558d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 559d1f6c38fSTyler Dauwalder} 560d1f6c38fSTyler Dauwalder 561d1f6c38fSTyler Dauwalderrule R5TestLib 562d1f6c38fSTyler Dauwalder{ 563c5ff4aa6STyler Dauwalder # R5TestLib <target> : <sources> : <dest> : <libraries> 564d1f6c38fSTyler Dauwalder # Builds a unit test for an R5 module. "_r5" is appended to the object 565d1f6c38fSTyler Dauwalder # and the target name. 566d1f6c38fSTyler Dauwalder # <target> The name of the target. 567d1f6c38fSTyler Dauwalder # <sources> The list of sources. 568d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 569d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 570d1f6c38fSTyler Dauwalder 571d1f6c38fSTyler Dauwalder local target = $(1:B)_r5$(1:S) ; 572d1f6c38fSTyler Dauwalder local sources = $(2) ; 573c5ff4aa6STyler Dauwalder local dest = $(3) ; 574d1f6c38fSTyler Dauwalder local libraries = $(4) ; 575d1f6c38fSTyler Dauwalder local objects = [ R5ObjectNames $(sources) ] ; 576d1f6c38fSTyler Dauwalder 577d1f6c38fSTyler Dauwalder # Our Main replacement. 578d1f6c38fSTyler Dauwalder MainFromObjects $(target) : $(objects) ; 5799342c27aSIngo Weinhold TestObjects $(sources) : : true ; 580d1f6c38fSTyler Dauwalder 581d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 5820d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 5830d1cdd94SIngo Weinhold Depends r5tests : $(target) ; 584d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 585d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 586d1f6c38fSTyler Dauwalder} 587d1f6c38fSTyler Dauwalder 58852a38012Sejakowatzrule CommonUnitTest 58952a38012Sejakowatz{ 59052a38012Sejakowatz # CommonUnitTest <target> : <sources> : <dest> : <obos libraries> 59152a38012Sejakowatz # : <r5 libraries> : <public headers>; 59252a38012Sejakowatz # Builds a unit test for both OBOS and R5 modules. 59352a38012Sejakowatz # <target> The name of the target. 59452a38012Sejakowatz # <sources> The list of sources. 59552a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 59652a38012Sejakowatz # <obos libraries> A list of link libraries for the OBOS tests (as passed 59752a38012Sejakowatz # to LinkSharedOSLibs). 59852a38012Sejakowatz # <r5 libraries> A list of link libraries for the R5 tests (as passed 59952a38012Sejakowatz # to LinkSharedOSLibs). 60052a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 60152a38012Sejakowatz # UsePublicHeaders). 60252a38012Sejakowatz 60352a38012Sejakowatz UnitTest $(1) : $(2) : $(3) : $(4) : $(6) ; 60452a38012Sejakowatz R5UnitTest $(1) : $(2) : $(3) : $(5) ; 60552a38012Sejakowatz} 60652a38012Sejakowatz 60752a38012Sejakowatzrule UnitTest 60852a38012Sejakowatz{ 60952a38012Sejakowatz # UnitTest <target> : <sources> : <dest> : <libraries> : <public headers> 61052a38012Sejakowatz # Builds a unit test for an OBOS module. 61152a38012Sejakowatz # <target> The name of the target. 61252a38012Sejakowatz # <sources> The list of sources. 61352a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 61452a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 61552a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 61652a38012Sejakowatz # UsePublicHeaders). 61752a38012Sejakowatz 61852a38012Sejakowatz local target = $(1) ; 61952a38012Sejakowatz local sources = $(2) ; 62052a38012Sejakowatz local dest = $(3) ; 62152a38012Sejakowatz local libraries = $(4) ; 62252a38012Sejakowatz local headerDirs = $(5) ; 6239342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 62452a38012Sejakowatz 6259342c27aSIngo Weinhold # Our Main replacement. 6269342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 6279342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 6283b9eae39SIngo Weinhold 62952a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 6309eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 6319eea4522SIngo Weinhold Depends obostests : $(target) ; 63252a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 63352a38012Sejakowatz} 63452a38012Sejakowatz 63552a38012Sejakowatzrule R5UnitTest 63652a38012Sejakowatz{ 63752a38012Sejakowatz # R5UnitTest <target> : <sources> : <dest> : <libraries> 63852a38012Sejakowatz # Builds a unit test for an R5 module. "_r5" is appended to the object 63952a38012Sejakowatz # and the target name. 64052a38012Sejakowatz # <target> The name of the target. 64152a38012Sejakowatz # <sources> The list of sources. 64252a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 64352a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 64452a38012Sejakowatz 64552a38012Sejakowatz local target = $(1)_r5 ; 64652a38012Sejakowatz local sources = $(2) ; 64752a38012Sejakowatz local dest = $(3) ; 64852a38012Sejakowatz local libraries = $(4) ; 64952a38012Sejakowatz local objects = [ R5ObjectNames $(sources) ] ; 65052a38012Sejakowatz 65152a38012Sejakowatz # Our Main replacement. 65252a38012Sejakowatz MainFromObjects $(target) : $(objects) ; 6539342c27aSIngo Weinhold TestObjects $(sources) : : true ; 65452a38012Sejakowatz 65552a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 6569eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 6579eea4522SIngo Weinhold Depends r5tests : $(target) ; 65852a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 65952a38012Sejakowatz} 66052a38012Sejakowatz 66152a38012Sejakowatzrule R5ObjectNames 66252a38012Sejakowatz{ 66352a38012Sejakowatz # R5ObjectNames <sources> ; 66452a38012Sejakowatz # Returns a list of gristed object names given a list of source file names. 66552a38012Sejakowatz # Moreover each object names gets "_r5" inserted before the object suffix. 66652a38012Sejakowatz local objects = $(1:S=)_r5 ; 66752a38012Sejakowatz return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ; 66852a38012Sejakowatz} 66952a38012Sejakowatz 6709342c27aSIngo Weinholdrule R5Objects 6719342c27aSIngo Weinhold{ 6729342c27aSIngo Weinhold # R5Objects <sources> 673dd9f8062SIngo Weinhold # Similar to Objects, but appends "_r5" to the object file names and 674dd9f8062SIngo Weinhold # removes `-nostdinc' from the CC and C++ flags to enable system headers. 6759342c27aSIngo Weinhold # <sources> The source files. 6769342c27aSIngo Weinhold 677dd9f8062SIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 678dd9f8062SIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 679dd9f8062SIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 680dd9f8062SIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 681dd9f8062SIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 682dd9f8062SIngo Weinhold 6839342c27aSIngo Weinhold local sources = $(1) ; 6849342c27aSIngo Weinhold local source ; 6859342c27aSIngo Weinhold for source in [ FGristFiles $(sources) ] 6869342c27aSIngo Weinhold { 6879342c27aSIngo Weinhold local object = [ R5ObjectNames $(source) ] ; 6889342c27aSIngo Weinhold Object $(object) : $(source) ; 6899342c27aSIngo Weinhold LocalDepends obj : $(object) ; 6909342c27aSIngo Weinhold } 691dd9f8062SIngo Weinhold 692dd9f8062SIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 693dd9f8062SIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 694dd9f8062SIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 6959342c27aSIngo Weinhold} 6969342c27aSIngo Weinhold 6979342c27aSIngo Weinholdrule TestObjects 6989342c27aSIngo Weinhold{ 6999342c27aSIngo Weinhold # TestLib <sources> : <public headers> : <r5> 7009342c27aSIngo Weinhold # Compiles objects for tests. 7019342c27aSIngo Weinhold # <sources> The list of sources. 7029342c27aSIngo Weinhold # <public headers> A list of public header dirs (as passed to 7039342c27aSIngo Weinhold # UsePublicHeaders). 7049342c27aSIngo Weinhold # <r5> If set, "_r5" is appended to the object file names and 7059342c27aSIngo Weinhold # <public headers> is ignored. Furthermore the pre-processor macro 7069342c27aSIngo Weinhold # TEST_R5 is defined, TEST_OBOS otherwise. 7079342c27aSIngo Weinhold 7089342c27aSIngo Weinhold local sources = $(1) ; 7099342c27aSIngo Weinhold local headerDirs = $(2) ; 7109342c27aSIngo Weinhold local r5 = $(3) ; 7119342c27aSIngo Weinhold local objects ; 7129342c27aSIngo Weinhold 7139342c27aSIngo Weinhold # Turn optimization off. 71496d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7159342c27aSIngo Weinhold local optim = $(OPTIM) ; 7169342c27aSIngo Weinhold OPTIM = ; 71796d27465SIngo Weinhold } 7189342c27aSIngo Weinhold 7199342c27aSIngo Weinhold SetupObjectsDir ; 7209342c27aSIngo Weinhold 7219342c27aSIngo Weinhold # compile 7229342c27aSIngo Weinhold if $(r5) { 723dd9f8062SIngo Weinhold SetupR5Includes ; 7249342c27aSIngo Weinhold objects = [ R5ObjectNames $(sources) ] ; 7259342c27aSIngo Weinhold R5Objects $(sources) ; 7269342c27aSIngo Weinhold } else { 727dd9f8062SIngo Weinhold SetupIncludes ; 7289342c27aSIngo Weinhold objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 7299342c27aSIngo Weinhold Objects $(sources) ; 7309342c27aSIngo Weinhold } 7319342c27aSIngo Weinhold 7329342c27aSIngo Weinhold # set headers/defines 7339b60a208SIngo Weinhold UseCppUnitObjectHeaders $(sources) : $(objects) ; 7349342c27aSIngo Weinhold if $(r5) { 735728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_R5 ; 7369342c27aSIngo Weinhold } else { 7379b60a208SIngo Weinhold UsePublicObjectHeaders $(sources) : $(headerDirs) : $(objects) ; 738728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_OBOS ; 7399342c27aSIngo Weinhold } 7409342c27aSIngo Weinhold 74196d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7429342c27aSIngo Weinhold # Turn debugging on. That is usually desired for test code. 7433844cf70SIngo Weinhold ObjectCcFlags $(objects) : $(DEBUG_FLAGS) ; 7443844cf70SIngo Weinhold ObjectC++Flags $(objects) : $(DEBUG_FLAGS) ; 7459342c27aSIngo Weinhold 7469342c27aSIngo Weinhold # Turn optimization on again. 7479342c27aSIngo Weinhold OPTIM = $(optim) ; 7489342c27aSIngo Weinhold } 74996d27465SIngo Weinhold} 7509342c27aSIngo Weinhold 7519285de51STyler Dauwalderrule R5SharedLibraryNames 7529285de51STyler Dauwalder{ 7539285de51STyler Dauwalder # R5SharedLibraryNames <sources> ; 7549285de51STyler Dauwalder # Returns a list of shared library names given a list of file names. NO 7559285de51STyler Dauwalder # GRISTING IS PERFORMED :-) However, each library names gets "_r5" inserted 7569285de51STyler Dauwalder # before the shared lib suffix. 7579285de51STyler Dauwalder return $(1:S=)_r5.so ; 7589285de51STyler Dauwalder} 7599285de51STyler Dauwalder 7609fc6b2e1SIngo Weinholdrule SimpleTest 7619fc6b2e1SIngo Weinhold{ 7629fc6b2e1SIngo Weinhold # UnitTest <target> : <sources> : <libraries> 7639fc6b2e1SIngo Weinhold # Builds a unit test for an OBOS module. 7649fc6b2e1SIngo Weinhold # <target> The name of the target. 7659fc6b2e1SIngo Weinhold # <sources> The list of sources. 7669fc6b2e1SIngo Weinhold # <dest> The directory for the target (as passed to FDirName). 7679fc6b2e1SIngo Weinhold # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 7689fc6b2e1SIngo Weinhold # <public headers> A list of public header dirs (as passed to 7699fc6b2e1SIngo Weinhold # UsePublicHeaders). 7709fc6b2e1SIngo Weinhold 7719fc6b2e1SIngo Weinhold local target = $(1) ; 7729fc6b2e1SIngo Weinhold local sources = $(2) ; 7739fc6b2e1SIngo Weinhold local libraries = $(3) ; 7749fc6b2e1SIngo Weinhold local relPath = [ FRelPath src tests : $(SUBDIR_TOKENS) ] ; 7759fc6b2e1SIngo Weinhold 7769fc6b2e1SIngo Weinhold # Turn optimization off. 77796d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7789fc6b2e1SIngo Weinhold local optim = $(OPTIM) ; 7799fc6b2e1SIngo Weinhold OPTIM = ; 78096d27465SIngo Weinhold } 7819fc6b2e1SIngo Weinhold 782a6c008e1Sbeveloper SetupIncludes ; 7839fc6b2e1SIngo Weinhold SetupObjectsDir ; 7849fc6b2e1SIngo Weinhold MakeLocateObjects $(sources) ; 7859fc6b2e1SIngo Weinhold Main $(target) : $(sources) ; 7869fc6b2e1SIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 7879eea4522SIngo Weinhold Depends obostests : $(target) ; 7889fc6b2e1SIngo Weinhold LinkSharedOSLibs $(target) : $(libraries) ; 789728b5725SIngo Weinhold ObjectsDefines $(sources) : TEST_OBOS ; 79096d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7919fc6b2e1SIngo Weinhold # Turn debugging on. That is usually desired for test code. 7923844cf70SIngo Weinhold ObjectCcFlags $(sources) : $(DEBUG_FLAGS) ; 7933844cf70SIngo Weinhold ObjectC++Flags $(sources) : $(DEBUG_FLAGS) ; 7949fc6b2e1SIngo Weinhold 7959fc6b2e1SIngo Weinhold # Turn optimization on again. 7969fc6b2e1SIngo Weinhold OPTIM = $(optim) ; 7979fc6b2e1SIngo Weinhold } 79896d27465SIngo Weinhold} 7999fc6b2e1SIngo Weinhold 80052a38012Sejakowatzrule Addon 80152a38012Sejakowatz{ 80283b3b0dfSIngo Weinhold # Addon <name> : <relpath> : <sources> : <is executable> : <libraries> ; 8037a384fdeSIngo Weinhold # <name>: Name of the add-on. 8047a384fdeSIngo Weinhold # <relpath>: Path where the add-on shall live relative to the add-on dir. 8057a384fdeSIngo Weinhold # <sources>: Source files. 80683b3b0dfSIngo Weinhold # <is executable>: true, if the target shall be executable as well. 80783b3b0dfSIngo Weinhold # <libraries>: Libraries to be linked against. 8087a384fdeSIngo Weinhold 8097a384fdeSIngo Weinhold local isExecutable = $(4) ; 81052a38012Sejakowatz 811a6c008e1Sbeveloper SetupIncludes ; 81252a38012Sejakowatz SetupObjectsDir ; 81352a38012Sejakowatz Main $(1) : $(3) ; 81452a38012Sejakowatz 81552a38012Sejakowatz # Create output dir path for addon 81652a38012Sejakowatz local targetdir; 81752a38012Sejakowatz targetdir = [ FDirName $(OBOS_ADDON_DIR) $(2) ] ; 81852a38012Sejakowatz 81952a38012Sejakowatz MakeLocate $(1) : $(targetdir) ; 8207a384fdeSIngo Weinhold 8217a384fdeSIngo Weinhold local linkFlags = -Xlinker -soname=\"$(1)\" ; 8227a384fdeSIngo Weinhold if $(isExecutable) != true { 8237a384fdeSIngo Weinhold linkFlags = -nostart $(linkFlags) ; 8247a384fdeSIngo Weinhold } 8257a384fdeSIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] $(linkFlags) ; 82683b3b0dfSIngo Weinhold LinkSharedOSLibs $(1) : $(5) ; 827af28904fSIngo Weinhold} 828af28904fSIngo Weinhold 82958efc9d8SIngo Weinholdrule R5KernelAddon 830af28904fSIngo Weinhold{ 831600203b1SAxel Dörfler # R5KernelAddon <name> : <relpath> : <sources> : <static-libraries> ; 832af28904fSIngo Weinhold 833af28904fSIngo Weinhold local sources = $(3) ; 834af28904fSIngo Weinhold 835af28904fSIngo Weinhold Addon $(1) : $(2) : $(3) ; 836*979afc6fSAxel Dörfler ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -fno-pic ; 837*979afc6fSAxel Dörfler ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -fno-pic -fno-exceptions ; 8389eea4522SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; 839600203b1SAxel Dörfler LinkSharedOSLibs $(1) : $(4) /boot/develop/lib/x86/_KERNEL_ ; 84052a38012Sejakowatz} 84152a38012Sejakowatz 8424fb5add0SMatthew Wilberrule Translator 8434fb5add0SMatthew Wilber{ 844007eb5f2SIngo Weinhold # Translator <name> : <sources> : <libraries> ; 845a6c008e1Sbeveloper SetupIncludes ; 8464fb5add0SMatthew Wilber SetupObjectsDir ; 8474fb5add0SMatthew Wilber Main $(1) : $(2) ; 848007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 8494fb5add0SMatthew Wilber 8504fb5add0SMatthew Wilber # Create output dir path for translator 8514fb5add0SMatthew Wilber local targetdir; 852d5b07cf2Sshatty targetdir = [ FDirName $(OBOS_ADDON_DIR) Translators ] ; 8534fb5add0SMatthew Wilber MakeLocate $(1) : $(targetdir) ; 8544fb5add0SMatthew Wilber} 8554fb5add0SMatthew Wilber 856c4071913SMatthew Wilberrule ScreenSaver 857c4071913SMatthew Wilber{ 858c4071913SMatthew Wilber # ScreenSaver <name> : <sources> : <libraries> ; 859c4071913SMatthew Wilber Addon $(1) : screen_savers : $(2) : false : $(3) ; 860c4071913SMatthew Wilber} 861c4071913SMatthew Wilber 86252a38012Sejakowatzrule MakeLocateObjects 86352a38012Sejakowatz{ 86421df5945SIngo Weinhold # MakeLocateObjects <sources_or_objects> ; 86552a38012Sejakowatz 86621df5945SIngo Weinhold local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 86752a38012Sejakowatz 86852a38012Sejakowatz for o in $(_objs) 86952a38012Sejakowatz { 87052a38012Sejakowatz local dir = $(o:D) ; 87152a38012Sejakowatz if $(dir) { 87252a38012Sejakowatz MakeLocate $(o) : [ FDirName $(LOCATE_TARGET) $(dir) ] ; 87352a38012Sejakowatz } else { 87452a38012Sejakowatz MakeLocate $(o) : $(LOCATE_TARGET) ; 87552a38012Sejakowatz } 87652a38012Sejakowatz } 87752a38012Sejakowatz} 87852a38012Sejakowatz 87952a38012Sejakowatzrule StaticLibrary 88052a38012Sejakowatz{ 881e9230d05SIngo Weinhold # StaticLibrary <name> : <sources> [ : <target dir> ] ; 882e9230d05SIngo Weinhold # Creates a static library from sources. 883e9230d05SIngo Weinhold # <name>: Basename of the library, without leading "lib" and trailing ".a". 88460c9c40fSIngo Weinhold # Grist is allowed -- it will be re-prepended after constructing 88560c9c40fSIngo Weinhold # the complete library name. 886e9230d05SIngo Weinhold # <source>: List of source files. 887e9230d05SIngo Weinhold # <target dir>: Directory into which the library shall be placed. Defaults 88860c9c40fSIngo Weinhold # to the objects directory for this subdir. If 88960c9c40fSIngo Weinhold # STATIC_LIBRARY_DIR is supplied (the literal string) 89060c9c40fSIngo Weinhold # the standard directory for static libs is used, otherwise 89160c9c40fSIngo Weinhold # the parameter is interpreted as directory path. 892e9230d05SIngo Weinhold # 89360c9c40fSIngo Weinhold local lib = lib$(1:B)$(SUFLIB) ; 89460c9c40fSIngo Weinhold lib = $(lib:G=$(1:G)) ; 895a6c008e1Sbeveloper SetupIncludes ; 89652a38012Sejakowatz SetupObjectsDir ; 89752a38012Sejakowatz MakeLocateObjects $(2) ; 898e9230d05SIngo Weinhold Library $(lib) : $(2) ; 899e9230d05SIngo Weinhold local targetDir = $(3) ; 90060c9c40fSIngo Weinhold if $(targetDir) { 90160c9c40fSIngo Weinhold if $(targetDir) = STATIC_LIBRARY_DIR { 902e9230d05SIngo Weinhold targetDir = $(OBOS_STLIB_DIR) ; 903e9230d05SIngo Weinhold } 904e9230d05SIngo Weinhold MakeLocate $(lib) : $(targetDir) ; 90560c9c40fSIngo Weinhold } else { 90660c9c40fSIngo Weinhold # nothing to do, since the Library rule already located the library 90760c9c40fSIngo Weinhold # in $(LOCATE_TARGET) 90860c9c40fSIngo Weinhold } 909f1e077f8SIngo Weinhold 910f1e077f8SIngo Weinhold # If KEEPOBJS is set, Library doesn't make the library depend on 911f1e077f8SIngo Weinhold # `lib'. 912f1e077f8SIngo Weinhold if $(KEEPOBJS) { 913f1e077f8SIngo Weinhold LocalDepends lib : $(lib) ; 914f1e077f8SIngo Weinhold } 91552a38012Sejakowatz} 91652a38012Sejakowatz 917dbf96817SIngo Weinholdrule R5KernelStaticLibrary 918dbf96817SIngo Weinhold{ 919dbf96817SIngo Weinhold # R5KernelStaticLibrary <name> : <sources> ; 920dbf96817SIngo Weinhold 921f1e077f8SIngo Weinhold local lib = lib$(1)$(SUFLIB) ; 922dbf96817SIngo Weinhold local sources = $(2) ; 923dbf96817SIngo Weinhold 924dbf96817SIngo Weinhold SetupIncludes ; 925dbf96817SIngo Weinhold SetupObjectsDir ; 926dbf96817SIngo Weinhold MakeLocateObjects $(sources) ; 927dbf96817SIngo Weinhold Library $(lib) : $(sources) ; 928*979afc6fSAxel Dörfler ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -fno-pic ; 929*979afc6fSAxel Dörfler ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -fno-pic -fno-exceptions ; 930dbf96817SIngo Weinhold} 931dbf96817SIngo Weinhold 93280721244SAxel Dörflerrule MergeObjectFromObjects 93380721244SAxel Dörfler{ 9342fbd7065SIngo Weinhold # MergeObjectFromObjects <name> : <objects> : <other objects> ; 9352fbd7065SIngo Weinhold # Merges object files to an object file. 9362fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 9372fbd7065SIngo Weinhold # <objects>: Object files to be merged. Grist will be added. 9382fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 9392fbd7065SIngo Weinhold # will be added. 9402fbd7065SIngo Weinhold # 941c8aa252aSIngo Weinhold local objects = [ FGristFiles $(2) ] ; 94280721244SAxel Dörfler MakeLocate $(1) : $(LOCATE_TARGET) ; 943c8aa252aSIngo Weinhold Depends $(1) : $(objects) ; 9442fbd7065SIngo Weinhold Depends $(1) : $(3) ; 94580721244SAxel Dörfler LINK on $(1) = ld ; 9462fbd7065SIngo Weinhold MergeObjectFromObjects1 $(1) : $(objects) $(3) ; 94780721244SAxel Dörfler} 94880721244SAxel Dörfler 94954b7cbe1SIngo Weinholdactions MergeObjectFromObjects1 95080721244SAxel Dörfler{ 95180721244SAxel Dörfler $(LINK) -r $(2) -o $(1) ; 95280721244SAxel Dörfler} 95380721244SAxel Dörfler 95480721244SAxel Dörflerrule MergeObject 95580721244SAxel Dörfler{ 9562fbd7065SIngo Weinhold # MergeObject <name> : <sources> : <other objects> ; 9572fbd7065SIngo Weinhold # Compiles source files and merges the object files to an object file. 9582fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 9592fbd7065SIngo Weinhold # <sources>: Sources to be compiled. Grist will be added. 9602fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 9612fbd7065SIngo Weinhold # will be added. 9622fbd7065SIngo Weinhold # 96380721244SAxel Dörfler SetupIncludes ; 96480721244SAxel Dörfler SetupObjectsDir ; 96580721244SAxel Dörfler MakeLocateObjects $(2) ; 96680721244SAxel Dörfler Objects $(2) ; 9672fbd7065SIngo Weinhold MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; 96880721244SAxel Dörfler} 96980721244SAxel Dörfler 97021df5945SIngo Weinholdrule SharedLibraryFromObjects 97152a38012Sejakowatz{ 9728d3308d9SIngo Weinhold # SharedLibraryFromObjects <name> : <objects> : <libraries> ; 97360c9c40fSIngo Weinhold local _lib = lib$(1:B).so ; 97460c9c40fSIngo Weinhold _lib = $(_lib:G=$(1:G)) ; 97521df5945SIngo Weinhold MainFromObjects $(_lib) : $(2) ; 97652a38012Sejakowatz MakeLocate $(_lib) : $(OBOS_SHLIB_DIR) ; 9779eea4522SIngo Weinhold LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ] 9789eea4522SIngo Weinhold -nostart -Xlinker -soname=\"$(_lib)\" ; 9798d3308d9SIngo Weinhold LinkSharedOSLibs $(_lib) : $(3) ; 98052a38012Sejakowatz} 98152a38012Sejakowatz 98221df5945SIngo Weinholdrule SharedLibrary 98321df5945SIngo Weinhold{ 9848d3308d9SIngo Weinhold # SharedLibrary <name> : <sources> : <libraries> ; 985a6c008e1Sbeveloper SetupIncludes ; 98621df5945SIngo Weinhold SetupObjectsDir ; 98721df5945SIngo Weinhold MakeLocateObjects $(2) ; 98821df5945SIngo Weinhold Objects $(2) ; 9898d3308d9SIngo Weinhold SharedLibraryFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; 99021df5945SIngo Weinhold} 99121df5945SIngo Weinhold 99252a38012Sejakowatzrule LinkSharedOSLibs 99352a38012Sejakowatz{ 99452a38012Sejakowatz # LinkSharedOSLibs <name> : <libs> ; 99552a38012Sejakowatz # Valid elements for <libs> are e.g. "be" or "libopenbeos.so" or 9964236d490SIngo Weinhold # "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy 9974236d490SIngo Weinhold # has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the 9984236d490SIngo Weinhold # file will be bound!), otherwise it is prefixed "-l" and added to 999a8cd0719SIngo Weinhold # LINKLIBS. If you want to specify a target that isn't a library and 1000a8cd0719SIngo Weinhold # also has neither grist nor a dirname, you can prepend "<nogrist>" as 1001a8cd0719SIngo Weinhold # grist; it will be stripped by this rule. 100252a38012Sejakowatz 100352a38012Sejakowatz for i in $(>) 100452a38012Sejakowatz { 10054236d490SIngo Weinhold local isfile = ; 10064236d490SIngo Weinhold if $(i:D) || $(i:G) { 10074236d490SIngo Weinhold isfile = true ; 1008a8cd0719SIngo Weinhold if $(i:G) = <nogrist> { 1009a8cd0719SIngo Weinhold i = $(i:G=) ; 1010a8cd0719SIngo Weinhold } 10114236d490SIngo Weinhold } else { 101252a38012Sejakowatz switch $(i:B) 101352a38012Sejakowatz { 1014007eb5f2SIngo Weinhold # XXX: _APP_ and _KERNEL_ should not be needed for ELF. 1015f7901247SPhilippe Houdoin case _APP_ : isfile = true ; 1016f7901247SPhilippe Houdoin case _KERNEL_ : isfile = true ; 10174236d490SIngo Weinhold case lib* : isfile = true ; 10184236d490SIngo Weinhold case * : isfile = ; 10194236d490SIngo Weinhold } 1020b8baf385SIngo Weinhold if ! $(isfile) && ( $(i:S) = .so || $(i:S) = .a ) { 1021b8baf385SIngo Weinhold isfile = true ; 1022b8baf385SIngo Weinhold } 10234236d490SIngo Weinhold } 10244236d490SIngo Weinhold if $(isfile) { 10259eea4522SIngo Weinhold NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(i) ; 10269eea4522SIngo Weinhold Depends $(1) : $(i) ; 10274236d490SIngo Weinhold } else { 10289eea4522SIngo Weinhold LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] -l$(i) ; 102952a38012Sejakowatz } 103052a38012Sejakowatz } 103152a38012Sejakowatz} 103252a38012Sejakowatz 103352a38012Sejakowatzrule AddResources 103452a38012Sejakowatz{ 103552a38012Sejakowatz # AddResources <name> : <resourcefiles> ; 103652a38012Sejakowatz 10378d3308d9SIngo Weinhold local resfiles = [ FGristFiles $(2) ] ; 10388d3308d9SIngo Weinhold SEARCH on $(resfiles) += $(SEARCH_SOURCE) ; 10398d3308d9SIngo Weinhold 10408d3308d9SIngo Weinhold for file in $(resfiles) { 10418d3308d9SIngo Weinhold if $(file:S) = .rdef { 10428d3308d9SIngo Weinhold local rdef = $(file) ; 10438d3308d9SIngo Weinhold file = $(rdef:S=.rsrc) ; 10448d3308d9SIngo Weinhold ResComp $(file) : $(rdef) ; 10458d3308d9SIngo Weinhold } 10468d3308d9SIngo Weinhold RESFILES on $(1) += $(file) ; 10478d3308d9SIngo Weinhold } 10488d3308d9SIngo Weinhold} 10498d3308d9SIngo Weinhold 10503844cf70SIngo Weinholdif $(OS) = BEOS { 10513844cf70SIngo Weinhold 10528d3308d9SIngo Weinholdrule ResComp 10538d3308d9SIngo Weinhold{ 10548d3308d9SIngo Weinhold # ResComp <resource file> : <rdef file> ; 10558d3308d9SIngo Weinhold # 10568d3308d9SIngo Weinhold # <resource file> and <rdef file> must be gristed. 10578d3308d9SIngo Weinhold 10588d3308d9SIngo Weinhold SetupObjectsDir ; 10598d3308d9SIngo Weinhold 10609fc6b2e1SIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 10618d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_TARGET) ; 10628d3308d9SIngo Weinhold Depends $(1) : $(2) rc ; 10638d3308d9SIngo Weinhold LocalClean clean : $(1) ; 10648d3308d9SIngo Weinhold ResComp1 $(1) : rc $(2) ; 10658d3308d9SIngo Weinhold} 10668d3308d9SIngo Weinhold 10673844cf70SIngo Weinhold} else { 10683844cf70SIngo Weinhold 10693844cf70SIngo Weinholdrule ResComp 10703844cf70SIngo Weinhold{ 10713844cf70SIngo Weinhold} 10723844cf70SIngo Weinhold 10733844cf70SIngo Weinhold} 10743844cf70SIngo Weinhold 10758d3308d9SIngo Weinholdactions ResComp1 10768d3308d9SIngo Weinhold{ 10776af76074SIngo Weinhold $(2[1]) -o $(1) $(2[2-]) 107852a38012Sejakowatz} 107952a38012Sejakowatz 1080728b5725SIngo Weinholdrule ObjectsDefines 1081728b5725SIngo Weinhold{ 1082728b5725SIngo Weinhold # Like ObjectDefines, but allows multiple files to be supplied 1083728b5725SIngo Weinhold local file ; 1084728b5725SIngo Weinhold for file in $(1) { 1085728b5725SIngo Weinhold ObjectDefines $(file) : $(2) ; 1086728b5725SIngo Weinhold } 1087728b5725SIngo Weinhold} 1088728b5725SIngo Weinhold 10899b60a208SIngo Weinholdrule SourceHdrs 10909b60a208SIngo Weinhold{ 10919b60a208SIngo Weinhold # SourceHdrs <sources> : <headers> [ : <gristed objects> ] ; 10929b60a208SIngo Weinhold # 10939b60a208SIngo Weinhold # Is a wrapper for ObjectHdrs, that passes <sources> and <headers> or, 10949b60a208SIngo Weinhold # if supplied <objects> and <headers>, and also adjusts HDRSEARCH (not 10959b60a208SIngo Weinhold # done by ObjectHdrs). 10969b60a208SIngo Weinhold 10979b60a208SIngo Weinhold local sources = [ FGristFiles $(1) ] ; 10989b60a208SIngo Weinhold local headers = $(2) ; 10999b60a208SIngo Weinhold local objects = $(3) ; 11009b60a208SIngo Weinhold 1101728b5725SIngo Weinhold local file ; 11029b60a208SIngo Weinhold if $(objects) { 1103728b5725SIngo Weinhold for file in $(objects) { 1104728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 1105c0e501e0SIngo Weinhold # also reformat the assembler headers 1106c0e501e0SIngo Weinhold ASHDRS on $(file) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) 1107c0e501e0SIngo Weinhold [ on $(file) return $(HDRS) ] ] ; 1108728b5725SIngo Weinhold } 11099b60a208SIngo Weinhold } else { 1110081debe8SIngo Weinhold for file in $(sources:S=$(SUFOBJ)) { 1111728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 1112c0e501e0SIngo Weinhold # also reformat the assembler headers 1113c0e501e0SIngo Weinhold ASHDRS on $(file) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) 1114c0e501e0SIngo Weinhold [ on $(file) return $(HDRS) ] ] ; 1115728b5725SIngo Weinhold } 11169b60a208SIngo Weinhold } 11179b60a208SIngo Weinhold 11189b60a208SIngo Weinhold # Also add the header search dirs to HDRSEARCH. Note, that these dirs 11199b60a208SIngo Weinhold # will be listed after the STDHDRS (if any), but that's better than not 11209b60a208SIngo Weinhold # being listed at all. 11219b60a208SIngo Weinhold HDRSEARCH on $(sources) += $(headers) ; 11229b60a208SIngo Weinhold} 11239b60a208SIngo Weinhold 11247d7f280eSIngo Weinholdrule PublicHeaders 112552a38012Sejakowatz{ 11267d7f280eSIngo Weinhold # PublicHeaders <group list> 112752a38012Sejakowatz # 11287d7f280eSIngo Weinhold # Returns the directory names for the public header dirs identified by 11297d7f280eSIngo Weinhold # <group list>. 113052a38012Sejakowatz 113152a38012Sejakowatz local list = $(1) ; 1132b005dbe3SAxel Dörfler local dirs = [ FDirName $(OBOS_TOP) headers os ] ; 1133b005dbe3SAxel Dörfler 113452a38012Sejakowatz for i in $(list) { 11357d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers os $(i) ] ; 11367d7f280eSIngo Weinhold } 11377d7f280eSIngo Weinhold return $(dirs) ; 113852a38012Sejakowatz} 113952a38012Sejakowatz 11407d7f280eSIngo Weinholdrule PrivateHeaders 11417d7f280eSIngo Weinhold{ 11427d7f280eSIngo Weinhold # PrivateHeaders <group list> 11437d7f280eSIngo Weinhold # 11447d7f280eSIngo Weinhold # Returns the directory names for the private header dirs identified by 11457d7f280eSIngo Weinhold # <group list>. 11467d7f280eSIngo Weinhold 11477d7f280eSIngo Weinhold local list = $(1) ; 11487d7f280eSIngo Weinhold local dirs ; 11497d7f280eSIngo Weinhold for i in $(list) { 11507d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers private $(i) ] ; 11517d7f280eSIngo Weinhold } 11527d7f280eSIngo Weinhold return $(dirs) ; 11537d7f280eSIngo Weinhold} 11547d7f280eSIngo Weinhold 11550f434a0aSDarkWyrmrule LibraryHeaders 11560f434a0aSDarkWyrm{ 11570f434a0aSDarkWyrm # LibraryHeaders <group list> 11580f434a0aSDarkWyrm # 11590f434a0aSDarkWyrm # Returns the directory names for the library header dirs identified by 11600f434a0aSDarkWyrm # <group list>. 11610f434a0aSDarkWyrm 11620f434a0aSDarkWyrm local list = $(1) ; 11630f434a0aSDarkWyrm local dirs ; 11640f434a0aSDarkWyrm for i in $(list) { 11650f434a0aSDarkWyrm dirs += [ FDirName $(OBOS_TOP) headers libs $(i) ] ; 11660f434a0aSDarkWyrm } 11670f434a0aSDarkWyrm return $(dirs) ; 11680f434a0aSDarkWyrm} 11690f434a0aSDarkWyrm 11707d7f280eSIngo Weinholdrule ArchHeaders 11717d7f280eSIngo Weinhold{ 11727d7f280eSIngo Weinhold # usage: ArchHeaders <arch> ; 11737d7f280eSIngo Weinhold # 11747d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 11757d7f280eSIngo Weinhold 11767d7f280eSIngo Weinhold return [ FDirName $(OBOS_TOP) headers private kernel arch $(1) ] ; 11777d7f280eSIngo Weinhold} 11787d7f280eSIngo Weinhold 11797d7f280eSIngo Weinholdrule UsePublicHeaders 11807d7f280eSIngo Weinhold{ 1181966528dcSIngo Weinhold # UsePublicHeaders <group list> ; 1182966528dcSIngo Weinhold # 1183966528dcSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 1184966528dcSIngo Weinhold # dirs of the subdirectory. 1185966528dcSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the 1186966528dcSIngo Weinhold # objects. 1187966528dcSIngo Weinhold 1188966528dcSIngo Weinhold UseHeaders [ PublicHeaders $(1) ] ; 11897d7f280eSIngo Weinhold} 11907d7f280eSIngo Weinhold 11917d7f280eSIngo Weinholdrule UsePublicObjectHeaders 11927d7f280eSIngo Weinhold{ 11939b60a208SIngo Weinhold # UsePublicObjectHeaders <sources> : <group list> [ : <objects> ] ; 11947d7f280eSIngo Weinhold # 11957d7f280eSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 11969b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 11979b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 11987d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 11997d7f280eSIngo Weinhold 12009b60a208SIngo Weinhold SourceHdrs $(1) : [ PublicHeaders $(2) ] : $(3) ; 120152a38012Sejakowatz} 120252a38012Sejakowatz 120352a38012Sejakowatzrule UsePrivateHeaders 120452a38012Sejakowatz{ 12057d7f280eSIngo Weinhold # UsePrivateHeaders <group list> ; 120652a38012Sejakowatz # 120752a38012Sejakowatz # Adds the private C header dirs given by <group list> to the header search 12087d7f280eSIngo Weinhold # dirs of the subdirectory. 12097d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 121052a38012Sejakowatz 12117d7f280eSIngo Weinhold UseHeaders [ PrivateHeaders $(1) ] ; 121252a38012Sejakowatz} 121352a38012Sejakowatz 12147d7f280eSIngo Weinholdrule UsePrivateObjectHeaders 12157d7f280eSIngo Weinhold{ 12169b60a208SIngo Weinhold # UsePrivateObjectHeaders <sources> : <group list> [ : <objects> ] ; 12177d7f280eSIngo Weinhold # 12187d7f280eSIngo Weinhold # Adds the private C header dirs given by <group list> to the header search 12199b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 12209b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 12217d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 12227d7f280eSIngo Weinhold 12239b60a208SIngo Weinhold SourceHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; 122452a38012Sejakowatz} 122552a38012Sejakowatz 122652a38012Sejakowatzrule UseHeaders 122752a38012Sejakowatz{ 12287d7f280eSIngo Weinhold # UseHeaders <headers> ; 122952a38012Sejakowatz # 123052a38012Sejakowatz # Adds the C header dirs <headers> to the header search 12317d7f280eSIngo Weinhold # dirs of the subdirectory. 12327d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 123352a38012Sejakowatz 12347d7f280eSIngo Weinhold local header ; 12357d7f280eSIngo Weinhold for header in $(1) { 123652a38012Sejakowatz SubDirHdrs $(header) ; 123752a38012Sejakowatz } 123852a38012Sejakowatz} 123952a38012Sejakowatz 124052a38012Sejakowatzrule UseCppUnitHeaders 124152a38012Sejakowatz{ 12427d7f280eSIngo Weinhold SubDirHdrs [ FDirName $(OBOS_TOP) headers tools cppunit ] ; 124352a38012Sejakowatz} 124452a38012Sejakowatz 1245be5af1baSIngo Weinholdrule UseCppUnitObjectHeaders 1246be5af1baSIngo Weinhold{ 12479b60a208SIngo Weinhold # UseCppUnitObjectHeaders <sources> [ : <objects> ] ; 12489b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers tools cppunit ] : $(2) ; 1249be5af1baSIngo Weinhold} 1250be5af1baSIngo Weinhold 125152a38012Sejakowatzrule UseArchHeaders 125252a38012Sejakowatz{ 12537d7f280eSIngo Weinhold # usage: UseArchHeaders <arch> ; 12547d7f280eSIngo Weinhold # 125552a38012Sejakowatz # <arch> specifies the architecture (e.g. x86). 12567d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 12577d7f280eSIngo Weinhold 12587d7f280eSIngo Weinhold local headers = [ ArchHeaders $(1) ] ; 125952a38012Sejakowatz local opt = -D$(OBOS_TARGET_DEFINE) ; 1260c633961aSIngo Weinhold 126152a38012Sejakowatz SubDirCcFlags $(opt) ; 126252a38012Sejakowatz SubDirC++Flags $(opt) ; 126316df6702SIngo Weinhold UseHeaders $(headers) ; 1264c633961aSIngo Weinhold} 1265c633961aSIngo Weinhold 12667d7f280eSIngo Weinholdrule UseArchObjectHeaders 12677d7f280eSIngo Weinhold{ 12689b60a208SIngo Weinhold # usage: UseArchObjectHeaders <sources> : <arch> : [ <objects> ] ; 12697d7f280eSIngo Weinhold # 12707d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 12717d7f280eSIngo Weinhold # <sources_or_objects> Source or object files. 12727d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 12737d7f280eSIngo Weinhold 12749b60a208SIngo Weinhold local sources = $(1) ; 12757d7f280eSIngo Weinhold local headers = [ ArchHeaders $(2) ] ; 12769b60a208SIngo Weinhold local objects = $(3) ; 12779b60a208SIngo Weinhold local targets ; 12789b60a208SIngo Weinhold if $(objects) { 12799b60a208SIngo Weinhold targets = $(objects) ; 12809b60a208SIngo Weinhold } else { 1281081debe8SIngo Weinhold targets = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 12829b60a208SIngo Weinhold } 12837d7f280eSIngo Weinhold local opt = -D$(OBOS_TARGET_DEFINE) ; 12847d7f280eSIngo Weinhold 12857d7f280eSIngo Weinhold ObjectCcFlags $(targets) : $(opt) ; 12867d7f280eSIngo Weinhold ObjectC++Flags $(targets) : $(opt) ; 12879b60a208SIngo Weinhold SourceHdrs $(sources) : $(headers) : $(objects) ; 128852a38012Sejakowatz} 128952a38012Sejakowatz 1290d25a77b4SIngo Weinholdrule UsePosixHeaders 1291d25a77b4SIngo Weinhold{ 1292a6c008e1Sbeveloper # XXX changed to do nothing 1293d25a77b4SIngo Weinhold} 1294d25a77b4SIngo Weinhold 1295d25a77b4SIngo Weinholdrule UsePosixObjectHeaders 1296d25a77b4SIngo Weinhold{ 12979b60a208SIngo Weinhold # UsePosixObjectHeaders <sources> [ : <objects> ] ; 1298d25a77b4SIngo Weinhold # 1299d25a77b4SIngo Weinhold # Adds the POSIX header dir to the header search 13009b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 13019b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 1302d25a77b4SIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 1303d25a77b4SIngo Weinhold 13049b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers posix ] : $(2) ; 1305d25a77b4SIngo Weinhold} 1306d25a77b4SIngo Weinhold 13070f434a0aSDarkWyrmrule UseLibraryHeaders 13080f434a0aSDarkWyrm{ 13090f434a0aSDarkWyrm # UseLibraryHeaders <group list> ; 13100f434a0aSDarkWyrm # 13110f434a0aSDarkWyrm # Adds the library header dirs given by <group list> to the header search 13120f434a0aSDarkWyrm # dirs of the subdirectory. 13130f434a0aSDarkWyrm # NOTE: This rule must be invoked *before* the rule that builds the objects. 13140f434a0aSDarkWyrm 13150f434a0aSDarkWyrm UseHeaders [ LibraryHeaders $(1) ] ; 13160f434a0aSDarkWyrm} 13170f434a0aSDarkWyrm 13183b9eae39SIngo Weinholdrule SplitPath 13193b9eae39SIngo Weinhold{ 13203b9eae39SIngo Weinhold # SplitPath <path> ; 13213b9eae39SIngo Weinhold # Decomposes a path into its components. 13223b9eae39SIngo Weinhold local path = $(1:G=) ; 13233b9eae39SIngo Weinhold local components ; 13248c27f58dSIngo Weinhold # $(path:D) for "/" is "/". Therefore the second condition. 13258c27f58dSIngo Weinhold while $(path:D) && $(path:D) != $(path) 13263b9eae39SIngo Weinhold { 13273b9eae39SIngo Weinhold # Note: $(path:B) returns "." for "..", but $(path:D=) is fine. 13283b9eae39SIngo Weinhold components = $(path:D=) $(components) ; 13293b9eae39SIngo Weinhold path = $(path:D) ; 13303b9eae39SIngo Weinhold } 13313b9eae39SIngo Weinhold components = $(path) $(components) ; 13323b9eae39SIngo Weinhold return $(components) ; 13333b9eae39SIngo Weinhold} 13343b9eae39SIngo Weinhold 13359fc6b2e1SIngo Weinholdrule PrependObjectHdrs 13369fc6b2e1SIngo Weinhold{ 13379fc6b2e1SIngo Weinhold # PrependObjectHdrs <objects_or_sources> : <dirs> ; 13389fc6b2e1SIngo Weinhold # Prepends <dirs> to the list of header search dirs of the objects 13399fc6b2e1SIngo Weinhold # specified by <objects_or_sources>. The HDRS variable will not be 13409fc6b2e1SIngo Weinhold # changed, only CCHDRS. 13419fc6b2e1SIngo Weinhold # Note: A subsequent ObjectHdrs invocation will therefore undo the 13429fc6b2e1SIngo Weinhold # effect of this rule. 13439fc6b2e1SIngo Weinhold # NOTE: This is a hack. 13449fc6b2e1SIngo Weinhold 13459fc6b2e1SIngo Weinhold local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 13469fc6b2e1SIngo Weinhold local dirs = $(2) ; 13479fc6b2e1SIngo Weinhold for object in $(objects) { 13489fc6b2e1SIngo Weinhold # Don't change HDRS to avoid screwing up the header scanning. 13499fc6b2e1SIngo Weinhold PREPENDED_HDRS on $(object) 13509fc6b2e1SIngo Weinhold = $(dirs) [ on $(object) return $(PREPENDED_HDRS) ] ; 13519fc6b2e1SIngo Weinhold CCHDRS on $(object) 13529fc6b2e1SIngo Weinhold = [ FIncludes [ on $(object) return $(PREPENDED_HDRS) $(HDRS) ] ] ; 13539fc6b2e1SIngo Weinhold } 13549fc6b2e1SIngo Weinhold} 13559fc6b2e1SIngo Weinhold 13563b9eae39SIngo Weinholdrule SymLink 13573b9eae39SIngo Weinhold{ 13587669b69fSIngo Weinhold # SymLink <target> : <source> : <makeDefaultDependencies> ; 13593b9eae39SIngo Weinhold # Links <target> to <source>. 13603b9eae39SIngo Weinhold # <source> is the exact link contents. No binding is done. 13617669b69fSIngo Weinhold # <makeDefaultDependencies> If true, <target> will be made a dependency 13627669b69fSIngo Weinhold # of the `all' pseudo target, i.e. it will be made by default, and removed 13637669b69fSIngo Weinhold # on `jam clean'. 13647669b69fSIngo Weinhold 13657669b69fSIngo Weinhold local target = $(1) ; 13667669b69fSIngo Weinhold local source = $(2) ; 13677669b69fSIngo Weinhold local makeDefaultDependencies = $(3) ; 13687669b69fSIngo Weinhold if ! $(makeDefaultDependencies) { 13697669b69fSIngo Weinhold makeDefaultDependencies = true ; 13707669b69fSIngo Weinhold } 13717669b69fSIngo Weinhold LINKCONTENTS on $(target) = $(source) ; 13727669b69fSIngo Weinhold SymLink1 $(target) ; 13737669b69fSIngo Weinhold if $(makeDefaultDependencies) = true { 13747669b69fSIngo Weinhold LocalDepends files : $(target) ; 13757669b69fSIngo Weinhold LocalClean clean : $(target) ; 13767669b69fSIngo Weinhold } 13773b9eae39SIngo Weinhold} 13783b9eae39SIngo Weinhold 13793b9eae39SIngo Weinholdactions SymLink1 13803b9eae39SIngo Weinhold{ 13810931b8f9SIngo Weinhold $(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)" 13820931b8f9SIngo Weinhold} 13830931b8f9SIngo Weinhold 13840931b8f9SIngo Weinholdrule RelSymLink 13850931b8f9SIngo Weinhold{ 13867669b69fSIngo Weinhold # RelSymLink <link> : <link target> : <makeDefaultDependencies> ; 13870931b8f9SIngo Weinhold # Creates a relative symbolic link from <link> to <link target>. 13880931b8f9SIngo Weinhold # <link> and <link target> can be usual targets. They may have a grist 13890931b8f9SIngo Weinhold # and don't need to have any dirname. Their LOCATE variables are used to 13900931b8f9SIngo Weinhold # find their locations. 13917669b69fSIngo Weinhold # <makeDefaultDependencies> If true (which is the default), <link> will be 13927669b69fSIngo Weinhold # made a dependency of the `files' pseudo target, i.e. it will be made by 13937669b69fSIngo Weinhold # default, and removed on `jam clean'. 13940931b8f9SIngo Weinhold 13950931b8f9SIngo Weinhold local target = $(1) ; 13960931b8f9SIngo Weinhold local source = $(2) ; 13977669b69fSIngo Weinhold local makeDefaultDependencies = $(3) ; 13980931b8f9SIngo Weinhold local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ; 13990931b8f9SIngo Weinhold local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ; 14000931b8f9SIngo Weinhold local sourcePath = $(source:G=) ; 14010931b8f9SIngo Weinhold sourcePath = $(sourcePath:D=$(sourceDir)) ; 14020931b8f9SIngo Weinhold local targetDirComponents = [ SplitPath $(targetDir) ] ; 14030931b8f9SIngo Weinhold local sourceComponents = [ SplitPath $(sourcePath) ] ; 14040931b8f9SIngo Weinhold 14050931b8f9SIngo Weinhold SymLink $(target) 14067669b69fSIngo Weinhold : [ FRelPath $(targetDirComponents) : $(sourceComponents) ] 14077669b69fSIngo Weinhold : $(makeDefaultDependencies) ; 14080931b8f9SIngo Weinhold NOUPDATE $(target) ; 14099eea4522SIngo Weinhold Depends $(target) : $(source) ; 14103b9eae39SIngo Weinhold} 14113b9eae39SIngo Weinhold 1412d391d2ebSIngo Weinholdrule AbsSymLink 1413d391d2ebSIngo Weinhold{ 14147bc56df1SIngo Weinhold # AbsSymLink <link> : <link target> : <link dir> 14157669b69fSIngo Weinhold # : <makeDefaultDependencies> ; 1416d391d2ebSIngo Weinhold # Creates an absolute symbolic link from <link> to <link target>. 1417d391d2ebSIngo Weinhold # <link> and <link target> must be usual targets. If <link dir> is 1418d391d2ebSIngo Weinhold # given, then it is set as LOCATE directory on <link>. 14197669b69fSIngo Weinhold # <makeDefaultDependencies> If true (which is the default), <link> will be 14207669b69fSIngo Weinhold # made a dependency of the `files' pseudo target, i.e. it will be made by 14217669b69fSIngo Weinhold # default, and removed on `jam clean'. 1422d391d2ebSIngo Weinhold 14237669b69fSIngo Weinhold local makeDefaultDependencies = $(4) ; 14247669b69fSIngo Weinhold if ! $(makeDefaultDependencies) { 14257669b69fSIngo Weinhold makeDefaultDependencies = true ; 14267669b69fSIngo Weinhold } 14277669b69fSIngo Weinhold 1428d391d2ebSIngo Weinhold Depends $(1) : $(2) ; 1429d391d2ebSIngo Weinhold if $(3) { 1430d391d2ebSIngo Weinhold MakeLocate $(1) : $(3) ; 1431d391d2ebSIngo Weinhold } 1432d391d2ebSIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 14337669b69fSIngo Weinhold if $(makeDefaultDependencies) = true { 14347669b69fSIngo Weinhold LocalDepends files : $(1) ; 1435d391d2ebSIngo Weinhold LocalClean clean : $(1) ; 1436d391d2ebSIngo Weinhold } 14377669b69fSIngo Weinhold} 1438d391d2ebSIngo Weinhold 1439d391d2ebSIngo Weinholdactions AbsSymLink 1440d391d2ebSIngo Weinhold{ 1441d391d2ebSIngo Weinhold target="$(2)" 1442d391d2ebSIngo Weinhold case "$target" in 1443d391d2ebSIngo Weinhold /*) ;; 1444d391d2ebSIngo Weinhold *) target=`pwd`/"$target";; 1445d391d2ebSIngo Weinhold esac 1446d391d2ebSIngo Weinhold $(RM) "$(1)" && $(LN) -s "$target" "$(1)" 1447d391d2ebSIngo Weinhold} 1448d391d2ebSIngo Weinhold 14497bc56df1SIngo Weinholdrule OBOSInstall 14507bc56df1SIngo Weinhold{ 14517bc56df1SIngo Weinhold # Usage: OBOSInstall <[ install [ and uninstall ] pseudotarget ]> 14527bc56df1SIngo Weinhold # : <directory> : <sources to install> 14537bc56df1SIngo Weinhold # : [ <installgrist> ] : [ <install rule> ] ; 14547bc56df1SIngo Weinhold local install = $(1[1]) ; 14557bc56df1SIngo Weinhold install ?= install ; 14567bc56df1SIngo Weinhold local uninstall = $(1[2]) ; 14577bc56df1SIngo Weinhold uninstall ?= un$(install) ; 14587bc56df1SIngo Weinhold local dir = $(2) ; 14597bc56df1SIngo Weinhold local sources = $(3) ; 14607bc56df1SIngo Weinhold local installgrist = $(4) ; 14617bc56df1SIngo Weinhold installgrist ?= $(INSTALLGRIST) ; 14627bc56df1SIngo Weinhold local installRule = $(5) ; 14637bc56df1SIngo Weinhold installRule ?= Install ; 14647bc56df1SIngo Weinhold local targets = $(sources:G=$(installgrist)) ; 14657bc56df1SIngo Weinhold 1466bacf6872Sshatty NotFile $(install) ; 1467bacf6872Sshatty NotFile $(uninstall) ; 14687bc56df1SIngo Weinhold Depends $(install) : $(targets) ; 14697bc56df1SIngo Weinhold Clean $(uninstall) : $(targets) ; 14707bc56df1SIngo Weinhold 14717bc56df1SIngo Weinhold SEARCH on $(sources) += $(SEARCH_SOURCE) ; 14727bc56df1SIngo Weinhold MakeLocate $(targets) : $(dir) ; 14737bc56df1SIngo Weinhold 14747bc56df1SIngo Weinhold local source ; 14757bc56df1SIngo Weinhold for source in $(sources) { 14767bc56df1SIngo Weinhold local target = $(source:G=$(installgrist)) ; 14777bc56df1SIngo Weinhold 14787bc56df1SIngo Weinhold Depends $(target) : $(source) ; 14797bc56df1SIngo Weinhold $(installRule) $(target) : $(source) ; 14807bc56df1SIngo Weinhold 14817bc56df1SIngo Weinhold if [ on $(target) return $(MODE) ] { 14827bc56df1SIngo Weinhold Chmod $(target) ; 14837bc56df1SIngo Weinhold } 14847bc56df1SIngo Weinhold 14857bc56df1SIngo Weinhold if $(OWNER) && $(CHOWN) { 14867bc56df1SIngo Weinhold Chown $(target) ; 14877bc56df1SIngo Weinhold OWNER on $(target) = $(OWNER) ; 14887bc56df1SIngo Weinhold } 14897bc56df1SIngo Weinhold 14907bc56df1SIngo Weinhold if $(GROUP) && $(CHGRP) { 14917bc56df1SIngo Weinhold Chgrp $(target) ; 14927bc56df1SIngo Weinhold GROUP on $(target) = $(GROUP) ; 14937bc56df1SIngo Weinhold } 14947bc56df1SIngo Weinhold } 14957bc56df1SIngo Weinhold} 14967bc56df1SIngo Weinhold 14977669b69fSIngo Weinholdrule InstallAbsSymLinkAdapter 14987669b69fSIngo Weinhold{ 14997669b69fSIngo Weinhold # InstallAbsSymLinkAdapter <link> : <link target> 15007669b69fSIngo Weinhold if ! [ on $(2) return $(TARGET) ] { 15017669b69fSIngo Weinhold TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; 15027669b69fSIngo Weinhold } 15037669b69fSIngo Weinhold AbsSymLink $(1) : $(2) : : false ; 15047669b69fSIngo Weinhold} 15057669b69fSIngo Weinhold 15067bc56df1SIngo Weinholdrule OBOSInstallAbsSymLink 15077bc56df1SIngo Weinhold{ 15087bc56df1SIngo Weinhold # Usage: OBOSInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]> 15097bc56df1SIngo Weinhold # : <directory> : <sources to install> 15107bc56df1SIngo Weinhold # : [ <installgrist> ] ; 15117669b69fSIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallAbsSymLinkAdapter ; 15127bc56df1SIngo Weinhold} 15137bc56df1SIngo Weinhold 15147bc56df1SIngo Weinholdrule InstallRelSymLinkAdapter 15157bc56df1SIngo Weinhold{ 15167bc56df1SIngo Weinhold # InstallRelSymLinkAdapter <link> : <link target> 15177bc56df1SIngo Weinhold if ! [ on $(2) return $(TARGET) ] { 15187bc56df1SIngo Weinhold TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; 15197bc56df1SIngo Weinhold } 15207669b69fSIngo Weinhold RelSymLink $(1) : $(2) : false ; 15217bc56df1SIngo Weinhold} 15227bc56df1SIngo Weinhold 15237bc56df1SIngo Weinholdrule OBOSInstallRelSymLink 15247bc56df1SIngo Weinhold{ 15257bc56df1SIngo Weinhold # Usage: OBOSInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]> 15267bc56df1SIngo Weinhold # : <directory> : <sources to install> 15277bc56df1SIngo Weinhold # : [ <installgrist> ] ; 15287bc56df1SIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ; 15297bc56df1SIngo Weinhold} 15307bc56df1SIngo Weinhold 15317bc56df1SIngo Weinhold 153252a38012Sejakowatz#------------------------------------------------------------------------------- 153352a38012Sejakowatz# Low-level OBOS utility rules 153452a38012Sejakowatz#------------------------------------------------------------------------------- 153579b49834SIngo Weinholdrule FObjectsDir 153679b49834SIngo Weinhold{ 1537121af366SIngo Weinhold # FObjectsDir <subdir tokens> 1538121af366SIngo Weinhold # 1539121af366SIngo Weinhold # Returns the output directory for object files the specified 1540121af366SIngo Weinhold # subdirectory. 1541121af366SIngo Weinhold # 1542121af366SIngo Weinhold # <subdir tokens>: The tokens of the subdir relative to the top. 1543121af366SIngo Weinhold # 1544121af366SIngo Weinhold 1545121af366SIngo Weinhold return [ FDirName $(OBOS_OBJECT_TARGET) $(1[2-]) ] ; 1546121af366SIngo Weinhold} 1547121af366SIngo Weinhold 1548121af366SIngo Weinholdrule FCurrentObjectsDir 1549121af366SIngo Weinhold{ 1550121af366SIngo Weinhold # FCurrentObjectsDir 155179b49834SIngo Weinhold # 155279b49834SIngo Weinhold # Returns the output directory for object files for the current 155379b49834SIngo Weinhold # subdirectory. 155479b49834SIngo Weinhold 1555121af366SIngo Weinhold return [ FObjectsDir $(SUBDIR_TOKENS) ] ; 155679b49834SIngo Weinhold} 155779b49834SIngo Weinhold 155852a38012Sejakowatzrule SetupObjectsDir 155952a38012Sejakowatz{ 1560121af366SIngo Weinhold LOCATE_TARGET = [ FCurrentObjectsDir ] ; 15618d3308d9SIngo Weinhold LOCATE_SOURCE = $(LOCATE_TARGET) ; 15628d3308d9SIngo Weinhold SEARCH_SOURCE = [ Filter $(SEARCH_SOURCE) : $(LOCATE_TARGET) ] 15638d3308d9SIngo Weinhold $(LOCATE_TARGET) ; 156452a38012Sejakowatz} 156552a38012Sejakowatz 156652a38012Sejakowatz#------------------------------------------------------------------------------- 156752a38012Sejakowatz# Link rule/action are overwritten as they don't handle linking files who's name 156852a38012Sejakowatz# contain spaces very well. Also adds resources and version to executable. 156952a38012Sejakowatz#------------------------------------------------------------------------------- 157052a38012Sejakowatzrule Link 157152a38012Sejakowatz{ 157252a38012Sejakowatz # Note: RESFILES must be set before invocation. 157352a38012Sejakowatz MODE on $(<) = $(EXEMODE) ; 157452a38012Sejakowatz on $(1) XRes $(1) : $(RESFILES) ; 157552a38012Sejakowatz Chmod $(<) ; 157652a38012Sejakowatz SetType $(1) ; 157752a38012Sejakowatz MimeSet $(1) ; 15781419ae2bSshatty SetVersion $(1) ; 157952a38012Sejakowatz} 158052a38012Sejakowatz 158152a38012Sejakowatzactions Link bind NEEDLIBS 158252a38012Sejakowatz{ 15831eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(2)" "$(NEEDLIBS)" $(LINKLIBS) ; 158452a38012Sejakowatz} 158552a38012Sejakowatz 15868d3308d9SIngo Weinholdrule LexC++ 15878d3308d9SIngo Weinhold{ 15888d3308d9SIngo Weinhold Depends $(1) : $(2) ; 15898d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_SOURCE) ; 15908d3308d9SIngo Weinhold LocalClean clean : $(1) ; 15918d3308d9SIngo Weinhold} 15928d3308d9SIngo Weinhold 15938d3308d9SIngo Weinholdactions LexC++ 15948d3308d9SIngo Weinhold{ 15958d3308d9SIngo Weinhold $(LEX) -o$(1) $(2) 15968d3308d9SIngo Weinhold} 15978d3308d9SIngo Weinhold 15988d3308d9SIngo Weinholdrule Bison 15998d3308d9SIngo Weinhold{ 16008d3308d9SIngo Weinhold local _h ; 16018d3308d9SIngo Weinhold 1602cec8c8b5SJérôme Duval _h = $(1:S=.hpp) ; 16038d3308d9SIngo Weinhold 16048d3308d9SIngo Weinhold MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ; 16058d3308d9SIngo Weinhold 16068d3308d9SIngo Weinhold Depends $(<) $(_h) : $(>) ; 16078d3308d9SIngo Weinhold Bison1 $(<) $(_h) : $(>) ; 16088d3308d9SIngo Weinhold LocalClean clean : $(<) $(_h) ; 16098d3308d9SIngo Weinhold 16108d3308d9SIngo Weinhold # make sure someone includes $(_h) else it will be 16118d3308d9SIngo Weinhold # a deadly independent target 16128d3308d9SIngo Weinhold 16138d3308d9SIngo Weinhold Includes $(<) : $(_h) ; 16148d3308d9SIngo Weinhold} 16158d3308d9SIngo Weinhold 16168d3308d9SIngo Weinholdactions Bison1 16178d3308d9SIngo Weinhold{ 16188d3308d9SIngo Weinhold bison $(YACCFLAGS) -o $(1[1]) $(2) 1619cec8c8b5SJérôme Duval [ -f $(1[1]).h ] && mv $(1[1]).h $(1[2]) || true 16208d3308d9SIngo Weinhold} 16218d3308d9SIngo Weinhold 1622705fc998SAxel Dörflerrule UnarchiveObjects 1623705fc998SAxel Dörfler{ 1624705fc998SAxel Dörfler # UnarchiveObjects <target objects> : <static object> 1625705fc998SAxel Dörfler 1626705fc998SAxel Dörfler MakeLocate $(1) : $(LOCATE_TARGET) ; 1627705fc998SAxel Dörfler Depends $(2) : $(1) ; 1628705fc998SAxel Dörfler SEARCH on $(2) = $(SEARCH_SOURCE) ; 1629705fc998SAxel Dörfler} 1630705fc998SAxel Dörfler 1631705fc998SAxel Dörfleractions UnarchiveObjects 1632705fc998SAxel Dörfler{ 16333c71865aSAxel Dörfler cd $(1[1]:D) 1634b8ab94faSIngo Weinhold ar -x "$(2)" $(1:BS) 1635705fc998SAxel Dörfler cd - 1636705fc998SAxel Dörfler} 1637705fc998SAxel Dörfler 163852a38012Sejakowatz# BeOS specific rules 163952a38012Sejakowatz 164052a38012Sejakowatzrule XRes 164152a38012Sejakowatz{ 164252a38012Sejakowatz # XRes <target> : <resource files> 164352a38012Sejakowatz if $(2) 164452a38012Sejakowatz { 16459eea4522SIngo Weinhold Depends $(1) : $(2) ; 164652a38012Sejakowatz XRes1 $(1) : $(2) ; 164752a38012Sejakowatz } 164852a38012Sejakowatz} 164952a38012Sejakowatz 165052a38012Sejakowatzrule XRes1 { } 165152a38012Sejakowatz 165252a38012Sejakowatzrule SetVersion 165352a38012Sejakowatz{ 165452a38012Sejakowatz # SetVersion <target> 165552a38012Sejakowatz} 165652a38012Sejakowatz 165752a38012Sejakowatzrule SetType 165852a38012Sejakowatz{ 165952a38012Sejakowatz # SetType <target> 166052a38012Sejakowatz} 166152a38012Sejakowatz 166252a38012Sejakowatzrule MimeSet 166352a38012Sejakowatz{ 166452a38012Sejakowatz # SetType <target> 166552a38012Sejakowatz} 166652a38012Sejakowatz 166752a38012Sejakowatz 166852a38012Sejakowatzif $(OS) = BEOS 166952a38012Sejakowatz{ 167052a38012Sejakowatz 167152a38012Sejakowatzactions XRes1 167252a38012Sejakowatz{ 16730931b8f9SIngo Weinhold xres -o "$(1)" "$(2)" ; 167452a38012Sejakowatz} 167552a38012Sejakowatz 167652a38012Sejakowatzactions SetVersion 167752a38012Sejakowatz{ 167852a38012Sejakowatz setversion "$(1)" -system $(OBOS_BUILD_VERSION) -short "$(OBOS_BUILD_DESCRIPTION)" ; 167952a38012Sejakowatz} 168052a38012Sejakowatz 168152a38012Sejakowatzactions SetType 168252a38012Sejakowatz{ 168352a38012Sejakowatz settype -t $(OBOS_TARGET_TYPE) "$(1)" ; 168452a38012Sejakowatz} 168552a38012Sejakowatz 168652a38012Sejakowatzactions MimeSet 168752a38012Sejakowatz{ 168852a38012Sejakowatz mimeset -f "$(1)" ; 168952a38012Sejakowatz} 169052a38012Sejakowatz 169152a38012Sejakowatz} # if BEOS 169252a38012Sejakowatz 169352a38012Sejakowatz 169452a38012Sejakowatzrule assemble 169552a38012Sejakowatz{ 169694782cf7SIngo Weinhold Depends $(<) : $(>) ; 169794782cf7SIngo Weinhold ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ; 169894782cf7SIngo Weinhold ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ; 169952a38012Sejakowatz} 170052a38012Sejakowatz 170152a38012Sejakowatzactions assemble 170252a38012Sejakowatz{ 1703a8687de4SAxel Dörfler $(CC) -c "$(2)" -O2 $(ASFLAGS) -D_ASSEMBLER $(KERNEL_CCFLAGS) $(ASHDRS) -o "$(1)" ; 170452a38012Sejakowatz} 170552a38012Sejakowatz 17060931b8f9SIngo Weinhold# Overridden to allow spaces in file names. 17070931b8f9SIngo Weinholdactions Chmod1 17080931b8f9SIngo Weinhold{ 17090931b8f9SIngo Weinhold $(CHMOD) "$(MODE)" "$(1)" 17100931b8f9SIngo Weinhold} 17110931b8f9SIngo Weinhold 17126991af8cSIngo Weinhold# Overridden to allow spaces in file names. 17136991af8cSIngo Weinholdactions piecemeal together existing Clean 17146991af8cSIngo Weinhold{ 17156991af8cSIngo Weinhold $(RM) "$(>)" 17166991af8cSIngo Weinhold} 17176991af8cSIngo Weinhold 171808125d07SIngo Weinholdrule ObjectReference 171908125d07SIngo Weinhold{ 172008125d07SIngo Weinhold # ObjectReference <reference object> : <source object> 172108125d07SIngo Weinhold # Makes <reference object> refer to the same file as <source object>. 172208125d07SIngo Weinhold # The filenames must of course be identical. 172308125d07SIngo Weinhold # <source object> must have already been LOCATEd. 172408125d07SIngo Weinhold 172508125d07SIngo Weinhold local ref = $(1) ; 172608125d07SIngo Weinhold local source = $(2) ; 172708125d07SIngo Weinhold if $(ref) != $(source) { 17289eea4522SIngo Weinhold Depends $(ref) : $(source) ; 172921df5945SIngo Weinhold LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ; 173008125d07SIngo Weinhold } 173108125d07SIngo Weinhold} 173208125d07SIngo Weinhold 173308125d07SIngo Weinholdrule ObjectReferences 173408125d07SIngo Weinhold{ 173508125d07SIngo Weinhold # ObjectReferences <source objects> 173608125d07SIngo Weinhold # Creates local references to <source objects>, i.e. identifiers with the 173708125d07SIngo Weinhold # current grist referring to the same files. <source objects> must have 173808125d07SIngo Weinhold # already been LOCATEd. 173908125d07SIngo Weinhold 174008125d07SIngo Weinhold local source ; 174108125d07SIngo Weinhold for source in $(1) { 174208125d07SIngo Weinhold ObjectReference [ FGristFiles $(source) ] : $(source) ; 174308125d07SIngo Weinhold } 174408125d07SIngo Weinhold} 174508125d07SIngo Weinhold 17469fc6b2e1SIngo Weinholdrule Filter 17479fc6b2e1SIngo Weinhold{ 17489fc6b2e1SIngo Weinhold # Filter <list> : <excludes> ; 17499fc6b2e1SIngo Weinhold # Removes all occurrences of <excludes> in <list>. 17509fc6b2e1SIngo Weinhold 17519fc6b2e1SIngo Weinhold local list = $(1) ; 17529fc6b2e1SIngo Weinhold local excludes = $(2) ; 17539fc6b2e1SIngo Weinhold local newList ; 17549fc6b2e1SIngo Weinhold local item ; 17559fc6b2e1SIngo Weinhold for item in $(list) { 17569fc6b2e1SIngo Weinhold local skip ; 17579fc6b2e1SIngo Weinhold local exclude ; 17589fc6b2e1SIngo Weinhold for exclude in $(excludes) { 17599fc6b2e1SIngo Weinhold if $(item) = $(exclude) { 17609fc6b2e1SIngo Weinhold skip = true ; 17619fc6b2e1SIngo Weinhold } 17629fc6b2e1SIngo Weinhold } 17639fc6b2e1SIngo Weinhold if ! $(skip) { 1764dd9f8062SIngo Weinhold newList += $(item) ; 17659fc6b2e1SIngo Weinhold } 17669fc6b2e1SIngo Weinhold } 17679fc6b2e1SIngo Weinhold return $(newList) ; 17689fc6b2e1SIngo Weinhold} 17699fc6b2e1SIngo Weinhold 17700931b8f9SIngo Weinhold 177152a38012Sejakowatz## Kernel stuff! 177252a38012Sejakowatz 177352a38012Sejakowatzrule SetupKernel 177452a38012Sejakowatz{ 177552a38012Sejakowatz # Usage SetupKernel <sources_or_objects> : <extra_cc_flags>; 177694a49b21SIngo Weinhold # 177794a49b21SIngo Weinhold # <sources_or_objects> - Ideally sources, otherwise HDRSEARCH can not be 177894a49b21SIngo Weinhold # set for the sources and the sources some header 177994a49b21SIngo Weinhold # dependencies might be missing. 178052a38012Sejakowatz 178194a49b21SIngo Weinhold local sources = [ FGristFiles $(1) ] ; 178294a49b21SIngo Weinhold local _objs = $(sources:S=$(SUFOBJ)) ; 178352a38012Sejakowatz 178428d2a30eSDaniel Reinhold #Setup Kernel header directories 178599b8dab3SAxel Dörfler local public_kernel_includes = add-ons/file_system add-ons/graphics app device drivers kernel storage support ; 1786c0e501e0SIngo Weinhold local private_kernel_includes = $(DOT) kernel libroot kernel/boot/platform/$(OBOS_BOOT_PLATFORM) ; 1787a6c008e1Sbeveloper # Use posix headers directory 1788c0e501e0SIngo Weinhold local headers = [ FDirName $(OBOS_TOP) headers posix ] ; 1789a6c008e1Sbeveloper # Use public OS header directories 1790c0e501e0SIngo Weinhold headers += [ PublicHeaders $(public_kernel_includes) ] ; 1791089a0629Sbeveloper # Use private directories 1792c0e501e0SIngo Weinhold headers += [ PrivateHeaders $(private_kernel_includes) ] ; 179309c5682dSIngo Weinhold # The platform dependent headers. 1794c0e501e0SIngo Weinhold headers += $(PLATFORM_HEADERS) ; 1795a6c008e1Sbeveloper 179694a49b21SIngo Weinhold SourceHdrs $(sources) : $(headers) ; 179794a49b21SIngo Weinhold UseArchObjectHeaders $(sources) : $(OBOS_ARCH) ; 179852a38012Sejakowatz 1799c0e501e0SIngo Weinhold local object ; 1800c0e501e0SIngo Weinhold for object in $(_objs) { 1801c0e501e0SIngo Weinhold ObjectCcFlags $(object) : $(KERNEL_CCFLAGS) $(2) ; 1802c0e501e0SIngo Weinhold ObjectC++Flags $(object) : $(KERNEL_C++FLAGS) $(2) ; 1803c0e501e0SIngo Weinhold } 180452a38012Sejakowatz} 180552a38012Sejakowatz 180652a38012Sejakowatzrule KernelObjects 180752a38012Sejakowatz{ 1808c0e501e0SIngo Weinhold SetupObjectsDir ; 180952a38012Sejakowatz 181052a38012Sejakowatz Objects $(1) ; 1811c0e501e0SIngo Weinhold 1812c0e501e0SIngo Weinhold SetupKernel $(1) : $(2) ; 181352a38012Sejakowatz} 181452a38012Sejakowatz 181552a38012Sejakowatzrule KernelLd 181652a38012Sejakowatz{ 181780721244SAxel Dörfler # KernelLd <name> : <objs> : <linkerscript> : <args> : <gcc_off> : <config_section> ; 181852a38012Sejakowatz 1819c0e501e0SIngo Weinhold SetupObjectsDir ; 182052a38012Sejakowatz LINK on $(1) = ld ; 182152a38012Sejakowatz 182252a38012Sejakowatz LINKFLAGS on $(1) = $(4) ; 182352a38012Sejakowatz if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 182452a38012Sejakowatz 182552a38012Sejakowatz # Remove any preset LINKLIBS 182652a38012Sejakowatz LINKLIBS on $(1) = ; 182752a38012Sejakowatz 182852a38012Sejakowatz # Show that we depend on the libraries we need 18299eea4522SIngo Weinhold LocalClean clean : $(1) ; 18309eea4522SIngo Weinhold LocalDepends all : $(1) ; 183152a38012Sejakowatz Depends $(1) : $(2) ; 183252a38012Sejakowatz 183352a38012Sejakowatz if $(6) { 183452a38012Sejakowatz for i in $(6) { 18352a83bfb4SIngo Weinhold KernelConfigSection $(i) : elf32 : $(1) ; 183652a38012Sejakowatz } 183752a38012Sejakowatz } 183852a38012Sejakowatz 183952a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 184052a38012Sejakowatz 184109c5682dSIngo Weinhold # Add the platform specific static libs (libgcc.a). 184252a38012Sejakowatz if ! $(5) { 184309c5682dSIngo Weinhold LINKLIBS on $(1) += $(PLATFORM_LINKLIBS) ; 184452a38012Sejakowatz } 1845c0e501e0SIngo Weinhold 1846c0e501e0SIngo Weinhold SetupKernel $(2) ; 184752a38012Sejakowatz} 184852a38012Sejakowatz 184952a38012Sejakowatzactions KernelLd 185052a38012Sejakowatz{ 18511eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ; 185252a38012Sejakowatz} 185352a38012Sejakowatz 1854811903d1SAxel Dörflerrule KernelAddon 1855811903d1SAxel Dörfler{ 1856600203b1SAxel Dörfler # KernelAddon <name> : <relpath> : <sources> : <static-libraries> ; 1857811903d1SAxel Dörfler 1858811903d1SAxel Dörfler local sources = $(3) ; 1859811903d1SAxel Dörfler 1860c0e501e0SIngo Weinhold SetupObjectsDir ; 186194a49b21SIngo Weinhold Addon $(1) : $(2) : $(sources) ; 1862*979afc6fSAxel Dörfler ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -fno-pic ; 1863*979afc6fSAxel Dörfler ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -fno-pic -fno-exceptions ; 1864811903d1SAxel Dörfler LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; 1865d5807053SIngo Weinhold LinkSharedOSLibs $(1) : $(4) <nogrist>kernel.so ; 186694a49b21SIngo Weinhold SetupKernel $(sources) ; 1867811903d1SAxel Dörfler} 1868811903d1SAxel Dörfler 186980721244SAxel Dörflerrule KernelMergeObject 187080721244SAxel Dörfler{ 18712fbd7065SIngo Weinhold # KernelMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ; 18722fbd7065SIngo Weinhold # Compiles source files and merges the object files to an object file. 18732fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 18742fbd7065SIngo Weinhold # <sources>: Sources to be compiled. Grist will be added. 18752fbd7065SIngo Weinhold # <extra CFLAGS>: Additional flags for compilation. 18762fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 18772fbd7065SIngo Weinhold # will be added. 18782fbd7065SIngo Weinhold # 187980721244SAxel Dörfler 1880c0e501e0SIngo Weinhold SetupObjectsDir ; 188180721244SAxel Dörfler 188280721244SAxel Dörfler MakeLocateObjects $(2) ; 188380721244SAxel Dörfler Objects $(2) ; 18842fbd7065SIngo Weinhold MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; 1885c0e501e0SIngo Weinhold 1886c0e501e0SIngo Weinhold SetupKernel $(2) : $(3) ; 188780721244SAxel Dörfler} 188880721244SAxel Dörfler 188952a38012Sejakowatzrule KernelStaticLibrary 189052a38012Sejakowatz{ 189152a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ; 189252a38012Sejakowatz # This is designed to take a set of sources and libraries and create 189352a38012Sejakowatz # a file called lib<name>.a 189452a38012Sejakowatz 1895c0e501e0SIngo Weinhold SetupObjectsDir ; 189652a38012Sejakowatz 189752a38012Sejakowatz MakeLocateObjects $(2) ; 189852a38012Sejakowatz Library $(1) : $(2) ; 1899c0e501e0SIngo Weinhold 1900c0e501e0SIngo Weinhold SetupKernel $(2) : $(3) ; 190152a38012Sejakowatz} 190252a38012Sejakowatz 190352a38012Sejakowatzrule KernelStaticLibraryObjects 190452a38012Sejakowatz{ 190552a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> ; 190652a38012Sejakowatz # This is designed to take a set of sources and libraries and create 190752a38012Sejakowatz # a file called <name> 190852a38012Sejakowatz 1909c0e501e0SIngo Weinhold SetupObjectsDir ; 191052a38012Sejakowatz 191152a38012Sejakowatz # Show that we depend on the libraries we need 19129eea4522SIngo Weinhold LocalClean clean : $(1) ; 19139eea4522SIngo Weinhold LocalDepends all : $(1) ; 191452a38012Sejakowatz Depends $(1) : $(2) ; 191552a38012Sejakowatz 191652a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 1917c0e501e0SIngo Weinhold 1918c0e501e0SIngo Weinhold SetupKernel $(2) ; 191952a38012Sejakowatz} 192052a38012Sejakowatz 192152a38012Sejakowatzactions KernelStaticLibraryObjects 192252a38012Sejakowatz{ 19230931b8f9SIngo Weinhold ar -r "$(1)" "$(2)" ; 192452a38012Sejakowatz} 192552a38012Sejakowatz 19265dc4e1efSIngo Weinholdrule BuildPlatformMain 192752a38012Sejakowatz{ 19288dc98d6dSIngo Weinhold # Usage BuildPlatformMain <target> : <sources> [ : <resetIncludes> ] ; 19298dc98d6dSIngo Weinhold # <target> The executable. 19308dc98d6dSIngo Weinhold # <sources> The sources. 19318dc98d6dSIngo Weinhold # <resetIncludes> "false", if header search dirs shall not be reset to the 19328dc98d6dSIngo Weinhold # platform defaults. Defaults to "true". 19338dc98d6dSIngo Weinhold # 193452a38012Sejakowatz SetupObjectsDir ; 19358dc98d6dSIngo Weinhold if $(3) != false { 19365dc4e1efSIngo Weinhold SetupDefaultIncludes ; 19378dc98d6dSIngo Weinhold } 193852a38012Sejakowatz 19395dc4e1efSIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 19405dc4e1efSIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 19415dc4e1efSIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 19425dc4e1efSIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 19435dc4e1efSIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 194452a38012Sejakowatz 194552a38012Sejakowatz Main $(1) : $(2) ; 19465dc4e1efSIngo Weinhold 19473844cf70SIngo Weinhold ObjectsDefines $(2) : _NO_INLINE_ASM ; 19483844cf70SIngo Weinhold # Be careful with find_thread() and the like. 19493844cf70SIngo Weinhold 19505dc4e1efSIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 19515dc4e1efSIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 19525dc4e1efSIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 195352a38012Sejakowatz} 195452a38012Sejakowatz 19559fcaa61dSIngo Weinholdrule BuildPlatformTest 19569fcaa61dSIngo Weinhold{ 19579fcaa61dSIngo Weinhold # Usage BuildPlatformTest <target> : <sources> ; 19589fcaa61dSIngo Weinhold 19599fcaa61dSIngo Weinhold local target = $(1) ; 19609fcaa61dSIngo Weinhold local sources = $(2) ; 19619fcaa61dSIngo Weinhold 19629fcaa61dSIngo Weinhold BuildPlatformMain $(target) : $(sources) ; 19639fcaa61dSIngo Weinhold local relPath ; 19649fcaa61dSIngo Weinhold if [ FIsPrefix src tests : $(SUBDIR_TOKENS) ] { 19659fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[3-]) ; 19669fcaa61dSIngo Weinhold } else { 19679fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[2-]) ; 19689fcaa61dSIngo Weinhold } 19699fcaa61dSIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 19709fcaa61dSIngo Weinhold} 19719fcaa61dSIngo Weinhold 197252a38012Sejakowatzrule KernelConfigSection 197352a38012Sejakowatz{ 197452a38012Sejakowatz # KernelConfigSection <section> : <type> : <file> ; 19752a83bfb4SIngo Weinhold 19762a83bfb4SIngo Weinhold SECTION_NAMES on $(OBOS_KERNEL_CONFIG) += $(1) ; 19772a83bfb4SIngo Weinhold SECTION_TYPES on $(OBOS_KERNEL_CONFIG) += $(2) ; 19782a83bfb4SIngo Weinhold SECTION_FILES on $(OBOS_KERNEL_CONFIG) += $(3) ; 19792a83bfb4SIngo Weinhold 19802a83bfb4SIngo Weinhold Depends $(OBOS_KERNEL_CONFIG) : $(3) ; 198152a38012Sejakowatz} 198252a38012Sejakowatz 198352a38012Sejakowatzrule WriteKernelConfig 198452a38012Sejakowatz{ 198552a38012Sejakowatz # usage: WriteKernelConfig <target> ; 198652a38012Sejakowatz 19879eea4522SIngo Weinhold LocalDepends files : $(1) ; 198852a38012Sejakowatz 19892a83bfb4SIngo Weinhold MakeLocate $(1) : $(OBOS_OBJECT_TARGET) ; 199052a38012Sejakowatz 19919eea4522SIngo Weinhold LocalClean clean : $(1) ; 199252a38012Sejakowatz} 199352a38012Sejakowatz 19942a83bfb4SIngo Weinholdactions WriteKernelConfig bind SECTION_FILES 199552a38012Sejakowatz{ 19960931b8f9SIngo Weinhold target="$(1)" 19970931b8f9SIngo Weinhold echo "# OpenBeOS Kernel Config File" > "$target" 19980931b8f9SIngo Weinhold echo "# Automatically generated - do not edit!" >> "$target" 19992a83bfb4SIngo Weinhold count=0 20002a83bfb4SIngo Weinhold for section in "$(SECTION_NAMES)" ; do 20012a83bfb4SIngo Weinhold count=`expr $count + 1` 20022a83bfb4SIngo Weinhold eval section$count="$section" 20032a83bfb4SIngo Weinhold done 20042a83bfb4SIngo Weinhold i=1 20052a83bfb4SIngo Weinhold for type in "$(SECTION_TYPES)" ; do 20062a83bfb4SIngo Weinhold eval type$i="$type" 20072a83bfb4SIngo Weinhold i=`expr $i + 1` 20082a83bfb4SIngo Weinhold done 20092a83bfb4SIngo Weinhold i=1 20102a83bfb4SIngo Weinhold for file in "$(SECTION_FILES)" ; do 20112a83bfb4SIngo Weinhold eval file$i="$file" 20122a83bfb4SIngo Weinhold i=`expr $i + 1` 20132a83bfb4SIngo Weinhold done 20142a83bfb4SIngo Weinhold for i in `seq $count` ; do 20152a83bfb4SIngo Weinhold eval section="\$section$i" 20162a83bfb4SIngo Weinhold eval type="\$type$i" 20172a83bfb4SIngo Weinhold eval file="\$file$i" 20180931b8f9SIngo Weinhold echo "" >> "$target" 20192a83bfb4SIngo Weinhold echo "["$section"]" >> "$target" 20202a83bfb4SIngo Weinhold echo "type="$type >> "$target" 20210931b8f9SIngo Weinhold case "$file" in 202252a38012Sejakowatz /*) ;; 20230931b8f9SIngo Weinhold *) file=`pwd`/"$file";; 202452a38012Sejakowatz esac 20252a83bfb4SIngo Weinhold echo "file="$file >> "$target" 202652a38012Sejakowatz done 202752a38012Sejakowatz} 202852a38012Sejakowatz 202952a38012Sejakowatzrule BuildKernel 203052a38012Sejakowatz{ 203152a38012Sejakowatz # Usage BuildKernel <target> : <config_file> ; 20320c0b2cd0SIngo Weinhold local kernel = $(1) ; 20330c0b2cd0SIngo Weinhold local configFile = $(2) ; 20340c0b2cd0SIngo Weinhold local bootmaker = bootmaker ; 203552a38012Sejakowatz 20369eea4522SIngo Weinhold LocalDepends all : $(kernel) ; 20370c0b2cd0SIngo Weinhold Depends $(kernel) : $(configFile) $(bootmaker) ; 20389eea4522SIngo Weinhold LocalClean clean : $(kernel) ; 20390c0b2cd0SIngo Weinhold MakeLocate $(kernel) : $(LOCATE_TARGET) ; 204052a38012Sejakowatz 20410c0b2cd0SIngo Weinhold BOOT_MAKER on $(kernel) = $(bootmaker) ; 204252a38012Sejakowatz} 204352a38012Sejakowatz 20440c0b2cd0SIngo Weinholdactions BuildKernel bind BOOT_MAKER 204552a38012Sejakowatz{ 20460c0b2cd0SIngo Weinhold "$(BOOT_MAKER)" --strip-debug --strip-binary strip "$(2)" -o "$(1)" ; 204752a38012Sejakowatz echo "" 204852a38012Sejakowatz echo "Kernel linked!" 204952a38012Sejakowatz echo "" 205052a38012Sejakowatz} 205152a38012Sejakowatz 205252a38012Sejakowatzrule KernelFloppyImage 205352a38012Sejakowatz{ 205452a38012Sejakowatz # Usage KernelFloppyImage <target> : <kernel> : <bootblock> ; 20550c0b2cd0SIngo Weinhold local floppy = $(1) ; 20560c0b2cd0SIngo Weinhold local kernel = $(2) ; 20570c0b2cd0SIngo Weinhold local bootblock = $(3) ; 20580c0b2cd0SIngo Weinhold local makeflop = makeflop ; 205952a38012Sejakowatz 20609eea4522SIngo Weinhold LocalDepends all : $(floppy) ; 20610c0b2cd0SIngo Weinhold Depends $(floppy) : $(kernel) $(bootblock) $(makeflop) ; 20629eea4522SIngo Weinhold LocalClean clean : $(floppy) ; 20630c0b2cd0SIngo Weinhold MakeLocate $(floppy) : $(OBOS_OBJECT_TARGET) ; 206452a38012Sejakowatz 20650c0b2cd0SIngo Weinhold BOOT_BLOCK on $(floppy) = $(bootblock) ; 20660c0b2cd0SIngo Weinhold MAKE_FLOP on $(floppy) = $(makeflop) ; 206752a38012Sejakowatz} 206852a38012Sejakowatz 206952a38012Sejakowatz# This may be a bit verbose, but I think it's useful to show what's 207052a38012Sejakowatz# going on, at least in this early stage of development. 20710c0b2cd0SIngo Weinholdactions KernelFloppyImage bind BOOT_BLOCK bind MAKE_FLOP 207252a38012Sejakowatz{ 20737378dd7fSAxel Dörfler "$(MAKE_FLOP)" "-p $(shell expr 18 \* 2 \* 512)" "$(BOOT_BLOCK)" "$(2)" "$(1)" ; 20740c0b2cd0SIngo Weinhold 207552a38012Sejakowatz echo "" 207652a38012Sejakowatz echo "*************************************************" 207752a38012Sejakowatz echo "* Kernel build completed! *" 207852a38012Sejakowatz echo "* Boot image for a 1.44M floppy created *" 207952a38012Sejakowatz echo "*************************************************" 208052a38012Sejakowatz echo "" 20810c0b2cd0SIngo Weinhold echo "Floppy image is $(1)" 208252a38012Sejakowatz echo "The following command will write it to a floppy on BeOS" 20830c0b2cd0SIngo Weinhold echo " dd if=$(1) of=/dev/disk/floppy/raw bs=18k" 20840c0b2cd0SIngo Weinhold echo "Alternatively you can run" 20850c0b2cd0SIngo Weinhold echo " ./configure --floppy /dev/disk/floppy/raw" 20860c0b2cd0SIngo Weinhold echo "once and build + write the image subsequently via" 20870c0b2cd0SIngo Weinhold echo " jam installfloppy" 208852a38012Sejakowatz echo "" 208952a38012Sejakowatz} 209052a38012Sejakowatz 20910c0b2cd0SIngo Weinholdrule InstallFloppy 20920c0b2cd0SIngo Weinhold{ 20930c0b2cd0SIngo Weinhold # InstallFloppy <target> : <floppy> 20940c0b2cd0SIngo Weinhold # "dd"s <floppy> to $(FLOPPY_PATH). 20950c0b2cd0SIngo Weinhold 20960c0b2cd0SIngo Weinhold local target = $(1) ; 20970c0b2cd0SIngo Weinhold local floppy = $(2) ; 20980c0b2cd0SIngo Weinhold 20990c0b2cd0SIngo Weinhold NotFile $(target) ; 21000c0b2cd0SIngo Weinhold Always $(target) ; 21010c0b2cd0SIngo Weinhold Depends $(target) : $(floppy) ; 21020c0b2cd0SIngo Weinhold} 21030c0b2cd0SIngo Weinhold 21040c0b2cd0SIngo Weinholdactions InstallFloppy 21050c0b2cd0SIngo Weinhold{ 21060c0b2cd0SIngo Weinhold if [ -z $(FLOPPY_PATH) ] ; then 21070c0b2cd0SIngo Weinhold echo "Can't install floppy: FLOPPY_PATH not set." 21080c0b2cd0SIngo Weinhold echo "run: ./configure --floppy <floppy path>" 21090c0b2cd0SIngo Weinhold echo 21100c0b2cd0SIngo Weinhold exit 0 21110c0b2cd0SIngo Weinhold fi 21120c0b2cd0SIngo Weinhold dd if=$(2) of=$(FLOPPY_PATH) bs=18k 21130c0b2cd0SIngo Weinhold} 211452a38012Sejakowatz 211521df5945SIngo Weinhold#------------------------------------------------------------------------------- 211621df5945SIngo Weinhold# FreeType 2 specific rules and variables 211721df5945SIngo Weinhold#------------------------------------------------------------------------------- 211821df5945SIngo Weinhold 211921df5945SIngo WeinholdFT2_INCLUDE = [ FDirName $(OBOS_TOP) headers libs freetype2 ] ; 212021df5945SIngo WeinholdFT2_SRC = [ FDirName $(OBOS_TOP) src libs freetype2 ] ; 212121df5945SIngo Weinhold 212221df5945SIngo WeinholdFT2_LIB = freetype ; 212321df5945SIngo Weinhold 2124fbd28219SIngo WeinholdFT2_COMPONENTS ?= gzip # support for gzip-compressed files. 2125fbd28219SIngo Weinhold autohint # auto-hinter 2126fbd28219SIngo Weinhold base # base component (public APIs) 2127fbd28219SIngo Weinhold bdf # BDF font driver 2128fbd28219SIngo Weinhold cache # cache sub-system 2129fbd28219SIngo Weinhold cff # CFF/CEF font driver 2130fbd28219SIngo Weinhold cid # Postscript CID-keyed font driver 21319ec866ccSDarkWyrm lzw # LZW routines 2132fbd28219SIngo Weinhold pcf # PCF font driver 2133fbd28219SIngo Weinhold pfr # PFR/TrueDoc font driver 2134fbd28219SIngo Weinhold psaux # Common Postscript routines module 2135fbd28219SIngo Weinhold pshinter # Postscript hinter module 2136fbd28219SIngo Weinhold psnames # Postscript names handling 2137fbd28219SIngo Weinhold raster # Monochrome rasterizer 2138fbd28219SIngo Weinhold smooth # Anti-aliased rasterizer 2139fbd28219SIngo Weinhold sfnt # SFNT-based format support routines 2140fbd28219SIngo Weinhold truetype # TrueType font driver 2141fbd28219SIngo Weinhold type1 # Postscript Type 1 font driver 2142fbd28219SIngo Weinhold type42 # Postscript Type 42 (embedded TrueType) driver 2143fbd28219SIngo Weinhold winfonts # Windows FON/FNT font driver 2144fbd28219SIngo Weinhold ; 2145fbd28219SIngo Weinhold 214621df5945SIngo Weinholdrule UseFreeTypeHeaders 214721df5945SIngo Weinhold{ 214821df5945SIngo Weinhold SubDirHdrs $(FT2_INCLUDE) ; 214921df5945SIngo Weinhold} 215021df5945SIngo Weinhold 215121df5945SIngo Weinholdrule UseFreeTypeObjectHeaders 215221df5945SIngo Weinhold{ 21539b60a208SIngo Weinhold # UseFreeTypeObjectHeaders <sources> [ : <objects> ] ; 21549b60a208SIngo Weinhold SourceHdrs $(1) : $(FT2_INCLUDE) : $(2) ; 215521df5945SIngo Weinhold} 215621df5945SIngo Weinhold 215721df5945SIngo Weinholdrule FT2_SubDir 215821df5945SIngo Weinhold{ 215921df5945SIngo Weinhold # FT2_SubDir <dir> 216021df5945SIngo Weinhold # <dir>: Components of a directory in the original hierarchy. 216121df5945SIngo Weinhold local dir = $(1) ; 216221df5945SIngo Weinhold local topDir ; 216321df5945SIngo Weinhold switch $(dir[1]) 216421df5945SIngo Weinhold { 216521df5945SIngo Weinhold case "include" : topDir = $(FT2_INCLUDE) ; 216621df5945SIngo Weinhold case src : topDir = $(FT2_SRC) ; 216721df5945SIngo Weinhold case * : ECHO "Unknown FreeType2 directory: " $(dir) ; 216821df5945SIngo Weinhold } 216921df5945SIngo Weinhold return [ FDirName $(topDir) $(dir[2-]) ] ; 217021df5945SIngo Weinhold} 217121df5945SIngo Weinhold 217221df5945SIngo Weinholdrule FT2_Library 217321df5945SIngo Weinhold{ 217421df5945SIngo Weinhold # FT2_Library <libname> : <sources> 217521df5945SIngo Weinhold # Builds objects from sources and adds the objects to the list of objects 217621df5945SIngo Weinhold # to be linked into the library. 217721df5945SIngo Weinhold # <libname> The name of the library. 217821df5945SIngo Weinhold # <sources> The sources. 217921df5945SIngo Weinhold 218021df5945SIngo Weinhold local library = lib$(1).so ; 218121df5945SIngo Weinhold local sources = $(2) ; 218228d2a30eSDaniel Reinhold SetupIncludes ; 218321df5945SIngo Weinhold SetupObjectsDir ; 218421df5945SIngo Weinhold MakeLocateObjects $(sources) ; 218521df5945SIngo Weinhold Objects $(sources) ; 218621df5945SIngo Weinhold LIBRARY_OBJECTS on $(library) += [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 218721df5945SIngo Weinhold} 218821df5945SIngo Weinhold 218921df5945SIngo Weinholdrule FT2_LinkLibrary 219021df5945SIngo Weinhold{ 219121df5945SIngo Weinhold # FT2_LinkLibrary <libname> 219221df5945SIngo Weinhold # Links the library from the objects build with FT2_LIBRARY before. 219321df5945SIngo Weinhold 219421df5945SIngo Weinhold local library = lib$(1).so ; 219521df5945SIngo Weinhold local objects = [ on $(library) return $(LIBRARY_OBJECTS) ] ; 219621df5945SIngo Weinhold ObjectReferences $(objects) ; 219721df5945SIngo Weinhold objects = [ FGristFiles $(objects) ] ; 219821df5945SIngo Weinhold SharedLibraryFromObjects $(1) : $(objects) ; 219921df5945SIngo Weinhold} 220021df5945SIngo Weinhold 22019b7a4b5dSshatty#------------------------------------------------------------------------------- 22029b7a4b5dSshatty# Packages for OBOS alpha/beta testers 22039b7a4b5dSshatty#------------------------------------------------------------------------------- 22049b7a4b5dSshatty 22059b7a4b5dSshattyrule Copy 22069b7a4b5dSshatty{ 22075c413522Sshatty Depends $(<) : $(>) ; 22089b7a4b5dSshatty SEARCH on $(>) = $(SEARCH_SOURCE) ; 22099b7a4b5dSshatty} 22109b7a4b5dSshatty 22119b7a4b5dSshattyactions Copy 22129b7a4b5dSshatty{ 221315716fddSPhilippe Houdoin cp -dp "$(>)" "$(<)" ; 221415716fddSPhilippe Houdoin if [ -f "$(>)" ] ; then copyattr "$(>)" "$(<)" ; fi ; 22159b7a4b5dSshatty} 22169b7a4b5dSshatty 22179b7a4b5dSshattyrule Packages 22189b7a4b5dSshatty{ 22199b7a4b5dSshatty local packagenames = $(1) ; 22209b7a4b5dSshatty local packagefiles = $(2) ; 22219b7a4b5dSshatty local path = $(3) ; 22229b7a4b5dSshatty for name in $(packagenames) { 22239b7a4b5dSshatty Package $(name) : $(packagefiles) : $(path) ; 22249b7a4b5dSshatty } 22259b7a4b5dSshatty} 22269b7a4b5dSshatty 22279b7a4b5dSshattyrule Package 22289b7a4b5dSshatty{ 22299b7a4b5dSshatty local packagename = $(1) ; 22309b7a4b5dSshatty local packagefiles = $(2) ; 22319b7a4b5dSshatty local path = $(3) ; 22329b7a4b5dSshatty 2233c06f365fSIngo Weinhold local packagezip = $(packagename:S=.zip:G=_packages) ; 22349b7a4b5dSshatty local packagedir = [ FDirName $(OBOS_PACKAGE_DIR) $(packagename) ] ; 22359b7a4b5dSshatty 22369b7a4b5dSshatty local installscript = install.sh ; 2237c06f365fSIngo Weinhold local packageinstallscript = $(installscript:G=_packages!$(packagename)) ; 22389b7a4b5dSshatty local installzip = install.zip ; 2239c06f365fSIngo Weinhold local packageinstallzip = $(installzip:G=_packages!$(packagename)) ; 22409b7a4b5dSshatty 2241c06f365fSIngo Weinhold local packageobjectdir 2242c06f365fSIngo Weinhold = [ FDirName $(OBOS_PACKAGE_OBJECT_DIR) $(packagename) ] ; 22439b7a4b5dSshatty local packagefiledir = [ FDirName $(packageobjectdir) $(path) ] ; 2244c06f365fSIngo Weinhold local packagefileinstallzip 2245c06f365fSIngo Weinhold = $(installzip:G=_package_objects!$(packagename)) ; 2246c06f365fSIngo Weinhold 2247c06f365fSIngo Weinhold # add the files to the install.zip 2248c06f365fSIngo Weinhold local packagefilegrist = [ FGrist _package_files $(packagename) $(path) ] ; 22499b7a4b5dSshatty for file in $(packagefiles) { 22509b7a4b5dSshatty if $(3[0]) = "boot" { 2251c06f365fSIngo Weinhold local packagefile = $(file:G=$(packagefilegrist)) ; 22529b7a4b5dSshatty MakeLocate $(packagefile) : $(packagefiledir) ; 22539b7a4b5dSshatty Copy $(packagefile) : $(file) ; 22549b7a4b5dSshatty Clean cleanPackages : $(packagefile) ; 22559b7a4b5dSshatty PackageInstallZip $(packagefileinstallzip) : $(packagefile) ; 22569b7a4b5dSshatty } else { 2257c06f365fSIngo Weinhold local packagefile = $(file:G=_packages!$(packagename)) ; 22589b7a4b5dSshatty MakeLocate $(packagefile) : $(packagedir) ; 225982bec102Sshatty Copy $(packagefile) : [ FGristFiles $(file) ] ; 22609b7a4b5dSshatty Clean cleanPackages : $(packagefile) ; 22619b7a4b5dSshatty Depends $(packagezip) : $(packagefile) ; 22629b7a4b5dSshatty } 22639b7a4b5dSshatty } 2264c06f365fSIngo Weinhold 2265c06f365fSIngo Weinhold # general setup for this packages -- only on first invocation 2266c06f365fSIngo Weinhold if ! $(_setup_$(packagename)) { 2267c06f365fSIngo Weinhold _setup_$(packagename) = true ; 2268c06f365fSIngo Weinhold 2269c06f365fSIngo Weinhold NotFile $(packagename) ; 2270b560211bSshatty LocalDepends packages : $(packagename) ; 2271c06f365fSIngo Weinhold 2272c06f365fSIngo Weinhold MakeLocate $(packagezip) : $(OBOS_PACKAGE_DIR) ; 2273c06f365fSIngo Weinhold MakeLocate $(packageinstallscript) : $(packagedir) ; 2274c06f365fSIngo Weinhold MakeLocate $(packageinstallzip) : $(packagedir) ; 2275c06f365fSIngo Weinhold MakeLocate $(packagefileinstallzip) : $(packageobjectdir) ; 2276c06f365fSIngo Weinhold 22779b7a4b5dSshatty PackageInstallScript $(packageinstallscript) : $(packagedir) ; 22789b7a4b5dSshatty LinkInstallZip $(packageinstallzip) : $(packagefileinstallzip) ; 22799b7a4b5dSshatty Depends $(packagename) : $(packagezip) ; 2280c06f365fSIngo Weinhold PackageZip $(packagezip) : $(packagedir) 2281c06f365fSIngo Weinhold : $(packageinstallscript) $(packageinstallzip) ; 2282c06f365fSIngo Weinhold } 2283c06f365fSIngo Weinhold 22849b7a4b5dSshatty} 22859b7a4b5dSshatty 22869b7a4b5dSshattyrule PackageZip 22879b7a4b5dSshatty{ 2288c06f365fSIngo Weinhold local dir = $(2:G=dir) ; 2289c06f365fSIngo Weinhold Depends $(1) : $(dir) $(3) ; 22909b7a4b5dSshatty Clean cleanPackages : $(1) ; 2291c06f365fSIngo Weinhold PackageZip1 $(1) : $(dir) ; 22929b7a4b5dSshatty} 22939b7a4b5dSshatty 2294c06f365fSIngo Weinholdactions together PackageZip1 { 22958042d2a0SPhilippe Houdoin cd "$(OBOS_PACKAGE_DIR)" ; 22968042d2a0SPhilippe Houdoin zip -rq "$(1:BS)" "$(2:BS)" ; 22979b7a4b5dSshatty} 22989b7a4b5dSshatty 22999b7a4b5dSshattyrule PackageInstallScript 23009b7a4b5dSshatty{ 23019b7a4b5dSshatty MakeLocate $(1) : $(2) ; 23029b7a4b5dSshatty Clean cleanPackages : $(1) ; 2303c06f365fSIngo Weinhold PackageInstallScript1 $(1) : $(2:G=dir) ; 23049b7a4b5dSshatty} 23059b7a4b5dSshatty 2306c06f365fSIngo Weinholdactions together PackageInstallScript1 23079b7a4b5dSshatty{ 230851fe1be4Sshattyecho '#!/bin/sh 230951fe1be4Sshattybase=`dirname "$0"` 23108042d2a0SPhilippe Houdoincd "$base" 231151fe1be4Sshattyif [ -n "$TTY" ] 231251fe1be4Sshattythen 231351fe1be4Sshatty unzip -d / install.zip 231451fe1be4Sshattyelse 231551fe1be4Sshatty response=`alert "Would you like to automatically overwrite existing files, or receive a prompt?" "Overwrite" "Prompt"` 231651fe1be4Sshatty if [ $response == "Overwrite" ] 231751fe1be4Sshatty then 231851fe1be4Sshatty unzip -od / install.zip 231951fe1be4Sshatty alert "Finished installing" "Thanks" 232051fe1be4Sshatty else 232151fe1be4Sshatty if [ -e /boot/beos/apps/Terminal ] 232251fe1be4Sshatty then 232351fe1be4Sshatty terminal=/boot/beos/apps/Terminal 232451fe1be4Sshatty else 232551fe1be4Sshatty terminal=`query Terminal | head -1` 232651fe1be4Sshatty fi 23278042d2a0SPhilippe Houdoin $terminal -t "installer" /bin/sh "$0" 232851fe1be4Sshatty fi 23298042d2a0SPhilippe Houdoinfi' > "$(1)" ; 23308042d2a0SPhilippe Houdoin chmod 755 "$(1)" ; 23319b7a4b5dSshatty} 23329b7a4b5dSshatty 23339b7a4b5dSshattyrule PackageInstallZip 23349b7a4b5dSshatty{ 23359b7a4b5dSshatty Depends $(1) : $(2) ; 23369b7a4b5dSshatty Clean cleanPackages : $(1) ; 23379b7a4b5dSshatty} 23389b7a4b5dSshatty 23399b7a4b5dSshattyactions together PackageInstallZip 23409b7a4b5dSshatty{ 23418042d2a0SPhilippe Houdoin cd "$(1:P)" ; 23428042d2a0SPhilippe Houdoin zip -rqy "$(1:BS)" boot ; 23439b7a4b5dSshatty} 23449b7a4b5dSshatty 23459b7a4b5dSshattyrule LinkInstallZip 23469b7a4b5dSshatty{ 23479b7a4b5dSshatty Depends $(1) : $(2) ; 23489b7a4b5dSshatty Clean cleanPackages : $(1) ; 23499b7a4b5dSshatty} 23509b7a4b5dSshatty 23519b7a4b5dSshattyactions together LinkInstallZip 23529b7a4b5dSshatty{ 23538042d2a0SPhilippe Houdoin ln -sf "`pwd`/$(2)" "$(1)" ; 23549b7a4b5dSshatty} 2355e91f3ca1Sbeveloper 2356e91f3ca1Sbeveloperrule SubIncludeGPL 2357e91f3ca1Sbeveloper{ 2358e91f3ca1Sbeveloper # SubInclude rule that can be used to conditionally include GPL licensed add-ons 2359e91f3ca1Sbeveloper if $(INCLUDE_GPL_ADDONS) = 1 { 2360e91f3ca1Sbeveloper SubInclude $(1) ; 2361e91f3ca1Sbeveloper } 2362e91f3ca1Sbeveloper} 2363