1# Include BuildConfig 2{ 3 local buildConfig = [ GLOB $(OBOS_TOP) : BuildConfig ] ; 4 if ! $(buildConfig) 5 { 6 EXIT "No BuildConfig!" 7 "Run ./configure in the source tree's root directory first!" ; 8 } 9 include $(buildConfig) ; 10} 11 12# Determine if we're building on PPC or x86 13# Determine mimetype of executable 14# Cross compiling can come later 15 16if $(METROWERKS) { 17 OBOS_TARGET ?= "ppc.R5" ; 18 OBOS_TARGET_TYPE ?= "application/x-be-executable" ; 19 OBOS_ARCH ?= "ppc" ; 20 OBOS_TARGET_DEFINE ?= "ARCH_ppc" ; 21} else { 22 OBOS_TARGET ?= "x86.R5" ; 23 OBOS_TARGET_TYPE ?= "application/x-vnd.Be-elfexecutable" ; 24 OBOS_ARCH ?= "x86" ; 25 OBOS_TARGET_DEFINE ?= "ARCH_x86" ; 26 OBOS_TARGET_DIR ?= "x86" ; 27} 28 29KERNEL_CCFLAGS ?= "-Wall -Wno-multichar -Wmissing-prototypes -finline -nostdinc" ; 30KERNEL_CCFLAGS += "-fno-builtin -D$(OBOS_TARGET_DEFINE) " ; 31 32AR = ar r ; 33OPTIM = -O2 ; 34 35# If no OBOS_OBJECT_TARGET is not defined yet, use our default directory and 36# include our "OBOS_TARGET" as subdirectory in there (to prevent different 37# builds mixing objects from different targets). 38if ! $(OBOS_OBJECT_TARGET) { 39 OBOS_OBJECT_TARGET ?= [ FDirName $(OBOS_TOP) objects $(OBOS_TARGET) ] ; 40} 41 42# If no OBOS_DISTRO_TARGET is not defined yet, use our default directory and 43# include our "OBOS_TARGET" as subdirectory in there (to prevent different 44# builds mixing executables from different targets). 45if ! $(OBOS_DISTRO_TARGET) { 46 OBOS_DISTRO_TARGET ?= [ FDirName $(OBOS_TOP) distro $(OBOS_TARGET) ] ; 47} 48 49# Set our version number if not already set and mark it as a developer build 50if ! $(OBOS_BUILD_VERSION) { 51 OBOS_BUILD_VERSION ?= "1 0 0 a 1" ; 52 OBOS_BUILD_DESCRIPTION ?= "Developer Build" ; 53} 54 55# If OBOS_BUILD_VERSION is set, but OBOS_BUILD_DESCRIPTION isn't, mark it as 56# an unknown build. 57if ! $(OBOS_BUILD_DESCRIPTION) { 58 OBOS_BUILD_DESCRIPTION ?= "Unknown Build" ; 59} 60 61# Relative subdirs for distro dir (these are for *INTERNAL* use by the following rules only!) 62OBOS_APPS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos apps ] ; 63OBOS_PREFS_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos preferences ] ; 64OBOS_SERVER_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system servers ] ; 65OBOS_ADDON_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system add-ons ] ; 66OBOS_SHLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ; 67OBOS_STLIB_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system lib ] ; 68OBOS_KERNEL_DIR ?= [ FDirName $(OBOS_DISTRO_TARGET) beos system ] ; 69OBOS_TEST_DIR ?= [ FDirName $(OBOS_TOP) tests ] ; 70 71OBOS_KERNEL_CONFIG = config.$(OBOS_ARCH).ini ; 72OBOS_KERNEL = kernel.$(OBOS_ARCH) ; 73OBOS_FLOPPY = floppy.$(OBOS_ARCH) ; 74 75rule SetupIncludes 76{ 77 OBOS_INCLUDES ?= . add-ons app be_apps device drivers game interface kernel mail media midi midi2 net opengl storage support translation ; 78 UsePublicHeaders $(OBOS_INCLUDES) ; 79} 80 81#------------------------------------------------------------------------------- 82# Things Jam needs in order to work :) 83#------------------------------------------------------------------------------- 84 85rule UserObject 86{ 87 switch $(2) 88 { 89 case *.S : assemble $(1) : $(2) ; 90 case * : ECHO "unknown suffix on" $(2) ; 91 } 92} 93 94# Override the default to give "prettier" command lines. 95actions Cc 96{ 97 $(CC) -c $(2) $(CCFLAGS) $(CCDEFS) $(CCHDRS) -o $(1) ; 98} 99 100actions C++ 101{ 102 $(C++) -c $(2) $(C++FLAGS) $(CCDEFS) $(CCHDRS) -o $(1) ; 103} 104 105 106#------------------------------------------------------------------------------- 107# General High-level OBOS target rules 108#------------------------------------------------------------------------------- 109 110rule App 111{ 112 # App <name> : <sources> ; 113 SetupObjectsDir ; 114 Main $(<) : $(>) ; 115 MakeLocate $(<) : $(OBOS_APPS_DIR) ; 116} 117 118rule Preference 119{ 120 # Preference <name> : <sources> ; 121# SetupIncludes ; 122 SetupObjectsDir ; 123 Main $(<) : $(>) ; 124 MakeLocate $(<) : $(OBOS_PREFS_DIR) ; 125} 126 127rule Server 128{ 129 # Server <name> : <sources> ; 130 131 SetupIncludes ; 132 SetupObjectsDir ; 133 Main $(<) : $(>) ; 134 MakeLocate $(<) : $(OBOS_SERVER_DIR) ; 135} 136 137# test pseudo targets 138NOTFILE obostests ; 139NOTFILE r5tests ; 140 141rule CommonUnitTest 142{ 143 # CommonUnitTest <target> : <sources> : <dest> : <obos libraries> 144 # : <r5 libraries> : <public headers>; 145 # Builds a unit test for both OBOS and R5 modules. 146 # <target> The name of the target. 147 # <sources> The list of sources. 148 # <dest> The directory for the target (as passed to FDirName). 149 # <obos libraries> A list of link libraries for the OBOS tests (as passed 150 # to LinkSharedOSLibs). 151 # <r5 libraries> A list of link libraries for the R5 tests (as passed 152 # to LinkSharedOSLibs). 153 # <public headers> A list of public header dirs (as passed to 154 # UsePublicHeaders). 155 156 UnitTest $(1) : $(2) : $(3) : $(4) : $(6) ; 157 R5UnitTest $(1) : $(2) : $(3) : $(5) ; 158} 159 160rule UnitTest 161{ 162 # UnitTest <target> : <sources> : <dest> : <libraries> : <public headers> 163 # Builds a unit test for an OBOS module. 164 # <target> The name of the target. 165 # <sources> The list of sources. 166 # <dest> The directory for the target (as passed to FDirName). 167 # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 168 # <public headers> A list of public header dirs (as passed to 169 # UsePublicHeaders). 170 171 local target = $(1) ; 172 local sources = $(2) ; 173 local dest = $(3) ; 174 local libraries = $(4) ; 175 local headerDirs = $(5) ; 176 177 # Turn optimization off. 178 local optim = $(OPTIM) ; 179 OPTIM = ; 180 181# SetupIncludes ; 182 UseCppUnitHeaders ; 183 SetupObjectsDir ; 184 MakeLocateObjects $(sources) ; 185 Main $(target) : $(sources) ; 186 MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 187 DEPENDS $(target) : libcppunit.so ; 188 DEPENDS obostests : $(target) ; 189 LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 190 UsePublicObjectHeaders $(sources) : $(headerDirs) ; 191 ObjectDefines $(sources) : TEST_OBOS ; 192 193 # Turn debugging on. That is usually desired for test code. 194 ObjectCcFlags $(sources) : "-g" ; 195 ObjectC++Flags $(sources) : "-g" ; 196 197 # Turn optimization on again. 198 OPTIM = $(optim) ; 199} 200 201rule R5UnitTest 202{ 203 # R5UnitTest <target> : <sources> : <dest> : <libraries> 204 # Builds a unit test for an R5 module. "_r5" is appended to the object 205 # and the target name. 206 # <target> The name of the target. 207 # <sources> The list of sources. 208 # <dest> The directory for the target (as passed to FDirName). 209 # <libraries> A list of link libraries (as passed to LinkSharedOSLibs). 210 211 local target = $(1)_r5 ; 212 local sources = $(2) ; 213 local dest = $(3) ; 214 local libraries = $(4) ; 215 local objects = [ R5ObjectNames $(sources) ] ; 216 217 # Turn optimization off. 218 local optim = $(OPTIM) ; 219 OPTIM = ; 220 221 UseCppUnitHeaders ; 222 SetupObjectsDir ; 223 MakeLocateObjects $(objects) ; 224 225 # Our Main replacement. 226 MainFromObjects $(target) : $(objects) ; 227 local source ; 228 for source in [ FGristFiles $(sources) ] 229 { 230 local object = [ R5ObjectNames $(source) ] ; 231 Object $(object) : $(source) ; 232 Depends obj : $(object) ; 233 } 234 235 MakeLocate $(target) : [ FDirName $(OBOS_TEST_DIR) $(dest) ] ; 236 DEPENDS $(target) : libcppunit.so ; 237 DEPENDS r5tests : $(target) ; 238 LinkSharedOSLibs $(target) : libcppunit.so $(libraries) ; 239 ObjectDefines $(objects) : TEST_R5 ; 240 241 # Turn debugging on. That is usually desired for test code. 242 ObjectCcFlags $(objects) : "-g" ; 243 ObjectC++Flags $(objects) : "-g" ; 244 245 # Turn optimization on again. 246 OPTIM = $(optim) ; 247} 248 249rule R5ObjectNames 250{ 251 # R5ObjectNames <sources> ; 252 # Returns a list of gristed object names given a list of source file names. 253 # Moreover each object names gets "_r5" inserted before the object suffix. 254 local objects = $(1:S=)_r5 ; 255 return [ FGristFiles $(objects:S=$(SUFOBJ)) ] ; 256} 257 258rule Addon 259{ 260 # Addon <name> : <relpath> : <sources> ; 261 262# SetupIncludes ; 263 SetupObjectsDir ; 264 Main $(1) : $(3) ; 265 266 # Create output dir path for addon 267 local targetdir; 268 targetdir = [ FDirName $(OBOS_ADDON_DIR) $(2) ] ; 269 270 MakeLocate $(1) : $(targetdir) ; 271 LINKFLAGS on $(1) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(1)\" ; 272} 273 274rule MakeLocateObjects 275{ 276 # MakeLocateObjects <gristed_sources_or_objects> ; 277 278 local _objs = $(1:S=$(SUFOBJ)) ; 279 280 for o in $(_objs) 281 { 282 local dir = $(o:D) ; 283 if $(dir) { 284 MakeLocate $(o) : [ FDirName $(LOCATE_TARGET) $(dir) ] ; 285 } else { 286 MakeLocate $(o) : $(LOCATE_TARGET) ; 287 } 288 } 289} 290 291rule StaticLibrary 292{ 293 # StaticLibrary <name> : <sources> ; 294 295 SetupIncludes ; 296 SetupObjectsDir ; 297 MakeLocateObjects $(2) ; 298 Library lib$(<).a : $(>) ; 299 MakeLocate lib$(<).a : $(OBOS_STLIB_DIR) ; 300} 301 302rule SharedLibrary 303{ 304 # SharedLibrary <name> : <sources> ; 305 local _lib = lib$(1).so ; 306 307# SetupIncludes ; 308 SetupObjectsDir ; 309 MakeLocateObjects $(2) ; 310 Main $(_lib) : $(2) ; 311 MakeLocate $(_lib) : $(OBOS_SHLIB_DIR) ; 312 LINKFLAGS on $(_lib) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(_lib)\" ; 313} 314 315rule LinkSharedOSLibs 316{ 317 # LinkSharedOSLibs <name> : <libs> ; 318 # Valid elements for <libs> are e.g. "be" or "libopenbeos.so" or 319 # "/boot/.../libfoo.so". If the basename starts with "lib" or the thingy 320 # has a dirname or grist, it is added to the NEEDLIBS variable (i.e. the 321 # file will be bound!), otherwise it is prefixed "-l" and added to 322 # LINKLIBS. 323 324 for i in $(>) 325 { 326 local isfile = ; 327 if $(i:D) || $(i:G) { 328 isfile = true ; 329 } else { 330 switch $(i:B) 331 { 332 case lib* : isfile = true ; 333 case * : isfile = ; 334 } 335 } 336 if $(isfile) { 337 NEEDLIBS on $(1) += $(i) ; 338 DEPENDS $(1) : $(i) ; 339 } else { 340 LINKLIBS on $(1) += -l$(i) ; 341 } 342 } 343} 344 345rule LinkStaticOSLibs 346{ 347 # LinkStaticOSLibs <name> : <libs> ; 348 349 for i in $(>) 350 { 351 LINKLIBS on $(<) = $(LINKLIBS) -l $(i) ; 352 } 353} 354 355rule AddResources 356{ 357 # AddResources <name> : <resourcefiles> ; 358 359 local dir; 360 361 dir = [ FDirName $(OBOS_TOP) $(SUBDIR_TOKENS) ] ; 362 363 for i in $(>) 364 { 365 RESFILES on $(<) = [ FDirName $(dir) $(i) ] ; 366 DEPENDS $(<) : [ FDirName $(dir) $(i) ] ; 367 } 368} 369 370rule PublicHeaders 371{ 372 # PublicHeaders <group list> 373 # 374 # Returns the directory names for the public header dirs identified by 375 # <group list>. 376 377 local list = $(1) ; 378 local dirs ; 379 for i in $(list) { 380 dirs += [ FDirName $(OBOS_TOP) headers os $(i) ] ; 381 } 382 return $(dirs) ; 383} 384 385rule PrivateHeaders 386{ 387 # PrivateHeaders <group list> 388 # 389 # Returns the directory names for the private header dirs identified by 390 # <group list>. 391 392 local list = $(1) ; 393 local dirs ; 394 for i in $(list) { 395 dirs += [ FDirName $(OBOS_TOP) headers private $(i) ] ; 396 } 397 return $(dirs) ; 398} 399 400rule ArchHeaders 401{ 402 # usage: ArchHeaders <arch> ; 403 # 404 # <arch> specifies the architecture (e.g. x86). 405 406 return [ FDirName $(OBOS_TOP) headers private kernel arch $(1) ] ; 407} 408 409rule UsePublicHeaders 410{ 411 # UsePublicHeaders <group list> ; 412 # 413 # Adds the public C header dirs given by <group list> to the header search 414 # dirs of the subdirectory. 415 # NOTE: This rule must be invoked *before* the rule that builds the objects. 416 417 UseHeaders [ PublicHeaders $(1) ] ; 418} 419 420rule UsePublicObjectHeaders 421{ 422 # UsePublicObjectHeaders <sources_or_objects> : <group list> ; 423 # 424 # Adds the public C header dirs given by <group list> to the header search 425 # dirs of <sources_or_objects>. 426 # NOTE: This rule must be invoked *after* the rule that builds the objects. 427 428 ObjectHdrs $(1) : [ PublicHeaders $(2) ] ; 429} 430 431rule UsePrivateHeaders 432{ 433 # UsePrivateHeaders <group list> ; 434 # 435 # Adds the private C header dirs given by <group list> to the header search 436 # dirs of the subdirectory. 437 # NOTE: This rule must be invoked *before* the rule that builds the objects. 438 439 UseHeaders [ PrivateHeaders $(1) ] ; 440} 441 442rule UsePrivateObjectHeaders 443{ 444 # UsePrivateObjectHeaders <sources_or_objects> : <group list> ; 445 # 446 # Adds the private C header dirs given by <group list> to the header search 447 # dirs of <sources_or_objects>. 448 # NOTE: This rule must be invoked *after* the rule that builds the objects. 449 450 ObjectHdrs $(1) : [ PrivateHeaders $(2) ] ; 451} 452 453rule UseHeaders 454{ 455 # UseHeaders <headers> ; 456 # 457 # Adds the C header dirs <headers> to the header search 458 # dirs of the subdirectory. 459 # NOTE: This rule must be invoked *before* the rule that builds the objects. 460 461 local header ; 462 for header in $(1) { 463 SubDirHdrs $(header) ; 464 } 465} 466 467rule UseCppUnitHeaders 468{ 469 SubDirHdrs [ FDirName $(OBOS_TOP) headers tools cppunit ] ; 470} 471 472rule UseArchHeaders 473{ 474 # usage: UseArchHeaders <arch> ; 475 # 476 # <arch> specifies the architecture (e.g. x86). 477 # NOTE: This rule must be invoked *before* the rule that builds the objects. 478 479 local headers = [ ArchHeaders $(1) ] ; 480 local opt = -D$(OBOS_TARGET_DEFINE) ; 481 482 SubDirCcFlags $(opt) ; 483 SubDirC++Flags $(opt) ; 484 SubDirHdrs $(headers) ; 485} 486 487rule UseArchObjectHeaders 488{ 489 # usage: UseArchObjectHeaders <sources_or_objects> : <arch> ; 490 # 491 # <arch> specifies the architecture (e.g. x86). 492 # <sources_or_objects> Source or object files. 493 # NOTE: This rule must be invoked *after* the rule that builds the objects. 494 495 local targets = $(1) ; 496 local headers = [ ArchHeaders $(2) ] ; 497 local opt = -D$(OBOS_TARGET_DEFINE) ; 498 499 ObjectCcFlags $(targets) : $(opt) ; 500 ObjectC++Flags $(targets) : $(opt) ; 501 ObjectHdrs $(targets) : $(headers) ; 502} 503 504rule SplitPath 505{ 506 # SplitPath <path> ; 507 # Decomposes a path into its components. 508 local path = $(1:G=) ; 509 local components ; 510 while $(path:D) 511 { 512 # Note: $(path:B) returns "." for "..", but $(path:D=) is fine. 513 components = $(path:D=) $(components) ; 514 path = $(path:D) ; 515 } 516 components = $(path) $(components) ; 517 return $(components) ; 518} 519 520rule SymLink 521{ 522 # SymLink <target> : <source> ; 523 # Links <target> to <source>. 524 # <source> is the exact link contents. No binding is done. 525 LINKCONTENTS on $(1) = $(2) ; 526 SymLink1 $(1) ; 527} 528 529actions SymLink1 530{ 531 $(RM) $(1) && $(LN) -s $(LINKCONTENTS) $(1) 532} 533 534#------------------------------------------------------------------------------- 535# Low-level OBOS utility rules 536#------------------------------------------------------------------------------- 537rule SetupObjectsDir 538{ 539 local rel_objectsdir; 540 541 # Copy subdir tokens except the first, as that will be "sources", and we 542 # do not want to include that :) 543 rel_objectsdir = [ FDirName $(SUBDIR_TOKENS[2-]) ] ; 544 LOCATE_TARGET = [ FDirName $(OBOS_OBJECT_TARGET) $(rel_objectsdir) ] ; 545} 546 547#------------------------------------------------------------------------------- 548# Link rule/action are overwritten as they don't handle linking files who's name 549# contain spaces very well. Also adds resources and version to executable. 550#------------------------------------------------------------------------------- 551rule Link 552{ 553 # Note: RESFILES must be set before invocation. 554 MODE on $(<) = $(EXEMODE) ; 555 on $(1) XRes $(1) : $(RESFILES) ; 556 SetVersion $(1) ; 557 Chmod $(<) ; 558 SetType $(1) ; 559 MimeSet $(1) ; 560} 561 562actions Link bind NEEDLIBS 563{ 564 $(LINK) $(LINKFLAGS) -o "$(1)" $(UNDEFS) $(2) $(NEEDLIBS) $(LINKLIBS) ; 565} 566 567# BeOS specific rules 568 569rule XRes 570{ 571 # XRes <target> : <resource files> 572 if $(2) 573 { 574 DEPENDS $(1) : $(2) ; 575 XRes1 $(1) : $(2) ; 576 } 577} 578 579rule XRes1 { } 580 581rule SetVersion 582{ 583 # SetVersion <target> 584} 585 586rule SetType 587{ 588 # SetType <target> 589} 590 591rule MimeSet 592{ 593 # SetType <target> 594} 595 596 597if $(OS) = BEOS 598{ 599 600actions XRes1 601{ 602 xres -o "$(1)" $(2) ; 603} 604 605actions SetVersion 606{ 607 setversion "$(1)" -system $(OBOS_BUILD_VERSION) -short "$(OBOS_BUILD_DESCRIPTION)" ; 608} 609 610actions SetType 611{ 612 settype -t $(OBOS_TARGET_TYPE) "$(1)" ; 613} 614 615actions MimeSet 616{ 617 mimeset -f "$(1)" ; 618} 619 620} # if BEOS 621 622 623rule assemble 624{ 625 DEPENDS $(1) : $(2) ; 626 Clean clean : $(1) ; 627} 628 629actions assemble 630{ 631$(CC) -c $(2) -O2 $(KERNEL_CCFLAGS) -o $(1) ; 632} 633 634## Kernel stuff! 635 636rule SetupKernel 637{ 638 # Usage SetupKernel <sources_or_objects> : <extra_cc_flags>; 639 640 local _objs = $(1:S=$(SUFOBJ)) ; 641 642 UsePublicHeaders kernel ; 643 UsePublicHeaders [ FDirName os kernel ] ; 644 UsePrivateHeaders kernel ; 645 UseArchHeaders $(OBOS_ARCH) ; 646 647 SetupObjectsDir ; 648 649 CCFLAGS on $(_objs) = $(KERNEL_CCFLAGS) $(2) ; 650 C++FLAGS on $(_objs) = $(KERNEL_CCFLAGS) $(2) ; 651} 652 653rule KernelObjects 654{ 655 SetupKernel $(1) : $(2) ; 656 657 Objects $(1) ; 658} 659 660rule KernelLd 661{ 662 # KernelLd <name> : <objs> : <linkerscript> : <args> : <gcc_off> ; 663 664 SetupKernel $(2) ; 665 LINK on $(1) = ld ; 666 667 LINKFLAGS on $(1) = $(4) ; 668 if $(3) { LINKFLAGS on $(1) += --script=$(3) ; } 669 670 # Remove any preset LINKLIBS 671 LINKLIBS on $(1) = ; 672 673 # Show that we depend on the libraries we need 674 Clean clean : $(1) ; 675 Depends all : $(1) ; 676 Depends $(1) : $(2) ; 677 678 if $(6) { 679 Depends $(OBOS_KERNEL_CONFIG) : $(1) ; 680 for i in $(6) { 681 SECTIONS on $(OBOS_KERNEL_CONFIG) += ":" $(i) elf32 [ FDirName $(LOCATE_TARGET) $(1) ] ; 682 } 683 } 684 685 MakeLocate $(1) : $(LOCATE_TARGET) ; 686 687 # Add libgcc.a - NB this should be detected not hard coded! 688 if ! $(5) { 689 LINKLIBS on $(1) += "-L $(GCC_PATH) -lgcc" ; 690 } 691} 692 693actions KernelLd 694{ 695$(LINK) $(LINKFLAGS) -o $(1) $(2) $(LINKLIBS) ; 696} 697 698rule KernelStaticLibrary 699{ 700 # Usage KernelStaticLibrary <name> : <sources> : <extra cc flags> ; 701 # This is designed to take a set of sources and libraries and create 702 # a file called lib<name>.a 703 704 SetupKernel $(2) : $(3) ; 705 706 MakeLocateObjects $(2) ; 707 Library $(1) : $(2) ; 708} 709 710rule KernelStaticLibraryObjects 711{ 712 # Usage KernelStaticLibrary <name> : <sources> ; 713 # This is designed to take a set of sources and libraries and create 714 # a file called <name> 715 716 SetupKernel $(2) ; 717 718 # Show that we depend on the libraries we need 719 Clean clean : $(1) ; 720 Depends all : $(1) ; 721 Depends $(1) : $(2) ; 722 723 MakeLocate $(1) : $(LOCATE_TARGET) ; 724} 725 726actions KernelStaticLibraryObjects 727{ 728ar -r $(1) $(2) ; 729} 730 731rule SystemMain 732{ 733 # Usage SystemMain <target> : <sources> : <rqd_by> ; 734 SetupObjectsDir ; 735 736 LINKLIBS = ; 737 738 # This allows us to preset certain commands we use 739 # for building. 740 if $(3) { 741 for obj in $(3) { 742 BUILD_CMD on $(obj) = [ FDirName $(LOCATE_TARGET) $(1) ] ; 743 } 744 } 745 746 Main $(1) : $(2) ; 747} 748 749rule KernelConfigSection 750{ 751 # KernelConfigSection <section> : <type> : <file> ; 752 SECTIONS on $(OBOS_KERNEL_CONFIG) += ":" $(1) $(2) $(3) ; 753} 754 755rule WriteKernelConfig 756{ 757 # usage: WriteKernelConfig <target> ; 758 759 Depends files : $(1) ; 760 761 LOCATE on $(1) = $(LOCATE_TARGET) ; 762 763 MakeLocate $(1) : $(LOCATE_TARGET) ; 764 765 Clean clean : $(1) ; 766} 767 768actions WriteKernelConfig 769{ 770 target=$(1) 771 echo "# OpenBeOS Kernel Config File" > $target 772 echo "# Automatically generated - do not edit!" >> $target 773 issection="0" 774 section= 775 for i in "$(SECTIONS)" ; do 776 if [ $issection == 1 ]; then 777 section=$i 778 issection=2 779 echo "["$section"]" >> $target 780 elif [ $issection == 2 ]; then 781 type=$i 782 issection=3 783 echo "type="$type >> $target 784 else 785 if [ $i == ":" ]; then 786 issection=1 787 echo "" >> $target 788 else 789 file=$i 790 case $file in 791 /*) ;; 792 *) file=`pwd`/$file;; 793 esac 794 echo "file="$file >> $target 795 fi 796 fi 797 done 798} 799 800rule BuildKernel 801{ 802 # Usage BuildKernel <target> : <config_file> ; 803 804 Depends all : $(1) ; 805 Depends $(1) : $(2) ; 806 Clean clean : $(1) ; 807 808 MakeLocate $(1) : $(LOCATE_TARGET) ; 809} 810 811actions BuildKernel 812{ 813 $(BUILD_CMD) --strip-debug --strip-binary strip $(2) -o $(1) ; 814 echo "" 815 echo "Kernel linked!" 816 echo "" 817} 818 819# At present I don't bother moving the final location for 820# the floppy image as it makes copying it onto a floppy easier if it's 821# where you did the build. This is easy enough changed. 822rule KernelFloppyImage 823{ 824 # Usage KernelFloppyImage <target> : <kernel> : <bootblock> ; 825 826 Depends all : $(1) ; 827 Depends $(1) : $(2) ; 828 Clean clean : $(1) ; 829 830 BOOT_BLOCK on $(1) = $(3) ; 831} 832 833# This may be a bit verbose, but I think it's useful to show what's 834# going on, at least in this early stage of development. 835actions KernelFloppyImage 836{ 837 $(BUILD_CMD) $(BOOT_BLOCK) $(2) $(1) ; 838 echo "" 839 echo "*************************************************" 840 echo "* Kernel build completed! *" 841 echo "* Boot image for a 1.44M floppy created *" 842 echo "*************************************************" 843 echo "" 844 echo "Floppy image is $(OBOS_FLOPPY)" 845 echo "The following command will write it to a floppy on BeOS" 846 echo " dd if=$(OBOS_FLOPPY) of=/dev/disk/floppy/raw bs=18k" 847 echo "" 848} 849 850 851