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 ; 108a17b9c0cSshatty } 109a17b9c0cSshatty} 110*6040be99Sshattyif $(BONE_COMPATIBLE) { 111*6040be99Sshatty NETWORK_LIBS = libsocket.so libbind.so ; 112*6040be99Sshatty} else { 113*6040be99Sshatty NETWORK_LIBS = libnet.so ; 114*6040be99Sshatty} 115be1aef42Sshatty 11652a38012Sejakowatz# Determine if we're building on PPC or x86 11752a38012Sejakowatz# Determine mimetype of executable 11852a38012Sejakowatz# Cross compiling can come later 11952a38012Sejakowatz 120c9882d9eSAxel DörflerTARGET_CPU ?= $(OSPLAT:L) ; 1211f622a7bSAxel DörflerOBOS_VERSION ?= R1 ; 1221f622a7bSAxel Dörfler 1231f622a7bSAxel Dörflerswitch $(TARGET_CPU) { 1241f622a7bSAxel Dörfler case ppc : 1251f622a7bSAxel Dörfler { 12652a38012Sejakowatz if $(METROWERKS) { 1271f622a7bSAxel Dörfler # at least parts of OpenBeOS still can be compiled with 1281f622a7bSAxel Dörfler # the Metrowerks compiler on BeOS/PPC 12952a38012Sejakowatz OBOS_TARGET_TYPE ?= "application/x-be-executable" ; 13052a38012Sejakowatz } else { 13152a38012Sejakowatz OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; 1321f622a7bSAxel Dörfler } 133894d1636Sshatty DEFINES += __POWERPC__ ARCH_ppc ; 134e29d8533SAxel Dörfler OBOS_BOOT_PLATFORM = openfirmware ; 1351f622a7bSAxel Dörfler } 1361f622a7bSAxel Dörfler case x86 : 1371f622a7bSAxel Dörfler { 1381f622a7bSAxel Dörfler # nothing special to do here... 139894d1636Sshatty DEFINES += __INTEL__ ARCH_x86 ; 140e29d8533SAxel Dörfler OBOS_BOOT_PLATFORM = bios_ia32 ; 1411f622a7bSAxel Dörfler } 1421f622a7bSAxel Dörfler case * : 1431f622a7bSAxel Dörfler Exit "Currently unsupported build platform:" $(TARGET_CPU) ; 1441f622a7bSAxel Dörfler} 1451f622a7bSAxel Dörfler 1461f622a7bSAxel Dörfler# set target specific variables 1471f622a7bSAxel Dörfler{ 1481f622a7bSAxel Dörfler #Echo "Building for" $(TARGET_CPU) ; 1491f622a7bSAxel Dörfler 1501f622a7bSAxel Dörfler OBOS_TARGET ?= $(TARGET_CPU).$(OBOS_VERSION) ; 1511f622a7bSAxel Dörfler OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; 1521f622a7bSAxel Dörfler OBOS_ARCH ?= $(TARGET_CPU) ; 1531f622a7bSAxel Dörfler OBOS_TARGET_DEFINE ?= "ARCH_"$(TARGET_CPU) ; 15452a38012Sejakowatz} 15552a38012Sejakowatz 15665c62a01SIngo Weinhold# Disable warnings only if WARNINGS is set to 0 157e5dc2d93Sbeveloper# Should be enabled by default later 15896d27465SIngo Weinhold# 15965c62a01SIngo WeinholdWARNINGS ?= 1 ; 16065c62a01SIngo Weinholdif $(WARNINGS) = 1 { 161e5dc2d93Sbeveloper # For an explanation of the different warning options, see: 162e5dc2d93Sbeveloper # http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_2.html 163e5dc2d93Sbeveloper # to get even more warnings, add: 164e5dc2d93Sbeveloper # -Wwrite-strings (doesn't work well with some Be headers) 165e5dc2d93Sbeveloper # -Wundef (dito) 166e5dc2d93Sbeveloper # -Wconversion (gets you many warnings about implicit conversions) 167e5dc2d93Sbeveloper # -W (gets you even more warnigs) 168dd9f8062SIngo Weinhold CCFLAGS += -Wall -Wno-multichar -Wmissing-prototypes ; 169dd9f8062SIngo Weinhold CCFLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; 170dd9f8062SIngo Weinhold C++FLAGS += -Wall -Wno-multichar -Wmissing-prototypes -Wno-ctor-dtor-privacy -Woverloaded-virtual ; 171dd9f8062SIngo Weinhold C++FLAGS += -Wpointer-arith -Wcast-align -Wsign-compare ; 17298cc804cSAxel Dörfler} else { 17398cc804cSAxel Dörfler CCFLAGS += -Wno-multichar ; 17498cc804cSAxel Dörfler C++FLAGS += -Wno-multichar ; 175e5dc2d93Sbeveloper} 176e5dc2d93Sbeveloper 17798cc804cSAxel Dörfler# standard kernel C/C++ flags 1780ff867c2SbeveloperKERNEL_CCFLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; 1790ff867c2SbeveloperKERNEL_CCFLAGS += -fno-builtin -D$(OBOS_TARGET_DEFINE) ; 180ea7627e5SAxel DörflerKERNEL_CCFLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 18198cc804cSAxel DörflerKERNEL_C++FLAGS ?= -Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc ; 182df48dfedSIngo WeinholdKERNEL_C++FLAGS += -fno-builtin -fno-exceptions -D$(OBOS_TARGET_DEFINE) ; 183ea7627e5SAxel DörflerKERNEL_C++FLAGS += -DBOCHS_DEBUG_HACK=$(BOCHS_DEBUG_HACK) -D_KERNEL_MODE ; 184bbb6f2d4SAxel Dörflerif $(GCC_VERSION[1]) >= 3 { 185bbb6f2d4SAxel Dörfler KERNEL_C++FLAGS += -fno-use-cxa-atexit ; 186bbb6f2d4SAxel Dörfler} 1870ff867c2Sbeveloper 1889eea4522SIngo Weinhold# We might later want to introduce debug levels or handle the whole issue 1899eea4522SIngo Weinhold# differently. For now there's only on or off. 1909eea4522SIngo Weinhold# 19165c62a01SIngo WeinholdDEBUG ?= 0 ; 19265c62a01SIngo Weinholdif $(DEBUG) != 0 { 1939eea4522SIngo Weinhold OPTIM ?= -O0 ; 19465c62a01SIngo Weinhold CCFLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 19565c62a01SIngo Weinhold C++FLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 19665c62a01SIngo Weinhold KERNEL_CCFLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 19765c62a01SIngo Weinhold KERNEL_C++FLAGS += -g [ FDefines DEBUG=$(DEBUG) ] ; 1989eea4522SIngo Weinhold LINKFLAGS += -g ; 1999eea4522SIngo Weinhold} else { 2009eea4522SIngo Weinhold OPTIM ?= -O2 ; 2019eea4522SIngo Weinhold} 20296d27465SIngo Weinhold# 20396d27465SIngo Weinhold# To disable for the tests OPTIM and DEBUG are overridden, set the environment 20496d27465SIngo Weinhold# variable NO_TEST_DEBUG. 2059eea4522SIngo Weinhold 20616fa4445SIngo Weinhold# Instructs the Library rule to not make its object files temporary. 207f1e077f8SIngo Weinhold# This is needed as some objects are used in a static library and for an 20816fa4445SIngo Weinhold# executable. 20916fa4445SIngo WeinholdKEEPOBJS = true ; 21016fa4445SIngo Weinhold 2117bc56df1SIngo Weinhold# under BeOS use copyattr instead of cp 2127bc56df1SIngo Weinholdif $(OS) = BEOS 2137bc56df1SIngo Weinhold{ 2147bc56df1SIngo Weinhold CP = copyattr --data ; 2157bc56df1SIngo Weinhold} 2167bc56df1SIngo Weinhold 21753cf6d7aSAxel Dörfler# for builds of tools in the current environment 21853cf6d7aSAxel Dörflerif $(OS) = BEOS { 21953cf6d7aSAxel Dörfler BUILD_LIBSTDC++ = stdc++.r4 ; 22053cf6d7aSAxel Dörfler} else { 22153cf6d7aSAxel Dörfler BUILD_LIBSTDC++ = stdc++ ; 22253cf6d7aSAxel Dörfler} 22353cf6d7aSAxel Dörfler 22452a38012Sejakowatz# If no OBOS_OBJECT_TARGET is not defined yet, use our default directory and 22552a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 22652a38012Sejakowatz# builds mixing objects from different targets). 22752a38012Sejakowatzif ! $(OBOS_OBJECT_TARGET) { 22852a38012Sejakowatz OBOS_OBJECT_TARGET ?= [ FDirName $(OBOS_TOP) objects $(OBOS_TARGET) ] ; 22952a38012Sejakowatz} 23052a38012Sejakowatz 23152a38012Sejakowatz# If no OBOS_DISTRO_TARGET is not defined yet, use our default directory and 23252a38012Sejakowatz# include our "OBOS_TARGET" as subdirectory in there (to prevent different 23352a38012Sejakowatz# builds mixing executables from different targets). 23452a38012Sejakowatzif ! $(OBOS_DISTRO_TARGET) { 23552a38012Sejakowatz OBOS_DISTRO_TARGET ?= [ FDirName $(OBOS_TOP) distro $(OBOS_TARGET) ] ; 23652a38012Sejakowatz} 23752a38012Sejakowatz 23852a38012Sejakowatz# Set our version number if not already set and mark it as a developer build 23952a38012Sejakowatzif ! $(OBOS_BUILD_VERSION) { 24052a38012Sejakowatz OBOS_BUILD_VERSION ?= "1 0 0 a 1" ; 24152a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Developer Build" ; 24252a38012Sejakowatz} 24352a38012Sejakowatz 24452a38012Sejakowatz# If OBOS_BUILD_VERSION is set, but OBOS_BUILD_DESCRIPTION isn't, mark it as 24552a38012Sejakowatz# an unknown build. 24652a38012Sejakowatzif ! $(OBOS_BUILD_DESCRIPTION) { 24752a38012Sejakowatz OBOS_BUILD_DESCRIPTION ?= "Unknown Build" ; 24852a38012Sejakowatz} 24952a38012Sejakowatz 250505554b4SIngo Weinhold# Relative subdirs for distro dir 251505554b4SIngo WeinholdOBOS_ADDON_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system add-ons ] ; 2525f281ed5SejakowatzOBOS_APPS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos apps ] ; 253f06de7f3SIngo WeinholdOBOS_BIN_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos bin ] ; 254505554b4SIngo WeinholdOBOS_ETC_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos etc ] ; 255505554b4SIngo WeinholdOBOS_FONTS_DIR ?= [ FDirName $(OBOS_ETC_DIR) fonts ] ; 256505554b4SIngo WeinholdOBOS_KERNEL_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system ] ; 25752a38012SejakowatzOBOS_PREFS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos preferences ] ; 25852a38012SejakowatzOBOS_SERVER_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system servers ] ; 25952a38012SejakowatzOBOS_SHLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ; 260e9230d05SIngo WeinholdOBOS_STLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) develop lib 261e9230d05SIngo Weinhold $(OBOS_ARCH) ] ; 26252a38012SejakowatzOBOS_TEST_DIR ?= [ FDirName $(OBOS_TOP) tests ] ; 26352a38012Sejakowatz 264c06f365fSIngo WeinholdOBOS_PACKAGE_DIR ?= [ FDirName $(OBOS_TOP) packages $(OBOS_TARGET) ] ; 265c06f365fSIngo WeinholdOBOS_PACKAGE_OBJECT_DIR ?= [ FDirName $(OBOS_OBJECT_TARGET) packages ] ; 266c06f365fSIngo Weinhold 26752a38012SejakowatzOBOS_KERNEL_CONFIG = config.$(OBOS_ARCH).ini ; 26852a38012SejakowatzOBOS_KERNEL = kernel.$(OBOS_ARCH) ; 26952a38012SejakowatzOBOS_FLOPPY = floppy.$(OBOS_ARCH) ; 27052a38012Sejakowatz 27152a38012Sejakowatzrule SetupIncludes 27252a38012Sejakowatz{ 273cfc7b456Sshatty # XXX add "opengl" later 274cfc7b456Sshatty 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 ; 275a6c008e1Sbeveloper 27628d2a30eSDaniel Reinhold # Overwrite any exiting content when changing HDRS. This rule may be invoked multiple times. 277a6c008e1Sbeveloper 278a6c008e1Sbeveloper # Use headers directory, to allow to do things like include <posix/string.h> 27928d2a30eSDaniel Reinhold HDRS = [ FDirName $(OBOS_TOP) headers ] ; 280a6c008e1Sbeveloper 281a6c008e1Sbeveloper # Use posix headers directory 28228d2a30eSDaniel Reinhold HDRS += [ FDirName $(OBOS_TOP) headers posix ] ; 283a6c008e1Sbeveloper 284a6c008e1Sbeveloper # Use public OS header directories 28528d2a30eSDaniel Reinhold HDRS += [ PublicHeaders $(os_includes) ] ; 286a6c008e1Sbeveloper 287c0e501e0SIngo Weinhold # Use the root of the private headers -- not so nice, but simplifies things. 288c0e501e0SIngo Weinhold HDRS += [ PrivateHeaders $(DOT) ] ; 289c0e501e0SIngo Weinhold 290a6c008e1Sbeveloper # Used as a fallback, the R5 header directories (we should remove this as soon as possible) 29128d2a30eSDaniel Reinhold HDRS += /boot/develop/headers/posix /boot/develop/headers/cpp ; 29209c5682dSIngo Weinhold 29309c5682dSIngo Weinhold # The platform dependent headers. 29409c5682dSIngo Weinhold HDRS += $(PLATFORM_HEADERS) ; 29552a38012Sejakowatz} 29652a38012Sejakowatz 297dd9f8062SIngo Weinholdrule SetupR5Includes 298dd9f8062SIngo Weinhold{ 299dd9f8062SIngo Weinhold # Unsets HDRS, so that the OBOS headers do not `shadow' the system headers. 300dd9f8062SIngo Weinhold HDRS = ; 301dd9f8062SIngo Weinhold} 302dd9f8062SIngo Weinhold 3035dc4e1efSIngo Weinholdrule SetupDefaultIncludes 3045dc4e1efSIngo Weinhold{ 3055dc4e1efSIngo Weinhold # Resets HDRS to the default headers for the build platform. 3065dc4e1efSIngo Weinhold HDRS = $(PLATFORM_DEFAULT_HEADERS) ; 3075dc4e1efSIngo Weinhold} 3085dc4e1efSIngo Weinhold 30952a38012Sejakowatz#------------------------------------------------------------------------------- 31052a38012Sejakowatz# Things Jam needs in order to work :) 31152a38012Sejakowatz#------------------------------------------------------------------------------- 31252a38012Sejakowatz 313c06f365fSIngo Weinhold# TODO: back-ported from jam 2.5: remove when not longer needed 314c06f365fSIngo Weinholdrule MakeLocate 315c06f365fSIngo Weinhold{ 316c06f365fSIngo Weinhold if $(>) 317c06f365fSIngo Weinhold { 318c06f365fSIngo Weinhold LOCATE on $(<) = $(>) ; 319c06f365fSIngo Weinhold Depends $(<) : $(>[1]:G=dir) ; 320c06f365fSIngo Weinhold MkDir $(>[1]:G=dir) ; 321c06f365fSIngo Weinhold } 322c06f365fSIngo Weinhold} 323c06f365fSIngo Weinhold 3248d3308d9SIngo Weinholdrule Object 3258d3308d9SIngo Weinhold{ 3268d3308d9SIngo Weinhold # This is basically the original Jambase 2.4 Object rule stripped by 3278d3308d9SIngo Weinhold # comments. Only the final switch statement has been changed to allow 3288d3308d9SIngo Weinhold # intermediate C++ files for Yacc and Lex. 3298d3308d9SIngo Weinhold 3308d3308d9SIngo Weinhold LocalClean clean : $(<) ; 3318d3308d9SIngo Weinhold 3328d3308d9SIngo Weinhold MakeLocate $(<) : $(LOCATE_TARGET) ; 3338d3308d9SIngo Weinhold SEARCH on $(>) = $(SEARCH_SOURCE) ; 3348d3308d9SIngo Weinhold 3358d3308d9SIngo Weinhold HDRS on $(<) = $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ; 3368d3308d9SIngo Weinhold 3378d3308d9SIngo Weinhold HDRRULE on $(>) = HdrRule ; 3388d3308d9SIngo Weinhold HDRSCAN on $(>) = $(HDRPATTERN) ; 3398d3308d9SIngo Weinhold HDRSEARCH on $(>) = 3408d3308d9SIngo Weinhold $(SEARCH_SOURCE:E) $(SUBDIRHDRS) $(HDRS) $(STDHDRS) ; 3418d3308d9SIngo Weinhold 3428d3308d9SIngo Weinhold HDRGRIST on $(>) = $(HDRGRIST) ; 3438d3308d9SIngo Weinhold 3448d3308d9SIngo Weinhold DEFINES on $(<) += $(DEFINES) ; 3458d3308d9SIngo Weinhold 3468d3308d9SIngo Weinhold # if source is not .c, generate .c with specific rule 3478d3308d9SIngo Weinhold 3488d3308d9SIngo Weinhold switch $(>:S) 3498d3308d9SIngo Weinhold { 3508d3308d9SIngo Weinhold case .asm : As $(<) : $(>) ; 3518d3308d9SIngo Weinhold case .c : Cc $(<) : $(>) ; 3528d3308d9SIngo Weinhold case .C : C++ $(<) : $(>) ; 3538d3308d9SIngo Weinhold case .cc : C++ $(<) : $(>) ; 3548d3308d9SIngo Weinhold case .cpp : C++ $(<) : $(>) ; 3558d3308d9SIngo Weinhold case .f : Fortran $(<) : $(>) ; 3568d3308d9SIngo Weinhold case .l : if [ on $(2) return $(GENERATE_C++) ] { 3578d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 3588d3308d9SIngo Weinhold LexC++ $(<:S=.cpp) : $(>) ; 3598d3308d9SIngo Weinhold } else { 3608d3308d9SIngo Weinhold Cc $(<) : $(<:S=.c) ; 3618d3308d9SIngo Weinhold Lex $(<:S=.c) : $(>) ; 3628d3308d9SIngo Weinhold } 3638d3308d9SIngo Weinhold case .s : As $(<) : $(>) ; 3648d3308d9SIngo Weinhold case .y : if [ on $(2) return $(GENERATE_C++) ] { 3658d3308d9SIngo Weinhold C++ $(<) : $(<:S=.cpp) ; 3668d3308d9SIngo Weinhold Bison $(<:S=.cpp) : $(>) ; 3678d3308d9SIngo Weinhold } else { 3688d3308d9SIngo Weinhold Cc $(<) : $(<:S=$(YACCGEN)) ; 3698d3308d9SIngo Weinhold Yacc $(<:S=$(YACCGEN)) : $(>) ; 3708d3308d9SIngo Weinhold } 3718d3308d9SIngo Weinhold case * : UserObject $(<) : $(>) ; 3728d3308d9SIngo Weinhold } 3738d3308d9SIngo Weinhold} 3748d3308d9SIngo Weinhold 37552a38012Sejakowatzrule UserObject 37652a38012Sejakowatz{ 37752a38012Sejakowatz switch $(2) 37852a38012Sejakowatz { 37952a38012Sejakowatz case *.S : assemble $(1) : $(2) ; 38008125d07SIngo Weinhold case *.o : return ; 38152a38012Sejakowatz case * : ECHO "unknown suffix on" $(2) ; 38252a38012Sejakowatz } 38352a38012Sejakowatz} 38452a38012Sejakowatz 38552a38012Sejakowatz# Override the default to give "prettier" command lines. 38652a38012Sejakowatzactions Cc 38752a38012Sejakowatz{ 3880931b8f9SIngo Weinhold $(CC) -c "$(2)" $(CCFLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; 38952a38012Sejakowatz} 39052a38012Sejakowatz 39152a38012Sejakowatzactions C++ 39252a38012Sejakowatz{ 3930931b8f9SIngo Weinhold $(C++) -c "$(2)" $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; 39452a38012Sejakowatz} 39552a38012Sejakowatz 39652a38012Sejakowatz 39752a38012Sejakowatz#------------------------------------------------------------------------------- 39852a38012Sejakowatz# General High-level OBOS target rules 39952a38012Sejakowatz#------------------------------------------------------------------------------- 40052a38012Sejakowatz 4015f281ed5Sejakowatzrule App 4025f281ed5Sejakowatz{ 403007eb5f2SIngo Weinhold # App <name> : <sources> : <libraries> ; 404a6c008e1Sbeveloper SetupIncludes ; 4055f281ed5Sejakowatz SetupObjectsDir ; 406007eb5f2SIngo Weinhold Main $(1) : $(2) ; 407007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_APPS_DIR) ; 408007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 409007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 410007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 4115f281ed5Sejakowatz} 4125f281ed5Sejakowatz 413f06de7f3SIngo Weinholdrule BinCommand 414f06de7f3SIngo Weinhold{ 41511fa3682SJérôme Duval # BinCommand <name> : <sources> : <libraries> : <res> ; 416a6c008e1Sbeveloper SetupIncludes ; 417f06de7f3SIngo Weinhold SetupObjectsDir ; 41811fa3682SJérôme Duval AddResources $(1) : $(4) ; 419f06de7f3SIngo Weinhold Main $(1) : $(2) ; 420f06de7f3SIngo Weinhold MakeLocate $(1) : $(OBOS_BIN_DIR) ; 421f06de7f3SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 422007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 423007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 424f06de7f3SIngo Weinhold} 425f06de7f3SIngo Weinhold 426f06de7f3SIngo Weinholdrule StdBinCommands 427f06de7f3SIngo Weinhold{ 42811fa3682SJérôme Duval # StdBinCommands <sources> : <libs> : <res> ; 429a6c008e1Sbeveloper SetupIncludes ; 430a6c008e1Sbeveloper SetupObjectsDir ; 431f06de7f3SIngo Weinhold local libs = $(2) ; 43211fa3682SJérôme Duval local ress = $(3) ; 4339342c27aSIngo Weinhold local source ; 434f06de7f3SIngo Weinhold for source in $(1) 435f06de7f3SIngo Weinhold { 436f06de7f3SIngo Weinhold local target = $(source:S=) ; 437a6c008e1Sbeveloper 43811fa3682SJérôme Duval BinCommand $(target) : $(source) : $(libs) : $(ress) ; 439f06de7f3SIngo Weinhold } 440f06de7f3SIngo Weinhold} 441f06de7f3SIngo Weinhold 44252a38012Sejakowatzrule Preference 44352a38012Sejakowatz{ 444007eb5f2SIngo Weinhold # Preference <name> : <sources> : <libraries> ; 445a6c008e1Sbeveloper SetupIncludes ; 44652a38012Sejakowatz SetupObjectsDir ; 447007eb5f2SIngo Weinhold Main $(1) : $(2) ; 448007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_PREFS_DIR) ; 449007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 450007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 451007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 45252a38012Sejakowatz} 45352a38012Sejakowatz 45452a38012Sejakowatzrule Server 45552a38012Sejakowatz{ 456007eb5f2SIngo Weinhold # Server <name> : <sources> : <libraries> ; 45752a38012Sejakowatz 458a6c008e1Sbeveloper SetupIncludes ; 45952a38012Sejakowatz SetupObjectsDir ; 460007eb5f2SIngo Weinhold Main $(1) : $(2) ; 461007eb5f2SIngo Weinhold MakeLocate $(1) : $(OBOS_SERVER_DIR) ; 462007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 463007eb5f2SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] 464007eb5f2SIngo Weinhold -Xlinker -soname=_APP_ ; 46552a38012Sejakowatz} 46652a38012Sejakowatz 46752a38012Sejakowatz# test pseudo targets 46852a38012SejakowatzNOTFILE obostests ; 46952a38012SejakowatzNOTFILE r5tests ; 47052a38012Sejakowatz 471d1f6c38fSTyler Dauwalderrule CommonTestLib 472d1f6c38fSTyler Dauwalder{ 473c5ff4aa6STyler Dauwalder # CommonTestLib <target> : <sources> : <obos libraries> 4749285de51STyler Dauwalder # : <r5 libraries> : <test libraries> : <public headers>; 475d1f6c38fSTyler Dauwalder # Builds a unit test for both OBOS and R5 modules. 476d1f6c38fSTyler Dauwalder # <target> The name of the target. 477d1f6c38fSTyler Dauwalder # <sources> The list of sources. 478d1f6c38fSTyler Dauwalder # <obos libraries> A list of link libraries for the OBOS tests (as passed 479d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 480d1f6c38fSTyler Dauwalder # <r5 libraries> A list of link libraries for the R5 tests (as passed 481d1f6c38fSTyler Dauwalder # to LinkSharedOSLibs). 4829285de51STyler Dauwalder # <test libraries> A list of link libraries for both OBOS tests and R5 tests 4839285de51STyler Dauwalder # that have a common name (i.e. specify libx.so and the OBOS tests will link 4849285de51STyler Dauwalder # to libx.so and the R5 tests will link to libx_r5.so). 485d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 486d1f6c38fSTyler Dauwalder # UsePublicHeaders). 487d1f6c38fSTyler Dauwalder 488c5ff4aa6STyler Dauwalder TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester lib ] : $(3) $(5) : $(6) ; 489c5ff4aa6STyler Dauwalder R5TestLib $(1) : $(2) : [ FDirName $(OBOS_TEST_DIR) unittester_r5 lib ] : $(4) [ R5SharedLibraryNames $(5) ] ; 490d1f6c38fSTyler Dauwalder} 491d1f6c38fSTyler Dauwalder 492d1f6c38fSTyler Dauwalderrule TestLib 493d1f6c38fSTyler Dauwalder{ 494d1f6c38fSTyler Dauwalder # TestLib <target> : <sources> : <dest> : <libraries> : <public headers> 495d1f6c38fSTyler Dauwalder # Builds a unit test library for an OBOS module. 496d1f6c38fSTyler Dauwalder # <target> The name of the target. 497d1f6c38fSTyler Dauwalder # <sources> The list of sources. 498d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 499d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 500d1f6c38fSTyler Dauwalder # <public headers> A list of public header dirs (as passed to 501d1f6c38fSTyler Dauwalder # UsePublicHeaders). 502d1f6c38fSTyler Dauwalder 503d1f6c38fSTyler Dauwalder local target = $(1) ; 504d1f6c38fSTyler Dauwalder local sources = $(2) ; 505d1f6c38fSTyler Dauwalder local dest = $(3) ; 506d1f6c38fSTyler Dauwalder local libraries = $(4) ; 507d1f6c38fSTyler Dauwalder local headerDirs = $(5) ; 5089342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 509d1f6c38fSTyler Dauwalder 5109342c27aSIngo Weinhold # Our Main replacement. 5119342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 5129342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 513d1f6c38fSTyler Dauwalder 514d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 5150d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 5160d1cdd94SIngo Weinhold Depends obostests : $(target) ; 517d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 518d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 519d1f6c38fSTyler Dauwalder} 520d1f6c38fSTyler Dauwalder 521d1f6c38fSTyler Dauwalderrule R5TestLib 522d1f6c38fSTyler Dauwalder{ 523c5ff4aa6STyler Dauwalder # R5TestLib <target> : <sources> : <dest> : <libraries> 524d1f6c38fSTyler Dauwalder # Builds a unit test for an R5 module. "_r5" is appended to the object 525d1f6c38fSTyler Dauwalder # and the target name. 526d1f6c38fSTyler Dauwalder # <target> The name of the target. 527d1f6c38fSTyler Dauwalder # <sources> The list of sources. 528d1f6c38fSTyler Dauwalder # <dest> The directory for the target (as passed to FDirName). 529d1f6c38fSTyler Dauwalder # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 530d1f6c38fSTyler Dauwalder 531d1f6c38fSTyler Dauwalder local target = $(1:B)_r5$(1:S) ; 532d1f6c38fSTyler Dauwalder local sources = $(2) ; 533c5ff4aa6STyler Dauwalder local dest = $(3) ; 534d1f6c38fSTyler Dauwalder local libraries = $(4) ; 535d1f6c38fSTyler Dauwalder local objects = [ R5ObjectNames $(sources) ] ; 536d1f6c38fSTyler Dauwalder 537d1f6c38fSTyler Dauwalder # Our Main replacement. 538d1f6c38fSTyler Dauwalder MainFromObjects $(target) : $(objects) ; 5399342c27aSIngo Weinhold TestObjects $(sources) : : true ; 540d1f6c38fSTyler Dauwalder 541d1f6c38fSTyler Dauwalder MakeLocate $(target) : $(dest) ; 5420d1cdd94SIngo Weinhold Depends $(target) : libcppunit.so ; 5430d1cdd94SIngo Weinhold Depends r5tests : $(target) ; 544d1f6c38fSTyler Dauwalder LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 545d1f6c38fSTyler Dauwalder LINKFLAGS on $(target) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(target)\" ; 546d1f6c38fSTyler Dauwalder} 547d1f6c38fSTyler Dauwalder 54852a38012Sejakowatzrule CommonUnitTest 54952a38012Sejakowatz{ 55052a38012Sejakowatz # CommonUnitTest <target> : <sources> : <dest> : <obos libraries> 55152a38012Sejakowatz # : <r5 libraries> : <public headers>; 55252a38012Sejakowatz # Builds a unit test for both OBOS and R5 modules. 55352a38012Sejakowatz # <target> The name of the target. 55452a38012Sejakowatz # <sources> The list of sources. 55552a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 55652a38012Sejakowatz # <obos libraries> A list of link libraries for the OBOS tests (as passed 55752a38012Sejakowatz # to LinkSharedOSLibs). 55852a38012Sejakowatz # <r5 libraries> A list of link libraries for the R5 tests (as passed 55952a38012Sejakowatz # to LinkSharedOSLibs). 56052a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 56152a38012Sejakowatz # UsePublicHeaders). 56252a38012Sejakowatz 56352a38012Sejakowatz UnitTest $(1) : $(2) : $(3) : $(4) : $(6) ; 56452a38012Sejakowatz R5UnitTest $(1) : $(2) : $(3) : $(5) ; 56552a38012Sejakowatz} 56652a38012Sejakowatz 56752a38012Sejakowatzrule UnitTest 56852a38012Sejakowatz{ 56952a38012Sejakowatz # UnitTest <target> : <sources> : <dest> : <libraries> : <public headers> 57052a38012Sejakowatz # Builds a unit test for an OBOS module. 57152a38012Sejakowatz # <target> The name of the target. 57252a38012Sejakowatz # <sources> The list of sources. 57352a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 57452a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 57552a38012Sejakowatz # <public headers> A list of public header dirs (as passed to 57652a38012Sejakowatz # UsePublicHeaders). 57752a38012Sejakowatz 57852a38012Sejakowatz local target = $(1) ; 57952a38012Sejakowatz local sources = $(2) ; 58052a38012Sejakowatz local dest = $(3) ; 58152a38012Sejakowatz local libraries = $(4) ; 58252a38012Sejakowatz local headerDirs = $(5) ; 5839342c27aSIngo Weinhold local objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 58452a38012Sejakowatz 5859342c27aSIngo Weinhold # Our Main replacement. 5869342c27aSIngo Weinhold MainFromObjects $(target) : $(objects) ; 5879342c27aSIngo Weinhold TestObjects $(sources) : $(headerDirs) ; 5883b9eae39SIngo Weinhold 58952a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 5909eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 5919eea4522SIngo Weinhold Depends obostests : $(target) ; 59252a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 59352a38012Sejakowatz} 59452a38012Sejakowatz 59552a38012Sejakowatzrule R5UnitTest 59652a38012Sejakowatz{ 59752a38012Sejakowatz # R5UnitTest <target> : <sources> : <dest> : <libraries> 59852a38012Sejakowatz # Builds a unit test for an R5 module. "_r5" is appended to the object 59952a38012Sejakowatz # and the target name. 60052a38012Sejakowatz # <target> The name of the target. 60152a38012Sejakowatz # <sources> The list of sources. 60252a38012Sejakowatz # <dest> The directory for the target (as passed to FDirName). 60352a38012Sejakowatz # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 60452a38012Sejakowatz 60552a38012Sejakowatz local target = $(1)_r5 ; 60652a38012Sejakowatz local sources = $(2) ; 60752a38012Sejakowatz local dest = $(3) ; 60852a38012Sejakowatz local libraries = $(4) ; 60952a38012Sejakowatz local objects = [ R5ObjectNames $(sources) ] ; 61052a38012Sejakowatz 61152a38012Sejakowatz # Our Main replacement. 61252a38012Sejakowatz MainFromObjects $(target) : $(objects) ; 6139342c27aSIngo Weinhold TestObjects $(sources) : : true ; 61452a38012Sejakowatz 61552a38012Sejakowatz MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 6169eea4522SIngo Weinhold Depends $(target) : libcppunit.so ; 6179eea4522SIngo Weinhold Depends r5tests : $(target) ; 61852a38012Sejakowatz LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 61952a38012Sejakowatz} 62052a38012Sejakowatz 62152a38012Sejakowatzrule R5ObjectNames 62252a38012Sejakowatz{ 62352a38012Sejakowatz # R5ObjectNames <sources> ; 62452a38012Sejakowatz # Returns a list of gristed object names given a list of source file names. 62552a38012Sejakowatz # Moreover each object names gets "_r5" inserted before the object suffix. 62652a38012Sejakowatz local objects = $(1:S=)_r5 ; 62752a38012Sejakowatz return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ; 62852a38012Sejakowatz} 62952a38012Sejakowatz 6309342c27aSIngo Weinholdrule R5Objects 6319342c27aSIngo Weinhold{ 6329342c27aSIngo Weinhold # R5Objects <sources> 633dd9f8062SIngo Weinhold # Similar to Objects, but appends "_r5" to the object file names and 634dd9f8062SIngo Weinhold # removes `-nostdinc' from the CC and C++ flags to enable system headers. 6359342c27aSIngo Weinhold # <sources> The source files. 6369342c27aSIngo Weinhold 637dd9f8062SIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 638dd9f8062SIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 639dd9f8062SIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 640dd9f8062SIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 641dd9f8062SIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 642dd9f8062SIngo Weinhold 6439342c27aSIngo Weinhold local sources = $(1) ; 6449342c27aSIngo Weinhold local source ; 6459342c27aSIngo Weinhold for source in [ FGristFiles $(sources) ] 6469342c27aSIngo Weinhold { 6479342c27aSIngo Weinhold local object = [ R5ObjectNames $(source) ] ; 6489342c27aSIngo Weinhold Object $(object) : $(source) ; 6499342c27aSIngo Weinhold LocalDepends obj : $(object) ; 6509342c27aSIngo Weinhold } 651dd9f8062SIngo Weinhold 652dd9f8062SIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 653dd9f8062SIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 654dd9f8062SIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 6559342c27aSIngo Weinhold} 6569342c27aSIngo Weinhold 6579342c27aSIngo Weinholdrule TestObjects 6589342c27aSIngo Weinhold{ 6599342c27aSIngo Weinhold # TestLib <sources> : <public headers> : <r5> 6609342c27aSIngo Weinhold # Compiles objects for tests. 6619342c27aSIngo Weinhold # <sources> The list of sources. 6629342c27aSIngo Weinhold # <public headers> A list of public header dirs (as passed to 6639342c27aSIngo Weinhold # UsePublicHeaders). 6649342c27aSIngo Weinhold # <r5> If set, "_r5" is appended to the object file names and 6659342c27aSIngo Weinhold # <public headers> is ignored. Furthermore the pre-processor macro 6669342c27aSIngo Weinhold # TEST_R5 is defined, TEST_OBOS otherwise. 6679342c27aSIngo Weinhold 6689342c27aSIngo Weinhold local sources = $(1) ; 6699342c27aSIngo Weinhold local headerDirs = $(2) ; 6709342c27aSIngo Weinhold local r5 = $(3) ; 6719342c27aSIngo Weinhold local objects ; 6729342c27aSIngo Weinhold 6739342c27aSIngo Weinhold # Turn optimization off. 67496d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 6759342c27aSIngo Weinhold local optim = $(OPTIM) ; 6769342c27aSIngo Weinhold OPTIM = ; 67796d27465SIngo Weinhold } 6789342c27aSIngo Weinhold 6799342c27aSIngo Weinhold SetupObjectsDir ; 6809342c27aSIngo Weinhold 6819342c27aSIngo Weinhold # compile 6829342c27aSIngo Weinhold if $(r5) { 683dd9f8062SIngo Weinhold SetupR5Includes ; 6849342c27aSIngo Weinhold objects = [ R5ObjectNames $(sources) ] ; 6859342c27aSIngo Weinhold R5Objects $(sources) ; 6869342c27aSIngo Weinhold } else { 687dd9f8062SIngo Weinhold SetupIncludes ; 6889342c27aSIngo Weinhold objects = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 6899342c27aSIngo Weinhold Objects $(sources) ; 6909342c27aSIngo Weinhold } 6919342c27aSIngo Weinhold 6929342c27aSIngo Weinhold # set headers/defines 6939b60a208SIngo Weinhold UseCppUnitObjectHeaders $(sources) : $(objects) ; 6949342c27aSIngo Weinhold if $(r5) { 695728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_R5 ; 6969342c27aSIngo Weinhold } else { 6979b60a208SIngo Weinhold UsePublicObjectHeaders $(sources) : $(headerDirs) : $(objects) ; 698728b5725SIngo Weinhold ObjectsDefines $(objects) : TEST_OBOS ; 6999342c27aSIngo Weinhold } 7009342c27aSIngo Weinhold 70196d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7029342c27aSIngo Weinhold # Turn debugging on. That is usually desired for test code. 7039342c27aSIngo Weinhold ObjectCcFlags $(objects) : "-g" ; 7049342c27aSIngo Weinhold ObjectC++Flags $(objects) : "-g" ; 7059342c27aSIngo Weinhold 7069342c27aSIngo Weinhold # Turn optimization on again. 7079342c27aSIngo Weinhold OPTIM = $(optim) ; 7089342c27aSIngo Weinhold } 70996d27465SIngo Weinhold} 7109342c27aSIngo Weinhold 7119285de51STyler Dauwalderrule R5SharedLibraryNames 7129285de51STyler Dauwalder{ 7139285de51STyler Dauwalder # R5SharedLibraryNames <sources> ; 7149285de51STyler Dauwalder # Returns a list of shared library names given a list of file names. NO 7159285de51STyler Dauwalder # GRISTING IS PERFORMED :-) However, each library names gets "_r5" inserted 7169285de51STyler Dauwalder # before the shared lib suffix. 7179285de51STyler Dauwalder return $(1:S=)_r5.so ; 7189285de51STyler Dauwalder} 7199285de51STyler Dauwalder 7209fc6b2e1SIngo Weinholdrule SimpleTest 7219fc6b2e1SIngo Weinhold{ 7229fc6b2e1SIngo Weinhold # UnitTest <target> : <sources> : <libraries> 7239fc6b2e1SIngo Weinhold # Builds a unit test for an OBOS module. 7249fc6b2e1SIngo Weinhold # <target> The name of the target. 7259fc6b2e1SIngo Weinhold # <sources> The list of sources. 7269fc6b2e1SIngo Weinhold # <dest> The directory for the target (as passed to FDirName). 7279fc6b2e1SIngo Weinhold # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 7289fc6b2e1SIngo Weinhold # <public headers> A list of public header dirs (as passed to 7299fc6b2e1SIngo Weinhold # UsePublicHeaders). 7309fc6b2e1SIngo Weinhold 7319fc6b2e1SIngo Weinhold local target = $(1) ; 7329fc6b2e1SIngo Weinhold local sources = $(2) ; 7339fc6b2e1SIngo Weinhold local libraries = $(3) ; 7349fc6b2e1SIngo Weinhold local relPath = [ FRelPath src tests : $(SUBDIR_TOKENS) ] ; 7359fc6b2e1SIngo Weinhold 7369fc6b2e1SIngo Weinhold # Turn optimization off. 73796d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7389fc6b2e1SIngo Weinhold local optim = $(OPTIM) ; 7399fc6b2e1SIngo Weinhold OPTIM = ; 74096d27465SIngo Weinhold } 7419fc6b2e1SIngo Weinhold 742a6c008e1Sbeveloper SetupIncludes ; 7439fc6b2e1SIngo Weinhold SetupObjectsDir ; 7449fc6b2e1SIngo Weinhold MakeLocateObjects $(sources) ; 7459fc6b2e1SIngo Weinhold Main $(target) : $(sources) ; 7469fc6b2e1SIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 7479eea4522SIngo Weinhold Depends obostests : $(target) ; 7489fc6b2e1SIngo Weinhold LinkSharedOSLibs $(target) : $(libraries) ; 749728b5725SIngo Weinhold ObjectsDefines $(sources) : TEST_OBOS ; 75096d27465SIngo Weinhold if ! $(NO_TEST_DEBUG) { 7519fc6b2e1SIngo Weinhold # Turn debugging on. That is usually desired for test code. 7529fc6b2e1SIngo Weinhold ObjectCcFlags $(sources) : "-g" ; 7539fc6b2e1SIngo Weinhold ObjectC++Flags $(sources) : "-g" ; 7549fc6b2e1SIngo Weinhold 7559fc6b2e1SIngo Weinhold # Turn optimization on again. 7569fc6b2e1SIngo Weinhold OPTIM = $(optim) ; 7579fc6b2e1SIngo Weinhold } 75896d27465SIngo Weinhold} 7599fc6b2e1SIngo Weinhold 76052a38012Sejakowatzrule Addon 76152a38012Sejakowatz{ 76283b3b0dfSIngo Weinhold # Addon <name> : <relpath> : <sources> : <is executable> : <libraries> ; 7637a384fdeSIngo Weinhold # <name>: Name of the add-on. 7647a384fdeSIngo Weinhold # <relpath>: Path where the add-on shall live relative to the add-on dir. 7657a384fdeSIngo Weinhold # <sources>: Source files. 76683b3b0dfSIngo Weinhold # <is executable>: true, if the target shall be executable as well. 76783b3b0dfSIngo Weinhold # <libraries>: Libraries to be linked against. 7687a384fdeSIngo Weinhold 7697a384fdeSIngo Weinhold local isExecutable = $(4) ; 77052a38012Sejakowatz 771a6c008e1Sbeveloper SetupIncludes ; 77252a38012Sejakowatz SetupObjectsDir ; 77352a38012Sejakowatz Main $(1) : $(3) ; 77452a38012Sejakowatz 77552a38012Sejakowatz # Create output dir path for addon 77652a38012Sejakowatz local targetdir; 77752a38012Sejakowatz targetdir = [ FDirName $(OBOS_ADDON_DIR) $(2) ] ; 77852a38012Sejakowatz 77952a38012Sejakowatz MakeLocate $(1) : $(targetdir) ; 7807a384fdeSIngo Weinhold 7817a384fdeSIngo Weinhold local linkFlags = -Xlinker -soname=\"$(1)\" ; 7827a384fdeSIngo Weinhold if $(isExecutable) != true { 7837a384fdeSIngo Weinhold linkFlags = -nostart $(linkFlags) ; 7847a384fdeSIngo Weinhold } 7857a384fdeSIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] $(linkFlags) ; 78683b3b0dfSIngo Weinhold LinkSharedOSLibs $(1) : $(5) ; 787af28904fSIngo Weinhold} 788af28904fSIngo Weinhold 78958efc9d8SIngo Weinholdrule R5KernelAddon 790af28904fSIngo Weinhold{ 791600203b1SAxel Dörfler # R5KernelAddon <name> : <relpath> : <sources> : <static-libraries> ; 792af28904fSIngo Weinhold 793af28904fSIngo Weinhold local sources = $(3) ; 794af28904fSIngo Weinhold 795af28904fSIngo Weinhold Addon $(1) : $(2) : $(3) ; 796af28904fSIngo Weinhold ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 797df48dfedSIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic -fno-exceptions ; 7989eea4522SIngo Weinhold LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; 799600203b1SAxel Dörfler LinkSharedOSLibs $(1) : $(4) /boot/develop/lib/x86/_KERNEL_ ; 80052a38012Sejakowatz} 80152a38012Sejakowatz 8024fb5add0SMatthew Wilberrule Translator 8034fb5add0SMatthew Wilber{ 804007eb5f2SIngo Weinhold # Translator <name> : <sources> : <libraries> ; 805a6c008e1Sbeveloper SetupIncludes ; 8064fb5add0SMatthew Wilber SetupObjectsDir ; 8074fb5add0SMatthew Wilber Main $(1) : $(2) ; 808007eb5f2SIngo Weinhold LinkSharedOSLibs $(1) : $(3) ; 8094fb5add0SMatthew Wilber 8104fb5add0SMatthew Wilber # Create output dir path for translator 8114fb5add0SMatthew Wilber local targetdir; 812d5b07cf2Sshatty targetdir = [ FDirName $(OBOS_ADDON_DIR) Translators ] ; 8134fb5add0SMatthew Wilber MakeLocate $(1) : $(targetdir) ; 8144fb5add0SMatthew Wilber} 8154fb5add0SMatthew Wilber 81652a38012Sejakowatzrule MakeLocateObjects 81752a38012Sejakowatz{ 81821df5945SIngo Weinhold # MakeLocateObjects <sources_or_objects> ; 81952a38012Sejakowatz 82021df5945SIngo Weinhold local _objs = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 82152a38012Sejakowatz 82252a38012Sejakowatz for o in $(_objs) 82352a38012Sejakowatz { 82452a38012Sejakowatz local dir = $(o:D) ; 82552a38012Sejakowatz if $(dir) { 82652a38012Sejakowatz MakeLocate $(o) : [ FDirName $(LOCATE_TARGET) $(dir) ] ; 82752a38012Sejakowatz } else { 82852a38012Sejakowatz MakeLocate $(o) : $(LOCATE_TARGET) ; 82952a38012Sejakowatz } 83052a38012Sejakowatz } 83152a38012Sejakowatz} 83252a38012Sejakowatz 83352a38012Sejakowatzrule StaticLibrary 83452a38012Sejakowatz{ 835e9230d05SIngo Weinhold # StaticLibrary <name> : <sources> [ : <target dir> ] ; 836e9230d05SIngo Weinhold # Creates a static library from sources. 837e9230d05SIngo Weinhold # <name>: Basename of the library, without leading "lib" and trailing ".a". 83860c9c40fSIngo Weinhold # Grist is allowed -- it will be re-prepended after constructing 83960c9c40fSIngo Weinhold # the complete library name. 840e9230d05SIngo Weinhold # <source>: List of source files. 841e9230d05SIngo Weinhold # <target dir>: Directory into which the library shall be placed. Defaults 84260c9c40fSIngo Weinhold # to the objects directory for this subdir. If 84360c9c40fSIngo Weinhold # STATIC_LIBRARY_DIR is supplied (the literal string) 84460c9c40fSIngo Weinhold # the standard directory for static libs is used, otherwise 84560c9c40fSIngo Weinhold # the parameter is interpreted as directory path. 846e9230d05SIngo Weinhold # 84760c9c40fSIngo Weinhold local lib = lib$(1:B)$(SUFLIB) ; 84860c9c40fSIngo Weinhold lib = $(lib:G=$(1:G)) ; 849a6c008e1Sbeveloper SetupIncludes ; 85052a38012Sejakowatz SetupObjectsDir ; 85152a38012Sejakowatz MakeLocateObjects $(2) ; 852e9230d05SIngo Weinhold Library $(lib) : $(2) ; 853e9230d05SIngo Weinhold local targetDir = $(3) ; 85460c9c40fSIngo Weinhold if $(targetDir) { 85560c9c40fSIngo Weinhold if $(targetDir) = STATIC_LIBRARY_DIR { 856e9230d05SIngo Weinhold targetDir = $(OBOS_STLIB_DIR) ; 857e9230d05SIngo Weinhold } 858e9230d05SIngo Weinhold MakeLocate $(lib) : $(targetDir) ; 85960c9c40fSIngo Weinhold } else { 86060c9c40fSIngo Weinhold # nothing to do, since the Library rule already located the library 86160c9c40fSIngo Weinhold # in $(LOCATE_TARGET) 86260c9c40fSIngo Weinhold } 863f1e077f8SIngo Weinhold 864f1e077f8SIngo Weinhold # If KEEPOBJS is set, Library doesn't make the library depend on 865f1e077f8SIngo Weinhold # `lib'. 866f1e077f8SIngo Weinhold if $(KEEPOBJS) { 867f1e077f8SIngo Weinhold LocalDepends lib : $(lib) ; 868f1e077f8SIngo Weinhold } 86952a38012Sejakowatz} 87052a38012Sejakowatz 871dbf96817SIngo Weinholdrule R5KernelStaticLibrary 872dbf96817SIngo Weinhold{ 873dbf96817SIngo Weinhold # R5KernelStaticLibrary <name> : <sources> ; 874dbf96817SIngo Weinhold 875f1e077f8SIngo Weinhold local lib = lib$(1)$(SUFLIB) ; 876dbf96817SIngo Weinhold local sources = $(2) ; 877dbf96817SIngo Weinhold 878dbf96817SIngo Weinhold SetupIncludes ; 879dbf96817SIngo Weinhold SetupObjectsDir ; 880dbf96817SIngo Weinhold MakeLocateObjects $(sources) ; 881dbf96817SIngo Weinhold Library $(lib) : $(sources) ; 882dbf96817SIngo Weinhold ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 883df48dfedSIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic -fno-exceptions ; 884dbf96817SIngo Weinhold} 885dbf96817SIngo Weinhold 88680721244SAxel Dörflerrule MergeObjectFromObjects 88780721244SAxel Dörfler{ 8882fbd7065SIngo Weinhold # MergeObjectFromObjects <name> : <objects> : <other objects> ; 8892fbd7065SIngo Weinhold # Merges object files to an object file. 8902fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 8912fbd7065SIngo Weinhold # <objects>: Object files to be merged. Grist will be added. 8922fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 8932fbd7065SIngo Weinhold # will be added. 8942fbd7065SIngo Weinhold # 895c8aa252aSIngo Weinhold local objects = [ FGristFiles $(2) ] ; 89680721244SAxel Dörfler MakeLocate $(1) : $(LOCATE_TARGET) ; 897c8aa252aSIngo Weinhold Depends $(1) : $(objects) ; 8982fbd7065SIngo Weinhold Depends $(1) : $(3) ; 89980721244SAxel Dörfler LINK on $(1) = ld ; 9002fbd7065SIngo Weinhold MergeObjectFromObjects1 $(1) : $(objects) $(3) ; 90180721244SAxel Dörfler} 90280721244SAxel Dörfler 90354b7cbe1SIngo Weinholdactions MergeObjectFromObjects1 90480721244SAxel Dörfler{ 90580721244SAxel Dörfler $(LINK) -r $(2) -o $(1) ; 90680721244SAxel Dörfler} 90780721244SAxel Dörfler 90880721244SAxel Dörflerrule MergeObject 90980721244SAxel Dörfler{ 9102fbd7065SIngo Weinhold # MergeObject <name> : <sources> : <other objects> ; 9112fbd7065SIngo Weinhold # Compiles source files and merges the object files to an object file. 9122fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 9132fbd7065SIngo Weinhold # <sources>: Sources to be compiled. Grist will be added. 9142fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 9152fbd7065SIngo Weinhold # will be added. 9162fbd7065SIngo Weinhold # 91780721244SAxel Dörfler SetupIncludes ; 91880721244SAxel Dörfler SetupObjectsDir ; 91980721244SAxel Dörfler MakeLocateObjects $(2) ; 92080721244SAxel Dörfler Objects $(2) ; 9212fbd7065SIngo Weinhold MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; 92280721244SAxel Dörfler} 92380721244SAxel Dörfler 92421df5945SIngo Weinholdrule SharedLibraryFromObjects 92552a38012Sejakowatz{ 9268d3308d9SIngo Weinhold # SharedLibraryFromObjects <name> : <objects> : <libraries> ; 92760c9c40fSIngo Weinhold local _lib = lib$(1:B).so ; 92860c9c40fSIngo Weinhold _lib = $(_lib:G=$(1:G)) ; 92921df5945SIngo Weinhold MainFromObjects $(_lib) : $(2) ; 93052a38012Sejakowatz MakeLocate $(_lib) : $(OBOS_SHLIB_DIR) ; 9319eea4522SIngo Weinhold LINKFLAGS on $(_lib) = [ on $(_lib) return $(LINKFLAGS) ] 9329eea4522SIngo Weinhold -nostart -Xlinker -soname=\"$(_lib)\" ; 9338d3308d9SIngo Weinhold LinkSharedOSLibs $(_lib) : $(3) ; 93452a38012Sejakowatz} 93552a38012Sejakowatz 93621df5945SIngo Weinholdrule SharedLibrary 93721df5945SIngo Weinhold{ 9388d3308d9SIngo Weinhold # SharedLibrary <name> : <sources> : <libraries> ; 939a6c008e1Sbeveloper SetupIncludes ; 94021df5945SIngo Weinhold SetupObjectsDir ; 94121df5945SIngo Weinhold MakeLocateObjects $(2) ; 94221df5945SIngo Weinhold Objects $(2) ; 9438d3308d9SIngo Weinhold SharedLibraryFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(3) ; 94421df5945SIngo Weinhold} 94521df5945SIngo Weinhold 94652a38012Sejakowatzrule LinkSharedOSLibs 94752a38012Sejakowatz{ 94852a38012Sejakowatz # LinkSharedOSLibs <name> : <libs> ; 94952a38012Sejakowatz # Valid elements for <libs> are e.g. "be" or "libopenbeos.so" or 9504236d490SIngo Weinhold # "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy 9514236d490SIngo Weinhold # has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the 9524236d490SIngo Weinhold # file will be bound!), otherwise it is prefixed "-l" and added to 953a8cd0719SIngo Weinhold # LINKLIBS. If you want to specify a target that isn't a library and 954a8cd0719SIngo Weinhold # also has neither grist nor a dirname, you can prepend "<nogrist>" as 955a8cd0719SIngo Weinhold # grist; it will be stripped by this rule. 95652a38012Sejakowatz 95752a38012Sejakowatz for i in $(>) 95852a38012Sejakowatz { 9594236d490SIngo Weinhold local isfile = ; 9604236d490SIngo Weinhold if $(i:D) || $(i:G) { 9614236d490SIngo Weinhold isfile = true ; 962a8cd0719SIngo Weinhold if $(i:G) = <nogrist> { 963a8cd0719SIngo Weinhold i = $(i:G=) ; 964a8cd0719SIngo Weinhold } 9654236d490SIngo Weinhold } else { 96652a38012Sejakowatz switch $(i:B) 96752a38012Sejakowatz { 968007eb5f2SIngo Weinhold # XXX: _APP_ and _KERNEL_ should not be needed for ELF. 969f7901247SPhilippe Houdoin case _APP_ : isfile = true ; 970f7901247SPhilippe Houdoin case _KERNEL_ : isfile = true ; 9714236d490SIngo Weinhold case lib* : isfile = true ; 9724236d490SIngo Weinhold case * : isfile = ; 9734236d490SIngo Weinhold } 974b8baf385SIngo Weinhold if ! $(isfile) && ( $(i:S) = .so || $(i:S) = .a ) { 975b8baf385SIngo Weinhold isfile = true ; 976b8baf385SIngo Weinhold } 9774236d490SIngo Weinhold } 9784236d490SIngo Weinhold if $(isfile) { 9799eea4522SIngo Weinhold NEEDLIBS on $(1) = [ on $(1) return $(NEEDLIBS) ] $(i) ; 9809eea4522SIngo Weinhold Depends $(1) : $(i) ; 9814236d490SIngo Weinhold } else { 9829eea4522SIngo Weinhold LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] -l$(i) ; 98352a38012Sejakowatz } 98452a38012Sejakowatz } 98552a38012Sejakowatz} 98652a38012Sejakowatz 98752a38012Sejakowatzrule AddResources 98852a38012Sejakowatz{ 98952a38012Sejakowatz # AddResources <name> : <resourcefiles> ; 99052a38012Sejakowatz 9918d3308d9SIngo Weinhold local resfiles = [ FGristFiles $(2) ] ; 9928d3308d9SIngo Weinhold SEARCH on $(resfiles) += $(SEARCH_SOURCE) ; 9938d3308d9SIngo Weinhold 9948d3308d9SIngo Weinhold for file in $(resfiles) { 9958d3308d9SIngo Weinhold if $(file:S) = .rdef { 9968d3308d9SIngo Weinhold local rdef = $(file) ; 9978d3308d9SIngo Weinhold file = $(rdef:S=.rsrc) ; 9988d3308d9SIngo Weinhold ResComp $(file) : $(rdef) ; 9998d3308d9SIngo Weinhold } 10008d3308d9SIngo Weinhold RESFILES on $(1) += $(file) ; 10018d3308d9SIngo Weinhold } 10028d3308d9SIngo Weinhold} 10038d3308d9SIngo Weinhold 10048d3308d9SIngo Weinholdrule ResComp 10058d3308d9SIngo Weinhold{ 10068d3308d9SIngo Weinhold # ResComp <resource file> : <rdef file> ; 10078d3308d9SIngo Weinhold # 10088d3308d9SIngo Weinhold # <resource file> and <rdef file> must be gristed. 10098d3308d9SIngo Weinhold 10108d3308d9SIngo Weinhold SetupObjectsDir ; 10118d3308d9SIngo Weinhold 10129fc6b2e1SIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 10138d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_TARGET) ; 10148d3308d9SIngo Weinhold Depends $(1) : $(2) rc ; 10158d3308d9SIngo Weinhold LocalClean clean : $(1) ; 10168d3308d9SIngo Weinhold ResComp1 $(1) : rc $(2) ; 10178d3308d9SIngo Weinhold} 10188d3308d9SIngo Weinhold 10198d3308d9SIngo Weinholdactions ResComp1 10208d3308d9SIngo Weinhold{ 10216af76074SIngo Weinhold $(2[1]) -o $(1) $(2[2-]) 102252a38012Sejakowatz} 102352a38012Sejakowatz 1024728b5725SIngo Weinholdrule ObjectsDefines 1025728b5725SIngo Weinhold{ 1026728b5725SIngo Weinhold # Like ObjectDefines, but allows multiple files to be supplied 1027728b5725SIngo Weinhold local file ; 1028728b5725SIngo Weinhold for file in $(1) { 1029728b5725SIngo Weinhold ObjectDefines $(file) : $(2) ; 1030728b5725SIngo Weinhold } 1031728b5725SIngo Weinhold} 1032728b5725SIngo Weinhold 10339b60a208SIngo Weinholdrule SourceHdrs 10349b60a208SIngo Weinhold{ 10359b60a208SIngo Weinhold # SourceHdrs <sources> : <headers> [ : <gristed objects> ] ; 10369b60a208SIngo Weinhold # 10379b60a208SIngo Weinhold # Is a wrapper for ObjectHdrs, that passes <sources> and <headers> or, 10389b60a208SIngo Weinhold # if supplied <objects> and <headers>, and also adjusts HDRSEARCH (not 10399b60a208SIngo Weinhold # done by ObjectHdrs). 10409b60a208SIngo Weinhold 10419b60a208SIngo Weinhold local sources = [ FGristFiles $(1) ] ; 10429b60a208SIngo Weinhold local headers = $(2) ; 10439b60a208SIngo Weinhold local objects = $(3) ; 10449b60a208SIngo Weinhold 1045728b5725SIngo Weinhold local file ; 10469b60a208SIngo Weinhold if $(objects) { 1047728b5725SIngo Weinhold for file in $(objects) { 1048728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 1049c0e501e0SIngo Weinhold # also reformat the assembler headers 1050c0e501e0SIngo Weinhold ASHDRS on $(file) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) 1051c0e501e0SIngo Weinhold [ on $(file) return $(HDRS) ] ] ; 1052728b5725SIngo Weinhold } 10539b60a208SIngo Weinhold } else { 1054081debe8SIngo Weinhold for file in $(sources:S=$(SUFOBJ)) { 1055728b5725SIngo Weinhold ObjectHdrs $(file) : $(headers) ; 1056c0e501e0SIngo Weinhold # also reformat the assembler headers 1057c0e501e0SIngo Weinhold ASHDRS on $(file) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) 1058c0e501e0SIngo Weinhold [ on $(file) return $(HDRS) ] ] ; 1059728b5725SIngo Weinhold } 10609b60a208SIngo Weinhold } 10619b60a208SIngo Weinhold 10629b60a208SIngo Weinhold # Also add the header search dirs to HDRSEARCH. Note, that these dirs 10639b60a208SIngo Weinhold # will be listed after the STDHDRS (if any), but that's better than not 10649b60a208SIngo Weinhold # being listed at all. 10659b60a208SIngo Weinhold HDRSEARCH on $(sources) += $(headers) ; 10669b60a208SIngo Weinhold} 10679b60a208SIngo Weinhold 10687d7f280eSIngo Weinholdrule PublicHeaders 106952a38012Sejakowatz{ 10707d7f280eSIngo Weinhold # PublicHeaders <group list> 107152a38012Sejakowatz # 10727d7f280eSIngo Weinhold # Returns the directory names for the public header dirs identified by 10737d7f280eSIngo Weinhold # <group list>. 107452a38012Sejakowatz 107552a38012Sejakowatz local list = $(1) ; 1076b005dbe3SAxel Dörfler local dirs = [ FDirName $(OBOS_TOP) headers os ] ; 1077b005dbe3SAxel Dörfler 107852a38012Sejakowatz for i in $(list) { 10797d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers os $(i) ] ; 10807d7f280eSIngo Weinhold } 10817d7f280eSIngo Weinhold return $(dirs) ; 108252a38012Sejakowatz} 108352a38012Sejakowatz 10847d7f280eSIngo Weinholdrule PrivateHeaders 10857d7f280eSIngo Weinhold{ 10867d7f280eSIngo Weinhold # PrivateHeaders <group list> 10877d7f280eSIngo Weinhold # 10887d7f280eSIngo Weinhold # Returns the directory names for the private header dirs identified by 10897d7f280eSIngo Weinhold # <group list>. 10907d7f280eSIngo Weinhold 10917d7f280eSIngo Weinhold local list = $(1) ; 10927d7f280eSIngo Weinhold local dirs ; 10937d7f280eSIngo Weinhold for i in $(list) { 10947d7f280eSIngo Weinhold dirs += [ FDirName $(OBOS_TOP) headers private $(i) ] ; 10957d7f280eSIngo Weinhold } 10967d7f280eSIngo Weinhold return $(dirs) ; 10977d7f280eSIngo Weinhold} 10987d7f280eSIngo Weinhold 10990f434a0aSDarkWyrmrule LibraryHeaders 11000f434a0aSDarkWyrm{ 11010f434a0aSDarkWyrm # LibraryHeaders <group list> 11020f434a0aSDarkWyrm # 11030f434a0aSDarkWyrm # Returns the directory names for the library header dirs identified by 11040f434a0aSDarkWyrm # <group list>. 11050f434a0aSDarkWyrm 11060f434a0aSDarkWyrm local list = $(1) ; 11070f434a0aSDarkWyrm local dirs ; 11080f434a0aSDarkWyrm for i in $(list) { 11090f434a0aSDarkWyrm dirs += [ FDirName $(OBOS_TOP) headers libs $(i) ] ; 11100f434a0aSDarkWyrm } 11110f434a0aSDarkWyrm return $(dirs) ; 11120f434a0aSDarkWyrm} 11130f434a0aSDarkWyrm 11147d7f280eSIngo Weinholdrule ArchHeaders 11157d7f280eSIngo Weinhold{ 11167d7f280eSIngo Weinhold # usage: ArchHeaders <arch> ; 11177d7f280eSIngo Weinhold # 11187d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 11197d7f280eSIngo Weinhold 11207d7f280eSIngo Weinhold return [ FDirName $(OBOS_TOP) headers private kernel arch $(1) ] ; 11217d7f280eSIngo Weinhold} 11227d7f280eSIngo Weinhold 11237d7f280eSIngo Weinholdrule UsePublicHeaders 11247d7f280eSIngo Weinhold{ 1125966528dcSIngo Weinhold # UsePublicHeaders <group list> ; 1126966528dcSIngo Weinhold # 1127966528dcSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 1128966528dcSIngo Weinhold # dirs of the subdirectory. 1129966528dcSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the 1130966528dcSIngo Weinhold # objects. 1131966528dcSIngo Weinhold 1132966528dcSIngo Weinhold UseHeaders [ PublicHeaders $(1) ] ; 11337d7f280eSIngo Weinhold} 11347d7f280eSIngo Weinhold 11357d7f280eSIngo Weinholdrule UsePublicObjectHeaders 11367d7f280eSIngo Weinhold{ 11379b60a208SIngo Weinhold # UsePublicObjectHeaders <sources> : <group list> [ : <objects> ] ; 11387d7f280eSIngo Weinhold # 11397d7f280eSIngo Weinhold # Adds the public C header dirs given by <group list> to the header search 11409b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 11419b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 11427d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 11437d7f280eSIngo Weinhold 11449b60a208SIngo Weinhold SourceHdrs $(1) : [ PublicHeaders $(2) ] : $(3) ; 114552a38012Sejakowatz} 114652a38012Sejakowatz 114752a38012Sejakowatzrule UsePrivateHeaders 114852a38012Sejakowatz{ 11497d7f280eSIngo Weinhold # UsePrivateHeaders <group list> ; 115052a38012Sejakowatz # 115152a38012Sejakowatz # Adds the private C header dirs given by <group list> to the header search 11527d7f280eSIngo Weinhold # dirs of the subdirectory. 11537d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 115452a38012Sejakowatz 11557d7f280eSIngo Weinhold UseHeaders [ PrivateHeaders $(1) ] ; 115652a38012Sejakowatz} 115752a38012Sejakowatz 11587d7f280eSIngo Weinholdrule UsePrivateObjectHeaders 11597d7f280eSIngo Weinhold{ 11609b60a208SIngo Weinhold # UsePrivateObjectHeaders <sources> : <group list> [ : <objects> ] ; 11617d7f280eSIngo Weinhold # 11627d7f280eSIngo Weinhold # Adds the private C header dirs given by <group list> to the header search 11639b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 11649b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 11657d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 11667d7f280eSIngo Weinhold 11679b60a208SIngo Weinhold SourceHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; 116852a38012Sejakowatz} 116952a38012Sejakowatz 117052a38012Sejakowatzrule UseHeaders 117152a38012Sejakowatz{ 11727d7f280eSIngo Weinhold # UseHeaders <headers> ; 117352a38012Sejakowatz # 117452a38012Sejakowatz # Adds the C header dirs <headers> to the header search 11757d7f280eSIngo Weinhold # dirs of the subdirectory. 11767d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 117752a38012Sejakowatz 11787d7f280eSIngo Weinhold local header ; 11797d7f280eSIngo Weinhold for header in $(1) { 118052a38012Sejakowatz SubDirHdrs $(header) ; 118152a38012Sejakowatz } 118252a38012Sejakowatz} 118352a38012Sejakowatz 118452a38012Sejakowatzrule UseCppUnitHeaders 118552a38012Sejakowatz{ 11867d7f280eSIngo Weinhold SubDirHdrs [ FDirName $(OBOS_TOP) headers tools cppunit ] ; 118752a38012Sejakowatz} 118852a38012Sejakowatz 1189be5af1baSIngo Weinholdrule UseCppUnitObjectHeaders 1190be5af1baSIngo Weinhold{ 11919b60a208SIngo Weinhold # UseCppUnitObjectHeaders <sources> [ : <objects> ] ; 11929b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers tools cppunit ] : $(2) ; 1193be5af1baSIngo Weinhold} 1194be5af1baSIngo Weinhold 119552a38012Sejakowatzrule UseArchHeaders 119652a38012Sejakowatz{ 11977d7f280eSIngo Weinhold # usage: UseArchHeaders <arch> ; 11987d7f280eSIngo Weinhold # 119952a38012Sejakowatz # <arch> specifies the architecture (e.g. x86). 12007d7f280eSIngo Weinhold # NOTE: This rule must be invoked *before* the rule that builds the objects. 12017d7f280eSIngo Weinhold 12027d7f280eSIngo Weinhold local headers = [ ArchHeaders $(1) ] ; 120352a38012Sejakowatz local opt = -D$(OBOS_TARGET_DEFINE) ; 1204c633961aSIngo Weinhold 120552a38012Sejakowatz SubDirCcFlags $(opt) ; 120652a38012Sejakowatz SubDirC++Flags $(opt) ; 1207089a0629Sbeveloper HDRS += $(headers) ; 1208c633961aSIngo Weinhold} 1209c633961aSIngo Weinhold 12107d7f280eSIngo Weinholdrule UseArchObjectHeaders 12117d7f280eSIngo Weinhold{ 12129b60a208SIngo Weinhold # usage: UseArchObjectHeaders <sources> : <arch> : [ <objects> ] ; 12137d7f280eSIngo Weinhold # 12147d7f280eSIngo Weinhold # <arch> specifies the architecture (e.g. x86). 12157d7f280eSIngo Weinhold # <sources_or_objects> Source or object files. 12167d7f280eSIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 12177d7f280eSIngo Weinhold 12189b60a208SIngo Weinhold local sources = $(1) ; 12197d7f280eSIngo Weinhold local headers = [ ArchHeaders $(2) ] ; 12209b60a208SIngo Weinhold local objects = $(3) ; 12219b60a208SIngo Weinhold local targets ; 12229b60a208SIngo Weinhold if $(objects) { 12239b60a208SIngo Weinhold targets = $(objects) ; 12249b60a208SIngo Weinhold } else { 1225081debe8SIngo Weinhold targets = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 12269b60a208SIngo Weinhold } 12277d7f280eSIngo Weinhold local opt = -D$(OBOS_TARGET_DEFINE) ; 12287d7f280eSIngo Weinhold 12297d7f280eSIngo Weinhold ObjectCcFlags $(targets) : $(opt) ; 12307d7f280eSIngo Weinhold ObjectC++Flags $(targets) : $(opt) ; 12319b60a208SIngo Weinhold SourceHdrs $(sources) : $(headers) : $(objects) ; 123252a38012Sejakowatz} 123352a38012Sejakowatz 1234d25a77b4SIngo Weinholdrule UsePosixHeaders 1235d25a77b4SIngo Weinhold{ 1236a6c008e1Sbeveloper # XXX changed to do nothing 1237d25a77b4SIngo Weinhold} 1238d25a77b4SIngo Weinhold 1239d25a77b4SIngo Weinholdrule UsePosixObjectHeaders 1240d25a77b4SIngo Weinhold{ 12419b60a208SIngo Weinhold # UsePosixObjectHeaders <sources> [ : <objects> ] ; 1242d25a77b4SIngo Weinhold # 1243d25a77b4SIngo Weinhold # Adds the POSIX header dir to the header search 12449b60a208SIngo Weinhold # dirs of either the object targets of <sources> or if supplied to 12459b60a208SIngo Weinhold # <objects>. Also adjusts HDRSEARCH of <sources>. 1246d25a77b4SIngo Weinhold # NOTE: This rule must be invoked *after* the rule that builds the objects. 1247d25a77b4SIngo Weinhold 12489b60a208SIngo Weinhold SourceHdrs $(1) : [ FDirName $(OBOS_TOP) headers posix ] : $(2) ; 1249d25a77b4SIngo Weinhold} 1250d25a77b4SIngo Weinhold 12510f434a0aSDarkWyrmrule UseLibraryHeaders 12520f434a0aSDarkWyrm{ 12530f434a0aSDarkWyrm # UseLibraryHeaders <group list> ; 12540f434a0aSDarkWyrm # 12550f434a0aSDarkWyrm # Adds the library header dirs given by <group list> to the header search 12560f434a0aSDarkWyrm # dirs of the subdirectory. 12570f434a0aSDarkWyrm # NOTE: This rule must be invoked *before* the rule that builds the objects. 12580f434a0aSDarkWyrm 12590f434a0aSDarkWyrm UseHeaders [ LibraryHeaders $(1) ] ; 12600f434a0aSDarkWyrm} 12610f434a0aSDarkWyrm 12623b9eae39SIngo Weinholdrule SplitPath 12633b9eae39SIngo Weinhold{ 12643b9eae39SIngo Weinhold # SplitPath <path> ; 12653b9eae39SIngo Weinhold # Decomposes a path into its components. 12663b9eae39SIngo Weinhold local path = $(1:G=) ; 12673b9eae39SIngo Weinhold local components ; 12688c27f58dSIngo Weinhold # $(path:D) for "/" is "/". Therefore the second condition. 12698c27f58dSIngo Weinhold while $(path:D) && $(path:D) != $(path) 12703b9eae39SIngo Weinhold { 12713b9eae39SIngo Weinhold # Note: $(path:B) returns "." for "..", but $(path:D=) is fine. 12723b9eae39SIngo Weinhold components = $(path:D=) $(components) ; 12733b9eae39SIngo Weinhold path = $(path:D) ; 12743b9eae39SIngo Weinhold } 12753b9eae39SIngo Weinhold components = $(path) $(components) ; 12763b9eae39SIngo Weinhold return $(components) ; 12773b9eae39SIngo Weinhold} 12783b9eae39SIngo Weinhold 12799fc6b2e1SIngo Weinholdrule PrependObjectHdrs 12809fc6b2e1SIngo Weinhold{ 12819fc6b2e1SIngo Weinhold # PrependObjectHdrs <objects_or_sources> : <dirs> ; 12829fc6b2e1SIngo Weinhold # Prepends <dirs> to the list of header search dirs of the objects 12839fc6b2e1SIngo Weinhold # specified by <objects_or_sources>. The HDRS variable will not be 12849fc6b2e1SIngo Weinhold # changed, only CCHDRS. 12859fc6b2e1SIngo Weinhold # Note: A subsequent ObjectHdrs invocation will therefore undo the 12869fc6b2e1SIngo Weinhold # effect of this rule. 12879fc6b2e1SIngo Weinhold # NOTE: This is a hack. 12889fc6b2e1SIngo Weinhold 12899fc6b2e1SIngo Weinhold local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] ; 12909fc6b2e1SIngo Weinhold local dirs = $(2) ; 12919fc6b2e1SIngo Weinhold for object in $(objects) { 12929fc6b2e1SIngo Weinhold # Don't change HDRS to avoid screwing up the header scanning. 12939fc6b2e1SIngo Weinhold PREPENDED_HDRS on $(object) 12949fc6b2e1SIngo Weinhold = $(dirs) [ on $(object) return $(PREPENDED_HDRS) ] ; 12959fc6b2e1SIngo Weinhold CCHDRS on $(object) 12969fc6b2e1SIngo Weinhold = [ FIncludes [ on $(object) return $(PREPENDED_HDRS) $(HDRS) ] ] ; 12979fc6b2e1SIngo Weinhold } 12989fc6b2e1SIngo Weinhold} 12999fc6b2e1SIngo Weinhold 13003b9eae39SIngo Weinholdrule SymLink 13013b9eae39SIngo Weinhold{ 13027669b69fSIngo Weinhold # SymLink <target> : <source> : <makeDefaultDependencies> ; 13033b9eae39SIngo Weinhold # Links <target> to <source>. 13043b9eae39SIngo Weinhold # <source> is the exact link contents. No binding is done. 13057669b69fSIngo Weinhold # <makeDefaultDependencies> If true, <target> will be made a dependency 13067669b69fSIngo Weinhold # of the `all' pseudo target, i.e. it will be made by default, and removed 13077669b69fSIngo Weinhold # on `jam clean'. 13087669b69fSIngo Weinhold 13097669b69fSIngo Weinhold local target = $(1) ; 13107669b69fSIngo Weinhold local source = $(2) ; 13117669b69fSIngo Weinhold local makeDefaultDependencies = $(3) ; 13127669b69fSIngo Weinhold if ! $(makeDefaultDependencies) { 13137669b69fSIngo Weinhold makeDefaultDependencies = true ; 13147669b69fSIngo Weinhold } 13157669b69fSIngo Weinhold LINKCONTENTS on $(target) = $(source) ; 13167669b69fSIngo Weinhold SymLink1 $(target) ; 13177669b69fSIngo Weinhold if $(makeDefaultDependencies) = true { 13187669b69fSIngo Weinhold LocalDepends files : $(target) ; 13197669b69fSIngo Weinhold LocalClean clean : $(target) ; 13207669b69fSIngo Weinhold } 13213b9eae39SIngo Weinhold} 13223b9eae39SIngo Weinhold 13233b9eae39SIngo Weinholdactions SymLink1 13243b9eae39SIngo Weinhold{ 13250931b8f9SIngo Weinhold $(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)" 13260931b8f9SIngo Weinhold} 13270931b8f9SIngo Weinhold 13280931b8f9SIngo Weinholdrule RelSymLink 13290931b8f9SIngo Weinhold{ 13307669b69fSIngo Weinhold # RelSymLink <link> : <link target> : <makeDefaultDependencies> ; 13310931b8f9SIngo Weinhold # Creates a relative symbolic link from <link> to <link target>. 13320931b8f9SIngo Weinhold # <link> and <link target> can be usual targets. They may have a grist 13330931b8f9SIngo Weinhold # and don't need to have any dirname. Their LOCATE variables are used to 13340931b8f9SIngo Weinhold # find their locations. 13357669b69fSIngo Weinhold # <makeDefaultDependencies> If true (which is the default), <link> will be 13367669b69fSIngo Weinhold # made a dependency of the `files' pseudo target, i.e. it will be made by 13377669b69fSIngo Weinhold # default, and removed on `jam clean'. 13380931b8f9SIngo Weinhold 13390931b8f9SIngo Weinhold local target = $(1) ; 13400931b8f9SIngo Weinhold local source = $(2) ; 13417669b69fSIngo Weinhold local makeDefaultDependencies = $(3) ; 13420931b8f9SIngo Weinhold local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ; 13430931b8f9SIngo Weinhold local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ; 13440931b8f9SIngo Weinhold local sourcePath = $(source:G=) ; 13450931b8f9SIngo Weinhold sourcePath = $(sourcePath:D=$(sourceDir)) ; 13460931b8f9SIngo Weinhold local targetDirComponents = [ SplitPath $(targetDir) ] ; 13470931b8f9SIngo Weinhold local sourceComponents = [ SplitPath $(sourcePath) ] ; 13480931b8f9SIngo Weinhold 13490931b8f9SIngo Weinhold SymLink $(target) 13507669b69fSIngo Weinhold : [ FRelPath $(targetDirComponents) : $(sourceComponents) ] 13517669b69fSIngo Weinhold : $(makeDefaultDependencies) ; 13520931b8f9SIngo Weinhold NOUPDATE $(target) ; 13539eea4522SIngo Weinhold Depends $(target) : $(source) ; 13543b9eae39SIngo Weinhold} 13553b9eae39SIngo Weinhold 1356d391d2ebSIngo Weinholdrule AbsSymLink 1357d391d2ebSIngo Weinhold{ 13587bc56df1SIngo Weinhold # AbsSymLink <link> : <link target> : <link dir> 13597669b69fSIngo Weinhold # : <makeDefaultDependencies> ; 1360d391d2ebSIngo Weinhold # Creates an absolute symbolic link from <link> to <link target>. 1361d391d2ebSIngo Weinhold # <link> and <link target> must be usual targets. If <link dir> is 1362d391d2ebSIngo Weinhold # given, then it is set as LOCATE directory on <link>. 13637669b69fSIngo Weinhold # <makeDefaultDependencies> If true (which is the default), <link> will be 13647669b69fSIngo Weinhold # made a dependency of the `files' pseudo target, i.e. it will be made by 13657669b69fSIngo Weinhold # default, and removed on `jam clean'. 1366d391d2ebSIngo Weinhold 13677669b69fSIngo Weinhold local makeDefaultDependencies = $(4) ; 13687669b69fSIngo Weinhold if ! $(makeDefaultDependencies) { 13697669b69fSIngo Weinhold makeDefaultDependencies = true ; 13707669b69fSIngo Weinhold } 13717669b69fSIngo Weinhold 1372d391d2ebSIngo Weinhold Depends $(1) : $(2) ; 1373d391d2ebSIngo Weinhold if $(3) { 1374d391d2ebSIngo Weinhold MakeLocate $(1) : $(3) ; 1375d391d2ebSIngo Weinhold } 1376d391d2ebSIngo Weinhold SEARCH on $(2) += $(SEARCH_SOURCE) ; 13777669b69fSIngo Weinhold if $(makeDefaultDependencies) = true { 13787669b69fSIngo Weinhold LocalDepends files : $(1) ; 1379d391d2ebSIngo Weinhold LocalClean clean : $(1) ; 1380d391d2ebSIngo Weinhold } 13817669b69fSIngo Weinhold} 1382d391d2ebSIngo Weinhold 1383d391d2ebSIngo Weinholdactions AbsSymLink 1384d391d2ebSIngo Weinhold{ 1385d391d2ebSIngo Weinhold target="$(2)" 1386d391d2ebSIngo Weinhold case "$target" in 1387d391d2ebSIngo Weinhold /*) ;; 1388d391d2ebSIngo Weinhold *) target=`pwd`/"$target";; 1389d391d2ebSIngo Weinhold esac 1390d391d2ebSIngo Weinhold $(RM) "$(1)" && $(LN) -s "$target" "$(1)" 1391d391d2ebSIngo Weinhold} 1392d391d2ebSIngo Weinhold 13937bc56df1SIngo Weinholdrule OBOSInstall 13947bc56df1SIngo Weinhold{ 13957bc56df1SIngo Weinhold # Usage: OBOSInstall <[ install [ and uninstall ] pseudotarget ]> 13967bc56df1SIngo Weinhold # : <directory> : <sources to install> 13977bc56df1SIngo Weinhold # : [ <installgrist> ] : [ <install rule> ] ; 13987bc56df1SIngo Weinhold local install = $(1[1]) ; 13997bc56df1SIngo Weinhold install ?= install ; 14007bc56df1SIngo Weinhold local uninstall = $(1[2]) ; 14017bc56df1SIngo Weinhold uninstall ?= un$(install) ; 14027bc56df1SIngo Weinhold local dir = $(2) ; 14037bc56df1SIngo Weinhold local sources = $(3) ; 14047bc56df1SIngo Weinhold local installgrist = $(4) ; 14057bc56df1SIngo Weinhold installgrist ?= $(INSTALLGRIST) ; 14067bc56df1SIngo Weinhold local installRule = $(5) ; 14077bc56df1SIngo Weinhold installRule ?= Install ; 14087bc56df1SIngo Weinhold local targets = $(sources:G=$(installgrist)) ; 14097bc56df1SIngo Weinhold 1410bacf6872Sshatty NotFile $(install) ; 1411bacf6872Sshatty NotFile $(uninstall) ; 14127bc56df1SIngo Weinhold Depends $(install) : $(targets) ; 14137bc56df1SIngo Weinhold Clean $(uninstall) : $(targets) ; 14147bc56df1SIngo Weinhold 14157bc56df1SIngo Weinhold SEARCH on $(sources) += $(SEARCH_SOURCE) ; 14167bc56df1SIngo Weinhold MakeLocate $(targets) : $(dir) ; 14177bc56df1SIngo Weinhold 14187bc56df1SIngo Weinhold local source ; 14197bc56df1SIngo Weinhold for source in $(sources) { 14207bc56df1SIngo Weinhold local target = $(source:G=$(installgrist)) ; 14217bc56df1SIngo Weinhold 14227bc56df1SIngo Weinhold Depends $(target) : $(source) ; 14237bc56df1SIngo Weinhold $(installRule) $(target) : $(source) ; 14247bc56df1SIngo Weinhold 14257bc56df1SIngo Weinhold if [ on $(target) return $(MODE) ] { 14267bc56df1SIngo Weinhold Chmod $(target) ; 14277bc56df1SIngo Weinhold } 14287bc56df1SIngo Weinhold 14297bc56df1SIngo Weinhold if $(OWNER) && $(CHOWN) { 14307bc56df1SIngo Weinhold Chown $(target) ; 14317bc56df1SIngo Weinhold OWNER on $(target) = $(OWNER) ; 14327bc56df1SIngo Weinhold } 14337bc56df1SIngo Weinhold 14347bc56df1SIngo Weinhold if $(GROUP) && $(CHGRP) { 14357bc56df1SIngo Weinhold Chgrp $(target) ; 14367bc56df1SIngo Weinhold GROUP on $(target) = $(GROUP) ; 14377bc56df1SIngo Weinhold } 14387bc56df1SIngo Weinhold } 14397bc56df1SIngo Weinhold} 14407bc56df1SIngo Weinhold 14417669b69fSIngo Weinholdrule InstallAbsSymLinkAdapter 14427669b69fSIngo Weinhold{ 14437669b69fSIngo Weinhold # InstallAbsSymLinkAdapter <link> : <link target> 14447669b69fSIngo Weinhold if ! [ on $(2) return $(TARGET) ] { 14457669b69fSIngo Weinhold TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; 14467669b69fSIngo Weinhold } 14477669b69fSIngo Weinhold AbsSymLink $(1) : $(2) : : false ; 14487669b69fSIngo Weinhold} 14497669b69fSIngo Weinhold 14507bc56df1SIngo Weinholdrule OBOSInstallAbsSymLink 14517bc56df1SIngo Weinhold{ 14527bc56df1SIngo Weinhold # Usage: OBOSInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]> 14537bc56df1SIngo Weinhold # : <directory> : <sources to install> 14547bc56df1SIngo Weinhold # : [ <installgrist> ] ; 14557669b69fSIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallAbsSymLinkAdapter ; 14567bc56df1SIngo Weinhold} 14577bc56df1SIngo Weinhold 14587bc56df1SIngo Weinholdrule InstallRelSymLinkAdapter 14597bc56df1SIngo Weinhold{ 14607bc56df1SIngo Weinhold # InstallRelSymLinkAdapter <link> : <link target> 14617bc56df1SIngo Weinhold if ! [ on $(2) return $(TARGET) ] { 14627bc56df1SIngo Weinhold TARGET on $(2) = [ on $(2) return $(SEARCH) ] ; 14637bc56df1SIngo Weinhold } 14647669b69fSIngo Weinhold RelSymLink $(1) : $(2) : false ; 14657bc56df1SIngo Weinhold} 14667bc56df1SIngo Weinhold 14677bc56df1SIngo Weinholdrule OBOSInstallRelSymLink 14687bc56df1SIngo Weinhold{ 14697bc56df1SIngo Weinhold # Usage: OBOSInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]> 14707bc56df1SIngo Weinhold # : <directory> : <sources to install> 14717bc56df1SIngo Weinhold # : [ <installgrist> ] ; 14727bc56df1SIngo Weinhold OBOSInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ; 14737bc56df1SIngo Weinhold} 14747bc56df1SIngo Weinhold 14757bc56df1SIngo Weinhold 147652a38012Sejakowatz#------------------------------------------------------------------------------- 147752a38012Sejakowatz# Low-level OBOS utility rules 147852a38012Sejakowatz#------------------------------------------------------------------------------- 147979b49834SIngo Weinholdrule FObjectsDir 148079b49834SIngo Weinhold{ 1481121af366SIngo Weinhold # FObjectsDir <subdir tokens> 1482121af366SIngo Weinhold # 1483121af366SIngo Weinhold # Returns the output directory for object files the specified 1484121af366SIngo Weinhold # subdirectory. 1485121af366SIngo Weinhold # 1486121af366SIngo Weinhold # <subdir tokens>: The tokens of the subdir relative to the top. 1487121af366SIngo Weinhold # 1488121af366SIngo Weinhold 1489121af366SIngo Weinhold return [ FDirName $(OBOS_OBJECT_TARGET) $(1[2-]) ] ; 1490121af366SIngo Weinhold} 1491121af366SIngo Weinhold 1492121af366SIngo Weinholdrule FCurrentObjectsDir 1493121af366SIngo Weinhold{ 1494121af366SIngo Weinhold # FCurrentObjectsDir 149579b49834SIngo Weinhold # 149679b49834SIngo Weinhold # Returns the output directory for object files for the current 149779b49834SIngo Weinhold # subdirectory. 149879b49834SIngo Weinhold 1499121af366SIngo Weinhold return [ FObjectsDir $(SUBDIR_TOKENS) ] ; 150079b49834SIngo Weinhold} 150179b49834SIngo Weinhold 150252a38012Sejakowatzrule SetupObjectsDir 150352a38012Sejakowatz{ 1504121af366SIngo Weinhold LOCATE_TARGET = [ FCurrentObjectsDir ] ; 15058d3308d9SIngo Weinhold LOCATE_SOURCE = $(LOCATE_TARGET) ; 15068d3308d9SIngo Weinhold SEARCH_SOURCE = [ Filter $(SEARCH_SOURCE) : $(LOCATE_TARGET) ] 15078d3308d9SIngo Weinhold $(LOCATE_TARGET) ; 150852a38012Sejakowatz} 150952a38012Sejakowatz 151052a38012Sejakowatz#------------------------------------------------------------------------------- 151152a38012Sejakowatz# Link rule/action are overwritten as they don't handle linking files who's name 151252a38012Sejakowatz# contain spaces very well. Also adds resources and version to executable. 151352a38012Sejakowatz#------------------------------------------------------------------------------- 151452a38012Sejakowatzrule Link 151552a38012Sejakowatz{ 151652a38012Sejakowatz # Note: RESFILES must be set before invocation. 151752a38012Sejakowatz MODE on $(<) = $(EXEMODE) ; 151852a38012Sejakowatz on $(1) XRes $(1) : $(RESFILES) ; 151952a38012Sejakowatz Chmod $(<) ; 152052a38012Sejakowatz SetType $(1) ; 152152a38012Sejakowatz MimeSet $(1) ; 15221419ae2bSshatty SetVersion $(1) ; 152352a38012Sejakowatz} 152452a38012Sejakowatz 152552a38012Sejakowatzactions Link bind NEEDLIBS 152652a38012Sejakowatz{ 15271eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) "$(2)" "$(NEEDLIBS)" $(LINKLIBS) ; 152852a38012Sejakowatz} 152952a38012Sejakowatz 15308d3308d9SIngo Weinholdrule LexC++ 15318d3308d9SIngo Weinhold{ 15328d3308d9SIngo Weinhold Depends $(1) : $(2) ; 15338d3308d9SIngo Weinhold MakeLocate $(1) : $(LOCATE_SOURCE) ; 15348d3308d9SIngo Weinhold LocalClean clean : $(1) ; 15358d3308d9SIngo Weinhold} 15368d3308d9SIngo Weinhold 15378d3308d9SIngo Weinholdactions LexC++ 15388d3308d9SIngo Weinhold{ 15398d3308d9SIngo Weinhold $(LEX) -o$(1) $(2) 15408d3308d9SIngo Weinhold} 15418d3308d9SIngo Weinhold 15428d3308d9SIngo Weinholdrule Bison 15438d3308d9SIngo Weinhold{ 15448d3308d9SIngo Weinhold local _h ; 15458d3308d9SIngo Weinhold 1546cec8c8b5SJérôme Duval _h = $(1:S=.hpp) ; 15478d3308d9SIngo Weinhold 15488d3308d9SIngo Weinhold MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ; 15498d3308d9SIngo Weinhold 15508d3308d9SIngo Weinhold Depends $(<) $(_h) : $(>) ; 15518d3308d9SIngo Weinhold Bison1 $(<) $(_h) : $(>) ; 15528d3308d9SIngo Weinhold LocalClean clean : $(<) $(_h) ; 15538d3308d9SIngo Weinhold 15548d3308d9SIngo Weinhold # make sure someone includes $(_h) else it will be 15558d3308d9SIngo Weinhold # a deadly independent target 15568d3308d9SIngo Weinhold 15578d3308d9SIngo Weinhold Includes $(<) : $(_h) ; 15588d3308d9SIngo Weinhold} 15598d3308d9SIngo Weinhold 15608d3308d9SIngo Weinholdactions Bison1 15618d3308d9SIngo Weinhold{ 15628d3308d9SIngo Weinhold bison $(YACCFLAGS) -o $(1[1]) $(2) 1563cec8c8b5SJérôme Duval [ -f $(1[1]).h ] && mv $(1[1]).h $(1[2]) || true 15648d3308d9SIngo Weinhold} 15658d3308d9SIngo Weinhold 1566705fc998SAxel Dörflerrule UnarchiveObjects 1567705fc998SAxel Dörfler{ 1568705fc998SAxel Dörfler # UnarchiveObjects <target objects> : <static object> 1569705fc998SAxel Dörfler 1570705fc998SAxel Dörfler MakeLocate $(1) : $(LOCATE_TARGET) ; 1571705fc998SAxel Dörfler Depends $(2) : $(1) ; 1572705fc998SAxel Dörfler SEARCH on $(2) = $(SEARCH_SOURCE) ; 1573705fc998SAxel Dörfler} 1574705fc998SAxel Dörfler 1575705fc998SAxel Dörfleractions UnarchiveObjects 1576705fc998SAxel Dörfler{ 15773c71865aSAxel Dörfler cd $(1[1]:D) 15783c71865aSAxel Dörfler ar -x "$(2)" $(1:B).o 1579705fc998SAxel Dörfler cd - 1580705fc998SAxel Dörfler} 1581705fc998SAxel Dörfler 158252a38012Sejakowatz# BeOS specific rules 158352a38012Sejakowatz 158452a38012Sejakowatzrule XRes 158552a38012Sejakowatz{ 158652a38012Sejakowatz # XRes <target> : <resource files> 158752a38012Sejakowatz if $(2) 158852a38012Sejakowatz { 15899eea4522SIngo Weinhold Depends $(1) : $(2) ; 159052a38012Sejakowatz XRes1 $(1) : $(2) ; 159152a38012Sejakowatz } 159252a38012Sejakowatz} 159352a38012Sejakowatz 159452a38012Sejakowatzrule XRes1 { } 159552a38012Sejakowatz 159652a38012Sejakowatzrule SetVersion 159752a38012Sejakowatz{ 159852a38012Sejakowatz # SetVersion <target> 159952a38012Sejakowatz} 160052a38012Sejakowatz 160152a38012Sejakowatzrule SetType 160252a38012Sejakowatz{ 160352a38012Sejakowatz # SetType <target> 160452a38012Sejakowatz} 160552a38012Sejakowatz 160652a38012Sejakowatzrule MimeSet 160752a38012Sejakowatz{ 160852a38012Sejakowatz # SetType <target> 160952a38012Sejakowatz} 161052a38012Sejakowatz 161152a38012Sejakowatz 161252a38012Sejakowatzif $(OS) = BEOS 161352a38012Sejakowatz{ 161452a38012Sejakowatz 161552a38012Sejakowatzactions XRes1 161652a38012Sejakowatz{ 16170931b8f9SIngo Weinhold xres -o "$(1)" "$(2)" ; 161852a38012Sejakowatz} 161952a38012Sejakowatz 162052a38012Sejakowatzactions SetVersion 162152a38012Sejakowatz{ 162252a38012Sejakowatz setversion "$(1)" -system $(OBOS_BUILD_VERSION) -short "$(OBOS_BUILD_DESCRIPTION)" ; 162352a38012Sejakowatz} 162452a38012Sejakowatz 162552a38012Sejakowatzactions SetType 162652a38012Sejakowatz{ 162752a38012Sejakowatz settype -t $(OBOS_TARGET_TYPE) "$(1)" ; 162852a38012Sejakowatz} 162952a38012Sejakowatz 163052a38012Sejakowatzactions MimeSet 163152a38012Sejakowatz{ 163252a38012Sejakowatz mimeset -f "$(1)" ; 163352a38012Sejakowatz} 163452a38012Sejakowatz 163552a38012Sejakowatz} # if BEOS 163652a38012Sejakowatz 163752a38012Sejakowatz 163852a38012Sejakowatzrule assemble 163952a38012Sejakowatz{ 164094782cf7SIngo Weinhold Depends $(<) : $(>) ; 164194782cf7SIngo Weinhold ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ; 164294782cf7SIngo Weinhold ASHDRS on $(<) = [ FIncludes $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ; 164352a38012Sejakowatz} 164452a38012Sejakowatz 164552a38012Sejakowatzactions assemble 164652a38012Sejakowatz{ 1647a8687de4SAxel Dörfler $(CC) -c "$(2)" -O2 $(ASFLAGS) -D_ASSEMBLER $(KERNEL_CCFLAGS) $(ASHDRS) -o "$(1)" ; 164852a38012Sejakowatz} 164952a38012Sejakowatz 16500931b8f9SIngo Weinhold# Overridden to allow spaces in file names. 16510931b8f9SIngo Weinholdactions Chmod1 16520931b8f9SIngo Weinhold{ 16530931b8f9SIngo Weinhold $(CHMOD) "$(MODE)" "$(1)" 16540931b8f9SIngo Weinhold} 16550931b8f9SIngo Weinhold 16566991af8cSIngo Weinhold# Overridden to allow spaces in file names. 16576991af8cSIngo Weinholdactions piecemeal together existing Clean 16586991af8cSIngo Weinhold{ 16596991af8cSIngo Weinhold $(RM) "$(>)" 16606991af8cSIngo Weinhold} 16616991af8cSIngo Weinhold 166208125d07SIngo Weinholdrule ObjectReference 166308125d07SIngo Weinhold{ 166408125d07SIngo Weinhold # ObjectReference <reference object> : <source object> 166508125d07SIngo Weinhold # Makes <reference object> refer to the same file as <source object>. 166608125d07SIngo Weinhold # The filenames must of course be identical. 166708125d07SIngo Weinhold # <source object> must have already been LOCATEd. 166808125d07SIngo Weinhold 166908125d07SIngo Weinhold local ref = $(1) ; 167008125d07SIngo Weinhold local source = $(2) ; 167108125d07SIngo Weinhold if $(ref) != $(source) { 16729eea4522SIngo Weinhold Depends $(ref) : $(source) ; 167321df5945SIngo Weinhold LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ; 167408125d07SIngo Weinhold } 167508125d07SIngo Weinhold} 167608125d07SIngo Weinhold 167708125d07SIngo Weinholdrule ObjectReferences 167808125d07SIngo Weinhold{ 167908125d07SIngo Weinhold # ObjectReferences <source objects> 168008125d07SIngo Weinhold # Creates local references to <source objects>, i.e. identifiers with the 168108125d07SIngo Weinhold # current grist referring to the same files. <source objects> must have 168208125d07SIngo Weinhold # already been LOCATEd. 168308125d07SIngo Weinhold 168408125d07SIngo Weinhold local source ; 168508125d07SIngo Weinhold for source in $(1) { 168608125d07SIngo Weinhold ObjectReference [ FGristFiles $(source) ] : $(source) ; 168708125d07SIngo Weinhold } 168808125d07SIngo Weinhold} 168908125d07SIngo Weinhold 16909fc6b2e1SIngo Weinholdrule Filter 16919fc6b2e1SIngo Weinhold{ 16929fc6b2e1SIngo Weinhold # Filter <list> : <excludes> ; 16939fc6b2e1SIngo Weinhold # Removes all occurrences of <excludes> in <list>. 16949fc6b2e1SIngo Weinhold 16959fc6b2e1SIngo Weinhold local list = $(1) ; 16969fc6b2e1SIngo Weinhold local excludes = $(2) ; 16979fc6b2e1SIngo Weinhold local newList ; 16989fc6b2e1SIngo Weinhold local item ; 16999fc6b2e1SIngo Weinhold for item in $(list) { 17009fc6b2e1SIngo Weinhold local skip ; 17019fc6b2e1SIngo Weinhold local exclude ; 17029fc6b2e1SIngo Weinhold for exclude in $(excludes) { 17039fc6b2e1SIngo Weinhold if $(item) = $(exclude) { 17049fc6b2e1SIngo Weinhold skip = true ; 17059fc6b2e1SIngo Weinhold } 17069fc6b2e1SIngo Weinhold } 17079fc6b2e1SIngo Weinhold if ! $(skip) { 1708dd9f8062SIngo Weinhold newList += $(item) ; 17099fc6b2e1SIngo Weinhold } 17109fc6b2e1SIngo Weinhold } 17119fc6b2e1SIngo Weinhold return $(newList) ; 17129fc6b2e1SIngo Weinhold} 17139fc6b2e1SIngo Weinhold 17140931b8f9SIngo Weinhold 171552a38012Sejakowatz## Kernel stuff! 171652a38012Sejakowatz 171752a38012Sejakowatzrule SetupKernel 171852a38012Sejakowatz{ 171952a38012Sejakowatz # Usage SetupKernel <sources_or_objects> : <extra_cc_flags>; 172094a49b21SIngo Weinhold # 172194a49b21SIngo Weinhold # <sources_or_objects> - Ideally sources, otherwise HDRSEARCH can not be 172294a49b21SIngo Weinhold # set for the sources and the sources some header 172394a49b21SIngo Weinhold # dependencies might be missing. 172452a38012Sejakowatz 172594a49b21SIngo Weinhold local sources = [ FGristFiles $(1) ] ; 172694a49b21SIngo Weinhold local _objs = $(sources:S=$(SUFOBJ)) ; 172752a38012Sejakowatz 172828d2a30eSDaniel Reinhold #Setup Kernel header directories 172999b8dab3SAxel Dörfler local public_kernel_includes = add-ons/file_system add-ons/graphics app device drivers kernel storage support ; 1730c0e501e0SIngo Weinhold local private_kernel_includes = $(DOT) kernel libroot kernel/boot/platform/$(OBOS_BOOT_PLATFORM) ; 1731a6c008e1Sbeveloper # Use posix headers directory 1732c0e501e0SIngo Weinhold local headers = [ FDirName $(OBOS_TOP) headers posix ] ; 1733a6c008e1Sbeveloper # Use public OS header directories 1734c0e501e0SIngo Weinhold headers += [ PublicHeaders $(public_kernel_includes) ] ; 1735089a0629Sbeveloper # Use private directories 1736c0e501e0SIngo Weinhold headers += [ PrivateHeaders $(private_kernel_includes) ] ; 173709c5682dSIngo Weinhold # The platform dependent headers. 1738c0e501e0SIngo Weinhold headers += $(PLATFORM_HEADERS) ; 1739a6c008e1Sbeveloper 174094a49b21SIngo Weinhold SourceHdrs $(sources) : $(headers) ; 174194a49b21SIngo Weinhold UseArchObjectHeaders $(sources) : $(OBOS_ARCH) ; 174252a38012Sejakowatz 1743c0e501e0SIngo Weinhold local object ; 1744c0e501e0SIngo Weinhold for object in $(_objs) { 1745c0e501e0SIngo Weinhold ObjectCcFlags $(object) : $(KERNEL_CCFLAGS) $(2) ; 1746c0e501e0SIngo Weinhold ObjectC++Flags $(object) : $(KERNEL_C++FLAGS) $(2) ; 1747c0e501e0SIngo Weinhold } 174852a38012Sejakowatz} 174952a38012Sejakowatz 175052a38012Sejakowatzrule KernelObjects 175152a38012Sejakowatz{ 1752c0e501e0SIngo Weinhold SetupObjectsDir ; 175352a38012Sejakowatz 175452a38012Sejakowatz Objects $(1) ; 1755c0e501e0SIngo Weinhold 1756c0e501e0SIngo Weinhold SetupKernel $(1) : $(2) ; 175752a38012Sejakowatz} 175852a38012Sejakowatz 175952a38012Sejakowatzrule KernelLd 176052a38012Sejakowatz{ 176180721244SAxel Dörfler # KernelLd <name> : <objs> : <linkerscript> : <args> : <gcc_off> : <config_section> ; 176252a38012Sejakowatz 1763c0e501e0SIngo Weinhold SetupObjectsDir ; 176452a38012Sejakowatz LINK on $(1) = ld ; 176552a38012Sejakowatz 176652a38012Sejakowatz LINKFLAGS on $(1) = $(4) ; 176752a38012Sejakowatz if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 176852a38012Sejakowatz 176952a38012Sejakowatz # Remove any preset LINKLIBS 177052a38012Sejakowatz LINKLIBS on $(1) = ; 177152a38012Sejakowatz 177252a38012Sejakowatz # Show that we depend on the libraries we need 17739eea4522SIngo Weinhold LocalClean clean : $(1) ; 17749eea4522SIngo Weinhold LocalDepends all : $(1) ; 177552a38012Sejakowatz Depends $(1) : $(2) ; 177652a38012Sejakowatz 177752a38012Sejakowatz if $(6) { 177852a38012Sejakowatz for i in $(6) { 17792a83bfb4SIngo Weinhold KernelConfigSection $(i) : elf32 : $(1) ; 178052a38012Sejakowatz } 178152a38012Sejakowatz } 178252a38012Sejakowatz 178352a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 178452a38012Sejakowatz 178509c5682dSIngo Weinhold # Add the platform specific static libs (libgcc.a). 178652a38012Sejakowatz if ! $(5) { 178709c5682dSIngo Weinhold LINKLIBS on $(1) += $(PLATFORM_LINKLIBS) ; 178852a38012Sejakowatz } 1789c0e501e0SIngo Weinhold 1790c0e501e0SIngo Weinhold SetupKernel $(2) ; 179152a38012Sejakowatz} 179252a38012Sejakowatz 179352a38012Sejakowatzactions KernelLd 179452a38012Sejakowatz{ 17951eb18edfSIngo Weinhold $(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ; 179652a38012Sejakowatz} 179752a38012Sejakowatz 1798811903d1SAxel Dörflerrule KernelAddon 1799811903d1SAxel Dörfler{ 1800600203b1SAxel Dörfler # KernelAddon <name> : <relpath> : <sources> : <static-libraries> ; 1801811903d1SAxel Dörfler 1802811903d1SAxel Dörfler local sources = $(3) ; 1803811903d1SAxel Dörfler 1804c0e501e0SIngo Weinhold SetupObjectsDir ; 180594a49b21SIngo Weinhold Addon $(1) : $(2) : $(sources) ; 1806811903d1SAxel Dörfler ObjectCcFlags $(sources) : -D_KERNEL_MODE=1 -no-fpic ; 1807df48dfedSIngo Weinhold ObjectC++Flags $(sources) : -D_KERNEL_MODE=1 -no-fpic -fno-exceptions ; 1808811903d1SAxel Dörfler LINKFLAGS on $(1) = [ on $(1) return $(LINKFLAGS) ] -nostdlib ; 1809600203b1SAxel Dörfler LinkSharedOSLibs $(1) : $(4) $(OBOS_TOP)/objects/$(OBOS_ARCH).$(OBOS_VERSION)/kernel/kernel.so ; 1810811903d1SAxel Dörfler # ToDo this has to be changed! 181194a49b21SIngo Weinhold SetupKernel $(sources) ; 1812811903d1SAxel Dörfler} 1813811903d1SAxel Dörfler 181480721244SAxel Dörflerrule KernelMergeObject 181580721244SAxel Dörfler{ 18162fbd7065SIngo Weinhold # KernelMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ; 18172fbd7065SIngo Weinhold # Compiles source files and merges the object files to an object file. 18182fbd7065SIngo Weinhold # <name>: Name of the object file to create. No grist will be added. 18192fbd7065SIngo Weinhold # <sources>: Sources to be compiled. Grist will be added. 18202fbd7065SIngo Weinhold # <extra CFLAGS>: Additional flags for compilation. 18212fbd7065SIngo Weinhold # <other objects>: Object files or static libraries to be merged. No grist 18222fbd7065SIngo Weinhold # will be added. 18232fbd7065SIngo Weinhold # 182480721244SAxel Dörfler 1825c0e501e0SIngo Weinhold SetupObjectsDir ; 182680721244SAxel Dörfler 182780721244SAxel Dörfler MakeLocateObjects $(2) ; 182880721244SAxel Dörfler Objects $(2) ; 18292fbd7065SIngo Weinhold MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ; 1830c0e501e0SIngo Weinhold 1831c0e501e0SIngo Weinhold SetupKernel $(2) : $(3) ; 183280721244SAxel Dörfler} 183380721244SAxel Dörfler 183452a38012Sejakowatzrule KernelStaticLibrary 183552a38012Sejakowatz{ 183652a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ; 183752a38012Sejakowatz # This is designed to take a set of sources and libraries and create 183852a38012Sejakowatz # a file called lib<name>.a 183952a38012Sejakowatz 1840c0e501e0SIngo Weinhold SetupObjectsDir ; 184152a38012Sejakowatz 184252a38012Sejakowatz MakeLocateObjects $(2) ; 184352a38012Sejakowatz Library $(1) : $(2) ; 1844c0e501e0SIngo Weinhold 1845c0e501e0SIngo Weinhold SetupKernel $(2) : $(3) ; 184652a38012Sejakowatz} 184752a38012Sejakowatz 184852a38012Sejakowatzrule KernelStaticLibraryObjects 184952a38012Sejakowatz{ 185052a38012Sejakowatz # Usage KernelStaticLibrary <name> : <sources> ; 185152a38012Sejakowatz # This is designed to take a set of sources and libraries and create 185252a38012Sejakowatz # a file called <name> 185352a38012Sejakowatz 1854c0e501e0SIngo Weinhold SetupObjectsDir ; 185552a38012Sejakowatz 185652a38012Sejakowatz # Show that we depend on the libraries we need 18579eea4522SIngo Weinhold LocalClean clean : $(1) ; 18589eea4522SIngo Weinhold LocalDepends all : $(1) ; 185952a38012Sejakowatz Depends $(1) : $(2) ; 186052a38012Sejakowatz 186152a38012Sejakowatz MakeLocate $(1) : $(LOCATE_TARGET) ; 1862c0e501e0SIngo Weinhold 1863c0e501e0SIngo Weinhold SetupKernel $(2) ; 186452a38012Sejakowatz} 186552a38012Sejakowatz 186652a38012Sejakowatzactions KernelStaticLibraryObjects 186752a38012Sejakowatz{ 18680931b8f9SIngo Weinhold ar -r "$(1)" "$(2)" ; 186952a38012Sejakowatz} 187052a38012Sejakowatz 18715dc4e1efSIngo Weinholdrule BuildPlatformMain 187252a38012Sejakowatz{ 18735dc4e1efSIngo Weinhold # Usage BuildPlatformMain <target> : <sources> ; 187452a38012Sejakowatz SetupObjectsDir ; 18755dc4e1efSIngo Weinhold SetupDefaultIncludes ; 187652a38012Sejakowatz 18775dc4e1efSIngo Weinhold # Remove `-nostdinc' from CCFLAGS and C++FLAGS. 18785dc4e1efSIngo Weinhold local oldCCFLAGS = $(CCFLAGS) ; 18795dc4e1efSIngo Weinhold local oldC++FLAGS = $(C++FLAGS) ; 18805dc4e1efSIngo Weinhold CCFLAGS = [ Filter $(CCFLAGS) : -nostdinc ] ; 18815dc4e1efSIngo Weinhold C++FLAGS = [ Filter $(C++FLAGS) : -nostdinc ] ; 188252a38012Sejakowatz 188352a38012Sejakowatz Main $(1) : $(2) ; 18845dc4e1efSIngo Weinhold 18855dc4e1efSIngo Weinhold # Reset CCFLAGS and C++FLAGS to original values. 18865dc4e1efSIngo Weinhold CCFLAGS = $(oldCCFLAGS) ; 18875dc4e1efSIngo Weinhold C++FLAGS = $(oldC++FLAGS) ; 188852a38012Sejakowatz} 188952a38012Sejakowatz 18909fcaa61dSIngo Weinholdrule BuildPlatformTest 18919fcaa61dSIngo Weinhold{ 18929fcaa61dSIngo Weinhold # Usage BuildPlatformTest <target> : <sources> ; 18939fcaa61dSIngo Weinhold 18949fcaa61dSIngo Weinhold local target = $(1) ; 18959fcaa61dSIngo Weinhold local sources = $(2) ; 18969fcaa61dSIngo Weinhold 18979fcaa61dSIngo Weinhold BuildPlatformMain $(target) : $(sources) ; 18989fcaa61dSIngo Weinhold local relPath ; 18999fcaa61dSIngo Weinhold if [ FIsPrefix src tests : $(SUBDIR_TOKENS) ] { 19009fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[3-]) ; 19019fcaa61dSIngo Weinhold } else { 19029fcaa61dSIngo Weinhold relPath = $(SUBDIR_TOKENS[2-]) ; 19039fcaa61dSIngo Weinhold } 19049fcaa61dSIngo Weinhold MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(relPath) ] ; 19059fcaa61dSIngo Weinhold} 19069fcaa61dSIngo Weinhold 190752a38012Sejakowatzrule KernelConfigSection 190852a38012Sejakowatz{ 190952a38012Sejakowatz # KernelConfigSection <section> : <type> : <file> ; 19102a83bfb4SIngo Weinhold 19112a83bfb4SIngo Weinhold SECTION_NAMES on $(OBOS_KERNEL_CONFIG) += $(1) ; 19122a83bfb4SIngo Weinhold SECTION_TYPES on $(OBOS_KERNEL_CONFIG) += $(2) ; 19132a83bfb4SIngo Weinhold SECTION_FILES on $(OBOS_KERNEL_CONFIG) += $(3) ; 19142a83bfb4SIngo Weinhold 19152a83bfb4SIngo Weinhold Depends $(OBOS_KERNEL_CONFIG) : $(3) ; 191652a38012Sejakowatz} 191752a38012Sejakowatz 191852a38012Sejakowatzrule WriteKernelConfig 191952a38012Sejakowatz{ 192052a38012Sejakowatz # usage: WriteKernelConfig <target> ; 192152a38012Sejakowatz 19229eea4522SIngo Weinhold LocalDepends files : $(1) ; 192352a38012Sejakowatz 19242a83bfb4SIngo Weinhold MakeLocate $(1) : $(OBOS_OBJECT_TARGET) ; 192552a38012Sejakowatz 19269eea4522SIngo Weinhold LocalClean clean : $(1) ; 192752a38012Sejakowatz} 192852a38012Sejakowatz 19292a83bfb4SIngo Weinholdactions WriteKernelConfig bind SECTION_FILES 193052a38012Sejakowatz{ 19310931b8f9SIngo Weinhold target="$(1)" 19320931b8f9SIngo Weinhold echo "# OpenBeOS Kernel Config File" > "$target" 19330931b8f9SIngo Weinhold echo "# Automatically generated - do not edit!" >> "$target" 19342a83bfb4SIngo Weinhold count=0 19352a83bfb4SIngo Weinhold for section in "$(SECTION_NAMES)" ; do 19362a83bfb4SIngo Weinhold count=`expr $count + 1` 19372a83bfb4SIngo Weinhold eval section$count="$section" 19382a83bfb4SIngo Weinhold done 19392a83bfb4SIngo Weinhold i=1 19402a83bfb4SIngo Weinhold for type in "$(SECTION_TYPES)" ; do 19412a83bfb4SIngo Weinhold eval type$i="$type" 19422a83bfb4SIngo Weinhold i=`expr $i + 1` 19432a83bfb4SIngo Weinhold done 19442a83bfb4SIngo Weinhold i=1 19452a83bfb4SIngo Weinhold for file in "$(SECTION_FILES)" ; do 19462a83bfb4SIngo Weinhold eval file$i="$file" 19472a83bfb4SIngo Weinhold i=`expr $i + 1` 19482a83bfb4SIngo Weinhold done 19492a83bfb4SIngo Weinhold for i in `seq $count` ; do 19502a83bfb4SIngo Weinhold eval section="\$section$i" 19512a83bfb4SIngo Weinhold eval type="\$type$i" 19522a83bfb4SIngo Weinhold eval file="\$file$i" 19530931b8f9SIngo Weinhold echo "" >> "$target" 19542a83bfb4SIngo Weinhold echo "["$section"]" >> "$target" 19552a83bfb4SIngo Weinhold echo "type="$type >> "$target" 19560931b8f9SIngo Weinhold case "$file" in 195752a38012Sejakowatz /*) ;; 19580931b8f9SIngo Weinhold *) file=`pwd`/"$file";; 195952a38012Sejakowatz esac 19602a83bfb4SIngo Weinhold echo "file="$file >> "$target" 196152a38012Sejakowatz done 196252a38012Sejakowatz} 196352a38012Sejakowatz 196452a38012Sejakowatzrule BuildKernel 196552a38012Sejakowatz{ 196652a38012Sejakowatz # Usage BuildKernel <target> : <config_file> ; 19670c0b2cd0SIngo Weinhold local kernel = $(1) ; 19680c0b2cd0SIngo Weinhold local configFile = $(2) ; 19690c0b2cd0SIngo Weinhold local bootmaker = bootmaker ; 197052a38012Sejakowatz 19719eea4522SIngo Weinhold LocalDepends all : $(kernel) ; 19720c0b2cd0SIngo Weinhold Depends $(kernel) : $(configFile) $(bootmaker) ; 19739eea4522SIngo Weinhold LocalClean clean : $(kernel) ; 19740c0b2cd0SIngo Weinhold MakeLocate $(kernel) : $(LOCATE_TARGET) ; 197552a38012Sejakowatz 19760c0b2cd0SIngo Weinhold BOOT_MAKER on $(kernel) = $(bootmaker) ; 197752a38012Sejakowatz} 197852a38012Sejakowatz 19790c0b2cd0SIngo Weinholdactions BuildKernel bind BOOT_MAKER 198052a38012Sejakowatz{ 19810c0b2cd0SIngo Weinhold "$(BOOT_MAKER)" --strip-debug --strip-binary strip "$(2)" -o "$(1)" ; 198252a38012Sejakowatz echo "" 198352a38012Sejakowatz echo "Kernel linked!" 198452a38012Sejakowatz echo "" 198552a38012Sejakowatz} 198652a38012Sejakowatz 198752a38012Sejakowatzrule KernelFloppyImage 198852a38012Sejakowatz{ 198952a38012Sejakowatz # Usage KernelFloppyImage <target> : <kernel> : <bootblock> ; 19900c0b2cd0SIngo Weinhold local floppy = $(1) ; 19910c0b2cd0SIngo Weinhold local kernel = $(2) ; 19920c0b2cd0SIngo Weinhold local bootblock = $(3) ; 19930c0b2cd0SIngo Weinhold local makeflop = makeflop ; 199452a38012Sejakowatz 19959eea4522SIngo Weinhold LocalDepends all : $(floppy) ; 19960c0b2cd0SIngo Weinhold Depends $(floppy) : $(kernel) $(bootblock) $(makeflop) ; 19979eea4522SIngo Weinhold LocalClean clean : $(floppy) ; 19980c0b2cd0SIngo Weinhold MakeLocate $(floppy) : $(OBOS_OBJECT_TARGET) ; 199952a38012Sejakowatz 20000c0b2cd0SIngo Weinhold BOOT_BLOCK on $(floppy) = $(bootblock) ; 20010c0b2cd0SIngo Weinhold MAKE_FLOP on $(floppy) = $(makeflop) ; 200252a38012Sejakowatz} 200352a38012Sejakowatz 200452a38012Sejakowatz# This may be a bit verbose, but I think it's useful to show what's 200552a38012Sejakowatz# going on, at least in this early stage of development. 20060c0b2cd0SIngo Weinholdactions KernelFloppyImage bind BOOT_BLOCK bind MAKE_FLOP 200752a38012Sejakowatz{ 20087378dd7fSAxel Dörfler "$(MAKE_FLOP)" "-p $(shell expr 18 \* 2 \* 512)" "$(BOOT_BLOCK)" "$(2)" "$(1)" ; 20090c0b2cd0SIngo Weinhold 201052a38012Sejakowatz echo "" 201152a38012Sejakowatz echo "*************************************************" 201252a38012Sejakowatz echo "* Kernel build completed! *" 201352a38012Sejakowatz echo "* Boot image for a 1.44M floppy created *" 201452a38012Sejakowatz echo "*************************************************" 201552a38012Sejakowatz echo "" 20160c0b2cd0SIngo Weinhold echo "Floppy image is $(1)" 201752a38012Sejakowatz echo "The following command will write it to a floppy on BeOS" 20180c0b2cd0SIngo Weinhold echo " dd if=$(1) of=/dev/disk/floppy/raw bs=18k" 20190c0b2cd0SIngo Weinhold echo "Alternatively you can run" 20200c0b2cd0SIngo Weinhold echo " ./configure --floppy /dev/disk/floppy/raw" 20210c0b2cd0SIngo Weinhold echo "once and build + write the image subsequently via" 20220c0b2cd0SIngo Weinhold echo " jam installfloppy" 202352a38012Sejakowatz echo "" 202452a38012Sejakowatz} 202552a38012Sejakowatz 20260c0b2cd0SIngo Weinholdrule InstallFloppy 20270c0b2cd0SIngo Weinhold{ 20280c0b2cd0SIngo Weinhold # InstallFloppy <target> : <floppy> 20290c0b2cd0SIngo Weinhold # "dd"s <floppy> to $(FLOPPY_PATH). 20300c0b2cd0SIngo Weinhold 20310c0b2cd0SIngo Weinhold local target = $(1) ; 20320c0b2cd0SIngo Weinhold local floppy = $(2) ; 20330c0b2cd0SIngo Weinhold 20340c0b2cd0SIngo Weinhold NotFile $(target) ; 20350c0b2cd0SIngo Weinhold Always $(target) ; 20360c0b2cd0SIngo Weinhold Depends $(target) : $(floppy) ; 20370c0b2cd0SIngo Weinhold} 20380c0b2cd0SIngo Weinhold 20390c0b2cd0SIngo Weinholdactions InstallFloppy 20400c0b2cd0SIngo Weinhold{ 20410c0b2cd0SIngo Weinhold if [ -z $(FLOPPY_PATH) ] ; then 20420c0b2cd0SIngo Weinhold echo "Can't install floppy: FLOPPY_PATH not set." 20430c0b2cd0SIngo Weinhold echo "run: ./configure --floppy <floppy path>" 20440c0b2cd0SIngo Weinhold echo 20450c0b2cd0SIngo Weinhold exit 0 20460c0b2cd0SIngo Weinhold fi 20470c0b2cd0SIngo Weinhold dd if=$(2) of=$(FLOPPY_PATH) bs=18k 20480c0b2cd0SIngo Weinhold} 204952a38012Sejakowatz 205021df5945SIngo Weinhold#------------------------------------------------------------------------------- 205121df5945SIngo Weinhold# FreeType 2 specific rules and variables 205221df5945SIngo Weinhold#------------------------------------------------------------------------------- 205321df5945SIngo Weinhold 205421df5945SIngo WeinholdFT2_INCLUDE = [ FDirName $(OBOS_TOP) headers libs freetype2 ] ; 205521df5945SIngo WeinholdFT2_SRC = [ FDirName $(OBOS_TOP) src libs freetype2 ] ; 205621df5945SIngo Weinhold 205721df5945SIngo WeinholdFT2_LIB = freetype ; 205821df5945SIngo Weinhold 2059fbd28219SIngo WeinholdFT2_COMPONENTS ?= gzip # support for gzip-compressed files. 2060fbd28219SIngo Weinhold autohint # auto-hinter 2061fbd28219SIngo Weinhold base # base component (public APIs) 2062fbd28219SIngo Weinhold bdf # BDF font driver 2063fbd28219SIngo Weinhold cache # cache sub-system 2064fbd28219SIngo Weinhold cff # CFF/CEF font driver 2065fbd28219SIngo Weinhold cid # Postscript CID-keyed font driver 20669ec866ccSDarkWyrm lzw # LZW routines 2067fbd28219SIngo Weinhold pcf # PCF font driver 2068fbd28219SIngo Weinhold pfr # PFR/TrueDoc font driver 2069fbd28219SIngo Weinhold psaux # Common Postscript routines module 2070fbd28219SIngo Weinhold pshinter # Postscript hinter module 2071fbd28219SIngo Weinhold psnames # Postscript names handling 2072fbd28219SIngo Weinhold raster # Monochrome rasterizer 2073fbd28219SIngo Weinhold smooth # Anti-aliased rasterizer 2074fbd28219SIngo Weinhold sfnt # SFNT-based format support routines 2075fbd28219SIngo Weinhold truetype # TrueType font driver 2076fbd28219SIngo Weinhold type1 # Postscript Type 1 font driver 2077fbd28219SIngo Weinhold type42 # Postscript Type 42 (embedded TrueType) driver 2078fbd28219SIngo Weinhold winfonts # Windows FON/FNT font driver 2079fbd28219SIngo Weinhold ; 2080fbd28219SIngo Weinhold 208121df5945SIngo Weinholdrule UseFreeTypeHeaders 208221df5945SIngo Weinhold{ 208321df5945SIngo Weinhold SubDirHdrs $(FT2_INCLUDE) ; 208421df5945SIngo Weinhold} 208521df5945SIngo Weinhold 208621df5945SIngo Weinholdrule UseFreeTypeObjectHeaders 208721df5945SIngo Weinhold{ 20889b60a208SIngo Weinhold # UseFreeTypeObjectHeaders <sources> [ : <objects> ] ; 20899b60a208SIngo Weinhold SourceHdrs $(1) : $(FT2_INCLUDE) : $(2) ; 209021df5945SIngo Weinhold} 209121df5945SIngo Weinhold 209221df5945SIngo Weinholdrule FT2_SubDir 209321df5945SIngo Weinhold{ 209421df5945SIngo Weinhold # FT2_SubDir <dir> 209521df5945SIngo Weinhold # <dir>: Components of a directory in the original hierarchy. 209621df5945SIngo Weinhold local dir = $(1) ; 209721df5945SIngo Weinhold local topDir ; 209821df5945SIngo Weinhold switch $(dir[1]) 209921df5945SIngo Weinhold { 210021df5945SIngo Weinhold case "include" : topDir = $(FT2_INCLUDE) ; 210121df5945SIngo Weinhold case src : topDir = $(FT2_SRC) ; 210221df5945SIngo Weinhold case * : ECHO "Unknown FreeType2 directory: " $(dir) ; 210321df5945SIngo Weinhold } 210421df5945SIngo Weinhold return [ FDirName $(topDir) $(dir[2-]) ] ; 210521df5945SIngo Weinhold} 210621df5945SIngo Weinhold 210721df5945SIngo Weinholdrule FT2_Library 210821df5945SIngo Weinhold{ 210921df5945SIngo Weinhold # FT2_Library <libname> : <sources> 211021df5945SIngo Weinhold # Builds objects from sources and adds the objects to the list of objects 211121df5945SIngo Weinhold # to be linked into the library. 211221df5945SIngo Weinhold # <libname> The name of the library. 211321df5945SIngo Weinhold # <sources> The sources. 211421df5945SIngo Weinhold 211521df5945SIngo Weinhold local library = lib$(1).so ; 211621df5945SIngo Weinhold local sources = $(2) ; 211728d2a30eSDaniel Reinhold SetupIncludes ; 211821df5945SIngo Weinhold SetupObjectsDir ; 211921df5945SIngo Weinhold MakeLocateObjects $(sources) ; 212021df5945SIngo Weinhold Objects $(sources) ; 212121df5945SIngo Weinhold LIBRARY_OBJECTS on $(library) += [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 212221df5945SIngo Weinhold} 212321df5945SIngo Weinhold 212421df5945SIngo Weinholdrule FT2_LinkLibrary 212521df5945SIngo Weinhold{ 212621df5945SIngo Weinhold # FT2_LinkLibrary <libname> 212721df5945SIngo Weinhold # Links the library from the objects build with FT2_LIBRARY before. 212821df5945SIngo Weinhold 212921df5945SIngo Weinhold local library = lib$(1).so ; 213021df5945SIngo Weinhold local objects = [ on $(library) return $(LIBRARY_OBJECTS) ] ; 213121df5945SIngo Weinhold ObjectReferences $(objects) ; 213221df5945SIngo Weinhold objects = [ FGristFiles $(objects) ] ; 213321df5945SIngo Weinhold SharedLibraryFromObjects $(1) : $(objects) ; 213421df5945SIngo Weinhold} 213521df5945SIngo Weinhold 21369b7a4b5dSshatty#------------------------------------------------------------------------------- 21379b7a4b5dSshatty# Packages for OBOS alpha/beta testers 21389b7a4b5dSshatty#------------------------------------------------------------------------------- 21399b7a4b5dSshatty 21409b7a4b5dSshattyrule Copy 21419b7a4b5dSshatty{ 21425c413522Sshatty Depends $(<) : $(>) ; 21439b7a4b5dSshatty SEARCH on $(>) = $(SEARCH_SOURCE) ; 21449b7a4b5dSshatty} 21459b7a4b5dSshatty 21469b7a4b5dSshattyactions Copy 21479b7a4b5dSshatty{ 214815716fddSPhilippe Houdoin cp -dp "$(>)" "$(<)" ; 214915716fddSPhilippe Houdoin if [ -f "$(>)" ] ; then copyattr "$(>)" "$(<)" ; fi ; 21509b7a4b5dSshatty} 21519b7a4b5dSshatty 21529b7a4b5dSshattyrule Packages 21539b7a4b5dSshatty{ 21549b7a4b5dSshatty local packagenames = $(1) ; 21559b7a4b5dSshatty local packagefiles = $(2) ; 21569b7a4b5dSshatty local path = $(3) ; 21579b7a4b5dSshatty for name in $(packagenames) { 21589b7a4b5dSshatty Package $(name) : $(packagefiles) : $(path) ; 21599b7a4b5dSshatty } 21609b7a4b5dSshatty} 21619b7a4b5dSshatty 21629b7a4b5dSshattyrule Package 21639b7a4b5dSshatty{ 21649b7a4b5dSshatty local packagename = $(1) ; 21659b7a4b5dSshatty local packagefiles = $(2) ; 21669b7a4b5dSshatty local path = $(3) ; 21679b7a4b5dSshatty 2168c06f365fSIngo Weinhold local packagezip = $(packagename:S=.zip:G=_packages) ; 21699b7a4b5dSshatty local packagedir = [ FDirName $(OBOS_PACKAGE_DIR) $(packagename) ] ; 21709b7a4b5dSshatty 21719b7a4b5dSshatty local installscript = install.sh ; 2172c06f365fSIngo Weinhold local packageinstallscript = $(installscript:G=_packages!$(packagename)) ; 21739b7a4b5dSshatty local installzip = install.zip ; 2174c06f365fSIngo Weinhold local packageinstallzip = $(installzip:G=_packages!$(packagename)) ; 21759b7a4b5dSshatty 2176c06f365fSIngo Weinhold local packageobjectdir 2177c06f365fSIngo Weinhold = [ FDirName $(OBOS_PACKAGE_OBJECT_DIR) $(packagename) ] ; 21789b7a4b5dSshatty local packagefiledir = [ FDirName $(packageobjectdir) $(path) ] ; 2179c06f365fSIngo Weinhold local packagefileinstallzip 2180c06f365fSIngo Weinhold = $(installzip:G=_package_objects!$(packagename)) ; 2181c06f365fSIngo Weinhold 2182c06f365fSIngo Weinhold # add the files to the install.zip 2183c06f365fSIngo Weinhold local packagefilegrist = [ FGrist _package_files $(packagename) $(path) ] ; 21849b7a4b5dSshatty for file in $(packagefiles) { 21859b7a4b5dSshatty if $(3[0]) = "boot" { 2186c06f365fSIngo Weinhold local packagefile = $(file:G=$(packagefilegrist)) ; 21879b7a4b5dSshatty MakeLocate $(packagefile) : $(packagefiledir) ; 21889b7a4b5dSshatty Copy $(packagefile) : $(file) ; 21899b7a4b5dSshatty Clean cleanPackages : $(packagefile) ; 21909b7a4b5dSshatty PackageInstallZip $(packagefileinstallzip) : $(packagefile) ; 21919b7a4b5dSshatty } else { 2192c06f365fSIngo Weinhold local packagefile = $(file:G=_packages!$(packagename)) ; 21939b7a4b5dSshatty MakeLocate $(packagefile) : $(packagedir) ; 219482bec102Sshatty Copy $(packagefile) : [ FGristFiles $(file) ] ; 21959b7a4b5dSshatty Clean cleanPackages : $(packagefile) ; 21969b7a4b5dSshatty Depends $(packagezip) : $(packagefile) ; 21979b7a4b5dSshatty } 21989b7a4b5dSshatty } 2199c06f365fSIngo Weinhold 2200c06f365fSIngo Weinhold # general setup for this packages -- only on first invocation 2201c06f365fSIngo Weinhold if ! $(_setup_$(packagename)) { 2202c06f365fSIngo Weinhold _setup_$(packagename) = true ; 2203c06f365fSIngo Weinhold 2204c06f365fSIngo Weinhold NotFile $(packagename) ; 2205b560211bSshatty LocalDepends packages : $(packagename) ; 2206c06f365fSIngo Weinhold 2207c06f365fSIngo Weinhold MakeLocate $(packagezip) : $(OBOS_PACKAGE_DIR) ; 2208c06f365fSIngo Weinhold MakeLocate $(packageinstallscript) : $(packagedir) ; 2209c06f365fSIngo Weinhold MakeLocate $(packageinstallzip) : $(packagedir) ; 2210c06f365fSIngo Weinhold MakeLocate $(packagefileinstallzip) : $(packageobjectdir) ; 2211c06f365fSIngo Weinhold 22129b7a4b5dSshatty PackageInstallScript $(packageinstallscript) : $(packagedir) ; 22139b7a4b5dSshatty LinkInstallZip $(packageinstallzip) : $(packagefileinstallzip) ; 22149b7a4b5dSshatty Depends $(packagename) : $(packagezip) ; 2215c06f365fSIngo Weinhold PackageZip $(packagezip) : $(packagedir) 2216c06f365fSIngo Weinhold : $(packageinstallscript) $(packageinstallzip) ; 2217c06f365fSIngo Weinhold } 2218c06f365fSIngo Weinhold 22199b7a4b5dSshatty} 22209b7a4b5dSshatty 22219b7a4b5dSshattyrule PackageZip 22229b7a4b5dSshatty{ 2223c06f365fSIngo Weinhold local dir = $(2:G=dir) ; 2224c06f365fSIngo Weinhold Depends $(1) : $(dir) $(3) ; 22259b7a4b5dSshatty Clean cleanPackages : $(1) ; 2226c06f365fSIngo Weinhold PackageZip1 $(1) : $(dir) ; 22279b7a4b5dSshatty} 22289b7a4b5dSshatty 2229c06f365fSIngo Weinholdactions together PackageZip1 { 22308042d2a0SPhilippe Houdoin cd "$(OBOS_PACKAGE_DIR)" ; 22318042d2a0SPhilippe Houdoin zip -rq "$(1:BS)" "$(2:BS)" ; 22329b7a4b5dSshatty} 22339b7a4b5dSshatty 22349b7a4b5dSshattyrule PackageInstallScript 22359b7a4b5dSshatty{ 22369b7a4b5dSshatty MakeLocate $(1) : $(2) ; 22379b7a4b5dSshatty Clean cleanPackages : $(1) ; 2238c06f365fSIngo Weinhold PackageInstallScript1 $(1) : $(2:G=dir) ; 22399b7a4b5dSshatty} 22409b7a4b5dSshatty 2241c06f365fSIngo Weinholdactions together PackageInstallScript1 22429b7a4b5dSshatty{ 224351fe1be4Sshattyecho '#!/bin/sh 224451fe1be4Sshattybase=`dirname "$0"` 22458042d2a0SPhilippe Houdoincd "$base" 224651fe1be4Sshattyif [ -n "$TTY" ] 224751fe1be4Sshattythen 224851fe1be4Sshatty unzip -d / install.zip 224951fe1be4Sshattyelse 225051fe1be4Sshatty response=`alert "Would you like to automatically overwrite existing files, or receive a prompt?" "Overwrite" "Prompt"` 225151fe1be4Sshatty if [ $response == "Overwrite" ] 225251fe1be4Sshatty then 225351fe1be4Sshatty unzip -od / install.zip 225451fe1be4Sshatty alert "Finished installing" "Thanks" 225551fe1be4Sshatty else 225651fe1be4Sshatty if [ -e /boot/beos/apps/Terminal ] 225751fe1be4Sshatty then 225851fe1be4Sshatty terminal=/boot/beos/apps/Terminal 225951fe1be4Sshatty else 226051fe1be4Sshatty terminal=`query Terminal | head -1` 226151fe1be4Sshatty fi 22628042d2a0SPhilippe Houdoin $terminal -t "installer" /bin/sh "$0" 226351fe1be4Sshatty fi 22648042d2a0SPhilippe Houdoinfi' > "$(1)" ; 22658042d2a0SPhilippe Houdoin chmod 755 "$(1)" ; 22669b7a4b5dSshatty} 22679b7a4b5dSshatty 22689b7a4b5dSshattyrule PackageInstallZip 22699b7a4b5dSshatty{ 22709b7a4b5dSshatty Depends $(1) : $(2) ; 22719b7a4b5dSshatty Clean cleanPackages : $(1) ; 22729b7a4b5dSshatty} 22739b7a4b5dSshatty 22749b7a4b5dSshattyactions together PackageInstallZip 22759b7a4b5dSshatty{ 22768042d2a0SPhilippe Houdoin cd "$(1:P)" ; 22778042d2a0SPhilippe Houdoin zip -rqy "$(1:BS)" boot ; 22789b7a4b5dSshatty} 22799b7a4b5dSshatty 22809b7a4b5dSshattyrule LinkInstallZip 22819b7a4b5dSshatty{ 22829b7a4b5dSshatty Depends $(1) : $(2) ; 22839b7a4b5dSshatty Clean cleanPackages : $(1) ; 22849b7a4b5dSshatty} 22859b7a4b5dSshatty 22869b7a4b5dSshattyactions together LinkInstallZip 22879b7a4b5dSshatty{ 22888042d2a0SPhilippe Houdoin ln -sf "`pwd`/$(2)" "$(1)" ; 22899b7a4b5dSshatty} 2290e91f3ca1Sbeveloper 2291e91f3ca1Sbeveloperrule SubIncludeGPL 2292e91f3ca1Sbeveloper{ 2293e91f3ca1Sbeveloper # SubInclude rule that can be used to conditionally include GPL licensed add-ons 2294e91f3ca1Sbeveloper if $(INCLUDE_GPL_ADDONS) = 1 { 2295e91f3ca1Sbeveloper SubInclude $(1) ; 2296e91f3ca1Sbeveloper } 2297e91f3ca1Sbeveloper} 2298