1SubDir HAIKU_TOP src build libroot ;
2
3UseHeaders [ FDirName $(HAIKU_TOP) headers build ] : true ;
4UseHeaders [ FDirName $(HAIKU_TOP) headers build os ] : true ;
5UseHeaders [ FDirName $(HAIKU_TOP) headers build os app ] : true ;
6UseHeaders [ FDirName $(HAIKU_TOP) headers build os drivers ] : true ;
7UseHeaders [ FDirName $(HAIKU_TOP) headers build os kernel ] : true ;
8UseHeaders [ FDirName $(HAIKU_TOP) headers build os interface ] : true ;
9UseHeaders [ FDirName $(HAIKU_TOP) headers build os storage ] : true ;
10UseHeaders [ FDirName $(HAIKU_TOP) headers build os support ] : true ;
11
12UsePrivateBuildHeaders kernel libroot system ;
13UsePrivateHeaders system ;
14
15{
16	local defines = [ FDefines
17		'HAIKU_BUILD_ATTRIBUTES_DIR="\"$(HAIKU_BUILD_ATTRIBUTES_DIR)\""'
18		_HAIKU_BUILD_DONT_REMAP_FD_FUNCTIONS=1
19	] ;
20	SubDirCcFlags $(defines) ;
21	SubDirC++Flags $(defines) ;
22
23	defines = [ FDefines
24		HAIKU_BUILD_GENERATED_DIRECTORY="\\\"$(HAIKU_OUTPUT_DIR)\\\""
25	] ;
26	ObjectC++Flags find_directory.cpp : $(defines) ;
27
28	defines = [ FDefines BUILDING_HAIKU_ERROR_MAPPER=1 ] ;
29	ObjectC++Flags errors.cpp : $(defines) ;
30
31	defines = [ FDefines KMESSAGE_CONTAINER_ONLY=1 ] ;
32	ObjectC++Flags KMessage.cpp : $(defines) ;
33}
34
35# locate the library
36MakeLocate libroot_build.so : $(HOST_BUILD_COMPATIBILITY_LIB_DIR) ;
37
38# darwin already has strlcpy and strlcat in libSystem
39local strlSources ;
40if $(HOST_PLATFORM) != darwin && $(HOST_PLATFORM) != haiku_host {
41	strlSources = strlcpy.c strlcat.c ;
42}
43
44if $(HOST_PLATFORM) = mingw {
45	strlSources += stpcpy.c strcasestr.c ;
46}
47
48local hostPlatformSources ;
49if $(HOST_PLATFORM) = freebsd {
50	hostPlatformSources = fs_freebsd.cpp ;
51}
52
53if $(HOST_PLATFORM) = darwin {
54	hostPlatformSources = fs_darwin.cpp ;
55}
56
57local librootSources =
58	atomic.cpp
59	byteorder.cpp
60	errors.cpp
61	find_directory.cpp
62	fs.cpp
63	fs_attr.cpp
64	fs_descriptors.cpp
65	misc.cpp
66	sem.cpp
67	thread.cpp
68	SHA256.cpp
69
70	$(hostPlatformSources)
71
72	driver_settings.cpp
73
74	$(strlSources)
75	strnlen.cpp
76
77	KMessage.cpp
78;
79
80USES_BE_API on [ FGristFiles $(librootSources:S=$(SUFOBJ)) ] = true ;
81
82local librootTarget = libroot_build.so ;
83if $(HAIKU_HOST_USE_XATTR) = 0 {
84	# prevent library from being cleaned when emulated attributes are used
85	librootTarget = <temp>libroot_build.so ;
86	File libroot_build.so : <temp>libroot_build.so ;
87	MODE on libroot_build.so = $(EXEMODE) ;
88	Chmod libroot_build.so ;
89	RmTemps libroot_build.so : <temp>libroot_build.so ;
90}
91BuildPlatformSharedLibrary $(librootTarget) :
92	$(librootSources)
93	:
94	$(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ;
95
96# TODO: This doesn't work with the function remapping.
97BuildPlatformStaticLibrary libroot_build.a :
98	:
99	[ FGristFiles $(librootSources:S=$(SUFOBJ)) ]
100;
101
102USES_BE_API on [ FGristFiles function_remapper$(SUFOBJ) ] = true ;
103
104NO_HIDDEN_VISIBILITY on <build>libroot_build_function_remapper.a = 1 ;
105BuildPlatformStaticLibraryPIC libroot_build_function_remapper.a :
106	function_remapper.cpp
107;
108
109SEARCH on [ FGristFiles driver_settings.cpp ]
110	= [ FDirName $(HAIKU_TOP) src system libroot os ] ;
111SEARCH on [ FGristFiles $(strlSources) strnlen.cpp ]
112	= [ FDirName $(HAIKU_TOP) src system libroot posix string ] ;
113SEARCH on [ FGristFiles SHA256.cpp ]
114	= [ FDirName $(HAIKU_TOP) src system libroot posix crypt ] ;
115SEARCH on [ FGristFiles KMessage.cpp ]
116    = [ FDirName $(HAIKU_TOP) src system kernel messaging ] ;
117