19eea4522SIngo Weinhold# Vanilla Jam compatibility 29eea4522SIngo Weinholdif ! $(INVOCATION_SUBDIR_SET) { 39eea4522SIngo Weinhold 49eea4522SIngo Weinhold rule FIsPrefix 59eea4522SIngo Weinhold { 69eea4522SIngo Weinhold # FIsPrefix <a> : <b> ; 79eea4522SIngo Weinhold # Returns true, if list <a> is a prefix (a proper one or equal) of 89eea4522SIngo Weinhold # list <b>, an empty list otherwise. 99eea4522SIngo Weinhold local a = $(1) ; 109eea4522SIngo Weinhold local b = $(2) ; 119eea4522SIngo Weinhold while $(a) && $(a[1]) = $(b[1]) { 129eea4522SIngo Weinhold a = $(a[2-]) ; 139eea4522SIngo Weinhold b = $(b[2-]) ; 149eea4522SIngo Weinhold } 159eea4522SIngo Weinhold 169eea4522SIngo Weinhold if $(a) { 179eea4522SIngo Weinhold return ; 189eea4522SIngo Weinhold } else { 199eea4522SIngo Weinhold return true ; 209eea4522SIngo Weinhold } 219eea4522SIngo Weinhold } 229eea4522SIngo Weinhold 239eea4522SIngo Weinhold rule LocalClean { Clean $(1) : $(2) ; } 249eea4522SIngo Weinhold 259eea4522SIngo Weinhold rule LocalDepends { Depends $(1) : $(2) ; } 269eea4522SIngo Weinhold 279eea4522SIngo Weinhold} # vanilla Jam compatibility 289eea4522SIngo Weinhold 294ff6d49fSIngo Weinhold# The directory for build system specific files 304ff6d49fSIngo WeinholdOBOS_BUILD_DIR = [ FDirName $(OBOS_TOP) build ] ; 314ff6d49fSIngo Weinhold 324ff6d49fSIngo Weinhold# Cache files for header scanning and jamfile caching 334ff6d49fSIngo WeinholdHCACHEFILE = header_cache ; 344ff6d49fSIngo WeinholdJCACHEFILE = jamfile_cache ; 354ff6d49fSIngo WeinholdLOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(OBOS_BUILD_DIR) ; 369eea4522SIngo Weinhold 3752a38012Sejakowatz# Include BuildConfig 3852a38012Sejakowatz{ 394ff6d49fSIngo Weinhold local buildConfig = [ GLOB $(OBOS_BUILD_DIR) : BuildConfig ] ; 4052a38012Sejakowatz if ! $(buildConfig) 4152a38012Sejakowatz { 424ff6d49fSIngo Weinhold ECHO "No BuildConfig found in $(OBOS_BUILD_DIR)!" ; 434ff6d49fSIngo Weinhold EXIT "Run ./configure in the source tree's root directory first!" ; 4452a38012Sejakowatz } 454ff6d49fSIngo Weinhold LOCATE on BuildConfig = $(OBOS_BUILD_DIR) ; 464ff6d49fSIngo Weinhold include BuildConfig ; 4752a38012Sejakowatz} 4852a38012Sejakowatz 498c17a26bSIngo Weinhold# analyze GCC version 508c17a26bSIngo Weinholdif ! $(GCC_RAW_VERSION) { 518c17a26bSIngo Weinhold ECHO "Variable GCC_RAW_VERSION not set. Please run ./configure or" ; 528c17a26bSIngo Weinhold EXIT "specify it manually." ; 538c17a26bSIngo Weinhold} 548c17a26bSIngo WeinholdGCC_VERSION = ; 558c17a26bSIngo Weinhold{ 568c17a26bSIngo Weinhold # split the raw version string at `.' and `-' characters 578c17a26bSIngo Weinhold local version = $(GCC_RAW_VERSION) ; 588c17a26bSIngo Weinhold while $(version) { 598c17a26bSIngo Weinhold local split = [ Match "([^.-]*)[.-](.*)" : $(version) ] ; 608c17a26bSIngo Weinhold if $(split) { 618c17a26bSIngo Weinhold GCC_VERSION += $(split[1]) ; 628c17a26bSIngo Weinhold version = $(split[2]) ; 638c17a26bSIngo Weinhold } else { 648c17a26bSIngo Weinhold GCC_VERSION += $(version) ; 658c17a26bSIngo Weinhold version = ; 668c17a26bSIngo Weinhold } 678c17a26bSIngo Weinhold } 688c17a26bSIngo Weinhold} 698c17a26bSIngo Weinhold 705dc4e1efSIngo Weinhold# Save the platform default headers. 715dc4e1efSIngo WeinholdPLATFORM_DEFAULT_HEADERS = $(HDRS) ; 725dc4e1efSIngo Weinhold 73705fc998SAxel Dörfler# Add some grist to the libgcc objects 74705fc998SAxel DörflerLIBGCC_OBJECTS = $(LIBGCC_OBJECTS:G=libgcc) ; 75705fc998SAxel Dörfler 76a6c008e1Sbeveloper# We do not include any local BeOS system headers by default 77dd9f8062SIngo WeinholdCCFLAGS += -nostdinc ; 78dd9f8062SIngo WeinholdC++FLAGS += -nostdinc ; 79a6c008e1Sbeveloper 802abad45eSbeveloper# Allow compiling unit tests on Zeta. Instead of fixing the PostMessage() 812abad45eSbeveloper# issues, they deprecated that nice function. This will enable it again: 822abad45eSbeveloperC++FLAGS += -D_ZETA_USING_DEPRECATED_API_=1 ; 832abad45eSbeveloper 844bb19442Sshattyif ! $(TARGET_PLATFORM) { 854bb19442Sshatty ECHO "Variable TARGET_PLATFORM not set. Please run ./configure or" ; 864bb19442Sshatty EXIT "specify it manually." ; 874bb19442Sshatty} 88a17b9c0cSshattyswitch $(TARGET_PLATFORM) 89a17b9c0cSshatty{ 90a17b9c0cSshatty case r5 : 91a17b9c0cSshatty { 924bb19442Sshatty # "everything" is r5 compatible 93be1aef42Sshatty } 94a17b9c0cSshatty case bone : 95a17b9c0cSshatty { 96a17b9c0cSshatty BONE_COMPATIBLE = true ; 97a17b9c0cSshatty } 98a17b9c0cSshatty case dano : 99a17b9c0cSshatty { 100a17b9c0cSshatty BONE_COMPATIBLE = true ; 101a17b9c0cSshatty DANO_COMPATIBLE = true ; 102a17b9c0cSshatty } 103a17b9c0cSshatty case haiku : 104a17b9c0cSshatty { 105a17b9c0cSshatty BONE_COMPATIBLE = true ; 106a17b9c0cSshatty DANO_COMPATIBLE = true ; 107a17b9c0cSshatty HAIKU_COMPATIBLE = true ; 108a104c31bSshatty DEFINES += __HAIKU__ ; 109a17b9c0cSshatty } 110a17b9c0cSshatty} 1116040be99Sshattyif $(BONE_COMPATIBLE) { 1126040be99Sshatty NETWORK_LIBS = libsocket.so libbind.so ; 1132506bbb6Sshatty SELECT_UNAME_ETC_LIB = libroot.so ; 1146040be99Sshatty} else { 1156040be99Sshatty NETWORK_LIBS = libnet.so ; 1162506bbb6Sshatty SELECT_UNAME_ETC_LIB = libnet.so ; 1176040be99Sshatty} 118be1aef42Sshatty 11952a38012Sejakowatz# Determine if we're building on PPC or x86 12052a38012Sejakowatz# Determine mimetype of executable 12152a38012Sejakowatz# Cross compiling can come later 12252a38012Sejakowatz 123c9882d9eSAxel DörflerTARGET_CPU ?= $(OSPLAT:L) ; 1241f622a7bSAxel DörflerOBOS_VERSION ?= R1 ; 1251f622a7bSAxel Dörfler 1261f622a7bSAxel Dörflerswitch $(TARGET_CPU) { 1271f622a7bSAxel Dörfler case ppc : 1281f622a7bSAxel Dörfler { 12952a38012Sejakowatz if $(METROWERKS) { 1301f622a7bSAxel Dörfler # at least parts of OpenBeOS still can be compiled with 1311f622a7bSAxel Dörfler # the Metrowerks compiler on BeOS/PPC 13252a38012Sejakowatz OBOS_TARGET_TYPE ?= "application/x-be-executable" ; 13352a38012Sejakowatz } else { 13452a38012Sejakowatz OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; 1351f622a7bSAxel Dörfler } 136894d1636Sshatty DEFINES += __POWERPC__ ARCH_ppc ; 137e29d8533SAxel Dörfler OBOS_BOOT_PLATFORM = openfirmware ; 1381f622a7bSAxel Dörfler } 1391f622a7bSAxel Dörfler case x86 : 1401f622a7bSAxel Dörfler { 1411f622a7bSAxel Dörfler # nothing special to do here... 142894d1636Sshatty DEFINES += __INTEL__ ARCH_x86 ; 143e29d8533SAxel Dörfler OBOS_BOOT_PLATFORM = bios_ia32 ; 1441f622a7bSAxel Dörfler } 1451f622a7bSAxel Dörfler case * : 1461f622a7bSAxel Dörfler Exit "Currently unsupported build platform:" $(TARGET_CPU) ; 1471f622a7bSAxel Dörfler} 1481f622a7bSAxel Dörfler 1491f622a7bSAxel Dörfler# set target specific variables 1501f622a7bSAxel Dörfler{ 1511f622a7bSAxel Dörfler #Echo "Building for" $(TARGET_CPU) ; 1521f622a7bSAxel Dörfler 1531f622a7bSAxel Dörfler OBOS_TARGET ?= $(TARGET_CPU).$(OBOS_VERSION) ; 1541f622a7bSAxel Dörfler OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; 1551f622a7bSAxel Dörfler OBOS_ARCH ?= $(TARGET_CPU) ; 1561f622a7bSAxel Dörfler OBOS_TARGET_DEFINE ?= "ARCH_"$(TARGET_CPU) ; 15752a38012Sejakowatz} 15852a38012Sejakowatz 15965c62a01SIngo Weinhold# Disable warnings only if WARNINGS is set to 0 160e5dc2d93Sbeveloper# Should be enabled by default later 16196d27465SIngo Weinhold# 16265c62a01SIngo WeinholdWARNINGS ?= 1 ; 16365c62a01SIngo Weinholdif $(WARNINGS) = 1 { 164e5dc2d93Sbeveloper # For an explanation of the different warning options, see: 165e5dc2d93Sbeveloper # http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html 166e5dc2d93Sbeveloper # to get even more warnings, add: 167e5dc2d93Sbeveloper # -Wwrite-strings (doesn't work well with some Be headers) 168e5dc2d93Sbeveloper # -Wundef (dito) 169e5dc2d93Sbeveloper # -Wconversion (gets you many warnings about implicit conversions) 170e5dc2d93Sbeveloper # -W (gets you even more warnigs) 171dd9f8062SIngo Weinhold CCFLAGS += -Wall -Wno-multichar -Wmissing-prototypes ; 172dd9f8062SIngo Weinhold CCFLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; 173dd9f8062SIngo Weinhold C++FLAGS += -Wall -Wno-multichar -Wmissing-prototypes -Wno-ctor-dtor-privacy -Woverloaded-virtual ; 174dd9f8062SIngo Weinhold C++FLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; 17598cc804cSAxel Dörfler} else { 17698cc804cSAxel Dörfler CCFLAGS += -Wno-multichar ; 17798cc804cSAxel Dörfler C++FLAGS += -Wno-multichar ; 178e5dc2d93Sbeveloper} 179e5dc2d93Sbeveloper 18098cc804cSAxel Dörfler# standard kernel C/C++ flags 1810ff867c2SbeveloperKERNEL_CCFLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; 1824d74cda3SAxel DörflerKERNEL_CCFLAGS += -fno-builtin -D$(OBOS_TARGET_DEFINE) -D__HAIKU__ ; 183ea7627e5SAxel DörflerKERNEL_CCFLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 18498cc804cSAxel DörflerKERNEL_C++FLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; 1854d74cda3SAxel DörflerKERNEL_C++FLAGS += -fno-builtin -fno-exceptions -D$(OBOS_TARGET_DEFINE) -D__HAIKU__ ; 186ea7627e5SAxel DörflerKERNEL_C++FLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 187bbb6f2d4SAxel Dörflerif $(GCC_VERSION[1]) >= 3 { 188bbb6f2d4SAxel Dörfler KERNEL_C++FLAGS += -fno-use-cxa-atexit ; 189bbb6f2d4SAxel Dörfler} 1900ff867c2Sbeveloper 1919eea4522SIngo Weinhold# We might later want to introduce debug levels or handle the whole issue 1929eea4522SIngo Weinhold# differently. For now there's only on or off. 1939eea4522SIngo Weinhold# 19465c62a01SIngo WeinholdDEBUG ?= 0 ; 19565c62a01SIngo Weinholdif $(DEBUG) != 0 { 1969eea4522SIngo Weinhold OPTIM ?= -O0 ; 19765c62a01SIngo Weinhold CCFLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 19865c62a01SIngo Weinhold C++FLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 19965c62a01SIngo Weinhold KERNEL_CCFLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 20065c62a01SIngo Weinhold KERNEL_C++FLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 2019eea4522SIngo Weinhold LINKFLAGS += -g ; 2029eea4522SIngo Weinhold} else { 2039eea4522SIngo Weinhold OPTIM ?= -O2 ; 2049eea4522SIngo Weinhold} 20596d27465SIngo Weinhold# 20696d27465SIngo Weinhold# To disable for the tests OPTIM and DEBUG are overridden, set the environment 20796d27465SIngo Weinhold# variable NO_TEST_DEBUG. 2089eea4522SIngo Weinhold 20916fa4445SIngo Weinhold# Instructs the Library rule to not make its object files temporary. 210f1e077f8SIngo Weinhold# This is needed as some objects are used in a static library and for an 21116fa4445SIngo Weinhold# executable. 21216fa4445SIngo WeinholdKEEPOBJS = true ; 21316fa4445SIngo Weinhold 2147bc56df1SIngo Weinhold# under BeOS use copyattr instead of cp 2157bc56df1SIngo Weinholdif $(OS) = BEOS 2167bc56df1SIngo Weinhold{ 2177bc56df1SIngo Weinhold CP = copyattr --data ; 2187bc56df1SIngo Weinhold} 2197bc56df1SIngo Weinhold 22053cf6d7aSAxel Dörfler# for builds of tools in the current environment 22153cf6d7aSAxel Dörflerif $(OS) = BEOS { 22253cf6d7aSAxel Dörfler BUILD_LIBSTDC++ = stdc++.r4 ; 22353cf6d7aSAxel Dörfler} else { 22453cf6d7aSAxel Dörfler BUILD_LIBSTDC++ = stdc++ ; 22553cf6d7aSAxel Dörfler} 22653cf6d7aSAxel Dörfler 22752a38012Sejakowatz# If no OBOS_OBJECT_TARGET is not defined yet, use our default directory and 22852a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 22952a38012Sejakowatz# builds mixing objects from different targets). 23052a38012Sejakowatzif ! $(OBOS_OBJECT_TARGET) { 23152a38012Sejakowatz OBOS_OBJECT_TARGET ?= [ FDirName $(OBOS_TOP) objects $(OBOS_TARGET) ] ; 23252a38012Sejakowatz} 23352a38012Sejakowatz 23452a38012Sejakowatz# If no OBOS_DISTRO_TARGET is not defined yet, use our default directory and 23552a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 23652a38012Sejakowatz# builds mixing executables from different targets). 23752a38012Sejakowatzif ! $(OBOS_DISTRO_TARGET) { 23852a38012Sejakowatz OBOS_DISTRO_TARGET ?= [ FDirName $(OBOS_TOP) distro $(OBOS_TARGET) ] ; 23952a38012Sejakowatz} 24052a38012Sejakowatz 24152a38012Sejakowatz# Set our version number if not already set and mark it as a developer build 24252a38012Sejakowatzif ! $(OBOS_BUILD_VERSION) { 24352a38012Sejakowatz OBOS_BUILD_VERSION ?= "1 0 0 a 1" ; 24452a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Developer Build" ; 24552a38012Sejakowatz} 24652a38012Sejakowatz 24752a38012Sejakowatz# If OBOS_BUILD_VERSION is set, but OBOS_BUILD_DESCRIPTION isn't, mark it as 24852a38012Sejakowatz# an unknown build. 24952a38012Sejakowatzif ! $(OBOS_BUILD_DESCRIPTION) { 25052a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Unknown Build" ; 25152a38012Sejakowatz} 25252a38012Sejakowatz 253505554b4SIngo Weinhold# Relative subdirs for distro dir 254505554b4SIngo WeinholdOBOS_ADDON_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system add-ons ] ; 2555f281ed5SejakowatzOBOS_APPS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos apps ] ; 256f06de7f3SIngo WeinholdOBOS_BIN_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos bin ] ; 257505554b4SIngo WeinholdOBOS_ETC_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos etc ] ; 258505554b4SIngo WeinholdOBOS_FONTS_DIR ?= [ FDirName $(OBOS_ETC_DIR) fonts ] ; 259505554b4SIngo WeinholdOBOS_KERNEL_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system ] ; 26052a38012SejakowatzOBOS_PREFS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos preferences ] ; 26152a38012SejakowatzOBOS_SERVER_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system servers ] ; 26252a38012SejakowatzOBOS_SHLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ; 263e9230d05SIngo WeinholdOBOS_STLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) develop lib 264e9230d05SIngo Weinhold $(OBOS_ARCH) ] ; 26552a38012SejakowatzOBOS_TEST_DIR ?= [ FDirName $(OBOS_TOP) tests ] ; 26652a38012Sejakowatz 267c06f365fSIngo WeinholdOBOS_PACKAGE_DIR ?= [ FDirName $(OBOS_TOP) packages $(OBOS_TARGET) ] ; 268c06f365fSIngo WeinholdOBOS_PACKAGE_OBJECT_DIR ?= [ FDirName $(OBOS_OBJECT_TARGET) packages ] ; 269c06f365fSIngo Weinhold 27052a38012SejakowatzOBOS_KERNEL_CONFIG = config.$(OBOS_ARCH).ini ; 27152a38012SejakowatzOBOS_KERNEL = kernel.$(OBOS_ARCH) ; 27252a38012SejakowatzOBOS_FLOPPY = floppy.$(OBOS_ARCH) ; 27352a38012Sejakowatz 27452a38012Sejakowatzrule SetupIncludes 27552a38012Sejakowatz{ 276cfc7b456Sshatty # XXX add "opengl" later 277cfc7b456Sshatty 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 ; 278a6c008e1Sbeveloper 27928d2a30eSDaniel Reinhold # Overwrite any exiting content when changing HDRS. This rule may be invoked multiple times. 280a6c008e1Sbeveloper 281a6c008e1Sbeveloper # Use headers directory, to allow to do things like include <posix/string.h> 28228d2a30eSDaniel Reinhold HDRS = [ FDirName $(OBOS_TOP) headers ] ; 283a6c008e1Sbeveloper 284a6c008e1Sbeveloper # Use posix headers directory 28528d2a30eSDaniel Reinhold HDRS += [ FDirName $(OBOS_TOP) headers posix ] ; 286a6c008e1Sbeveloper 287a6c008e1Sbeveloper # Use public OS header directories 28828d2a30eSDaniel Reinhold HDRS += [ PublicHeaders $(os_includes) ] ; 289a6c008e1Sbeveloper 290c0e501e0SIngo Weinhold # Use the root of the private headers -- not so nice, but simplifies things. 291c0e501e0SIngo Weinhold HDRS += [ PrivateHeaders $(DOT) ] ; 292c0e501e0SIngo Weinhold 293a6c008e1Sbeveloper # Used as a fallback, the R5 header directories (we should remove this as soon as possible) 29428d2a30eSDaniel Reinhold HDRS += /boot/develop/headers/posix /boot/develop/headers/cpp ; 29509c5682dSIngo Weinhold 29609c5682dSIngo Weinhold # The platform dependent headers. 29709c5682dSIngo Weinhold HDRS += $(PLATFORM_HEADERS) ; 29852a38012Sejakowatz} 29952a38012Sejakowatz 300dd9f8062SIngo Weinholdrule SetupR5Includes 301dd9f8062SIngo Weinhold{ 302dd9f8062SIngo Weinhold # Unsets HDRS, so that the OBOS headers do not `shadow' the system headers. 303dd9f8062SIngo Weinhold HDRS = ; 304dd9f8062SIngo Weinhold} 305dd9f8062SIngo Weinhold 3065dc4e1efSIngo Weinholdrule SetupDefaultIncludes 3075dc4e1efSIngo Weinhold{ 3085dc4e1efSIngo Weinhold # Resets HDRS to the default headers for the build platform. 3095dc4e1efSIngo Weinhold HDRS = $(PLATFORM_DEFAULT_HEADERS) ; 3105dc4e1efSIngo Weinhold} 3115dc4e1efSIngo Weinhold 31252a38012Sejakowatz#------------------------------------------------------------------------------- 31352a38012Sejakowatz# Things Jam needs in order to work :) 31452a38012Sejakowatz#------------------------------------------------------------------------------- 31552a38012Sejakowatz 316c06f365fSIngo Weinhold# TODO: back-ported from jam 2.5: remove when not longer needed 317c06f365fSIngo Weinholdrule MakeLocate 318c06f365fSIngo Weinhold{ 319c06f365fSIngo Weinhold if $(>) 320c06f365fSIngo Weinhold { 321c06f365fSIngo Weinhold LOCATE on $(<) = $(>) ; 322c06f365fSIngo Weinhold Depends $(<) : $(>[1]:G=dir) ; 323c06f365fSIngo Weinhold MkDir $(>[1]:G=dir) ; 324c06f365fSIngo Weinhold } 325c06f365fSIngo Weinhold} 326c06f365fSIngo Weinhold 3278d3308d9SIngo Weinholdrule Object 3288d3308d9SIngo Weinhold{ 3298d3308d9SIngo Weinhold # This is basically the original Jambase 2.4 Object rule stripped by 3308d3308d9SIngo Weinhold # comments. Only the final switch statement has been changed to allow 3318d3308d9SIngo Weinhold # intermediate C++ files for Yacc and Lex. 3328d3308d9SIngo Weinhold 3338d3308d9SIngo Weinhold LocalClean clean : $(<) ; 3348d3308d9SIngo Weinhold 3358d3308d9SIngo Weinhold MakeLocate $(<) : $(LOCATE_TARGET) ; 3368d3308d9SIngo Weinhold SEARCH on $(>) = $(SEARCH_SOURCE) ; 3378d3308d9SIngo Weinhold 3388d3308d9SIngo Weinhold HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ; 3398d3308d9SIngo Weinhold 3408d3308d9SIngo Weinhold HDRRULE on $(>) = HdrRule ; 3418d3308d9SIngo Weinhold HDRSCAN on $(>) = $(HDRPATTERN) ; 3428d3308d9SIngo Weinhold HDRSEARCH on $(>) = 3438d3308d9SIngo Weinhold $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ; 3448d3308d9SIngo Weinhold 3458d3308d9SIngo Weinhold HDRGRIST on $(>) = $(HDRGRIST) ; 3468d3308d9SIngo Weinhold 3478d3308d9SIngo Weinhold DEFINES on $(<) += $(DEFINES) ; 3488d3308d9SIngo Weinhold 3498d3308d9SIngo Weinhold # if source is not .c, generate .c with specific rule 3508d3308d9SIngo Weinhold 3518d3308d9SIngo Weinhold switch $(>:S) 3528d3308d9SIngo Weinhold { 3538d3308d9SIngo Weinhold case .asm : As $(<) : $(>) ; 3548d3308d9SIngo Weinhold case .c : Cc $(<) : $(>) ; 3558d3308d9SIngo Weinhold case .C : C++ $(<) : $(>) ; 3568d3308d9SIngo Weinhold case .cc : C++ $(<) : $(>) ; 3578d3308d9SIngo Weinhold case .cpp : C++ $(<) : $(>) ; 3588d3308d9SIngo Weinhold case .f : Fortran $(<) : $(>) ; 3598d3308d9SIngo Weinhold case .l : if [ on $(2) return $(GENERATE_C++) ] { 3608d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 3618d3308d9SIngo Weinhold LexC++ $(<:S=.cpp) : $(>) ; 3628d3308d9SIngo Weinhold } else { 3638d3308d9SIngo Weinhold Cc $(<) : $(<:S=.c) ; 3648d3308d9SIngo Weinhold Lex $(<:S=.c) : $(>) ; 3658d3308d9SIngo Weinhold } 3668d3308d9SIngo Weinhold case .s : As $(<) : $(>) ; 3678d3308d9SIngo Weinhold case .y : if [ on $(2) return $(GENERATE_C++) ] { 3688d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 3698d3308d9SIngo Weinhold Bison $(<:S=.cpp) : $(>) ; 3708d3308d9SIngo Weinhold } else { 3718d3308d9SIngo Weinhold Cc $(<) : $(<:S=$(YACCGEN)) ; 3728d3308d9SIngo Weinhold Yacc $(<:S=$(YACCGEN)) : $(>) ; 3738d3308d9SIngo Weinhold } 3748d3308d9SIngo Weinhold case * : UserObject $(<) : $(>) ; 3758d3308d9SIngo Weinhold } 3768d3308d9SIngo Weinhold} 3778d3308d9SIngo Weinhold 37852a38012Sejakowatzrule UserObject 37952a38012Sejakowatz{ 38052a38012Sejakowatz switch $(2) 38152a38012Sejakowatz { 38252a38012Sejakowatz case *.S : assemble $(1) : $(2) ; 38308125d07SIngo Weinhold case *.o : return ; 38452a38012Sejakowatz case * : ECHO "unknown suffix on" $(2) ; 38552a38012Sejakowatz } 38652a38012Sejakowatz} 38752a38012Sejakowatz 38852a38012Sejakowatz# Override the default to give "prettier" command lines. 38952a38012Sejakowatzactions Cc 39052a38012Sejakowatz{ 391*025d0733SJérôme Duval $(CC) $(CCFLAGS) -c "$(2)" $(CCDEFS) $(CCHDRS) -o "$(1)" ; 39252a38012Sejakowatz} 39352a38012Sejakowatz 39452a38012Sejakowatzactions C++ 39552a38012Sejakowatz{ 3960931b8f9SIngo Weinhold $(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; 39752a38012Sejakowatz} 39852a38012Sejakowatz 39952a38012Sejakowatz 40052a38012Sejakowatz#------------------------------------------------------------------------------- 40152a38012Sejakowatz# General High-level OBOS target rules 40252a38012Sejakowatz#------------------------------------------------------------------------------- 40352a38012Sejakowatz 4045f281ed5Sejakowatzrule App 4055f281ed5Sejakowatz{ 40639a01fbbSshatty # App <name> : <sources> : <libraries> : <res> ; 407a6c008e1Sbeveloper SetupIncludes ; 4085f281ed5Sejakowatz SetupObjectsDir ; 40939a01fbbSshatty AddResources $(1) : $(4) ; 410007eb5f2SIngo Weinhold Main $(1) : $(2) ; 411007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_APPS_DIR) ; 412007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 413007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 414007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 4155f281ed5Sejakowatz} 4165f281ed5Sejakowatz 417f06de7f3SIngo Weinholdrule BinCommand 418f06de7f3SIngo Weinhold{ 41911fa3682SJérôme Duval # BinCommand <name> : <sources> : <libraries> : <res> ; 420a6c008e1Sbeveloper SetupIncludes ; 421f06de7f3SIngo Weinhold SetupObjectsDir ; 42211fa3682SJérôme Duval AddResources $(1) : $(4) ; 423f06de7f3SIngo Weinhold Main $(1) : $(2) ; 424f06de7f3SIngo Weinhold MakeLocate $(1) : $(OBOS_BIN_DIR) ; 425f06de7f3SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 426007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 427007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 428f06de7f3SIngo Weinhold} 429f06de7f3SIngo Weinhold 430f06de7f3SIngo Weinholdrule StdBinCommands 431f06de7f3SIngo Weinhold{ 43211fa3682SJérôme Duval # StdBinCommands <sources> : <libs> : <res> ; 433a6c008e1Sbeveloper SetupIncludes ; 434a6c008e1Sbeveloper SetupObjectsDir ; 435f06de7f3SIngo Weinhold local libs = $(2) ; 43611fa3682SJérôme Duval local ress = $(3) ; 4379342c27aSIngo Weinhold local source ; 438f06de7f3SIngo Weinhold for source in $(1) 439f06de7f3SIngo Weinhold { 440f06de7f3SIngo Weinhold local target = $(source:S=) ; 441a6c008e1Sbeveloper 44211fa3682SJérôme Duval BinCommand $(target) : $(source) : $(libs) : $(ress) ; 443f06de7f3SIngo Weinhold } 444f06de7f3SIngo Weinhold} 445f06de7f3SIngo Weinhold 44652a38012Sejakowatzrule Preference 44752a38012Sejakowatz{ 448007eb5f2SIngo Weinhold # Preference <name> : <sources> : <libraries> ; 449a6c008e1Sbeveloper SetupIncludes ; 45052a38012Sejakowatz SetupObjectsDir ; 451007eb5f2SIngo Weinhold Main $(1) : $(2) ; 452007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_PREFS_DIR) ; 453007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 454007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 455007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 45652a38012Sejakowatz} 45752a38012Sejakowatz 45852a38012Sejakowatzrule Server 45952a38012Sejakowatz{ 460007eb5f2SIngo Weinhold # Server <name> : <sources> : <libraries> ; 46152a38012Sejakowatz 462a6c008e1Sbeveloper SetupIncludes ; 46352a38012Sejakowatz SetupObjectsDir ; 464007eb5f2SIngo Weinhold Main $(1) : $(2) ; 465007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_SERVER_DIR) ; 466007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 467007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 468007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 46952a38012Sejakowatz} 47052a38012Sejakowatz 47152a38012Sejakowatz# test pseudo targets 47252a38012SejakowatzNOTFILE obostests ; 47352a38012SejakowatzNOTFILE r5tests ; 47452a38012Sejakowatz 475d1f6c38fSTyler Dauwalderrule CommonTestLib 476d1f6c38fSTyler Dauwalder{ 477c5ff4aa6STyler Dauwalder # CommonTestLib <target> : <sources> : <obos libraries> 4789285de51STyler Dauwalder # : <r5 libraries> : <test libraries> : <public headers>; 479d1f6c38fSTyler Dauwalder # Builds a unit test for both OBOS and R5 modules. 480d1f6c38fSTyler Dauwalder # <target> The name of the target. 481d1f6c38fSTyler Dauwalder # <sources> The list of sources. 482d1f6c38fSTyler Dauwalder # <obos libraries> A list of link libraries for the OBOS tests (as passed 483d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 484d1f6c38fSTyler Dauwalder # <r5 libraries> A list of link libraries for the R5 tests (as passed 485d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 4869285de51STyler Dauwalder # <test libraries> A list of link libraries for both OBOS tests and R5 tests 4879285de51STyler Dauwalder # that have a common name (i.e. specify libx.so and the OBOS tests will link 4889285de51STyler Dauwalder # to libx.so and the R5 tests will link to libx_r5.so). 489d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 490d1f6c38fSTyler Dauwalder # UsePublicHeaders). 491d1f6c38fSTyler Dauwalder 492c5ff4aa6STyler Dauwalder TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester lib ] : $(3) $(5) : $(6) ; 493c5ff4aa6STyler Dauwalder R5TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester_r5 lib ] : $(4) [ R5SharedLibraryNames $(5) ] ; 494d1f6c38fSTyler Dauwalder} 495d1f6c38fSTyler Dauwalder 496d1f6c38fSTyler Dauwalderrule TestLib 497d1f6c38fSTyler Dauwalder{ 498d1f6c38fSTyler Dauwalder # TestLib <target> : <sources> : <dest> : <libraries> : <public headers> 499d1f6c38fSTyler Dauwalder # Builds a unit test library for an OBOS module. 500d1f6c38fSTyler Dauwalder # <target> The name of the target. 501d1f6c38fSTyler Dauwalder # <sources> The list of sources. 502d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 503d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 504d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 505d1f6c38fSTyler Dauwalder # UsePublicHeaders). 506d1f6c38fSTyler Dauwalder 507d1f6c38fSTyler Dauwalder local target = $(1) ; 508d1f6c38fSTyler Dauwalder local sources = $(2) ; 509d1f6c38fSTyler Dauwalder local dest = $(3) ; 510d1f6c38fSTyler Dauwalder local libraries = $(4) ; 511d1f6c38fSTyler Dauwalder local headerDirs = $(5) ; 5129342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 513d1f6c38fSTyler Dauwalder 5149342c27aSIngo Weinhold # Our Main replacement. 5159342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 5169342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 517d1f6c38fSTyler Dauwalder 518d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 5190d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 5200d1cdd94SIngo Weinhold Depends obostests : $(target) ; 521d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 522d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 523d1f6c38fSTyler Dauwalder} 524d1f6c38fSTyler Dauwalder 525d1f6c38fSTyler Dauwalderrule R5TestLib 526d1f6c38fSTyler Dauwalder{ 527c5ff4aa6STyler Dauwalder # R5TestLib <target> : <sources> : <dest> : <libraries> 528d1f6c38fSTyler Dauwalder # Builds a unit test for an R5 module. "_r5" is appended to the object 529d1f6c38fSTyler Dauwalder # and the target name. 530d1f6c38fSTyler Dauwalder # <target> The name of the target. 531d1f6c38fSTyler Dauwalder # <sources> The list of sources. 532d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 533d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 534d1f6c38fSTyler Dauwalder 535d1f6c38fSTyler Dauwalder local target = $(1:B)_r5$(1:S) ; 536d1f6c38fSTyler Dauwalder local sources = $(2) ; 537c5ff4aa6STyler Dauwalder local dest = $(3) ; 538d1f6c38fSTyler Dauwalder local libraries = $(4) ; 539d1f6c38fSTyler Dauwalder local objects = [ R5ObjectNames $(sources) ] ; 540d1f6c38fSTyler Dauwalder 541d1f6c38fSTyler Dauwalder # Our Main replacement. 542d1f6c38fSTyler Dauwalder MainFromObjects $(target) : $(objects) ; 5439342c27aSIngo Weinhold TestObjects $(sources) : : true ; 544d1f6c38fSTyler Dauwalder 545d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 5460d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 5470d1cdd94SIngo Weinhold Depends r5tests : $(target) ; 548d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 549d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 550d1f6c38fSTyler Dauwalder} 551d1f6c38fSTyler Dauwalder 55252a38012Sejakowatzrule CommonUnitTest 55352a38012Sejakowatz{ 55452a38012Sejakowatz # CommonUnitTest <target> : <sources> : <dest> : <obos libraries> 55552a38012Sejakowatz # : <r5 libraries> : <public headers>; 55652a38012Sejakowatz # Builds a unit test for both OBOS and R5 modules. 55752a38012Sejakowatz # <target> The name of the target. 55852a38012Sejakowatz # <sources> The list of sources. 55952a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 56052a38012Sejakowatz # <obos libraries> A list of link libraries for the OBOS tests (as passed 56152a38012Sejakowatz # to LinkSharedOSLibs). 56252a38012Sejakowatz # <r5 libraries> A list of link libraries for the R5 tests (as passed 56352a38012Sejakowatz # to LinkSharedOSLibs). 56452a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 56552a38012Sejakowatz # UsePublicHeaders). 56652a38012Sejakowatz 56752a38012Sejakowatz UnitTest $(1) : $(2) : $(3) : $(4) : $(6) ; 56852a38012Sejakowatz R5UnitTest $(1) : $(2) : $(3) : $(5) ; 56952a38012Sejakowatz} 57052a38012Sejakowatz 57152a38012Sejakowatzrule UnitTest 57252a38012Sejakowatz{ 57352a38012Sejakowatz # UnitTest <target> : <sources> : <dest> : <libraries> : <public headers> 57452a38012Sejakowatz # Builds a unit test for an OBOS module. 57552a38012Sejakowatz # <target> The name of the target. 57652a38012Sejakowatz # <sources> The list of sources. 57752a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 57852a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 57952a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 58052a38012Sejakowatz # UsePublicHeaders). 58152a38012Sejakowatz 58252a38012Sejakowatz local target = $(1) ; 58352a38012Sejakowatz local sources = $(2) ; 58452a38012Sejakowatz local dest = $(3) ; 58552a38012Sejakowatz local libraries = $(4) ; 58652a38012Sejakowatz local headerDirs = $(5) ; 5879342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 58852a38012Sejakowatz 5899342c27aSIngo Weinhold # Our Main replacement. 5909342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 5919342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 5923b9eae39SIngo Weinhold 59352a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 5949eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 5959eea4522SIngo Weinhold Depends obostests : $(target) ; 59652a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 59752a38012Sejakowatz} 59852a38012Sejakowatz 59952a38012Sejakowatzrule R5UnitTest 60052a38012Sejakowatz{ 60152a38012Sejakowatz # R5UnitTest <target> : <sources> : <dest> : <libraries> 60252a38012Sejakowatz # Builds a unit test for an R5 module. "_r5" is appended to the object 60352a38012Sejakowatz # and the target name. 60452a38012Sejakowatz # <target> The name of the target. 60552a38012Sejakowatz # <sources> The list of sources. 60652a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 60752a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 60852a38012Sejakowatz 60952a38012Sejakowatz local target = $(1)_r5 ; 61052a38012Sejakowatz local sources = $(2) ; 61152a38012Sejakowatz local dest = $(3) ; 61252a38012Sejakowatz local libraries = $(4) ; 61352a38012Sejakowatz local objects = [ R5ObjectNames $(sources) ] ; 61452a38012Sejakowatz 61552a38012Sejakowatz # Our Main replacement. 61652a38012Sejakowatz MainFromObjects $(target) : $(objects) ; 6179342c27aSIngo Weinhold TestObjects $(sources) : : true ; 61852a38012Sejakowatz 61952a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 6209eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 6219eea4522SIngo Weinhold Depends r5tests : $(target) ; 62252a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 62352a38012Sejakowatz} 62452a38012Sejakowatz 62552a38012Sejakowatzrule R5ObjectNames 62652a38012Sejakowatz{ 62752a38012Sejakowatz # R5ObjectNames <sources> ; 62852a38012Sejakowatz # Returns a list of gristed object names given a list of source file names. 62952a38012Sejakowatz # Moreover each object names gets "_r5" inserted before the object suffix. 63052a38012Sejakowatz local objects = $(1:S=)_r5 ; 63152a38012Sejakowatz return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ; 63252a38012Sejakowatz} 63352a38012Sejakowatz 6349342c27aSIngo Weinholdrule R5Objects 6359342c27aSIngo Weinhold{ 6369342c27aSIngo Weinhold # R5Objects <sources> 637dd9f8062SIngo Weinhold # Similar to Objects, but appends "_r5" to the object file names and 638dd9f8062SIngo Weinhold # removes `-nostdinc' from the CC and C++ flags to enable system headers. 6399342c27aSIngo Weinhold # <sources> The source files. 6409342c27aSIngo Weinhold 641dd9f8062SIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 642dd9f8062SIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 643dd9f8062SIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 644dd9f8062SIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 645dd9f8062SIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 646dd9f8062SIngo Weinhold 6479342c27aSIngo Weinhold local sources = $(1) ; 6489342c27aSIngo Weinhold local source ; 6499342c27aSIngo Weinhold for source in [ FGristFiles $(sources) ] 6509342c27aSIngo Weinhold { 6519342c27aSIngo Weinhold local object = [ R5ObjectNames $(source) ] ; 6529342c27aSIngo Weinhold Object $(object) : $(source) ; 6539342c27aSIngo Weinhold LocalDepends obj : $(object) ; 6549342c27aSIngo Weinhold } 655dd9f8062SIngo Weinhold 656dd9f8062SIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 657dd9f8062SIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 658dd9f8062SIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 6599342c27aSIngo Weinhold} 6609342c27aSIngo Weinhold 6619342c27aSIngo Weinholdrule TestObjects 6629342c27aSIngo Weinhold{ 6639342c27aSIngo Weinhold # TestLib <sources> : <public headers> : <r5> 6649342c27aSIngo Weinhold # Compiles objects for tests. 6659342c27aSIngo Weinhold # <sources> The list of sources. 6669342c27aSIngo Weinhold # <public headers> A list of public header dirs (as passed to 6679342c27aSIngo Weinhold # UsePublicHeaders). 6689342c27aSIngo Weinhold # <r5> If set, "_r5" is appended to the object file names and 6699342c27aSIngo Weinhold # <public headers> is ignored. Furthermore the pre-processor macro 6709342c27aSIngo Weinhold # TEST_R5 is defined, TEST_OBOS otherwise. 6719342c27aSIngo Weinhold 6729342c27aSIngo Weinhold local sources = $(1) ; 6739342c27aSIngo Weinhold local headerDirs = $(2) ; 6749342c27aSIngo Weinhold local r5 = $(3) ; 6759342c27aSIngo Weinhold local objects ; 6769342c27aSIngo Weinhold 6779342c27aSIngo Weinhold # Turn optimization off. 67896d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6799342c27aSIngo Weinhold local optim = $(OPTIM) ; 6809342c27aSIngo Weinhold OPTIM = ; 68196d27465SIngo Weinhold } 6829342c27aSIngo Weinhold 6839342c27aSIngo Weinhold SetupObjectsDir ; 6849342c27aSIngo Weinhold 6859342c27aSIngo Weinhold # compile 6869342c27aSIngo Weinhold if $(r5) { 687dd9f8062SIngo Weinhold SetupR5Includes ; 6889342c27aSIngo Weinhold objects = [ R5ObjectNames $(sources) ] ; 6899342c27aSIngo Weinhold R5Objects $(sources) ; 6909342c27aSIngo Weinhold } else { 691dd9f8062SIngo Weinhold SetupIncludes ; 6929342c27aSIngo Weinhold objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 6939342c27aSIngo Weinhold Objects $(sources) ; 6949342c27aSIngo Weinhold } 6959342c27aSIngo Weinhold 6969342c27aSIngo Weinhold # set headers/defines 6979b60a208SIngo Weinhold UseCppUnitObjectHeaders $(sources) : $(objects) ; 6989342c27aSIngo Weinhold if $(r5) { 699728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_R5 ; 7009342c27aSIngo Weinhold } else { 7019b60a208SIngo Weinhold UsePublicObjectHeaders $(sources) : $(headerDirs) : $(objects) ; 702728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_OBOS ; 7039342c27aSIngo Weinhold } 7049342c27aSIngo Weinhold 70596d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7069342c27aSIngo Weinhold # Turn debugging on. That is usually desired for test code. 7079342c27aSIngo Weinhold ObjectCcFlags $(objects) : "-g" ; 7089342c27aSIngo Weinhold ObjectC++Flags $(objects) : "-g" ; 7099342c27aSIngo Weinhold 7109342c27aSIngo Weinhold # Turn optimization on again. 7119342c27aSIngo Weinhold OPTIM = $(optim) ; 7129342c27aSIngo Weinhold } 71396d27465SIngo Weinhold} 7149342c27aSIngo Weinhold 7159285de51STyler Dauwalderrule R5SharedLibraryNames 7169285de51STyler Dauwalder{ 7179285de51STyler Dauwalder # R5SharedLibraryNames <sources> ; 7189285de51STyler Dauwalder # Returns a list of shared library names given a list of file names. NO 7199285de51STyler Dauwalder # GRISTING IS PERFORMED :-) However, each library names gets "_r5" inserted 7209285de51STyler Dauwalder # before the shared lib suffix. 7219285de51STyler Dauwalder return $(1:S=)_r5.so ; 7229285de51STyler Dauwalder} 7239285de51STyler Dauwalder 7249fc6b2e1SIngo Weinholdrule SimpleTest 7259fc6b2e1SIngo Weinhold{ 7269fc6b2e1SIngo Weinhold # UnitTest <target> : <sources> : <libraries> 7279fc6b2e1SIngo Weinhold # Builds a unit test for an OBOS module. 7289fc6b2e1SIngo Weinhold # <target> The name of the target. 7299fc6b2e1SIngo Weinhold # <sources> The list of sources. 7309fc6b2e1SIngo Weinhold # <dest> The directory for the target (as passed to FDirName). 7319fc6b2e1SIngo Weinhold # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 7329fc6b2e1SIngo Weinhold # <public headers> A list of public header dirs (as passed to 7339fc6b2e1SIngo Weinhold # UsePublicHeaders). 7349fc6b2e1SIngo Weinhold 7359fc6b2e1SIngo Weinhold local target = $(1) ; 7369fc6b2e1SIngo Weinhold local sources = $(2) ; 7379fc6b2e1SIngo Weinhold local libraries = $(3) ; 7389fc6b2e1SIngo Weinhold local relPath = [ FRelPath src tests : $(SUBDIR_TOKENS) ] ; 7399fc6b2e1SIngo Weinhold 7409fc6b2e1SIngo Weinhold # Turn optimization off. 74196d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7429fc6b2e1SIngo Weinhold local optim = $(OPTIM) ; 7439fc6b2e1SIngo Weinhold OPTIM = ; 74496d27465SIngo Weinhold } 7459fc6b2e1SIngo Weinhold 746a6c008e1Sbeveloper SetupIncludes ; 7479fc6b2e1SIngo Weinhold SetupObjectsDir ; 7489fc6b2e1SIngo Weinhold MakeLocateObjects $(sources) ; 7499fc6b2e1SIngo Weinhold Main $(target) : $(sources) ; 7509fc6b2e1SIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 7519eea4522SIngo Weinhold Depends obostests : $(target) ; 7529fc6b2e1SIngo Weinhold LinkSharedOSLibs $(target) : $(libraries) ; 753728b5725SIngo Weinhold ObjectsDefines $(sources) : TEST_OBOS ; 75496d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7559fc6b2e1SIngo Weinhold # Turn debugging on. That is usually desired for test code. 7569fc6b2e1SIngo Weinhold ObjectCcFlags $(sources) : "-g" ; 7579fc6b2e1SIngo Weinhold ObjectC++Flags $(sources) : "-g" ; 7589fc6b2e1SIngo Weinhold 7599fc6b2e1SIngo Weinhold # Turn optimization on again. 7609fc6b2e1SIngo Weinhold OPTIM = $(optim) ; 7619fc6b2e1SIngo Weinhold } 76296d27465SIngo Weinhold} 7639fc6b2e1SIngo Weinhold 76452a38012Sejakowatzrule Addon 76552a38012Sejakowatz{ 76683b3b0dfSIngo Weinhold # Addon <name> : <relpath> : <sources> : <is executable> : <libraries> ; 7677a384fdeSIngo Weinhold # <name>: Name of the add-on. 7687a384fdeSIngo Weinhold # <relpath>: Path where the add-on shall live relative to the add-on dir. 7697a384fdeSIngo Weinhold # <sources>: Source files. 77083b3b0dfSIngo Weinhold # <is executable>: true, if the target shall be executable as well. 77183b3b0dfSIngo Weinhold # <libraries>: Libraries to be linked against. 7727a384fdeSIngo Weinhold 7737a384fdeSIngo Weinhold local isExecutable = $(4) ; 77452a38012Sejakowatz 775a6c008e1Sbeveloper SetupIncludes ; 77652a38012Sejakowatz SetupObjectsDir ; 77752a38012Sejakowatz Main $(1) : $(3) ; 77852a38012Sejakowatz 77952a38012Sejakowatz # Create output dir path for addon 78052a38012Sejakowatz local targetdir; 78152a38012Sejakowatz targetdir = [ FDirName $(OBOS_ADDON_DIR) $(2) ] ; 78252a38012Sejakowatz 78352a38012Sejakowatz MakeLocate $(1) : $(targetdir) ; 7847a384fdeSIngo Weinhold 7857a384fdeSIngo Weinhold local linkFlags = -Xlinker -soname=\"$(1)\" ; 7867a384fdeSIngo Weinhold if $(isExecutable) != true { 7877a384fdeSIngo Weinhold linkFlags = -nostart $(linkFlags) ; 7887a384fdeSIngo Weinhold } 7897a384fdeSIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] $(linkFlags) ; 79083b3b0dfSIngo Weinhold LinkSharedOSLibs $(1) : $(5) ; 791af28904fSIngo Weinhold} 792af28904fSIngo Weinhold 79358efc9d8SIngo Weinholdrule R5KernelAddon 794af28904fSIngo Weinhold{ 795600203b1SAxel Dörfler # R5KernelAddon <name> : <relpath> : <sources> : <static-libraries> ; 796af28904fSIngo Weinhold 797af28904fSIngo Weinhold local sources = $(3) ; 798af28904fSIngo Weinhold 799af28904fSIngo Weinhold Addon $(1) : $(2) : $(3) ; 800af28904fSIngo Weinhold ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 801df48dfedSIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic -fno-exceptions ; 8029eea4522SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; 803600203b1SAxel Dörfler LinkSharedOSLibs $(1) : $(4) /boot/develop/lib/x86/_KERNEL_ ; 80452a38012Sejakowatz} 80552a38012Sejakowatz 8064fb5add0SMatthew Wilberrule Translator 8074fb5add0SMatthew Wilber{ 808007eb5f2SIngo Weinhold # Translator <name> : <sources> : <libraries> ; 809a6c008e1Sbeveloper SetupIncludes ; 8104fb5add0SMatthew Wilber SetupObjectsDir ; 8114fb5add0SMatthew Wilber Main $(1) : $(2) ; 812007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 8134fb5add0SMatthew Wilber 8144fb5add0SMatthew Wilber # Create output dir path for translator 8154fb5add0SMatthew Wilber local targetdir; 816d5b07cf2Sshatty targetdir = [ FDirName $(OBOS_ADDON_DIR) Translators ] ; 8174fb5add0SMatthew Wilber MakeLocate $(1) : $(targetdir) ; 8184fb5add0SMatthew Wilber} 8194fb5add0SMatthew Wilber 820c4071913SMatthew Wilberrule ScreenSaver 821c4071913SMatthew Wilber{ 822c4071913SMatthew Wilber # ScreenSaver <name> : <sources> : <libraries> ; 823c4071913SMatthew Wilber Addon $(1) : screen_savers : $(2) : false : $(3) ; 824c4071913SMatthew Wilber} 825c4071913SMatthew Wilber 82652a38012Sejakowatzrule MakeLocateObjects 82752a38012Sejakowatz{ 82821df5945SIngo Weinhold # MakeLocateObjects <sources_or_objects> ; 82952a38012Sejakowatz 83021df5945SIngo Weinhold local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 83152a38012Sejakowatz 83252a38012Sejakowatz for o in $(_objs) 83352a38012Sejakowatz { 83452a38012Sejakowatz local dir = $(o:D) ; 83552a38012Sejakowatz if $(dir) { 83652a38012Sejakowatz MakeLocate $(o) : [ FDirName $(LOCATE_TARGET) $(dir) ] ; 83752a38012Sejakowatz } else { 83852a38012Sejakowatz MakeLocate $(o) : $(LOCATE_TARGET) ; 83952a38012Sejakowatz } 84052a38012Sejakowatz } 84152a38012Sejakowatz} 84252a38012Sejakowatz 84352a38012Sejakowatzrule StaticLibrary 84452a38012Sejakowatz{ 845e9230d05SIngo Weinhold # StaticLibrary <name> : <sources> [ : <target dir> ] ; 846e9230d05SIngo Weinhold # Creates a static library from sources. 847e9230d05SIngo Weinhold # <name>: Basename of the library, without leading "lib" and trailing ".a". 84860c9c40fSIngo Weinhold # Grist is allowed -- it will be re-prepended after constructing 84960c9c40fSIngo Weinhold # the complete library name. 850e9230d05SIngo Weinhold # <source>: List of source files. 851e9230d05SIngo Weinhold # <target dir>: Directory into which the library shall be placed. Defaults 85260c9c40fSIngo Weinhold # to the objects directory for this subdir. If 85360c9c40fSIngo Weinhold # STATIC_LIBRARY_DIR is supplied (the literal string) 85460c9c40fSIngo Weinhold # the standard directory for static libs is used, otherwise 85560c9c40fSIngo Weinhold # the parameter is interpreted as directory path. 856e9230d05SIngo Weinhold # 85760c9c40fSIngo Weinhold local lib = lib$(1:B)$(SUFLIB) ; 85860c9c40fSIngo Weinhold lib = $(lib:G=$(1:G)) ; 859a6c008e1Sbeveloper SetupIncludes ; 86052a38012Sejakowatz SetupObjectsDir ; 86152a38012Sejakowatz MakeLocateObjects $(2) ; 862e9230d05SIngo Weinhold Library $(lib) : $(2) ; 863e9230d05SIngo Weinhold local targetDir = $(3) ; 86460c9c40fSIngo Weinhold if $(targetDir) { 86560c9c40fSIngo Weinhold if $(targetDir) = STATIC_LIBRARY_DIR { 866e9230d05SIngo Weinhold targetDir = $(OBOS_STLIB_DIR) ; 867e9230d05SIngo Weinhold } 868e9230d05SIngo Weinhold MakeLocate $(lib) : $(targetDir) ; 86960c9c40fSIngo Weinhold } else { 87060c9c40fSIngo Weinhold # nothing to do, since the Library rule already located the library 87160c9c40fSIngo Weinhold # in $(LOCATE_TARGET) 87260c9c40fSIngo Weinhold } 873f1e077f8SIngo Weinhold 874f1e077f8SIngo Weinhold # If KEEPOBJS is set, Library doesn't make the library depend on 875f1e077f8SIngo Weinhold # `lib'. 876f1e077f8SIngo Weinhold if $(KEEPOBJS) { 877f1e077f8SIngo Weinhold LocalDepends lib : $(lib) ; 878f1e077f8SIngo Weinhold } 87952a38012Sejakowatz} 88052a38012Sejakowatz 881dbf96817SIngo Weinholdrule R5KernelStaticLibrary 882dbf96817SIngo Weinhold{ 883dbf96817SIngo Weinhold # R5KernelStaticLibrary <name> : <sources> ; 884dbf96817SIngo Weinhold 885f1e077f8SIngo Weinhold local lib = lib$(1)$(SUFLIB) ; 886dbf96817SIngo Weinhold local sources = $(2) ; 887dbf96817SIngo Weinhold 888dbf96817SIngo Weinhold SetupIncludes ; 889dbf96817SIngo Weinhold SetupObjectsDir ; 890dbf96817SIngo Weinhold MakeLocateObjects $(sources) ; 891dbf96817SIngo Weinhold Library $(lib) : $(sources) ; 892dbf96817SIngo Weinhold ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 893df48dfedSIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic -fno-exceptions ; 894dbf96817SIngo Weinhold} 895dbf96817SIngo Weinhold 89680721244SAxel Dörflerrule MergeObjectFromObjects 89780721244SAxel Dörfler{ 8982fbd7065SIngo Weinhold # MergeObjectFromObjects <name> : <objects> : <other objects> ; 8992fbd7065SIngo Weinhold # Merges object files to an object file. 9002fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 9012fbd7065SIngo Weinhold # <objects>: Object files to be merged. Grist will be added. 9022fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 9032fbd7065SIngo Weinhold # will be added. 9042fbd7065SIngo Weinhold # 905c8aa252aSIngo Weinhold local objects = [ FGristFiles $(2) ] ; 90680721244SAxel Dörfler MakeLocate $(1) : $(LOCATE_TARGET) ; 907c8aa252aSIngo Weinhold Depends $(1) : $(objects) ; 9082fbd7065SIngo Weinhold Depends $(1) : $(3) ; 90980721244SAxel Dörfler LINK on $(1) = ld ; 9102fbd7065SIngo Weinhold MergeObjectFromObjects1 $(1) : $(objects) $(3) ; 91180721244SAxel Dörfler} 91280721244SAxel Dörfler 91354b7cbe1SIngo Weinholdactions MergeObjectFromObjects1 91480721244SAxel Dörfler{ 91580721244SAxel Dörfler $(LINK) -r $(2) -o $(1) ; 91680721244SAxel Dörfler} 91780721244SAxel Dörfler 91880721244SAxel Dörflerrule MergeObject 91980721244SAxel Dörfler{ 9202fbd7065SIngo Weinhold # MergeObject <name> : <sources> : <other objects> ; 9212fbd7065SIngo Weinhold # Compiles source files and merges the object files to an object file. 9222fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 9232fbd7065SIngo Weinhold # <sources>: Sources to be compiled. Grist will be added. 9242fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 9252fbd7065SIngo Weinhold # will be added. 9262fbd7065SIngo Weinhold # 92780721244SAxel Dörfler SetupIncludes ; 92880721244SAxel Dörfler SetupObjectsDir ; 92980721244SAxel Dörfler MakeLocateObjects $(2) ; 93080721244SAxel Dörfler Objects $(2) ; 9312fbd7065SIngo Weinhold MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; 93280721244SAxel Dörfler} 93380721244SAxel Dörfler 93421df5945SIngo Weinholdrule SharedLibraryFromObjects 93552a38012Sejakowatz{ 9368d3308d9SIngo Weinhold # SharedLibraryFromObjects <name> : <objects> : <libraries> ; 93760c9c40fSIngo Weinhold local _lib = lib$(1:B).so ; 93860c9c40fSIngo Weinhold _lib = $(_lib:G=$(1:G)) ; 93921df5945SIngo Weinhold MainFromObjects $(_lib) : $(2) ; 94052a38012Sejakowatz MakeLocate $(_lib) : $(OBOS_SHLIB_DIR) ; 9419eea4522SIngo Weinhold LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ] 9429eea4522SIngo Weinhold -nostart -Xlinker -soname=\"$(_lib)\" ; 9438d3308d9SIngo Weinhold LinkSharedOSLibs $(_lib) : $(3) ; 94452a38012Sejakowatz} 94552a38012Sejakowatz 94621df5945SIngo Weinholdrule SharedLibrary 94721df5945SIngo Weinhold{ 9488d3308d9SIngo Weinhold # SharedLibrary <name> : <sources> : <libraries> ; 949a6c008e1Sbeveloper SetupIncludes ; 95021df5945SIngo Weinhold SetupObjectsDir ; 95121df5945SIngo Weinhold MakeLocateObjects $(2) ; 95221df5945SIngo Weinhold Objects $(2) ; 9538d3308d9SIngo Weinhold SharedLibraryFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; 95421df5945SIngo Weinhold} 95521df5945SIngo Weinhold 95652a38012Sejakowatzrule LinkSharedOSLibs 95752a38012Sejakowatz{ 95852a38012Sejakowatz # LinkSharedOSLibs <name> : <libs> ; 95952a38012Sejakowatz # Valid elements for <libs> are e.g. "be" or "libopenbeos.so" or 9604236d490SIngo Weinhold # "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy 9614236d490SIngo Weinhold # has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the 9624236d490SIngo Weinhold # file will be bound!), otherwise it is prefixed "-l" and added to 963a8cd0719SIngo Weinhold # LINKLIBS. If you want to specify a target that isn't a library and 964a8cd0719SIngo Weinhold # also has neither grist nor a dirname, you can prepend "<nogrist>" as 965a8cd0719SIngo Weinhold # grist; it will be stripped by this rule. 96652a38012Sejakowatz 96752a38012Sejakowatz for i in $(>) 96852a38012Sejakowatz { 9694236d490SIngo Weinhold local isfile = ; 9704236d490SIngo Weinhold if $(i:D) || $(i:G) { 9714236d490SIngo Weinhold isfile = true ; 972a8cd0719SIngo Weinhold if $(i:G) = <nogrist> { 973a8cd0719SIngo Weinhold i = $(i:G=) ; 974a8cd0719SIngo Weinhold } 9754236d490SIngo Weinhold } else { 97652a38012Sejakowatz switch $(i:B) 97752a38012Sejakowatz { 978007eb5f2SIngo Weinhold # XXX: _APP_ and _KERNEL_ should not be needed for ELF. 979f7901247SPhilippe Houdoin case _APP_ : isfile = true ; 980f7901247SPhilippe Houdoin case _KERNEL_ : isfile = true ; 9814236d490SIngo Weinhold case lib* : isfile = true ; 9824236d490SIngo Weinhold case * : isfile = ; 9834236d490SIngo Weinhold } 984b8baf385SIngo Weinhold if ! $(isfile) && ( $(i:S) = .so || $(i:S) = .a ) { 985b8baf385SIngo Weinhold isfile = true ; 986b8baf385SIngo Weinhold } 9874236d490SIngo Weinhold } 9884236d490SIngo Weinhold if $(isfile) { 9899eea4522SIngo Weinhold NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(i) ; 9909eea4522SIngo Weinhold Depends $(1) : $(i) ; 9914236d490SIngo Weinhold } else { 9929eea4522SIngo Weinhold LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] -l$(i) ; 99352a38012Sejakowatz } 99452a38012Sejakowatz } 99552a38012Sejakowatz} 99652a38012Sejakowatz 99752a38012Sejakowatzrule AddResources 99852a38012Sejakowatz{ 99952a38012Sejakowatz # AddResources <name> : <resourcefiles> ; 100052a38012Sejakowatz 10018d3308d9SIngo Weinhold local resfiles = [ FGristFiles $(2) ] ; 10028d3308d9SIngo Weinhold SEARCH on $(resfiles) += $(SEARCH_SOURCE) ; 10038d3308d9SIngo Weinhold 10048d3308d9SIngo Weinhold for file in $(resfiles) { 10058d3308d9SIngo Weinhold if $(file:S) = .rdef { 10068d3308d9SIngo Weinhold local rdef = $(file) ; 10078d3308d9SIngo Weinhold file = $(rdef:S=.rsrc) ; 10088d3308d9SIngo Weinhold ResComp $(file) : $(rdef) ; 10098d3308d9SIngo Weinhold } 10108d3308d9SIngo Weinhold RESFILES on $(1) += $(file) ; 10118d3308d9SIngo Weinhold } 10128d3308d9SIngo Weinhold} 10138d3308d9SIngo Weinhold 10148d3308d9SIngo Weinholdrule ResComp 10158d3308d9SIngo Weinhold{ 10168d3308d9SIngo Weinhold # ResComp <resource file> : <rdef file> ; 10178d3308d9SIngo Weinhold # 10188d3308d9SIngo Weinhold # <resource file> and <rdef file> must be gristed. 10198d3308d9SIngo Weinhold 10208d3308d9SIngo Weinhold SetupObjectsDir ; 10218d3308d9SIngo Weinhold 10229fc6b2e1SIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 10238d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_TARGET) ; 10248d3308d9SIngo Weinhold Depends $(1) : $(2) rc ; 10258d3308d9SIngo Weinhold LocalClean clean : $(1) ; 10268d3308d9SIngo Weinhold ResComp1 $(1) : rc $(2) ; 10278d3308d9SIngo Weinhold} 10288d3308d9SIngo Weinhold 10298d3308d9SIngo Weinholdactions ResComp1 10308d3308d9SIngo Weinhold{ 10316af76074SIngo Weinhold $(2[1]) -o $(1) $(2[2-]) 103252a38012Sejakowatz} 103352a38012Sejakowatz 1034728b5725SIngo Weinholdrule ObjectsDefines 1035728b5725SIngo Weinhold{ 1036728b5725SIngo Weinhold # Like ObjectDefines, but allows multiple files to be supplied 1037728b5725SIngo Weinhold local file ; 1038728b5725SIngo Weinhold for file in $(1) { 1039728b5725SIngo Weinhold ObjectDefines $(file) : $(2) ; 1040728b5725SIngo Weinhold } 1041728b5725SIngo Weinhold} 1042728b5725SIngo Weinhold 10439b60a208SIngo Weinholdrule SourceHdrs 10449b60a208SIngo Weinhold{ 10459b60a208SIngo Weinhold # SourceHdrs <sources> : <headers> [ : <gristed objects> ] ; 10469b60a208SIngo Weinhold # 10479b60a208SIngo Weinhold # Is a wrapper for ObjectHdrs, that passes <sources> and <headers> or, 10489b60a208SIngo Weinhold # if supplied <objects> and <headers>, and also adjusts HDRSEARCH (not 10499b60a208SIngo Weinhold # done by ObjectHdrs). 10509b60a208SIngo Weinhold 10519b60a208SIngo Weinhold local sources = [ FGristFiles $(1) ] ; 10529b60a208SIngo Weinhold local headers = $(2) ; 10539b60a208SIngo Weinhold local objects = $(3) ; 10549b60a208SIngo Weinhold 1055728b5725SIngo Weinhold local file ; 10569b60a208SIngo Weinhold if $(objects) { 1057728b5725SIngo Weinhold for file in $(objects) { 1058728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 1059c0e501e0SIngo Weinhold # also reformat the assembler headers 1060c0e501e0SIngo Weinhold ASHDRS on $(file) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) 1061c0e501e0SIngo Weinhold [ on $(file) return $(HDRS) ] ] ; 1062728b5725SIngo Weinhold } 10639b60a208SIngo Weinhold } else { 1064081debe8SIngo Weinhold for file in $(sources:S=$(SUFOBJ)) { 1065728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 1066c0e501e0SIngo Weinhold # also reformat the assembler headers 1067c0e501e0SIngo Weinhold ASHDRS on $(file) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) 1068c0e501e0SIngo Weinhold [ on $(file) return $(HDRS) ] ] ; 1069728b5725SIngo Weinhold } 10709b60a208SIngo Weinhold } 10719b60a208SIngo Weinhold 10729b60a208SIngo Weinhold # Also add the header search dirs to HDRSEARCH. Note, that these dirs 10739b60a208SIngo Weinhold # will be listed after the STDHDRS (if any), but that's better than not 10749b60a208SIngo Weinhold # being listed at all. 10759b60a208SIngo Weinhold HDRSEARCH on $(sources) += $(headers) ; 10769b60a208SIngo Weinhold} 10779b60a208SIngo Weinhold 10787d7f280eSIngo Weinholdrule PublicHeaders 107952a38012Sejakowatz{ 10807d7f280eSIngo Weinhold # PublicHeaders <group list> 108152a38012Sejakowatz # 10827d7f280eSIngo Weinhold # Returns the directory names for the public header dirs identified by 10837d7f280eSIngo Weinhold # <group list>. 108452a38012Sejakowatz 108552a38012Sejakowatz local list = $(1) ; 1086b005dbe3SAxel Dörfler local dirs = [ FDirName $(OBOS_TOP) headers os ] ; 1087b005dbe3SAxel Dörfler 108852a38012Sejakowatz for i in $(list) { 10897d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers os $(i) ] ; 10907d7f280eSIngo Weinhold } 10917d7f280eSIngo Weinhold return $(dirs) ; 109252a38012Sejakowatz} 109352a38012Sejakowatz 10947d7f280eSIngo Weinholdrule PrivateHeaders 10957d7f280eSIngo Weinhold{ 10967d7f280eSIngo Weinhold # PrivateHeaders <group list> 10977d7f280eSIngo Weinhold # 10987d7f280eSIngo Weinhold # Returns the directory names for the private header dirs identified by 10997d7f280eSIngo Weinhold # <group list>. 11007d7f280eSIngo Weinhold 11017d7f280eSIngo Weinhold local list = $(1) ; 11027d7f280eSIngo Weinhold local dirs ; 11037d7f280eSIngo Weinhold for i in $(list) { 11047d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers private $(i) ] ; 11057d7f280eSIngo Weinhold } 11067d7f280eSIngo Weinhold return $(dirs) ; 11077d7f280eSIngo Weinhold} 11087d7f280eSIngo Weinhold 11090f434a0aSDarkWyrmrule LibraryHeaders 11100f434a0aSDarkWyrm{ 11110f434a0aSDarkWyrm # LibraryHeaders <group list> 11120f434a0aSDarkWyrm # 11130f434a0aSDarkWyrm # Returns the directory names for the library header dirs identified by 11140f434a0aSDarkWyrm # <group list>. 11150f434a0aSDarkWyrm 11160f434a0aSDarkWyrm local list = $(1) ; 11170f434a0aSDarkWyrm local dirs ; 11180f434a0aSDarkWyrm for i in $(list) { 11190f434a0aSDarkWyrm dirs += [ FDirName $(OBOS_TOP) headers libs $(i) ] ; 11200f434a0aSDarkWyrm } 11210f434a0aSDarkWyrm return $(dirs) ; 11220f434a0aSDarkWyrm} 11230f434a0aSDarkWyrm 11247d7f280eSIngo Weinholdrule ArchHeaders 11257d7f280eSIngo Weinhold{ 11267d7f280eSIngo Weinhold # usage: ArchHeaders <arch> ; 11277d7f280eSIngo Weinhold # 11287d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 11297d7f280eSIngo Weinhold 11307d7f280eSIngo Weinhold return [ FDirName $(OBOS_TOP) headers private kernel arch $(1) ] ; 11317d7f280eSIngo Weinhold} 11327d7f280eSIngo Weinhold 11337d7f280eSIngo Weinholdrule UsePublicHeaders 11347d7f280eSIngo Weinhold{ 1135966528dcSIngo Weinhold # UsePublicHeaders <group list> ; 1136966528dcSIngo Weinhold # 1137966528dcSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 1138966528dcSIngo Weinhold # dirs of the subdirectory. 1139966528dcSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the 1140966528dcSIngo Weinhold # objects. 1141966528dcSIngo Weinhold 1142966528dcSIngo Weinhold UseHeaders [ PublicHeaders $(1) ] ; 11437d7f280eSIngo Weinhold} 11447d7f280eSIngo Weinhold 11457d7f280eSIngo Weinholdrule UsePublicObjectHeaders 11467d7f280eSIngo Weinhold{ 11479b60a208SIngo Weinhold # UsePublicObjectHeaders <sources> : <group list> [ : <objects> ] ; 11487d7f280eSIngo Weinhold # 11497d7f280eSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 11509b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 11519b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 11527d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 11537d7f280eSIngo Weinhold 11549b60a208SIngo Weinhold SourceHdrs $(1) : [ PublicHeaders $(2) ] : $(3) ; 115552a38012Sejakowatz} 115652a38012Sejakowatz 115752a38012Sejakowatzrule UsePrivateHeaders 115852a38012Sejakowatz{ 11597d7f280eSIngo Weinhold # UsePrivateHeaders <group list> ; 116052a38012Sejakowatz # 116152a38012Sejakowatz # Adds the private C header dirs given by <group list> to the header search 11627d7f280eSIngo Weinhold # dirs of the subdirectory. 11637d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 116452a38012Sejakowatz 11657d7f280eSIngo Weinhold UseHeaders [ PrivateHeaders $(1) ] ; 116652a38012Sejakowatz} 116752a38012Sejakowatz 11687d7f280eSIngo Weinholdrule UsePrivateObjectHeaders 11697d7f280eSIngo Weinhold{ 11709b60a208SIngo Weinhold # UsePrivateObjectHeaders <sources> : <group list> [ : <objects> ] ; 11717d7f280eSIngo Weinhold # 11727d7f280eSIngo Weinhold # Adds the private C header dirs given by <group list> to the header search 11739b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 11749b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 11757d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 11767d7f280eSIngo Weinhold 11779b60a208SIngo Weinhold SourceHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; 117852a38012Sejakowatz} 117952a38012Sejakowatz 118052a38012Sejakowatzrule UseHeaders 118152a38012Sejakowatz{ 11827d7f280eSIngo Weinhold # UseHeaders <headers> ; 118352a38012Sejakowatz # 118452a38012Sejakowatz # Adds the C header dirs <headers> to the header search 11857d7f280eSIngo Weinhold # dirs of the subdirectory. 11867d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 118752a38012Sejakowatz 11887d7f280eSIngo Weinhold local header ; 11897d7f280eSIngo Weinhold for header in $(1) { 119052a38012Sejakowatz SubDirHdrs $(header) ; 119152a38012Sejakowatz } 119252a38012Sejakowatz} 119352a38012Sejakowatz 119452a38012Sejakowatzrule UseCppUnitHeaders 119552a38012Sejakowatz{ 11967d7f280eSIngo Weinhold SubDirHdrs [ FDirName $(OBOS_TOP) headers tools cppunit ] ; 119752a38012Sejakowatz} 119852a38012Sejakowatz 1199be5af1baSIngo Weinholdrule UseCppUnitObjectHeaders 1200be5af1baSIngo Weinhold{ 12019b60a208SIngo Weinhold # UseCppUnitObjectHeaders <sources> [ : <objects> ] ; 12029b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers tools cppunit ] : $(2) ; 1203be5af1baSIngo Weinhold} 1204be5af1baSIngo Weinhold 120552a38012Sejakowatzrule UseArchHeaders 120652a38012Sejakowatz{ 12077d7f280eSIngo Weinhold # usage: UseArchHeaders <arch> ; 12087d7f280eSIngo Weinhold # 120952a38012Sejakowatz # <arch> specifies the architecture (e.g. x86). 12107d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 12117d7f280eSIngo Weinhold 12127d7f280eSIngo Weinhold local headers = [ ArchHeaders $(1) ] ; 121352a38012Sejakowatz local opt = -D$(OBOS_TARGET_DEFINE) ; 1214c633961aSIngo Weinhold 121552a38012Sejakowatz SubDirCcFlags $(opt) ; 121652a38012Sejakowatz SubDirC++Flags $(opt) ; 1217089a0629Sbeveloper HDRS += $(headers) ; 1218c633961aSIngo Weinhold} 1219c633961aSIngo Weinhold 12207d7f280eSIngo Weinholdrule UseArchObjectHeaders 12217d7f280eSIngo Weinhold{ 12229b60a208SIngo Weinhold # usage: UseArchObjectHeaders <sources> : <arch> : [ <objects> ] ; 12237d7f280eSIngo Weinhold # 12247d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 12257d7f280eSIngo Weinhold # <sources_or_objects> Source or object files. 12267d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 12277d7f280eSIngo Weinhold 12289b60a208SIngo Weinhold local sources = $(1) ; 12297d7f280eSIngo Weinhold local headers = [ ArchHeaders $(2) ] ; 12309b60a208SIngo Weinhold local objects = $(3) ; 12319b60a208SIngo Weinhold local targets ; 12329b60a208SIngo Weinhold if $(objects) { 12339b60a208SIngo Weinhold targets = $(objects) ; 12349b60a208SIngo Weinhold } else { 1235081debe8SIngo Weinhold targets = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 12369b60a208SIngo Weinhold } 12377d7f280eSIngo Weinhold local opt = -D$(OBOS_TARGET_DEFINE) ; 12387d7f280eSIngo Weinhold 12397d7f280eSIngo Weinhold ObjectCcFlags $(targets) : $(opt) ; 12407d7f280eSIngo Weinhold ObjectC++Flags $(targets) : $(opt) ; 12419b60a208SIngo Weinhold SourceHdrs $(sources) : $(headers) : $(objects) ; 124252a38012Sejakowatz} 124352a38012Sejakowatz 1244d25a77b4SIngo Weinholdrule UsePosixHeaders 1245d25a77b4SIngo Weinhold{ 1246a6c008e1Sbeveloper # XXX changed to do nothing 1247d25a77b4SIngo Weinhold} 1248d25a77b4SIngo Weinhold 1249d25a77b4SIngo Weinholdrule UsePosixObjectHeaders 1250d25a77b4SIngo Weinhold{ 12519b60a208SIngo Weinhold # UsePosixObjectHeaders <sources> [ : <objects> ] ; 1252d25a77b4SIngo Weinhold # 1253d25a77b4SIngo Weinhold # Adds the POSIX header dir to the header search 12549b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 12559b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 1256d25a77b4SIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 1257d25a77b4SIngo Weinhold 12589b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers posix ] : $(2) ; 1259d25a77b4SIngo Weinhold} 1260d25a77b4SIngo Weinhold 12610f434a0aSDarkWyrmrule UseLibraryHeaders 12620f434a0aSDarkWyrm{ 12630f434a0aSDarkWyrm # UseLibraryHeaders <group list> ; 12640f434a0aSDarkWyrm # 12650f434a0aSDarkWyrm # Adds the library header dirs given by <group list> to the header search 12660f434a0aSDarkWyrm # dirs of the subdirectory. 12670f434a0aSDarkWyrm # NOTE: This rule must be invoked *before* the rule that builds the objects. 12680f434a0aSDarkWyrm 12690f434a0aSDarkWyrm UseHeaders [ LibraryHeaders $(1) ] ; 12700f434a0aSDarkWyrm} 12710f434a0aSDarkWyrm 12723b9eae39SIngo Weinholdrule SplitPath 12733b9eae39SIngo Weinhold{ 12743b9eae39SIngo Weinhold # SplitPath <path> ; 12753b9eae39SIngo Weinhold # Decomposes a path into its components. 12763b9eae39SIngo Weinhold local path = $(1:G=) ; 12773b9eae39SIngo Weinhold local components ; 12788c27f58dSIngo Weinhold # $(path:D) for "/" is "/". Therefore the second condition. 12798c27f58dSIngo Weinhold while $(path:D) && $(path:D) != $(path) 12803b9eae39SIngo Weinhold { 12813b9eae39SIngo Weinhold # Note: $(path:B) returns "." for "..", but $(path:D=) is fine. 12823b9eae39SIngo Weinhold components = $(path:D=) $(components) ; 12833b9eae39SIngo Weinhold path = $(path:D) ; 12843b9eae39SIngo Weinhold } 12853b9eae39SIngo Weinhold components = $(path) $(components) ; 12863b9eae39SIngo Weinhold return $(components) ; 12873b9eae39SIngo Weinhold} 12883b9eae39SIngo Weinhold 12899fc6b2e1SIngo Weinholdrule PrependObjectHdrs 12909fc6b2e1SIngo Weinhold{ 12919fc6b2e1SIngo Weinhold # PrependObjectHdrs <objects_or_sources> : <dirs> ; 12929fc6b2e1SIngo Weinhold # Prepends <dirs> to the list of header search dirs of the objects 12939fc6b2e1SIngo Weinhold # specified by <objects_or_sources>. The HDRS variable will not be 12949fc6b2e1SIngo Weinhold # changed, only CCHDRS. 12959fc6b2e1SIngo Weinhold # Note: A subsequent ObjectHdrs invocation will therefore undo the 12969fc6b2e1SIngo Weinhold # effect of this rule. 12979fc6b2e1SIngo Weinhold # NOTE: This is a hack. 12989fc6b2e1SIngo Weinhold 12999fc6b2e1SIngo Weinhold local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 13009fc6b2e1SIngo Weinhold local dirs = $(2) ; 13019fc6b2e1SIngo Weinhold for object in $(objects) { 13029fc6b2e1SIngo Weinhold # Don't change HDRS to avoid screwing up the header scanning. 13039fc6b2e1SIngo Weinhold PREPENDED_HDRS on $(object) 13049fc6b2e1SIngo Weinhold = $(dirs) [ on $(object) return $(PREPENDED_HDRS) ] ; 13059fc6b2e1SIngo Weinhold CCHDRS on $(object) 13069fc6b2e1SIngo Weinhold = [ FIncludes [ on $(object) return $(PREPENDED_HDRS) $(HDRS) ] ] ; 13079fc6b2e1SIngo Weinhold } 13089fc6b2e1SIngo Weinhold} 13099fc6b2e1SIngo Weinhold 13103b9eae39SIngo Weinholdrule SymLink 13113b9eae39SIngo Weinhold{ 13127669b69fSIngo Weinhold # SymLink <target> : <source> : <makeDefaultDependencies> ; 13133b9eae39SIngo Weinhold # Links <target> to <source>. 13143b9eae39SIngo Weinhold # <source> is the exact link contents. No binding is done. 13157669b69fSIngo Weinhold # <makeDefaultDependencies> If true, <target> will be made a dependency 13167669b69fSIngo Weinhold # of the `all' pseudo target, i.e. it will be made by default, and removed 13177669b69fSIngo Weinhold # on `jam clean'. 13187669b69fSIngo Weinhold 13197669b69fSIngo Weinhold local target = $(1) ; 13207669b69fSIngo Weinhold local source = $(2) ; 13217669b69fSIngo Weinhold local makeDefaultDependencies = $(3) ; 13227669b69fSIngo Weinhold if ! $(makeDefaultDependencies) { 13237669b69fSIngo Weinhold makeDefaultDependencies = true ; 13247669b69fSIngo Weinhold } 13257669b69fSIngo Weinhold LINKCONTENTS on $(target) = $(source) ; 13267669b69fSIngo Weinhold SymLink1 $(target) ; 13277669b69fSIngo Weinhold if $(makeDefaultDependencies) = true { 13287669b69fSIngo Weinhold LocalDepends files : $(target) ; 13297669b69fSIngo Weinhold LocalClean clean : $(target) ; 13307669b69fSIngo Weinhold } 13313b9eae39SIngo Weinhold} 13323b9eae39SIngo Weinhold 13333b9eae39SIngo Weinholdactions SymLink1 13343b9eae39SIngo Weinhold{ 13350931b8f9SIngo Weinhold $(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)" 13360931b8f9SIngo Weinhold} 13370931b8f9SIngo Weinhold 13380931b8f9SIngo Weinholdrule RelSymLink 13390931b8f9SIngo Weinhold{ 13407669b69fSIngo Weinhold # RelSymLink <link> : <link target> : <makeDefaultDependencies> ; 13410931b8f9SIngo Weinhold # Creates a relative symbolic link from <link> to <link target>. 13420931b8f9SIngo Weinhold # <link> and <link target> can be usual targets. They may have a grist 13430931b8f9SIngo Weinhold # and don't need to have any dirname. Their LOCATE variables are used to 13440931b8f9SIngo Weinhold # find their locations. 13457669b69fSIngo Weinhold # <makeDefaultDependencies> If true (which is the default), <link> will be 13467669b69fSIngo Weinhold # made a dependency of the `files' pseudo target, i.e. it will be made by 13477669b69fSIngo Weinhold # default, and removed on `jam clean'. 13480931b8f9SIngo Weinhold 13490931b8f9SIngo Weinhold local target = $(1) ; 13500931b8f9SIngo Weinhold local source = $(2) ; 13517669b69fSIngo Weinhold local makeDefaultDependencies = $(3) ; 13520931b8f9SIngo Weinhold local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ; 13530931b8f9SIngo Weinhold local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ; 13540931b8f9SIngo Weinhold local sourcePath = $(source:G=) ; 13550931b8f9SIngo Weinhold sourcePath = $(sourcePath:D=$(sourceDir)) ; 13560931b8f9SIngo Weinhold local targetDirComponents = [ SplitPath $(targetDir) ] ; 13570931b8f9SIngo Weinhold local sourceComponents = [ SplitPath $(sourcePath) ] ; 13580931b8f9SIngo Weinhold 13590931b8f9SIngo Weinhold SymLink $(target) 13607669b69fSIngo Weinhold : [ FRelPath $(targetDirComponents) : $(sourceComponents) ] 13617669b69fSIngo Weinhold : $(makeDefaultDependencies) ; 13620931b8f9SIngo Weinhold NOUPDATE $(target) ; 13639eea4522SIngo Weinhold Depends $(target) : $(source) ; 13643b9eae39SIngo Weinhold} 13653b9eae39SIngo Weinhold 1366d391d2ebSIngo Weinholdrule AbsSymLink 1367d391d2ebSIngo Weinhold{ 13687bc56df1SIngo Weinhold # AbsSymLink <link> : <link target> : <link dir> 13697669b69fSIngo Weinhold # : <makeDefaultDependencies> ; 1370d391d2ebSIngo Weinhold # Creates an absolute symbolic link from <link> to <link target>. 1371d391d2ebSIngo Weinhold # <link> and <link target> must be usual targets. If <link dir> is 1372d391d2ebSIngo Weinhold # given, then it is set as LOCATE directory on <link>. 13737669b69fSIngo Weinhold # <makeDefaultDependencies> If true (which is the default), <link> will be 13747669b69fSIngo Weinhold # made a dependency of the `files' pseudo target, i.e. it will be made by 13757669b69fSIngo Weinhold # default, and removed on `jam clean'. 1376d391d2ebSIngo Weinhold 13777669b69fSIngo Weinhold local makeDefaultDependencies = $(4) ; 13787669b69fSIngo Weinhold if ! $(makeDefaultDependencies) { 13797669b69fSIngo Weinhold makeDefaultDependencies = true ; 13807669b69fSIngo Weinhold } 13817669b69fSIngo Weinhold 1382d391d2ebSIngo Weinhold Depends $(1) : $(2) ; 1383d391d2ebSIngo Weinhold if $(3) { 1384d391d2ebSIngo Weinhold MakeLocate $(1) : $(3) ; 1385d391d2ebSIngo Weinhold } 1386d391d2ebSIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 13877669b69fSIngo Weinhold if $(makeDefaultDependencies) = true { 13887669b69fSIngo Weinhold LocalDepends files : $(1) ; 1389d391d2ebSIngo Weinhold LocalClean clean : $(1) ; 1390d391d2ebSIngo Weinhold } 13917669b69fSIngo Weinhold} 1392d391d2ebSIngo Weinhold 1393d391d2ebSIngo Weinholdactions AbsSymLink 1394d391d2ebSIngo Weinhold{ 1395d391d2ebSIngo Weinhold target="$(2)" 1396d391d2ebSIngo Weinhold case "$target" in 1397d391d2ebSIngo Weinhold /*) ;; 1398d391d2ebSIngo Weinhold *) target=`pwd`/"$target";; 1399d391d2ebSIngo Weinhold esac 1400d391d2ebSIngo Weinhold $(RM) "$(1)" && $(LN) -s "$target" "$(1)" 1401d391d2ebSIngo Weinhold} 1402d391d2ebSIngo Weinhold 14037bc56df1SIngo Weinholdrule OBOSInstall 14047bc56df1SIngo Weinhold{ 14057bc56df1SIngo Weinhold # Usage: OBOSInstall <[ install [ and uninstall ] pseudotarget ]> 14067bc56df1SIngo Weinhold # : <directory> : <sources to install> 14077bc56df1SIngo Weinhold # : [ <installgrist> ] : [ <install rule> ] ; 14087bc56df1SIngo Weinhold local install = $(1[1]) ; 14097bc56df1SIngo Weinhold install ?= install ; 14107bc56df1SIngo Weinhold local uninstall = $(1[2]) ; 14117bc56df1SIngo Weinhold uninstall ?= un$(install) ; 14127bc56df1SIngo Weinhold local dir = $(2) ; 14137bc56df1SIngo Weinhold local sources = $(3) ; 14147bc56df1SIngo Weinhold local installgrist = $(4) ; 14157bc56df1SIngo Weinhold installgrist ?= $(INSTALLGRIST) ; 14167bc56df1SIngo Weinhold local installRule = $(5) ; 14177bc56df1SIngo Weinhold installRule ?= Install ; 14187bc56df1SIngo Weinhold local targets = $(sources:G=$(installgrist)) ; 14197bc56df1SIngo Weinhold 1420bacf6872Sshatty NotFile $(install) ; 1421bacf6872Sshatty NotFile $(uninstall) ; 14227bc56df1SIngo Weinhold Depends $(install) : $(targets) ; 14237bc56df1SIngo Weinhold Clean $(uninstall) : $(targets) ; 14247bc56df1SIngo Weinhold 14257bc56df1SIngo Weinhold SEARCH on $(sources) += $(SEARCH_SOURCE) ; 14267bc56df1SIngo Weinhold MakeLocate $(targets) : $(dir) ; 14277bc56df1SIngo Weinhold 14287bc56df1SIngo Weinhold local source ; 14297bc56df1SIngo Weinhold for source in $(sources) { 14307bc56df1SIngo Weinhold local target = $(source:G=$(installgrist)) ; 14317bc56df1SIngo Weinhold 14327bc56df1SIngo Weinhold Depends $(target) : $(source) ; 14337bc56df1SIngo Weinhold $(installRule) $(target) : $(source) ; 14347bc56df1SIngo Weinhold 14357bc56df1SIngo Weinhold if [ on $(target) return $(MODE) ] { 14367bc56df1SIngo Weinhold Chmod $(target) ; 14377bc56df1SIngo Weinhold } 14387bc56df1SIngo Weinhold 14397bc56df1SIngo Weinhold if $(OWNER) && $(CHOWN) { 14407bc56df1SIngo Weinhold Chown $(target) ; 14417bc56df1SIngo Weinhold OWNER on $(target) = $(OWNER) ; 14427bc56df1SIngo Weinhold } 14437bc56df1SIngo Weinhold 14447bc56df1SIngo Weinhold if $(GROUP) && $(CHGRP) { 14457bc56df1SIngo Weinhold Chgrp $(target) ; 14467bc56df1SIngo Weinhold GROUP on $(target) = $(GROUP) ; 14477bc56df1SIngo Weinhold } 14487bc56df1SIngo Weinhold } 14497bc56df1SIngo Weinhold} 14507bc56df1SIngo Weinhold 14517669b69fSIngo Weinholdrule InstallAbsSymLinkAdapter 14527669b69fSIngo Weinhold{ 14537669b69fSIngo Weinhold # InstallAbsSymLinkAdapter <link> : <link target> 14547669b69fSIngo Weinhold if ! [ on $(2) return $(TARGET) ] { 14557669b69fSIngo Weinhold TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; 14567669b69fSIngo Weinhold } 14577669b69fSIngo Weinhold AbsSymLink $(1) : $(2) : : false ; 14587669b69fSIngo Weinhold} 14597669b69fSIngo Weinhold 14607bc56df1SIngo Weinholdrule OBOSInstallAbsSymLink 14617bc56df1SIngo Weinhold{ 14627bc56df1SIngo Weinhold # Usage: OBOSInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]> 14637bc56df1SIngo Weinhold # : <directory> : <sources to install> 14647bc56df1SIngo Weinhold # : [ <installgrist> ] ; 14657669b69fSIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallAbsSymLinkAdapter ; 14667bc56df1SIngo Weinhold} 14677bc56df1SIngo Weinhold 14687bc56df1SIngo Weinholdrule InstallRelSymLinkAdapter 14697bc56df1SIngo Weinhold{ 14707bc56df1SIngo Weinhold # InstallRelSymLinkAdapter <link> : <link target> 14717bc56df1SIngo Weinhold if ! [ on $(2) return $(TARGET) ] { 14727bc56df1SIngo Weinhold TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; 14737bc56df1SIngo Weinhold } 14747669b69fSIngo Weinhold RelSymLink $(1) : $(2) : false ; 14757bc56df1SIngo Weinhold} 14767bc56df1SIngo Weinhold 14777bc56df1SIngo Weinholdrule OBOSInstallRelSymLink 14787bc56df1SIngo Weinhold{ 14797bc56df1SIngo Weinhold # Usage: OBOSInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]> 14807bc56df1SIngo Weinhold # : <directory> : <sources to install> 14817bc56df1SIngo Weinhold # : [ <installgrist> ] ; 14827bc56df1SIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ; 14837bc56df1SIngo Weinhold} 14847bc56df1SIngo Weinhold 14857bc56df1SIngo Weinhold 148652a38012Sejakowatz#------------------------------------------------------------------------------- 148752a38012Sejakowatz# Low-level OBOS utility rules 148852a38012Sejakowatz#------------------------------------------------------------------------------- 148979b49834SIngo Weinholdrule FObjectsDir 149079b49834SIngo Weinhold{ 1491121af366SIngo Weinhold # FObjectsDir <subdir tokens> 1492121af366SIngo Weinhold # 1493121af366SIngo Weinhold # Returns the output directory for object files the specified 1494121af366SIngo Weinhold # subdirectory. 1495121af366SIngo Weinhold # 1496121af366SIngo Weinhold # <subdir tokens>: The tokens of the subdir relative to the top. 1497121af366SIngo Weinhold # 1498121af366SIngo Weinhold 1499121af366SIngo Weinhold return [ FDirName $(OBOS_OBJECT_TARGET) $(1[2-]) ] ; 1500121af366SIngo Weinhold} 1501121af366SIngo Weinhold 1502121af366SIngo Weinholdrule FCurrentObjectsDir 1503121af366SIngo Weinhold{ 1504121af366SIngo Weinhold # FCurrentObjectsDir 150579b49834SIngo Weinhold # 150679b49834SIngo Weinhold # Returns the output directory for object files for the current 150779b49834SIngo Weinhold # subdirectory. 150879b49834SIngo Weinhold 1509121af366SIngo Weinhold return [ FObjectsDir $(SUBDIR_TOKENS) ] ; 151079b49834SIngo Weinhold} 151179b49834SIngo Weinhold 151252a38012Sejakowatzrule SetupObjectsDir 151352a38012Sejakowatz{ 1514121af366SIngo Weinhold LOCATE_TARGET = [ FCurrentObjectsDir ] ; 15158d3308d9SIngo Weinhold LOCATE_SOURCE = $(LOCATE_TARGET) ; 15168d3308d9SIngo Weinhold SEARCH_SOURCE = [ Filter $(SEARCH_SOURCE) : $(LOCATE_TARGET) ] 15178d3308d9SIngo Weinhold $(LOCATE_TARGET) ; 151852a38012Sejakowatz} 151952a38012Sejakowatz 152052a38012Sejakowatz#------------------------------------------------------------------------------- 152152a38012Sejakowatz# Link rule/action are overwritten as they don't handle linking files who's name 152252a38012Sejakowatz# contain spaces very well. Also adds resources and version to executable. 152352a38012Sejakowatz#------------------------------------------------------------------------------- 152452a38012Sejakowatzrule Link 152552a38012Sejakowatz{ 152652a38012Sejakowatz # Note: RESFILES must be set before invocation. 152752a38012Sejakowatz MODE on $(<) = $(EXEMODE) ; 152852a38012Sejakowatz on $(1) XRes $(1) : $(RESFILES) ; 152952a38012Sejakowatz Chmod $(<) ; 153052a38012Sejakowatz SetType $(1) ; 153152a38012Sejakowatz MimeSet $(1) ; 15321419ae2bSshatty SetVersion $(1) ; 153352a38012Sejakowatz} 153452a38012Sejakowatz 153552a38012Sejakowatzactions Link bind NEEDLIBS 153652a38012Sejakowatz{ 15371eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(2)" "$(NEEDLIBS)" $(LINKLIBS) ; 153852a38012Sejakowatz} 153952a38012Sejakowatz 15408d3308d9SIngo Weinholdrule LexC++ 15418d3308d9SIngo Weinhold{ 15428d3308d9SIngo Weinhold Depends $(1) : $(2) ; 15438d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_SOURCE) ; 15448d3308d9SIngo Weinhold LocalClean clean : $(1) ; 15458d3308d9SIngo Weinhold} 15468d3308d9SIngo Weinhold 15478d3308d9SIngo Weinholdactions LexC++ 15488d3308d9SIngo Weinhold{ 15498d3308d9SIngo Weinhold $(LEX) -o$(1) $(2) 15508d3308d9SIngo Weinhold} 15518d3308d9SIngo Weinhold 15528d3308d9SIngo Weinholdrule Bison 15538d3308d9SIngo Weinhold{ 15548d3308d9SIngo Weinhold local _h ; 15558d3308d9SIngo Weinhold 1556cec8c8b5SJérôme Duval _h = $(1:S=.hpp) ; 15578d3308d9SIngo Weinhold 15588d3308d9SIngo Weinhold MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ; 15598d3308d9SIngo Weinhold 15608d3308d9SIngo Weinhold Depends $(<) $(_h) : $(>) ; 15618d3308d9SIngo Weinhold Bison1 $(<) $(_h) : $(>) ; 15628d3308d9SIngo Weinhold LocalClean clean : $(<) $(_h) ; 15638d3308d9SIngo Weinhold 15648d3308d9SIngo Weinhold # make sure someone includes $(_h) else it will be 15658d3308d9SIngo Weinhold # a deadly independent target 15668d3308d9SIngo Weinhold 15678d3308d9SIngo Weinhold Includes $(<) : $(_h) ; 15688d3308d9SIngo Weinhold} 15698d3308d9SIngo Weinhold 15708d3308d9SIngo Weinholdactions Bison1 15718d3308d9SIngo Weinhold{ 15728d3308d9SIngo Weinhold bison $(YACCFLAGS) -o $(1[1]) $(2) 1573cec8c8b5SJérôme Duval [ -f $(1[1]).h ] && mv $(1[1]).h $(1[2]) || true 15748d3308d9SIngo Weinhold} 15758d3308d9SIngo Weinhold 1576705fc998SAxel Dörflerrule UnarchiveObjects 1577705fc998SAxel Dörfler{ 1578705fc998SAxel Dörfler # UnarchiveObjects <target objects> : <static object> 1579705fc998SAxel Dörfler 1580705fc998SAxel Dörfler MakeLocate $(1) : $(LOCATE_TARGET) ; 1581705fc998SAxel Dörfler Depends $(2) : $(1) ; 1582705fc998SAxel Dörfler SEARCH on $(2) = $(SEARCH_SOURCE) ; 1583705fc998SAxel Dörfler} 1584705fc998SAxel Dörfler 1585705fc998SAxel Dörfleractions UnarchiveObjects 1586705fc998SAxel Dörfler{ 15873c71865aSAxel Dörfler cd $(1[1]:D) 15883c71865aSAxel Dörfler ar -x "$(2)" $(1:B).o 1589705fc998SAxel Dörfler cd - 1590705fc998SAxel Dörfler} 1591705fc998SAxel Dörfler 159252a38012Sejakowatz# BeOS specific rules 159352a38012Sejakowatz 159452a38012Sejakowatzrule XRes 159552a38012Sejakowatz{ 159652a38012Sejakowatz # XRes <target> : <resource files> 159752a38012Sejakowatz if $(2) 159852a38012Sejakowatz { 15999eea4522SIngo Weinhold Depends $(1) : $(2) ; 160052a38012Sejakowatz XRes1 $(1) : $(2) ; 160152a38012Sejakowatz } 160252a38012Sejakowatz} 160352a38012Sejakowatz 160452a38012Sejakowatzrule XRes1 { } 160552a38012Sejakowatz 160652a38012Sejakowatzrule SetVersion 160752a38012Sejakowatz{ 160852a38012Sejakowatz # SetVersion <target> 160952a38012Sejakowatz} 161052a38012Sejakowatz 161152a38012Sejakowatzrule SetType 161252a38012Sejakowatz{ 161352a38012Sejakowatz # SetType <target> 161452a38012Sejakowatz} 161552a38012Sejakowatz 161652a38012Sejakowatzrule MimeSet 161752a38012Sejakowatz{ 161852a38012Sejakowatz # SetType <target> 161952a38012Sejakowatz} 162052a38012Sejakowatz 162152a38012Sejakowatz 162252a38012Sejakowatzif $(OS) = BEOS 162352a38012Sejakowatz{ 162452a38012Sejakowatz 162552a38012Sejakowatzactions XRes1 162652a38012Sejakowatz{ 16270931b8f9SIngo Weinhold xres -o "$(1)" "$(2)" ; 162852a38012Sejakowatz} 162952a38012Sejakowatz 163052a38012Sejakowatzactions SetVersion 163152a38012Sejakowatz{ 163252a38012Sejakowatz setversion "$(1)" -system $(OBOS_BUILD_VERSION) -short "$(OBOS_BUILD_DESCRIPTION)" ; 163352a38012Sejakowatz} 163452a38012Sejakowatz 163552a38012Sejakowatzactions SetType 163652a38012Sejakowatz{ 163752a38012Sejakowatz settype -t $(OBOS_TARGET_TYPE) "$(1)" ; 163852a38012Sejakowatz} 163952a38012Sejakowatz 164052a38012Sejakowatzactions MimeSet 164152a38012Sejakowatz{ 164252a38012Sejakowatz mimeset -f "$(1)" ; 164352a38012Sejakowatz} 164452a38012Sejakowatz 164552a38012Sejakowatz} # if BEOS 164652a38012Sejakowatz 164752a38012Sejakowatz 164852a38012Sejakowatzrule assemble 164952a38012Sejakowatz{ 165094782cf7SIngo Weinhold Depends $(<) : $(>) ; 165194782cf7SIngo Weinhold ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ; 165294782cf7SIngo Weinhold ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ; 165352a38012Sejakowatz} 165452a38012Sejakowatz 165552a38012Sejakowatzactions assemble 165652a38012Sejakowatz{ 1657a8687de4SAxel Dörfler $(CC) -c "$(2)" -O2 $(ASFLAGS) -D_ASSEMBLER $(KERNEL_CCFLAGS) $(ASHDRS) -o "$(1)" ; 165852a38012Sejakowatz} 165952a38012Sejakowatz 16600931b8f9SIngo Weinhold# Overridden to allow spaces in file names. 16610931b8f9SIngo Weinholdactions Chmod1 16620931b8f9SIngo Weinhold{ 16630931b8f9SIngo Weinhold $(CHMOD) "$(MODE)" "$(1)" 16640931b8f9SIngo Weinhold} 16650931b8f9SIngo Weinhold 16666991af8cSIngo Weinhold# Overridden to allow spaces in file names. 16676991af8cSIngo Weinholdactions piecemeal together existing Clean 16686991af8cSIngo Weinhold{ 16696991af8cSIngo Weinhold $(RM) "$(>)" 16706991af8cSIngo Weinhold} 16716991af8cSIngo Weinhold 167208125d07SIngo Weinholdrule ObjectReference 167308125d07SIngo Weinhold{ 167408125d07SIngo Weinhold # ObjectReference <reference object> : <source object> 167508125d07SIngo Weinhold # Makes <reference object> refer to the same file as <source object>. 167608125d07SIngo Weinhold # The filenames must of course be identical. 167708125d07SIngo Weinhold # <source object> must have already been LOCATEd. 167808125d07SIngo Weinhold 167908125d07SIngo Weinhold local ref = $(1) ; 168008125d07SIngo Weinhold local source = $(2) ; 168108125d07SIngo Weinhold if $(ref) != $(source) { 16829eea4522SIngo Weinhold Depends $(ref) : $(source) ; 168321df5945SIngo Weinhold LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ; 168408125d07SIngo Weinhold } 168508125d07SIngo Weinhold} 168608125d07SIngo Weinhold 168708125d07SIngo Weinholdrule ObjectReferences 168808125d07SIngo Weinhold{ 168908125d07SIngo Weinhold # ObjectReferences <source objects> 169008125d07SIngo Weinhold # Creates local references to <source objects>, i.e. identifiers with the 169108125d07SIngo Weinhold # current grist referring to the same files. <source objects> must have 169208125d07SIngo Weinhold # already been LOCATEd. 169308125d07SIngo Weinhold 169408125d07SIngo Weinhold local source ; 169508125d07SIngo Weinhold for source in $(1) { 169608125d07SIngo Weinhold ObjectReference [ FGristFiles $(source) ] : $(source) ; 169708125d07SIngo Weinhold } 169808125d07SIngo Weinhold} 169908125d07SIngo Weinhold 17009fc6b2e1SIngo Weinholdrule Filter 17019fc6b2e1SIngo Weinhold{ 17029fc6b2e1SIngo Weinhold # Filter <list> : <excludes> ; 17039fc6b2e1SIngo Weinhold # Removes all occurrences of <excludes> in <list>. 17049fc6b2e1SIngo Weinhold 17059fc6b2e1SIngo Weinhold local list = $(1) ; 17069fc6b2e1SIngo Weinhold local excludes = $(2) ; 17079fc6b2e1SIngo Weinhold local newList ; 17089fc6b2e1SIngo Weinhold local item ; 17099fc6b2e1SIngo Weinhold for item in $(list) { 17109fc6b2e1SIngo Weinhold local skip ; 17119fc6b2e1SIngo Weinhold local exclude ; 17129fc6b2e1SIngo Weinhold for exclude in $(excludes) { 17139fc6b2e1SIngo Weinhold if $(item) = $(exclude) { 17149fc6b2e1SIngo Weinhold skip = true ; 17159fc6b2e1SIngo Weinhold } 17169fc6b2e1SIngo Weinhold } 17179fc6b2e1SIngo Weinhold if ! $(skip) { 1718dd9f8062SIngo Weinhold newList += $(item) ; 17199fc6b2e1SIngo Weinhold } 17209fc6b2e1SIngo Weinhold } 17219fc6b2e1SIngo Weinhold return $(newList) ; 17229fc6b2e1SIngo Weinhold} 17239fc6b2e1SIngo Weinhold 17240931b8f9SIngo Weinhold 172552a38012Sejakowatz## Kernel stuff! 172652a38012Sejakowatz 172752a38012Sejakowatzrule SetupKernel 172852a38012Sejakowatz{ 172952a38012Sejakowatz # Usage SetupKernel <sources_or_objects> : <extra_cc_flags>; 173094a49b21SIngo Weinhold # 173194a49b21SIngo Weinhold # <sources_or_objects> - Ideally sources, otherwise HDRSEARCH can not be 173294a49b21SIngo Weinhold # set for the sources and the sources some header 173394a49b21SIngo Weinhold # dependencies might be missing. 173452a38012Sejakowatz 173594a49b21SIngo Weinhold local sources = [ FGristFiles $(1) ] ; 173694a49b21SIngo Weinhold local _objs = $(sources:S=$(SUFOBJ)) ; 173752a38012Sejakowatz 173828d2a30eSDaniel Reinhold #Setup Kernel header directories 173999b8dab3SAxel Dörfler local public_kernel_includes = add-ons/file_system add-ons/graphics app device drivers kernel storage support ; 1740c0e501e0SIngo Weinhold local private_kernel_includes = $(DOT) kernel libroot kernel/boot/platform/$(OBOS_BOOT_PLATFORM) ; 1741a6c008e1Sbeveloper # Use posix headers directory 1742c0e501e0SIngo Weinhold local headers = [ FDirName $(OBOS_TOP) headers posix ] ; 1743a6c008e1Sbeveloper # Use public OS header directories 1744c0e501e0SIngo Weinhold headers += [ PublicHeaders $(public_kernel_includes) ] ; 1745089a0629Sbeveloper # Use private directories 1746c0e501e0SIngo Weinhold headers += [ PrivateHeaders $(private_kernel_includes) ] ; 174709c5682dSIngo Weinhold # The platform dependent headers. 1748c0e501e0SIngo Weinhold headers += $(PLATFORM_HEADERS) ; 1749a6c008e1Sbeveloper 175094a49b21SIngo Weinhold SourceHdrs $(sources) : $(headers) ; 175194a49b21SIngo Weinhold UseArchObjectHeaders $(sources) : $(OBOS_ARCH) ; 175252a38012Sejakowatz 1753c0e501e0SIngo Weinhold local object ; 1754c0e501e0SIngo Weinhold for object in $(_objs) { 1755c0e501e0SIngo Weinhold ObjectCcFlags $(object) : $(KERNEL_CCFLAGS) $(2) ; 1756c0e501e0SIngo Weinhold ObjectC++Flags $(object) : $(KERNEL_C++FLAGS) $(2) ; 1757c0e501e0SIngo Weinhold } 175852a38012Sejakowatz} 175952a38012Sejakowatz 176052a38012Sejakowatzrule KernelObjects 176152a38012Sejakowatz{ 1762c0e501e0SIngo Weinhold SetupObjectsDir ; 176352a38012Sejakowatz 176452a38012Sejakowatz Objects $(1) ; 1765c0e501e0SIngo Weinhold 1766c0e501e0SIngo Weinhold SetupKernel $(1) : $(2) ; 176752a38012Sejakowatz} 176852a38012Sejakowatz 176952a38012Sejakowatzrule KernelLd 177052a38012Sejakowatz{ 177180721244SAxel Dörfler # KernelLd <name> : <objs> : <linkerscript> : <args> : <gcc_off> : <config_section> ; 177252a38012Sejakowatz 1773c0e501e0SIngo Weinhold SetupObjectsDir ; 177452a38012Sejakowatz LINK on $(1) = ld ; 177552a38012Sejakowatz 177652a38012Sejakowatz LINKFLAGS on $(1) = $(4) ; 177752a38012Sejakowatz if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 177852a38012Sejakowatz 177952a38012Sejakowatz # Remove any preset LINKLIBS 178052a38012Sejakowatz LINKLIBS on $(1) = ; 178152a38012Sejakowatz 178252a38012Sejakowatz # Show that we depend on the libraries we need 17839eea4522SIngo Weinhold LocalClean clean : $(1) ; 17849eea4522SIngo Weinhold LocalDepends all : $(1) ; 178552a38012Sejakowatz Depends $(1) : $(2) ; 178652a38012Sejakowatz 178752a38012Sejakowatz if $(6) { 178852a38012Sejakowatz for i in $(6) { 17892a83bfb4SIngo Weinhold KernelConfigSection $(i) : elf32 : $(1) ; 179052a38012Sejakowatz } 179152a38012Sejakowatz } 179252a38012Sejakowatz 179352a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 179452a38012Sejakowatz 179509c5682dSIngo Weinhold # Add the platform specific static libs (libgcc.a). 179652a38012Sejakowatz if ! $(5) { 179709c5682dSIngo Weinhold LINKLIBS on $(1) += $(PLATFORM_LINKLIBS) ; 179852a38012Sejakowatz } 1799c0e501e0SIngo Weinhold 1800c0e501e0SIngo Weinhold SetupKernel $(2) ; 180152a38012Sejakowatz} 180252a38012Sejakowatz 180352a38012Sejakowatzactions KernelLd 180452a38012Sejakowatz{ 18051eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ; 180652a38012Sejakowatz} 180752a38012Sejakowatz 1808811903d1SAxel Dörflerrule KernelAddon 1809811903d1SAxel Dörfler{ 1810600203b1SAxel Dörfler # KernelAddon <name> : <relpath> : <sources> : <static-libraries> ; 1811811903d1SAxel Dörfler 1812811903d1SAxel Dörfler local sources = $(3) ; 1813811903d1SAxel Dörfler 1814c0e501e0SIngo Weinhold SetupObjectsDir ; 181594a49b21SIngo Weinhold Addon $(1) : $(2) : $(sources) ; 1816811903d1SAxel Dörfler ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 1817df48dfedSIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic -fno-exceptions ; 1818811903d1SAxel Dörfler LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; 1819600203b1SAxel Dörfler LinkSharedOSLibs $(1) : $(4) $(OBOS_TOP)/objects/$(OBOS_ARCH).$(OBOS_VERSION)/kernel/kernel.so ; 1820811903d1SAxel Dörfler # ToDo this has to be changed! 182194a49b21SIngo Weinhold SetupKernel $(sources) ; 1822811903d1SAxel Dörfler} 1823811903d1SAxel Dörfler 182480721244SAxel Dörflerrule KernelMergeObject 182580721244SAxel Dörfler{ 18262fbd7065SIngo Weinhold # KernelMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ; 18272fbd7065SIngo Weinhold # Compiles source files and merges the object files to an object file. 18282fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 18292fbd7065SIngo Weinhold # <sources>: Sources to be compiled. Grist will be added. 18302fbd7065SIngo Weinhold # <extra CFLAGS>: Additional flags for compilation. 18312fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 18322fbd7065SIngo Weinhold # will be added. 18332fbd7065SIngo Weinhold # 183480721244SAxel Dörfler 1835c0e501e0SIngo Weinhold SetupObjectsDir ; 183680721244SAxel Dörfler 183780721244SAxel Dörfler MakeLocateObjects $(2) ; 183880721244SAxel Dörfler Objects $(2) ; 18392fbd7065SIngo Weinhold MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; 1840c0e501e0SIngo Weinhold 1841c0e501e0SIngo Weinhold SetupKernel $(2) : $(3) ; 184280721244SAxel Dörfler} 184380721244SAxel Dörfler 184452a38012Sejakowatzrule KernelStaticLibrary 184552a38012Sejakowatz{ 184652a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ; 184752a38012Sejakowatz # This is designed to take a set of sources and libraries and create 184852a38012Sejakowatz # a file called lib<name>.a 184952a38012Sejakowatz 1850c0e501e0SIngo Weinhold SetupObjectsDir ; 185152a38012Sejakowatz 185252a38012Sejakowatz MakeLocateObjects $(2) ; 185352a38012Sejakowatz Library $(1) : $(2) ; 1854c0e501e0SIngo Weinhold 1855c0e501e0SIngo Weinhold SetupKernel $(2) : $(3) ; 185652a38012Sejakowatz} 185752a38012Sejakowatz 185852a38012Sejakowatzrule KernelStaticLibraryObjects 185952a38012Sejakowatz{ 186052a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> ; 186152a38012Sejakowatz # This is designed to take a set of sources and libraries and create 186252a38012Sejakowatz # a file called <name> 186352a38012Sejakowatz 1864c0e501e0SIngo Weinhold SetupObjectsDir ; 186552a38012Sejakowatz 186652a38012Sejakowatz # Show that we depend on the libraries we need 18679eea4522SIngo Weinhold LocalClean clean : $(1) ; 18689eea4522SIngo Weinhold LocalDepends all : $(1) ; 186952a38012Sejakowatz Depends $(1) : $(2) ; 187052a38012Sejakowatz 187152a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 1872c0e501e0SIngo Weinhold 1873c0e501e0SIngo Weinhold SetupKernel $(2) ; 187452a38012Sejakowatz} 187552a38012Sejakowatz 187652a38012Sejakowatzactions KernelStaticLibraryObjects 187752a38012Sejakowatz{ 18780931b8f9SIngo Weinhold ar -r "$(1)" "$(2)" ; 187952a38012Sejakowatz} 188052a38012Sejakowatz 18815dc4e1efSIngo Weinholdrule BuildPlatformMain 188252a38012Sejakowatz{ 18835dc4e1efSIngo Weinhold # Usage BuildPlatformMain <target> : <sources> ; 188452a38012Sejakowatz SetupObjectsDir ; 18855dc4e1efSIngo Weinhold SetupDefaultIncludes ; 188652a38012Sejakowatz 18875dc4e1efSIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 18885dc4e1efSIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 18895dc4e1efSIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 18905dc4e1efSIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 18915dc4e1efSIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 189252a38012Sejakowatz 189352a38012Sejakowatz Main $(1) : $(2) ; 18945dc4e1efSIngo Weinhold 18955dc4e1efSIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 18965dc4e1efSIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 18975dc4e1efSIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 189852a38012Sejakowatz} 189952a38012Sejakowatz 19009fcaa61dSIngo Weinholdrule BuildPlatformTest 19019fcaa61dSIngo Weinhold{ 19029fcaa61dSIngo Weinhold # Usage BuildPlatformTest <target> : <sources> ; 19039fcaa61dSIngo Weinhold 19049fcaa61dSIngo Weinhold local target = $(1) ; 19059fcaa61dSIngo Weinhold local sources = $(2) ; 19069fcaa61dSIngo Weinhold 19079fcaa61dSIngo Weinhold BuildPlatformMain $(target) : $(sources) ; 19089fcaa61dSIngo Weinhold local relPath ; 19099fcaa61dSIngo Weinhold if [ FIsPrefix src tests : $(SUBDIR_TOKENS) ] { 19109fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[3-]) ; 19119fcaa61dSIngo Weinhold } else { 19129fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[2-]) ; 19139fcaa61dSIngo Weinhold } 19149fcaa61dSIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 19159fcaa61dSIngo Weinhold} 19169fcaa61dSIngo Weinhold 191752a38012Sejakowatzrule KernelConfigSection 191852a38012Sejakowatz{ 191952a38012Sejakowatz # KernelConfigSection <section> : <type> : <file> ; 19202a83bfb4SIngo Weinhold 19212a83bfb4SIngo Weinhold SECTION_NAMES on $(OBOS_KERNEL_CONFIG) += $(1) ; 19222a83bfb4SIngo Weinhold SECTION_TYPES on $(OBOS_KERNEL_CONFIG) += $(2) ; 19232a83bfb4SIngo Weinhold SECTION_FILES on $(OBOS_KERNEL_CONFIG) += $(3) ; 19242a83bfb4SIngo Weinhold 19252a83bfb4SIngo Weinhold Depends $(OBOS_KERNEL_CONFIG) : $(3) ; 192652a38012Sejakowatz} 192752a38012Sejakowatz 192852a38012Sejakowatzrule WriteKernelConfig 192952a38012Sejakowatz{ 193052a38012Sejakowatz # usage: WriteKernelConfig <target> ; 193152a38012Sejakowatz 19329eea4522SIngo Weinhold LocalDepends files : $(1) ; 193352a38012Sejakowatz 19342a83bfb4SIngo Weinhold MakeLocate $(1) : $(OBOS_OBJECT_TARGET) ; 193552a38012Sejakowatz 19369eea4522SIngo Weinhold LocalClean clean : $(1) ; 193752a38012Sejakowatz} 193852a38012Sejakowatz 19392a83bfb4SIngo Weinholdactions WriteKernelConfig bind SECTION_FILES 194052a38012Sejakowatz{ 19410931b8f9SIngo Weinhold target="$(1)" 19420931b8f9SIngo Weinhold echo "# OpenBeOS Kernel Config File" > "$target" 19430931b8f9SIngo Weinhold echo "# Automatically generated - do not edit!" >> "$target" 19442a83bfb4SIngo Weinhold count=0 19452a83bfb4SIngo Weinhold for section in "$(SECTION_NAMES)" ; do 19462a83bfb4SIngo Weinhold count=`expr $count + 1` 19472a83bfb4SIngo Weinhold eval section$count="$section" 19482a83bfb4SIngo Weinhold done 19492a83bfb4SIngo Weinhold i=1 19502a83bfb4SIngo Weinhold for type in "$(SECTION_TYPES)" ; do 19512a83bfb4SIngo Weinhold eval type$i="$type" 19522a83bfb4SIngo Weinhold i=`expr $i + 1` 19532a83bfb4SIngo Weinhold done 19542a83bfb4SIngo Weinhold i=1 19552a83bfb4SIngo Weinhold for file in "$(SECTION_FILES)" ; do 19562a83bfb4SIngo Weinhold eval file$i="$file" 19572a83bfb4SIngo Weinhold i=`expr $i + 1` 19582a83bfb4SIngo Weinhold done 19592a83bfb4SIngo Weinhold for i in `seq $count` ; do 19602a83bfb4SIngo Weinhold eval section="\$section$i" 19612a83bfb4SIngo Weinhold eval type="\$type$i" 19622a83bfb4SIngo Weinhold eval file="\$file$i" 19630931b8f9SIngo Weinhold echo "" >> "$target" 19642a83bfb4SIngo Weinhold echo "["$section"]" >> "$target" 19652a83bfb4SIngo Weinhold echo "type="$type >> "$target" 19660931b8f9SIngo Weinhold case "$file" in 196752a38012Sejakowatz /*) ;; 19680931b8f9SIngo Weinhold *) file=`pwd`/"$file";; 196952a38012Sejakowatz esac 19702a83bfb4SIngo Weinhold echo "file="$file >> "$target" 197152a38012Sejakowatz done 197252a38012Sejakowatz} 197352a38012Sejakowatz 197452a38012Sejakowatzrule BuildKernel 197552a38012Sejakowatz{ 197652a38012Sejakowatz # Usage BuildKernel <target> : <config_file> ; 19770c0b2cd0SIngo Weinhold local kernel = $(1) ; 19780c0b2cd0SIngo Weinhold local configFile = $(2) ; 19790c0b2cd0SIngo Weinhold local bootmaker = bootmaker ; 198052a38012Sejakowatz 19819eea4522SIngo Weinhold LocalDepends all : $(kernel) ; 19820c0b2cd0SIngo Weinhold Depends $(kernel) : $(configFile) $(bootmaker) ; 19839eea4522SIngo Weinhold LocalClean clean : $(kernel) ; 19840c0b2cd0SIngo Weinhold MakeLocate $(kernel) : $(LOCATE_TARGET) ; 198552a38012Sejakowatz 19860c0b2cd0SIngo Weinhold BOOT_MAKER on $(kernel) = $(bootmaker) ; 198752a38012Sejakowatz} 198852a38012Sejakowatz 19890c0b2cd0SIngo Weinholdactions BuildKernel bind BOOT_MAKER 199052a38012Sejakowatz{ 19910c0b2cd0SIngo Weinhold "$(BOOT_MAKER)" --strip-debug --strip-binary strip "$(2)" -o "$(1)" ; 199252a38012Sejakowatz echo "" 199352a38012Sejakowatz echo "Kernel linked!" 199452a38012Sejakowatz echo "" 199552a38012Sejakowatz} 199652a38012Sejakowatz 199752a38012Sejakowatzrule KernelFloppyImage 199852a38012Sejakowatz{ 199952a38012Sejakowatz # Usage KernelFloppyImage <target> : <kernel> : <bootblock> ; 20000c0b2cd0SIngo Weinhold local floppy = $(1) ; 20010c0b2cd0SIngo Weinhold local kernel = $(2) ; 20020c0b2cd0SIngo Weinhold local bootblock = $(3) ; 20030c0b2cd0SIngo Weinhold local makeflop = makeflop ; 200452a38012Sejakowatz 20059eea4522SIngo Weinhold LocalDepends all : $(floppy) ; 20060c0b2cd0SIngo Weinhold Depends $(floppy) : $(kernel) $(bootblock) $(makeflop) ; 20079eea4522SIngo Weinhold LocalClean clean : $(floppy) ; 20080c0b2cd0SIngo Weinhold MakeLocate $(floppy) : $(OBOS_OBJECT_TARGET) ; 200952a38012Sejakowatz 20100c0b2cd0SIngo Weinhold BOOT_BLOCK on $(floppy) = $(bootblock) ; 20110c0b2cd0SIngo Weinhold MAKE_FLOP on $(floppy) = $(makeflop) ; 201252a38012Sejakowatz} 201352a38012Sejakowatz 201452a38012Sejakowatz# This may be a bit verbose, but I think it's useful to show what's 201552a38012Sejakowatz# going on, at least in this early stage of development. 20160c0b2cd0SIngo Weinholdactions KernelFloppyImage bind BOOT_BLOCK bind MAKE_FLOP 201752a38012Sejakowatz{ 20187378dd7fSAxel Dörfler "$(MAKE_FLOP)" "-p $(shell expr 18 \* 2 \* 512)" "$(BOOT_BLOCK)" "$(2)" "$(1)" ; 20190c0b2cd0SIngo Weinhold 202052a38012Sejakowatz echo "" 202152a38012Sejakowatz echo "*************************************************" 202252a38012Sejakowatz echo "* Kernel build completed! *" 202352a38012Sejakowatz echo "* Boot image for a 1.44M floppy created *" 202452a38012Sejakowatz echo "*************************************************" 202552a38012Sejakowatz echo "" 20260c0b2cd0SIngo Weinhold echo "Floppy image is $(1)" 202752a38012Sejakowatz echo "The following command will write it to a floppy on BeOS" 20280c0b2cd0SIngo Weinhold echo " dd if=$(1) of=/dev/disk/floppy/raw bs=18k" 20290c0b2cd0SIngo Weinhold echo "Alternatively you can run" 20300c0b2cd0SIngo Weinhold echo " ./configure --floppy /dev/disk/floppy/raw" 20310c0b2cd0SIngo Weinhold echo "once and build + write the image subsequently via" 20320c0b2cd0SIngo Weinhold echo " jam installfloppy" 203352a38012Sejakowatz echo "" 203452a38012Sejakowatz} 203552a38012Sejakowatz 20360c0b2cd0SIngo Weinholdrule InstallFloppy 20370c0b2cd0SIngo Weinhold{ 20380c0b2cd0SIngo Weinhold # InstallFloppy <target> : <floppy> 20390c0b2cd0SIngo Weinhold # "dd"s <floppy> to $(FLOPPY_PATH). 20400c0b2cd0SIngo Weinhold 20410c0b2cd0SIngo Weinhold local target = $(1) ; 20420c0b2cd0SIngo Weinhold local floppy = $(2) ; 20430c0b2cd0SIngo Weinhold 20440c0b2cd0SIngo Weinhold NotFile $(target) ; 20450c0b2cd0SIngo Weinhold Always $(target) ; 20460c0b2cd0SIngo Weinhold Depends $(target) : $(floppy) ; 20470c0b2cd0SIngo Weinhold} 20480c0b2cd0SIngo Weinhold 20490c0b2cd0SIngo Weinholdactions InstallFloppy 20500c0b2cd0SIngo Weinhold{ 20510c0b2cd0SIngo Weinhold if [ -z $(FLOPPY_PATH) ] ; then 20520c0b2cd0SIngo Weinhold echo "Can't install floppy: FLOPPY_PATH not set." 20530c0b2cd0SIngo Weinhold echo "run: ./configure --floppy <floppy path>" 20540c0b2cd0SIngo Weinhold echo 20550c0b2cd0SIngo Weinhold exit 0 20560c0b2cd0SIngo Weinhold fi 20570c0b2cd0SIngo Weinhold dd if=$(2) of=$(FLOPPY_PATH) bs=18k 20580c0b2cd0SIngo Weinhold} 205952a38012Sejakowatz 206021df5945SIngo Weinhold#------------------------------------------------------------------------------- 206121df5945SIngo Weinhold# FreeType 2 specific rules and variables 206221df5945SIngo Weinhold#------------------------------------------------------------------------------- 206321df5945SIngo Weinhold 206421df5945SIngo WeinholdFT2_INCLUDE = [ FDirName $(OBOS_TOP) headers libs freetype2 ] ; 206521df5945SIngo WeinholdFT2_SRC = [ FDirName $(OBOS_TOP) src libs freetype2 ] ; 206621df5945SIngo Weinhold 206721df5945SIngo WeinholdFT2_LIB = freetype ; 206821df5945SIngo Weinhold 2069fbd28219SIngo WeinholdFT2_COMPONENTS ?= gzip # support for gzip-compressed files. 2070fbd28219SIngo Weinhold autohint # auto-hinter 2071fbd28219SIngo Weinhold base # base component (public APIs) 2072fbd28219SIngo Weinhold bdf # BDF font driver 2073fbd28219SIngo Weinhold cache # cache sub-system 2074fbd28219SIngo Weinhold cff # CFF/CEF font driver 2075fbd28219SIngo Weinhold cid # Postscript CID-keyed font driver 20769ec866ccSDarkWyrm lzw # LZW routines 2077fbd28219SIngo Weinhold pcf # PCF font driver 2078fbd28219SIngo Weinhold pfr # PFR/TrueDoc font driver 2079fbd28219SIngo Weinhold psaux # Common Postscript routines module 2080fbd28219SIngo Weinhold pshinter # Postscript hinter module 2081fbd28219SIngo Weinhold psnames # Postscript names handling 2082fbd28219SIngo Weinhold raster # Monochrome rasterizer 2083fbd28219SIngo Weinhold smooth # Anti-aliased rasterizer 2084fbd28219SIngo Weinhold sfnt # SFNT-based format support routines 2085fbd28219SIngo Weinhold truetype # TrueType font driver 2086fbd28219SIngo Weinhold type1 # Postscript Type 1 font driver 2087fbd28219SIngo Weinhold type42 # Postscript Type 42 (embedded TrueType) driver 2088fbd28219SIngo Weinhold winfonts # Windows FON/FNT font driver 2089fbd28219SIngo Weinhold ; 2090fbd28219SIngo Weinhold 209121df5945SIngo Weinholdrule UseFreeTypeHeaders 209221df5945SIngo Weinhold{ 209321df5945SIngo Weinhold SubDirHdrs $(FT2_INCLUDE) ; 209421df5945SIngo Weinhold} 209521df5945SIngo Weinhold 209621df5945SIngo Weinholdrule UseFreeTypeObjectHeaders 209721df5945SIngo Weinhold{ 20989b60a208SIngo Weinhold # UseFreeTypeObjectHeaders <sources> [ : <objects> ] ; 20999b60a208SIngo Weinhold SourceHdrs $(1) : $(FT2_INCLUDE) : $(2) ; 210021df5945SIngo Weinhold} 210121df5945SIngo Weinhold 210221df5945SIngo Weinholdrule FT2_SubDir 210321df5945SIngo Weinhold{ 210421df5945SIngo Weinhold # FT2_SubDir <dir> 210521df5945SIngo Weinhold # <dir>: Components of a directory in the original hierarchy. 210621df5945SIngo Weinhold local dir = $(1) ; 210721df5945SIngo Weinhold local topDir ; 210821df5945SIngo Weinhold switch $(dir[1]) 210921df5945SIngo Weinhold { 211021df5945SIngo Weinhold case "include" : topDir = $(FT2_INCLUDE) ; 211121df5945SIngo Weinhold case src : topDir = $(FT2_SRC) ; 211221df5945SIngo Weinhold case * : ECHO "Unknown FreeType2 directory: " $(dir) ; 211321df5945SIngo Weinhold } 211421df5945SIngo Weinhold return [ FDirName $(topDir) $(dir[2-]) ] ; 211521df5945SIngo Weinhold} 211621df5945SIngo Weinhold 211721df5945SIngo Weinholdrule FT2_Library 211821df5945SIngo Weinhold{ 211921df5945SIngo Weinhold # FT2_Library <libname> : <sources> 212021df5945SIngo Weinhold # Builds objects from sources and adds the objects to the list of objects 212121df5945SIngo Weinhold # to be linked into the library. 212221df5945SIngo Weinhold # <libname> The name of the library. 212321df5945SIngo Weinhold # <sources> The sources. 212421df5945SIngo Weinhold 212521df5945SIngo Weinhold local library = lib$(1).so ; 212621df5945SIngo Weinhold local sources = $(2) ; 212728d2a30eSDaniel Reinhold SetupIncludes ; 212821df5945SIngo Weinhold SetupObjectsDir ; 212921df5945SIngo Weinhold MakeLocateObjects $(sources) ; 213021df5945SIngo Weinhold Objects $(sources) ; 213121df5945SIngo Weinhold LIBRARY_OBJECTS on $(library) += [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 213221df5945SIngo Weinhold} 213321df5945SIngo Weinhold 213421df5945SIngo Weinholdrule FT2_LinkLibrary 213521df5945SIngo Weinhold{ 213621df5945SIngo Weinhold # FT2_LinkLibrary <libname> 213721df5945SIngo Weinhold # Links the library from the objects build with FT2_LIBRARY before. 213821df5945SIngo Weinhold 213921df5945SIngo Weinhold local library = lib$(1).so ; 214021df5945SIngo Weinhold local objects = [ on $(library) return $(LIBRARY_OBJECTS) ] ; 214121df5945SIngo Weinhold ObjectReferences $(objects) ; 214221df5945SIngo Weinhold objects = [ FGristFiles $(objects) ] ; 214321df5945SIngo Weinhold SharedLibraryFromObjects $(1) : $(objects) ; 214421df5945SIngo Weinhold} 214521df5945SIngo Weinhold 21469b7a4b5dSshatty#------------------------------------------------------------------------------- 21479b7a4b5dSshatty# Packages for OBOS alpha/beta testers 21489b7a4b5dSshatty#------------------------------------------------------------------------------- 21499b7a4b5dSshatty 21509b7a4b5dSshattyrule Copy 21519b7a4b5dSshatty{ 21525c413522Sshatty Depends $(<) : $(>) ; 21539b7a4b5dSshatty SEARCH on $(>) = $(SEARCH_SOURCE) ; 21549b7a4b5dSshatty} 21559b7a4b5dSshatty 21569b7a4b5dSshattyactions Copy 21579b7a4b5dSshatty{ 215815716fddSPhilippe Houdoin cp -dp "$(>)" "$(<)" ; 215915716fddSPhilippe Houdoin if [ -f "$(>)" ] ; then copyattr "$(>)" "$(<)" ; fi ; 21609b7a4b5dSshatty} 21619b7a4b5dSshatty 21629b7a4b5dSshattyrule Packages 21639b7a4b5dSshatty{ 21649b7a4b5dSshatty local packagenames = $(1) ; 21659b7a4b5dSshatty local packagefiles = $(2) ; 21669b7a4b5dSshatty local path = $(3) ; 21679b7a4b5dSshatty for name in $(packagenames) { 21689b7a4b5dSshatty Package $(name) : $(packagefiles) : $(path) ; 21699b7a4b5dSshatty } 21709b7a4b5dSshatty} 21719b7a4b5dSshatty 21729b7a4b5dSshattyrule Package 21739b7a4b5dSshatty{ 21749b7a4b5dSshatty local packagename = $(1) ; 21759b7a4b5dSshatty local packagefiles = $(2) ; 21769b7a4b5dSshatty local path = $(3) ; 21779b7a4b5dSshatty 2178c06f365fSIngo Weinhold local packagezip = $(packagename:S=.zip:G=_packages) ; 21799b7a4b5dSshatty local packagedir = [ FDirName $(OBOS_PACKAGE_DIR) $(packagename) ] ; 21809b7a4b5dSshatty 21819b7a4b5dSshatty local installscript = install.sh ; 2182c06f365fSIngo Weinhold local packageinstallscript = $(installscript:G=_packages!$(packagename)) ; 21839b7a4b5dSshatty local installzip = install.zip ; 2184c06f365fSIngo Weinhold local packageinstallzip = $(installzip:G=_packages!$(packagename)) ; 21859b7a4b5dSshatty 2186c06f365fSIngo Weinhold local packageobjectdir 2187c06f365fSIngo Weinhold = [ FDirName $(OBOS_PACKAGE_OBJECT_DIR) $(packagename) ] ; 21889b7a4b5dSshatty local packagefiledir = [ FDirName $(packageobjectdir) $(path) ] ; 2189c06f365fSIngo Weinhold local packagefileinstallzip 2190c06f365fSIngo Weinhold = $(installzip:G=_package_objects!$(packagename)) ; 2191c06f365fSIngo Weinhold 2192c06f365fSIngo Weinhold # add the files to the install.zip 2193c06f365fSIngo Weinhold local packagefilegrist = [ FGrist _package_files $(packagename) $(path) ] ; 21949b7a4b5dSshatty for file in $(packagefiles) { 21959b7a4b5dSshatty if $(3[0]) = "boot" { 2196c06f365fSIngo Weinhold local packagefile = $(file:G=$(packagefilegrist)) ; 21979b7a4b5dSshatty MakeLocate $(packagefile) : $(packagefiledir) ; 21989b7a4b5dSshatty Copy $(packagefile) : $(file) ; 21999b7a4b5dSshatty Clean cleanPackages : $(packagefile) ; 22009b7a4b5dSshatty PackageInstallZip $(packagefileinstallzip) : $(packagefile) ; 22019b7a4b5dSshatty } else { 2202c06f365fSIngo Weinhold local packagefile = $(file:G=_packages!$(packagename)) ; 22039b7a4b5dSshatty MakeLocate $(packagefile) : $(packagedir) ; 220482bec102Sshatty Copy $(packagefile) : [ FGristFiles $(file) ] ; 22059b7a4b5dSshatty Clean cleanPackages : $(packagefile) ; 22069b7a4b5dSshatty Depends $(packagezip) : $(packagefile) ; 22079b7a4b5dSshatty } 22089b7a4b5dSshatty } 2209c06f365fSIngo Weinhold 2210c06f365fSIngo Weinhold # general setup for this packages -- only on first invocation 2211c06f365fSIngo Weinhold if ! $(_setup_$(packagename)) { 2212c06f365fSIngo Weinhold _setup_$(packagename) = true ; 2213c06f365fSIngo Weinhold 2214c06f365fSIngo Weinhold NotFile $(packagename) ; 2215b560211bSshatty LocalDepends packages : $(packagename) ; 2216c06f365fSIngo Weinhold 2217c06f365fSIngo Weinhold MakeLocate $(packagezip) : $(OBOS_PACKAGE_DIR) ; 2218c06f365fSIngo Weinhold MakeLocate $(packageinstallscript) : $(packagedir) ; 2219c06f365fSIngo Weinhold MakeLocate $(packageinstallzip) : $(packagedir) ; 2220c06f365fSIngo Weinhold MakeLocate $(packagefileinstallzip) : $(packageobjectdir) ; 2221c06f365fSIngo Weinhold 22229b7a4b5dSshatty PackageInstallScript $(packageinstallscript) : $(packagedir) ; 22239b7a4b5dSshatty LinkInstallZip $(packageinstallzip) : $(packagefileinstallzip) ; 22249b7a4b5dSshatty Depends $(packagename) : $(packagezip) ; 2225c06f365fSIngo Weinhold PackageZip $(packagezip) : $(packagedir) 2226c06f365fSIngo Weinhold : $(packageinstallscript) $(packageinstallzip) ; 2227c06f365fSIngo Weinhold } 2228c06f365fSIngo Weinhold 22299b7a4b5dSshatty} 22309b7a4b5dSshatty 22319b7a4b5dSshattyrule PackageZip 22329b7a4b5dSshatty{ 2233c06f365fSIngo Weinhold local dir = $(2:G=dir) ; 2234c06f365fSIngo Weinhold Depends $(1) : $(dir) $(3) ; 22359b7a4b5dSshatty Clean cleanPackages : $(1) ; 2236c06f365fSIngo Weinhold PackageZip1 $(1) : $(dir) ; 22379b7a4b5dSshatty} 22389b7a4b5dSshatty 2239c06f365fSIngo Weinholdactions together PackageZip1 { 22408042d2a0SPhilippe Houdoin cd "$(OBOS_PACKAGE_DIR)" ; 22418042d2a0SPhilippe Houdoin zip -rq "$(1:BS)" "$(2:BS)" ; 22429b7a4b5dSshatty} 22439b7a4b5dSshatty 22449b7a4b5dSshattyrule PackageInstallScript 22459b7a4b5dSshatty{ 22469b7a4b5dSshatty MakeLocate $(1) : $(2) ; 22479b7a4b5dSshatty Clean cleanPackages : $(1) ; 2248c06f365fSIngo Weinhold PackageInstallScript1 $(1) : $(2:G=dir) ; 22499b7a4b5dSshatty} 22509b7a4b5dSshatty 2251c06f365fSIngo Weinholdactions together PackageInstallScript1 22529b7a4b5dSshatty{ 225351fe1be4Sshattyecho '#!/bin/sh 225451fe1be4Sshattybase=`dirname "$0"` 22558042d2a0SPhilippe Houdoincd "$base" 225651fe1be4Sshattyif [ -n "$TTY" ] 225751fe1be4Sshattythen 225851fe1be4Sshatty unzip -d / install.zip 225951fe1be4Sshattyelse 226051fe1be4Sshatty response=`alert "Would you like to automatically overwrite existing files, or receive a prompt?" "Overwrite" "Prompt"` 226151fe1be4Sshatty if [ $response == "Overwrite" ] 226251fe1be4Sshatty then 226351fe1be4Sshatty unzip -od / install.zip 226451fe1be4Sshatty alert "Finished installing" "Thanks" 226551fe1be4Sshatty else 226651fe1be4Sshatty if [ -e /boot/beos/apps/Terminal ] 226751fe1be4Sshatty then 226851fe1be4Sshatty terminal=/boot/beos/apps/Terminal 226951fe1be4Sshatty else 227051fe1be4Sshatty terminal=`query Terminal | head -1` 227151fe1be4Sshatty fi 22728042d2a0SPhilippe Houdoin $terminal -t "installer" /bin/sh "$0" 227351fe1be4Sshatty fi 22748042d2a0SPhilippe Houdoinfi' > "$(1)" ; 22758042d2a0SPhilippe Houdoin chmod 755 "$(1)" ; 22769b7a4b5dSshatty} 22779b7a4b5dSshatty 22789b7a4b5dSshattyrule PackageInstallZip 22799b7a4b5dSshatty{ 22809b7a4b5dSshatty Depends $(1) : $(2) ; 22819b7a4b5dSshatty Clean cleanPackages : $(1) ; 22829b7a4b5dSshatty} 22839b7a4b5dSshatty 22849b7a4b5dSshattyactions together PackageInstallZip 22859b7a4b5dSshatty{ 22868042d2a0SPhilippe Houdoin cd "$(1:P)" ; 22878042d2a0SPhilippe Houdoin zip -rqy "$(1:BS)" boot ; 22889b7a4b5dSshatty} 22899b7a4b5dSshatty 22909b7a4b5dSshattyrule LinkInstallZip 22919b7a4b5dSshatty{ 22929b7a4b5dSshatty Depends $(1) : $(2) ; 22939b7a4b5dSshatty Clean cleanPackages : $(1) ; 22949b7a4b5dSshatty} 22959b7a4b5dSshatty 22969b7a4b5dSshattyactions together LinkInstallZip 22979b7a4b5dSshatty{ 22988042d2a0SPhilippe Houdoin ln -sf "`pwd`/$(2)" "$(1)" ; 22999b7a4b5dSshatty} 2300e91f3ca1Sbeveloper 2301e91f3ca1Sbeveloperrule SubIncludeGPL 2302e91f3ca1Sbeveloper{ 2303e91f3ca1Sbeveloper # SubInclude rule that can be used to conditionally include GPL licensed add-ons 2304e91f3ca1Sbeveloper if $(INCLUDE_GPL_ADDONS) = 1 { 2305e91f3ca1Sbeveloper SubInclude $(1) ; 2306e91f3ca1Sbeveloper } 2307e91f3ca1Sbeveloper} 2308