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 49*8c17a26bSIngo Weinhold# analyze GCC version 50*8c17a26bSIngo Weinholdif ! $(GCC_RAW_VERSION) { 51*8c17a26bSIngo Weinhold ECHO "Variable GCC_RAW_VERSION not set. Please run ./configure or" ; 52*8c17a26bSIngo Weinhold EXIT "specify it manually." ; 53*8c17a26bSIngo Weinhold} 54*8c17a26bSIngo WeinholdGCC_VERSION = ; 55*8c17a26bSIngo Weinhold{ 56*8c17a26bSIngo Weinhold # split the raw version string at `.' and `-' characters 57*8c17a26bSIngo Weinhold local version = $(GCC_RAW_VERSION) ; 58*8c17a26bSIngo Weinhold while $(version) { 59*8c17a26bSIngo Weinhold local split = [ Match "([^.-]*)[.-](.*)" : $(version) ] ; 60*8c17a26bSIngo Weinhold if $(split) { 61*8c17a26bSIngo Weinhold GCC_VERSION += $(split[1]) ; 62*8c17a26bSIngo Weinhold version = $(split[2]) ; 63*8c17a26bSIngo Weinhold } else { 64*8c17a26bSIngo Weinhold GCC_VERSION += $(version) ; 65*8c17a26bSIngo Weinhold version = ; 66*8c17a26bSIngo Weinhold } 67*8c17a26bSIngo Weinhold } 68*8c17a26bSIngo Weinhold} 69*8c17a26bSIngo 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) ; 1440ff867c2Sbeveloper 1459eea4522SIngo Weinhold# We might later want to introduce debug levels or handle the whole issue 1469eea4522SIngo Weinhold# differently. For now there's only on or off. 1479eea4522SIngo Weinhold# 14865c62a01SIngo WeinholdDEBUG ?= 0 ; 14965c62a01SIngo Weinholdif $(DEBUG) != 0 { 1509eea4522SIngo Weinhold OPTIM ?= -O0 ; 15165c62a01SIngo Weinhold CCFLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 15265c62a01SIngo Weinhold C++FLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 15365c62a01SIngo Weinhold KERNEL_CCFLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 15465c62a01SIngo Weinhold KERNEL_C++FLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 1559eea4522SIngo Weinhold LINKFLAGS += -g ; 1569eea4522SIngo Weinhold} else { 1579eea4522SIngo Weinhold OPTIM ?= -O2 ; 1589eea4522SIngo Weinhold} 15996d27465SIngo Weinhold# 16096d27465SIngo Weinhold# To disable for the tests OPTIM and DEBUG are overridden, set the environment 16196d27465SIngo Weinhold# variable NO_TEST_DEBUG. 1629eea4522SIngo Weinhold 16316fa4445SIngo Weinhold# Instructs the Library rule to not make its object files temporary. 164f1e077f8SIngo Weinhold# This is needed as some objects are used in a static library and for an 16516fa4445SIngo Weinhold# executable. 16616fa4445SIngo WeinholdKEEPOBJS = true ; 16716fa4445SIngo Weinhold 1687bc56df1SIngo Weinhold# under BeOS use copyattr instead of cp 1697bc56df1SIngo Weinholdif $(OS) = BEOS 1707bc56df1SIngo Weinhold{ 1717bc56df1SIngo Weinhold CP = copyattr --data ; 1727bc56df1SIngo Weinhold} 1737bc56df1SIngo Weinhold 17452a38012Sejakowatz# If no OBOS_OBJECT_TARGET is not defined yet, use our default directory and 17552a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 17652a38012Sejakowatz# builds mixing objects from different targets). 17752a38012Sejakowatzif ! $(OBOS_OBJECT_TARGET) { 17852a38012Sejakowatz OBOS_OBJECT_TARGET ?= [ FDirName $(OBOS_TOP) objects $(OBOS_TARGET) ] ; 17952a38012Sejakowatz} 18052a38012Sejakowatz 18152a38012Sejakowatz# If no OBOS_DISTRO_TARGET is not defined yet, use our default directory and 18252a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 18352a38012Sejakowatz# builds mixing executables from different targets). 18452a38012Sejakowatzif ! $(OBOS_DISTRO_TARGET) { 18552a38012Sejakowatz OBOS_DISTRO_TARGET ?= [ FDirName $(OBOS_TOP) distro $(OBOS_TARGET) ] ; 18652a38012Sejakowatz} 18752a38012Sejakowatz 18852a38012Sejakowatz# Set our version number if not already set and mark it as a developer build 18952a38012Sejakowatzif ! $(OBOS_BUILD_VERSION) { 19052a38012Sejakowatz OBOS_BUILD_VERSION ?= "1 0 0 a 1" ; 19152a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Developer Build" ; 19252a38012Sejakowatz} 19352a38012Sejakowatz 19452a38012Sejakowatz# If OBOS_BUILD_VERSION is set, but OBOS_BUILD_DESCRIPTION isn't, mark it as 19552a38012Sejakowatz# an unknown build. 19652a38012Sejakowatzif ! $(OBOS_BUILD_DESCRIPTION) { 19752a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Unknown Build" ; 19852a38012Sejakowatz} 19952a38012Sejakowatz 200505554b4SIngo Weinhold# Relative subdirs for distro dir 201505554b4SIngo WeinholdOBOS_ADDON_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system add-ons ] ; 2025f281ed5SejakowatzOBOS_APPS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos apps ] ; 203f06de7f3SIngo WeinholdOBOS_BIN_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos bin ] ; 204505554b4SIngo WeinholdOBOS_ETC_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos etc ] ; 205505554b4SIngo WeinholdOBOS_FONTS_DIR ?= [ FDirName $(OBOS_ETC_DIR) fonts ] ; 206505554b4SIngo WeinholdOBOS_KERNEL_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system ] ; 20752a38012SejakowatzOBOS_PREFS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos preferences ] ; 20852a38012SejakowatzOBOS_SERVER_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system servers ] ; 20952a38012SejakowatzOBOS_SHLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ; 210e9230d05SIngo WeinholdOBOS_STLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) develop lib 211e9230d05SIngo Weinhold $(OBOS_ARCH) ] ; 21252a38012SejakowatzOBOS_TEST_DIR ?= [ FDirName $(OBOS_TOP) tests ] ; 21352a38012Sejakowatz 21452a38012SejakowatzOBOS_KERNEL_CONFIG = config.$(OBOS_ARCH).ini ; 21552a38012SejakowatzOBOS_KERNEL = kernel.$(OBOS_ARCH) ; 21652a38012SejakowatzOBOS_FLOPPY = floppy.$(OBOS_ARCH) ; 21752a38012Sejakowatz 21852a38012Sejakowatzrule SetupIncludes 21952a38012Sejakowatz{ 220cfc7b456Sshatty # XXX add "opengl" later 221cfc7b456Sshatty 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 ; 222a6c008e1Sbeveloper 22328d2a30eSDaniel Reinhold # Overwrite any exiting content when changing HDRS. This rule may be invoked multiple times. 224a6c008e1Sbeveloper 225a6c008e1Sbeveloper # Use headers directory, to allow to do things like include <posix/string.h> 22628d2a30eSDaniel Reinhold HDRS = [ FDirName $(OBOS_TOP) headers ] ; 227a6c008e1Sbeveloper 228a6c008e1Sbeveloper # Use posix headers directory 22928d2a30eSDaniel Reinhold HDRS += [ FDirName $(OBOS_TOP) headers posix ] ; 230a6c008e1Sbeveloper 231a6c008e1Sbeveloper # Use public OS header directories 23228d2a30eSDaniel Reinhold HDRS += [ PublicHeaders $(os_includes) ] ; 233a6c008e1Sbeveloper 234a6c008e1Sbeveloper # Used as a fallback, the R5 header directories (we should remove this as soon as possible) 23528d2a30eSDaniel Reinhold HDRS += /boot/develop/headers/posix /boot/develop/headers/cpp ; 23609c5682dSIngo Weinhold 23709c5682dSIngo Weinhold # The platform dependent headers. 23809c5682dSIngo Weinhold HDRS += $(PLATFORM_HEADERS) ; 23952a38012Sejakowatz} 24052a38012Sejakowatz 241dd9f8062SIngo Weinholdrule SetupR5Includes 242dd9f8062SIngo Weinhold{ 243dd9f8062SIngo Weinhold # Unsets HDRS, so that the OBOS headers do not `shadow' the system headers. 244dd9f8062SIngo Weinhold HDRS = ; 245dd9f8062SIngo Weinhold} 246dd9f8062SIngo Weinhold 2475dc4e1efSIngo Weinholdrule SetupDefaultIncludes 2485dc4e1efSIngo Weinhold{ 2495dc4e1efSIngo Weinhold # Resets HDRS to the default headers for the build platform. 2505dc4e1efSIngo Weinhold HDRS = $(PLATFORM_DEFAULT_HEADERS) ; 2515dc4e1efSIngo Weinhold} 2525dc4e1efSIngo Weinhold 25352a38012Sejakowatz#------------------------------------------------------------------------------- 25452a38012Sejakowatz# Things Jam needs in order to work :) 25552a38012Sejakowatz#------------------------------------------------------------------------------- 25652a38012Sejakowatz 2578d3308d9SIngo Weinholdrule Object 2588d3308d9SIngo Weinhold{ 2598d3308d9SIngo Weinhold # This is basically the original Jambase 2.4 Object rule stripped by 2608d3308d9SIngo Weinhold # comments. Only the final switch statement has been changed to allow 2618d3308d9SIngo Weinhold # intermediate C++ files for Yacc and Lex. 2628d3308d9SIngo Weinhold 2638d3308d9SIngo Weinhold LocalClean clean : $(<) ; 2648d3308d9SIngo Weinhold 2658d3308d9SIngo Weinhold MakeLocate $(<) : $(LOCATE_TARGET) ; 2668d3308d9SIngo Weinhold SEARCH on $(>) = $(SEARCH_SOURCE) ; 2678d3308d9SIngo Weinhold 2688d3308d9SIngo Weinhold HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ; 2698d3308d9SIngo Weinhold 2708d3308d9SIngo Weinhold HDRRULE on $(>) = HdrRule ; 2718d3308d9SIngo Weinhold HDRSCAN on $(>) = $(HDRPATTERN) ; 2728d3308d9SIngo Weinhold HDRSEARCH on $(>) = 2738d3308d9SIngo Weinhold $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ; 2748d3308d9SIngo Weinhold 2758d3308d9SIngo Weinhold HDRGRIST on $(>) = $(HDRGRIST) ; 2768d3308d9SIngo Weinhold 2778d3308d9SIngo Weinhold DEFINES on $(<) += $(DEFINES) ; 2788d3308d9SIngo Weinhold 2798d3308d9SIngo Weinhold # if source is not .c, generate .c with specific rule 2808d3308d9SIngo Weinhold 2818d3308d9SIngo Weinhold switch $(>:S) 2828d3308d9SIngo Weinhold { 2838d3308d9SIngo Weinhold case .asm : As $(<) : $(>) ; 2848d3308d9SIngo Weinhold case .c : Cc $(<) : $(>) ; 2858d3308d9SIngo Weinhold case .C : C++ $(<) : $(>) ; 2868d3308d9SIngo Weinhold case .cc : C++ $(<) : $(>) ; 2878d3308d9SIngo Weinhold case .cpp : C++ $(<) : $(>) ; 2888d3308d9SIngo Weinhold case .f : Fortran $(<) : $(>) ; 2898d3308d9SIngo Weinhold case .l : if [ on $(2) return $(GENERATE_C++) ] { 2908d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 2918d3308d9SIngo Weinhold LexC++ $(<:S=.cpp) : $(>) ; 2928d3308d9SIngo Weinhold } else { 2938d3308d9SIngo Weinhold Cc $(<) : $(<:S=.c) ; 2948d3308d9SIngo Weinhold Lex $(<:S=.c) : $(>) ; 2958d3308d9SIngo Weinhold } 2968d3308d9SIngo Weinhold case .s : As $(<) : $(>) ; 2978d3308d9SIngo Weinhold case .y : if [ on $(2) return $(GENERATE_C++) ] { 2988d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 2998d3308d9SIngo Weinhold Bison $(<:S=.cpp) : $(>) ; 3008d3308d9SIngo Weinhold } else { 3018d3308d9SIngo Weinhold Cc $(<) : $(<:S=$(YACCGEN)) ; 3028d3308d9SIngo Weinhold Yacc $(<:S=$(YACCGEN)) : $(>) ; 3038d3308d9SIngo Weinhold } 3048d3308d9SIngo Weinhold case * : UserObject $(<) : $(>) ; 3058d3308d9SIngo Weinhold } 3068d3308d9SIngo Weinhold} 3078d3308d9SIngo Weinhold 30852a38012Sejakowatzrule UserObject 30952a38012Sejakowatz{ 31052a38012Sejakowatz switch $(2) 31152a38012Sejakowatz { 31252a38012Sejakowatz case *.S : assemble $(1) : $(2) ; 31308125d07SIngo Weinhold case *.o : return ; 31452a38012Sejakowatz case * : ECHO "unknown suffix on" $(2) ; 31552a38012Sejakowatz } 31652a38012Sejakowatz} 31752a38012Sejakowatz 31852a38012Sejakowatz# Override the default to give "prettier" command lines. 31952a38012Sejakowatzactions Cc 32052a38012Sejakowatz{ 3210931b8f9SIngo Weinhold $(CC) -c "$(2)" $(CCFLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; 32252a38012Sejakowatz} 32352a38012Sejakowatz 32452a38012Sejakowatzactions C++ 32552a38012Sejakowatz{ 3260931b8f9SIngo Weinhold $(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; 32752a38012Sejakowatz} 32852a38012Sejakowatz 32952a38012Sejakowatz 33052a38012Sejakowatz#------------------------------------------------------------------------------- 33152a38012Sejakowatz# General High-level OBOS target rules 33252a38012Sejakowatz#------------------------------------------------------------------------------- 33352a38012Sejakowatz 3345f281ed5Sejakowatzrule App 3355f281ed5Sejakowatz{ 336007eb5f2SIngo Weinhold # App <name> : <sources> : <libraries> ; 337a6c008e1Sbeveloper SetupIncludes ; 3385f281ed5Sejakowatz SetupObjectsDir ; 339007eb5f2SIngo Weinhold Main $(1) : $(2) ; 340007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_APPS_DIR) ; 341007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 342007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 343007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 3445f281ed5Sejakowatz} 3455f281ed5Sejakowatz 346f06de7f3SIngo Weinholdrule BinCommand 347f06de7f3SIngo Weinhold{ 348f06de7f3SIngo Weinhold # BinCommand <name> : <sources> : <libraries> ; 349a6c008e1Sbeveloper SetupIncludes ; 350f06de7f3SIngo Weinhold SetupObjectsDir ; 351f06de7f3SIngo Weinhold Main $(1) : $(2) ; 352f06de7f3SIngo Weinhold MakeLocate $(1) : $(OBOS_BIN_DIR) ; 353f06de7f3SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 354007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 355007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 356f06de7f3SIngo Weinhold} 357f06de7f3SIngo Weinhold 358f06de7f3SIngo Weinholdrule StdBinCommands 359f06de7f3SIngo Weinhold{ 360f06de7f3SIngo Weinhold # StdBinCommands <sources> : <libs> ; 361a6c008e1Sbeveloper SetupIncludes ; 362a6c008e1Sbeveloper SetupObjectsDir ; 363f06de7f3SIngo Weinhold local libs = $(2) ; 3649342c27aSIngo Weinhold local source ; 365f06de7f3SIngo Weinhold for source in $(1) 366f06de7f3SIngo Weinhold { 367f06de7f3SIngo Weinhold local target = $(source:S=) ; 368f06de7f3SIngo Weinhold target = [ FGristFiles $(target) ] ; 369a6c008e1Sbeveloper 3703b4190abSbeveloper BinCommand $(target) : $(source) : $(libs) ; 371f06de7f3SIngo Weinhold } 372f06de7f3SIngo Weinhold} 373f06de7f3SIngo Weinhold 37452a38012Sejakowatzrule Preference 37552a38012Sejakowatz{ 376007eb5f2SIngo Weinhold # Preference <name> : <sources> : <libraries> ; 377a6c008e1Sbeveloper SetupIncludes ; 37852a38012Sejakowatz SetupObjectsDir ; 379007eb5f2SIngo Weinhold Main $(1) : $(2) ; 380007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_PREFS_DIR) ; 381007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 382007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 383007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 38452a38012Sejakowatz} 38552a38012Sejakowatz 38652a38012Sejakowatzrule Server 38752a38012Sejakowatz{ 388007eb5f2SIngo Weinhold # Server <name> : <sources> : <libraries> ; 38952a38012Sejakowatz 390a6c008e1Sbeveloper SetupIncludes ; 39152a38012Sejakowatz SetupObjectsDir ; 392007eb5f2SIngo Weinhold Main $(1) : $(2) ; 393007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_SERVER_DIR) ; 394007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 395007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 396007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 39752a38012Sejakowatz} 39852a38012Sejakowatz 39952a38012Sejakowatz# test pseudo targets 40052a38012SejakowatzNOTFILE obostests ; 40152a38012SejakowatzNOTFILE r5tests ; 40252a38012Sejakowatz 403d1f6c38fSTyler Dauwalderrule CommonTestLib 404d1f6c38fSTyler Dauwalder{ 405c5ff4aa6STyler Dauwalder # CommonTestLib <target> : <sources> : <obos libraries> 4069285de51STyler Dauwalder # : <r5 libraries> : <test libraries> : <public headers>; 407d1f6c38fSTyler Dauwalder # Builds a unit test for both OBOS and R5 modules. 408d1f6c38fSTyler Dauwalder # <target> The name of the target. 409d1f6c38fSTyler Dauwalder # <sources> The list of sources. 410d1f6c38fSTyler Dauwalder # <obos libraries> A list of link libraries for the OBOS tests (as passed 411d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 412d1f6c38fSTyler Dauwalder # <r5 libraries> A list of link libraries for the R5 tests (as passed 413d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 4149285de51STyler Dauwalder # <test libraries> A list of link libraries for both OBOS tests and R5 tests 4159285de51STyler Dauwalder # that have a common name (i.e. specify libx.so and the OBOS tests will link 4169285de51STyler Dauwalder # to libx.so and the R5 tests will link to libx_r5.so). 417d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 418d1f6c38fSTyler Dauwalder # UsePublicHeaders). 419d1f6c38fSTyler Dauwalder 420c5ff4aa6STyler Dauwalder TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester lib ] : $(3) $(5) : $(6) ; 421c5ff4aa6STyler Dauwalder R5TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester_r5 lib ] : $(4) [ R5SharedLibraryNames $(5) ] ; 422d1f6c38fSTyler Dauwalder} 423d1f6c38fSTyler Dauwalder 424d1f6c38fSTyler Dauwalderrule TestLib 425d1f6c38fSTyler Dauwalder{ 426d1f6c38fSTyler Dauwalder # TestLib <target> : <sources> : <dest> : <libraries> : <public headers> 427d1f6c38fSTyler Dauwalder # Builds a unit test library for an OBOS module. 428d1f6c38fSTyler Dauwalder # <target> The name of the target. 429d1f6c38fSTyler Dauwalder # <sources> The list of sources. 430d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 431d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 432d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 433d1f6c38fSTyler Dauwalder # UsePublicHeaders). 434d1f6c38fSTyler Dauwalder 435d1f6c38fSTyler Dauwalder local target = $(1) ; 436d1f6c38fSTyler Dauwalder local sources = $(2) ; 437d1f6c38fSTyler Dauwalder local dest = $(3) ; 438d1f6c38fSTyler Dauwalder local libraries = $(4) ; 439d1f6c38fSTyler Dauwalder local headerDirs = $(5) ; 4409342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 441d1f6c38fSTyler Dauwalder 4429342c27aSIngo Weinhold # Our Main replacement. 4439342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 4449342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 445d1f6c38fSTyler Dauwalder 446d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 4470d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 4480d1cdd94SIngo Weinhold Depends obostests : $(target) ; 449d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 450d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 451d1f6c38fSTyler Dauwalder} 452d1f6c38fSTyler Dauwalder 453d1f6c38fSTyler Dauwalderrule R5TestLib 454d1f6c38fSTyler Dauwalder{ 455c5ff4aa6STyler Dauwalder # R5TestLib <target> : <sources> : <dest> : <libraries> 456d1f6c38fSTyler Dauwalder # Builds a unit test for an R5 module. "_r5" is appended to the object 457d1f6c38fSTyler Dauwalder # and the target name. 458d1f6c38fSTyler Dauwalder # <target> The name of the target. 459d1f6c38fSTyler Dauwalder # <sources> The list of sources. 460d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 461d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 462d1f6c38fSTyler Dauwalder 463d1f6c38fSTyler Dauwalder local target = $(1:B)_r5$(1:S) ; 464d1f6c38fSTyler Dauwalder local sources = $(2) ; 465c5ff4aa6STyler Dauwalder local dest = $(3) ; 466d1f6c38fSTyler Dauwalder local libraries = $(4) ; 467d1f6c38fSTyler Dauwalder local objects = [ R5ObjectNames $(sources) ] ; 468d1f6c38fSTyler Dauwalder 469d1f6c38fSTyler Dauwalder # Our Main replacement. 470d1f6c38fSTyler Dauwalder MainFromObjects $(target) : $(objects) ; 4719342c27aSIngo Weinhold TestObjects $(sources) : : true ; 472d1f6c38fSTyler Dauwalder 473d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 4740d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 4750d1cdd94SIngo Weinhold Depends r5tests : $(target) ; 476d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 477d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 478d1f6c38fSTyler Dauwalder} 479d1f6c38fSTyler Dauwalder 48052a38012Sejakowatzrule CommonUnitTest 48152a38012Sejakowatz{ 48252a38012Sejakowatz # CommonUnitTest <target> : <sources> : <dest> : <obos libraries> 48352a38012Sejakowatz # : <r5 libraries> : <public headers>; 48452a38012Sejakowatz # Builds a unit test for both OBOS and R5 modules. 48552a38012Sejakowatz # <target> The name of the target. 48652a38012Sejakowatz # <sources> The list of sources. 48752a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 48852a38012Sejakowatz # <obos libraries> A list of link libraries for the OBOS tests (as passed 48952a38012Sejakowatz # to LinkSharedOSLibs). 49052a38012Sejakowatz # <r5 libraries> A list of link libraries for the R5 tests (as passed 49152a38012Sejakowatz # to LinkSharedOSLibs). 49252a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 49352a38012Sejakowatz # UsePublicHeaders). 49452a38012Sejakowatz 49552a38012Sejakowatz UnitTest $(1) : $(2) : $(3) : $(4) : $(6) ; 49652a38012Sejakowatz R5UnitTest $(1) : $(2) : $(3) : $(5) ; 49752a38012Sejakowatz} 49852a38012Sejakowatz 49952a38012Sejakowatzrule UnitTest 50052a38012Sejakowatz{ 50152a38012Sejakowatz # UnitTest <target> : <sources> : <dest> : <libraries> : <public headers> 50252a38012Sejakowatz # Builds a unit test for an OBOS module. 50352a38012Sejakowatz # <target> The name of the target. 50452a38012Sejakowatz # <sources> The list of sources. 50552a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 50652a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 50752a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 50852a38012Sejakowatz # UsePublicHeaders). 50952a38012Sejakowatz 51052a38012Sejakowatz local target = $(1) ; 51152a38012Sejakowatz local sources = $(2) ; 51252a38012Sejakowatz local dest = $(3) ; 51352a38012Sejakowatz local libraries = $(4) ; 51452a38012Sejakowatz local headerDirs = $(5) ; 5159342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 51652a38012Sejakowatz 5179342c27aSIngo Weinhold # Our Main replacement. 5189342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 5199342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 5203b9eae39SIngo Weinhold 52152a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 5229eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 5239eea4522SIngo Weinhold Depends obostests : $(target) ; 52452a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 52552a38012Sejakowatz} 52652a38012Sejakowatz 52752a38012Sejakowatzrule R5UnitTest 52852a38012Sejakowatz{ 52952a38012Sejakowatz # R5UnitTest <target> : <sources> : <dest> : <libraries> 53052a38012Sejakowatz # Builds a unit test for an R5 module. "_r5" is appended to the object 53152a38012Sejakowatz # and the target name. 53252a38012Sejakowatz # <target> The name of the target. 53352a38012Sejakowatz # <sources> The list of sources. 53452a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 53552a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 53652a38012Sejakowatz 53752a38012Sejakowatz local target = $(1)_r5 ; 53852a38012Sejakowatz local sources = $(2) ; 53952a38012Sejakowatz local dest = $(3) ; 54052a38012Sejakowatz local libraries = $(4) ; 54152a38012Sejakowatz local objects = [ R5ObjectNames $(sources) ] ; 54252a38012Sejakowatz 54352a38012Sejakowatz # Our Main replacement. 54452a38012Sejakowatz MainFromObjects $(target) : $(objects) ; 5459342c27aSIngo Weinhold TestObjects $(sources) : : true ; 54652a38012Sejakowatz 54752a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 5489eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 5499eea4522SIngo Weinhold Depends r5tests : $(target) ; 55052a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 55152a38012Sejakowatz} 55252a38012Sejakowatz 55352a38012Sejakowatzrule R5ObjectNames 55452a38012Sejakowatz{ 55552a38012Sejakowatz # R5ObjectNames <sources> ; 55652a38012Sejakowatz # Returns a list of gristed object names given a list of source file names. 55752a38012Sejakowatz # Moreover each object names gets "_r5" inserted before the object suffix. 55852a38012Sejakowatz local objects = $(1:S=)_r5 ; 55952a38012Sejakowatz return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ; 56052a38012Sejakowatz} 56152a38012Sejakowatz 5629342c27aSIngo Weinholdrule R5Objects 5639342c27aSIngo Weinhold{ 5649342c27aSIngo Weinhold # R5Objects <sources> 565dd9f8062SIngo Weinhold # Similar to Objects, but appends "_r5" to the object file names and 566dd9f8062SIngo Weinhold # removes `-nostdinc' from the CC and C++ flags to enable system headers. 5679342c27aSIngo Weinhold # <sources> The source files. 5689342c27aSIngo Weinhold 569dd9f8062SIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 570dd9f8062SIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 571dd9f8062SIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 572dd9f8062SIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 573dd9f8062SIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 574dd9f8062SIngo Weinhold 5759342c27aSIngo Weinhold local sources = $(1) ; 5769342c27aSIngo Weinhold local source ; 5779342c27aSIngo Weinhold for source in [ FGristFiles $(sources) ] 5789342c27aSIngo Weinhold { 5799342c27aSIngo Weinhold local object = [ R5ObjectNames $(source) ] ; 5809342c27aSIngo Weinhold Object $(object) : $(source) ; 5819342c27aSIngo Weinhold LocalDepends obj : $(object) ; 5829342c27aSIngo Weinhold } 583dd9f8062SIngo Weinhold 584dd9f8062SIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 585dd9f8062SIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 586dd9f8062SIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 5879342c27aSIngo Weinhold} 5889342c27aSIngo Weinhold 5899342c27aSIngo Weinholdrule TestObjects 5909342c27aSIngo Weinhold{ 5919342c27aSIngo Weinhold # TestLib <sources> : <public headers> : <r5> 5929342c27aSIngo Weinhold # Compiles objects for tests. 5939342c27aSIngo Weinhold # <sources> The list of sources. 5949342c27aSIngo Weinhold # <public headers> A list of public header dirs (as passed to 5959342c27aSIngo Weinhold # UsePublicHeaders). 5969342c27aSIngo Weinhold # <r5> If set, "_r5" is appended to the object file names and 5979342c27aSIngo Weinhold # <public headers> is ignored. Furthermore the pre-processor macro 5989342c27aSIngo Weinhold # TEST_R5 is defined, TEST_OBOS otherwise. 5999342c27aSIngo Weinhold 6009342c27aSIngo Weinhold local sources = $(1) ; 6019342c27aSIngo Weinhold local headerDirs = $(2) ; 6029342c27aSIngo Weinhold local r5 = $(3) ; 6039342c27aSIngo Weinhold local objects ; 6049342c27aSIngo Weinhold 6059342c27aSIngo Weinhold # Turn optimization off. 60696d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6079342c27aSIngo Weinhold local optim = $(OPTIM) ; 6089342c27aSIngo Weinhold OPTIM = ; 60996d27465SIngo Weinhold } 6109342c27aSIngo Weinhold 6119342c27aSIngo Weinhold SetupObjectsDir ; 6129342c27aSIngo Weinhold 6139342c27aSIngo Weinhold # compile 6149342c27aSIngo Weinhold if $(r5) { 615dd9f8062SIngo Weinhold SetupR5Includes ; 6169342c27aSIngo Weinhold objects = [ R5ObjectNames $(sources) ] ; 6179342c27aSIngo Weinhold R5Objects $(sources) ; 6189342c27aSIngo Weinhold } else { 619dd9f8062SIngo Weinhold SetupIncludes ; 6209342c27aSIngo Weinhold objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 6219342c27aSIngo Weinhold Objects $(sources) ; 6229342c27aSIngo Weinhold } 6239342c27aSIngo Weinhold 6249342c27aSIngo Weinhold # set headers/defines 6259b60a208SIngo Weinhold UseCppUnitObjectHeaders $(sources) : $(objects) ; 6269342c27aSIngo Weinhold if $(r5) { 627728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_R5 ; 6289342c27aSIngo Weinhold } else { 6299b60a208SIngo Weinhold UsePublicObjectHeaders $(sources) : $(headerDirs) : $(objects) ; 630728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_OBOS ; 6319342c27aSIngo Weinhold } 6329342c27aSIngo Weinhold 63396d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6349342c27aSIngo Weinhold # Turn debugging on. That is usually desired for test code. 6359342c27aSIngo Weinhold ObjectCcFlags $(objects) : "-g" ; 6369342c27aSIngo Weinhold ObjectC++Flags $(objects) : "-g" ; 6379342c27aSIngo Weinhold 6389342c27aSIngo Weinhold # Turn optimization on again. 6399342c27aSIngo Weinhold OPTIM = $(optim) ; 6409342c27aSIngo Weinhold } 64196d27465SIngo Weinhold} 6429342c27aSIngo Weinhold 6439285de51STyler Dauwalderrule R5SharedLibraryNames 6449285de51STyler Dauwalder{ 6459285de51STyler Dauwalder # R5SharedLibraryNames <sources> ; 6469285de51STyler Dauwalder # Returns a list of shared library names given a list of file names. NO 6479285de51STyler Dauwalder # GRISTING IS PERFORMED :-) However, each library names gets "_r5" inserted 6489285de51STyler Dauwalder # before the shared lib suffix. 6499285de51STyler Dauwalder return $(1:S=)_r5.so ; 6509285de51STyler Dauwalder} 6519285de51STyler Dauwalder 6529fc6b2e1SIngo Weinholdrule SimpleTest 6539fc6b2e1SIngo Weinhold{ 6549fc6b2e1SIngo Weinhold # UnitTest <target> : <sources> : <libraries> 6559fc6b2e1SIngo Weinhold # Builds a unit test for an OBOS module. 6569fc6b2e1SIngo Weinhold # <target> The name of the target. 6579fc6b2e1SIngo Weinhold # <sources> The list of sources. 6589fc6b2e1SIngo Weinhold # <dest> The directory for the target (as passed to FDirName). 6599fc6b2e1SIngo Weinhold # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 6609fc6b2e1SIngo Weinhold # <public headers> A list of public header dirs (as passed to 6619fc6b2e1SIngo Weinhold # UsePublicHeaders). 6629fc6b2e1SIngo Weinhold 6639fc6b2e1SIngo Weinhold local target = $(1) ; 6649fc6b2e1SIngo Weinhold local sources = $(2) ; 6659fc6b2e1SIngo Weinhold local libraries = $(3) ; 6669fc6b2e1SIngo Weinhold local relPath = [ FRelPath src tests : $(SUBDIR_TOKENS) ] ; 6679fc6b2e1SIngo Weinhold 6689fc6b2e1SIngo Weinhold # Turn optimization off. 66996d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6709fc6b2e1SIngo Weinhold local optim = $(OPTIM) ; 6719fc6b2e1SIngo Weinhold OPTIM = ; 67296d27465SIngo Weinhold } 6739fc6b2e1SIngo Weinhold 674a6c008e1Sbeveloper SetupIncludes ; 6759fc6b2e1SIngo Weinhold SetupObjectsDir ; 6769fc6b2e1SIngo Weinhold MakeLocateObjects $(sources) ; 6779fc6b2e1SIngo Weinhold Main $(target) : $(sources) ; 6789fc6b2e1SIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 6799eea4522SIngo Weinhold Depends obostests : $(target) ; 6809fc6b2e1SIngo Weinhold LinkSharedOSLibs $(target) : $(libraries) ; 681728b5725SIngo Weinhold ObjectsDefines $(sources) : TEST_OBOS ; 68296d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6839fc6b2e1SIngo Weinhold # Turn debugging on. That is usually desired for test code. 6849fc6b2e1SIngo Weinhold ObjectCcFlags $(sources) : "-g" ; 6859fc6b2e1SIngo Weinhold ObjectC++Flags $(sources) : "-g" ; 6869fc6b2e1SIngo Weinhold 6879fc6b2e1SIngo Weinhold # Turn optimization on again. 6889fc6b2e1SIngo Weinhold OPTIM = $(optim) ; 6899fc6b2e1SIngo Weinhold } 69096d27465SIngo Weinhold} 6919fc6b2e1SIngo Weinhold 69252a38012Sejakowatzrule Addon 69352a38012Sejakowatz{ 69483b3b0dfSIngo Weinhold # Addon <name> : <relpath> : <sources> : <is executable> : <libraries> ; 6957a384fdeSIngo Weinhold # <name>: Name of the add-on. 6967a384fdeSIngo Weinhold # <relpath>: Path where the add-on shall live relative to the add-on dir. 6977a384fdeSIngo Weinhold # <sources>: Source files. 69883b3b0dfSIngo Weinhold # <is executable>: true, if the target shall be executable as well. 69983b3b0dfSIngo Weinhold # <libraries>: Libraries to be linked against. 7007a384fdeSIngo Weinhold 7017a384fdeSIngo Weinhold local isExecutable = $(4) ; 70252a38012Sejakowatz 703a6c008e1Sbeveloper SetupIncludes ; 70452a38012Sejakowatz SetupObjectsDir ; 70552a38012Sejakowatz Main $(1) : $(3) ; 70652a38012Sejakowatz 70752a38012Sejakowatz # Create output dir path for addon 70852a38012Sejakowatz local targetdir; 70952a38012Sejakowatz targetdir = [ FDirName $(OBOS_ADDON_DIR) $(2) ] ; 71052a38012Sejakowatz 71152a38012Sejakowatz MakeLocate $(1) : $(targetdir) ; 7127a384fdeSIngo Weinhold 7137a384fdeSIngo Weinhold local linkFlags = -Xlinker -soname=\"$(1)\" ; 7147a384fdeSIngo Weinhold if $(isExecutable) != true { 7157a384fdeSIngo Weinhold linkFlags = -nostart $(linkFlags) ; 7167a384fdeSIngo Weinhold } 7177a384fdeSIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] $(linkFlags) ; 71883b3b0dfSIngo Weinhold LinkSharedOSLibs $(1) : $(5) ; 719af28904fSIngo Weinhold} 720af28904fSIngo Weinhold 72158efc9d8SIngo Weinholdrule R5KernelAddon 722af28904fSIngo Weinhold{ 72358efc9d8SIngo Weinhold # R5KernelAddon <name> : <relpath> : <sources> ; 724af28904fSIngo Weinhold 725af28904fSIngo Weinhold local sources = $(3) ; 726af28904fSIngo Weinhold 727af28904fSIngo Weinhold Addon $(1) : $(2) : $(3) ; 728af28904fSIngo Weinhold ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 729af28904fSIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic 730af28904fSIngo Weinhold -fno-exceptions -fno-rtti ; 7319eea4522SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; 732af28904fSIngo Weinhold LinkSharedOSLibs $(1) : /boot/develop/lib/x86/_KERNEL_ ; 73352a38012Sejakowatz} 73452a38012Sejakowatz 7354fb5add0SMatthew Wilberrule Translator 7364fb5add0SMatthew Wilber{ 737007eb5f2SIngo Weinhold # Translator <name> : <sources> : <libraries> ; 738a6c008e1Sbeveloper SetupIncludes ; 7394fb5add0SMatthew Wilber SetupObjectsDir ; 7404fb5add0SMatthew Wilber Main $(1) : $(2) ; 741007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 7424fb5add0SMatthew Wilber 7434fb5add0SMatthew Wilber # Create output dir path for translator 7444fb5add0SMatthew Wilber local targetdir; 745d5b07cf2Sshatty targetdir = [ FDirName $(OBOS_ADDON_DIR) Translators ] ; 7464fb5add0SMatthew Wilber MakeLocate $(1) : $(targetdir) ; 7474fb5add0SMatthew Wilber} 7484fb5add0SMatthew Wilber 74952a38012Sejakowatzrule MakeLocateObjects 75052a38012Sejakowatz{ 75121df5945SIngo Weinhold # MakeLocateObjects <sources_or_objects> ; 75252a38012Sejakowatz 75321df5945SIngo Weinhold local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 75452a38012Sejakowatz 75552a38012Sejakowatz for o in $(_objs) 75652a38012Sejakowatz { 75752a38012Sejakowatz local dir = $(o:D) ; 75852a38012Sejakowatz if $(dir) { 75952a38012Sejakowatz MakeLocate $(o) : [ FDirName $(LOCATE_TARGET) $(dir) ] ; 76052a38012Sejakowatz } else { 76152a38012Sejakowatz MakeLocate $(o) : $(LOCATE_TARGET) ; 76252a38012Sejakowatz } 76352a38012Sejakowatz } 76452a38012Sejakowatz} 76552a38012Sejakowatz 76652a38012Sejakowatzrule StaticLibrary 76752a38012Sejakowatz{ 768e9230d05SIngo Weinhold # StaticLibrary <name> : <sources> [ : <target dir> ] ; 769e9230d05SIngo Weinhold # Creates a static library from sources. 770e9230d05SIngo Weinhold # <name>: Basename of the library, without leading "lib" and trailing ".a". 771e9230d05SIngo Weinhold # <source>: List of source files. 772e9230d05SIngo Weinhold # <target dir>: Directory into which the library shall be placed. Defaults 773e9230d05SIngo Weinhold # to the standard directory for static libs. 774e9230d05SIngo Weinhold # 775e9230d05SIngo Weinhold local lib = lib$(1)$(SUFLIB) ; 776a6c008e1Sbeveloper SetupIncludes ; 77752a38012Sejakowatz SetupObjectsDir ; 77852a38012Sejakowatz MakeLocateObjects $(2) ; 779e9230d05SIngo Weinhold Library $(lib) : $(2) ; 780e9230d05SIngo Weinhold local targetDir = $(3) ; 781e9230d05SIngo Weinhold if ! $(targetDir) { 782e9230d05SIngo Weinhold targetDir = $(OBOS_STLIB_DIR) ; 783e9230d05SIngo Weinhold } 784e9230d05SIngo Weinhold MakeLocate $(lib) : $(targetDir) ; 785f1e077f8SIngo Weinhold 786f1e077f8SIngo Weinhold # If KEEPOBJS is set, Library doesn't make the library depend on 787f1e077f8SIngo Weinhold # `lib'. 788f1e077f8SIngo Weinhold if $(KEEPOBJS) { 789f1e077f8SIngo Weinhold LocalDepends lib : $(lib) ; 790f1e077f8SIngo Weinhold } 79152a38012Sejakowatz} 79252a38012Sejakowatz 793dbf96817SIngo Weinholdrule R5KernelStaticLibrary 794dbf96817SIngo Weinhold{ 795dbf96817SIngo Weinhold # R5KernelStaticLibrary <name> : <sources> ; 796dbf96817SIngo Weinhold 797f1e077f8SIngo Weinhold local lib = lib$(1)$(SUFLIB) ; 798dbf96817SIngo Weinhold local sources = $(2) ; 799dbf96817SIngo Weinhold 800dbf96817SIngo Weinhold SetupIncludes ; 801dbf96817SIngo Weinhold SetupObjectsDir ; 802dbf96817SIngo Weinhold MakeLocateObjects $(sources) ; 803dbf96817SIngo Weinhold Library $(lib) : $(sources) ; 804dbf96817SIngo Weinhold ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 805dbf96817SIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic 806dbf96817SIngo Weinhold -fno-exceptions -fno-rtti ; 807dbf96817SIngo Weinhold} 808dbf96817SIngo Weinhold 80980721244SAxel Dörflerrule MergeObjectFromObjects 81080721244SAxel Dörfler{ 81180721244SAxel Dörfler # MergeObjectFromObjects <name> : <objects> ; 812c8aa252aSIngo Weinhold local objects = [ FGristFiles $(2) ] ; 81380721244SAxel Dörfler MakeLocate $(1) : $(LOCATE_TARGET) ; 814c8aa252aSIngo Weinhold Depends $(1) : $(objects) ; 81580721244SAxel Dörfler LINK on $(1) = ld ; 816c8aa252aSIngo Weinhold MergeObjectFromObjects1 $(1) : $(objects) ; 81780721244SAxel Dörfler} 81880721244SAxel Dörfler 81954b7cbe1SIngo Weinholdactions MergeObjectFromObjects1 82080721244SAxel Dörfler{ 82180721244SAxel Dörfler $(LINK) -r $(2) -o $(1) ; 82280721244SAxel Dörfler} 82380721244SAxel Dörfler 82480721244SAxel Dörflerrule MergeObject 82580721244SAxel Dörfler{ 82680721244SAxel Dörfler # MergeObject <name> : <sources> ; 82780721244SAxel Dörfler SetupIncludes ; 82880721244SAxel Dörfler SetupObjectsDir ; 82980721244SAxel Dörfler MakeLocateObjects $(2) ; 83080721244SAxel Dörfler Objects $(2) ; 83180721244SAxel Dörfler MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) ; 83280721244SAxel Dörfler} 83380721244SAxel Dörfler 83421df5945SIngo Weinholdrule SharedLibraryFromObjects 83552a38012Sejakowatz{ 8368d3308d9SIngo Weinhold # SharedLibraryFromObjects <name> : <objects> : <libraries> ; 83752a38012Sejakowatz local _lib = lib$(1).so ; 83821df5945SIngo Weinhold MainFromObjects $(_lib) : $(2) ; 83952a38012Sejakowatz MakeLocate $(_lib) : $(OBOS_SHLIB_DIR) ; 8409eea4522SIngo Weinhold LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ] 8419eea4522SIngo Weinhold -nostart -Xlinker -soname=\"$(_lib)\" ; 8428d3308d9SIngo Weinhold LinkSharedOSLibs $(_lib) : $(3) ; 84352a38012Sejakowatz} 84452a38012Sejakowatz 84521df5945SIngo Weinholdrule SharedLibrary 84621df5945SIngo Weinhold{ 8478d3308d9SIngo Weinhold # SharedLibrary <name> : <sources> : <libraries> ; 848a6c008e1Sbeveloper SetupIncludes ; 84921df5945SIngo Weinhold SetupObjectsDir ; 85021df5945SIngo Weinhold MakeLocateObjects $(2) ; 85121df5945SIngo Weinhold Objects $(2) ; 8528d3308d9SIngo Weinhold SharedLibraryFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; 85321df5945SIngo Weinhold} 85421df5945SIngo Weinhold 85552a38012Sejakowatzrule LinkSharedOSLibs 85652a38012Sejakowatz{ 85752a38012Sejakowatz # LinkSharedOSLibs <name> : <libs> ; 85852a38012Sejakowatz # Valid elements for <libs> are e.g. "be" or "libopenbeos.so" or 8594236d490SIngo Weinhold # "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy 8604236d490SIngo Weinhold # has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the 8614236d490SIngo Weinhold # file will be bound!), otherwise it is prefixed "-l" and added to 862a8cd0719SIngo Weinhold # LINKLIBS. If you want to specify a target that isn't a library and 863a8cd0719SIngo Weinhold # also has neither grist nor a dirname, you can prepend "<nogrist>" as 864a8cd0719SIngo Weinhold # grist; it will be stripped by this rule. 86552a38012Sejakowatz 86652a38012Sejakowatz for i in $(>) 86752a38012Sejakowatz { 8684236d490SIngo Weinhold local isfile = ; 8694236d490SIngo Weinhold if $(i:D) || $(i:G) { 8704236d490SIngo Weinhold isfile = true ; 871a8cd0719SIngo Weinhold if $(i:G) = <nogrist> { 872a8cd0719SIngo Weinhold i = $(i:G=) ; 873a8cd0719SIngo Weinhold } 8744236d490SIngo Weinhold } else { 87552a38012Sejakowatz switch $(i:B) 87652a38012Sejakowatz { 877007eb5f2SIngo Weinhold # XXX: _APP_ and _KERNEL_ should not be needed for ELF. 878f7901247SPhilippe Houdoin case _APP_ : isfile = true ; 879f7901247SPhilippe Houdoin case _KERNEL_ : isfile = true ; 8804236d490SIngo Weinhold case lib* : isfile = true ; 8814236d490SIngo Weinhold case * : isfile = ; 8824236d490SIngo Weinhold } 883b8baf385SIngo Weinhold if ! $(isfile) && ( $(i:S) = .so || $(i:S) = .a ) { 884b8baf385SIngo Weinhold isfile = true ; 885b8baf385SIngo Weinhold } 8864236d490SIngo Weinhold } 8874236d490SIngo Weinhold if $(isfile) { 8889eea4522SIngo Weinhold NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(i) ; 8899eea4522SIngo Weinhold Depends $(1) : $(i) ; 8904236d490SIngo Weinhold } else { 8919eea4522SIngo Weinhold LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] -l$(i) ; 89252a38012Sejakowatz } 89352a38012Sejakowatz } 89452a38012Sejakowatz} 89552a38012Sejakowatz 89652a38012Sejakowatzrule LinkStaticOSLibs 89752a38012Sejakowatz{ 89852a38012Sejakowatz # LinkStaticOSLibs <name> : <libs> ; 89952a38012Sejakowatz 90052a38012Sejakowatz for i in $(>) 90152a38012Sejakowatz { 90252a38012Sejakowatz LINKLIBS on $(<) = $(LINKLIBS) -l $(i) ; 90352a38012Sejakowatz } 90452a38012Sejakowatz} 90552a38012Sejakowatz 90652a38012Sejakowatzrule AddResources 90752a38012Sejakowatz{ 90852a38012Sejakowatz # AddResources <name> : <resourcefiles> ; 90952a38012Sejakowatz 9108d3308d9SIngo Weinhold local resfiles = [ FGristFiles $(2) ] ; 9118d3308d9SIngo Weinhold SEARCH on $(resfiles) += $(SEARCH_SOURCE) ; 9128d3308d9SIngo Weinhold 9138d3308d9SIngo Weinhold for file in $(resfiles) { 9148d3308d9SIngo Weinhold if $(file:S) = .rdef { 9158d3308d9SIngo Weinhold local rdef = $(file) ; 9168d3308d9SIngo Weinhold file = $(rdef:S=.rsrc) ; 9178d3308d9SIngo Weinhold ResComp $(file) : $(rdef) ; 9188d3308d9SIngo Weinhold } 9198d3308d9SIngo Weinhold RESFILES on $(1) += $(file) ; 9208d3308d9SIngo Weinhold } 9218d3308d9SIngo Weinhold} 9228d3308d9SIngo Weinhold 9238d3308d9SIngo Weinholdrule ResComp 9248d3308d9SIngo Weinhold{ 9258d3308d9SIngo Weinhold # ResComp <resource file> : <rdef file> ; 9268d3308d9SIngo Weinhold # 9278d3308d9SIngo Weinhold # <resource file> and <rdef file> must be gristed. 9288d3308d9SIngo Weinhold 9298d3308d9SIngo Weinhold SetupObjectsDir ; 9308d3308d9SIngo Weinhold 9319fc6b2e1SIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 9328d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_TARGET) ; 9338d3308d9SIngo Weinhold Depends $(1) : $(2) rc ; 9348d3308d9SIngo Weinhold LocalClean clean : $(1) ; 9358d3308d9SIngo Weinhold ResComp1 $(1) : rc $(2) ; 9368d3308d9SIngo Weinhold} 9378d3308d9SIngo Weinhold 9388d3308d9SIngo Weinholdactions ResComp1 9398d3308d9SIngo Weinhold{ 9406af76074SIngo Weinhold $(2[1]) -o $(1) $(2[2-]) 94152a38012Sejakowatz} 94252a38012Sejakowatz 943728b5725SIngo Weinholdrule ObjectsDefines 944728b5725SIngo Weinhold{ 945728b5725SIngo Weinhold # Like ObjectDefines, but allows multiple files to be supplied 946728b5725SIngo Weinhold local file ; 947728b5725SIngo Weinhold for file in $(1) { 948728b5725SIngo Weinhold ObjectDefines $(file) : $(2) ; 949728b5725SIngo Weinhold } 950728b5725SIngo Weinhold} 951728b5725SIngo Weinhold 9529b60a208SIngo Weinholdrule SourceHdrs 9539b60a208SIngo Weinhold{ 9549b60a208SIngo Weinhold # SourceHdrs <sources> : <headers> [ : <gristed objects> ] ; 9559b60a208SIngo Weinhold # 9569b60a208SIngo Weinhold # Is a wrapper for ObjectHdrs, that passes <sources> and <headers> or, 9579b60a208SIngo Weinhold # if supplied <objects> and <headers>, and also adjusts HDRSEARCH (not 9589b60a208SIngo Weinhold # done by ObjectHdrs). 9599b60a208SIngo Weinhold 9609b60a208SIngo Weinhold local sources = [ FGristFiles $(1) ] ; 9619b60a208SIngo Weinhold local headers = $(2) ; 9629b60a208SIngo Weinhold local objects = $(3) ; 9639b60a208SIngo Weinhold 964728b5725SIngo Weinhold local file ; 9659b60a208SIngo Weinhold if $(objects) { 966728b5725SIngo Weinhold for file in $(objects) { 967728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 968728b5725SIngo Weinhold } 9699b60a208SIngo Weinhold } else { 970728b5725SIngo Weinhold for file in $(sources) { 971728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 972728b5725SIngo Weinhold } 9739b60a208SIngo Weinhold } 9749b60a208SIngo Weinhold 9759b60a208SIngo Weinhold # Also add the header search dirs to HDRSEARCH. Note, that these dirs 9769b60a208SIngo Weinhold # will be listed after the STDHDRS (if any), but that's better than not 9779b60a208SIngo Weinhold # being listed at all. 9789b60a208SIngo Weinhold HDRSEARCH on $(sources) += $(headers) ; 9799b60a208SIngo Weinhold} 9809b60a208SIngo Weinhold 9817d7f280eSIngo Weinholdrule PublicHeaders 98252a38012Sejakowatz{ 9837d7f280eSIngo Weinhold # PublicHeaders <group list> 98452a38012Sejakowatz # 9857d7f280eSIngo Weinhold # Returns the directory names for the public header dirs identified by 9867d7f280eSIngo Weinhold # <group list>. 98752a38012Sejakowatz 98852a38012Sejakowatz local list = $(1) ; 989b005dbe3SAxel Dörfler local dirs = [ FDirName $(OBOS_TOP) headers os ] ; 990b005dbe3SAxel Dörfler 99152a38012Sejakowatz for i in $(list) { 9927d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers os $(i) ] ; 9937d7f280eSIngo Weinhold } 9947d7f280eSIngo Weinhold return $(dirs) ; 99552a38012Sejakowatz} 99652a38012Sejakowatz 9977d7f280eSIngo Weinholdrule PrivateHeaders 9987d7f280eSIngo Weinhold{ 9997d7f280eSIngo Weinhold # PrivateHeaders <group list> 10007d7f280eSIngo Weinhold # 10017d7f280eSIngo Weinhold # Returns the directory names for the private header dirs identified by 10027d7f280eSIngo Weinhold # <group list>. 10037d7f280eSIngo Weinhold 10047d7f280eSIngo Weinhold local list = $(1) ; 10057d7f280eSIngo Weinhold local dirs ; 10067d7f280eSIngo Weinhold for i in $(list) { 10077d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers private $(i) ] ; 10087d7f280eSIngo Weinhold } 10097d7f280eSIngo Weinhold return $(dirs) ; 10107d7f280eSIngo Weinhold} 10117d7f280eSIngo Weinhold 10120f434a0aSDarkWyrmrule LibraryHeaders 10130f434a0aSDarkWyrm{ 10140f434a0aSDarkWyrm # LibraryHeaders <group list> 10150f434a0aSDarkWyrm # 10160f434a0aSDarkWyrm # Returns the directory names for the library header dirs identified by 10170f434a0aSDarkWyrm # <group list>. 10180f434a0aSDarkWyrm 10190f434a0aSDarkWyrm local list = $(1) ; 10200f434a0aSDarkWyrm local dirs ; 10210f434a0aSDarkWyrm for i in $(list) { 10220f434a0aSDarkWyrm dirs += [ FDirName $(OBOS_TOP) headers libs $(i) ] ; 10230f434a0aSDarkWyrm } 10240f434a0aSDarkWyrm return $(dirs) ; 10250f434a0aSDarkWyrm} 10260f434a0aSDarkWyrm 10277d7f280eSIngo Weinholdrule ArchHeaders 10287d7f280eSIngo Weinhold{ 10297d7f280eSIngo Weinhold # usage: ArchHeaders <arch> ; 10307d7f280eSIngo Weinhold # 10317d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 10327d7f280eSIngo Weinhold 10337d7f280eSIngo Weinhold return [ FDirName $(OBOS_TOP) headers private kernel arch $(1) ] ; 10347d7f280eSIngo Weinhold} 10357d7f280eSIngo Weinhold 10367d7f280eSIngo Weinholdrule UsePublicHeaders 10377d7f280eSIngo Weinhold{ 1038966528dcSIngo Weinhold # UsePublicHeaders <group list> ; 1039966528dcSIngo Weinhold # 1040966528dcSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 1041966528dcSIngo Weinhold # dirs of the subdirectory. 1042966528dcSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the 1043966528dcSIngo Weinhold # objects. 1044966528dcSIngo Weinhold 1045966528dcSIngo Weinhold UseHeaders [ PublicHeaders $(1) ] ; 10467d7f280eSIngo Weinhold} 10477d7f280eSIngo Weinhold 10487d7f280eSIngo Weinholdrule UsePublicObjectHeaders 10497d7f280eSIngo Weinhold{ 10509b60a208SIngo Weinhold # UsePublicObjectHeaders <sources> : <group list> [ : <objects> ] ; 10517d7f280eSIngo Weinhold # 10527d7f280eSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 10539b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 10549b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 10557d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 10567d7f280eSIngo Weinhold 10579b60a208SIngo Weinhold SourceHdrs $(1) : [ PublicHeaders $(2) ] : $(3) ; 105852a38012Sejakowatz} 105952a38012Sejakowatz 106052a38012Sejakowatzrule UsePrivateHeaders 106152a38012Sejakowatz{ 10627d7f280eSIngo Weinhold # UsePrivateHeaders <group list> ; 106352a38012Sejakowatz # 106452a38012Sejakowatz # Adds the private C header dirs given by <group list> to the header search 10657d7f280eSIngo Weinhold # dirs of the subdirectory. 10667d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 106752a38012Sejakowatz 10687d7f280eSIngo Weinhold UseHeaders [ PrivateHeaders $(1) ] ; 106952a38012Sejakowatz} 107052a38012Sejakowatz 10717d7f280eSIngo Weinholdrule UsePrivateObjectHeaders 10727d7f280eSIngo Weinhold{ 10739b60a208SIngo Weinhold # UsePrivateObjectHeaders <sources> : <group list> [ : <objects> ] ; 10747d7f280eSIngo Weinhold # 10757d7f280eSIngo Weinhold # Adds the private C header dirs given by <group list> to the header search 10769b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 10779b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 10787d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 10797d7f280eSIngo Weinhold 10809b60a208SIngo Weinhold SourceHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; 108152a38012Sejakowatz} 108252a38012Sejakowatz 108352a38012Sejakowatzrule UseHeaders 108452a38012Sejakowatz{ 10857d7f280eSIngo Weinhold # UseHeaders <headers> ; 108652a38012Sejakowatz # 108752a38012Sejakowatz # Adds the C header dirs <headers> to the header search 10887d7f280eSIngo Weinhold # dirs of the subdirectory. 10897d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 109052a38012Sejakowatz 10917d7f280eSIngo Weinhold local header ; 10927d7f280eSIngo Weinhold for header in $(1) { 109352a38012Sejakowatz SubDirHdrs $(header) ; 109452a38012Sejakowatz } 109552a38012Sejakowatz} 109652a38012Sejakowatz 109752a38012Sejakowatzrule UseCppUnitHeaders 109852a38012Sejakowatz{ 10997d7f280eSIngo Weinhold SubDirHdrs [ FDirName $(OBOS_TOP) headers tools cppunit ] ; 110052a38012Sejakowatz} 110152a38012Sejakowatz 1102be5af1baSIngo Weinholdrule UseCppUnitObjectHeaders 1103be5af1baSIngo Weinhold{ 11049b60a208SIngo Weinhold # UseCppUnitObjectHeaders <sources> [ : <objects> ] ; 11059b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers tools cppunit ] : $(2) ; 1106be5af1baSIngo Weinhold} 1107be5af1baSIngo Weinhold 110852a38012Sejakowatzrule UseArchHeaders 110952a38012Sejakowatz{ 11107d7f280eSIngo Weinhold # usage: UseArchHeaders <arch> ; 11117d7f280eSIngo Weinhold # 111252a38012Sejakowatz # <arch> specifies the architecture (e.g. x86). 11137d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 11147d7f280eSIngo Weinhold 11157d7f280eSIngo Weinhold local headers = [ ArchHeaders $(1) ] ; 111652a38012Sejakowatz local opt = -D$(OBOS_TARGET_DEFINE) ; 1117c633961aSIngo Weinhold 111852a38012Sejakowatz SubDirCcFlags $(opt) ; 111952a38012Sejakowatz SubDirC++Flags $(opt) ; 1120089a0629Sbeveloper HDRS += $(headers) ; 1121c633961aSIngo Weinhold} 1122c633961aSIngo Weinhold 11237d7f280eSIngo Weinholdrule UseArchObjectHeaders 11247d7f280eSIngo Weinhold{ 11259b60a208SIngo Weinhold # usage: UseArchObjectHeaders <sources> : <arch> : [ <objects> ] ; 11267d7f280eSIngo Weinhold # 11277d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 11287d7f280eSIngo Weinhold # <sources_or_objects> Source or object files. 11297d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 11307d7f280eSIngo Weinhold 11319b60a208SIngo Weinhold local sources = $(1) ; 11327d7f280eSIngo Weinhold local headers = [ ArchHeaders $(2) ] ; 11339b60a208SIngo Weinhold local objects = $(3) ; 11349b60a208SIngo Weinhold local targets ; 11359b60a208SIngo Weinhold if $(objects) { 11369b60a208SIngo Weinhold targets = $(objects) ; 11379b60a208SIngo Weinhold } else { 11389b60a208SIngo Weinhold targets = $(sources) ; 11399b60a208SIngo Weinhold } 11407d7f280eSIngo Weinhold local opt = -D$(OBOS_TARGET_DEFINE) ; 11417d7f280eSIngo Weinhold 11427d7f280eSIngo Weinhold ObjectCcFlags $(targets) : $(opt) ; 11437d7f280eSIngo Weinhold ObjectC++Flags $(targets) : $(opt) ; 11449b60a208SIngo Weinhold SourceHdrs $(sources) : $(headers) : $(objects) ; 114552a38012Sejakowatz} 114652a38012Sejakowatz 1147d25a77b4SIngo Weinholdrule UsePosixHeaders 1148d25a77b4SIngo Weinhold{ 1149a6c008e1Sbeveloper # XXX changed to do nothing 1150d25a77b4SIngo Weinhold} 1151d25a77b4SIngo Weinhold 1152d25a77b4SIngo Weinholdrule UsePosixObjectHeaders 1153d25a77b4SIngo Weinhold{ 11549b60a208SIngo Weinhold # UsePosixObjectHeaders <sources> [ : <objects> ] ; 1155d25a77b4SIngo Weinhold # 1156d25a77b4SIngo Weinhold # Adds the POSIX header dir to the header search 11579b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 11589b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 1159d25a77b4SIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 1160d25a77b4SIngo Weinhold 11619b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers posix ] : $(2) ; 1162d25a77b4SIngo Weinhold} 1163d25a77b4SIngo Weinhold 11640f434a0aSDarkWyrmrule UseLibraryHeaders 11650f434a0aSDarkWyrm{ 11660f434a0aSDarkWyrm # UseLibraryHeaders <group list> ; 11670f434a0aSDarkWyrm # 11680f434a0aSDarkWyrm # Adds the library header dirs given by <group list> to the header search 11690f434a0aSDarkWyrm # dirs of the subdirectory. 11700f434a0aSDarkWyrm # NOTE: This rule must be invoked *before* the rule that builds the objects. 11710f434a0aSDarkWyrm 11720f434a0aSDarkWyrm UseHeaders [ LibraryHeaders $(1) ] ; 11730f434a0aSDarkWyrm} 11740f434a0aSDarkWyrm 11753b9eae39SIngo Weinholdrule SplitPath 11763b9eae39SIngo Weinhold{ 11773b9eae39SIngo Weinhold # SplitPath <path> ; 11783b9eae39SIngo Weinhold # Decomposes a path into its components. 11793b9eae39SIngo Weinhold local path = $(1:G=) ; 11803b9eae39SIngo Weinhold local components ; 11818c27f58dSIngo Weinhold # $(path:D) for "/" is "/". Therefore the second condition. 11828c27f58dSIngo Weinhold while $(path:D) && $(path:D) != $(path) 11833b9eae39SIngo Weinhold { 11843b9eae39SIngo Weinhold # Note: $(path:B) returns "." for "..", but $(path:D=) is fine. 11853b9eae39SIngo Weinhold components = $(path:D=) $(components) ; 11863b9eae39SIngo Weinhold path = $(path:D) ; 11873b9eae39SIngo Weinhold } 11883b9eae39SIngo Weinhold components = $(path) $(components) ; 11893b9eae39SIngo Weinhold return $(components) ; 11903b9eae39SIngo Weinhold} 11913b9eae39SIngo Weinhold 11929fc6b2e1SIngo Weinholdrule PrependObjectHdrs 11939fc6b2e1SIngo Weinhold{ 11949fc6b2e1SIngo Weinhold # PrependObjectHdrs <objects_or_sources> : <dirs> ; 11959fc6b2e1SIngo Weinhold # Prepends <dirs> to the list of header search dirs of the objects 11969fc6b2e1SIngo Weinhold # specified by <objects_or_sources>. The HDRS variable will not be 11979fc6b2e1SIngo Weinhold # changed, only CCHDRS. 11989fc6b2e1SIngo Weinhold # Note: A subsequent ObjectHdrs invocation will therefore undo the 11999fc6b2e1SIngo Weinhold # effect of this rule. 12009fc6b2e1SIngo Weinhold # NOTE: This is a hack. 12019fc6b2e1SIngo Weinhold 12029fc6b2e1SIngo Weinhold local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 12039fc6b2e1SIngo Weinhold local dirs = $(2) ; 12049fc6b2e1SIngo Weinhold for object in $(objects) { 12059fc6b2e1SIngo Weinhold # Don't change HDRS to avoid screwing up the header scanning. 12069fc6b2e1SIngo Weinhold PREPENDED_HDRS on $(object) 12079fc6b2e1SIngo Weinhold = $(dirs) [ on $(object) return $(PREPENDED_HDRS) ] ; 12089fc6b2e1SIngo Weinhold CCHDRS on $(object) 12099fc6b2e1SIngo Weinhold = [ FIncludes [ on $(object) return $(PREPENDED_HDRS) $(HDRS) ] ] ; 12109fc6b2e1SIngo Weinhold } 12119fc6b2e1SIngo Weinhold} 12129fc6b2e1SIngo Weinhold 12133b9eae39SIngo Weinholdrule SymLink 12143b9eae39SIngo Weinhold{ 12153b9eae39SIngo Weinhold # SymLink <target> : <source> ; 12163b9eae39SIngo Weinhold # Links <target> to <source>. 12173b9eae39SIngo Weinhold # <source> is the exact link contents. No binding is done. 12183b9eae39SIngo Weinhold LINKCONTENTS on $(1) = $(2) ; 12193b9eae39SIngo Weinhold SymLink1 $(1) ; 12209eea4522SIngo Weinhold LocalDepends all : $(target) ; 12213b9eae39SIngo Weinhold} 12223b9eae39SIngo Weinhold 12233b9eae39SIngo Weinholdactions SymLink1 12243b9eae39SIngo Weinhold{ 12250931b8f9SIngo Weinhold $(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)" 12260931b8f9SIngo Weinhold} 12270931b8f9SIngo Weinhold 12280931b8f9SIngo Weinholdrule RelSymLink 12290931b8f9SIngo Weinhold{ 12300931b8f9SIngo Weinhold # RelSymLink <link> : <link target> 12310931b8f9SIngo Weinhold # Creates a relative symbolic link from <link> to <link target>. 12320931b8f9SIngo Weinhold # <link> and <link target> can be usual targets. They may have a grist 12330931b8f9SIngo Weinhold # and don't need to have any dirname. Their LOCATE variables are used to 12340931b8f9SIngo Weinhold # find their locations. 12350931b8f9SIngo Weinhold 12360931b8f9SIngo Weinhold local target = $(1) ; 12370931b8f9SIngo Weinhold local source = $(2) ; 12380931b8f9SIngo Weinhold local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ; 12390931b8f9SIngo Weinhold local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ; 12400931b8f9SIngo Weinhold local sourcePath = $(source:G=) ; 12410931b8f9SIngo Weinhold sourcePath = $(sourcePath:D=$(sourceDir)) ; 12420931b8f9SIngo Weinhold local targetDirComponents = [ SplitPath $(targetDir) ] ; 12430931b8f9SIngo Weinhold local sourceComponents = [ SplitPath $(sourcePath) ] ; 12440931b8f9SIngo Weinhold 12450931b8f9SIngo Weinhold SymLink $(target) 12460931b8f9SIngo Weinhold : [ FRelPath $(targetDirComponents) : $(sourceComponents) ] ; 12470931b8f9SIngo Weinhold NOUPDATE $(target) ; 12489eea4522SIngo Weinhold Depends $(target) : $(source) ; 12496991af8cSIngo Weinhold LocalClean clean : $(target) ; 12503b9eae39SIngo Weinhold} 12513b9eae39SIngo Weinhold 1252d391d2ebSIngo Weinholdrule AbsSymLink 1253d391d2ebSIngo Weinhold{ 12547bc56df1SIngo Weinhold # AbsSymLink <link> : <link target> : <link dir> 1255d391d2ebSIngo Weinhold # Creates an absolute symbolic link from <link> to <link target>. 1256d391d2ebSIngo Weinhold # <link> and <link target> must be usual targets. If <link dir> is 1257d391d2ebSIngo Weinhold # given, then it is set as LOCATE directory on <link>. 1258d391d2ebSIngo Weinhold 1259d391d2ebSIngo Weinhold LocalDepends files : $(1) ; 1260d391d2ebSIngo Weinhold Depends $(1) : $(2) ; 1261d391d2ebSIngo Weinhold if $(3) { 1262d391d2ebSIngo Weinhold MakeLocate $(1) : $(3) ; 1263d391d2ebSIngo Weinhold } 1264d391d2ebSIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 1265d391d2ebSIngo Weinhold LocalClean clean : $(1) ; 1266d391d2ebSIngo Weinhold} 1267d391d2ebSIngo Weinhold 1268d391d2ebSIngo Weinholdactions AbsSymLink 1269d391d2ebSIngo Weinhold{ 1270d391d2ebSIngo Weinhold target="$(2)" 1271d391d2ebSIngo Weinhold case "$target" in 1272d391d2ebSIngo Weinhold /*) ;; 1273d391d2ebSIngo Weinhold *) target=`pwd`/"$target";; 1274d391d2ebSIngo Weinhold esac 1275d391d2ebSIngo Weinhold $(RM) "$(1)" && $(LN) -s "$target" "$(1)" 1276d391d2ebSIngo Weinhold} 1277d391d2ebSIngo Weinhold 12787bc56df1SIngo Weinholdrule OBOSInstall 12797bc56df1SIngo Weinhold{ 12807bc56df1SIngo Weinhold # Usage: OBOSInstall <[ install [ and uninstall ] pseudotarget ]> 12817bc56df1SIngo Weinhold # : <directory> : <sources to install> 12827bc56df1SIngo Weinhold # : [ <installgrist> ] : [ <install rule> ] ; 12837bc56df1SIngo Weinhold local install = $(1[1]) ; 12847bc56df1SIngo Weinhold install ?= install ; 12857bc56df1SIngo Weinhold local uninstall = $(1[2]) ; 12867bc56df1SIngo Weinhold uninstall ?= un$(install) ; 12877bc56df1SIngo Weinhold local dir = $(2) ; 12887bc56df1SIngo Weinhold local sources = $(3) ; 12897bc56df1SIngo Weinhold local installgrist = $(4) ; 12907bc56df1SIngo Weinhold installgrist ?= $(INSTALLGRIST) ; 12917bc56df1SIngo Weinhold local installRule = $(5) ; 12927bc56df1SIngo Weinhold installRule ?= Install ; 12937bc56df1SIngo Weinhold local targets = $(sources:G=$(installgrist)) ; 12947bc56df1SIngo Weinhold 12957bc56df1SIngo Weinhold Depends $(install) : $(targets) ; 12967bc56df1SIngo Weinhold Clean $(uninstall) : $(targets) ; 12977bc56df1SIngo Weinhold 12987bc56df1SIngo Weinhold SEARCH on $(sources) += $(SEARCH_SOURCE) ; 12997bc56df1SIngo Weinhold MakeLocate $(targets) : $(dir) ; 13007bc56df1SIngo Weinhold 13017bc56df1SIngo Weinhold local source ; 13027bc56df1SIngo Weinhold for source in $(sources) { 13037bc56df1SIngo Weinhold local target = $(source:G=$(installgrist)) ; 13047bc56df1SIngo Weinhold 13057bc56df1SIngo Weinhold Depends $(target) : $(source) ; 13067bc56df1SIngo Weinhold $(installRule) $(target) : $(source) ; 13077bc56df1SIngo Weinhold 13087bc56df1SIngo Weinhold if [ on $(target) return $(MODE) ] { 13097bc56df1SIngo Weinhold Chmod $(target) ; 13107bc56df1SIngo Weinhold } 13117bc56df1SIngo Weinhold 13127bc56df1SIngo Weinhold if $(OWNER) && $(CHOWN) { 13137bc56df1SIngo Weinhold Chown $(target) ; 13147bc56df1SIngo Weinhold OWNER on $(target) = $(OWNER) ; 13157bc56df1SIngo Weinhold } 13167bc56df1SIngo Weinhold 13177bc56df1SIngo Weinhold if $(GROUP) && $(CHGRP) { 13187bc56df1SIngo Weinhold Chgrp $(target) ; 13197bc56df1SIngo Weinhold GROUP on $(target) = $(GROUP) ; 13207bc56df1SIngo Weinhold } 13217bc56df1SIngo Weinhold } 13227bc56df1SIngo Weinhold} 13237bc56df1SIngo Weinhold 13247bc56df1SIngo Weinholdrule OBOSInstallAbsSymLink 13257bc56df1SIngo Weinhold{ 13267bc56df1SIngo Weinhold # Usage: OBOSInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]> 13277bc56df1SIngo Weinhold # : <directory> : <sources to install> 13287bc56df1SIngo Weinhold # : [ <installgrist> ] ; 13297bc56df1SIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : AbsSymLink ; 13307bc56df1SIngo Weinhold} 13317bc56df1SIngo Weinhold 13327bc56df1SIngo Weinholdrule InstallRelSymLinkAdapter 13337bc56df1SIngo Weinhold{ 13347bc56df1SIngo Weinhold # InstallRelSymLinkAdapter <link> : <link target> 13357bc56df1SIngo Weinhold if ! [ on $(2) return $(TARGET) ] { 13367bc56df1SIngo Weinhold TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; 13377bc56df1SIngo Weinhold } 13387bc56df1SIngo Weinhold RelSymLink $(1) : $(2) ; 13397bc56df1SIngo Weinhold} 13407bc56df1SIngo Weinhold 13417bc56df1SIngo Weinholdrule OBOSInstallRelSymLink 13427bc56df1SIngo Weinhold{ 13437bc56df1SIngo Weinhold # Usage: OBOSInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]> 13447bc56df1SIngo Weinhold # : <directory> : <sources to install> 13457bc56df1SIngo Weinhold # : [ <installgrist> ] ; 13467bc56df1SIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ; 13477bc56df1SIngo Weinhold} 13487bc56df1SIngo Weinhold 13497bc56df1SIngo Weinhold 135052a38012Sejakowatz#------------------------------------------------------------------------------- 135152a38012Sejakowatz# Low-level OBOS utility rules 135252a38012Sejakowatz#------------------------------------------------------------------------------- 135352a38012Sejakowatzrule SetupObjectsDir 135452a38012Sejakowatz{ 135552a38012Sejakowatz local rel_objectsdir; 135652a38012Sejakowatz 135752a38012Sejakowatz # Copy subdir tokens except the first, as that will be "sources", and we 135852a38012Sejakowatz # do not want to include that :) 135952a38012Sejakowatz rel_objectsdir = [ FDirName $(SUBDIR_TOKENS[2-]) ] ; 136052a38012Sejakowatz LOCATE_TARGET = [ FDirName $(OBOS_OBJECT_TARGET) $(rel_objectsdir) ] ; 13618d3308d9SIngo Weinhold LOCATE_SOURCE = $(LOCATE_TARGET) ; 13628d3308d9SIngo Weinhold SEARCH_SOURCE = [ Filter $(SEARCH_SOURCE) : $(LOCATE_TARGET) ] 13638d3308d9SIngo Weinhold $(LOCATE_TARGET) ; 136452a38012Sejakowatz} 136552a38012Sejakowatz 136652a38012Sejakowatz#------------------------------------------------------------------------------- 136752a38012Sejakowatz# Link rule/action are overwritten as they don't handle linking files who's name 136852a38012Sejakowatz# contain spaces very well. Also adds resources and version to executable. 136952a38012Sejakowatz#------------------------------------------------------------------------------- 137052a38012Sejakowatzrule Link 137152a38012Sejakowatz{ 137252a38012Sejakowatz # Note: RESFILES must be set before invocation. 137352a38012Sejakowatz MODE on $(<) = $(EXEMODE) ; 137452a38012Sejakowatz on $(1) XRes $(1) : $(RESFILES) ; 137552a38012Sejakowatz Chmod $(<) ; 137652a38012Sejakowatz SetType $(1) ; 137752a38012Sejakowatz MimeSet $(1) ; 13781419ae2bSshatty SetVersion $(1) ; 137952a38012Sejakowatz} 138052a38012Sejakowatz 138152a38012Sejakowatzactions Link bind NEEDLIBS 138252a38012Sejakowatz{ 13831eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(2)" "$(NEEDLIBS)" $(LINKLIBS) ; 138452a38012Sejakowatz} 138552a38012Sejakowatz 13868d3308d9SIngo Weinholdrule LexC++ 13878d3308d9SIngo Weinhold{ 13888d3308d9SIngo Weinhold Depends $(1) : $(2) ; 13898d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_SOURCE) ; 13908d3308d9SIngo Weinhold LocalClean clean : $(1) ; 13918d3308d9SIngo Weinhold} 13928d3308d9SIngo Weinhold 13938d3308d9SIngo Weinholdactions LexC++ 13948d3308d9SIngo Weinhold{ 13958d3308d9SIngo Weinhold $(LEX) -o$(1) $(2) 13968d3308d9SIngo Weinhold} 13978d3308d9SIngo Weinhold 13988d3308d9SIngo Weinholdrule Bison 13998d3308d9SIngo Weinhold{ 14008d3308d9SIngo Weinhold local _h ; 14018d3308d9SIngo Weinhold 14028d3308d9SIngo Weinhold _h = $(1).h ; 14038d3308d9SIngo Weinhold 14048d3308d9SIngo Weinhold MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ; 14058d3308d9SIngo Weinhold 14068d3308d9SIngo Weinhold Depends $(<) $(_h) : $(>) ; 14078d3308d9SIngo Weinhold Bison1 $(<) $(_h) : $(>) ; 14088d3308d9SIngo Weinhold LocalClean clean : $(<) $(_h) ; 14098d3308d9SIngo Weinhold 14108d3308d9SIngo Weinhold # make sure someone includes $(_h) else it will be 14118d3308d9SIngo Weinhold # a deadly independent target 14128d3308d9SIngo Weinhold 14138d3308d9SIngo Weinhold Includes $(<) : $(_h) ; 14148d3308d9SIngo Weinhold} 14158d3308d9SIngo Weinhold 14168d3308d9SIngo Weinholdactions Bison1 14178d3308d9SIngo Weinhold{ 14188d3308d9SIngo Weinhold bison $(YACCFLAGS) -o $(1[1]) $(2) 14198d3308d9SIngo Weinhold} 14208d3308d9SIngo Weinhold 142152a38012Sejakowatz# BeOS specific rules 142252a38012Sejakowatz 142352a38012Sejakowatzrule XRes 142452a38012Sejakowatz{ 142552a38012Sejakowatz # XRes <target> : <resource files> 142652a38012Sejakowatz if $(2) 142752a38012Sejakowatz { 14289eea4522SIngo Weinhold Depends $(1) : $(2) ; 142952a38012Sejakowatz XRes1 $(1) : $(2) ; 143052a38012Sejakowatz } 143152a38012Sejakowatz} 143252a38012Sejakowatz 143352a38012Sejakowatzrule XRes1 { } 143452a38012Sejakowatz 143552a38012Sejakowatzrule SetVersion 143652a38012Sejakowatz{ 143752a38012Sejakowatz # SetVersion <target> 143852a38012Sejakowatz} 143952a38012Sejakowatz 144052a38012Sejakowatzrule SetType 144152a38012Sejakowatz{ 144252a38012Sejakowatz # SetType <target> 144352a38012Sejakowatz} 144452a38012Sejakowatz 144552a38012Sejakowatzrule MimeSet 144652a38012Sejakowatz{ 144752a38012Sejakowatz # SetType <target> 144852a38012Sejakowatz} 144952a38012Sejakowatz 145052a38012Sejakowatz 145152a38012Sejakowatzif $(OS) = BEOS 145252a38012Sejakowatz{ 145352a38012Sejakowatz 145452a38012Sejakowatzactions XRes1 145552a38012Sejakowatz{ 14560931b8f9SIngo Weinhold xres -o "$(1)" "$(2)" ; 145752a38012Sejakowatz} 145852a38012Sejakowatz 145952a38012Sejakowatzactions SetVersion 146052a38012Sejakowatz{ 146152a38012Sejakowatz setversion "$(1)" -system $(OBOS_BUILD_VERSION) -short "$(OBOS_BUILD_DESCRIPTION)" ; 146252a38012Sejakowatz} 146352a38012Sejakowatz 146452a38012Sejakowatzactions SetType 146552a38012Sejakowatz{ 146652a38012Sejakowatz settype -t $(OBOS_TARGET_TYPE) "$(1)" ; 146752a38012Sejakowatz} 146852a38012Sejakowatz 146952a38012Sejakowatzactions MimeSet 147052a38012Sejakowatz{ 147152a38012Sejakowatz mimeset -f "$(1)" ; 147252a38012Sejakowatz} 147352a38012Sejakowatz 147452a38012Sejakowatz} # if BEOS 147552a38012Sejakowatz 147652a38012Sejakowatz 147752a38012Sejakowatzrule assemble 147852a38012Sejakowatz{ 147994782cf7SIngo Weinhold Depends $(<) : $(>) ; 148094782cf7SIngo Weinhold ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ; 148194782cf7SIngo Weinhold ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ; 148252a38012Sejakowatz} 148352a38012Sejakowatz 148452a38012Sejakowatzactions assemble 148552a38012Sejakowatz{ 1486a8687de4SAxel Dörfler $(CC) -c "$(2)" -O2 $(ASFLAGS) -D_ASSEMBLER $(KERNEL_CCFLAGS) $(ASHDRS) -o "$(1)" ; 148752a38012Sejakowatz} 148852a38012Sejakowatz 14890931b8f9SIngo Weinhold# Overridden to allow spaces in file names. 14900931b8f9SIngo Weinholdactions Chmod1 14910931b8f9SIngo Weinhold{ 14920931b8f9SIngo Weinhold $(CHMOD) "$(MODE)" "$(1)" 14930931b8f9SIngo Weinhold} 14940931b8f9SIngo Weinhold 14956991af8cSIngo Weinhold# Overridden to allow spaces in file names. 14966991af8cSIngo Weinholdactions piecemeal together existing Clean 14976991af8cSIngo Weinhold{ 14986991af8cSIngo Weinhold $(RM) "$(>)" 14996991af8cSIngo Weinhold} 15006991af8cSIngo Weinhold 150108125d07SIngo Weinholdrule ObjectReference 150208125d07SIngo Weinhold{ 150308125d07SIngo Weinhold # ObjectReference <reference object> : <source object> 150408125d07SIngo Weinhold # Makes <reference object> refer to the same file as <source object>. 150508125d07SIngo Weinhold # The filenames must of course be identical. 150608125d07SIngo Weinhold # <source object> must have already been LOCATEd. 150708125d07SIngo Weinhold 150808125d07SIngo Weinhold local ref = $(1) ; 150908125d07SIngo Weinhold local source = $(2) ; 151008125d07SIngo Weinhold if $(ref) != $(source) { 15119eea4522SIngo Weinhold Depends $(ref) : $(source) ; 151221df5945SIngo Weinhold LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ; 151308125d07SIngo Weinhold } 151408125d07SIngo Weinhold} 151508125d07SIngo Weinhold 151608125d07SIngo Weinholdrule ObjectReferences 151708125d07SIngo Weinhold{ 151808125d07SIngo Weinhold # ObjectReferences <source objects> 151908125d07SIngo Weinhold # Creates local references to <source objects>, i.e. identifiers with the 152008125d07SIngo Weinhold # current grist referring to the same files. <source objects> must have 152108125d07SIngo Weinhold # already been LOCATEd. 152208125d07SIngo Weinhold 152308125d07SIngo Weinhold local source ; 152408125d07SIngo Weinhold for source in $(1) { 152508125d07SIngo Weinhold ObjectReference [ FGristFiles $(source) ] : $(source) ; 152608125d07SIngo Weinhold } 152708125d07SIngo Weinhold} 152808125d07SIngo Weinhold 15299fc6b2e1SIngo Weinholdrule Filter 15309fc6b2e1SIngo Weinhold{ 15319fc6b2e1SIngo Weinhold # Filter <list> : <excludes> ; 15329fc6b2e1SIngo Weinhold # Removes all occurrences of <excludes> in <list>. 15339fc6b2e1SIngo Weinhold 15349fc6b2e1SIngo Weinhold local list = $(1) ; 15359fc6b2e1SIngo Weinhold local excludes = $(2) ; 15369fc6b2e1SIngo Weinhold local newList ; 15379fc6b2e1SIngo Weinhold local item ; 15389fc6b2e1SIngo Weinhold for item in $(list) { 15399fc6b2e1SIngo Weinhold local skip ; 15409fc6b2e1SIngo Weinhold local exclude ; 15419fc6b2e1SIngo Weinhold for exclude in $(excludes) { 15429fc6b2e1SIngo Weinhold if $(item) = $(exclude) { 15439fc6b2e1SIngo Weinhold skip = true ; 15449fc6b2e1SIngo Weinhold } 15459fc6b2e1SIngo Weinhold } 15469fc6b2e1SIngo Weinhold if ! $(skip) { 1547dd9f8062SIngo Weinhold newList += $(item) ; 15489fc6b2e1SIngo Weinhold } 15499fc6b2e1SIngo Weinhold } 15509fc6b2e1SIngo Weinhold return $(newList) ; 15519fc6b2e1SIngo Weinhold} 15529fc6b2e1SIngo Weinhold 15530931b8f9SIngo Weinhold 155452a38012Sejakowatz## Kernel stuff! 155552a38012Sejakowatz 155652a38012Sejakowatzrule SetupKernel 155752a38012Sejakowatz{ 155852a38012Sejakowatz # Usage SetupKernel <sources_or_objects> : <extra_cc_flags>; 155952a38012Sejakowatz 15602dd47f63SIngo Weinhold local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 156152a38012Sejakowatz 156228d2a30eSDaniel Reinhold #Setup Kernel header directories 1563089a0629Sbeveloper local public_kernel_includes = add-ons/file_system add-ons/graphics device drivers kernel storage support ; 1564b8b44e7aSAxel Dörfler local private_kernel_includes = kernel libroot kernel/boot/platform/$(OBOS_BOOT_PLATFORM) ; 1565a6c008e1Sbeveloper # Use posix headers directory 156628d2a30eSDaniel Reinhold HDRS = [ FDirName $(OBOS_TOP) headers posix ] ; 1567a6c008e1Sbeveloper # Use public OS header directories 1568089a0629Sbeveloper HDRS += [ PublicHeaders $(public_kernel_includes) ] ; 1569089a0629Sbeveloper # Use private directories 1570089a0629Sbeveloper HDRS += [ PrivateHeaders $(private_kernel_includes) ] ; 157109c5682dSIngo Weinhold # The platform dependent headers. 157209c5682dSIngo Weinhold HDRS += $(PLATFORM_HEADERS) ; 1573a6c008e1Sbeveloper 157452a38012Sejakowatz UseArchHeaders $(OBOS_ARCH) ; 157552a38012Sejakowatz 157652a38012Sejakowatz SetupObjectsDir ; 157752a38012Sejakowatz 157852a38012Sejakowatz CCFLAGS on $(_objs) = $(KERNEL_CCFLAGS) $(2) ; 157998cc804cSAxel Dörfler C++FLAGS on $(_objs) = $(KERNEL_C++FLAGS) $(2) ; 158052a38012Sejakowatz} 158152a38012Sejakowatz 158252a38012Sejakowatzrule KernelObjects 158352a38012Sejakowatz{ 158452a38012Sejakowatz SetupKernel $(1) : $(2) ; 158552a38012Sejakowatz 158652a38012Sejakowatz Objects $(1) ; 158752a38012Sejakowatz} 158852a38012Sejakowatz 158952a38012Sejakowatzrule KernelLd 159052a38012Sejakowatz{ 159180721244SAxel Dörfler # KernelLd <name> : <objs> : <linkerscript> : <args> : <gcc_off> : <config_section> ; 159252a38012Sejakowatz 159352a38012Sejakowatz SetupKernel $(2) ; 159452a38012Sejakowatz LINK on $(1) = ld ; 159552a38012Sejakowatz 159652a38012Sejakowatz LINKFLAGS on $(1) = $(4) ; 159752a38012Sejakowatz if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 159852a38012Sejakowatz 159952a38012Sejakowatz # Remove any preset LINKLIBS 160052a38012Sejakowatz LINKLIBS on $(1) = ; 160152a38012Sejakowatz 160252a38012Sejakowatz # Show that we depend on the libraries we need 16039eea4522SIngo Weinhold LocalClean clean : $(1) ; 16049eea4522SIngo Weinhold LocalDepends all : $(1) ; 160552a38012Sejakowatz Depends $(1) : $(2) ; 160652a38012Sejakowatz 160752a38012Sejakowatz if $(6) { 160852a38012Sejakowatz for i in $(6) { 16092a83bfb4SIngo Weinhold KernelConfigSection $(i) : elf32 : $(1) ; 161052a38012Sejakowatz } 161152a38012Sejakowatz } 161252a38012Sejakowatz 161352a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 161452a38012Sejakowatz 161509c5682dSIngo Weinhold # Add the platform specific static libs (libgcc.a). 161652a38012Sejakowatz if ! $(5) { 161709c5682dSIngo Weinhold LINKLIBS on $(1) += $(PLATFORM_LINKLIBS) ; 161852a38012Sejakowatz } 161952a38012Sejakowatz} 162052a38012Sejakowatz 162152a38012Sejakowatzactions KernelLd 162252a38012Sejakowatz{ 16231eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ; 162452a38012Sejakowatz} 162552a38012Sejakowatz 162680721244SAxel Dörflerrule KernelMergeObject 162780721244SAxel Dörfler{ 162880721244SAxel Dörfler # KernelMergeObject <name> : <sources> : <extra CFLAGS> ; 162980721244SAxel Dörfler 163080721244SAxel Dörfler SetupKernel $(2) : $(3) ; 163180721244SAxel Dörfler 163280721244SAxel Dörfler MakeLocateObjects $(2) ; 163380721244SAxel Dörfler Objects $(2) ; 163480721244SAxel Dörfler MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) ; 163580721244SAxel Dörfler} 163680721244SAxel Dörfler 163752a38012Sejakowatzrule KernelStaticLibrary 163852a38012Sejakowatz{ 163952a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ; 164052a38012Sejakowatz # This is designed to take a set of sources and libraries and create 164152a38012Sejakowatz # a file called lib<name>.a 164252a38012Sejakowatz 164352a38012Sejakowatz SetupKernel $(2) : $(3) ; 164452a38012Sejakowatz 164552a38012Sejakowatz MakeLocateObjects $(2) ; 164652a38012Sejakowatz Library $(1) : $(2) ; 164752a38012Sejakowatz} 164852a38012Sejakowatz 164952a38012Sejakowatzrule KernelStaticLibraryObjects 165052a38012Sejakowatz{ 165152a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> ; 165252a38012Sejakowatz # This is designed to take a set of sources and libraries and create 165352a38012Sejakowatz # a file called <name> 165452a38012Sejakowatz 165552a38012Sejakowatz SetupKernel $(2) ; 165652a38012Sejakowatz 165752a38012Sejakowatz # Show that we depend on the libraries we need 16589eea4522SIngo Weinhold LocalClean clean : $(1) ; 16599eea4522SIngo Weinhold LocalDepends all : $(1) ; 166052a38012Sejakowatz Depends $(1) : $(2) ; 166152a38012Sejakowatz 166252a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 166352a38012Sejakowatz} 166452a38012Sejakowatz 166552a38012Sejakowatzactions KernelStaticLibraryObjects 166652a38012Sejakowatz{ 16670931b8f9SIngo Weinhold ar -r "$(1)" "$(2)" ; 166852a38012Sejakowatz} 166952a38012Sejakowatz 16705dc4e1efSIngo Weinholdrule BuildPlatformMain 167152a38012Sejakowatz{ 16725dc4e1efSIngo Weinhold # Usage BuildPlatformMain <target> : <sources> ; 167352a38012Sejakowatz SetupObjectsDir ; 16745dc4e1efSIngo Weinhold SetupDefaultIncludes ; 167552a38012Sejakowatz 16765dc4e1efSIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 16775dc4e1efSIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 16785dc4e1efSIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 16795dc4e1efSIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 16805dc4e1efSIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 168152a38012Sejakowatz 168252a38012Sejakowatz Main $(1) : $(2) ; 16835dc4e1efSIngo Weinhold 16845dc4e1efSIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 16855dc4e1efSIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 16865dc4e1efSIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 168752a38012Sejakowatz} 168852a38012Sejakowatz 16899fcaa61dSIngo Weinholdrule BuildPlatformTest 16909fcaa61dSIngo Weinhold{ 16919fcaa61dSIngo Weinhold # Usage BuildPlatformTest <target> : <sources> ; 16929fcaa61dSIngo Weinhold 16939fcaa61dSIngo Weinhold local target = $(1) ; 16949fcaa61dSIngo Weinhold local sources = $(2) ; 16959fcaa61dSIngo Weinhold 16969fcaa61dSIngo Weinhold BuildPlatformMain $(target) : $(sources) ; 16979fcaa61dSIngo Weinhold local relPath ; 16989fcaa61dSIngo Weinhold if [ FIsPrefix src tests : $(SUBDIR_TOKENS) ] { 16999fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[3-]) ; 17009fcaa61dSIngo Weinhold } else { 17019fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[2-]) ; 17029fcaa61dSIngo Weinhold } 17039fcaa61dSIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 17049fcaa61dSIngo Weinhold} 17059fcaa61dSIngo Weinhold 170652a38012Sejakowatzrule KernelConfigSection 170752a38012Sejakowatz{ 170852a38012Sejakowatz # KernelConfigSection <section> : <type> : <file> ; 17092a83bfb4SIngo Weinhold 17102a83bfb4SIngo Weinhold SECTION_NAMES on $(OBOS_KERNEL_CONFIG) += $(1) ; 17112a83bfb4SIngo Weinhold SECTION_TYPES on $(OBOS_KERNEL_CONFIG) += $(2) ; 17122a83bfb4SIngo Weinhold SECTION_FILES on $(OBOS_KERNEL_CONFIG) += $(3) ; 17132a83bfb4SIngo Weinhold 17142a83bfb4SIngo Weinhold Depends $(OBOS_KERNEL_CONFIG) : $(3) ; 171552a38012Sejakowatz} 171652a38012Sejakowatz 171752a38012Sejakowatzrule WriteKernelConfig 171852a38012Sejakowatz{ 171952a38012Sejakowatz # usage: WriteKernelConfig <target> ; 172052a38012Sejakowatz 17219eea4522SIngo Weinhold LocalDepends files : $(1) ; 172252a38012Sejakowatz 17232a83bfb4SIngo Weinhold MakeLocate $(1) : $(OBOS_OBJECT_TARGET) ; 172452a38012Sejakowatz 17259eea4522SIngo Weinhold LocalClean clean : $(1) ; 172652a38012Sejakowatz} 172752a38012Sejakowatz 17282a83bfb4SIngo Weinholdactions WriteKernelConfig bind SECTION_FILES 172952a38012Sejakowatz{ 17300931b8f9SIngo Weinhold target="$(1)" 17310931b8f9SIngo Weinhold echo "# OpenBeOS Kernel Config File" > "$target" 17320931b8f9SIngo Weinhold echo "# Automatically generated - do not edit!" >> "$target" 17332a83bfb4SIngo Weinhold count=0 17342a83bfb4SIngo Weinhold for section in "$(SECTION_NAMES)" ; do 17352a83bfb4SIngo Weinhold count=`expr $count + 1` 17362a83bfb4SIngo Weinhold eval section$count="$section" 17372a83bfb4SIngo Weinhold done 17382a83bfb4SIngo Weinhold i=1 17392a83bfb4SIngo Weinhold for type in "$(SECTION_TYPES)" ; do 17402a83bfb4SIngo Weinhold eval type$i="$type" 17412a83bfb4SIngo Weinhold i=`expr $i + 1` 17422a83bfb4SIngo Weinhold done 17432a83bfb4SIngo Weinhold i=1 17442a83bfb4SIngo Weinhold for file in "$(SECTION_FILES)" ; do 17452a83bfb4SIngo Weinhold eval file$i="$file" 17462a83bfb4SIngo Weinhold i=`expr $i + 1` 17472a83bfb4SIngo Weinhold done 17482a83bfb4SIngo Weinhold for i in `seq $count` ; do 17492a83bfb4SIngo Weinhold eval section="\$section$i" 17502a83bfb4SIngo Weinhold eval type="\$type$i" 17512a83bfb4SIngo Weinhold eval file="\$file$i" 17520931b8f9SIngo Weinhold echo "" >> "$target" 17532a83bfb4SIngo Weinhold echo "["$section"]" >> "$target" 17542a83bfb4SIngo Weinhold echo "type="$type >> "$target" 17550931b8f9SIngo Weinhold case "$file" in 175652a38012Sejakowatz /*) ;; 17570931b8f9SIngo Weinhold *) file=`pwd`/"$file";; 175852a38012Sejakowatz esac 17592a83bfb4SIngo Weinhold echo "file="$file >> "$target" 176052a38012Sejakowatz done 176152a38012Sejakowatz} 176252a38012Sejakowatz 176352a38012Sejakowatzrule BuildKernel 176452a38012Sejakowatz{ 176552a38012Sejakowatz # Usage BuildKernel <target> : <config_file> ; 17660c0b2cd0SIngo Weinhold local kernel = $(1) ; 17670c0b2cd0SIngo Weinhold local configFile = $(2) ; 17680c0b2cd0SIngo Weinhold local bootmaker = bootmaker ; 176952a38012Sejakowatz 17709eea4522SIngo Weinhold LocalDepends all : $(kernel) ; 17710c0b2cd0SIngo Weinhold Depends $(kernel) : $(configFile) $(bootmaker) ; 17729eea4522SIngo Weinhold LocalClean clean : $(kernel) ; 17730c0b2cd0SIngo Weinhold MakeLocate $(kernel) : $(LOCATE_TARGET) ; 177452a38012Sejakowatz 17750c0b2cd0SIngo Weinhold BOOT_MAKER on $(kernel) = $(bootmaker) ; 177652a38012Sejakowatz} 177752a38012Sejakowatz 17780c0b2cd0SIngo Weinholdactions BuildKernel bind BOOT_MAKER 177952a38012Sejakowatz{ 17800c0b2cd0SIngo Weinhold "$(BOOT_MAKER)" --strip-debug --strip-binary strip "$(2)" -o "$(1)" ; 178152a38012Sejakowatz echo "" 178252a38012Sejakowatz echo "Kernel linked!" 178352a38012Sejakowatz echo "" 178452a38012Sejakowatz} 178552a38012Sejakowatz 178652a38012Sejakowatzrule KernelFloppyImage 178752a38012Sejakowatz{ 178852a38012Sejakowatz # Usage KernelFloppyImage <target> : <kernel> : <bootblock> ; 17890c0b2cd0SIngo Weinhold local floppy = $(1) ; 17900c0b2cd0SIngo Weinhold local kernel = $(2) ; 17910c0b2cd0SIngo Weinhold local bootblock = $(3) ; 17920c0b2cd0SIngo Weinhold local makeflop = makeflop ; 179352a38012Sejakowatz 17949eea4522SIngo Weinhold LocalDepends all : $(floppy) ; 17950c0b2cd0SIngo Weinhold Depends $(floppy) : $(kernel) $(bootblock) $(makeflop) ; 17969eea4522SIngo Weinhold LocalClean clean : $(floppy) ; 17970c0b2cd0SIngo Weinhold MakeLocate $(floppy) : $(OBOS_OBJECT_TARGET) ; 179852a38012Sejakowatz 17990c0b2cd0SIngo Weinhold BOOT_BLOCK on $(floppy) = $(bootblock) ; 18000c0b2cd0SIngo Weinhold MAKE_FLOP on $(floppy) = $(makeflop) ; 180152a38012Sejakowatz} 180252a38012Sejakowatz 180352a38012Sejakowatz# This may be a bit verbose, but I think it's useful to show what's 180452a38012Sejakowatz# going on, at least in this early stage of development. 18050c0b2cd0SIngo Weinholdactions KernelFloppyImage bind BOOT_BLOCK bind MAKE_FLOP 180652a38012Sejakowatz{ 18077378dd7fSAxel Dörfler "$(MAKE_FLOP)" "-p $(shell expr 18 \* 2 \* 512)" "$(BOOT_BLOCK)" "$(2)" "$(1)" ; 18080c0b2cd0SIngo Weinhold 180952a38012Sejakowatz echo "" 181052a38012Sejakowatz echo "*************************************************" 181152a38012Sejakowatz echo "* Kernel build completed! *" 181252a38012Sejakowatz echo "* Boot image for a 1.44M floppy created *" 181352a38012Sejakowatz echo "*************************************************" 181452a38012Sejakowatz echo "" 18150c0b2cd0SIngo Weinhold echo "Floppy image is $(1)" 181652a38012Sejakowatz echo "The following command will write it to a floppy on BeOS" 18170c0b2cd0SIngo Weinhold echo " dd if=$(1) of=/dev/disk/floppy/raw bs=18k" 18180c0b2cd0SIngo Weinhold echo "Alternatively you can run" 18190c0b2cd0SIngo Weinhold echo " ./configure --floppy /dev/disk/floppy/raw" 18200c0b2cd0SIngo Weinhold echo "once and build + write the image subsequently via" 18210c0b2cd0SIngo Weinhold echo " jam installfloppy" 182252a38012Sejakowatz echo "" 182352a38012Sejakowatz} 182452a38012Sejakowatz 18250c0b2cd0SIngo Weinholdrule InstallFloppy 18260c0b2cd0SIngo Weinhold{ 18270c0b2cd0SIngo Weinhold # InstallFloppy <target> : <floppy> 18280c0b2cd0SIngo Weinhold # "dd"s <floppy> to $(FLOPPY_PATH). 18290c0b2cd0SIngo Weinhold 18300c0b2cd0SIngo Weinhold local target = $(1) ; 18310c0b2cd0SIngo Weinhold local floppy = $(2) ; 18320c0b2cd0SIngo Weinhold 18330c0b2cd0SIngo Weinhold NotFile $(target) ; 18340c0b2cd0SIngo Weinhold Always $(target) ; 18350c0b2cd0SIngo Weinhold Depends $(target) : $(floppy) ; 18360c0b2cd0SIngo Weinhold} 18370c0b2cd0SIngo Weinhold 18380c0b2cd0SIngo Weinholdactions InstallFloppy 18390c0b2cd0SIngo Weinhold{ 18400c0b2cd0SIngo Weinhold if [ -z $(FLOPPY_PATH) ] ; then 18410c0b2cd0SIngo Weinhold echo "Can't install floppy: FLOPPY_PATH not set." 18420c0b2cd0SIngo Weinhold echo "run: ./configure --floppy <floppy path>" 18430c0b2cd0SIngo Weinhold echo 18440c0b2cd0SIngo Weinhold exit 0 18450c0b2cd0SIngo Weinhold fi 18460c0b2cd0SIngo Weinhold dd if=$(2) of=$(FLOPPY_PATH) bs=18k 18470c0b2cd0SIngo Weinhold} 184852a38012Sejakowatz 184921df5945SIngo Weinhold#------------------------------------------------------------------------------- 185021df5945SIngo Weinhold# FreeType 2 specific rules and variables 185121df5945SIngo Weinhold#------------------------------------------------------------------------------- 185221df5945SIngo Weinhold 185321df5945SIngo WeinholdFT2_INCLUDE = [ FDirName $(OBOS_TOP) headers libs freetype2 ] ; 185421df5945SIngo WeinholdFT2_SRC = [ FDirName $(OBOS_TOP) src libs freetype2 ] ; 185521df5945SIngo Weinhold 185621df5945SIngo WeinholdFT2_LIB = freetype ; 185721df5945SIngo Weinhold 1858fbd28219SIngo WeinholdFT2_COMPONENTS ?= gzip # support for gzip-compressed files. 1859fbd28219SIngo Weinhold autohint # auto-hinter 1860fbd28219SIngo Weinhold base # base component (public APIs) 1861fbd28219SIngo Weinhold bdf # BDF font driver 1862fbd28219SIngo Weinhold cache # cache sub-system 1863fbd28219SIngo Weinhold cff # CFF/CEF font driver 1864fbd28219SIngo Weinhold cid # Postscript CID-keyed font driver 1865fbd28219SIngo Weinhold pcf # PCF font driver 1866fbd28219SIngo Weinhold pfr # PFR/TrueDoc font driver 1867fbd28219SIngo Weinhold psaux # Common Postscript routines module 1868fbd28219SIngo Weinhold pshinter # Postscript hinter module 1869fbd28219SIngo Weinhold psnames # Postscript names handling 1870fbd28219SIngo Weinhold raster # Monochrome rasterizer 1871fbd28219SIngo Weinhold smooth # Anti-aliased rasterizer 1872fbd28219SIngo Weinhold sfnt # SFNT-based format support routines 1873fbd28219SIngo Weinhold truetype # TrueType font driver 1874fbd28219SIngo Weinhold type1 # Postscript Type 1 font driver 1875fbd28219SIngo Weinhold type42 # Postscript Type 42 (embedded TrueType) driver 1876fbd28219SIngo Weinhold winfonts # Windows FON/FNT font driver 1877fbd28219SIngo Weinhold ; 1878fbd28219SIngo Weinhold 187921df5945SIngo Weinholdrule UseFreeTypeHeaders 188021df5945SIngo Weinhold{ 188121df5945SIngo Weinhold SubDirHdrs $(FT2_INCLUDE) ; 188221df5945SIngo Weinhold} 188321df5945SIngo Weinhold 188421df5945SIngo Weinholdrule UseFreeTypeObjectHeaders 188521df5945SIngo Weinhold{ 18869b60a208SIngo Weinhold # UseFreeTypeObjectHeaders <sources> [ : <objects> ] ; 18879b60a208SIngo Weinhold SourceHdrs $(1) : $(FT2_INCLUDE) : $(2) ; 188821df5945SIngo Weinhold} 188921df5945SIngo Weinhold 189021df5945SIngo Weinholdrule FT2_SubDir 189121df5945SIngo Weinhold{ 189221df5945SIngo Weinhold # FT2_SubDir <dir> 189321df5945SIngo Weinhold # <dir>: Components of a directory in the original hierarchy. 189421df5945SIngo Weinhold local dir = $(1) ; 189521df5945SIngo Weinhold local topDir ; 189621df5945SIngo Weinhold switch $(dir[1]) 189721df5945SIngo Weinhold { 189821df5945SIngo Weinhold case "include" : topDir = $(FT2_INCLUDE) ; 189921df5945SIngo Weinhold case src : topDir = $(FT2_SRC) ; 190021df5945SIngo Weinhold case * : ECHO "Unknown FreeType2 directory: " $(dir) ; 190121df5945SIngo Weinhold } 190221df5945SIngo Weinhold return [ FDirName $(topDir) $(dir[2-]) ] ; 190321df5945SIngo Weinhold} 190421df5945SIngo Weinhold 190521df5945SIngo Weinholdrule FT2_Library 190621df5945SIngo Weinhold{ 190721df5945SIngo Weinhold # FT2_Library <libname> : <sources> 190821df5945SIngo Weinhold # Builds objects from sources and adds the objects to the list of objects 190921df5945SIngo Weinhold # to be linked into the library. 191021df5945SIngo Weinhold # <libname> The name of the library. 191121df5945SIngo Weinhold # <sources> The sources. 191221df5945SIngo Weinhold 191321df5945SIngo Weinhold local library = lib$(1).so ; 191421df5945SIngo Weinhold local sources = $(2) ; 191528d2a30eSDaniel Reinhold SetupIncludes ; 191621df5945SIngo Weinhold SetupObjectsDir ; 191721df5945SIngo Weinhold MakeLocateObjects $(sources) ; 191821df5945SIngo Weinhold Objects $(sources) ; 191921df5945SIngo Weinhold LIBRARY_OBJECTS on $(library) += [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 192021df5945SIngo Weinhold} 192121df5945SIngo Weinhold 192221df5945SIngo Weinholdrule FT2_LinkLibrary 192321df5945SIngo Weinhold{ 192421df5945SIngo Weinhold # FT2_LinkLibrary <libname> 192521df5945SIngo Weinhold # Links the library from the objects build with FT2_LIBRARY before. 192621df5945SIngo Weinhold 192721df5945SIngo Weinhold local library = lib$(1).so ; 192821df5945SIngo Weinhold local objects = [ on $(library) return $(LIBRARY_OBJECTS) ] ; 192921df5945SIngo Weinhold ObjectReferences $(objects) ; 193021df5945SIngo Weinhold objects = [ FGristFiles $(objects) ] ; 193121df5945SIngo Weinhold SharedLibraryFromObjects $(1) : $(objects) ; 193221df5945SIngo Weinhold} 193321df5945SIngo Weinhold 1934