ImageRules revision e20c80b57f5603cc5b43c57b400309747ba46c44
1rule FSameTargetWithPrependedGrist
2{
3	# SameTargetWithPrependedGrist <target> : <grist to prepend> ;
4	#
5	local target = $(1) ;
6	local gristToPrepend = $(2) ;
7	local grist = $(target:G) ;
8
9	if $(grist) {
10		grist = $(gristToPrepend)!$(grist) ;
11	} else {
12		grist = $(gristToPrepend) ;
13	}
14
15	return $(target:G=$(grist)) ;
16}
17
18rule InitScript
19{
20	# Note: The script must have been LOCATEd before.
21	local script = $(1) ;
22	local initScript
23		= [ FSameTargetWithPrependedGrist $(script) : init-script ] ;
24
25	if ! [ on $(script) return $(__is_initialized) ] {
26		__is_initialized on $(script) = true ;
27
28		MakeLocate $(initScript) : [ on $(script) return $(LOCATE) ] ;
29		Always $(initScript) ;
30		Depends $(script) : $(initScript) ;
31
32		InitScript1 $(initScript) ;
33	}
34
35	return $(initScript) ;
36}
37
38actions InitScript1
39{
40	$(RM) $(1)
41	touch $(1)
42}
43
44rule AddVariableToScript script : variable : value
45{
46	# AddVariableToScript <script> : <variable> : <value> ;
47
48	# interpret an empty variable value as empty string
49	if ! $(value) {
50		value = "" ;
51	}
52
53	InitScript $(script) ;
54
55	VARIABLE_DEFS on $(script) += "echo $(variable)=\\\"$(value[1])\\\" >> " ;
56
57	# if the value is an array, add the other array elements
58	value = $(value[2-]) ;
59	while $(value) {
60		VARIABLE_DEFS on $(script)
61			+= "echo $(variable)=\\\" \\\$$(variable) $(value[1])\\\" >> " ;
62		value = $(value[2-]) ;
63	}
64
65	AddVariableToScript1 $(script) ;
66}
67
68actions together AddVariableToScript1
69{
70	$(VARIABLE_DEFS)$(1);
71}
72
73rule AddTargetVariableToScript
74{
75	# AddTargetVariableToScript <script> : <target> [ : <variable> ] ;
76	#
77	local script = $(1) ;
78	local target = $(2) ;
79	local variable = $(3:E=$(target:BS)) ;
80
81	InitScript $(script) ;
82
83	# That's not completely save, if one has more than on target with the
84	# same base name. A unique pseudo target would have to be introduced
85	# to do it more correctly.
86	VARIABLE_NAME($(target:BS)) on $(script) = $(variable) ;
87
88	Depends $(script) : $(target) ;
89	AddTargetVariableToScript1 $(script) : $(target) ;
90}
91
92actions AddTargetVariableToScript1
93{
94	echo "$(VARIABLE_NAME($(2:BS)))=\"$(2)\"" >> $(1)
95}
96
97
98#pragma mark -
99
100rule AddDirectoryToContainer container : directoryTokens
101{
102	# AddDirectoryToContainer <container> : <directoryTokens>
103
104	local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ;
105	local directory = [ FDirName $(directoryTokens) ] ;
106	directory = $(directory:G=$(containerGrist)) ;
107
108	if ! [ on $(directory) return $(__is_on_image) ] {
109		HAIKU_INSTALL_DIRECTORIES on $(container) += $(directory) ;
110		__is_on_image on $(directory) = true ;
111		DIRECTORY_TOKENS on $(directory) = $(directoryTokens) ;
112		NotFile $(directory) ;
113
114		# mark the parent dir as not to be created
115		local parent = [ FReverse $(directoryTokens) ] ;
116		parent = [ FReverse $(parent[2-]) ] ;
117		if $(parent) {
118			parent = [ FDirName $(parent) ] ;
119			parent = $(parent:G=$(containerGrist)) ;
120			DONT_CREATE on $(parent) = true ;
121		}
122	}
123
124	return $(directory) ;
125}
126
127rule FilterContainerUpdateTargets targets : filterVariable
128{
129	# FilterContainerUpdateTargets targets : filterVariable
130
131	local filteredTargets ;
132	local target ;
133	for target in $(targets) {
134		if [ on $(target) return $($(filterVariable)) ] {
135			filteredTargets += $(target) ;
136		}
137	}
138	return $(filteredTargets) ;
139}
140
141
142rule IncludeAllTargetsInContainer container
143{
144	local filterVar
145		= [ on $(container) return $(HAIKU_INCLUDE_IN_CONTAINER_VAR) ] ;
146	if $(filterVar) {
147		return $($(filterVar)) ;
148	}
149
150	return ;
151}
152
153
154rule AddFilesToContainer container : directoryTokens : targets : destName
155{
156	# AddFilesToContainer <container> : <directoryTokens> : <targets>
157	#	[ : dest name ]
158	#
159	local directory = [ AddDirectoryToContainer $(container)
160		: $(directoryTokens) ] ;
161	local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ;
162
163	# If the image shall only be updated, we filter out all targets not marked
164	# accordingly.
165	if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
166		&& ! [ IncludeAllTargetsInContainer $(container) ] {
167		local filterVar
168			= [ on $(container) return $(HAIKU_INCLUDE_IN_CONTAINER_VAR) ] ;
169		if $(filterVar) {
170			targets = [ FilterContainerUpdateTargets $(targets)
171				: $(filterVar) ] ;
172		}
173	}
174
175	# We create a unique dummy target per target to install.
176	local installTargetsVar
177		= [ on $(container) return $(HAIKU_INSTALL_TARGETS_VAR) ] ;
178	local target ;
179	for target in $(targets) {
180		local name ;
181		if $(destName) {
182			name = $(destName) ;
183		} else {
184			name = $(target:G=:D=) ;
185		}
186
187		local destTarget = $(name:G=$(containerGrist)__$(directory:G=)) ;
188		TARGET on $(destTarget) = $(target) ;
189		INSTALL_DIR on $(destTarget) = $(directory) ;
190		$(installTargetsVar) on $(target) += $(destTarget) ;
191		TARGETS_TO_INSTALL on $(directory) += $(destTarget) ;
192	}
193}
194
195rule FFilesInContainerDirectory container : directoryTokens
196{
197	local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ;
198	local directory = [ FDirName $(directoryTokens) ] ;
199	directory = $(directory:G=$(containerGrist)) ;
200
201	if [ on $(directory) return $(__is_on_image) ] {
202		on $(directory) return $(TARGETS_TO_INSTALL) ;
203	}
204
205	return ;
206}
207
208rule AddSymlinkToContainer container : directoryTokens : linkTarget : linkName
209{
210	# AddSymlinkToContainer <container> : <directory> : <link target>
211	#	[ : <link name> ] ;
212	#
213
214	# If the image shall only be updated, we don't add any symlinks.
215	if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
216		&& ! [ IncludeAllTargetsInContainer $(container) ] {
217		return ;
218	}
219
220	local directory = [ AddDirectoryToContainer $(container)
221		: $(directoryTokens) ] ;
222
223	if ! $(linkName) {
224		local path = [ FReverse [ FSplitPath $(linkTarget) ] ] ;
225		linkName = $(path[1]) ;
226	}
227
228	local link = $(directory)/$(linkName) ;
229	SYMLINK_TARGET on $(link) = $(linkTarget) ;
230	SYMLINKS_TO_INSTALL on $(directory) += $(link) ;
231}
232
233rule FSymlinksInContainerDirectory container : directoryTokens
234{
235	local containerGrist = [ on $(container) return $(HAIKU_CONTAINER_GRIST) ] ;
236	local directory = [ FDirName $(directoryTokens) ] ;
237	directory = $(directory:G=$(containerGrist)) ;
238
239	if [ on $(directory) return $(__is_on_image) ] {
240		on $(directory) return $(SYMLINKS_TO_INSTALL) ;
241	}
242
243	return ;
244}
245
246rule CopyDirectoryToContainer container : directoryTokens : sourceDirectory
247	: targetDirectoryName : excludePatterns : alwaysUpdate
248{
249	# CopyDirectoryToContainer <container> : <directoryTokens>
250	#	: <sourceDirectory> : <targetDirectoryName> : <excludePatterns>
251	#	: <alwaysUpdate> ;
252	#
253
254	# If the image shall only be updated, we don't copy any directories
255	if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
256			&& ! [ IncludeAllTargetsInContainer $(container) ]
257			&& ! $(alwaysUpdate) {
258		return ;
259	}
260
261	if ! $(targetDirectoryName) {
262		local path = [ FReverse [ FSplitPath $(sourceDirectory) ] ] ;
263		targetDirectoryName = $(path[1]) ;
264	}
265
266	local directory = [ AddDirectoryToContainer $(container)
267		: $(directoryTokens) $(targetDirectoryName) ] ;
268
269	local targetDir = $(directory)/-/$(sourceDirectory) ;
270	EXCLUDE_PATTERNS on $(targetDir) = $(excludePatterns) ;
271	SOURCE_DIRECTORY on $(targetDir) = $(sourceDirectory) ;
272	TARGET_DIRECTORY on $(targetDir) = $(directory) ;
273	DIRECTORIES_TO_INSTALL on $(directory) += $(targetDir) ;
274}
275
276rule UnzipArchiveToContainer container : directoryTokens : zipFile
277{
278	# UnzipArchiveToContainer <container> : <directory> : <zipFile> ] ;
279	#
280
281	local directory = [ AddDirectoryToContainer $(container)
282		: $(directoryTokens) ] ;
283
284	ZIP_FILES_TO_INSTALL on $(directory) += $(zipFile) ;
285}
286
287rule AddDriversToContainer container : relativeDirectoryTokens : targets
288{
289	# AddDriversToContainer <container> : <relative directory> : <targets> ;
290	#
291	local directoryTokens = system add-ons kernel drivers dev
292		$(relativeDirectoryTokens) ;
293
294	AddFilesToContainer $(container) : system add-ons kernel drivers bin
295		: $(targets) ;
296
297	# If the image shall only be updated, we don't add any symlinks.
298	if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
299		&& ! [ IncludeAllTargetsInContainer $(container) ] {
300		return ;
301	}
302
303	# get the relative symlink path prefix
304	local linkPrefix = ;
305	for i in $(relativeDirectoryTokens) {
306		linkPrefix += .. ;
307	}
308	linkPrefix += .. bin ;
309
310	# add the symlinks
311	local name ;
312	for name in $(targets:BS) {
313		AddSymlinkToContainer $(container) : $(directoryTokens)
314			: [ FDirName $(linkPrefix) $(name) ] : $(name) ;
315	}
316}
317
318rule AddNewDriversToContainer container : relativeDirectoryTokens
319	: targets
320{
321	# AddNewDriversToContainer <container> : <directory> : <targets> ;
322	#
323	local directoryTokens = system add-ons kernel drivers
324		$(relativeDirectoryTokens) ;
325
326	AddFilesToContainer $(container) : $(directoryTokens)
327		: $(targets) ;
328}
329
330rule AddBootModuleSymlinksToContainer container : targets
331{
332	# AddBootModuleSymlinksToContainer <container> : <targets> ;
333	#
334
335	# If the image shall only be updated, we don't add any symlinks.
336	if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
337		&& ! [ IncludeAllTargetsInContainer $(container) ] {
338		return ;
339	}
340
341	# add the symlinks
342	local installTargetsVar
343		= [ on $(container) return $(HAIKU_INSTALL_TARGETS_VAR) ] ;
344	local target ;
345	for target in $(targets) {
346		# Symlink to the first place where the target has been installed.
347		local destTarget = [ on $(target) return $($(installTargetsVar)[1]) ] ;
348		local installDir = [ on $(destTarget) return $(INSTALL_DIR) ] ;
349
350		if ! $(installDir) {
351			Echo "ERROR: AddBootModuleSymlinksToContainer: Can't create a "
352				"symlink to target" \"$(target)"\"." ;
353			Exit "ERROR: Add*ToContainer has not been invoked for it yet." ;
354		}
355
356		local name = $(target:BS) ;
357		local linkTarget = [ FDirName /boot $(installDir:G=) $(name) ] ;
358
359		AddSymlinkToContainer $(container) : system add-ons kernel boot
360			: $(linkTarget) : $(name) ;
361	}
362}
363
364
365rule CreateContainerMakeDirectoriesScript container : script
366{
367	MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ;
368	Always $(script) ;
369
370	local initScript = [ InitScript $(script) ] ;
371
372	local scriptBody
373		= [ FSameTargetWithPrependedGrist $(script) : script-body ] ;
374	LOCATE on $(scriptBody) = [ on $(script) return $(LOCATE) ] ;
375	Depends $(scriptBody) : $(initScript) ;
376	Depends $(script) : $(scriptBody) ;
377
378	# collect the directories to create
379	local dirsToCreate ;
380	local directories = [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] ;
381	local dir ;
382	for dir in $(directories) {
383		if ! [ on $(dir) return $(DONT_CREATE) ] {
384			dirsToCreate += $(dir) ;
385		}
386	}
387
388	# If the image shall only be updated, we don't create directories.
389	if $(dirsToCreate)
390		&& ( ! [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
391			|| [ IncludeAllTargetsInContainer $(container) ] ) {
392		Depends $(scriptBody) : $(dirsToCreate) ;
393		CreateContainerMakeDirectoriesScript1 $(scriptBody) : $(dirsToCreate) ;
394
395		# For directories with attributes, we convert those the specified
396		# resource files to files with attributes and add commands to the script
397		# adding the attributes to the directories.
398		for dir in $(directories) {
399			local resourceFiles = [ on $(dir) return $(ATTRIBUTE_FILES) ] ;
400			if $(resourceFiles) {
401				local dirTokens = [ on $(dir) return $(DIRECTORY_TOKENS) ] ;
402
403				# translate resources file to file with attributes
404				local attributeFile = $(script)-attributes-$(dirTokens:J=-) ;
405				ResAttr $(attributeFile) : $(resourceFiles) ;
406
407				# use a unique dummy target for this file, on which we
408				# can define the TARGET_DIR variable
409				local dummyTarget = $(script)-attributes-dummy-$(dir:G=) ;
410				NotFile $(dummyTarget) ;
411				TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
412
413				Depends $(dummyTarget) : $(initScript) $(attributeFile) ;
414				Depends $(script) : $(dummyTarget) ;
415
416				AppendToContainerMakeDirectoriesScriptAttributes $(dummyTarget)
417					: $(initScript) $(attributeFile) ;
418			}
419		}
420	}
421}
422
423actions piecemeal CreateContainerMakeDirectoriesScript1
424{
425	echo \$mkdir -p "\"\${tPrefix}$(2:G=)\"" >> $(1)
426}
427
428actions AppendToContainerMakeDirectoriesScriptAttributes
429{
430	echo \$copyAttrs "\"\${sPrefix}$(2[2])\"" \
431		"\"\${tPrefix}$(TARGET_DIR)\"" >> $(2[1])
432}
433
434rule CreateContainerCopyFilesScript container : script
435{
436	MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ;
437	Always $(script) ;
438
439	local initScript = [ InitScript $(script) ] ;
440
441	local scriptBody
442		= [ FSameTargetWithPrependedGrist $(script) : script-body ] ;
443	LOCATE on $(scriptBody) = [ on $(script) return $(LOCATE) ] ;
444	Depends $(scriptBody) : $(initScript) ;
445	Depends $(script) : $(scriptBody) ;
446
447	local dir ;
448	for dir in [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] {
449		# filter the targets that shall be renamed; they have to be copied
450		# individually
451		local destTargets = [ on $(dir) return $(TARGETS_TO_INSTALL) ] ;
452		local remainingTargets ;
453		local destTarget ;
454		for destTarget in $(destTargets) {
455			local target = [ on $(destTarget) return $(TARGET) ] ;
456			local name = $(destTarget:BS) ;
457			if $(name) != $(target:BS) {
458				# use a unique dummy target for this file, on which we
459				# can define the TARGET_DIR variable
460				local dummyTarget = $(script)-dummy-$(dir:G=)-$(target) ;
461				NotFile $(dummyTarget) ;
462				TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
463				INSTALL_TARGET_NAME on $(dummyTarget) = $(name) ;
464
465				Depends $(dummyTarget) : $(initScript) $(target) ;
466				Depends $(script) : $(dummyTarget) ;
467
468				AppendToContainerCopyFilesScriptSingleFile $(dummyTarget)
469					: $(initScript) $(target) ;
470			} else {
471				remainingTargets += $(target) ;
472			}
473		}
474		targets = $(remainingTargets) ;
475
476		if $(targets) {
477			# use a unique dummy target for this directory, on which we
478			# can define the TARGET_DIR variable
479			local dummyTarget = $(script)-dummy-$(dir:G=) ;
480			NotFile $(dummyTarget) ;
481			TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
482
483			Depends $(dummyTarget) : $(initScript) $(targets) ;
484			Depends $(script) : $(dummyTarget) ;
485
486			OUTPUT_SCRIPT on $(dummyTarget) = $(initScript) ;
487			AppendToContainerCopyFilesScript $(dummyTarget) : $(targets) ;
488		}
489
490		local symlinks = [ on $(dir) return $(SYMLINKS_TO_INSTALL) ] ;
491		local symlink ;
492		for symlink in $(symlinks) {
493			NotFile $(symlink) ;
494
495			Depends $(script) : $(symlink) ;
496			Depends $(symlink) : $(initScript) ;
497
498			AddSymlinkToContainerCopyFilesScript $(symlink) : $(initScript) ;
499		}
500
501		local targetDirs = [ on $(dir) return $(DIRECTORIES_TO_INSTALL) ] ;
502		local targetDir ;
503		for targetDir in $(targetDirs) {
504			NotFile $(targetDir) ;
505
506			Depends $(script) : $(targetDir) ;
507			Depends $(targetDir) : $(initScript) ;
508
509			AddDirectoryToContainerCopyFilesScript $(targetDir) : $(initScript) ;
510		}
511	}
512}
513
514
515actions piecemeal AppendToContainerCopyFilesScript bind OUTPUT_SCRIPT
516{
517	echo \$cp "\"\${sPrefix}$(2)\"" "\"\${tPrefix}$(TARGET_DIR)\"" >> $(OUTPUT_SCRIPT)
518}
519
520
521actions AppendToContainerCopyFilesScriptSingleFile
522{
523	echo \$cp "\"\${sPrefix}$(2[2])\"" \
524		"\"\${tPrefix}$(TARGET_DIR)/$(INSTALL_TARGET_NAME)\"" >> $(2[1])
525}
526
527
528actions AddSymlinkToContainerCopyFilesScript
529{
530	echo \$ln -sfn "\"$(SYMLINK_TARGET)\"" "\"\${tPrefix}$(1:G=)\"" >> $(2[1])
531}
532
533
534actions AddDirectoryToContainerCopyFilesScript
535{
536	echo \$cp -r $(EXCLUDE_PATTERNS) "\"\${sPrefix}$(SOURCE_DIRECTORY)/.\"" \
537		"\"\${tPrefix}$(TARGET_DIRECTORY:G=)\"" >> $(2[1])
538}
539
540
541rule CreateContainerUnzipFilesScript container : script
542{
543	MakeLocate $(script) : $(HAIKU_OUTPUT_DIR) ;
544	Always $(script) ;
545
546	local initScript = [ InitScript $(script) ] ;
547
548	local scriptBody
549		= [ FSameTargetWithPrependedGrist $(script) : script-body ] ;
550	LOCATE on $(scriptBody) = [ on $(script) return $(LOCATE) ] ;
551	Depends $(scriptBody) : $(initScript) ;
552	Depends $(script) : $(scriptBody) ;
553
554	local dir ;
555	for dir in [ on $(container) return $(HAIKU_INSTALL_DIRECTORIES) ] {
556		local zipFiles = [ on $(dir) return $(ZIP_FILES_TO_INSTALL) ] ;
557		local zipFile ;
558		for zipFile in $(zipFiles) {
559			# use a unique dummy target for this file, on which we
560			# can define the TARGET_DIR variable
561			local dummyTarget = $(script)-dummy-$(dir:G=)-$(zipFile) ;
562			NotFile $(dummyTarget) ;
563			TARGET_DIR on $(dummyTarget) = $(dir:G=) ;
564
565			Depends $(dummyTarget) : $(initScript) $(zipFile) ;
566			Depends $(script) : $(dummyTarget) ;
567
568			AddUnzipFileToContainerUnzipFilesScript $(dummyTarget)
569				: $(initScript) $(zipFile) ;
570		}
571	}
572}
573
574actions AddUnzipFileToContainerUnzipFilesScript
575{
576	echo unzipFile "\"$(2[2])\"" "\"$(TARGET_DIR)\"" >> $(2[1])
577}
578
579
580#pragma mark - Haiku Image rules
581
582rule SetUpdateHaikuImageOnly flag
583{
584	HAIKU_CONTAINER_UPDATE_ONLY on $(HAIKU_IMAGE_CONTAINER_NAME) = $(flag) ;
585}
586
587rule IsUpdateHaikuImageOnly
588{
589	on $(HAIKU_IMAGE_CONTAINER_NAME) return $(HAIKU_CONTAINER_UPDATE_ONLY) ;
590}
591
592rule AddDirectoryToHaikuImage directoryTokens : attributeFiles
593{
594	# AddDirectoryToHaikuImage <directoryTokens>
595
596	local dir = [ AddDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME)
597		: $(directoryTokens) ] ;
598
599	if $(attributeFiles) {
600		SEARCH on $(attributeFiles)
601			+= [ FDirName $(HAIKU_TOP) data image_directories ] ;
602		ATTRIBUTE_FILES on $(dir) += $(attributeFiles) ;
603	}
604
605	return $(dir) ;
606}
607
608rule AddFilesToHaikuImage directory : targets : destName
609{
610	# AddFilesToHaikuImage <directory> : <targets> [ : dest name ]
611
612	AddFilesToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directory)
613		: $(targets) : $(destName) ;
614}
615
616rule FFilesInHaikuImageDirectory directoryTokens
617{
618	return [ FFilesInContainerDirectory $(HAIKU_IMAGE_CONTAINER_NAME)
619		: $(directoryTokens) ] ;
620}
621
622rule AddSymlinkToHaikuImage directoryTokens : linkTarget : linkName
623{
624	# AddSymlinkToHaikuImage <directory> : <link target> [ : <link name> ] ;
625
626	AddSymlinkToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directoryTokens)
627		: $(linkTarget) : $(linkName) ;
628}
629
630rule FSymlinksInHaikuImageDirectory directoryTokens
631{
632	return [ FSymlinksInContainerDirectory $(HAIKU_IMAGE_CONTAINER_NAME)
633		: $(directoryTokens) ] ;
634}
635
636rule CopyDirectoryToHaikuImage directoryTokens : sourceDirectory
637	: targetDirectoryName : excludePatterns : alwaysUpdate
638{
639	CopyDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directoryTokens)
640		: $(sourceDirectory) : $(targetDirectoryName) : $(excludePatterns)
641		: $(alwaysUpdate) ;
642}
643
644rule AddSourceDirectoryToHaikuImage dirTokens : alwaysUpdate
645{
646	# AddSourceDirectoryToHaikuImage <dirTokens> : <alwaysUpdate> ;
647
648	CopyDirectoryToHaikuImage home HaikuSources
649		: [ FDirName $(HAIKU_TOP) $(dirTokens) ]
650		: : -x .svn : $(alwaysUpdate) ;
651}
652
653rule AddHeaderDirectoryToHaikuImage dirTokens : dirName : alwaysUpdate
654{
655	# AddHeaderDirectoryToHaikuImage <dirTokens> : [ <dirName> ]
656	#	: <alwaysUpdate> ;
657
658	CopyDirectoryToHaikuImage develop headers
659		: [ FDirName $(HAIKU_TOP) headers $(dirTokens) ]
660		: $(dirName) : -x .svn : $(alwaysUpdate) ;
661}
662
663rule UnzipArchiveToHaikuImage dirTokens : zipFile : alwaysUpdate
664{
665	# UnzipArchiveToHaikuImage <dirTokens> : <zipFile> : <alwaysUpdate> ;
666
667	# If the image shall only be updated, we unzip only, if explicitely
668	# requested.
669	if ! [ IsUpdateHaikuImageOnly ] || $(alwaysUpdate) {
670		UnzipArchiveToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(dirTokens)
671			: $(zipFile) ;
672	}
673}
674
675rule AddDriversToHaikuImage relativeDirectoryTokens : targets
676{
677	# AddDriversToHaikuImage <relative directory> : <targets> ;
678
679	AddDriversToContainer $(HAIKU_IMAGE_CONTAINER_NAME)
680		: $(relativeDirectoryTokens) : $(targets) ;
681}
682
683rule AddNewDriversToHaikuImage relativeDirectoryTokens : targets
684{
685	# AddNewDriversToHaikuImage <relative directory> : <targets> ;
686
687	AddNewDriversToContainer $(HAIKU_IMAGE_CONTAINER_NAME)
688		: $(relativeDirectoryTokens) : $(targets) ;
689}
690
691rule AddBootModuleSymlinksToHaikuImage targets
692{
693	# AddBootModuleSymlinksToHaikuImage <targets> ;
694
695	AddBootModuleSymlinksToContainer $(HAIKU_IMAGE_CONTAINER_NAME)
696		: $(targets) ;
697}
698
699rule AddOptionalHaikuImagePackages packages
700{
701	local package ;
702	for package in $(packages) {
703		if ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_ADDED) ] {
704			HAIKU_OPTIONAL_PACKAGE_ADDED on $(package) = 1 ;
705			HAIKU_ADDED_OPTIONAL_PACKAGES += $(package) ;
706		}
707	}
708}
709
710rule IsOptionalHaikuImagePackageAdded package
711{
712	if ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_EXISTS) ] {
713		HAIKU_OPTIONAL_PACKAGE_EXISTS on $(package) = 1 ;
714		HAIKU_EXISTING_OPTIONAL_PACKAGES += $(package) ;
715	}
716
717	if [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_ADDED) ] {
718		return 1 ;
719	}
720
721	return ;
722}
723
724rule OptionalPackageDependencies package : dependencies
725{
726	if [ IsOptionalHaikuImagePackageAdded $(package) ] {
727		AddOptionalHaikuImagePackages $(dependencies) ;
728	}
729}
730
731rule InstallOptionalHaikuImagePackage package : url : dirTokens
732{
733	# download zip file
734	local zipFile = [ DownloadOptionalPackage $(package) : $(url) ] ;
735
736	# unzip onto image
737	UnzipArchiveToHaikuImage $(dirTokens) : $(zipFile) ;
738}
739
740rule AddEntryToHaikuImageUserGroupFile file : entry
741{
742	local allEntries = [ on $(file) return $(HAIKU_IMAGE_USER_GROUP_ENTRIES) ] ;
743
744	if $(allEntries) {
745		allEntries = $(allEntries)|$(entry) ;
746	} else {
747		allEntries = $(entry) ;
748
749		Always $(file) ;
750		MakeLocate $(file) : $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) ;
751		BuildHaikuImageUserGroupFile $(file) ;
752		AddFilesToHaikuImage system etc : $(file) ;
753	}
754
755	HAIKU_IMAGE_USER_GROUP_ENTRIES on $(file) = $(allEntries) ;
756}
757
758actions BuildHaikuImageUserGroupFile
759{
760	echo "$(HAIKU_IMAGE_USER_GROUP_ENTRIES)" | tr '|' '\n' > $(1)
761}
762
763rule AddUserToHaikuImage user : uid : gid : home : shell : realName
764{
765	if ! $(user) || ! $(uid) || ! $(gid) || ! $(home) {
766		Exit "Invalid haiku user specification passed to AddUserToHaikuImage." ;
767	}
768
769	local entry
770		= $(user):x:$(uid):$(gid):$(realName:E=$(user)):$(home):$(shell:E="") ;
771
772	AddEntryToHaikuImageUserGroupFile <haiku-image>passwd : $(entry) ;
773}
774
775rule AddGroupToHaikuImage group : gid : members
776{
777	if ! $(group) || ! $(gid) {
778		Exit "Invalid haiku group specification passed to"
779			"AddGroupToHaikuImage." ;
780	}
781
782	local entry = $(group):x:$(gid):$(members:J=,:E) ;
783
784	AddEntryToHaikuImageUserGroupFile <haiku-image>group : $(entry) ;
785}
786
787rule AddOptionalPackageDescriptionToHaikuImage file : searchPath
788{
789	if $(searchPath) {
790		SEARCH on $(file) = [ FDirName $(searchPath) ] ;
791	}
792
793	HAIKU_IMAGE_OPTIONAL_PACKAGE_DESCRIPTIONS += $(file) ;
794}
795
796rule AddLicenseToHaikuImage file : name : searchPath
797{
798	if $(searchPath) {
799		SEARCH on $(file) = [ FDirName $(searchPath) ] ;
800	}
801
802	if $(name) && $(file:BS) = $(name) {
803		name = ;
804	}
805
806	AddFilesToHaikuImage system data licenses : $(file) : $(name) ;
807}
808
809
810rule CreateHaikuImageMakeDirectoriesScript script
811{
812	CreateContainerMakeDirectoriesScript $(HAIKU_IMAGE_CONTAINER_NAME)
813		: $(script) ;
814}
815
816rule CreateHaikuImageCopyFilesScript script
817{
818	CreateContainerCopyFilesScript $(HAIKU_IMAGE_CONTAINER_NAME) : $(script) ;
819}
820
821rule CreateHaikuImageUnzipFilesScript script
822{
823	CreateContainerUnzipFilesScript $(HAIKU_IMAGE_CONTAINER_NAME) : $(script) ;
824}
825
826rule BuildHaikuImage haikuImage : scripts : isImage : isVMwareImage
827{
828	# BuildHaikuImage <haiku image> : <scripts> : <is image> : <isVMwareImage> ;
829
830	if $(isImage) = 1 || $(isImage) = true {
831		IS_IMAGE on $(haikuImage) = 1 ;
832	} else {
833		IS_IMAGE on $(haikuImage) = "" ;
834	}
835
836	if $(isVMwareImage) = 1 || $(isVMwareImage) = true {
837		IS_VMWARE_IMAGE on $(haikuImage) = 1 ;
838	} else {
839		IS_VMWARE_IMAGE on $(haikuImage) = "" ;
840	}
841
842	local mainScript = build_haiku_image ;
843	SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ;
844
845	Depends $(haikuImage) : $(mainScript) $(scripts) ;
846	BuildHaikuImage1 $(haikuImage) : $(mainScript) $(scripts) ;
847}
848
849actions BuildHaikuImage1
850{
851	export imagePath="$(1)"
852	export isImage="$(IS_IMAGE)"
853	export isVMwareImage="$(IS_VMWARE_IMAGE)"
854	$(2[1]) $(2[2-])
855}
856
857rule BuildVMWareImage vmwareImage : plainImage : imageSize
858{
859	# BuildVMWareImage <vmware image> : <plain image> : <image size in MB>
860
861	IMAGE_SIZE on $(vmwareImage) = $(imageSize) ;
862
863	Depends $(vmwareImage) : <build>vmdkheader $(plainImage) ;
864	BuildVMWareImage1 $(vmwareImage) : <build>vmdkheader $(plainImage) ;
865}
866
867actions BuildVMWareImage1
868{
869	$(RM) $(1)
870	$(2[1]) -h 64k -i$(IMAGE_SIZE)M $(1) &&
871	cat $(2[2]) >> $(1)
872}
873
874
875#pragma mark - Network Boot Archive rules
876
877rule AddDirectoryToNetBootArchive directoryTokens
878{
879	# AddDirectoryToNetBootArchive <directoryTokens>
880
881	return [ AddDirectoryToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
882		: $(directoryTokens) ] ;
883}
884
885rule AddFilesToNetBootArchive directory : targets : destName
886{
887	# AddFilesToNetBootArchive <directory> : <targets> [ : dest name ]
888
889	AddFilesToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) : $(directory)
890		: $(targets) : $(destName) ;
891}
892
893rule AddSymlinkToNetBootArchive directoryTokens : linkTarget : linkName
894{
895	# AddSymlinkToNetBootArchive <directory> : <link target> [ : <link name> ] ;
896
897	AddSymlinkToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
898		: $(directoryTokens) : $(linkTarget) : $(linkName) ;
899}
900
901rule AddDriversToNetBootArchive relativeDirectoryTokens : targets
902{
903	# AddDriversToNetBootArchive <relative directory> : <targets> ;
904
905	AddDriversToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
906		: $(relativeDirectoryTokens) : $(targets) ;
907}
908
909rule AddNewDriversToNetBootArchive relativeDirectoryTokens : targets
910{
911	# AddNewDriversToNetBootArchive <relative directory> : <targets> ;
912
913	AddNewDriversToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
914		: $(relativeDirectoryTokens) : $(targets) ;
915}
916
917rule AddDriverRegistrationToNetBootArchive relativeDirectoryTokens : target
918	: links
919{
920	# AddDriverRegistrationToNetBootArchive <directory> : <link target>
921	#	: <link names> ] ;
922
923	AddDriverRegistrationToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
924		: $(relativeDirectoryTokens) : $(target) : $(links) ;
925}
926
927rule AddBootModuleSymlinksToNetBootArchive targets
928{
929	# AddBootModuleSymlinksToNetBootArchive <targets> ;
930
931	AddBootModuleSymlinksToContainer $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
932		: $(targets) ;
933}
934
935rule CreateNetBootArchiveMakeDirectoriesScript script
936{
937	CreateContainerMakeDirectoriesScript
938		$(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME) : $(script) ;
939}
940
941rule CreateNetBootArchiveCopyFilesScript script
942{
943	CreateContainerCopyFilesScript $(HAIKU_NET_BOOT_ARCHIVE_CONTAINER_NAME)
944		: $(script) ;
945}
946
947rule BuildNetBootArchive archive : scripts
948{
949	# BuildNetBootArchive <archive> : <scripts>  ;
950
951	local mainScript = build_tgz_archive ;
952	SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ;
953
954	Depends $(archive) : $(mainScript) $(scripts) ;
955	BuildNetBootArchive1 $(archive) : $(mainScript) $(scripts) ;
956}
957
958actions BuildNetBootArchive1
959{
960	$(2[1]) $(1) $(2[2-])
961}
962
963
964#pragma mark - Alternative GCC Archive rules
965
966
967rule AddDirectoryToAlternativeGCCArchive directoryTokens
968{
969	# AddDirectoryToAlternativeGCCArchive <directoryTokens>
970
971	return [ AddDirectoryToContainer
972		$(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) : $(directoryTokens) ] ;
973}
974
975rule AddFilesToAlternativeGCCArchive directory : targets : destName
976{
977	# AddFilesToAlternativeGCCArchive <directory> : <targets> [ : dest name ]
978
979	AddFilesToContainer $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME)
980		: $(directory) : $(targets) : $(destName) ;
981}
982
983rule AddSymlinkToAlternativeGCCArchive directoryTokens : linkTarget : linkName
984{
985	# AddSymlinkToAlternativeGCCArchive <directory> : <link target>
986	#	[ : <link name> ] ;
987
988	AddSymlinkToContainer $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME)
989		: $(directoryTokens) : $(linkTarget) : $(linkName) ;
990}
991
992rule CopyDirectoryToAlternativeGCCArchive directoryTokens : sourceDirectory
993	: targetDirectoryName : excludePatterns : alwaysUpdate
994{
995	CopyDirectoryToContainer $(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME)
996		: $(directoryTokens) : $(sourceDirectory) : $(targetDirectoryName)
997		: $(excludePatterns) : $(alwaysUpdate) ;
998}
999
1000rule CreateAlternativeGCCArchiveMakeDirectoriesScript script
1001{
1002	CreateContainerMakeDirectoriesScript
1003		$(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) : $(script) ;
1004}
1005
1006rule CreateAlternativeGCCArchiveCopyFilesScript script
1007{
1008	CreateContainerCopyFilesScript
1009		$(HAIKU_ALTERNATIVE_GCC_ARCHIVE_CONTAINER_NAME) : $(script) ;
1010}
1011
1012rule BuildAlternativeGCCArchive archive : scripts
1013{
1014	# BuildAlternativeGCCArchive <archive> : <scripts>  ;
1015
1016	local mainScript = build_zip_archive ;
1017	SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ;
1018
1019	Depends $(archive) : $(mainScript) $(scripts) ;
1020	BuildAlternativeGCCArchive1 $(archive) : $(mainScript) $(scripts) ;
1021}
1022
1023actions BuildAlternativeGCCArchive1
1024{
1025	$(2[1]) $(1) $(2[2-])
1026}
1027
1028
1029#pragma mark - Haiku Hybrid Image rules
1030
1031
1032rule AddFilesToHaikuHybridImage directory : targets : destName
1033	: useABISubDir
1034{
1035	# AddFilesToHaikuHybridImage <directory> : <targets> : <destName>
1036	#	: <useABISubDir>
1037	#
1038	# Convenience rule calling both AddFilesToHaikuImage and
1039	# AddFilesToAlternativeGCCArchive.
1040	#
1041	# <useABISubDir>
1042	#	if non-empty, specifies that an ABI subdirectory shall be appended to
1043	#	<directory> for the alternative GCC archive.
1044
1045	local alternativeSubDir ;
1046	if $(useABISubDir) {
1047		alternativeSubDir = gcc$(HAIKU_GCC_VERSION[1]) ;
1048	}
1049
1050	AddFilesToHaikuImage $(directory) : $(targets) : $(destName) ;
1051	AddFilesToAlternativeGCCArchive $(directory) $(alternativeSubDir)
1052		: $(targets) : $(destName) ;
1053}
1054
1055rule AddSymlinkToHaikuHybridImage directoryTokens : linkTarget : linkName
1056	: useSymlinkTargetABISubDir : useABISubDir
1057{
1058	# AddFilesToHaikuHybridImage <directoryTokens> : <linkTarget> : <linkName>
1059	#	[ : <useSymlinkTargetABISubDir> [ :  <useABISubDir> ] ]
1060	#
1061	# Convenience rule calling both AddSymlinkToHaikuImage and
1062	# AddSymlinkToAlternativeGCCArchive.
1063	#
1064	# <linkTarget>
1065	#	Can be a list of components that will be joined to path inserting
1066	#	"/"s inbetween.
1067	# <useSymlinkTargetABISubDir>
1068	#	If non-empty, specifies that an ABI subdirectory shall be inserted
1069	#	into <linkTarget> (between the first and second component) for the
1070	#	alternative GCC archive.
1071	# <useABISubDir>
1072	#	If non-empty, specifies that an ABI subdirectory part shall be appended
1073	#	to the directory tokens for the alternative GCC archive.
1074
1075	local alternativeDirTokens = $(directoryTokens) ;
1076	if $(useABISubDir) {
1077		alternativeDirTokens += gcc$(HAIKU_GCC_VERSION[1]) ;
1078	}
1079
1080	local alternativeLinkTarget = $(linkTarget) ;
1081	if $(useSymlinkTargetABISubDir) {
1082		alternativeLinkTarget = $(linkTarget[1]) gcc$(HAIKU_GCC_VERSION[1])
1083			$(linkTarget[2-]) ;
1084	}
1085	linkTarget = $(linkTarget:J=/) ;
1086	alternativeLinkTarget = $(alternativeLinkTarget:J=/) ;
1087
1088	AddSymlinkToHaikuImage $(directoryTokens) : $(linkTarget) : $(linkName) ;
1089	AddSymlinkToAlternativeGCCArchive $(alternativeDirTokens)
1090		: $(alternativeLinkTarget) : $(linkName) ;
1091}
1092
1093
1094#pragma mark - Floppy Boot Archive rules
1095
1096
1097rule AddDirectoryToFloppyBootArchive directoryTokens
1098{
1099	# AddDirectoryToFloppyBootArchive <directoryTokens>
1100
1101	return [ AddDirectoryToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1102		: $(directoryTokens) ] ;
1103}
1104
1105rule AddFilesToFloppyBootArchive directory : targets : destName
1106{
1107	# AddFilesToFloppyBootArchive <directory> : <targets> [ : dest name ]
1108
1109	AddFilesToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) : $(directory)
1110		: $(targets) : $(destName) ;
1111}
1112
1113rule AddSymlinkToFloppyBootArchive directoryTokens : linkTarget : linkName
1114{
1115	# AddSymlinkToFloppyBootArchive <directory> : <link target> [ : <link name> ] ;
1116
1117	AddSymlinkToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1118		: $(directoryTokens) : $(linkTarget) : $(linkName) ;
1119}
1120
1121rule AddDriversToFloppyBootArchive relativeDirectoryTokens : targets
1122{
1123	# AddDriversToFloppyBootArchive <relative directory> : <targets> ;
1124
1125	AddDriversToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1126		: $(relativeDirectoryTokens) : $(targets) ;
1127}
1128
1129rule AddNewDriversToFloppyBootArchive relativeDirectoryTokens : targets
1130{
1131	# AddNewDriversToFloppyBootArchive <relative directory> : <targets> ;
1132
1133	AddNewDriversToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1134		: $(relativeDirectoryTokens) : $(targets) ;
1135}
1136
1137rule AddDriverRegistrationToFloppyBootArchive relativeDirectoryTokens : target
1138	: links
1139{
1140	# AddDriverRegistrationToFloppyBootArchive <directory> : <link target>
1141	#	: <link names> ] ;
1142
1143	AddDriverRegistrationToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1144		: $(relativeDirectoryTokens) : $(target) : $(links) ;
1145}
1146
1147rule AddBootModuleSymlinksToFloppyBootArchive targets
1148{
1149	# AddBootModuleSymlinksToFloppyBootArchive <targets> ;
1150
1151	AddBootModuleSymlinksToContainer $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1152		: $(targets) ;
1153}
1154
1155rule CreateFloppyBootArchiveMakeDirectoriesScript script
1156{
1157	CreateContainerMakeDirectoriesScript
1158		$(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME) : $(script) ;
1159}
1160
1161rule CreateFloppyBootArchiveCopyFilesScript script
1162{
1163	CreateContainerCopyFilesScript $(HAIKU_FLOPPY_BOOT_IMAGE_CONTAINER_NAME)
1164		: $(script) ;
1165}
1166
1167rule BuildFloppyBootArchive archive : scripts
1168{
1169	# BuildHFloppyBootArchive <archive> : <scripts>  ;
1170
1171	local mainScript = build_tgz_archive ;
1172	SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ;
1173
1174	Depends $(archive) : $(mainScript) $(scripts) ;
1175	BuildFloppyBootArchive1 $(archive) : $(mainScript) $(scripts) ;
1176}
1177
1178actions BuildFloppyBootArchive1
1179{
1180	$(2[1]) $(1) $(2[2-])
1181}
1182
1183# warning: that is quite x86 dependant...
1184
1185rule BuildFloppyBootImage image : haikuLoader : archive
1186{
1187	Depends $(image) : $(haikuLoader) ;
1188	Depends $(image) : $(archive) ;
1189	#MakeLocateDebug $(image) ;
1190	FLOPPY_IMAGE_SIZE on $(image) = $(HAIKU_BOOT_FLOPPY_IMAGE_SIZE) ;
1191	ARCHIVE_IMAGE_OFFSET on $(image) = $(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ;
1192	BuildFloppyBootImage1 $(image) : $(haikuLoader) $(archive) ;
1193	if $(HAIKU_BOOT_PLATFORM) = atari_m68k {
1194		Depends $(image) : <build>fixup_tos_boot_checksum ;
1195		BuildFloppyBootImageAtariM68K $(image) : <build>fixup_tos_boot_checksum ;
1196	}
1197}
1198
1199actions BuildFloppyBootImage1
1200{
1201	$(RM) $(<)
1202	# make an empty image
1203	dd if=/dev/zero of=$(<) bs=1k count=$(FLOPPY_IMAGE_SIZE)
1204	# add haiku_loader
1205	dd if=$(>[1]) of=$(<) conv=notrunc
1206	# add the boot drivers tgz archive
1207	dd if=$(>[2]) of=$(<) bs=$(ARCHIVE_IMAGE_OFFSET)k seek=1 conv=notrunc
1208}
1209
1210actions BuildFloppyBootImageAtariM68K
1211{
1212	# fixup the boot sector checksum
1213	$(>[1]) $(<)
1214}
1215
1216#pragma mark - CD Boot Image rules
1217
1218rule BuildCDBootImage image : bootfloppy : extrafiles
1219{
1220	Depends $(image) : $(bootfloppy) ;
1221	Depends $(image) : $(extrafiles) ;
1222	BOOTIMG on $(image) = $(bootfloppy) ;
1223
1224	BuildCDBootImage1 $(image) : $(bootfloppy) $(extrafiles) ;
1225}
1226
1227actions BuildCDBootImage1
1228{
1229	$(RM) $(<)
1230	mkisofs -b $(BOOTIMG) -r -J -V bootimg -o $(<) $(>[1]) $(>[2-])
1231}
1232
1233
1234#pragma mark - CD Boot PPC Image rules
1235
1236rule BuildCDBootPPCImage image : hfsmaps : elfloader : coffloader : chrpscript : extrafiles
1237{
1238	Depends $(image) : $(elfloader) ;
1239	Depends $(image) : $(coffloader) ;
1240	Depends $(image) : $(chrpscript) ;
1241	Depends $(image) : $(extrafiles) ;
1242	Depends $(image) : $(hfsmaps) ;
1243	MAPS on $(image) = $(hfsmaps) ;
1244
1245	BuildCDBootPPCImage1 $(image) : $(elfloader) $(coffloader) $(chrpscript) $(extrafiles) ;
1246}
1247
1248actions BuildCDBootPPCImage1 bind MAPS
1249{
1250	$(RM) $(<)
1251	mkdir -p $(HAIKU_OUTPUT_DIR)/cd/ppc
1252	cp $(>) $(HAIKU_OUTPUT_DIR)/cd/ppc/
1253	cp $(>[3]) $(HAIKU_OUTPUT_DIR)/cd/ppc/bootinfo.txt
1254	cp $(>[1]) $(HAIKU_OUTPUT_DIR)/cd/ofwboot.elf
1255	cp $(>[2]) $(HAIKU_OUTPUT_DIR)/cd/ofwboot.xcf
1256	#mkisofs -r -U -chrp-boot -V bootimg -o $(<) $(>[1]) $(>[2-])
1257	#mkisofs -hfs -r -U -chrp-boot -part -map $(MAPS) -no-desktop -hfs-volid bootimg -V bootimg -prep-boot $(>[1]:D=) -o $(<) $(>[1]) $(>[2-])
1258	#mkisofs -v -hfs -part -map $(MAPS) -no-desktop -hfs-volid bootimg -V bootimg -hfs-bless $(HAIKU_OUTPUT_DIR)/cd/ppc -r -o $(<) $(>[1]) $(>[2-]) $(HAIKU_OUTPUT_DIR)/cd
1259	#mkisofs -r -U -chrp-boot -V bootimg -prep-boot $(>[1]:D=) -o $(<) $(>[1]) $(>[2-])
1260	#mkisofs -r -U -V bootimg -prep-boot $(>[1]:D=) -o $(<) $(>[1]) $(>[2-])
1261	# $(HAIKU_OUTPUT_DIR)/cd
1262	# -hfs -hfs-bless .
1263	mkisofs -v -hfs -part -map $(MAPS) -no-desktop -hfs-volid bootimg -V bootimg -hfs-bless $(HAIKU_OUTPUT_DIR)/cd/ppc -prep-boot ppc/$(>[2]:D=) -r -o $(<) $(HAIKU_OUTPUT_DIR)/cd
1264	#$(RM) -R $(HAIKU_OUTPUT_DIR)/cd
1265}
1266
1267
1268