xref: /haiku/src/system/libroot/Jamfile (revision e6eaad8615c4734498b9b800847d18bbe62782fa)
1SubDir HAIKU_TOP src system libroot ;
2
3UsePrivateHeaders libroot runtime_loader ;
4
5rule FilterArchive
6{
7	# FilterArchive <target> : <source> : <members to remove>
8
9	# set the tools according to the platform
10	AR on $(1) = $(TARGET_AR_$(TARGET_PACKAGING_ARCH)) d ;
11	# TODO: use $(TARGET_DELARFLAGS_$(TARGET_PACKAGING_ARCH))
12	RANLIB on $(1) = $(TARGET_RANLIB_$(TARGET_PACKAGING_ARCH)) ;
13	MEMBERS on $(1) = $(3) ;
14
15	MakeLocateArch $(1) ;
16	Depends $(1) : $(2) ;
17	File $(1) : $(2) ;
18
19	# delete the unwanted members
20	FilterArchive1 $(1) ;
21
22	if $(RANLIB) {
23		Ranlib $(1) ;
24	}
25}
26
27actions FilterArchive1
28{
29	$(AR) $(<) $(MEMBERS)
30}
31
32local architectureObject ;
33for architectureObject in [ MultiArchSubDirSetup ] {
34	on $(architectureObject) {
35		local architecture = $(TARGET_PACKAGING_ARCH) ;
36
37		UsePrivateSystemHeaders ;
38
39		# Make a copy of libgcc without the objects we don't need
40		FilterArchive <$(architecture)>libroot_libgcc_$(TARGET_ARCH).a
41			: $(HAIKU_GCC_LIBGCC_$(architecture))
42			: $(HAIKU_GCC_LIBGCC_OBJECTS_EXCLUDES_$(architecture)) ;
43
44		# One object to link them all...
45		TARGET_LDFLAGS_$(TARGET_PACKAGING_ARCH) on
46			<$(architecture)>libroot_libgcc_$(TARGET_ARCH).o =
47			[ on <$(architecture)>libroot_libgcc_$(TARGET_ARCH).o
48				return $(TARGET_LDFLAGS_$(TARGET_PACKAGING_ARCH)) ]
49			--whole-archive ;
50
51		MergeObject <$(architecture)>libroot_libgcc_$(TARGET_ARCH).o
52			:
53			: <$(architecture)>libroot_libgcc_$(TARGET_ARCH).a ;
54
55		local librootObjects =
56			libroot_libgcc_$(TARGET_ARCH).o
57
58			os_main.o
59			os_arch_$(TARGET_ARCH).o
60
61			posix_arch_$(TARGET_ARCH).o
62			posix_crypt.o
63			posix_locale.o
64			posix_main.o
65			posix_pthread.o
66			posix_signal.o
67			posix_stdio.o
68			posix_gnu_arch_$(TARGET_ARCH).o
69			posix_gnu_ctype.o
70			posix_gnu_ext.o
71			posix_gnu_iconv.o
72			posix_gnu_libio.o
73			posix_gnu_locale.o
74			posix_gnu_misc.o
75			posix_gnu_regex.o
76			posix_gnu_stdio.o
77			posix_gnu_stdlib.o
78			posix_gnu_string.o
79			posix_gnu_wcsmbs.o
80			posix_stdlib.o
81			posix_string.o
82			posix_string_arch_$(TARGET_ARCH).o
83			posix_sys.o
84			posix_time.o
85			posix_unistd.o
86			posix_wchar.o
87			;
88		librootObjects = $(librootObjects:G=$(architecture)) ;
89
90		local librootDebugObjects =
91			posix_malloc_debug.o
92			;
93		librootDebugObjects = $(librootDebugObjects:G=$(architecture)) ;
94
95		local librootNoDebugObjects =
96			posix_malloc.o
97			;
98		librootNoDebugObjects = $(librootNoDebugObjects:G=$(architecture)) ;
99
100		local libroot = [ MultiArchDefaultGristFiles libroot.so ] ;
101		local librootDebug = $(libroot:B=libroot_debug) ;
102
103		DONT_LINK_AGAINST_LIBROOT on $(libroot) = true ;
104		DONT_LINK_AGAINST_LIBROOT on $(librootDebug) = true ;
105
106		SetVersionScript $(libroot) : libroot_versions ;
107		SetVersionScript $(librootDebug) : libroot_versions ;
108
109		SharedLibrary $(libroot)
110			:
111			libroot_init.c
112			:
113			$(librootObjects)
114			$(librootNoDebugObjects)
115			$(HAIKU_STATIC_LIBSUPC++_$(architecture))
116			;
117
118		# Use the standard libroot.so soname, so when the debug version is
119		# pre-loaded it prevents the standard version to be loaded as well.
120		HAIKU_SONAME on $(librootDebug) = libroot.so ;
121
122		SharedLibrary $(librootDebug)
123			:
124			libroot_init.c
125			:
126			$(librootObjects)
127			$(librootDebugObjects)
128			$(HAIKU_STATIC_LIBSUPC++_$(architecture))
129			;
130
131
132		# Copy libroot.so and update the copy's revision section. We link
133		# everything against the original, but the copy will end up on the disk
134		# image (this way we avoid unnecessary dependencies). The copy will be
135		# located in a subdirectory.
136		if $(TARGET_PLATFORM) = haiku {
137			local targetDir = [ FDirName $(TARGET_DEBUG_$(DEBUG)_LOCATE_TARGET)
138				revisioned ] ;
139			local revisionedLibroot = [ MultiArchDefaultGristFiles
140				libroot.so : revisioned ] ;
141			local revisionedLibrootDebug
142				= $(librootDebug:G=$(revisionedLibroot:G)) ;
143
144			MakeLocate $(revisionedLibroot) : $(targetDir) ;
145			CopySetHaikuRevision $(revisionedLibroot) : $(libroot) ;
146
147			MakeLocate $(revisionedLibrootDebug) : $(targetDir) ;
148			CopySetHaikuRevision $(revisionedLibrootDebug) : $(librootDebug) ;
149		}
150	}
151}
152
153SubInclude HAIKU_TOP src system libroot add-ons ;
154SubInclude HAIKU_TOP src system libroot os ;
155SubInclude HAIKU_TOP src system libroot posix ;
156