xref: /haiku/build/jam/BootRules (revision a629567a9001547736cfe892cdf992be16868fed)
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 += $(TARGET_BOOT_LIBSUPC++) ;
58	}
59	LINKLIBS on $(1) =  $(libs) $(TARGET_BOOT_LIBGCC) ;
60
61	# TODO: Do we really want to invoke SetupBoot here? The objects should
62	# have been compiled with BootObjects anyway, so we're doing that twice.
63	SetupBoot $(2) ;
64
65	# Show that we depend on the libraries we need
66	LocalClean clean : $(1) ;
67	LocalDepends all : $(1) ;
68	Depends $(1) : $(2) ;
69
70	MakeLocateDebug $(1) ;
71
72	on $(1) XRes $(1) : $(RESFILES) ;
73	if ! [ on $(1) return $(DONT_USE_BEOS_RULES) ] {
74		SetType $(1) ;
75		MimeSet $(1) ;
76		SetVersion $(1) ;
77	}
78}
79
80actions BootLd bind VERSION_SCRIPT
81{
82	$(LINK) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) \
83		--version-script=$(VERSION_SCRIPT)
84}
85
86rule BootMergeObject
87{
88	# BootMergeObject <name> : <sources> : <extra CFLAGS> : <other objects> ;
89	# Compiles source files and merges the object files to an object file.
90	# <name>: Name of the object file to create. No grist will be added.
91	# <sources>: Sources to be compiled. Grist will be added.
92	# <extra CFLAGS>: Additional flags for compilation.
93	# <other objects>: Object files or static libraries to be merged. No grist
94	#                  will be added.
95	#
96
97	SetupBoot $(2) : $(3) ;
98	Objects $(2) ;
99	MergeObjectFromObjects $(1) : $(2:S=$(SUFOBJ)) : $(4) ;
100	LINKFLAGS on $(1) += $(TARGET_BOOT_LINKFLAGS) ;
101}
102
103rule BootStaticLibrary
104{
105	# Usage BootStaticLibrary <name> : <sources> : <extra cc flags>  ;
106	# This is designed to take a set of sources and libraries and create
107	# a file called lib<name>.a
108
109	SetupBoot $(2) : $(3) : false ;
110	Library $(1) : $(2) ;
111}
112
113rule BootStaticLibraryObjects
114{
115	# Usage BootStaticLibrary <name> : <sources> ;
116	# This is designed to take a set of sources and libraries and create
117	# a file called <name>
118
119	# Show that we depend on the libraries we need
120	SetupBoot $(2) ;
121	LocalClean clean : $(1) ;
122	LocalDepends all : $(1) ;
123	Depends $(1) : $(2) ;
124
125	MakeLocateDebug $(1) ;
126}
127
128actions BootStaticLibraryObjects
129{
130	# Force recreation of the archive to avoid build errors caused by
131	# stale dependencies after renaming or deleting object files.
132	$(RM) "$(1)"
133	$(HAIKU_AR_$(TARGET_PACKAGING_ARCH)) -r "$(1)" "$(2)" ;
134}
135