1 # Makefile fragment for NaCl configurations.
3 # Copyright (C) 2015 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>.
20 # The libthread_db code does not compile for NaCl because there is no
21 # sys/procfs.h supplying the register layout types. But since libthread_db
22 # will probably never be useful for NaCl, just elide the directory rather
23 # than implementing stuff to make it compile (and never get used).
24 subdirs
:= $(filter-out nptl_db
,$(subdirs
))
25 sorted-subdirs
:= $(filter-out nptl_db
,$(sorted-subdirs
))
27 # The (required) --with-headers option to configure sets sysheaders to the
28 # location of the native_client/.. source directory. We'll get necessary
29 # headers directly from there.
30 naclsrc
= $(sysheaders
)/native_client
/src
32 # How to find the directory containing this Makefile.
33 nacl
= $(..
)sysdeps
/nacl
35 # Generate our bits/errno.h with the numbers from NaCl's sys/errno.h file.
36 nacl-errno
= $(naclsrc
)/trusted
/service_runtime
/include/sys
/errno.h
38 bits-errno
= $(common-objpfx
)bits
/errno.h
39 $(bits-errno
): $(common-objpfx
)stamp-errnos
;
40 $(common-objpfx
)stamp-errnos
: $(nacl
)/errnos.awk
$(..
)manual
/errno.texi \
42 $(make-target-directory
)
43 $(AWK
) -f
$^
> $(bits-errno
)-tmp
44 # Make it unwritable so noone will edit it by mistake.
45 -chmod a-w
$(bits-errno
)-tmp
46 $(move-if-change
) $(bits-errno
)-tmp
$(bits-errno
)
48 common-generated
+= stamp-errnos bits
/errno.h
49 before-compile
+= $(bits-errno
)
51 # Massage NaCl's irt.h (and irt_dev.h) into something we can use.
52 # See irt.sed for details.
53 nacl-irt.h
= $(common-objpfx
)nacl-irt.h
54 $(nacl-irt.h
): $(nacl
)/irt.sed \
55 $(naclsrc
)/untrusted
/irt
/irt.h \
56 $(naclsrc
)/untrusted
/irt
/irt_dev.h
59 common-generated
+= nacl-irt.h
60 before-compile
+= $(nacl-irt.h
)
62 $(common-objpfx
)nacl-interfaces.v.i
: $(nacl
)/nacl-interfaces.mk.in \
63 $(nacl
)/nacl-interface-list.h
64 -include $(common-objpfx
)nacl-interfaces.v
65 common-generated
+= nacl-interfaces.v
66 before-compile
+= $(common-objpfx
)nacl-interfaces.v
68 nacl-all-interfaces
= $(nacl-mandatory-interfaces
) $(nacl-optional-interfaces
)
69 nacl-interface-routines
= $(nacl-all-interfaces
:%=nacl-interface-
%)
71 define nacl-interface-table-command
72 (echo
'#define INTERFACE_CATEGORY $1'; \
73 echo
'#define INTERFACE_MODULE $(firstword $(subst -, ,$*))'; \
74 echo
'#define INTERFACE_TYPE $(word 2,$(subst -, ,$*))'; \
75 echo
'#define INTERFACE_STRING $(nacl-$*-string)'; \
76 echo
'#include "nacl-interface-table.c"' \
81 nacl-interface-pattern
= $(objpfx
)nacl-interface-
%.c
83 $(nacl-mandatory-interfaces
:%=$(nacl-interface-pattern
)): \
84 $(nacl-interface-pattern
): $(nacl
)/Makefile
$(common-objpfx
)nacl-interfaces.v
85 $(make-target-directory
)
86 $(call nacl-interface-table-command
,mandatory
)
87 $(nacl-optional-interfaces
:%=$(nacl-interface-pattern
)): \
88 $(nacl-interface-pattern
): $(nacl
)/Makefile
$(common-objpfx
)nacl-interfaces.v
89 $(make-target-directory
)
90 $(call nacl-interface-table-command
,optional
)
92 nacl-routines-of
= $(filter nacl-interface-
$1-%,$(nacl-interface-routines
))
95 # Run the NaCl code validator on binaries after we link them, so the
96 # build does not succeed with any binary that won't pass validation.
97 # Moving the file around makes sure that we don't leave a target
98 # appearing complete after it fails validation.
100 mv
-f
$1 $1.prevalidation
101 $(nacl
)/nacl-after-link.sh
'${READELF}' $1.prevalidation
102 mv
-f
$1.prevalidation
$1
105 # The test wrapper script takes care of running things under NaCl's sel_ldr.
106 test-wrapper-env-only
= $(nacl
)/nacl-test-wrapper.sh
--arch
=$(nacl-sdk-arch
)
107 test-wrapper-env
= $(test-wrapper-env-only
)
108 test-wrapper
= $(test-wrapper-env
) --
111 sysdep_routines
+= nacl_interface_query nacl_interface_ext_supply \
112 nacl-interfaces
$(call nacl-routines-of
,libc
)
116 sysdep-dl-routines
+= $(call nacl-routines-of
,rtld
)
117 sysdep-rtld-routines
+= nacl-interfaces
$(call nacl-routines-of
,rtld
)
121 sysdep_routines
+= xstatconv
124 ifeq ($(subdir
),nptl
)
125 # We do not need any wrappers in libpthread.
126 libpthread-routines
:= $(filter-out ptw-
%,$(libpthread-routines
))
129 ifeq ($(subdir
),misc
)
130 # We reuse the Linux file since the bits match. The file lives in the
131 # top-level source tree so we can use it without reference to any
132 # sysdeps/.../linux/ directories, but it's still a sysdeps decision to
134 sysdep_headers
+= bits
/mman-linux.h