19eea4522SIngo Weinhold# Vanilla Jam compatibility 29eea4522SIngo Weinholdif ! $(INVOCATION_SUBDIR_SET) { 39eea4522SIngo Weinhold 49eea4522SIngo Weinhold rule FIsPrefix 59eea4522SIngo Weinhold { 69eea4522SIngo Weinhold # FIsPrefix <a> : <b> ; 79eea4522SIngo Weinhold # Returns true, if list <a> is a prefix (a proper one or equal) of 89eea4522SIngo Weinhold # list <b>, an empty list otherwise. 99eea4522SIngo Weinhold local a = $(1) ; 109eea4522SIngo Weinhold local b = $(2) ; 119eea4522SIngo Weinhold while $(a) && $(a[1]) = $(b[1]) { 129eea4522SIngo Weinhold a = $(a[2-]) ; 139eea4522SIngo Weinhold b = $(b[2-]) ; 149eea4522SIngo Weinhold } 159eea4522SIngo Weinhold 169eea4522SIngo Weinhold if $(a) { 179eea4522SIngo Weinhold return ; 189eea4522SIngo Weinhold } else { 199eea4522SIngo Weinhold return true ; 209eea4522SIngo Weinhold } 219eea4522SIngo Weinhold } 229eea4522SIngo Weinhold 239eea4522SIngo Weinhold rule LocalClean { Clean $(1) : $(2) ; } 249eea4522SIngo Weinhold 259eea4522SIngo Weinhold rule LocalDepends { Depends $(1) : $(2) ; } 269eea4522SIngo Weinhold 279eea4522SIngo Weinhold} # vanilla Jam compatibility 289eea4522SIngo Weinhold 294ff6d49fSIngo Weinhold# The directory for build system specific files 304ff6d49fSIngo WeinholdOBOS_BUILD_DIR = [ FDirName $(OBOS_TOP) build ] ; 314ff6d49fSIngo Weinhold 324ff6d49fSIngo Weinhold# Cache files for header scanning and jamfile caching 334ff6d49fSIngo WeinholdHCACHEFILE = header_cache ; 344ff6d49fSIngo WeinholdJCACHEFILE = jamfile_cache ; 354ff6d49fSIngo WeinholdLOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(OBOS_BUILD_DIR) ; 369eea4522SIngo Weinhold 3752a38012Sejakowatz# Include BuildConfig 3852a38012Sejakowatz{ 394ff6d49fSIngo Weinhold local buildConfig = [ GLOB $(OBOS_BUILD_DIR) : BuildConfig ] ; 4052a38012Sejakowatz if ! $(buildConfig) 4152a38012Sejakowatz { 424ff6d49fSIngo Weinhold ECHO "No BuildConfig found in $(OBOS_BUILD_DIR)!" ; 434ff6d49fSIngo Weinhold EXIT "Run ./configure in the source tree's root directory first!" ; 4452a38012Sejakowatz } 454ff6d49fSIngo Weinhold LOCATE on BuildConfig = $(OBOS_BUILD_DIR) ; 464ff6d49fSIngo Weinhold include BuildConfig ; 4752a38012Sejakowatz} 4852a38012Sejakowatz 498c17a26bSIngo Weinhold# analyze GCC version 508c17a26bSIngo Weinholdif ! $(GCC_RAW_VERSION) { 518c17a26bSIngo Weinhold ECHO "Variable GCC_RAW_VERSION not set. Please run ./configure or" ; 528c17a26bSIngo Weinhold EXIT "specify it manually." ; 538c17a26bSIngo Weinhold} 548c17a26bSIngo WeinholdGCC_VERSION = ; 558c17a26bSIngo Weinhold{ 568c17a26bSIngo Weinhold # split the raw version string at `.' and `-' characters 578c17a26bSIngo Weinhold local version = $(GCC_RAW_VERSION) ; 588c17a26bSIngo Weinhold while $(version) { 598c17a26bSIngo Weinhold local split = [ Match "([^.-]*)[.-](.*)" : $(version) ] ; 608c17a26bSIngo Weinhold if $(split) { 618c17a26bSIngo Weinhold GCC_VERSION += $(split[1]) ; 628c17a26bSIngo Weinhold version = $(split[2]) ; 638c17a26bSIngo Weinhold } else { 648c17a26bSIngo Weinhold GCC_VERSION += $(version) ; 658c17a26bSIngo Weinhold version = ; 668c17a26bSIngo Weinhold } 678c17a26bSIngo Weinhold } 688c17a26bSIngo Weinhold} 698c17a26bSIngo Weinhold 705dc4e1efSIngo Weinhold# Save the platform default headers. 715dc4e1efSIngo WeinholdPLATFORM_DEFAULT_HEADERS = $(HDRS) ; 725dc4e1efSIngo Weinhold 73a6c008e1Sbeveloper# We do not include any local BeOS system headers by default 74dd9f8062SIngo WeinholdCCFLAGS += -nostdinc ; 75dd9f8062SIngo WeinholdC++FLAGS += -nostdinc ; 76a6c008e1Sbeveloper 7752a38012Sejakowatz# Determine if we're building on PPC or x86 7852a38012Sejakowatz# Determine mimetype of executable 7952a38012Sejakowatz# Cross compiling can come later 8052a38012Sejakowatz 81c9882d9eSAxel DörflerTARGET_CPU ?= $(OSPLAT:L) ; 821f622a7bSAxel DörflerOBOS_VERSION ?= R1 ; 831f622a7bSAxel Dörfler 841f622a7bSAxel Dörflerswitch $(TARGET_CPU) { 851f622a7bSAxel Dörfler case ppc : 861f622a7bSAxel Dörfler { 8752a38012Sejakowatz if $(METROWERKS) { 881f622a7bSAxel Dörfler # at least parts of OpenBeOS still can be compiled with 891f622a7bSAxel Dörfler # the Metrowerks compiler on BeOS/PPC 9052a38012Sejakowatz OBOS_TARGET_TYPE ?= "application/x-be-executable" ; 9152a38012Sejakowatz } else { 9252a38012Sejakowatz OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; 931f622a7bSAxel Dörfler } 94dd22481eSAxel Dörfler DEFINES += __POWERPC__ ; 95e29d8533SAxel Dörfler OBOS_BOOT_PLATFORM = openfirmware ; 961f622a7bSAxel Dörfler } 971f622a7bSAxel Dörfler case x86 : 981f622a7bSAxel Dörfler { 991f622a7bSAxel Dörfler # nothing special to do here... 100e29d8533SAxel Dörfler OBOS_BOOT_PLATFORM = bios_ia32 ; 1011f622a7bSAxel Dörfler } 1021f622a7bSAxel Dörfler case * : 1031f622a7bSAxel Dörfler Exit "Currently unsupported build platform:" $(TARGET_CPU) ; 1041f622a7bSAxel Dörfler} 1051f622a7bSAxel Dörfler 1061f622a7bSAxel Dörfler# set target specific variables 1071f622a7bSAxel Dörfler{ 1081f622a7bSAxel Dörfler #Echo "Building for" $(TARGET_CPU) ; 1091f622a7bSAxel Dörfler 1101f622a7bSAxel Dörfler OBOS_TARGET ?= $(TARGET_CPU).$(OBOS_VERSION) ; 1111f622a7bSAxel Dörfler OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; 1121f622a7bSAxel Dörfler OBOS_ARCH ?= $(TARGET_CPU) ; 1131f622a7bSAxel Dörfler OBOS_TARGET_DEFINE ?= "ARCH_"$(TARGET_CPU) ; 11452a38012Sejakowatz} 11552a38012Sejakowatz 11665c62a01SIngo Weinhold# Disable warnings only if WARNINGS is set to 0 117e5dc2d93Sbeveloper# Should be enabled by default later 11896d27465SIngo Weinhold# 11965c62a01SIngo WeinholdWARNINGS ?= 1 ; 12065c62a01SIngo Weinholdif $(WARNINGS) = 1 { 121e5dc2d93Sbeveloper # For an explanation of the different warning options, see: 122e5dc2d93Sbeveloper # http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html 123e5dc2d93Sbeveloper # to get even more warnings, add: 124e5dc2d93Sbeveloper # -Wwrite-strings (doesn't work well with some Be headers) 125e5dc2d93Sbeveloper # -Wundef (dito) 126e5dc2d93Sbeveloper # -Wconversion (gets you many warnings about implicit conversions) 127e5dc2d93Sbeveloper # -W (gets you even more warnigs) 128dd9f8062SIngo Weinhold CCFLAGS += -Wall -Wno-multichar -Wmissing-prototypes ; 129dd9f8062SIngo Weinhold CCFLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; 130dd9f8062SIngo Weinhold C++FLAGS += -Wall -Wno-multichar -Wmissing-prototypes -Wno-ctor-dtor-privacy -Woverloaded-virtual ; 131dd9f8062SIngo Weinhold C++FLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; 13298cc804cSAxel Dörfler} else { 13398cc804cSAxel Dörfler CCFLAGS += -Wno-multichar ; 13498cc804cSAxel Dörfler C++FLAGS += -Wno-multichar ; 135e5dc2d93Sbeveloper} 136e5dc2d93Sbeveloper 13798cc804cSAxel Dörfler# standard kernel C/C++ flags 1380ff867c2SbeveloperKERNEL_CCFLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; 1390ff867c2SbeveloperKERNEL_CCFLAGS += -fno-builtin -D$(OBOS_TARGET_DEFINE) ; 1400ff867c2SbeveloperKERNEL_CCFLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ; 14198cc804cSAxel DörflerKERNEL_C++FLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; 14298cc804cSAxel DörflerKERNEL_C++FLAGS += -fno-builtin -fno-exceptions -fno-rtti -D$(OBOS_TARGET_DEFINE) ; 14398cc804cSAxel DörflerKERNEL_C++FLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) ; 144bbb6f2d4SAxel Dörflerif $(GCC_VERSION[1]) >= 3 { 145bbb6f2d4SAxel Dörfler KERNEL_C++FLAGS += -fno-use-cxa-atexit ; 146bbb6f2d4SAxel Dörfler} 1470ff867c2Sbeveloper 1489eea4522SIngo Weinhold# We might later want to introduce debug levels or handle the whole issue 1499eea4522SIngo Weinhold# differently. For now there's only on or off. 1509eea4522SIngo Weinhold# 15165c62a01SIngo WeinholdDEBUG ?= 0 ; 15265c62a01SIngo Weinholdif $(DEBUG) != 0 { 1539eea4522SIngo Weinhold OPTIM ?= -O0 ; 15465c62a01SIngo Weinhold CCFLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 15565c62a01SIngo Weinhold C++FLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 15665c62a01SIngo Weinhold KERNEL_CCFLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 15765c62a01SIngo Weinhold KERNEL_C++FLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 1589eea4522SIngo Weinhold LINKFLAGS += -g ; 1599eea4522SIngo Weinhold} else { 1609eea4522SIngo Weinhold OPTIM ?= -O2 ; 1619eea4522SIngo Weinhold} 16296d27465SIngo Weinhold# 16396d27465SIngo Weinhold# To disable for the tests OPTIM and DEBUG are overridden, set the environment 16496d27465SIngo Weinhold# variable NO_TEST_DEBUG. 1659eea4522SIngo Weinhold 16616fa4445SIngo Weinhold# Instructs the Library rule to not make its object files temporary. 167f1e077f8SIngo Weinhold# This is needed as some objects are used in a static library and for an 16816fa4445SIngo Weinhold# executable. 16916fa4445SIngo WeinholdKEEPOBJS = true ; 17016fa4445SIngo Weinhold 1717bc56df1SIngo Weinhold# under BeOS use copyattr instead of cp 1727bc56df1SIngo Weinholdif $(OS) = BEOS 1737bc56df1SIngo Weinhold{ 1747bc56df1SIngo Weinhold CP = copyattr --data ; 1757bc56df1SIngo Weinhold} 1767bc56df1SIngo Weinhold 17752a38012Sejakowatz# If no OBOS_OBJECT_TARGET is not defined yet, use our default directory and 17852a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 17952a38012Sejakowatz# builds mixing objects from different targets). 18052a38012Sejakowatzif ! $(OBOS_OBJECT_TARGET) { 18152a38012Sejakowatz OBOS_OBJECT_TARGET ?= [ FDirName $(OBOS_TOP) objects $(OBOS_TARGET) ] ; 18252a38012Sejakowatz} 18352a38012Sejakowatz 18452a38012Sejakowatz# If no OBOS_DISTRO_TARGET is not defined yet, use our default directory and 18552a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 18652a38012Sejakowatz# builds mixing executables from different targets). 18752a38012Sejakowatzif ! $(OBOS_DISTRO_TARGET) { 18852a38012Sejakowatz OBOS_DISTRO_TARGET ?= [ FDirName $(OBOS_TOP) distro $(OBOS_TARGET) ] ; 18952a38012Sejakowatz} 19052a38012Sejakowatz 19152a38012Sejakowatz# Set our version number if not already set and mark it as a developer build 19252a38012Sejakowatzif ! $(OBOS_BUILD_VERSION) { 19352a38012Sejakowatz OBOS_BUILD_VERSION ?= "1 0 0 a 1" ; 19452a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Developer Build" ; 19552a38012Sejakowatz} 19652a38012Sejakowatz 19752a38012Sejakowatz# If OBOS_BUILD_VERSION is set, but OBOS_BUILD_DESCRIPTION isn't, mark it as 19852a38012Sejakowatz# an unknown build. 19952a38012Sejakowatzif ! $(OBOS_BUILD_DESCRIPTION) { 20052a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Unknown Build" ; 20152a38012Sejakowatz} 20252a38012Sejakowatz 203505554b4SIngo Weinhold# Relative subdirs for distro dir 204505554b4SIngo WeinholdOBOS_ADDON_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system add-ons ] ; 2055f281ed5SejakowatzOBOS_APPS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos apps ] ; 206f06de7f3SIngo WeinholdOBOS_BIN_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos bin ] ; 207505554b4SIngo WeinholdOBOS_ETC_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos etc ] ; 208505554b4SIngo WeinholdOBOS_FONTS_DIR ?= [ FDirName $(OBOS_ETC_DIR) fonts ] ; 209505554b4SIngo WeinholdOBOS_KERNEL_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system ] ; 21052a38012SejakowatzOBOS_PREFS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos preferences ] ; 21152a38012SejakowatzOBOS_SERVER_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system servers ] ; 21252a38012SejakowatzOBOS_SHLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ; 213e9230d05SIngo WeinholdOBOS_STLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) develop lib 214e9230d05SIngo Weinhold $(OBOS_ARCH) ] ; 21552a38012SejakowatzOBOS_TEST_DIR ?= [ FDirName $(OBOS_TOP) tests ] ; 21652a38012Sejakowatz 21752a38012SejakowatzOBOS_KERNEL_CONFIG = config.$(OBOS_ARCH).ini ; 21852a38012SejakowatzOBOS_KERNEL = kernel.$(OBOS_ARCH) ; 21952a38012SejakowatzOBOS_FLOPPY = floppy.$(OBOS_ARCH) ; 22052a38012Sejakowatz 22152a38012Sejakowatzrule SetupIncludes 22252a38012Sejakowatz{ 223cfc7b456Sshatty # XXX add "opengl" later 224cfc7b456Sshatty 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 ; 225a6c008e1Sbeveloper 22628d2a30eSDaniel Reinhold # Overwrite any exiting content when changing HDRS. This rule may be invoked multiple times. 227a6c008e1Sbeveloper 228a6c008e1Sbeveloper # Use headers directory, to allow to do things like include <posix/string.h> 22928d2a30eSDaniel Reinhold HDRS = [ FDirName $(OBOS_TOP) headers ] ; 230a6c008e1Sbeveloper 231a6c008e1Sbeveloper # Use posix headers directory 23228d2a30eSDaniel Reinhold HDRS += [ FDirName $(OBOS_TOP) headers posix ] ; 233a6c008e1Sbeveloper 234a6c008e1Sbeveloper # Use public OS header directories 23528d2a30eSDaniel Reinhold HDRS += [ PublicHeaders $(os_includes) ] ; 236a6c008e1Sbeveloper 237a6c008e1Sbeveloper # Used as a fallback, the R5 header directories (we should remove this as soon as possible) 23828d2a30eSDaniel Reinhold HDRS += /boot/develop/headers/posix /boot/develop/headers/cpp ; 23909c5682dSIngo Weinhold 24009c5682dSIngo Weinhold # The platform dependent headers. 24109c5682dSIngo Weinhold HDRS += $(PLATFORM_HEADERS) ; 24252a38012Sejakowatz} 24352a38012Sejakowatz 244dd9f8062SIngo Weinholdrule SetupR5Includes 245dd9f8062SIngo Weinhold{ 246dd9f8062SIngo Weinhold # Unsets HDRS, so that the OBOS headers do not `shadow' the system headers. 247dd9f8062SIngo Weinhold HDRS = ; 248dd9f8062SIngo Weinhold} 249dd9f8062SIngo Weinhold 2505dc4e1efSIngo Weinholdrule SetupDefaultIncludes 2515dc4e1efSIngo Weinhold{ 2525dc4e1efSIngo Weinhold # Resets HDRS to the default headers for the build platform. 2535dc4e1efSIngo Weinhold HDRS = $(PLATFORM_DEFAULT_HEADERS) ; 2545dc4e1efSIngo Weinhold} 2555dc4e1efSIngo Weinhold 25652a38012Sejakowatz#------------------------------------------------------------------------------- 25752a38012Sejakowatz# Things Jam needs in order to work :) 25852a38012Sejakowatz#------------------------------------------------------------------------------- 25952a38012Sejakowatz 2608d3308d9SIngo Weinholdrule Object 2618d3308d9SIngo Weinhold{ 2628d3308d9SIngo Weinhold # This is basically the original Jambase 2.4 Object rule stripped by 2638d3308d9SIngo Weinhold # comments. Only the final switch statement has been changed to allow 2648d3308d9SIngo Weinhold # intermediate C++ files for Yacc and Lex. 2658d3308d9SIngo Weinhold 2668d3308d9SIngo Weinhold LocalClean clean : $(<) ; 2678d3308d9SIngo Weinhold 2688d3308d9SIngo Weinhold MakeLocate $(<) : $(LOCATE_TARGET) ; 2698d3308d9SIngo Weinhold SEARCH on $(>) = $(SEARCH_SOURCE) ; 2708d3308d9SIngo Weinhold 2718d3308d9SIngo Weinhold HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ; 2728d3308d9SIngo Weinhold 2738d3308d9SIngo Weinhold HDRRULE on $(>) = HdrRule ; 2748d3308d9SIngo Weinhold HDRSCAN on $(>) = $(HDRPATTERN) ; 2758d3308d9SIngo Weinhold HDRSEARCH on $(>) = 2768d3308d9SIngo Weinhold $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ; 2778d3308d9SIngo Weinhold 2788d3308d9SIngo Weinhold HDRGRIST on $(>) = $(HDRGRIST) ; 2798d3308d9SIngo Weinhold 2808d3308d9SIngo Weinhold DEFINES on $(<) += $(DEFINES) ; 2818d3308d9SIngo Weinhold 2828d3308d9SIngo Weinhold # if source is not .c, generate .c with specific rule 2838d3308d9SIngo Weinhold 2848d3308d9SIngo Weinhold switch $(>:S) 2858d3308d9SIngo Weinhold { 2868d3308d9SIngo Weinhold case .asm : As $(<) : $(>) ; 2878d3308d9SIngo Weinhold case .c : Cc $(<) : $(>) ; 2888d3308d9SIngo Weinhold case .C : C++ $(<) : $(>) ; 2898d3308d9SIngo Weinhold case .cc : C++ $(<) : $(>) ; 2908d3308d9SIngo Weinhold case .cpp : C++ $(<) : $(>) ; 2918d3308d9SIngo Weinhold case .f : Fortran $(<) : $(>) ; 2928d3308d9SIngo Weinhold case .l : if [ on $(2) return $(GENERATE_C++) ] { 2938d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 2948d3308d9SIngo Weinhold LexC++ $(<:S=.cpp) : $(>) ; 2958d3308d9SIngo Weinhold } else { 2968d3308d9SIngo Weinhold Cc $(<) : $(<:S=.c) ; 2978d3308d9SIngo Weinhold Lex $(<:S=.c) : $(>) ; 2988d3308d9SIngo Weinhold } 2998d3308d9SIngo Weinhold case .s : As $(<) : $(>) ; 3008d3308d9SIngo Weinhold case .y : if [ on $(2) return $(GENERATE_C++) ] { 3018d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 3028d3308d9SIngo Weinhold Bison $(<:S=.cpp) : $(>) ; 3038d3308d9SIngo Weinhold } else { 3048d3308d9SIngo Weinhold Cc $(<) : $(<:S=$(YACCGEN)) ; 3058d3308d9SIngo Weinhold Yacc $(<:S=$(YACCGEN)) : $(>) ; 3068d3308d9SIngo Weinhold } 3078d3308d9SIngo Weinhold case * : UserObject $(<) : $(>) ; 3088d3308d9SIngo Weinhold } 3098d3308d9SIngo Weinhold} 3108d3308d9SIngo Weinhold 31152a38012Sejakowatzrule UserObject 31252a38012Sejakowatz{ 31352a38012Sejakowatz switch $(2) 31452a38012Sejakowatz { 31552a38012Sejakowatz case *.S : assemble $(1) : $(2) ; 31608125d07SIngo Weinhold case *.o : return ; 31752a38012Sejakowatz case * : ECHO "unknown suffix on" $(2) ; 31852a38012Sejakowatz } 31952a38012Sejakowatz} 32052a38012Sejakowatz 32152a38012Sejakowatz# Override the default to give "prettier" command lines. 32252a38012Sejakowatzactions Cc 32352a38012Sejakowatz{ 3240931b8f9SIngo Weinhold $(CC) -c "$(2)" $(CCFLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; 32552a38012Sejakowatz} 32652a38012Sejakowatz 32752a38012Sejakowatzactions C++ 32852a38012Sejakowatz{ 3290931b8f9SIngo Weinhold $(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; 33052a38012Sejakowatz} 33152a38012Sejakowatz 33252a38012Sejakowatz 33352a38012Sejakowatz#------------------------------------------------------------------------------- 33452a38012Sejakowatz# General High-level OBOS target rules 33552a38012Sejakowatz#------------------------------------------------------------------------------- 33652a38012Sejakowatz 3375f281ed5Sejakowatzrule App 3385f281ed5Sejakowatz{ 339007eb5f2SIngo Weinhold # App <name> : <sources> : <libraries> ; 340a6c008e1Sbeveloper SetupIncludes ; 3415f281ed5Sejakowatz SetupObjectsDir ; 342007eb5f2SIngo Weinhold Main $(1) : $(2) ; 343007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_APPS_DIR) ; 344007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 345007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 346007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 3475f281ed5Sejakowatz} 3485f281ed5Sejakowatz 349f06de7f3SIngo Weinholdrule BinCommand 350f06de7f3SIngo Weinhold{ 351f06de7f3SIngo Weinhold # BinCommand <name> : <sources> : <libraries> ; 352a6c008e1Sbeveloper SetupIncludes ; 353f06de7f3SIngo Weinhold SetupObjectsDir ; 354f06de7f3SIngo Weinhold Main $(1) : $(2) ; 355f06de7f3SIngo Weinhold MakeLocate $(1) : $(OBOS_BIN_DIR) ; 356f06de7f3SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 357007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 358007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 359f06de7f3SIngo Weinhold} 360f06de7f3SIngo Weinhold 361f06de7f3SIngo Weinholdrule StdBinCommands 362f06de7f3SIngo Weinhold{ 363f06de7f3SIngo Weinhold # StdBinCommands <sources> : <libs> ; 364a6c008e1Sbeveloper SetupIncludes ; 365a6c008e1Sbeveloper SetupObjectsDir ; 366f06de7f3SIngo Weinhold local libs = $(2) ; 3679342c27aSIngo Weinhold local source ; 368f06de7f3SIngo Weinhold for source in $(1) 369f06de7f3SIngo Weinhold { 370f06de7f3SIngo Weinhold local target = $(source:S=) ; 371f06de7f3SIngo Weinhold target = [ FGristFiles $(target) ] ; 372a6c008e1Sbeveloper 3733b4190abSbeveloper BinCommand $(target) : $(source) : $(libs) ; 374f06de7f3SIngo Weinhold } 375f06de7f3SIngo Weinhold} 376f06de7f3SIngo Weinhold 37752a38012Sejakowatzrule Preference 37852a38012Sejakowatz{ 379007eb5f2SIngo Weinhold # Preference <name> : <sources> : <libraries> ; 380a6c008e1Sbeveloper SetupIncludes ; 38152a38012Sejakowatz SetupObjectsDir ; 382007eb5f2SIngo Weinhold Main $(1) : $(2) ; 383007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_PREFS_DIR) ; 384007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 385007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 386007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 38752a38012Sejakowatz} 38852a38012Sejakowatz 38952a38012Sejakowatzrule Server 39052a38012Sejakowatz{ 391007eb5f2SIngo Weinhold # Server <name> : <sources> : <libraries> ; 39252a38012Sejakowatz 393a6c008e1Sbeveloper SetupIncludes ; 39452a38012Sejakowatz SetupObjectsDir ; 395007eb5f2SIngo Weinhold Main $(1) : $(2) ; 396007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_SERVER_DIR) ; 397007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 398007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 399007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 40052a38012Sejakowatz} 40152a38012Sejakowatz 40252a38012Sejakowatz# test pseudo targets 40352a38012SejakowatzNOTFILE obostests ; 40452a38012SejakowatzNOTFILE r5tests ; 40552a38012Sejakowatz 406d1f6c38fSTyler Dauwalderrule CommonTestLib 407d1f6c38fSTyler Dauwalder{ 408c5ff4aa6STyler Dauwalder # CommonTestLib <target> : <sources> : <obos libraries> 4099285de51STyler Dauwalder # : <r5 libraries> : <test libraries> : <public headers>; 410d1f6c38fSTyler Dauwalder # Builds a unit test for both OBOS and R5 modules. 411d1f6c38fSTyler Dauwalder # <target> The name of the target. 412d1f6c38fSTyler Dauwalder # <sources> The list of sources. 413d1f6c38fSTyler Dauwalder # <obos libraries> A list of link libraries for the OBOS tests (as passed 414d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 415d1f6c38fSTyler Dauwalder # <r5 libraries> A list of link libraries for the R5 tests (as passed 416d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 4179285de51STyler Dauwalder # <test libraries> A list of link libraries for both OBOS tests and R5 tests 4189285de51STyler Dauwalder # that have a common name (i.e. specify libx.so and the OBOS tests will link 4199285de51STyler Dauwalder # to libx.so and the R5 tests will link to libx_r5.so). 420d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 421d1f6c38fSTyler Dauwalder # UsePublicHeaders). 422d1f6c38fSTyler Dauwalder 423c5ff4aa6STyler Dauwalder TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester lib ] : $(3) $(5) : $(6) ; 424c5ff4aa6STyler Dauwalder R5TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester_r5 lib ] : $(4) [ R5SharedLibraryNames $(5) ] ; 425d1f6c38fSTyler Dauwalder} 426d1f6c38fSTyler Dauwalder 427d1f6c38fSTyler Dauwalderrule TestLib 428d1f6c38fSTyler Dauwalder{ 429d1f6c38fSTyler Dauwalder # TestLib <target> : <sources> : <dest> : <libraries> : <public headers> 430d1f6c38fSTyler Dauwalder # Builds a unit test library for an OBOS module. 431d1f6c38fSTyler Dauwalder # <target> The name of the target. 432d1f6c38fSTyler Dauwalder # <sources> The list of sources. 433d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 434d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 435d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 436d1f6c38fSTyler Dauwalder # UsePublicHeaders). 437d1f6c38fSTyler Dauwalder 438d1f6c38fSTyler Dauwalder local target = $(1) ; 439d1f6c38fSTyler Dauwalder local sources = $(2) ; 440d1f6c38fSTyler Dauwalder local dest = $(3) ; 441d1f6c38fSTyler Dauwalder local libraries = $(4) ; 442d1f6c38fSTyler Dauwalder local headerDirs = $(5) ; 4439342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 444d1f6c38fSTyler Dauwalder 4459342c27aSIngo Weinhold # Our Main replacement. 4469342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 4479342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 448d1f6c38fSTyler Dauwalder 449d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 4500d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 4510d1cdd94SIngo Weinhold Depends obostests : $(target) ; 452d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 453d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 454d1f6c38fSTyler Dauwalder} 455d1f6c38fSTyler Dauwalder 456d1f6c38fSTyler Dauwalderrule R5TestLib 457d1f6c38fSTyler Dauwalder{ 458c5ff4aa6STyler Dauwalder # R5TestLib <target> : <sources> : <dest> : <libraries> 459d1f6c38fSTyler Dauwalder # Builds a unit test for an R5 module. "_r5" is appended to the object 460d1f6c38fSTyler Dauwalder # and the target name. 461d1f6c38fSTyler Dauwalder # <target> The name of the target. 462d1f6c38fSTyler Dauwalder # <sources> The list of sources. 463d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 464d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 465d1f6c38fSTyler Dauwalder 466d1f6c38fSTyler Dauwalder local target = $(1:B)_r5$(1:S) ; 467d1f6c38fSTyler Dauwalder local sources = $(2) ; 468c5ff4aa6STyler Dauwalder local dest = $(3) ; 469d1f6c38fSTyler Dauwalder local libraries = $(4) ; 470d1f6c38fSTyler Dauwalder local objects = [ R5ObjectNames $(sources) ] ; 471d1f6c38fSTyler Dauwalder 472d1f6c38fSTyler Dauwalder # Our Main replacement. 473d1f6c38fSTyler Dauwalder MainFromObjects $(target) : $(objects) ; 4749342c27aSIngo Weinhold TestObjects $(sources) : : true ; 475d1f6c38fSTyler Dauwalder 476d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 4770d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 4780d1cdd94SIngo Weinhold Depends r5tests : $(target) ; 479d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 480d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 481d1f6c38fSTyler Dauwalder} 482d1f6c38fSTyler Dauwalder 48352a38012Sejakowatzrule CommonUnitTest 48452a38012Sejakowatz{ 48552a38012Sejakowatz # CommonUnitTest <target> : <sources> : <dest> : <obos libraries> 48652a38012Sejakowatz # : <r5 libraries> : <public headers>; 48752a38012Sejakowatz # Builds a unit test for both OBOS and R5 modules. 48852a38012Sejakowatz # <target> The name of the target. 48952a38012Sejakowatz # <sources> The list of sources. 49052a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 49152a38012Sejakowatz # <obos libraries> A list of link libraries for the OBOS tests (as passed 49252a38012Sejakowatz # to LinkSharedOSLibs). 49352a38012Sejakowatz # <r5 libraries> A list of link libraries for the R5 tests (as passed 49452a38012Sejakowatz # to LinkSharedOSLibs). 49552a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 49652a38012Sejakowatz # UsePublicHeaders). 49752a38012Sejakowatz 49852a38012Sejakowatz UnitTest $(1) : $(2) : $(3) : $(4) : $(6) ; 49952a38012Sejakowatz R5UnitTest $(1) : $(2) : $(3) : $(5) ; 50052a38012Sejakowatz} 50152a38012Sejakowatz 50252a38012Sejakowatzrule UnitTest 50352a38012Sejakowatz{ 50452a38012Sejakowatz # UnitTest <target> : <sources> : <dest> : <libraries> : <public headers> 50552a38012Sejakowatz # Builds a unit test for an OBOS module. 50652a38012Sejakowatz # <target> The name of the target. 50752a38012Sejakowatz # <sources> The list of sources. 50852a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 50952a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 51052a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 51152a38012Sejakowatz # UsePublicHeaders). 51252a38012Sejakowatz 51352a38012Sejakowatz local target = $(1) ; 51452a38012Sejakowatz local sources = $(2) ; 51552a38012Sejakowatz local dest = $(3) ; 51652a38012Sejakowatz local libraries = $(4) ; 51752a38012Sejakowatz local headerDirs = $(5) ; 5189342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 51952a38012Sejakowatz 5209342c27aSIngo Weinhold # Our Main replacement. 5219342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 5229342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 5233b9eae39SIngo Weinhold 52452a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 5259eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 5269eea4522SIngo Weinhold Depends obostests : $(target) ; 52752a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 52852a38012Sejakowatz} 52952a38012Sejakowatz 53052a38012Sejakowatzrule R5UnitTest 53152a38012Sejakowatz{ 53252a38012Sejakowatz # R5UnitTest <target> : <sources> : <dest> : <libraries> 53352a38012Sejakowatz # Builds a unit test for an R5 module. "_r5" is appended to the object 53452a38012Sejakowatz # and the target name. 53552a38012Sejakowatz # <target> The name of the target. 53652a38012Sejakowatz # <sources> The list of sources. 53752a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 53852a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 53952a38012Sejakowatz 54052a38012Sejakowatz local target = $(1)_r5 ; 54152a38012Sejakowatz local sources = $(2) ; 54252a38012Sejakowatz local dest = $(3) ; 54352a38012Sejakowatz local libraries = $(4) ; 54452a38012Sejakowatz local objects = [ R5ObjectNames $(sources) ] ; 54552a38012Sejakowatz 54652a38012Sejakowatz # Our Main replacement. 54752a38012Sejakowatz MainFromObjects $(target) : $(objects) ; 5489342c27aSIngo Weinhold TestObjects $(sources) : : true ; 54952a38012Sejakowatz 55052a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 5519eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 5529eea4522SIngo Weinhold Depends r5tests : $(target) ; 55352a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 55452a38012Sejakowatz} 55552a38012Sejakowatz 55652a38012Sejakowatzrule R5ObjectNames 55752a38012Sejakowatz{ 55852a38012Sejakowatz # R5ObjectNames <sources> ; 55952a38012Sejakowatz # Returns a list of gristed object names given a list of source file names. 56052a38012Sejakowatz # Moreover each object names gets "_r5" inserted before the object suffix. 56152a38012Sejakowatz local objects = $(1:S=)_r5 ; 56252a38012Sejakowatz return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ; 56352a38012Sejakowatz} 56452a38012Sejakowatz 5659342c27aSIngo Weinholdrule R5Objects 5669342c27aSIngo Weinhold{ 5679342c27aSIngo Weinhold # R5Objects <sources> 568dd9f8062SIngo Weinhold # Similar to Objects, but appends "_r5" to the object file names and 569dd9f8062SIngo Weinhold # removes `-nostdinc' from the CC and C++ flags to enable system headers. 5709342c27aSIngo Weinhold # <sources> The source files. 5719342c27aSIngo Weinhold 572dd9f8062SIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 573dd9f8062SIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 574dd9f8062SIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 575dd9f8062SIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 576dd9f8062SIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 577dd9f8062SIngo Weinhold 5789342c27aSIngo Weinhold local sources = $(1) ; 5799342c27aSIngo Weinhold local source ; 5809342c27aSIngo Weinhold for source in [ FGristFiles $(sources) ] 5819342c27aSIngo Weinhold { 5829342c27aSIngo Weinhold local object = [ R5ObjectNames $(source) ] ; 5839342c27aSIngo Weinhold Object $(object) : $(source) ; 5849342c27aSIngo Weinhold LocalDepends obj : $(object) ; 5859342c27aSIngo Weinhold } 586dd9f8062SIngo Weinhold 587dd9f8062SIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 588dd9f8062SIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 589dd9f8062SIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 5909342c27aSIngo Weinhold} 5919342c27aSIngo Weinhold 5929342c27aSIngo Weinholdrule TestObjects 5939342c27aSIngo Weinhold{ 5949342c27aSIngo Weinhold # TestLib <sources> : <public headers> : <r5> 5959342c27aSIngo Weinhold # Compiles objects for tests. 5969342c27aSIngo Weinhold # <sources> The list of sources. 5979342c27aSIngo Weinhold # <public headers> A list of public header dirs (as passed to 5989342c27aSIngo Weinhold # UsePublicHeaders). 5999342c27aSIngo Weinhold # <r5> If set, "_r5" is appended to the object file names and 6009342c27aSIngo Weinhold # <public headers> is ignored. Furthermore the pre-processor macro 6019342c27aSIngo Weinhold # TEST_R5 is defined, TEST_OBOS otherwise. 6029342c27aSIngo Weinhold 6039342c27aSIngo Weinhold local sources = $(1) ; 6049342c27aSIngo Weinhold local headerDirs = $(2) ; 6059342c27aSIngo Weinhold local r5 = $(3) ; 6069342c27aSIngo Weinhold local objects ; 6079342c27aSIngo Weinhold 6089342c27aSIngo Weinhold # Turn optimization off. 60996d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6109342c27aSIngo Weinhold local optim = $(OPTIM) ; 6119342c27aSIngo Weinhold OPTIM = ; 61296d27465SIngo Weinhold } 6139342c27aSIngo Weinhold 6149342c27aSIngo Weinhold SetupObjectsDir ; 6159342c27aSIngo Weinhold 6169342c27aSIngo Weinhold # compile 6179342c27aSIngo Weinhold if $(r5) { 618dd9f8062SIngo Weinhold SetupR5Includes ; 6199342c27aSIngo Weinhold objects = [ R5ObjectNames $(sources) ] ; 6209342c27aSIngo Weinhold R5Objects $(sources) ; 6219342c27aSIngo Weinhold } else { 622dd9f8062SIngo Weinhold SetupIncludes ; 6239342c27aSIngo Weinhold objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 6249342c27aSIngo Weinhold Objects $(sources) ; 6259342c27aSIngo Weinhold } 6269342c27aSIngo Weinhold 6279342c27aSIngo Weinhold # set headers/defines 6289b60a208SIngo Weinhold UseCppUnitObjectHeaders $(sources) : $(objects) ; 6299342c27aSIngo Weinhold if $(r5) { 630728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_R5 ; 6319342c27aSIngo Weinhold } else { 6329b60a208SIngo Weinhold UsePublicObjectHeaders $(sources) : $(headerDirs) : $(objects) ; 633728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_OBOS ; 6349342c27aSIngo Weinhold } 6359342c27aSIngo Weinhold 63696d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6379342c27aSIngo Weinhold # Turn debugging on. That is usually desired for test code. 6389342c27aSIngo Weinhold ObjectCcFlags $(objects) : "-g" ; 6399342c27aSIngo Weinhold ObjectC++Flags $(objects) : "-g" ; 6409342c27aSIngo Weinhold 6419342c27aSIngo Weinhold # Turn optimization on again. 6429342c27aSIngo Weinhold OPTIM = $(optim) ; 6439342c27aSIngo Weinhold } 64496d27465SIngo Weinhold} 6459342c27aSIngo Weinhold 6469285de51STyler Dauwalderrule R5SharedLibraryNames 6479285de51STyler Dauwalder{ 6489285de51STyler Dauwalder # R5SharedLibraryNames <sources> ; 6499285de51STyler Dauwalder # Returns a list of shared library names given a list of file names. NO 6509285de51STyler Dauwalder # GRISTING IS PERFORMED :-) However, each library names gets "_r5" inserted 6519285de51STyler Dauwalder # before the shared lib suffix. 6529285de51STyler Dauwalder return $(1:S=)_r5.so ; 6539285de51STyler Dauwalder} 6549285de51STyler Dauwalder 6559fc6b2e1SIngo Weinholdrule SimpleTest 6569fc6b2e1SIngo Weinhold{ 6579fc6b2e1SIngo Weinhold # UnitTest <target> : <sources> : <libraries> 6589fc6b2e1SIngo Weinhold # Builds a unit test for an OBOS module. 6599fc6b2e1SIngo Weinhold # <target> The name of the target. 6609fc6b2e1SIngo Weinhold # <sources> The list of sources. 6619fc6b2e1SIngo Weinhold # <dest> The directory for the target (as passed to FDirName). 6629fc6b2e1SIngo Weinhold # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 6639fc6b2e1SIngo Weinhold # <public headers> A list of public header dirs (as passed to 6649fc6b2e1SIngo Weinhold # UsePublicHeaders). 6659fc6b2e1SIngo Weinhold 6669fc6b2e1SIngo Weinhold local target = $(1) ; 6679fc6b2e1SIngo Weinhold local sources = $(2) ; 6689fc6b2e1SIngo Weinhold local libraries = $(3) ; 6699fc6b2e1SIngo Weinhold local relPath = [ FRelPath src tests : $(SUBDIR_TOKENS) ] ; 6709fc6b2e1SIngo Weinhold 6719fc6b2e1SIngo Weinhold # Turn optimization off. 67296d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6739fc6b2e1SIngo Weinhold local optim = $(OPTIM) ; 6749fc6b2e1SIngo Weinhold OPTIM = ; 67596d27465SIngo Weinhold } 6769fc6b2e1SIngo Weinhold 677a6c008e1Sbeveloper SetupIncludes ; 6789fc6b2e1SIngo Weinhold SetupObjectsDir ; 6799fc6b2e1SIngo Weinhold MakeLocateObjects $(sources) ; 6809fc6b2e1SIngo Weinhold Main $(target) : $(sources) ; 6819fc6b2e1SIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 6829eea4522SIngo Weinhold Depends obostests : $(target) ; 6839fc6b2e1SIngo Weinhold LinkSharedOSLibs $(target) : $(libraries) ; 684728b5725SIngo Weinhold ObjectsDefines $(sources) : TEST_OBOS ; 68596d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6869fc6b2e1SIngo Weinhold # Turn debugging on. That is usually desired for test code. 6879fc6b2e1SIngo Weinhold ObjectCcFlags $(sources) : "-g" ; 6889fc6b2e1SIngo Weinhold ObjectC++Flags $(sources) : "-g" ; 6899fc6b2e1SIngo Weinhold 6909fc6b2e1SIngo Weinhold # Turn optimization on again. 6919fc6b2e1SIngo Weinhold OPTIM = $(optim) ; 6929fc6b2e1SIngo Weinhold } 69396d27465SIngo Weinhold} 6949fc6b2e1SIngo Weinhold 69552a38012Sejakowatzrule Addon 69652a38012Sejakowatz{ 69783b3b0dfSIngo Weinhold # Addon <name> : <relpath> : <sources> : <is executable> : <libraries> ; 6987a384fdeSIngo Weinhold # <name>: Name of the add-on. 6997a384fdeSIngo Weinhold # <relpath>: Path where the add-on shall live relative to the add-on dir. 7007a384fdeSIngo Weinhold # <sources>: Source files. 70183b3b0dfSIngo Weinhold # <is executable>: true, if the target shall be executable as well. 70283b3b0dfSIngo Weinhold # <libraries>: Libraries to be linked against. 7037a384fdeSIngo Weinhold 7047a384fdeSIngo Weinhold local isExecutable = $(4) ; 70552a38012Sejakowatz 706a6c008e1Sbeveloper SetupIncludes ; 70752a38012Sejakowatz SetupObjectsDir ; 70852a38012Sejakowatz Main $(1) : $(3) ; 70952a38012Sejakowatz 71052a38012Sejakowatz # Create output dir path for addon 71152a38012Sejakowatz local targetdir; 71252a38012Sejakowatz targetdir = [ FDirName $(OBOS_ADDON_DIR) $(2) ] ; 71352a38012Sejakowatz 71452a38012Sejakowatz MakeLocate $(1) : $(targetdir) ; 7157a384fdeSIngo Weinhold 7167a384fdeSIngo Weinhold local linkFlags = -Xlinker -soname=\"$(1)\" ; 7177a384fdeSIngo Weinhold if $(isExecutable) != true { 7187a384fdeSIngo Weinhold linkFlags = -nostart $(linkFlags) ; 7197a384fdeSIngo Weinhold } 7207a384fdeSIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] $(linkFlags) ; 72183b3b0dfSIngo Weinhold LinkSharedOSLibs $(1) : $(5) ; 722af28904fSIngo Weinhold} 723af28904fSIngo Weinhold 72458efc9d8SIngo Weinholdrule R5KernelAddon 725af28904fSIngo Weinhold{ 72658efc9d8SIngo Weinhold # R5KernelAddon <name> : <relpath> : <sources> ; 727af28904fSIngo Weinhold 728af28904fSIngo Weinhold local sources = $(3) ; 729af28904fSIngo Weinhold 730af28904fSIngo Weinhold Addon $(1) : $(2) : $(3) ; 731af28904fSIngo Weinhold ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 732af28904fSIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic 733af28904fSIngo Weinhold -fno-exceptions -fno-rtti ; 7349eea4522SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; 735af28904fSIngo Weinhold LinkSharedOSLibs $(1) : /boot/develop/lib/x86/_KERNEL_ ; 73652a38012Sejakowatz} 73752a38012Sejakowatz 7384fb5add0SMatthew Wilberrule Translator 7394fb5add0SMatthew Wilber{ 740007eb5f2SIngo Weinhold # Translator <name> : <sources> : <libraries> ; 741a6c008e1Sbeveloper SetupIncludes ; 7424fb5add0SMatthew Wilber SetupObjectsDir ; 7434fb5add0SMatthew Wilber Main $(1) : $(2) ; 744007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 7454fb5add0SMatthew Wilber 7464fb5add0SMatthew Wilber # Create output dir path for translator 7474fb5add0SMatthew Wilber local targetdir; 748d5b07cf2Sshatty targetdir = [ FDirName $(OBOS_ADDON_DIR) Translators ] ; 7494fb5add0SMatthew Wilber MakeLocate $(1) : $(targetdir) ; 7504fb5add0SMatthew Wilber} 7514fb5add0SMatthew Wilber 75252a38012Sejakowatzrule MakeLocateObjects 75352a38012Sejakowatz{ 75421df5945SIngo Weinhold # MakeLocateObjects <sources_or_objects> ; 75552a38012Sejakowatz 75621df5945SIngo Weinhold local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 75752a38012Sejakowatz 75852a38012Sejakowatz for o in $(_objs) 75952a38012Sejakowatz { 76052a38012Sejakowatz local dir = $(o:D) ; 76152a38012Sejakowatz if $(dir) { 76252a38012Sejakowatz MakeLocate $(o) : [ FDirName $(LOCATE_TARGET) $(dir) ] ; 76352a38012Sejakowatz } else { 76452a38012Sejakowatz MakeLocate $(o) : $(LOCATE_TARGET) ; 76552a38012Sejakowatz } 76652a38012Sejakowatz } 76752a38012Sejakowatz} 76852a38012Sejakowatz 76952a38012Sejakowatzrule StaticLibrary 77052a38012Sejakowatz{ 771e9230d05SIngo Weinhold # StaticLibrary <name> : <sources> [ : <target dir> ] ; 772e9230d05SIngo Weinhold # Creates a static library from sources. 773e9230d05SIngo Weinhold # <name>: Basename of the library, without leading "lib" and trailing ".a". 77460c9c40fSIngo Weinhold # Grist is allowed -- it will be re-prepended after constructing 77560c9c40fSIngo Weinhold # the complete library name. 776e9230d05SIngo Weinhold # <source>: List of source files. 777e9230d05SIngo Weinhold # <target dir>: Directory into which the library shall be placed. Defaults 77860c9c40fSIngo Weinhold # to the objects directory for this subdir. If 77960c9c40fSIngo Weinhold # STATIC_LIBRARY_DIR is supplied (the literal string) 78060c9c40fSIngo Weinhold # the standard directory for static libs is used, otherwise 78160c9c40fSIngo Weinhold # the parameter is interpreted as directory path. 782e9230d05SIngo Weinhold # 78360c9c40fSIngo Weinhold local lib = lib$(1:B)$(SUFLIB) ; 78460c9c40fSIngo Weinhold lib = $(lib:G=$(1:G)) ; 785a6c008e1Sbeveloper SetupIncludes ; 78652a38012Sejakowatz SetupObjectsDir ; 78752a38012Sejakowatz MakeLocateObjects $(2) ; 788e9230d05SIngo Weinhold Library $(lib) : $(2) ; 789e9230d05SIngo Weinhold local targetDir = $(3) ; 79060c9c40fSIngo Weinhold if $(targetDir) { 79160c9c40fSIngo Weinhold if $(targetDir) = STATIC_LIBRARY_DIR { 792e9230d05SIngo Weinhold targetDir = $(OBOS_STLIB_DIR) ; 793e9230d05SIngo Weinhold } 794e9230d05SIngo Weinhold MakeLocate $(lib) : $(targetDir) ; 79560c9c40fSIngo Weinhold } else { 79660c9c40fSIngo Weinhold # nothing to do, since the Library rule already located the library 79760c9c40fSIngo Weinhold # in $(LOCATE_TARGET) 79860c9c40fSIngo Weinhold } 799f1e077f8SIngo Weinhold 800f1e077f8SIngo Weinhold # If KEEPOBJS is set, Library doesn't make the library depend on 801f1e077f8SIngo Weinhold # `lib'. 802f1e077f8SIngo Weinhold if $(KEEPOBJS) { 803f1e077f8SIngo Weinhold LocalDepends lib : $(lib) ; 804f1e077f8SIngo Weinhold } 80552a38012Sejakowatz} 80652a38012Sejakowatz 807dbf96817SIngo Weinholdrule R5KernelStaticLibrary 808dbf96817SIngo Weinhold{ 809dbf96817SIngo Weinhold # R5KernelStaticLibrary <name> : <sources> ; 810dbf96817SIngo Weinhold 811f1e077f8SIngo Weinhold local lib = lib$(1)$(SUFLIB) ; 812dbf96817SIngo Weinhold local sources = $(2) ; 813dbf96817SIngo Weinhold 814dbf96817SIngo Weinhold SetupIncludes ; 815dbf96817SIngo Weinhold SetupObjectsDir ; 816dbf96817SIngo Weinhold MakeLocateObjects $(sources) ; 817dbf96817SIngo Weinhold Library $(lib) : $(sources) ; 818dbf96817SIngo Weinhold ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 819dbf96817SIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic 820dbf96817SIngo Weinhold -fno-exceptions -fno-rtti ; 821dbf96817SIngo Weinhold} 822dbf96817SIngo Weinhold 82380721244SAxel Dörflerrule MergeObjectFromObjects 82480721244SAxel Dörfler{ 8252fbd7065SIngo Weinhold # MergeObjectFromObjects <name> : <objects> : <other objects> ; 8262fbd7065SIngo Weinhold # Merges object files to an object file. 8272fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 8282fbd7065SIngo Weinhold # <objects>: Object files to be merged. Grist will be added. 8292fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 8302fbd7065SIngo Weinhold # will be added. 8312fbd7065SIngo Weinhold # 832c8aa252aSIngo Weinhold local objects = [ FGristFiles $(2) ] ; 83380721244SAxel Dörfler MakeLocate $(1) : $(LOCATE_TARGET) ; 834c8aa252aSIngo Weinhold Depends $(1) : $(objects) ; 8352fbd7065SIngo Weinhold Depends $(1) : $(3) ; 83680721244SAxel Dörfler LINK on $(1) = ld ; 8372fbd7065SIngo Weinhold MergeObjectFromObjects1 $(1) : $(objects) $(3) ; 83880721244SAxel Dörfler} 83980721244SAxel Dörfler 84054b7cbe1SIngo Weinholdactions MergeObjectFromObjects1 84180721244SAxel Dörfler{ 84280721244SAxel Dörfler $(LINK) -r $(2) -o $(1) ; 84380721244SAxel Dörfler} 84480721244SAxel Dörfler 84580721244SAxel Dörflerrule MergeObject 84680721244SAxel Dörfler{ 8472fbd7065SIngo Weinhold # MergeObject <name> : <sources> : <other objects> ; 8482fbd7065SIngo Weinhold # Compiles source files and merges the object files to an object file. 8492fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 8502fbd7065SIngo Weinhold # <sources>: Sources to be compiled. Grist will be added. 8512fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 8522fbd7065SIngo Weinhold # will be added. 8532fbd7065SIngo Weinhold # 85480721244SAxel Dörfler SetupIncludes ; 85580721244SAxel Dörfler SetupObjectsDir ; 85680721244SAxel Dörfler MakeLocateObjects $(2) ; 85780721244SAxel Dörfler Objects $(2) ; 8582fbd7065SIngo Weinhold MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; 85980721244SAxel Dörfler} 86080721244SAxel Dörfler 86121df5945SIngo Weinholdrule SharedLibraryFromObjects 86252a38012Sejakowatz{ 8638d3308d9SIngo Weinhold # SharedLibraryFromObjects <name> : <objects> : <libraries> ; 86460c9c40fSIngo Weinhold local _lib = lib$(1:B).so ; 86560c9c40fSIngo Weinhold _lib = $(_lib:G=$(1:G)) ; 86621df5945SIngo Weinhold MainFromObjects $(_lib) : $(2) ; 86752a38012Sejakowatz MakeLocate $(_lib) : $(OBOS_SHLIB_DIR) ; 8689eea4522SIngo Weinhold LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ] 8699eea4522SIngo Weinhold -nostart -Xlinker -soname=\"$(_lib)\" ; 8708d3308d9SIngo Weinhold LinkSharedOSLibs $(_lib) : $(3) ; 87152a38012Sejakowatz} 87252a38012Sejakowatz 87321df5945SIngo Weinholdrule SharedLibrary 87421df5945SIngo Weinhold{ 8758d3308d9SIngo Weinhold # SharedLibrary <name> : <sources> : <libraries> ; 876a6c008e1Sbeveloper SetupIncludes ; 87721df5945SIngo Weinhold SetupObjectsDir ; 87821df5945SIngo Weinhold MakeLocateObjects $(2) ; 87921df5945SIngo Weinhold Objects $(2) ; 8808d3308d9SIngo Weinhold SharedLibraryFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; 88121df5945SIngo Weinhold} 88221df5945SIngo Weinhold 88352a38012Sejakowatzrule LinkSharedOSLibs 88452a38012Sejakowatz{ 88552a38012Sejakowatz # LinkSharedOSLibs <name> : <libs> ; 88652a38012Sejakowatz # Valid elements for <libs> are e.g. "be" or "libopenbeos.so" or 8874236d490SIngo Weinhold # "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy 8884236d490SIngo Weinhold # has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the 8894236d490SIngo Weinhold # file will be bound!), otherwise it is prefixed "-l" and added to 890a8cd0719SIngo Weinhold # LINKLIBS. If you want to specify a target that isn't a library and 891a8cd0719SIngo Weinhold # also has neither grist nor a dirname, you can prepend "<nogrist>" as 892a8cd0719SIngo Weinhold # grist; it will be stripped by this rule. 89352a38012Sejakowatz 89452a38012Sejakowatz for i in $(>) 89552a38012Sejakowatz { 8964236d490SIngo Weinhold local isfile = ; 8974236d490SIngo Weinhold if $(i:D) || $(i:G) { 8984236d490SIngo Weinhold isfile = true ; 899a8cd0719SIngo Weinhold if $(i:G) = <nogrist> { 900a8cd0719SIngo Weinhold i = $(i:G=) ; 901a8cd0719SIngo Weinhold } 9024236d490SIngo Weinhold } else { 90352a38012Sejakowatz switch $(i:B) 90452a38012Sejakowatz { 905007eb5f2SIngo Weinhold # XXX: _APP_ and _KERNEL_ should not be needed for ELF. 906f7901247SPhilippe Houdoin case _APP_ : isfile = true ; 907f7901247SPhilippe Houdoin case _KERNEL_ : isfile = true ; 9084236d490SIngo Weinhold case lib* : isfile = true ; 9094236d490SIngo Weinhold case * : isfile = ; 9104236d490SIngo Weinhold } 911b8baf385SIngo Weinhold if ! $(isfile) && ( $(i:S) = .so || $(i:S) = .a ) { 912b8baf385SIngo Weinhold isfile = true ; 913b8baf385SIngo Weinhold } 9144236d490SIngo Weinhold } 9154236d490SIngo Weinhold if $(isfile) { 9169eea4522SIngo Weinhold NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(i) ; 9179eea4522SIngo Weinhold Depends $(1) : $(i) ; 9184236d490SIngo Weinhold } else { 9199eea4522SIngo Weinhold LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] -l$(i) ; 92052a38012Sejakowatz } 92152a38012Sejakowatz } 92252a38012Sejakowatz} 92352a38012Sejakowatz 92452a38012Sejakowatzrule LinkStaticOSLibs 92552a38012Sejakowatz{ 92652a38012Sejakowatz # LinkStaticOSLibs <name> : <libs> ; 92752a38012Sejakowatz 92852a38012Sejakowatz for i in $(>) 92952a38012Sejakowatz { 93052a38012Sejakowatz LINKLIBS on $(<) = $(LINKLIBS) -l $(i) ; 93152a38012Sejakowatz } 93252a38012Sejakowatz} 93352a38012Sejakowatz 93452a38012Sejakowatzrule AddResources 93552a38012Sejakowatz{ 93652a38012Sejakowatz # AddResources <name> : <resourcefiles> ; 93752a38012Sejakowatz 9388d3308d9SIngo Weinhold local resfiles = [ FGristFiles $(2) ] ; 9398d3308d9SIngo Weinhold SEARCH on $(resfiles) += $(SEARCH_SOURCE) ; 9408d3308d9SIngo Weinhold 9418d3308d9SIngo Weinhold for file in $(resfiles) { 9428d3308d9SIngo Weinhold if $(file:S) = .rdef { 9438d3308d9SIngo Weinhold local rdef = $(file) ; 9448d3308d9SIngo Weinhold file = $(rdef:S=.rsrc) ; 9458d3308d9SIngo Weinhold ResComp $(file) : $(rdef) ; 9468d3308d9SIngo Weinhold } 9478d3308d9SIngo Weinhold RESFILES on $(1) += $(file) ; 9488d3308d9SIngo Weinhold } 9498d3308d9SIngo Weinhold} 9508d3308d9SIngo Weinhold 9518d3308d9SIngo Weinholdrule ResComp 9528d3308d9SIngo Weinhold{ 9538d3308d9SIngo Weinhold # ResComp <resource file> : <rdef file> ; 9548d3308d9SIngo Weinhold # 9558d3308d9SIngo Weinhold # <resource file> and <rdef file> must be gristed. 9568d3308d9SIngo Weinhold 9578d3308d9SIngo Weinhold SetupObjectsDir ; 9588d3308d9SIngo Weinhold 9599fc6b2e1SIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 9608d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_TARGET) ; 9618d3308d9SIngo Weinhold Depends $(1) : $(2) rc ; 9628d3308d9SIngo Weinhold LocalClean clean : $(1) ; 9638d3308d9SIngo Weinhold ResComp1 $(1) : rc $(2) ; 9648d3308d9SIngo Weinhold} 9658d3308d9SIngo Weinhold 9668d3308d9SIngo Weinholdactions ResComp1 9678d3308d9SIngo Weinhold{ 9686af76074SIngo Weinhold $(2[1]) -o $(1) $(2[2-]) 96952a38012Sejakowatz} 97052a38012Sejakowatz 971728b5725SIngo Weinholdrule ObjectsDefines 972728b5725SIngo Weinhold{ 973728b5725SIngo Weinhold # Like ObjectDefines, but allows multiple files to be supplied 974728b5725SIngo Weinhold local file ; 975728b5725SIngo Weinhold for file in $(1) { 976728b5725SIngo Weinhold ObjectDefines $(file) : $(2) ; 977728b5725SIngo Weinhold } 978728b5725SIngo Weinhold} 979728b5725SIngo Weinhold 9809b60a208SIngo Weinholdrule SourceHdrs 9819b60a208SIngo Weinhold{ 9829b60a208SIngo Weinhold # SourceHdrs <sources> : <headers> [ : <gristed objects> ] ; 9839b60a208SIngo Weinhold # 9849b60a208SIngo Weinhold # Is a wrapper for ObjectHdrs, that passes <sources> and <headers> or, 9859b60a208SIngo Weinhold # if supplied <objects> and <headers>, and also adjusts HDRSEARCH (not 9869b60a208SIngo Weinhold # done by ObjectHdrs). 9879b60a208SIngo Weinhold 9889b60a208SIngo Weinhold local sources = [ FGristFiles $(1) ] ; 9899b60a208SIngo Weinhold local headers = $(2) ; 9909b60a208SIngo Weinhold local objects = $(3) ; 9919b60a208SIngo Weinhold 992728b5725SIngo Weinhold local file ; 9939b60a208SIngo Weinhold if $(objects) { 994728b5725SIngo Weinhold for file in $(objects) { 995728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 996728b5725SIngo Weinhold } 9979b60a208SIngo Weinhold } else { 998728b5725SIngo Weinhold for file in $(sources) { 999728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 1000728b5725SIngo Weinhold } 10019b60a208SIngo Weinhold } 10029b60a208SIngo Weinhold 10039b60a208SIngo Weinhold # Also add the header search dirs to HDRSEARCH. Note, that these dirs 10049b60a208SIngo Weinhold # will be listed after the STDHDRS (if any), but that's better than not 10059b60a208SIngo Weinhold # being listed at all. 10069b60a208SIngo Weinhold HDRSEARCH on $(sources) += $(headers) ; 10079b60a208SIngo Weinhold} 10089b60a208SIngo Weinhold 10097d7f280eSIngo Weinholdrule PublicHeaders 101052a38012Sejakowatz{ 10117d7f280eSIngo Weinhold # PublicHeaders <group list> 101252a38012Sejakowatz # 10137d7f280eSIngo Weinhold # Returns the directory names for the public header dirs identified by 10147d7f280eSIngo Weinhold # <group list>. 101552a38012Sejakowatz 101652a38012Sejakowatz local list = $(1) ; 1017b005dbe3SAxel Dörfler local dirs = [ FDirName $(OBOS_TOP) headers os ] ; 1018b005dbe3SAxel Dörfler 101952a38012Sejakowatz for i in $(list) { 10207d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers os $(i) ] ; 10217d7f280eSIngo Weinhold } 10227d7f280eSIngo Weinhold return $(dirs) ; 102352a38012Sejakowatz} 102452a38012Sejakowatz 10257d7f280eSIngo Weinholdrule PrivateHeaders 10267d7f280eSIngo Weinhold{ 10277d7f280eSIngo Weinhold # PrivateHeaders <group list> 10287d7f280eSIngo Weinhold # 10297d7f280eSIngo Weinhold # Returns the directory names for the private header dirs identified by 10307d7f280eSIngo Weinhold # <group list>. 10317d7f280eSIngo Weinhold 10327d7f280eSIngo Weinhold local list = $(1) ; 10337d7f280eSIngo Weinhold local dirs ; 10347d7f280eSIngo Weinhold for i in $(list) { 10357d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers private $(i) ] ; 10367d7f280eSIngo Weinhold } 10377d7f280eSIngo Weinhold return $(dirs) ; 10387d7f280eSIngo Weinhold} 10397d7f280eSIngo Weinhold 10400f434a0aSDarkWyrmrule LibraryHeaders 10410f434a0aSDarkWyrm{ 10420f434a0aSDarkWyrm # LibraryHeaders <group list> 10430f434a0aSDarkWyrm # 10440f434a0aSDarkWyrm # Returns the directory names for the library header dirs identified by 10450f434a0aSDarkWyrm # <group list>. 10460f434a0aSDarkWyrm 10470f434a0aSDarkWyrm local list = $(1) ; 10480f434a0aSDarkWyrm local dirs ; 10490f434a0aSDarkWyrm for i in $(list) { 10500f434a0aSDarkWyrm dirs += [ FDirName $(OBOS_TOP) headers libs $(i) ] ; 10510f434a0aSDarkWyrm } 10520f434a0aSDarkWyrm return $(dirs) ; 10530f434a0aSDarkWyrm} 10540f434a0aSDarkWyrm 10557d7f280eSIngo Weinholdrule ArchHeaders 10567d7f280eSIngo Weinhold{ 10577d7f280eSIngo Weinhold # usage: ArchHeaders <arch> ; 10587d7f280eSIngo Weinhold # 10597d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 10607d7f280eSIngo Weinhold 10617d7f280eSIngo Weinhold return [ FDirName $(OBOS_TOP) headers private kernel arch $(1) ] ; 10627d7f280eSIngo Weinhold} 10637d7f280eSIngo Weinhold 10647d7f280eSIngo Weinholdrule UsePublicHeaders 10657d7f280eSIngo Weinhold{ 1066966528dcSIngo Weinhold # UsePublicHeaders <group list> ; 1067966528dcSIngo Weinhold # 1068966528dcSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 1069966528dcSIngo Weinhold # dirs of the subdirectory. 1070966528dcSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the 1071966528dcSIngo Weinhold # objects. 1072966528dcSIngo Weinhold 1073966528dcSIngo Weinhold UseHeaders [ PublicHeaders $(1) ] ; 10747d7f280eSIngo Weinhold} 10757d7f280eSIngo Weinhold 10767d7f280eSIngo Weinholdrule UsePublicObjectHeaders 10777d7f280eSIngo Weinhold{ 10789b60a208SIngo Weinhold # UsePublicObjectHeaders <sources> : <group list> [ : <objects> ] ; 10797d7f280eSIngo Weinhold # 10807d7f280eSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 10819b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 10829b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 10837d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 10847d7f280eSIngo Weinhold 10859b60a208SIngo Weinhold SourceHdrs $(1) : [ PublicHeaders $(2) ] : $(3) ; 108652a38012Sejakowatz} 108752a38012Sejakowatz 108852a38012Sejakowatzrule UsePrivateHeaders 108952a38012Sejakowatz{ 10907d7f280eSIngo Weinhold # UsePrivateHeaders <group list> ; 109152a38012Sejakowatz # 109252a38012Sejakowatz # Adds the private C header dirs given by <group list> to the header search 10937d7f280eSIngo Weinhold # dirs of the subdirectory. 10947d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 109552a38012Sejakowatz 10967d7f280eSIngo Weinhold UseHeaders [ PrivateHeaders $(1) ] ; 109752a38012Sejakowatz} 109852a38012Sejakowatz 10997d7f280eSIngo Weinholdrule UsePrivateObjectHeaders 11007d7f280eSIngo Weinhold{ 11019b60a208SIngo Weinhold # UsePrivateObjectHeaders <sources> : <group list> [ : <objects> ] ; 11027d7f280eSIngo Weinhold # 11037d7f280eSIngo Weinhold # Adds the private C header dirs given by <group list> to the header search 11049b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 11059b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 11067d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 11077d7f280eSIngo Weinhold 11089b60a208SIngo Weinhold SourceHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; 110952a38012Sejakowatz} 111052a38012Sejakowatz 111152a38012Sejakowatzrule UseHeaders 111252a38012Sejakowatz{ 11137d7f280eSIngo Weinhold # UseHeaders <headers> ; 111452a38012Sejakowatz # 111552a38012Sejakowatz # Adds the C header dirs <headers> to the header search 11167d7f280eSIngo Weinhold # dirs of the subdirectory. 11177d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 111852a38012Sejakowatz 11197d7f280eSIngo Weinhold local header ; 11207d7f280eSIngo Weinhold for header in $(1) { 112152a38012Sejakowatz SubDirHdrs $(header) ; 112252a38012Sejakowatz } 112352a38012Sejakowatz} 112452a38012Sejakowatz 112552a38012Sejakowatzrule UseCppUnitHeaders 112652a38012Sejakowatz{ 11277d7f280eSIngo Weinhold SubDirHdrs [ FDirName $(OBOS_TOP) headers tools cppunit ] ; 112852a38012Sejakowatz} 112952a38012Sejakowatz 1130be5af1baSIngo Weinholdrule UseCppUnitObjectHeaders 1131be5af1baSIngo Weinhold{ 11329b60a208SIngo Weinhold # UseCppUnitObjectHeaders <sources> [ : <objects> ] ; 11339b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers tools cppunit ] : $(2) ; 1134be5af1baSIngo Weinhold} 1135be5af1baSIngo Weinhold 113652a38012Sejakowatzrule UseArchHeaders 113752a38012Sejakowatz{ 11387d7f280eSIngo Weinhold # usage: UseArchHeaders <arch> ; 11397d7f280eSIngo Weinhold # 114052a38012Sejakowatz # <arch> specifies the architecture (e.g. x86). 11417d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 11427d7f280eSIngo Weinhold 11437d7f280eSIngo Weinhold local headers = [ ArchHeaders $(1) ] ; 114452a38012Sejakowatz local opt = -D$(OBOS_TARGET_DEFINE) ; 1145c633961aSIngo Weinhold 114652a38012Sejakowatz SubDirCcFlags $(opt) ; 114752a38012Sejakowatz SubDirC++Flags $(opt) ; 1148089a0629Sbeveloper HDRS += $(headers) ; 1149c633961aSIngo Weinhold} 1150c633961aSIngo Weinhold 11517d7f280eSIngo Weinholdrule UseArchObjectHeaders 11527d7f280eSIngo Weinhold{ 11539b60a208SIngo Weinhold # usage: UseArchObjectHeaders <sources> : <arch> : [ <objects> ] ; 11547d7f280eSIngo Weinhold # 11557d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 11567d7f280eSIngo Weinhold # <sources_or_objects> Source or object files. 11577d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 11587d7f280eSIngo Weinhold 11599b60a208SIngo Weinhold local sources = $(1) ; 11607d7f280eSIngo Weinhold local headers = [ ArchHeaders $(2) ] ; 11619b60a208SIngo Weinhold local objects = $(3) ; 11629b60a208SIngo Weinhold local targets ; 11639b60a208SIngo Weinhold if $(objects) { 11649b60a208SIngo Weinhold targets = $(objects) ; 11659b60a208SIngo Weinhold } else { 11669b60a208SIngo Weinhold targets = $(sources) ; 11679b60a208SIngo Weinhold } 11687d7f280eSIngo Weinhold local opt = -D$(OBOS_TARGET_DEFINE) ; 11697d7f280eSIngo Weinhold 11707d7f280eSIngo Weinhold ObjectCcFlags $(targets) : $(opt) ; 11717d7f280eSIngo Weinhold ObjectC++Flags $(targets) : $(opt) ; 11729b60a208SIngo Weinhold SourceHdrs $(sources) : $(headers) : $(objects) ; 117352a38012Sejakowatz} 117452a38012Sejakowatz 1175d25a77b4SIngo Weinholdrule UsePosixHeaders 1176d25a77b4SIngo Weinhold{ 1177a6c008e1Sbeveloper # XXX changed to do nothing 1178d25a77b4SIngo Weinhold} 1179d25a77b4SIngo Weinhold 1180d25a77b4SIngo Weinholdrule UsePosixObjectHeaders 1181d25a77b4SIngo Weinhold{ 11829b60a208SIngo Weinhold # UsePosixObjectHeaders <sources> [ : <objects> ] ; 1183d25a77b4SIngo Weinhold # 1184d25a77b4SIngo Weinhold # Adds the POSIX header dir to the header search 11859b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 11869b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 1187d25a77b4SIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 1188d25a77b4SIngo Weinhold 11899b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers posix ] : $(2) ; 1190d25a77b4SIngo Weinhold} 1191d25a77b4SIngo Weinhold 11920f434a0aSDarkWyrmrule UseLibraryHeaders 11930f434a0aSDarkWyrm{ 11940f434a0aSDarkWyrm # UseLibraryHeaders <group list> ; 11950f434a0aSDarkWyrm # 11960f434a0aSDarkWyrm # Adds the library header dirs given by <group list> to the header search 11970f434a0aSDarkWyrm # dirs of the subdirectory. 11980f434a0aSDarkWyrm # NOTE: This rule must be invoked *before* the rule that builds the objects. 11990f434a0aSDarkWyrm 12000f434a0aSDarkWyrm UseHeaders [ LibraryHeaders $(1) ] ; 12010f434a0aSDarkWyrm} 12020f434a0aSDarkWyrm 12033b9eae39SIngo Weinholdrule SplitPath 12043b9eae39SIngo Weinhold{ 12053b9eae39SIngo Weinhold # SplitPath <path> ; 12063b9eae39SIngo Weinhold # Decomposes a path into its components. 12073b9eae39SIngo Weinhold local path = $(1:G=) ; 12083b9eae39SIngo Weinhold local components ; 12098c27f58dSIngo Weinhold # $(path:D) for "/" is "/". Therefore the second condition. 12108c27f58dSIngo Weinhold while $(path:D) && $(path:D) != $(path) 12113b9eae39SIngo Weinhold { 12123b9eae39SIngo Weinhold # Note: $(path:B) returns "." for "..", but $(path:D=) is fine. 12133b9eae39SIngo Weinhold components = $(path:D=) $(components) ; 12143b9eae39SIngo Weinhold path = $(path:D) ; 12153b9eae39SIngo Weinhold } 12163b9eae39SIngo Weinhold components = $(path) $(components) ; 12173b9eae39SIngo Weinhold return $(components) ; 12183b9eae39SIngo Weinhold} 12193b9eae39SIngo Weinhold 12209fc6b2e1SIngo Weinholdrule PrependObjectHdrs 12219fc6b2e1SIngo Weinhold{ 12229fc6b2e1SIngo Weinhold # PrependObjectHdrs <objects_or_sources> : <dirs> ; 12239fc6b2e1SIngo Weinhold # Prepends <dirs> to the list of header search dirs of the objects 12249fc6b2e1SIngo Weinhold # specified by <objects_or_sources>. The HDRS variable will not be 12259fc6b2e1SIngo Weinhold # changed, only CCHDRS. 12269fc6b2e1SIngo Weinhold # Note: A subsequent ObjectHdrs invocation will therefore undo the 12279fc6b2e1SIngo Weinhold # effect of this rule. 12289fc6b2e1SIngo Weinhold # NOTE: This is a hack. 12299fc6b2e1SIngo Weinhold 12309fc6b2e1SIngo Weinhold local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 12319fc6b2e1SIngo Weinhold local dirs = $(2) ; 12329fc6b2e1SIngo Weinhold for object in $(objects) { 12339fc6b2e1SIngo Weinhold # Don't change HDRS to avoid screwing up the header scanning. 12349fc6b2e1SIngo Weinhold PREPENDED_HDRS on $(object) 12359fc6b2e1SIngo Weinhold = $(dirs) [ on $(object) return $(PREPENDED_HDRS) ] ; 12369fc6b2e1SIngo Weinhold CCHDRS on $(object) 12379fc6b2e1SIngo Weinhold = [ FIncludes [ on $(object) return $(PREPENDED_HDRS) $(HDRS) ] ] ; 12389fc6b2e1SIngo Weinhold } 12399fc6b2e1SIngo Weinhold} 12409fc6b2e1SIngo Weinhold 12413b9eae39SIngo Weinholdrule SymLink 12423b9eae39SIngo Weinhold{ 1243*7669b69fSIngo Weinhold # SymLink <target> : <source> : <makeDefaultDependencies> ; 12443b9eae39SIngo Weinhold # Links <target> to <source>. 12453b9eae39SIngo Weinhold # <source> is the exact link contents. No binding is done. 1246*7669b69fSIngo Weinhold # <makeDefaultDependencies> If true, <target> will be made a dependency 1247*7669b69fSIngo Weinhold # of the `all' pseudo target, i.e. it will be made by default, and removed 1248*7669b69fSIngo Weinhold # on `jam clean'. 1249*7669b69fSIngo Weinhold 1250*7669b69fSIngo Weinhold local target = $(1) ; 1251*7669b69fSIngo Weinhold local source = $(2) ; 1252*7669b69fSIngo Weinhold local makeDefaultDependencies = $(3) ; 1253*7669b69fSIngo Weinhold if ! $(makeDefaultDependencies) { 1254*7669b69fSIngo Weinhold makeDefaultDependencies = true ; 1255*7669b69fSIngo Weinhold } 1256*7669b69fSIngo Weinhold LINKCONTENTS on $(target) = $(source) ; 1257*7669b69fSIngo Weinhold SymLink1 $(target) ; 1258*7669b69fSIngo Weinhold if $(makeDefaultDependencies) = true { 1259*7669b69fSIngo Weinhold LocalDepends files : $(target) ; 1260*7669b69fSIngo Weinhold LocalClean clean : $(target) ; 1261*7669b69fSIngo Weinhold } 12623b9eae39SIngo Weinhold} 12633b9eae39SIngo Weinhold 12643b9eae39SIngo Weinholdactions SymLink1 12653b9eae39SIngo Weinhold{ 12660931b8f9SIngo Weinhold $(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)" 12670931b8f9SIngo Weinhold} 12680931b8f9SIngo Weinhold 12690931b8f9SIngo Weinholdrule RelSymLink 12700931b8f9SIngo Weinhold{ 1271*7669b69fSIngo Weinhold # RelSymLink <link> : <link target> : <makeDefaultDependencies> ; 12720931b8f9SIngo Weinhold # Creates a relative symbolic link from <link> to <link target>. 12730931b8f9SIngo Weinhold # <link> and <link target> can be usual targets. They may have a grist 12740931b8f9SIngo Weinhold # and don't need to have any dirname. Their LOCATE variables are used to 12750931b8f9SIngo Weinhold # find their locations. 1276*7669b69fSIngo Weinhold # <makeDefaultDependencies> If true (which is the default), <link> will be 1277*7669b69fSIngo Weinhold # made a dependency of the `files' pseudo target, i.e. it will be made by 1278*7669b69fSIngo Weinhold # default, and removed on `jam clean'. 12790931b8f9SIngo Weinhold 12800931b8f9SIngo Weinhold local target = $(1) ; 12810931b8f9SIngo Weinhold local source = $(2) ; 1282*7669b69fSIngo Weinhold local makeDefaultDependencies = $(3) ; 12830931b8f9SIngo Weinhold local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ; 12840931b8f9SIngo Weinhold local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ; 12850931b8f9SIngo Weinhold local sourcePath = $(source:G=) ; 12860931b8f9SIngo Weinhold sourcePath = $(sourcePath:D=$(sourceDir)) ; 12870931b8f9SIngo Weinhold local targetDirComponents = [ SplitPath $(targetDir) ] ; 12880931b8f9SIngo Weinhold local sourceComponents = [ SplitPath $(sourcePath) ] ; 12890931b8f9SIngo Weinhold 12900931b8f9SIngo Weinhold SymLink $(target) 1291*7669b69fSIngo Weinhold : [ FRelPath $(targetDirComponents) : $(sourceComponents) ] 1292*7669b69fSIngo Weinhold : $(makeDefaultDependencies) ; 12930931b8f9SIngo Weinhold NOUPDATE $(target) ; 12949eea4522SIngo Weinhold Depends $(target) : $(source) ; 12953b9eae39SIngo Weinhold} 12963b9eae39SIngo Weinhold 1297d391d2ebSIngo Weinholdrule AbsSymLink 1298d391d2ebSIngo Weinhold{ 12997bc56df1SIngo Weinhold # AbsSymLink <link> : <link target> : <link dir> 1300*7669b69fSIngo Weinhold # : <makeDefaultDependencies> ; 1301d391d2ebSIngo Weinhold # Creates an absolute symbolic link from <link> to <link target>. 1302d391d2ebSIngo Weinhold # <link> and <link target> must be usual targets. If <link dir> is 1303d391d2ebSIngo Weinhold # given, then it is set as LOCATE directory on <link>. 1304*7669b69fSIngo Weinhold # <makeDefaultDependencies> If true (which is the default), <link> will be 1305*7669b69fSIngo Weinhold # made a dependency of the `files' pseudo target, i.e. it will be made by 1306*7669b69fSIngo Weinhold # default, and removed on `jam clean'. 1307d391d2ebSIngo Weinhold 1308*7669b69fSIngo Weinhold local makeDefaultDependencies = $(4) ; 1309*7669b69fSIngo Weinhold if ! $(makeDefaultDependencies) { 1310*7669b69fSIngo Weinhold makeDefaultDependencies = true ; 1311*7669b69fSIngo Weinhold } 1312*7669b69fSIngo Weinhold 1313d391d2ebSIngo Weinhold Depends $(1) : $(2) ; 1314d391d2ebSIngo Weinhold if $(3) { 1315d391d2ebSIngo Weinhold MakeLocate $(1) : $(3) ; 1316d391d2ebSIngo Weinhold } 1317d391d2ebSIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 1318*7669b69fSIngo Weinhold if $(makeDefaultDependencies) = true { 1319*7669b69fSIngo Weinhold LocalDepends files : $(1) ; 1320d391d2ebSIngo Weinhold LocalClean clean : $(1) ; 1321d391d2ebSIngo Weinhold } 1322*7669b69fSIngo Weinhold} 1323d391d2ebSIngo Weinhold 1324d391d2ebSIngo Weinholdactions AbsSymLink 1325d391d2ebSIngo Weinhold{ 1326d391d2ebSIngo Weinhold target="$(2)" 1327d391d2ebSIngo Weinhold case "$target" in 1328d391d2ebSIngo Weinhold /*) ;; 1329d391d2ebSIngo Weinhold *) target=`pwd`/"$target";; 1330d391d2ebSIngo Weinhold esac 1331d391d2ebSIngo Weinhold $(RM) "$(1)" && $(LN) -s "$target" "$(1)" 1332d391d2ebSIngo Weinhold} 1333d391d2ebSIngo Weinhold 13347bc56df1SIngo Weinholdrule OBOSInstall 13357bc56df1SIngo Weinhold{ 13367bc56df1SIngo Weinhold # Usage: OBOSInstall <[ install [ and uninstall ] pseudotarget ]> 13377bc56df1SIngo Weinhold # : <directory> : <sources to install> 13387bc56df1SIngo Weinhold # : [ <installgrist> ] : [ <install rule> ] ; 13397bc56df1SIngo Weinhold local install = $(1[1]) ; 13407bc56df1SIngo Weinhold install ?= install ; 13417bc56df1SIngo Weinhold local uninstall = $(1[2]) ; 13427bc56df1SIngo Weinhold uninstall ?= un$(install) ; 13437bc56df1SIngo Weinhold local dir = $(2) ; 13447bc56df1SIngo Weinhold local sources = $(3) ; 13457bc56df1SIngo Weinhold local installgrist = $(4) ; 13467bc56df1SIngo Weinhold installgrist ?= $(INSTALLGRIST) ; 13477bc56df1SIngo Weinhold local installRule = $(5) ; 13487bc56df1SIngo Weinhold installRule ?= Install ; 13497bc56df1SIngo Weinhold local targets = $(sources:G=$(installgrist)) ; 13507bc56df1SIngo Weinhold 13517bc56df1SIngo Weinhold Depends $(install) : $(targets) ; 13527bc56df1SIngo Weinhold Clean $(uninstall) : $(targets) ; 13537bc56df1SIngo Weinhold 13547bc56df1SIngo Weinhold SEARCH on $(sources) += $(SEARCH_SOURCE) ; 13557bc56df1SIngo Weinhold MakeLocate $(targets) : $(dir) ; 13567bc56df1SIngo Weinhold 13577bc56df1SIngo Weinhold local source ; 13587bc56df1SIngo Weinhold for source in $(sources) { 13597bc56df1SIngo Weinhold local target = $(source:G=$(installgrist)) ; 13607bc56df1SIngo Weinhold 13617bc56df1SIngo Weinhold Depends $(target) : $(source) ; 13627bc56df1SIngo Weinhold $(installRule) $(target) : $(source) ; 13637bc56df1SIngo Weinhold 13647bc56df1SIngo Weinhold if [ on $(target) return $(MODE) ] { 13657bc56df1SIngo Weinhold Chmod $(target) ; 13667bc56df1SIngo Weinhold } 13677bc56df1SIngo Weinhold 13687bc56df1SIngo Weinhold if $(OWNER) && $(CHOWN) { 13697bc56df1SIngo Weinhold Chown $(target) ; 13707bc56df1SIngo Weinhold OWNER on $(target) = $(OWNER) ; 13717bc56df1SIngo Weinhold } 13727bc56df1SIngo Weinhold 13737bc56df1SIngo Weinhold if $(GROUP) && $(CHGRP) { 13747bc56df1SIngo Weinhold Chgrp $(target) ; 13757bc56df1SIngo Weinhold GROUP on $(target) = $(GROUP) ; 13767bc56df1SIngo Weinhold } 13777bc56df1SIngo Weinhold } 13787bc56df1SIngo Weinhold} 13797bc56df1SIngo Weinhold 1380*7669b69fSIngo Weinholdrule InstallAbsSymLinkAdapter 1381*7669b69fSIngo Weinhold{ 1382*7669b69fSIngo Weinhold # InstallAbsSymLinkAdapter <link> : <link target> 1383*7669b69fSIngo Weinhold if ! [ on $(2) return $(TARGET) ] { 1384*7669b69fSIngo Weinhold TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; 1385*7669b69fSIngo Weinhold } 1386*7669b69fSIngo Weinhold AbsSymLink $(1) : $(2) : : false ; 1387*7669b69fSIngo Weinhold} 1388*7669b69fSIngo Weinhold 13897bc56df1SIngo Weinholdrule OBOSInstallAbsSymLink 13907bc56df1SIngo Weinhold{ 13917bc56df1SIngo Weinhold # Usage: OBOSInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]> 13927bc56df1SIngo Weinhold # : <directory> : <sources to install> 13937bc56df1SIngo Weinhold # : [ <installgrist> ] ; 1394*7669b69fSIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallAbsSymLinkAdapter ; 13957bc56df1SIngo Weinhold} 13967bc56df1SIngo Weinhold 13977bc56df1SIngo Weinholdrule InstallRelSymLinkAdapter 13987bc56df1SIngo Weinhold{ 13997bc56df1SIngo Weinhold # InstallRelSymLinkAdapter <link> : <link target> 14007bc56df1SIngo Weinhold if ! [ on $(2) return $(TARGET) ] { 14017bc56df1SIngo Weinhold TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; 14027bc56df1SIngo Weinhold } 1403*7669b69fSIngo Weinhold RelSymLink $(1) : $(2) : false ; 14047bc56df1SIngo Weinhold} 14057bc56df1SIngo Weinhold 14067bc56df1SIngo Weinholdrule OBOSInstallRelSymLink 14077bc56df1SIngo Weinhold{ 14087bc56df1SIngo Weinhold # Usage: OBOSInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]> 14097bc56df1SIngo Weinhold # : <directory> : <sources to install> 14107bc56df1SIngo Weinhold # : [ <installgrist> ] ; 14117bc56df1SIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ; 14127bc56df1SIngo Weinhold} 14137bc56df1SIngo Weinhold 14147bc56df1SIngo Weinhold 141552a38012Sejakowatz#------------------------------------------------------------------------------- 141652a38012Sejakowatz# Low-level OBOS utility rules 141752a38012Sejakowatz#------------------------------------------------------------------------------- 141852a38012Sejakowatzrule SetupObjectsDir 141952a38012Sejakowatz{ 142052a38012Sejakowatz local rel_objectsdir; 142152a38012Sejakowatz 142252a38012Sejakowatz # Copy subdir tokens except the first, as that will be "sources", and we 142352a38012Sejakowatz # do not want to include that :) 142452a38012Sejakowatz rel_objectsdir = [ FDirName $(SUBDIR_TOKENS[2-]) ] ; 142552a38012Sejakowatz LOCATE_TARGET = [ FDirName $(OBOS_OBJECT_TARGET) $(rel_objectsdir) ] ; 14268d3308d9SIngo Weinhold LOCATE_SOURCE = $(LOCATE_TARGET) ; 14278d3308d9SIngo Weinhold SEARCH_SOURCE = [ Filter $(SEARCH_SOURCE) : $(LOCATE_TARGET) ] 14288d3308d9SIngo Weinhold $(LOCATE_TARGET) ; 142952a38012Sejakowatz} 143052a38012Sejakowatz 143152a38012Sejakowatz#------------------------------------------------------------------------------- 143252a38012Sejakowatz# Link rule/action are overwritten as they don't handle linking files who's name 143352a38012Sejakowatz# contain spaces very well. Also adds resources and version to executable. 143452a38012Sejakowatz#------------------------------------------------------------------------------- 143552a38012Sejakowatzrule Link 143652a38012Sejakowatz{ 143752a38012Sejakowatz # Note: RESFILES must be set before invocation. 143852a38012Sejakowatz MODE on $(<) = $(EXEMODE) ; 143952a38012Sejakowatz on $(1) XRes $(1) : $(RESFILES) ; 144052a38012Sejakowatz Chmod $(<) ; 144152a38012Sejakowatz SetType $(1) ; 144252a38012Sejakowatz MimeSet $(1) ; 14431419ae2bSshatty SetVersion $(1) ; 144452a38012Sejakowatz} 144552a38012Sejakowatz 144652a38012Sejakowatzactions Link bind NEEDLIBS 144752a38012Sejakowatz{ 14481eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(2)" "$(NEEDLIBS)" $(LINKLIBS) ; 144952a38012Sejakowatz} 145052a38012Sejakowatz 14518d3308d9SIngo Weinholdrule LexC++ 14528d3308d9SIngo Weinhold{ 14538d3308d9SIngo Weinhold Depends $(1) : $(2) ; 14548d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_SOURCE) ; 14558d3308d9SIngo Weinhold LocalClean clean : $(1) ; 14568d3308d9SIngo Weinhold} 14578d3308d9SIngo Weinhold 14588d3308d9SIngo Weinholdactions LexC++ 14598d3308d9SIngo Weinhold{ 14608d3308d9SIngo Weinhold $(LEX) -o$(1) $(2) 14618d3308d9SIngo Weinhold} 14628d3308d9SIngo Weinhold 14638d3308d9SIngo Weinholdrule Bison 14648d3308d9SIngo Weinhold{ 14658d3308d9SIngo Weinhold local _h ; 14668d3308d9SIngo Weinhold 14678d3308d9SIngo Weinhold _h = $(1).h ; 14688d3308d9SIngo Weinhold 14698d3308d9SIngo Weinhold MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ; 14708d3308d9SIngo Weinhold 14718d3308d9SIngo Weinhold Depends $(<) $(_h) : $(>) ; 14728d3308d9SIngo Weinhold Bison1 $(<) $(_h) : $(>) ; 14738d3308d9SIngo Weinhold LocalClean clean : $(<) $(_h) ; 14748d3308d9SIngo Weinhold 14758d3308d9SIngo Weinhold # make sure someone includes $(_h) else it will be 14768d3308d9SIngo Weinhold # a deadly independent target 14778d3308d9SIngo Weinhold 14788d3308d9SIngo Weinhold Includes $(<) : $(_h) ; 14798d3308d9SIngo Weinhold} 14808d3308d9SIngo Weinhold 14818d3308d9SIngo Weinholdactions Bison1 14828d3308d9SIngo Weinhold{ 14838d3308d9SIngo Weinhold bison $(YACCFLAGS) -o $(1[1]) $(2) 14848d3308d9SIngo Weinhold} 14858d3308d9SIngo Weinhold 148652a38012Sejakowatz# BeOS specific rules 148752a38012Sejakowatz 148852a38012Sejakowatzrule XRes 148952a38012Sejakowatz{ 149052a38012Sejakowatz # XRes <target> : <resource files> 149152a38012Sejakowatz if $(2) 149252a38012Sejakowatz { 14939eea4522SIngo Weinhold Depends $(1) : $(2) ; 149452a38012Sejakowatz XRes1 $(1) : $(2) ; 149552a38012Sejakowatz } 149652a38012Sejakowatz} 149752a38012Sejakowatz 149852a38012Sejakowatzrule XRes1 { } 149952a38012Sejakowatz 150052a38012Sejakowatzrule SetVersion 150152a38012Sejakowatz{ 150252a38012Sejakowatz # SetVersion <target> 150352a38012Sejakowatz} 150452a38012Sejakowatz 150552a38012Sejakowatzrule SetType 150652a38012Sejakowatz{ 150752a38012Sejakowatz # SetType <target> 150852a38012Sejakowatz} 150952a38012Sejakowatz 151052a38012Sejakowatzrule MimeSet 151152a38012Sejakowatz{ 151252a38012Sejakowatz # SetType <target> 151352a38012Sejakowatz} 151452a38012Sejakowatz 151552a38012Sejakowatz 151652a38012Sejakowatzif $(OS) = BEOS 151752a38012Sejakowatz{ 151852a38012Sejakowatz 151952a38012Sejakowatzactions XRes1 152052a38012Sejakowatz{ 15210931b8f9SIngo Weinhold xres -o "$(1)" "$(2)" ; 152252a38012Sejakowatz} 152352a38012Sejakowatz 152452a38012Sejakowatzactions SetVersion 152552a38012Sejakowatz{ 152652a38012Sejakowatz setversion "$(1)" -system $(OBOS_BUILD_VERSION) -short "$(OBOS_BUILD_DESCRIPTION)" ; 152752a38012Sejakowatz} 152852a38012Sejakowatz 152952a38012Sejakowatzactions SetType 153052a38012Sejakowatz{ 153152a38012Sejakowatz settype -t $(OBOS_TARGET_TYPE) "$(1)" ; 153252a38012Sejakowatz} 153352a38012Sejakowatz 153452a38012Sejakowatzactions MimeSet 153552a38012Sejakowatz{ 153652a38012Sejakowatz mimeset -f "$(1)" ; 153752a38012Sejakowatz} 153852a38012Sejakowatz 153952a38012Sejakowatz} # if BEOS 154052a38012Sejakowatz 154152a38012Sejakowatz 154252a38012Sejakowatzrule assemble 154352a38012Sejakowatz{ 154494782cf7SIngo Weinhold Depends $(<) : $(>) ; 154594782cf7SIngo Weinhold ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ; 154694782cf7SIngo Weinhold ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ; 154752a38012Sejakowatz} 154852a38012Sejakowatz 154952a38012Sejakowatzactions assemble 155052a38012Sejakowatz{ 1551a8687de4SAxel Dörfler $(CC) -c "$(2)" -O2 $(ASFLAGS) -D_ASSEMBLER $(KERNEL_CCFLAGS) $(ASHDRS) -o "$(1)" ; 155252a38012Sejakowatz} 155352a38012Sejakowatz 15540931b8f9SIngo Weinhold# Overridden to allow spaces in file names. 15550931b8f9SIngo Weinholdactions Chmod1 15560931b8f9SIngo Weinhold{ 15570931b8f9SIngo Weinhold $(CHMOD) "$(MODE)" "$(1)" 15580931b8f9SIngo Weinhold} 15590931b8f9SIngo Weinhold 15606991af8cSIngo Weinhold# Overridden to allow spaces in file names. 15616991af8cSIngo Weinholdactions piecemeal together existing Clean 15626991af8cSIngo Weinhold{ 15636991af8cSIngo Weinhold $(RM) "$(>)" 15646991af8cSIngo Weinhold} 15656991af8cSIngo Weinhold 156608125d07SIngo Weinholdrule ObjectReference 156708125d07SIngo Weinhold{ 156808125d07SIngo Weinhold # ObjectReference <reference object> : <source object> 156908125d07SIngo Weinhold # Makes <reference object> refer to the same file as <source object>. 157008125d07SIngo Weinhold # The filenames must of course be identical. 157108125d07SIngo Weinhold # <source object> must have already been LOCATEd. 157208125d07SIngo Weinhold 157308125d07SIngo Weinhold local ref = $(1) ; 157408125d07SIngo Weinhold local source = $(2) ; 157508125d07SIngo Weinhold if $(ref) != $(source) { 15769eea4522SIngo Weinhold Depends $(ref) : $(source) ; 157721df5945SIngo Weinhold LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ; 157808125d07SIngo Weinhold } 157908125d07SIngo Weinhold} 158008125d07SIngo Weinhold 158108125d07SIngo Weinholdrule ObjectReferences 158208125d07SIngo Weinhold{ 158308125d07SIngo Weinhold # ObjectReferences <source objects> 158408125d07SIngo Weinhold # Creates local references to <source objects>, i.e. identifiers with the 158508125d07SIngo Weinhold # current grist referring to the same files. <source objects> must have 158608125d07SIngo Weinhold # already been LOCATEd. 158708125d07SIngo Weinhold 158808125d07SIngo Weinhold local source ; 158908125d07SIngo Weinhold for source in $(1) { 159008125d07SIngo Weinhold ObjectReference [ FGristFiles $(source) ] : $(source) ; 159108125d07SIngo Weinhold } 159208125d07SIngo Weinhold} 159308125d07SIngo Weinhold 15949fc6b2e1SIngo Weinholdrule Filter 15959fc6b2e1SIngo Weinhold{ 15969fc6b2e1SIngo Weinhold # Filter <list> : <excludes> ; 15979fc6b2e1SIngo Weinhold # Removes all occurrences of <excludes> in <list>. 15989fc6b2e1SIngo Weinhold 15999fc6b2e1SIngo Weinhold local list = $(1) ; 16009fc6b2e1SIngo Weinhold local excludes = $(2) ; 16019fc6b2e1SIngo Weinhold local newList ; 16029fc6b2e1SIngo Weinhold local item ; 16039fc6b2e1SIngo Weinhold for item in $(list) { 16049fc6b2e1SIngo Weinhold local skip ; 16059fc6b2e1SIngo Weinhold local exclude ; 16069fc6b2e1SIngo Weinhold for exclude in $(excludes) { 16079fc6b2e1SIngo Weinhold if $(item) = $(exclude) { 16089fc6b2e1SIngo Weinhold skip = true ; 16099fc6b2e1SIngo Weinhold } 16109fc6b2e1SIngo Weinhold } 16119fc6b2e1SIngo Weinhold if ! $(skip) { 1612dd9f8062SIngo Weinhold newList += $(item) ; 16139fc6b2e1SIngo Weinhold } 16149fc6b2e1SIngo Weinhold } 16159fc6b2e1SIngo Weinhold return $(newList) ; 16169fc6b2e1SIngo Weinhold} 16179fc6b2e1SIngo Weinhold 16180931b8f9SIngo Weinhold 161952a38012Sejakowatz## Kernel stuff! 162052a38012Sejakowatz 162152a38012Sejakowatzrule SetupKernel 162252a38012Sejakowatz{ 162352a38012Sejakowatz # Usage SetupKernel <sources_or_objects> : <extra_cc_flags>; 162452a38012Sejakowatz 16252dd47f63SIngo Weinhold local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 162652a38012Sejakowatz 162728d2a30eSDaniel Reinhold #Setup Kernel header directories 1628089a0629Sbeveloper local public_kernel_includes = add-ons/file_system add-ons/graphics device drivers kernel storage support ; 1629b8b44e7aSAxel Dörfler local private_kernel_includes = kernel libroot kernel/boot/platform/$(OBOS_BOOT_PLATFORM) ; 1630a6c008e1Sbeveloper # Use posix headers directory 163128d2a30eSDaniel Reinhold HDRS = [ FDirName $(OBOS_TOP) headers posix ] ; 1632a6c008e1Sbeveloper # Use public OS header directories 1633089a0629Sbeveloper HDRS += [ PublicHeaders $(public_kernel_includes) ] ; 1634089a0629Sbeveloper # Use private directories 1635089a0629Sbeveloper HDRS += [ PrivateHeaders $(private_kernel_includes) ] ; 163609c5682dSIngo Weinhold # The platform dependent headers. 163709c5682dSIngo Weinhold HDRS += $(PLATFORM_HEADERS) ; 1638a6c008e1Sbeveloper 163952a38012Sejakowatz UseArchHeaders $(OBOS_ARCH) ; 164052a38012Sejakowatz 164152a38012Sejakowatz SetupObjectsDir ; 164252a38012Sejakowatz 164352a38012Sejakowatz CCFLAGS on $(_objs) = $(KERNEL_CCFLAGS) $(2) ; 164498cc804cSAxel Dörfler C++FLAGS on $(_objs) = $(KERNEL_C++FLAGS) $(2) ; 164552a38012Sejakowatz} 164652a38012Sejakowatz 164752a38012Sejakowatzrule KernelObjects 164852a38012Sejakowatz{ 164952a38012Sejakowatz SetupKernel $(1) : $(2) ; 165052a38012Sejakowatz 165152a38012Sejakowatz Objects $(1) ; 165252a38012Sejakowatz} 165352a38012Sejakowatz 165452a38012Sejakowatzrule KernelLd 165552a38012Sejakowatz{ 165680721244SAxel Dörfler # KernelLd <name> : <objs> : <linkerscript> : <args> : <gcc_off> : <config_section> ; 165752a38012Sejakowatz 165852a38012Sejakowatz SetupKernel $(2) ; 165952a38012Sejakowatz LINK on $(1) = ld ; 166052a38012Sejakowatz 166152a38012Sejakowatz LINKFLAGS on $(1) = $(4) ; 166252a38012Sejakowatz if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 166352a38012Sejakowatz 166452a38012Sejakowatz # Remove any preset LINKLIBS 166552a38012Sejakowatz LINKLIBS on $(1) = ; 166652a38012Sejakowatz 166752a38012Sejakowatz # Show that we depend on the libraries we need 16689eea4522SIngo Weinhold LocalClean clean : $(1) ; 16699eea4522SIngo Weinhold LocalDepends all : $(1) ; 167052a38012Sejakowatz Depends $(1) : $(2) ; 167152a38012Sejakowatz 167252a38012Sejakowatz if $(6) { 167352a38012Sejakowatz for i in $(6) { 16742a83bfb4SIngo Weinhold KernelConfigSection $(i) : elf32 : $(1) ; 167552a38012Sejakowatz } 167652a38012Sejakowatz } 167752a38012Sejakowatz 167852a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 167952a38012Sejakowatz 168009c5682dSIngo Weinhold # Add the platform specific static libs (libgcc.a). 168152a38012Sejakowatz if ! $(5) { 168209c5682dSIngo Weinhold LINKLIBS on $(1) += $(PLATFORM_LINKLIBS) ; 168352a38012Sejakowatz } 168452a38012Sejakowatz} 168552a38012Sejakowatz 168652a38012Sejakowatzactions KernelLd 168752a38012Sejakowatz{ 16881eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ; 168952a38012Sejakowatz} 169052a38012Sejakowatz 169180721244SAxel Dörflerrule KernelMergeObject 169280721244SAxel Dörfler{ 16932fbd7065SIngo Weinhold # KernelMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ; 16942fbd7065SIngo Weinhold # Compiles source files and merges the object files to an object file. 16952fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 16962fbd7065SIngo Weinhold # <sources>: Sources to be compiled. Grist will be added. 16972fbd7065SIngo Weinhold # <extra CFLAGS>: Additional flags for compilation. 16982fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 16992fbd7065SIngo Weinhold # will be added. 17002fbd7065SIngo Weinhold # 170180721244SAxel Dörfler 170280721244SAxel Dörfler SetupKernel $(2) : $(3) ; 170380721244SAxel Dörfler 170480721244SAxel Dörfler MakeLocateObjects $(2) ; 170580721244SAxel Dörfler Objects $(2) ; 17062fbd7065SIngo Weinhold MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; 170780721244SAxel Dörfler} 170880721244SAxel Dörfler 170952a38012Sejakowatzrule KernelStaticLibrary 171052a38012Sejakowatz{ 171152a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ; 171252a38012Sejakowatz # This is designed to take a set of sources and libraries and create 171352a38012Sejakowatz # a file called lib<name>.a 171452a38012Sejakowatz 171552a38012Sejakowatz SetupKernel $(2) : $(3) ; 171652a38012Sejakowatz 171752a38012Sejakowatz MakeLocateObjects $(2) ; 171852a38012Sejakowatz Library $(1) : $(2) ; 171952a38012Sejakowatz} 172052a38012Sejakowatz 172152a38012Sejakowatzrule KernelStaticLibraryObjects 172252a38012Sejakowatz{ 172352a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> ; 172452a38012Sejakowatz # This is designed to take a set of sources and libraries and create 172552a38012Sejakowatz # a file called <name> 172652a38012Sejakowatz 172752a38012Sejakowatz SetupKernel $(2) ; 172852a38012Sejakowatz 172952a38012Sejakowatz # Show that we depend on the libraries we need 17309eea4522SIngo Weinhold LocalClean clean : $(1) ; 17319eea4522SIngo Weinhold LocalDepends all : $(1) ; 173252a38012Sejakowatz Depends $(1) : $(2) ; 173352a38012Sejakowatz 173452a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 173552a38012Sejakowatz} 173652a38012Sejakowatz 173752a38012Sejakowatzactions KernelStaticLibraryObjects 173852a38012Sejakowatz{ 17390931b8f9SIngo Weinhold ar -r "$(1)" "$(2)" ; 174052a38012Sejakowatz} 174152a38012Sejakowatz 17425dc4e1efSIngo Weinholdrule BuildPlatformMain 174352a38012Sejakowatz{ 17445dc4e1efSIngo Weinhold # Usage BuildPlatformMain <target> : <sources> ; 174552a38012Sejakowatz SetupObjectsDir ; 17465dc4e1efSIngo Weinhold SetupDefaultIncludes ; 174752a38012Sejakowatz 17485dc4e1efSIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 17495dc4e1efSIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 17505dc4e1efSIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 17515dc4e1efSIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 17525dc4e1efSIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 175352a38012Sejakowatz 175452a38012Sejakowatz Main $(1) : $(2) ; 17555dc4e1efSIngo Weinhold 17565dc4e1efSIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 17575dc4e1efSIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 17585dc4e1efSIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 175952a38012Sejakowatz} 176052a38012Sejakowatz 17619fcaa61dSIngo Weinholdrule BuildPlatformTest 17629fcaa61dSIngo Weinhold{ 17639fcaa61dSIngo Weinhold # Usage BuildPlatformTest <target> : <sources> ; 17649fcaa61dSIngo Weinhold 17659fcaa61dSIngo Weinhold local target = $(1) ; 17669fcaa61dSIngo Weinhold local sources = $(2) ; 17679fcaa61dSIngo Weinhold 17689fcaa61dSIngo Weinhold BuildPlatformMain $(target) : $(sources) ; 17699fcaa61dSIngo Weinhold local relPath ; 17709fcaa61dSIngo Weinhold if [ FIsPrefix src tests : $(SUBDIR_TOKENS) ] { 17719fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[3-]) ; 17729fcaa61dSIngo Weinhold } else { 17739fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[2-]) ; 17749fcaa61dSIngo Weinhold } 17759fcaa61dSIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 17769fcaa61dSIngo Weinhold} 17779fcaa61dSIngo Weinhold 177852a38012Sejakowatzrule KernelConfigSection 177952a38012Sejakowatz{ 178052a38012Sejakowatz # KernelConfigSection <section> : <type> : <file> ; 17812a83bfb4SIngo Weinhold 17822a83bfb4SIngo Weinhold SECTION_NAMES on $(OBOS_KERNEL_CONFIG) += $(1) ; 17832a83bfb4SIngo Weinhold SECTION_TYPES on $(OBOS_KERNEL_CONFIG) += $(2) ; 17842a83bfb4SIngo Weinhold SECTION_FILES on $(OBOS_KERNEL_CONFIG) += $(3) ; 17852a83bfb4SIngo Weinhold 17862a83bfb4SIngo Weinhold Depends $(OBOS_KERNEL_CONFIG) : $(3) ; 178752a38012Sejakowatz} 178852a38012Sejakowatz 178952a38012Sejakowatzrule WriteKernelConfig 179052a38012Sejakowatz{ 179152a38012Sejakowatz # usage: WriteKernelConfig <target> ; 179252a38012Sejakowatz 17939eea4522SIngo Weinhold LocalDepends files : $(1) ; 179452a38012Sejakowatz 17952a83bfb4SIngo Weinhold MakeLocate $(1) : $(OBOS_OBJECT_TARGET) ; 179652a38012Sejakowatz 17979eea4522SIngo Weinhold LocalClean clean : $(1) ; 179852a38012Sejakowatz} 179952a38012Sejakowatz 18002a83bfb4SIngo Weinholdactions WriteKernelConfig bind SECTION_FILES 180152a38012Sejakowatz{ 18020931b8f9SIngo Weinhold target="$(1)" 18030931b8f9SIngo Weinhold echo "# OpenBeOS Kernel Config File" > "$target" 18040931b8f9SIngo Weinhold echo "# Automatically generated - do not edit!" >> "$target" 18052a83bfb4SIngo Weinhold count=0 18062a83bfb4SIngo Weinhold for section in "$(SECTION_NAMES)" ; do 18072a83bfb4SIngo Weinhold count=`expr $count + 1` 18082a83bfb4SIngo Weinhold eval section$count="$section" 18092a83bfb4SIngo Weinhold done 18102a83bfb4SIngo Weinhold i=1 18112a83bfb4SIngo Weinhold for type in "$(SECTION_TYPES)" ; do 18122a83bfb4SIngo Weinhold eval type$i="$type" 18132a83bfb4SIngo Weinhold i=`expr $i + 1` 18142a83bfb4SIngo Weinhold done 18152a83bfb4SIngo Weinhold i=1 18162a83bfb4SIngo Weinhold for file in "$(SECTION_FILES)" ; do 18172a83bfb4SIngo Weinhold eval file$i="$file" 18182a83bfb4SIngo Weinhold i=`expr $i + 1` 18192a83bfb4SIngo Weinhold done 18202a83bfb4SIngo Weinhold for i in `seq $count` ; do 18212a83bfb4SIngo Weinhold eval section="\$section$i" 18222a83bfb4SIngo Weinhold eval type="\$type$i" 18232a83bfb4SIngo Weinhold eval file="\$file$i" 18240931b8f9SIngo Weinhold echo "" >> "$target" 18252a83bfb4SIngo Weinhold echo "["$section"]" >> "$target" 18262a83bfb4SIngo Weinhold echo "type="$type >> "$target" 18270931b8f9SIngo Weinhold case "$file" in 182852a38012Sejakowatz /*) ;; 18290931b8f9SIngo Weinhold *) file=`pwd`/"$file";; 183052a38012Sejakowatz esac 18312a83bfb4SIngo Weinhold echo "file="$file >> "$target" 183252a38012Sejakowatz done 183352a38012Sejakowatz} 183452a38012Sejakowatz 183552a38012Sejakowatzrule BuildKernel 183652a38012Sejakowatz{ 183752a38012Sejakowatz # Usage BuildKernel <target> : <config_file> ; 18380c0b2cd0SIngo Weinhold local kernel = $(1) ; 18390c0b2cd0SIngo Weinhold local configFile = $(2) ; 18400c0b2cd0SIngo Weinhold local bootmaker = bootmaker ; 184152a38012Sejakowatz 18429eea4522SIngo Weinhold LocalDepends all : $(kernel) ; 18430c0b2cd0SIngo Weinhold Depends $(kernel) : $(configFile) $(bootmaker) ; 18449eea4522SIngo Weinhold LocalClean clean : $(kernel) ; 18450c0b2cd0SIngo Weinhold MakeLocate $(kernel) : $(LOCATE_TARGET) ; 184652a38012Sejakowatz 18470c0b2cd0SIngo Weinhold BOOT_MAKER on $(kernel) = $(bootmaker) ; 184852a38012Sejakowatz} 184952a38012Sejakowatz 18500c0b2cd0SIngo Weinholdactions BuildKernel bind BOOT_MAKER 185152a38012Sejakowatz{ 18520c0b2cd0SIngo Weinhold "$(BOOT_MAKER)" --strip-debug --strip-binary strip "$(2)" -o "$(1)" ; 185352a38012Sejakowatz echo "" 185452a38012Sejakowatz echo "Kernel linked!" 185552a38012Sejakowatz echo "" 185652a38012Sejakowatz} 185752a38012Sejakowatz 185852a38012Sejakowatzrule KernelFloppyImage 185952a38012Sejakowatz{ 186052a38012Sejakowatz # Usage KernelFloppyImage <target> : <kernel> : <bootblock> ; 18610c0b2cd0SIngo Weinhold local floppy = $(1) ; 18620c0b2cd0SIngo Weinhold local kernel = $(2) ; 18630c0b2cd0SIngo Weinhold local bootblock = $(3) ; 18640c0b2cd0SIngo Weinhold local makeflop = makeflop ; 186552a38012Sejakowatz 18669eea4522SIngo Weinhold LocalDepends all : $(floppy) ; 18670c0b2cd0SIngo Weinhold Depends $(floppy) : $(kernel) $(bootblock) $(makeflop) ; 18689eea4522SIngo Weinhold LocalClean clean : $(floppy) ; 18690c0b2cd0SIngo Weinhold MakeLocate $(floppy) : $(OBOS_OBJECT_TARGET) ; 187052a38012Sejakowatz 18710c0b2cd0SIngo Weinhold BOOT_BLOCK on $(floppy) = $(bootblock) ; 18720c0b2cd0SIngo Weinhold MAKE_FLOP on $(floppy) = $(makeflop) ; 187352a38012Sejakowatz} 187452a38012Sejakowatz 187552a38012Sejakowatz# This may be a bit verbose, but I think it's useful to show what's 187652a38012Sejakowatz# going on, at least in this early stage of development. 18770c0b2cd0SIngo Weinholdactions KernelFloppyImage bind BOOT_BLOCK bind MAKE_FLOP 187852a38012Sejakowatz{ 18797378dd7fSAxel Dörfler "$(MAKE_FLOP)" "-p $(shell expr 18 \* 2 \* 512)" "$(BOOT_BLOCK)" "$(2)" "$(1)" ; 18800c0b2cd0SIngo Weinhold 188152a38012Sejakowatz echo "" 188252a38012Sejakowatz echo "*************************************************" 188352a38012Sejakowatz echo "* Kernel build completed! *" 188452a38012Sejakowatz echo "* Boot image for a 1.44M floppy created *" 188552a38012Sejakowatz echo "*************************************************" 188652a38012Sejakowatz echo "" 18870c0b2cd0SIngo Weinhold echo "Floppy image is $(1)" 188852a38012Sejakowatz echo "The following command will write it to a floppy on BeOS" 18890c0b2cd0SIngo Weinhold echo " dd if=$(1) of=/dev/disk/floppy/raw bs=18k" 18900c0b2cd0SIngo Weinhold echo "Alternatively you can run" 18910c0b2cd0SIngo Weinhold echo " ./configure --floppy /dev/disk/floppy/raw" 18920c0b2cd0SIngo Weinhold echo "once and build + write the image subsequently via" 18930c0b2cd0SIngo Weinhold echo " jam installfloppy" 189452a38012Sejakowatz echo "" 189552a38012Sejakowatz} 189652a38012Sejakowatz 18970c0b2cd0SIngo Weinholdrule InstallFloppy 18980c0b2cd0SIngo Weinhold{ 18990c0b2cd0SIngo Weinhold # InstallFloppy <target> : <floppy> 19000c0b2cd0SIngo Weinhold # "dd"s <floppy> to $(FLOPPY_PATH). 19010c0b2cd0SIngo Weinhold 19020c0b2cd0SIngo Weinhold local target = $(1) ; 19030c0b2cd0SIngo Weinhold local floppy = $(2) ; 19040c0b2cd0SIngo Weinhold 19050c0b2cd0SIngo Weinhold NotFile $(target) ; 19060c0b2cd0SIngo Weinhold Always $(target) ; 19070c0b2cd0SIngo Weinhold Depends $(target) : $(floppy) ; 19080c0b2cd0SIngo Weinhold} 19090c0b2cd0SIngo Weinhold 19100c0b2cd0SIngo Weinholdactions InstallFloppy 19110c0b2cd0SIngo Weinhold{ 19120c0b2cd0SIngo Weinhold if [ -z $(FLOPPY_PATH) ] ; then 19130c0b2cd0SIngo Weinhold echo "Can't install floppy: FLOPPY_PATH not set." 19140c0b2cd0SIngo Weinhold echo "run: ./configure --floppy <floppy path>" 19150c0b2cd0SIngo Weinhold echo 19160c0b2cd0SIngo Weinhold exit 0 19170c0b2cd0SIngo Weinhold fi 19180c0b2cd0SIngo Weinhold dd if=$(2) of=$(FLOPPY_PATH) bs=18k 19190c0b2cd0SIngo Weinhold} 192052a38012Sejakowatz 192121df5945SIngo Weinhold#------------------------------------------------------------------------------- 192221df5945SIngo Weinhold# FreeType 2 specific rules and variables 192321df5945SIngo Weinhold#------------------------------------------------------------------------------- 192421df5945SIngo Weinhold 192521df5945SIngo WeinholdFT2_INCLUDE = [ FDirName $(OBOS_TOP) headers libs freetype2 ] ; 192621df5945SIngo WeinholdFT2_SRC = [ FDirName $(OBOS_TOP) src libs freetype2 ] ; 192721df5945SIngo Weinhold 192821df5945SIngo WeinholdFT2_LIB = freetype ; 192921df5945SIngo Weinhold 1930fbd28219SIngo WeinholdFT2_COMPONENTS ?= gzip # support for gzip-compressed files. 1931fbd28219SIngo Weinhold autohint # auto-hinter 1932fbd28219SIngo Weinhold base # base component (public APIs) 1933fbd28219SIngo Weinhold bdf # BDF font driver 1934fbd28219SIngo Weinhold cache # cache sub-system 1935fbd28219SIngo Weinhold cff # CFF/CEF font driver 1936fbd28219SIngo Weinhold cid # Postscript CID-keyed font driver 1937fbd28219SIngo Weinhold pcf # PCF font driver 1938fbd28219SIngo Weinhold pfr # PFR/TrueDoc font driver 1939fbd28219SIngo Weinhold psaux # Common Postscript routines module 1940fbd28219SIngo Weinhold pshinter # Postscript hinter module 1941fbd28219SIngo Weinhold psnames # Postscript names handling 1942fbd28219SIngo Weinhold raster # Monochrome rasterizer 1943fbd28219SIngo Weinhold smooth # Anti-aliased rasterizer 1944fbd28219SIngo Weinhold sfnt # SFNT-based format support routines 1945fbd28219SIngo Weinhold truetype # TrueType font driver 1946fbd28219SIngo Weinhold type1 # Postscript Type 1 font driver 1947fbd28219SIngo Weinhold type42 # Postscript Type 42 (embedded TrueType) driver 1948fbd28219SIngo Weinhold winfonts # Windows FON/FNT font driver 1949fbd28219SIngo Weinhold ; 1950fbd28219SIngo Weinhold 195121df5945SIngo Weinholdrule UseFreeTypeHeaders 195221df5945SIngo Weinhold{ 195321df5945SIngo Weinhold SubDirHdrs $(FT2_INCLUDE) ; 195421df5945SIngo Weinhold} 195521df5945SIngo Weinhold 195621df5945SIngo Weinholdrule UseFreeTypeObjectHeaders 195721df5945SIngo Weinhold{ 19589b60a208SIngo Weinhold # UseFreeTypeObjectHeaders <sources> [ : <objects> ] ; 19599b60a208SIngo Weinhold SourceHdrs $(1) : $(FT2_INCLUDE) : $(2) ; 196021df5945SIngo Weinhold} 196121df5945SIngo Weinhold 196221df5945SIngo Weinholdrule FT2_SubDir 196321df5945SIngo Weinhold{ 196421df5945SIngo Weinhold # FT2_SubDir <dir> 196521df5945SIngo Weinhold # <dir>: Components of a directory in the original hierarchy. 196621df5945SIngo Weinhold local dir = $(1) ; 196721df5945SIngo Weinhold local topDir ; 196821df5945SIngo Weinhold switch $(dir[1]) 196921df5945SIngo Weinhold { 197021df5945SIngo Weinhold case "include" : topDir = $(FT2_INCLUDE) ; 197121df5945SIngo Weinhold case src : topDir = $(FT2_SRC) ; 197221df5945SIngo Weinhold case * : ECHO "Unknown FreeType2 directory: " $(dir) ; 197321df5945SIngo Weinhold } 197421df5945SIngo Weinhold return [ FDirName $(topDir) $(dir[2-]) ] ; 197521df5945SIngo Weinhold} 197621df5945SIngo Weinhold 197721df5945SIngo Weinholdrule FT2_Library 197821df5945SIngo Weinhold{ 197921df5945SIngo Weinhold # FT2_Library <libname> : <sources> 198021df5945SIngo Weinhold # Builds objects from sources and adds the objects to the list of objects 198121df5945SIngo Weinhold # to be linked into the library. 198221df5945SIngo Weinhold # <libname> The name of the library. 198321df5945SIngo Weinhold # <sources> The sources. 198421df5945SIngo Weinhold 198521df5945SIngo Weinhold local library = lib$(1).so ; 198621df5945SIngo Weinhold local sources = $(2) ; 198728d2a30eSDaniel Reinhold SetupIncludes ; 198821df5945SIngo Weinhold SetupObjectsDir ; 198921df5945SIngo Weinhold MakeLocateObjects $(sources) ; 199021df5945SIngo Weinhold Objects $(sources) ; 199121df5945SIngo Weinhold LIBRARY_OBJECTS on $(library) += [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 199221df5945SIngo Weinhold} 199321df5945SIngo Weinhold 199421df5945SIngo Weinholdrule FT2_LinkLibrary 199521df5945SIngo Weinhold{ 199621df5945SIngo Weinhold # FT2_LinkLibrary <libname> 199721df5945SIngo Weinhold # Links the library from the objects build with FT2_LIBRARY before. 199821df5945SIngo Weinhold 199921df5945SIngo Weinhold local library = lib$(1).so ; 200021df5945SIngo Weinhold local objects = [ on $(library) return $(LIBRARY_OBJECTS) ] ; 200121df5945SIngo Weinhold ObjectReferences $(objects) ; 200221df5945SIngo Weinhold objects = [ FGristFiles $(objects) ] ; 200321df5945SIngo Weinhold SharedLibraryFromObjects $(1) : $(objects) ; 200421df5945SIngo Weinhold} 200521df5945SIngo Weinhold 2006