1 rule FSameTargetWithPrependedGrist
3 # SameTargetWithPrependedGrist <target> : <grist to prepend> ;
6 local gristToPrepend = $(2) ;
7 local grist = $(target:G) ;
10 grist = $(gristToPrepend)!$(grist) ;
12 grist = $(gristToPrepend) ;
15 return $(target:G=$(grist)) ;
20 # Note: The script must have been LOCATEd before.
23 = [ FSameTargetWithPrependedGrist $(script) : init-script ] ;
25 if ! [ on $(script) return $(__is_initialized) ] {
26 __is_initialized on $(script) = true ;
28 MakeLocate $(initScript) : [ on $(script) return $(LOCATE) ] ;
29 Always $(initScript) ;
30 Depends $(script) : $(initScript) ;
32 InitScript1 $(initScript) ;
35 return $(initScript) ;
44 rule AddVariableToScript script : variable : value
46 # AddVariableToScript <script> : <variable> : <value> ;
48 # interpret an empty variable value as empty string
53 InitScript $(script) ;
55 VARIABLE_DEFS on $(script) += "echo $(variable)=\\\"$(value[1])\\\" >> " ;
57 # if the value is an array, add the other array elements
58 value = $(value[2-]) ;
60 VARIABLE_DEFS on $(script)
61 += "echo $(variable)=\\\" \\\$$(variable) $(value[1])\\\" >> " ;
62 value = $(value[2-]) ;
65 AddVariableToScript1 $(script) ;
68 actions together AddVariableToScript1
74 rule AddTargetVariableToScript script : targets : variable
76 # AddTargetVariableToScript <script> : <targets> [ : <variable> ] ;
78 # If <targets> contains multiple targets, their paths must not contain
79 # whitespaces or other characters that need to be escaped in the shell.
81 variable ?= $(3:E=$(targets[1]:BS)) ;
83 local initScript = [ InitScript $(script) ] ;
85 serialization = [ on $(script) return $(HAIKU_SERIALIZATION) ] ;
87 local variableTarget = [ NewUniqueTarget ] ;
88 NotFile $(variableTarget) ;
89 Depends $(variableTarget) : $(initScript) $(targets) $(serialization) ;
90 Depends $(script) : $(variableTarget) ;
92 HAIKU_SERIALIZATION on $(script) = $(variableTarget) ;
94 HAIKU_VARIABLE_NAME on $(variableTarget) = $(variable) ;
95 AddTargetVariableToScript1 $(variableTarget) : $(initScript) $(targets) ;
99 actions AddTargetVariableToScript1
102 echo "$(HAIKU_VARIABLE_NAME)=" >> "$script"
105 for value in "$(2[2-])" ; do
106 if [ -z "$firstSeen" ]; then
107 echo "$(HAIKU_VARIABLE_NAME)=\"$value\"" >> "$script"
110 echo "$(HAIKU_VARIABLE_NAME)=\"\$$(HAIKU_VARIABLE_NAME) $value\"" \
119 rule AddDirectoryToContainer container : directoryTokens : attributeFiles
121 # AddDirectoryToContainer <container> : <directoryTokens> : <attributeFiles>
123 local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ;
124 local directory = [ FDirName $(directoryTokens) ] ;
125 directory = $(directory:G=$(containerGrist)) ;
127 if ! [ on $(directory) return $(__is_on_image) ] {
128 HAIKU_INSTALL_DIRECTORIES on $(container) += $(directory) ;
129 __is_on_image on $(directory) = true ;
130 DIRECTORY_TOKENS on $(directory) = $(directoryTokens) ;
131 NotFile $(directory) ;
133 # mark the parent dir as not to be created
134 local parent = [ FReverse $(directoryTokens) ] ;
135 parent = [ FReverse $(parent[2-]) ] ;
137 parent = [ FDirName $(parent) ] ;
138 parent = $(parent:G=$(containerGrist)) ;
139 DONT_CREATE on $(parent) = true ;
143 if $(attributeFiles) {
144 SEARCH on $(attributeFiles)
145 += [ FDirName $(HAIKU_TOP) data image_directories ] ;
146 ATTRIBUTE_FILES on $(dir) += $(attributeFiles) ;
149 return $(directory) ;
152 rule FilterContainerUpdateTargets targets : filterVariable
154 # FilterContainerUpdateTargets targets : filterVariable
156 local filteredTargets ;
158 for target in $(targets) {
159 if [ on $(target) return $($(filterVariable)) ] {
160 filteredTargets += $(target) ;
163 return $(filteredTargets) ;
167 rule IncludeAllTargetsInContainer container
170 = [ on $(container) return $(HAIKU_INCLUDE_IN_CONTAINER_VAR) ] ;
172 return $($(filterVar)) ;
179 rule PropagateContainerUpdateTargetFlags toTarget : fromTarget
181 if [ on $(fromTarget) return $(HAIKU_INCLUDE_IN_IMAGE) ] {
182 HAIKU_INCLUDE_IN_IMAGE on $(toTarget) = 1 ;
185 if [ on $(fromTarget) return $(HAIKU_INCLUDE_IN_PACKAGES) ] {
186 HAIKU_INCLUDE_IN_PACKAGES on $(toTarget) = 1 ;
191 rule AddFilesToContainer container : directoryTokens : targets : destName
194 # AddFilesToContainer <container> : <directoryTokens> : <targets>
195 # : [ <destName> ] : [ <flags> ]
198 # computeName - <destName> is the name of a shell command/function that
199 # computes the destination name.
200 # alwaysUpdate - When only updating the container, always also update the
203 local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ;
204 local systemDirTokens
205 = [ on $(container) return $(HAIKU_CONTAINER_SYSTEM_DIR_TOKENS) ] ;
207 targets = [ FFilterByBuildFeatures $(targets) ] ;
209 # If the image shall only be updated, we filter out all targets not marked
211 if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
212 && ! [ IncludeAllTargetsInContainer $(container) ]
213 && ! alwaysUpdate in $(flags) {
215 = [ on $(container) return $(HAIKU_INCLUDE_IN_CONTAINER_VAR) ] ;
217 targets = [ FilterContainerUpdateTargets $(targets)
220 # If there are any targets, mark the container as to be included in
221 # an update, too, if it has set the update inheritance variable.
222 # This makes updating a target that lives in a package on an image
225 local updateVariable = [ on $(container) return
226 $(HAIKU_CONTAINER_INHERIT_UPDATE_VARIABLE) ] ;
227 if $(updateVariable) {
228 $(updateVariable) on $(container) = 1 ;
238 local directory = [ AddDirectoryToContainer $(container)
239 : $(directoryTokens) ] ;
241 # We create a unique dummy target per target to install.
242 local installTargetsVar
243 = [ on $(container) return $(HAIKU_INSTALL_TARGETS_VAR) ] ;
244 local stripExecutables
245 = [ on $(container) return $(HAIKU_CONTAINER_STRIP_EXECUTABLES) ] ;
247 for target in $(targets) {
251 if computeName in $(flags) {
252 nameFunction = $(destName) ;
253 name = $(destName)/$(target:BSM) ;
258 name = $(target:BSM) ;
261 local installTarget = $(target) ;
262 if $(stripExecutables)
263 && [ on $(target) return $(HAIKU_TARGET_IS_EXECUTABLE) ] {
264 installTarget = [ StripFiles $(target) ] ;
267 local destTarget = $(name:G=$(containerGrist)__$(directory:G=)) ;
268 TARGET on $(destTarget) = $(installTarget) ;
269 INSTALL_DIR on $(destTarget) = $(directory) ;
270 NAME_FUNCTION on $(destTarget) = $(nameFunction) ;
271 $(installTargetsVar) on $(target) += $(destTarget) ;
272 TARGETS_TO_INSTALL on $(directory) += $(destTarget) ;
274 # If the target is associated with catalog files, add those, too.
275 local catalogs = [ on $(target) return $(HAIKU_CATALOG_FILES) ] ;
278 = [ on $(target) return $(HAIKU_CATALOG_SIGNATURE) ] ;
279 AddFilesToContainer $(container)
280 : $(systemDirTokens) data locale catalogs $(signature)
284 # If the target is associated with MIME DB entries, add those, too.
285 local mimeDBEntries = [ on $(target) return $(HAIKU_MIME_DB_ENTRIES) ] ;
286 if $(mimeDBEntries) {
287 # Make sure we add the entries only once by tracking the containers
288 # we have already added it to.
289 local containers = [ on $(mimeDBEntries)
290 return $(HAIKU_MIME_DB_ENTRIES_IN_CONTAINERS) ] ;
291 if ! $(container) in $(containers) {
292 HAIKU_MIME_DB_ENTRIES_IN_CONTAINERS on $(mimeDBEntries)
293 = $(containers) $(container) ;
294 CopyDirectoryToContainer $(container) : data
295 : $(mimeDBEntries) : mime_db : : alwaysUpdate isTarget ;
301 rule FFilesInContainerDirectory container : directoryTokens
303 local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ;
304 local directory = [ FDirName $(directoryTokens) ] ;
305 directory = $(directory:G=$(containerGrist)) ;
307 if [ on $(directory) return $(__is_on_image) ] {
308 on $(directory) return $(TARGETS_TO_INSTALL) ;
314 rule AddSymlinkToContainer container : directoryTokens : linkTarget : linkName
316 # AddSymlinkToContainer <container> : <directory> : <link target>
317 # [ : <link name> ] ;
320 # If the image shall only be updated, we don't add any symlinks.
321 if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
322 && ! [ IncludeAllTargetsInContainer $(container) ] {
326 local directory = [ AddDirectoryToContainer $(container)
327 : $(directoryTokens) ] ;
330 local path = [ FReverse [ FSplitPath $(linkTarget) ] ] ;
331 linkName = $(path[1]) ;
334 local link = $(directory)/$(linkName) ;
335 SYMLINK_TARGET on $(link) = $(linkTarget) ;
336 SYMLINKS_TO_INSTALL on $(directory) += $(link) ;
339 rule FSymlinksInContainerDirectory container : directoryTokens
341 local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ;
342 local directory = [ FDirName $(directoryTokens) ] ;
343 directory = $(directory:G=$(containerGrist)) ;
345 if [ on $(directory) return $(__is_on_image) ] {
346 on $(directory) return $(SYMLINKS_TO_INSTALL) ;
352 rule CopyDirectoryToContainer container : directoryTokens : sourceDirectory
353 : targetDirectoryName : excludePatterns : flags
355 # CopyDirectoryToContainer <container> : <directoryTokens>
356 # : <sourceDirectory> : <targetDirectoryName> : <excludePatterns>
359 # Supported flags: alwaysUpdate, isTarget
360 # isTarget: <sourceDirectory> is a target, not a path
362 # If the image shall only be updated, we don't copy any directories
363 if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
364 && ! [ IncludeAllTargetsInContainer $(container) ]
365 && ! alwaysUpdate in $(flags) {
369 if ! $(targetDirectoryName) {
370 targetDirectoryName = $(sourceDirectory[1]:BSM) ;
373 # If sourceDirectory is a path, not a target, make it a target, so we can
374 # treat both the same way.
375 if ! isTarget in $(flags) {
376 sourceDirectory = $(sourceDirectory:G=copy-directory-to-container) ;
377 SEARCH on $(sourceDirectory) = ;
378 TARGET on $(sourceDirectory) = ;
381 local directory = [ AddDirectoryToContainer $(container)
382 : $(directoryTokens) $(targetDirectoryName) ] ;
384 local targetDir = $(directory)/-/$(sourceDirectory) ;
385 Depends $(targetDir) : $(sourceDirectory) ;
386 EXCLUDE_PATTERNS on $(targetDir) = $(excludePatterns) ;
387 SOURCE_DIRECTORY on $(targetDir) = $(sourceDirectory) ;
388 TARGET_DIRECTORY on $(targetDir) = $(directory) ;
389 DIRECTORIES_TO_INSTALL on $(directory) += $(targetDir) ;
393 rule AddHeaderDirectoryToContainer container : dirTokens : dirName
396 # AddHeaderDirectoryToContainer <container> : <dirTokens> : [ <dirName> ]
399 # Supported flags: alwaysUpdate
401 local systemDirTokens
402 = [ on $(container) return $(HAIKU_CONTAINER_SYSTEM_DIR_TOKENS) ] ;
404 CopyDirectoryToContainer $(container) : $(systemDirTokens) develop headers
405 : [ FDirName $(HAIKU_TOP) headers $(dirTokens) ]
406 : $(dirName) : -x *~ : $(flags) ;
410 rule AddWifiFirmwareToContainer container : driver : package : archive : extract
412 # AddWifiFirmwareToContainer <container> : <driver> : <package> : <archive>
415 # complete location to wifi firmware archive
416 local firmwareArchive = [ FDirName
417 $(HAIKU_TOP) data system data firmware $(driver) $(archive) ] ;
419 local systemDirTokens
420 = [ on $(container) return $(HAIKU_CONTAINER_SYSTEM_DIR_TOKENS) ] ;
422 local dirTokens = $(systemDirTokens) data firmware $(driver) ;
423 if $(extract) = true || $(extract) = 1 {
424 ExtractArchiveToContainer $(container) : $(dirTokens)
425 : $(firmwareArchive) : : $(package) ;
427 AddFilesToContainer $(container) : $(dirTokens) : $(firmwareArchive) ;
432 rule ExtractArchiveToContainer container : directoryTokens : archiveFile
433 : flags : extractedSubDir
435 # ExtractArchiveToContainer <container> : <directory> : <archiveFile>
436 # : [ <flags> ] : <extractedSubDir> ;
438 # Supported flags: alwaysUpdate
440 # If the container shall only be updated, we extract only, if explicitely
442 if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
443 && ! alwaysUpdate in $(flags) {
447 local directory = [ AddDirectoryToContainer $(container)
448 : $(directoryTokens) ] ;
450 ARCHIVE_FILES_TO_INSTALL on $(directory) += $(archiveFile) ;
451 ARCHIVE_SUBDIR_TO_INSTALL_FROM on $(archiveFile) = $(extractedSubDir) ;
454 rule AddDriversToContainer container : relativeDirectoryTokens : targets
456 # AddDriversToContainer <container> : <relative directory> : <targets> ;
458 local systemDirTokens
459 = [ on $(container) return $(HAIKU_CONTAINER_SYSTEM_DIR_TOKENS) ] ;
460 local directoryTokens = $(systemDirTokens) add-ons kernel drivers dev
461 $(relativeDirectoryTokens) ;
463 targets = [ FFilterByBuildFeatures $(targets) ] ;
465 # A driver can be in multiple categories. Avoid adding it to the bin/
466 # directory more than once.
469 for target in $(targets) {
471 = [ on $(target) return $(HAIKU_DRIVER_IN_CONTAINERS) ] ;
472 if ! $(container) in $(containers) {
473 HAIKU_DRIVER_IN_CONTAINERS on $(target)
474 = $(containers) $(container) ;
475 binTargets += $(target) ;
479 AddFilesToContainer $(container)
480 : $(systemDirTokens) add-ons kernel drivers bin
483 # If the image shall only be updated, we don't add any symlinks.
484 if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
485 && ! [ IncludeAllTargetsInContainer $(container) ] {
489 # get the relative symlink path prefix
492 for i in $(relativeDirectoryTokens) {
495 linkPrefix += .. bin ;
499 for name in $(targets:BSM) {
500 AddSymlinkToContainer $(container) : $(directoryTokens)
501 : [ FDirName $(linkPrefix) $(name) ] : $(name) ;
505 rule AddNewDriversToContainer container : relativeDirectoryTokens
508 # AddNewDriversToContainer <container> : <directory> : <targets> : <flags> ;
511 # alwaysUpdate - When only updating the container, always also update the
514 local systemDirTokens
515 = [ on $(container) return $(HAIKU_CONTAINER_SYSTEM_DIR_TOKENS) ] ;
516 local directoryTokens = $(systemDirTokens) add-ons kernel drivers
517 $(relativeDirectoryTokens) ;
519 targets = [ FFilterByBuildFeatures $(targets) ] ;
521 AddFilesToContainer $(container) : $(directoryTokens)
522 : $(targets) : : $(flags) ;
525 rule AddBootModuleSymlinksToContainer container : targets
527 # AddBootModuleSymlinksToContainer <container> : <targets> ;
530 # If the container shall only be updated, we don't add any symlinks.
532 if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
533 && ! [ IncludeAllTargetsInContainer $(container) ] {
537 local systemDirTokens
538 = [ on $(container) return $(HAIKU_CONTAINER_SYSTEM_DIR_TOKENS) ] ;
539 targets = [ FFilterByBuildFeatures $(targets) ] ;
542 local installTargetsVar
543 = [ on $(container) return $(HAIKU_INSTALL_TARGETS_VAR) ] ;
545 for target in $(targets) {
546 # Symlink to the first place where the target has been installed.
547 local destTarget = [ on $(target) return $($(installTargetsVar)[1]) ] ;
548 local installDir = [ on $(destTarget) return $(INSTALL_DIR) ] ;
551 Echo "ERROR: AddBootModuleSymlinksToContainer: Can't create a "
552 "symlink to target" \"$(target)"\"." ;
553 Exit "ERROR: Add*ToContainer has not been invoked for it yet." ;
556 # chop off the system dir prefix from installDir
557 installDir = [ on $(installDir) return $(DIRECTORY_TOKENS) ] ;
559 for dummy in $(systemDirTokens) {
560 installDir = $(installDir[2-]) ;
563 local name = $(target:BSM) ;
564 local linkTarget = [ FDirName ../../.. $(installDir) $(name) ] ;
566 AddSymlinkToContainer $(container)
567 : $(systemDirTokens) add-ons kernel boot
568 : $(linkTarget) : $(name) ;
573 rule AddLibrariesToContainer container : directory : libs
575 # AddLibrariesToContainer <container> : <directory> : <libs>
577 # Installs libraries with the appropriate links into the container.
582 local abiVersion = [ on $(lib) return $(HAIKU_LIB_ABI_VERSION) ] ;
584 local abiVersionedLib = $(lib:G=).$(abiVersion) ;
585 AddFilesToContainer $(container) : $(directory) : $(lib)
586 : $(abiVersionedLib) ;
587 AddSymlinkToContainer $(container) : $(directory)
588 : $(abiVersionedLib) : $(lib:G=) ;
590 AddFilesToContainer $(container) : $(directory) : $(lib) ;
596 rule CreateContainerMakeDirectoriesScript container : script
598 MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ;
601 local initScript = [ InitScript $(script) ] ;
604 = [ FSameTargetWithPrependedGrist $(script) : script-body ] ;
605 LOCATE on $(scriptBody) = [ on $(script) return $(LOCATE) ] ;
606 Depends $(scriptBody) : $(initScript) ;
607 Depends $(script) : $(scriptBody) ;
609 # collect the directories to create
612 = [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] ;
614 for dir in $(directories) {
615 if ! [ on $(dir) return $(DONT_CREATE) ] {
616 dirsToCreate += $(dir) ;
620 # If the image shall only be updated, we don't create directories.
622 && ( ! [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
623 || [ IncludeAllTargetsInContainer $(container) ]
624 || [ on $(container) return
625 $(HAIKU_CONTAINER_ALWAYS_CREATE_DIRECTORIES) ] ) {
626 Depends $(scriptBody) : $(dirsToCreate) ;
627 CreateContainerMakeDirectoriesScript1 $(scriptBody) : $(dirsToCreate) ;
629 local serializationDependency = $(scriptBody) ;
630 # Used to create a dependency chain between the dummy targets.
631 # This forces jam to build them one after the other, thus preventing
632 # concurrent writes to the script file when building with multiple
635 # For directories with attributes, we convert those the specified
636 # resource files to files with attributes and add commands to the script
637 # adding the attributes to the directories.
638 for dir in $(directories) {
639 local resourceFiles = [ on $(dir) return $(ATTRIBUTE_FILES) ] ;
640 if $(resourceFiles) {
641 local dirTokens = [ on $(dir) return $(DIRECTORY_TOKENS) ] ;
643 # translate resources file to file with attributes
644 local attributeFile = $(script)-attributes-$(dirTokens:J=-) ;
645 ResAttr $(attributeFile) : $(resourceFiles) ;
647 # use a unique dummy target for this file, on which we
648 # can define the TARGET_DIR variable
649 local dummyTarget = $(script)-attributes-dummy-$(dir:G=) ;
650 NotFile $(dummyTarget) ;
651 TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
653 Depends $(dummyTarget) : $(initScript) $(attributeFile)
654 $(serializationDependency) ;
655 Depends $(script) : $(dummyTarget) ;
656 serializationDependency = $(dummyTarget) ;
658 AppendToContainerMakeDirectoriesScriptAttributes $(dummyTarget)
659 : $(initScript) $(attributeFile) ;
665 actions piecemeal CreateContainerMakeDirectoriesScript1
667 echo \$mkdir -p "\"\${tPrefix}$(2:G=)\"" >> $(1)
670 actions AppendToContainerMakeDirectoriesScriptAttributes
672 echo \$copyAttrs "\"\${sPrefix}$(2[2])\"" \
673 "\"\${tPrefix}$(TARGET_DIR)\"" >> $(2[1])
676 rule CreateContainerCopyFilesScript container : script
678 MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ;
681 local initScript = [ InitScript $(script) ] ;
684 = [ FSameTargetWithPrependedGrist $(script) : script-body ] ;
685 LOCATE on $(scriptBody) = [ on $(script) return $(LOCATE) ] ;
686 Depends $(scriptBody) : $(initScript) ;
687 Depends $(script) : $(scriptBody) ;
689 local serializationDependency = $(scriptBody) ;
690 # Used to create a dependency chain between the dummy targets.
691 # This forces jam to build them one after the other, thus preventing
692 # concurrent writes to the script file when building with multiple
696 for dir in [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] {
697 # filter the targets that shall be renamed; they have to be copied
699 local destTargets = [ on $(dir) return $(TARGETS_TO_INSTALL) ] ;
700 local remainingTargets ;
702 for destTarget in $(destTargets) {
703 local target = [ on $(destTarget) return $(TARGET) ] ;
704 local name = $(destTarget:G=) ;
705 if $(name) != $(target:BSM) {
706 # use a unique dummy target for this file, on which we
707 # can define the TARGET_DIR variable
708 local dummyTarget = $(script)-dummy-$(dir:G=)-$(target) ;
709 NotFile $(dummyTarget) ;
710 TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
713 = [ on $(destTarget) return $(NAME_FUNCTION) ] ;
715 INSTALL_TARGET_NAME on $(dummyTarget) = "\\${name}" ;
717 INSTALL_TARGET_NAME on $(dummyTarget) = $(name) ;
719 NAME_FUNCTION on $(dummyTarget) = $(nameFunction) ;
721 Depends $(dummyTarget) : $(initScript) $(target)
722 $(serializationDependency) ;
723 Depends $(script) : $(dummyTarget) ;
724 serializationDependency = $(dummyTarget) ;
726 AppendToContainerCopyFilesScriptSingleFile $(dummyTarget)
727 : $(initScript) $(target) ;
729 remainingTargets += $(target) ;
732 targets = $(remainingTargets) ;
735 # use a unique dummy target for this directory, on which we
736 # can define the TARGET_DIR variable
737 local dummyTarget = $(script)-dummy-$(dir:G=) ;
738 NotFile $(dummyTarget) ;
739 TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
741 Depends $(dummyTarget) : $(initScript) $(targets)
742 $(serializationDependency) ;
743 Depends $(script) : $(dummyTarget) ;
744 serializationDependency = $(dummyTarget) ;
746 OUTPUT_SCRIPT on $(dummyTarget) = $(initScript) ;
747 AppendToContainerCopyFilesScript $(dummyTarget) : $(targets) ;
750 local symlinks = [ on $(dir) return $(SYMLINKS_TO_INSTALL) ] ;
752 for symlink in $(symlinks) {
755 Depends $(script) : $(symlink) ;
756 Depends $(symlink) : $(initScript) $(serializationDependency) ;
757 serializationDependency = $(symlink) ;
759 AddSymlinkToContainerCopyFilesScript $(symlink) : $(initScript) ;
762 local targetDirs = [ on $(dir) return $(DIRECTORIES_TO_INSTALL) ] ;
764 for targetDir in $(targetDirs) {
765 NotFile $(targetDir) ;
767 Depends $(script) : $(targetDir) ;
768 Depends $(targetDir) : $(initScript) $(serializationDependency) ;
769 serializationDependency = $(targetDir) ;
771 AddDirectoryToContainerCopyFilesScript $(targetDir)
778 actions piecemeal AppendToContainerCopyFilesScript bind OUTPUT_SCRIPT
780 echo \$cp "\"\${sPrefix}$(2)\"" "\"\${tPrefix}$(TARGET_DIR)\"" \
785 actions AppendToContainerCopyFilesScriptSingleFile
787 if [ -n "$(NAME_FUNCTION:E)" ]; then
788 echo "name=\`$(NAME_FUNCTION:E) \"$(2[2])\" 2> /dev/null \` || exit 1" \
792 echo \$cp "\"\${sPrefix}$(2[2])\"" \
793 "\"\${tPrefix}$(TARGET_DIR)/$(INSTALL_TARGET_NAME)\"" >> $(2[1])
797 actions AddSymlinkToContainerCopyFilesScript
799 echo \$ln -sfn "\"$(SYMLINK_TARGET)\"" "\"\${tPrefix}$(1:G=)\"" >> $(2[1])
803 actions AddDirectoryToContainerCopyFilesScript bind SOURCE_DIRECTORY
805 echo \$cp -r $(EXCLUDE_PATTERNS) "\"\${sPrefix}$(SOURCE_DIRECTORY)/.\"" \
806 "\"\${tPrefix}$(TARGET_DIRECTORY:G=)\"" >> $(2[1])
810 rule CreateContainerExtractFilesScript container : script
812 MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ;
815 local initScript = [ InitScript $(script) ] ;
818 = [ FSameTargetWithPrependedGrist $(script) : script-body ] ;
819 LOCATE on $(scriptBody) = [ on $(script) return $(LOCATE) ] ;
820 Depends $(scriptBody) : $(initScript) ;
821 Depends $(script) : $(scriptBody) ;
823 local serializationDependency = $(scriptBody) ;
824 # Used to create a dependency chain between the dummy targets.
825 # This forces jam to build them one after the other, thus preventing
826 # concurrent writes to the script file when building with multiple
830 for dir in [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] {
831 local archiveFiles = [ on $(dir) return $(ARCHIVE_FILES_TO_INSTALL) ] ;
833 for archiveFile in $(archiveFiles) {
834 # use a unique dummy target for this file, on which we
835 # can define the TARGET_DIR variable
836 local dummyTarget = $(script)-dummy-$(dir:G=)-$(archiveFile) ;
837 NotFile $(dummyTarget) ;
838 TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
840 local extractedSubDir = [ on $(archiveFile)
841 return $(ARCHIVE_SUBDIR_TO_INSTALL_FROM) ] ;
842 ARCHIVE_SUBDIR_TO_INSTALL_FROM on $(dummyTarget) =
843 $(extractedSubDir:E=.) ;
845 Depends $(dummyTarget) : $(initScript) $(archiveFile)
846 $(serializationDependency) ;
847 Depends $(script) : $(dummyTarget) ;
848 serializationDependency = $(dummyTarget) ;
850 AddExtractFileToContainerExtractFilesScript $(dummyTarget)
851 : $(initScript) $(archiveFile) ;
857 actions AddExtractFileToContainerExtractFilesScript
859 echo extractFile "\"$(2[2])\"" "\"$(TARGET_DIR)\"" \
860 "\"$(ARCHIVE_SUBDIR_TO_INSTALL_FROM)\"" >> $(2[1])
864 rule AddPackagesAndRepositoryVariablesToContainerScript script : container
866 AddVariableToScript $(script) : downloadDir : $(HAIKU_DOWNLOAD_DIR) ;
867 AddTargetVariableToScript $(script) : <build>package ;
868 AddTargetVariableToScript $(script) : <build>get_package_dependencies
869 : getPackageDependencies ;
871 # Add a variable to indicate whether packages dependencies shall be
872 # resolved. We always want to do that in non-update mode, but also in update
873 # mode when all packages are updated.
875 = [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] ;
876 local resolvePackageDependencies ;
877 if ( ! $(updateOnly) || $(HAIKU_UPDATE_ALL_PACKAGES) )
878 && $(HAIKU_BUILD_TYPE) != bootstrap {
879 resolvePackageDependencies = 1 ;
881 AddVariableToScript $(script) : resolvePackageDependencies
882 : $(resolvePackageDependencies) ;
884 AddVariableToScript $(script) : noDownloads : $(HAIKU_NO_DOWNLOADS) ;
886 AddVariableToScript $(script) : updateAllPackages
887 : $(HAIKU_UPDATE_ALL_PACKAGES) ;
889 # Add variable "systemPackages" with the packages copied/updated.
890 local allPackages = [ on $(container) return $(HAIKU_PACKAGES_IN_IMAGE) ] ;
891 if $(updateOnly) && ! [ IncludeAllTargetsInContainer $(container) ] {
892 allPackages = [ FilterContainerUpdateTargets $(allPackages)
893 : [ on $(container) return $(HAIKU_INCLUDE_IN_CONTAINER_VAR) ] ] ;
896 AddTargetVariableToScript $(script) : $(allPackages) : systemPackages ;
898 # Generate the repository package lists and add variables for the
901 local repositoryFiles ;
902 for repository in $(HAIKU_REPOSITORIES) {
904 += [ on $(repository) return $(HAIKU_REPOSITORY_CACHE_FILE) ] ;
907 AddTargetVariableToScript $(script) : $(repositoryFiles) : repositories ;
911 #pragma mark - Haiku Image rules
913 rule SetUpdateHaikuImageOnly flag
915 HAIKU_CONTAINER_UPDATE_ONLY on $(HAIKU_IMAGE_CONTAINER_NAME) = $(flag) ;
918 rule IsUpdateHaikuImageOnly
920 on $(HAIKU_IMAGE_CONTAINER_NAME) return $(HAIKU_CONTAINER_UPDATE_ONLY) ;
923 rule AddDirectoryToHaikuImage directoryTokens : attributeFiles
925 # AddDirectoryToHaikuImage <directoryTokens> : <attributeFiles>
927 return [ AddDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME)
928 : $(directoryTokens) : $(attributeFiles) ] ;
931 rule AddFilesToHaikuImage directory : targets : destName : flags
933 # AddFilesToHaikuImage <directory> : <targets> : [ <destName> ]
936 AddFilesToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directory)
937 : $(targets) : $(destName) : $(flags) ;
940 rule FFilesInHaikuImageDirectory directoryTokens
942 return [ FFilesInContainerDirectory $(HAIKU_IMAGE_CONTAINER_NAME)
943 : $(directoryTokens) ] ;
946 rule AddSymlinkToHaikuImage directoryTokens : linkTarget : linkName
948 # AddSymlinkToHaikuImage <directory> : <link target> [ : <link name> ] ;
950 linkTarget = $(linkTarget:J=/) ;
952 AddSymlinkToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directoryTokens)
953 : $(linkTarget) : $(linkName) ;
956 rule FSymlinksInHaikuImageDirectory directoryTokens
958 return [ FSymlinksInContainerDirectory $(HAIKU_IMAGE_CONTAINER_NAME)
959 : $(directoryTokens) ] ;
962 rule CopyDirectoryToHaikuImage directoryTokens : sourceDirectory
963 : targetDirectoryName : excludePatterns : flags
965 CopyDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directoryTokens)
966 : $(sourceDirectory) : $(targetDirectoryName) : $(excludePatterns)
970 rule AddSourceDirectoryToHaikuImage dirTokens : flags
972 # AddSourceDirectoryToHaikuImage <dirTokens> : <flags> ;
974 CopyDirectoryToHaikuImage home HaikuSources
975 : [ FDirName $(HAIKU_TOP) $(dirTokens) ]
979 rule AddHeaderDirectoryToHaikuImage dirTokens : dirName : flags
981 # AddHeaderDirectoryToHaikuImage <dirTokens> : [ <dirName> ]
984 AddHeaderDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(dirTokens)
985 : $(dirName) : $(flags) ;
988 rule AddWifiFirmwareToHaikuImage driver : package : archive : extract
990 # AddWifiFirmwareToHaikuImage <driver> : <package> : <archive> : <extract>
992 AddWifiFirmwareToHaikuImage $(HAIKU_IMAGE_CONTAINER_NAME) : $(driver)
993 : $(package) : $(archive) : $(extract) ;
996 rule ExtractArchiveToHaikuImage dirTokens : archiveFile : flags
999 # ExtractArchiveToHaikuImage <dirTokens> : <archiveFile> : <flags>
1000 # : <extractedSubDir> ;
1002 ExtractArchiveToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(dirTokens)
1003 : $(archiveFile) : $(flags) : $(extractedSubDir) ;
1006 rule AddDriversToHaikuImage relativeDirectoryTokens : targets
1008 # AddDriversToHaikuImage <relative directory> : <targets> ;
1010 AddDriversToContainer $(HAIKU_IMAGE_CONTAINER_NAME)
1011 : $(relativeDirectoryTokens) : $(targets) ;
1014 rule AddNewDriversToHaikuImage relativeDirectoryTokens : targets : flags
1016 # AddNewDriversToHaikuImage <relative directory> : <targets> : <flags> ;
1018 AddNewDriversToContainer $(HAIKU_IMAGE_CONTAINER_NAME)
1019 : $(relativeDirectoryTokens) : $(targets) : $(flags) ;
1022 rule AddBootModuleSymlinksToHaikuImage targets
1024 # AddBootModuleSymlinksToHaikuImage <targets> ;
1026 AddBootModuleSymlinksToContainer $(HAIKU_IMAGE_CONTAINER_NAME)
1030 rule AddPackageFilesToHaikuImage location : packages : flags
1032 # AddPackageFilesToHaikuImage <location> : <packages> : <flags>
1035 # nameFromMetaInfo - determine the target file name from the package meta
1038 packages = [ FFilterByBuildFeatures $(packages) ] ;
1039 HAIKU_PACKAGES_IN_IMAGE on $(HAIKU_IMAGE_CONTAINER_NAME)
1040 = [ on $(HAIKU_IMAGE_CONTAINER_NAME) return $(HAIKU_PACKAGES_IN_IMAGE) ]
1042 HAIKU_PACKAGE_INSTALLATION_LOCATION on $(packages) = $(location) ;
1044 if nameFromMetaInfo in $(flags) {
1045 AddFilesToHaikuImage $(location) packages : $(packages)
1046 : packageFileName : computeName ;
1048 AddFilesToHaikuImage $(location) packages : $(packages) ;
1052 rule AddOptionalHaikuImagePackages packages
1055 for package in $(packages) {
1056 if ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_ADDED) ] {
1057 HAIKU_OPTIONAL_PACKAGE_ADDED on $(package) = 1 ;
1058 HAIKU_ADDED_OPTIONAL_PACKAGES += $(package) ;
1060 local dependencies = [ on $(package)
1061 return $(HAIKU_OPTIONAL_PACKAGE_DEPENDENCIES) ] ;
1062 AddOptionalHaikuImagePackages $(dependencies) ;
1066 rule SuppressOptionalHaikuImagePackages packages
1069 for package in $(packages) {
1070 if ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_SUPPRESSED) ] {
1071 HAIKU_OPTIONAL_PACKAGE_SUPPRESSED on $(package) = 1 ;
1076 rule IsOptionalHaikuImagePackageAdded package
1078 if ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_EXISTS) ] {
1079 HAIKU_OPTIONAL_PACKAGE_EXISTS on $(package) = 1 ;
1080 HAIKU_EXISTING_OPTIONAL_PACKAGES += $(package) ;
1083 if [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_ADDED) ] &&
1084 ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_SUPPRESSED) ] {
1091 rule OptionalPackageDependencies package : dependencies
1093 HAIKU_OPTIONAL_PACKAGE_DEPENDENCIES on $(package) = $(dependencies) ;
1094 if [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_ADDED) ] {
1095 AddOptionalHaikuImagePackages $(dependencies) ;
1100 rule AddHaikuImagePackages packages
1102 # AddHaikuImagePackages <packages> ;
1103 # Adds the given packages <packages> to the image.
1105 packages = [ FFilterByBuildFeatures $(packages) ] ;
1108 for package in $(packages) {
1109 local resolvedPackage = [ IsPackageAvailable $(package) ] ;
1110 if ! $(resolvedPackage) {
1111 Echo "AddHaikuImagePackages: package" $(package)
1116 if ! [ on $(resolvedPackage) return $(HAIKU_PACKAGE_ADDED) ] {
1117 HAIKU_PACKAGE_ADDED on $(resolvedPackage) = 1 ;
1118 HAIKU_ADDED_PACKAGES += $(resolvedPackage) ;
1120 # download the package file and add it to the image
1121 local file = [ FetchPackage $(package) ] ;
1123 if $(HAIKU_UPDATE_ALL_PACKAGES) {
1124 HAIKU_INCLUDE_IN_IMAGE on $(file) = 1 ;
1127 AddPackageFilesToHaikuImage system : $(file) ;
1133 rule IsHaikuImagePackageAdded package
1135 local resolvedPackage = [ IsPackageAvailable $(package) ] ;
1136 if $(resolvedPackage)
1137 && [ on $(resolvedPackage) return $(HAIKU_PACKAGE_ADDED) ] {
1145 rule BuildHaikuImagePackageList target
1151 # get the file names of all added packages
1152 local packageFiles ;
1154 for package in $(HAIKU_ADDED_PACKAGES) {
1155 packageFiles += [ FetchPackage $(package) : nameResolved ] ;
1158 # extract the versioned package names (without revision)
1159 packageFiles = [ Match "^([^-]*)" : $(packageFiles:B) ] ;
1161 HAIKU_IMAGE_PACKAGES on $(target) = $(packageFiles) ;
1165 actions BuildHaikuImagePackageList
1167 echo $(HAIKU_IMAGE_PACKAGES) | xargs -n 1 echo | LC_ALL=C sort -u > $(1)
1171 rule InstallSourceArchive file : url
1173 if $(HAIKU_INCLUDE_SOURCES) = 1 {
1174 # download archive file
1175 local archiveFile = [ DownloadFile $(file) : $(url) ] ;
1177 # copy directly into image
1178 AddFilesToHaikuImage _sources_ : $(archiveFile) ;
1182 rule InstallOptionalHaikuImagePackage url : dirTokens : flags
1184 # TODO: Remove the non-hpkg cases!
1185 # Currently the semantics differs depending on whether the cdPackage flag
1186 # has been specified and the type of the package file:
1187 # * For a hpkg <dirTokens> is ignored. The package will be copied into the
1188 # system/packages directory.
1189 # * For a regular archive and cdPackage, <dirTokens> is ignored and
1190 # the package will be copied to the _package_ directory of the CD image.
1191 # * For a regular archive and without cdPackage, <dirTokens> specifies the
1192 # directory relative to the image's root directory where the content of
1193 # the archive will be extracted to.
1195 # Supported flags: cdPackage
1197 local package = $(url:BS) ;
1199 # download archive file
1200 local archiveFile = [ DownloadFile $(package) : $(url) ] ;
1202 if $(package:S) = .hpkg {
1203 if $(HAIKU_UPDATE_ALL_PACKAGES) {
1204 HAIKU_INCLUDE_IN_IMAGE on $(archiveFile) = 1 ;
1206 AddPackageFilesToHaikuImage system : $(archiveFile) ;
1207 } else if cdPackage in $(flags) && $(HAIKU_CD_NAME) {
1208 # TODO: If HAIKU_CD_NAME is set, that doesn't mean we're building a CD
1211 AddFilesToHaikuImage _packages_ : $(archiveFile) ;
1213 # extract onto image
1214 ExtractArchiveToHaikuImage $(dirTokens) : $(archiveFile) : $(flags) ;
1218 rule AddEntryToHaikuImageUserGroupFile file : entry
1220 local allEntries = [ on $(file) return $(HAIKU_IMAGE_USER_GROUP_ENTRIES) ] ;
1223 allEntries = $(allEntries)|$(entry) ;
1225 allEntries = $(entry) ;
1228 MakeLocate $(file) : $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) ;
1229 BuildHaikuImageUserGroupFile $(file) ;
1230 AddFilesToHaikuImage system settings etc : $(file) ;
1233 HAIKU_IMAGE_USER_GROUP_ENTRIES on $(file) = $(allEntries) ;
1236 actions BuildHaikuImageUserGroupFile
1238 echo "$(HAIKU_IMAGE_USER_GROUP_ENTRIES)" | tr '|' '\n' > $(1)
1241 rule AddUserToHaikuImage user : uid : gid : home : shell : realName
1243 if ! $(user) || ! $(uid) || ! $(gid) || ! $(home) {
1244 Exit "Invalid haiku user specification passed to AddUserToHaikuImage." ;
1248 = $(user):x:$(uid):$(gid):$(realName:E=$(user)):$(home):$(shell:E="") ;
1250 AddEntryToHaikuImageUserGroupFile <haiku-image>passwd : $(entry) ;
1253 rule AddGroupToHaikuImage group : gid : members
1255 if ! $(group) || ! $(gid) {
1256 Exit "Invalid haiku group specification passed to"
1257 "AddGroupToHaikuImage." ;
1260 local entry = $(group):x:$(gid):$(members:J=,:E) ;
1262 AddEntryToHaikuImageUserGroupFile <haiku-image>group : $(entry) ;
1266 rule AddLibrariesToHaikuImage directory : libs
1268 # AddLibraryToHaikuImage <directory> : <libs>
1270 # Installs libraries with the appropriate links onto the image.
1273 AddLibrariesToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directory)
1278 rule CreateHaikuImageMakeDirectoriesScript script
1280 CreateContainerMakeDirectoriesScript $(HAIKU_IMAGE_CONTAINER_NAME)
1284 rule CreateHaikuImageCopyFilesScript script
1286 CreateContainerCopyFilesScript $(HAIKU_IMAGE_CONTAINER_NAME) : $(script) ;
1289 rule CreateHaikuImageExtractFilesScript script
1291 CreateContainerExtractFilesScript $(HAIKU_IMAGE_CONTAINER_NAME)
1295 rule BuildHaikuImage haikuImage : scripts : isImage : isVMwareImage
1297 # BuildHaikuImage <haiku image> : <scripts> : <is image> : <isVMwareImage> ;
1299 if $(isImage) = 1 || $(isImage) = true {
1300 IS_IMAGE on $(haikuImage) = 1 ;
1302 IS_IMAGE on $(haikuImage) = "" ;
1305 if $(isVMwareImage) = 1 || $(isVMwareImage) = true {
1306 IS_VMWARE_IMAGE on $(haikuImage) = 1 ;
1308 IS_VMWARE_IMAGE on $(haikuImage) = "" ;
1311 local mainScript = build_haiku_image ;
1312 SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ;
1314 Depends $(haikuImage) : $(mainScript) $(scripts) ;
1315 BuildHaikuImage1 $(haikuImage) : $(mainScript) $(scripts) ;
1318 actions BuildHaikuImage1
1320 export imagePath="$(1)"
1321 export isImage="$(IS_IMAGE)"
1322 export isVMwareImage="$(IS_VMWARE_IMAGE)"
1326 rule BuildVMWareImage vmwareImage : plainImage : imageSize
1328 # BuildVMWareImage <vmware image> : <plain image> : <image size in MB>
1330 IMAGE_SIZE on $(vmwareImage) = $(imageSize) ;
1332 Depends $(vmwareImage) : <build>vmdkheader $(plainImage) ;
1333 BuildVMWareImage1 $(vmwareImage) : <build>vmdkheader $(plainImage) ;
1336 actions BuildVMWareImage1
1339 $(2[1]) -h 64k -i$(IMAGE_SIZE)M $(1) &&
1344 #pragma mark - Network Boot Archive rules
1346 rule AddDirectoryToNetBootArchive directoryTokens
1348 # AddDirectoryToNetBootArchive <directoryTokens>
1350 return [ AddDirectoryToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
1351 : $(directoryTokens) ] ;
1354 rule AddFilesToNetBootArchive directory : targets : destName
1356 # AddFilesToNetBootArchive <directory> : <targets> [ : dest name ]
1358 AddFilesToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) : $(directory)
1359 : $(targets) : $(destName) ;
1362 rule AddSymlinkToNetBootArchive directoryTokens : linkTarget : linkName
1364 # AddSymlinkToNetBootArchive <directory> : <link target> [ : <link name> ] ;
1366 AddSymlinkToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
1367 : $(directoryTokens) : $(linkTarget) : $(linkName) ;
1370 rule AddDriversToNetBootArchive relativeDirectoryTokens : targets
1372 # AddDriversToNetBootArchive <relative directory> : <targets> ;
1374 AddDriversToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
1375 : $(relativeDirectoryTokens) : $(targets) ;
1378 rule AddNewDriversToNetBootArchive relativeDirectoryTokens : targets
1380 # AddNewDriversToNetBootArchive <relative directory> : <targets> ;
1382 AddNewDriversToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
1383 : $(relativeDirectoryTokens) : $(targets) ;
1386 rule AddDriverRegistrationToNetBootArchive relativeDirectoryTokens : target
1389 # AddDriverRegistrationToNetBootArchive <directory> : <link target>
1390 # : <link names> ] ;
1392 AddDriverRegistrationToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
1393 : $(relativeDirectoryTokens) : $(target) : $(links) ;
1396 rule AddBootModuleSymlinksToNetBootArchive targets
1398 # AddBootModuleSymlinksToNetBootArchive <targets> ;
1400 AddBootModuleSymlinksToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
1404 rule CreateNetBootArchiveMakeDirectoriesScript script
1406 CreateContainerMakeDirectoriesScript
1407 $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) : $(script) ;
1410 rule CreateNetBootArchiveCopyFilesScript script
1412 CreateContainerCopyFilesScript $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
1416 rule BuildNetBootArchive archive : scripts
1418 # BuildNetBootArchive <archive> : <scripts> ;
1420 local mainScript = build_archive ;
1421 SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ;
1423 Depends $(archive) : $(mainScript) $(scripts) ;
1424 BuildNetBootArchive1 $(archive) : $(mainScript) $(scripts) ;
1427 actions BuildNetBootArchive1
1429 $(2[1]) $(1) $(2[2-])
1433 #pragma mark - Floppy Boot Archive rules
1436 rule AddDirectoryToFloppyBootArchive directoryTokens
1438 # AddDirectoryToFloppyBootArchive <directoryTokens>
1440 return [ AddDirectoryToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1441 : $(directoryTokens) ] ;
1444 rule AddFilesToFloppyBootArchive directory : targets : destName
1446 # AddFilesToFloppyBootArchive <directory> : <targets> [ : dest name ]
1448 AddFilesToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) : $(directory)
1449 : $(targets) : $(destName) ;
1452 rule AddSymlinkToFloppyBootArchive directoryTokens : linkTarget : linkName
1454 # AddSymlinkToFloppyBootArchive <directory> : <link target>
1455 # [ : <link name> ] ;
1457 AddSymlinkToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1458 : $(directoryTokens) : $(linkTarget) : $(linkName) ;
1461 rule AddDriversToFloppyBootArchive relativeDirectoryTokens : targets
1463 # AddDriversToFloppyBootArchive <relative directory> : <targets> ;
1465 AddDriversToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1466 : $(relativeDirectoryTokens) : $(targets) ;
1469 rule AddNewDriversToFloppyBootArchive relativeDirectoryTokens : targets
1471 # AddNewDriversToFloppyBootArchive <relative directory> : <targets> ;
1473 AddNewDriversToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1474 : $(relativeDirectoryTokens) : $(targets) ;
1477 rule AddDriverRegistrationToFloppyBootArchive relativeDirectoryTokens : target
1480 # AddDriverRegistrationToFloppyBootArchive <directory> : <link target>
1481 # : <link names> ] ;
1483 AddDriverRegistrationToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1484 : $(relativeDirectoryTokens) : $(target) : $(links) ;
1487 rule AddBootModuleSymlinksToFloppyBootArchive targets
1489 # AddBootModuleSymlinksToFloppyBootArchive <targets> ;
1491 AddBootModuleSymlinksToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1495 rule CreateFloppyBootArchiveMakeDirectoriesScript script
1497 CreateContainerMakeDirectoriesScript
1498 $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) : $(script) ;
1501 rule CreateFloppyBootArchiveCopyFilesScript script
1503 CreateContainerCopyFilesScript $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1507 rule BuildFloppyBootArchive archive : scripts
1509 # BuildHFloppyBootArchive <archive> : <scripts> ;
1511 local mainScript = build_archive ;
1512 SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ;
1514 Depends $(archive) : $(mainScript) $(scripts) ;
1515 BuildFloppyBootArchive1 $(archive) : $(mainScript) $(scripts) ;
1518 actions BuildFloppyBootArchive1
1520 $(2[1]) $(1) $(2[2-])
1523 # warning: that is quite x86 dependant...
1525 rule BuildFloppyBootImage image : haikuLoader : archive
1527 Depends $(image) : $(haikuLoader) ;
1528 Depends $(image) : $(archive) ;
1529 #MakeLocateDebug $(image) ;
1530 FLOPPY_IMAGE_SIZE on $(image) = $(HAIKU_BOOT_FLOPPY_IMAGE_SIZE) ;
1531 ARCHIVE_IMAGE_OFFSET on $(image) = $(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ;
1532 BuildFloppyBootImage1 $(image) : $(haikuLoader) $(archive) ;
1533 if $(HAIKU_BOOT_PLATFORM) = atari_m68k {
1534 Depends $(image) : <build>fixup_tos_boot_checksum ;
1535 BuildFloppyBootImageFixupM68K $(image)
1536 : <build>fixup_tos_boot_checksum ;
1538 if $(HAIKU_BOOT_PLATFORM) = amiga_m68k {
1539 Depends $(image) : <build>fixup_amiga_boot_checksum ;
1540 BuildFloppyBootImageFixupM68K $(image)
1541 : <build>fixup_amiga_boot_checksum ;
1545 actions BuildFloppyBootImage1
1547 haiku_loader_size=`stat -c %s "$(>[1])"`
1548 drivers_tgz_size=`stat -c %s "$(>[2])"`
1549 if [ $? -ne 0 ] ; then
1550 # FreeBSD's stat command don't support -c/--format option
1551 # and use %z specifier for file size
1552 haiku_loader_size=`stat -f %z "$(>[1])"`
1553 drivers_tgz_size=`stat -f %z "$(>[2])"`
1555 archive_image_offset=`echo "$(ARCHIVE_IMAGE_OFFSET) * 1024" | bc`
1557 `echo "($(FLOPPY_IMAGE_SIZE) - $(ARCHIVE_IMAGE_OFFSET)) * 1024" | bc`
1558 if [ $haiku_loader_size -gt $archive_image_offset ] ; then
1559 echo "Error: $(>[1]) is too big ($haiku_loader_size) to fit "
1560 echo " before the boot archive starting at $archive_image_offset!"
1563 if [ $drivers_tgz_size -gt $floppy_tgz_size ] ; then
1564 echo "Error: $(>[2]) is too big ($drivers_tgz_size) to fit "
1565 echo " in the boot floppy ($floppy_tgz_size)!"
1569 # make an empty image
1570 dd if=/dev/zero of=$(<) bs=1k count=$(FLOPPY_IMAGE_SIZE)
1572 dd if=$(>[1]) of=$(<) conv=notrunc
1573 # add the boot drivers tgz archive
1574 dd if=$(>[2]) of=$(<) bs=$(ARCHIVE_IMAGE_OFFSET)k seek=1 conv=notrunc
1577 actions BuildFloppyBootImageFixupM68K
1579 # fixup the boot sector checksum
1583 #pragma mark - CD Boot Image rules
1585 rule BuildCDBootImage image : bootfloppy : extrafiles
1587 Depends $(image) : $(bootfloppy) ;
1588 Depends $(image) : $(extrafiles) ;
1589 BOOTIMG on $(image) = $(bootfloppy) ;
1591 BuildCDBootImage1 $(image) : $(bootfloppy) $(extrafiles) ;
1594 actions BuildCDBootImage1
1597 mkisofs -b $(BOOTIMG) -r -J -V bootimg -o $(<) $(>[1]) $(>[2-]) \
1598 || genisoimage -b $(BOOTIMG) -r -J -V bootimg -o $(<) $(>[1]) $(>[2-])
1602 #pragma mark - CD Boot PPC Image rules
1604 rule BuildCDBootPPCImage image : hfsmaps : elfloader : coffloader : chrpscript
1607 Depends $(image) : $(elfloader) ;
1608 Depends $(image) : $(coffloader) ;
1609 Depends $(image) : $(chrpscript) ;
1610 Depends $(image) : $(extrafiles) ;
1611 Depends $(image) : $(hfsmaps) ;
1612 MAPS on $(image) = $(hfsmaps) ;
1614 BuildCDBootPPCImage1 $(image) : $(elfloader) $(coffloader) $(chrpscript)
1618 actions BuildCDBootPPCImage1 bind MAPS
1621 mkdir -p $(HAIKU_OUTPUT_DIR)/cd/ppc
1622 mkdir -p $(HAIKU_OUTPUT_DIR)/cd/boot
1624 cp $(>[3]) $(HAIKU_OUTPUT_DIR)/cd/ppc/bootinfo.txt
1625 cp $(>[3]) $(HAIKU_OUTPUT_DIR)/cd/boot/boot.chrp
1627 cp $(>[2]) $(HAIKU_OUTPUT_DIR)/cd/boot/haikuloader.xcf
1628 cp $(>[1]) $(HAIKU_OUTPUT_DIR)/cd/boot/haikuloader.elf
1629 # Extras (readme files, etc)
1630 cp $(>[4]) $(HAIKU_OUTPUT_DIR)/cd/
1632 mkisofs -v -hfs -part -map $(MAPS) -no-desktop -hfs-volid bootimg \
1633 -V bootimg -hfs-bless $(HAIKU_OUTPUT_DIR)/cd/boot -prep-boot \
1634 boot/haikuloader.xcf -r -o $(<) $(HAIKU_OUTPUT_DIR)/cd \
1636 genisoimage -v -hfs -part -map $(MAPS) -no-desktop -hfs-volid bootimg \
1637 -V bootimg -hfs-bless $(HAIKU_OUTPUT_DIR)/cd/boot -prep-boot \
1638 boot/haikuloader.xcf -r -o $(<) $(HAIKU_OUTPUT_DIR)/cd
1639 $(RM) -R $(HAIKU_OUTPUT_DIR)/cd