1SubDir HAIKU_TOP src system libroot ;
2
3UsePrivateHeaders libroot runtime_loader ;
4
5local architectureObject ;
6for architectureObject in [ MultiArchSubDirSetup ] {
7	on $(architectureObject) {
8		local architecture = $(TARGET_PACKAGING_ARCH) ;
9
10		UsePrivateSystemHeaders ;
11
12		local libgccAsSingleObject ;
13		if $(architecture) = x86_gcc2 {
14			libgccAsSingleObject
15				= <$(architecture)>libroot_libgcc_$(TARGET_ARCH).o ;
16			# One object to link them all...
17			TARGET_LDFLAGS_$(TARGET_PACKAGING_ARCH) on
18				<$(architecture)>libroot_libgcc_$(TARGET_ARCH).o =
19				[ on <$(architecture)>libroot_libgcc_$(TARGET_ARCH).o
20					return $(TARGET_LDFLAGS_$(TARGET_PACKAGING_ARCH)) ]
21				--whole-archive ;
22			MergeObject $(libgccAsSingleObject) : : [ TargetLibgcc ] ;
23		}
24
25		local librootObjects =
26			$(libgccAsSingleObject)
27
28			os_main.o
29			os_arch_$(TARGET_ARCH).o
30
31			posix_arch_$(TARGET_ARCH).o
32			posix_crypt.o
33			posix_locale.o
34			posix_main.o
35			posix_pthread.o
36			posix_signal.o
37			posix_stdio.o
38			posix_musl.o
39			posix_gnu_arch_$(TARGET_ARCH).o
40			posix_gnu_ctype.o
41			posix_gnu_ext.o
42			posix_gnu_iconv.o
43			posix_gnu_libio.o
44			posix_gnu_locale.o
45			posix_gnu_math.o
46			posix_gnu_misc.o
47			posix_gnu_regex.o
48			posix_gnu_stdio.o
49			posix_gnu_stdlib.o
50			posix_gnu_wcsmbs.o
51			posix_stdlib.o
52			posix_string.o
53			posix_string_arch_$(TARGET_ARCH).o
54			posix_sys.o
55			posix_time.o
56			posix_unistd.o
57			posix_wchar.o
58			;
59		librootObjects = $(librootObjects:G=$(architecture)) ;
60
61		local librootDebugObjects =
62			posix_malloc_debug.o
63			;
64		librootDebugObjects = $(librootDebugObjects:G=$(architecture)) ;
65
66		local librootNoDebugObjects =
67			posix_malloc.o
68			;
69		librootNoDebugObjects = $(librootNoDebugObjects:G=$(architecture)) ;
70
71		local libroot = [ MultiArchDefaultGristFiles libroot.so ] ;
72		local librootDebug = $(libroot:B=libroot_debug) ;
73
74		DONT_LINK_AGAINST_LIBROOT on $(libroot) = true ;
75		DONT_LINK_AGAINST_LIBROOT on $(librootDebug) = true ;
76
77		SetVersionScript $(libroot) : libroot_versions ;
78		SetVersionScript $(librootDebug) : libroot_versions ;
79
80		SharedLibrary $(libroot)
81			:
82			libroot_init.c
83			:
84			$(librootObjects)
85			$(librootNoDebugObjects)
86			[ TargetStaticLibsupc++ ]
87			[ TargetLibgcc ]
88			;
89
90		# Use the standard libroot.so soname, so when the debug version is
91		# pre-loaded it prevents the standard version to be loaded as well.
92		HAIKU_SONAME on $(librootDebug) = libroot.so ;
93
94		SharedLibrary $(librootDebug)
95			:
96			libroot_init.c
97			:
98			$(librootObjects)
99			$(librootDebugObjects)
100			[ TargetStaticLibsupc++ ]
101			[ TargetLibgcc ]
102			;
103
104		# These are defined in POSIX for c99 support, so fake'em
105		StaticLibrary [ MultiArchDefaultGristFiles libc.a ] : empty.c ;
106		StaticLibrary [ MultiArchDefaultGristFiles libm.a ] : empty.c ;
107		StaticLibrary [ MultiArchDefaultGristFiles libpthread.a ] : empty.c ;
108
109		# Copy libroot.so and update the copy's revision section. We link
110		# everything against the original, but the copy will end up on the disk
111		# image (this way we avoid unnecessary dependencies). The copy will be
112		# located in a subdirectory.
113		if $(TARGET_PLATFORM) = haiku {
114			local targetDir = [ FDirName $(TARGET_DEBUG_$(DEBUG)_LOCATE_TARGET)
115				revisioned ] ;
116			local revisionedLibroot = [ MultiArchDefaultGristFiles
117				libroot.so : revisioned ] ;
118			local revisionedLibrootDebug
119				= $(librootDebug:G=$(revisionedLibroot:G)) ;
120
121			MakeLocate $(revisionedLibroot) : $(targetDir) ;
122			CopySetHaikuRevision $(revisionedLibroot) : $(libroot) ;
123
124			MakeLocate $(revisionedLibrootDebug) : $(targetDir) ;
125			CopySetHaikuRevision $(revisionedLibrootDebug) : $(librootDebug) ;
126		}
127	}
128}
129
130SubInclude HAIKU_TOP src system libroot add-ons ;
131SubInclude HAIKU_TOP src system libroot os ;
132SubInclude HAIKU_TOP src system libroot posix ;
133SubInclude HAIKU_TOP src system libroot stubbed ;
134