BootRules revision 220d0402
1rule SetupBoot
2{
3	# Usage SetupBoot <sources_or_objects> : <extra_cc_flags> : <include_private_headers> ;
4	#
5	# <sources_or_objects> - Ideally sources, otherwise HDRSEARCH can not be
6	#                        set for the sources and the sources some header
7	#                        dependencies might be missing.
8
9	local sources = [ FGristFiles $(1) ] ;
10	local objects = $(sources:S=$(SUFOBJ)) ;
11
12	# add private kernel headers
13	if $(3) != false {
14		SourceSysHdrs $(sources) : $(TARGET_PRIVATE_KERNEL_HEADERS) ;
15	}
16
17	if $(HAIKU_BOOT_C++_HEADERS_DIR_$(TARGET_PACKAGING_ARCH)) {
18		SourceSysHdrs $(sources) :
19			$(HAIKU_BOOT_C++_HEADERS_DIR_$(TARGET_PACKAGING_ARCH)) ;
20	}
21
22	local object ;
23	for object in $(objects) {
24		# add boot flags for the object
25		ObjectCcFlags $(object) : $(TARGET_BOOT_CCFLAGS) $(2) ;
26		ObjectC++Flags $(object) : $(TARGET_BOOT_C++FLAGS) $(2) ;
27		ObjectDefines $(object) : $(TARGET_KERNEL_DEFINES) ;
28        ASFLAGS on $(object) = $(TARGET_BOOT_CCFLAGS) ;
29
30		# override warning flags
31		TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH) on $(object)
32			= $(TARGET_KERNEL_WARNING_CCFLAGS) ;
33		TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH) on $(object)
34			= $(TARGET_KERNEL_WARNING_C++FLAGS) ;
35	}
36}
37
38rule BootObjects
39{
40	SetupBoot $(1) : $(2) ;
41	Objects $(1) ;
42}
43
44rule BootLd
45{
46	# BootLd <name> : <objs> : <linkerscript> : <args> ;
47
48	LINK on $(1) = $(TARGET_LD_$(TARGET_PACKAGING_ARCH)) ;
49
50	LINKFLAGS on $(1) = $(4) ;
51	if $(3) { LINKFLAGS on $(1) += --script=$(3) ; }
52
53	# Remove any preset LINKLIBS, but link against libgcc.a. Linking against
54	# libsupc++ is opt-out.
55	local libs ;
56	if ! [ on $(1) return $(HAIKU_NO_LIBSUPC++) ] {
57		libs += [ TargetBootLibsupc++ true ] ;
58		Depends $(1) : [ TargetBootLibsupc++ ] ;
59	}
60	LINKLIBS on $(1) =  $(libs) [ TargetBootLibgcc true ] ;
61	Depends $(1) : [ TargetBootLibgcc ] ;
62
63	# TODO: Do we really want to invoke SetupBoot here? The objects should
64	# have been compiled with BootObjects anyway, so we're doing that twice.
65	SetupBoot $(2) ;
66
67	# Show that we depend on the libraries we need
68	LocalClean clean : $(1) ;
69	LocalDepends all : $(1) ;
70	Depends $(1) : $(2) ;
71
72	MakeLocateDebug $(1) ;
73
74	on $(1) XRes $(1) : $(RESFILES) ;
75	if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] {
76		SetType $(1) ;
77		MimeSet $(1) ;
78		SetVersion $(1) ;
79	}
80}
81
82actions BootLd bind VERSION_SCRIPT
83{
84	$(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) \
85		--version-script=$(VERSION_SCRIPT)
86}
87
88rule BootMergeObject
89{
90	# BootMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ;
91	# Compiles source files and merges the object files to an object file.
92	# <name>: Name of the object file to create. No grist will be added.
93	# <sources>: Sources to be compiled. Grist will be added.
94	# <extra CFLAGS>: Additional flags for compilation.
95	# <other objects>: Object files or static libraries to be merged. No grist
96	#                  will be added.
97	#
98
99	SetupBoot $(2) : $(3) ;
100	Objects $(2) ;
101	MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ;
102	LINKFLAGS on $(1) += $(TARGET_BOOT_LINKFLAGS) ;
103}
104
105rule BootStaticLibrary
106{
107	# Usage BootStaticLibrary <name> : <sources> : <extra cc flags>  ;
108	# This is designed to take a set of sources and libraries and create
109	# a file called lib<name>.a
110
111	SetupBoot $(2) : $(3) : false ;
112	Library $(1) : $(2) ;
113}
114
115rule BootStaticLibraryObjects
116{
117	# Usage BootStaticLibrary <name> : <sources> ;
118	# This is designed to take a set of sources and libraries and create
119	# a file called <name>
120
121	# Show that we depend on the libraries we need
122	SetupBoot $(2) ;
123	LocalClean clean : $(1) ;
124	LocalDepends all : $(1) ;
125	Depends $(1) : $(2) ;
126
127	MakeLocateDebug $(1) ;
128}
129
130actions BootStaticLibraryObjects
131{
132	# Force recreation of the archive to avoid build errors caused by
133	# stale dependencies after renaming or deleting object files.
134	$(RM) "$(1)"
135	$(HAIKU_AR_$(TARGET_PACKAGING_ARCH)) -r "$(1)" "$(2)" ;
136}
137