]> git.ipfire.org Git - thirdparty/glibc.git/blame - posix/Makefile
Complete _BSD_SOURCE / _SVID_source followup cleanup.
[thirdparty/glibc.git] / posix / Makefile
CommitLineData
d4697bc9 1# Copyright (C) 1991-2014 Free Software Foundation, Inc.
28f540f4
RM
2# This file is part of the GNU C Library.
3
4# The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5# modify it under the terms of the GNU Lesser General Public
6# License as published by the Free Software Foundation; either
7# version 2.1 of the License, or (at your option) any later version.
28f540f4
RM
8
9# The GNU C Library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12# Lesser General Public License for more details.
28f540f4 13
41bdb6e2 14# You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15# License along with the GNU C Library; if not, see
16# <http://www.gnu.org/licenses/>.
28f540f4
RM
17
18#
19# Sub-makefile for POSIX portion of the library.
20#
21subdir := posix
22
7b3547eb 23headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
3efdabe7 24 glob.h regex.h wordexp.h fnmatch.h getopt.h \
13a571a7 25 bits/types.h bits/typesizes.h bits/pthreadtypes.h \
9c83a5ec 26 bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \
5107cf1d
UD
27 bits/local_lim.h tar.h bits/utsname.h bits/confname.h \
28 bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \
d1462d2e 29 bits/sched.h re_comp.h wait.h bits/environments.h cpio.h \
553cc5f9 30 sys/sysmacros.h spawn.h bits/unistd.h
28f540f4 31
28f540f4
RM
32routines := \
33 uname \
34 times \
bd355af0 35 wait waitpid wait3 wait4 waitid \
7b3547eb 36 alarm sleep pause nanosleep \
e8c6a442 37 fork vfork _exit \
3d5243d4 38 execve fexecve execv execle execl execvp execlp execvpe \
28f540f4 39 getpid getppid \
3bbceb12 40 getuid geteuid getgid getegid getgroups setuid setgid group_member \
0d8733c4 41 getpgid setpgid getpgrp bsd-getpgrp setpgrp getsid setsid \
747bf98e 42 getresuid getresgid setresuid setresgid \
28f540f4 43 pathconf sysconf fpathconf \
a5f4e34a 44 glob glob64 fnmatch regex \
28f540f4 45 confstr \
7cc27f44 46 getopt getopt1 getopt_init \
7b3547eb 47 sched_setp sched_getp sched_sets sched_gets sched_yield sched_primax \
972e719e 48 sched_primin sched_rr_gi sched_getaffinity sched_setaffinity \
a5a0310d 49 getaddrinfo gai_strerror wordexp \
a5a6f926
UD
50 pread pwrite pread64 pwrite64 \
51 spawn_faction_init spawn_faction_destroy spawn_faction_addclose \
52 spawn_faction_addopen spawn_faction_adddup2 \
53 spawnattr_init spawnattr_destroy \
54 spawnattr_getdefault spawnattr_setdefault \
55 spawnattr_getflags spawnattr_setflags \
afa0569f
UD
56 spawnattr_getpgroup spawnattr_setpgroup spawn spawnp spawni \
57 spawnattr_getsigmask spawnattr_getschedpolicy spawnattr_getschedparam \
bfef9264 58 spawnattr_setsigmask spawnattr_setschedpolicy spawnattr_setschedparam \
aeb2153c 59 posix_madvise \
44f08a6e 60 get_child_max sched_cpucount sched_cpualloc sched_cpufree
7b3547eb 61
7cabd57c
UD
62include ../Makeconfig
63
5f9e57ba 64aux := init-posix environ
df455ccb 65tests := tstgetopt testfnm runtests runptests \
bd9df4cd 66 tst-preadwrite tst-preadwrite64 test-vfork regexbug1 \
ad92208d 67 tst-getlogin tst-mmap tst-getaddrinfo tst-truncate \
726b7b0f 68 tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \
3eab00bd 69 tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
d683fe11 70 tst-gnuglob tst-regex bug-regex5 bug-regex6 bug-regex7 \
82bbb29e 71 bug-regex8 bug-regex9 bug-regex10 bug-regex11 bug-regex12 \
74e12fbc 72 bug-regex13 bug-regex14 bug-regex15 bug-regex16 \
14744156 73 bug-regex17 bug-regex18 bug-regex19 bug-regex20 \
7db61208 74 bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
784aacea 75 bug-regex25 bug-regex26 bug-regex27 bug-regex28 \
8887a920 76 bug-regex29 bug-regex30 bug-regex31 bug-regex32 \
71b5d1c5 77 bug-regex33 tst-nice tst-nanosleep tst-regex2 \
380f06d3 78 transbug tst-rxspencer tst-pcre tst-boost \
df859a0c 79 bug-ga1 tst-vfork1 tst-vfork2 tst-vfork3 tst-waitid \
c27849fb 80 tst-getaddrinfo2 bug-glob1 bug-glob2 bug-glob3 tst-sysconf \
f9ab9ba9
UD
81 tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \
82 tst-execv1 tst-execv2 tst-execl1 tst-execl2 \
506cbf1f 83 tst-execve1 tst-execve2 tst-execle1 tst-execle2 \
846d1362 84 tst-execvp3 tst-execvp4 tst-rfc3484 tst-rfc3484-2 \
ee72b971 85 tst-rfc3484-3 \
e3267684
UD
86 tst-getaddrinfo3 tst-fnmatch2 tst-cpucount tst-cpuset \
87 bug-getopt1 bug-getopt2 bug-getopt3 bug-getopt4 \
adbb8027 88 bug-getopt5 tst-getopt_long1 bug-regex34 bug-regex35 \
7f98f180 89 tst-pathconf tst-getaddrinfo4 tst-rxspencer-no-utf8
5605e117 90xtests := bug-ga2
df455ccb 91ifeq (yes,$(build-shared))
2604afb1 92test-srcs := globtest
e8c6a442 93tests += wordexp-test tst-exec tst-spawn
df455ccb 94endif
4cf8f209
L
95tests-static = tst-exec-static tst-spawn-static
96tests += $(tests-static)
28f540f4
RM
97others := getconf
98install-bin := getconf
ff40792e 99install-others-programs := $(inst_libexecdir)/getconf
28f540f4 100
92040cbc 101before-compile := testcases.h ptestcases.h
4cca6b86 102
414fd335 103# So they get cleaned up.
ba9234d9 104generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) \
cb207240 105 annexc annexc.out wordexp-tst.out bug-regex2-mem \
240e87c2 106 bug-regex2.mtrace bug-regex14-mem bug-regex14.mtrace \
ee70274a 107 bug-regex21-mem bug-regex21.mtrace \
ef06edbe 108 bug-regex31-mem bug-regex31.mtrace \
7f98f180
JM
109 tst-rxspencer-no-utf8-mem tst-rxspencer-no-utf8.mtrace \
110 tst-getconf.out \
5605e117 111 tst-pcre-mem tst-pcre.mtrace tst-boost-mem tst-boost.mtrace \
df859a0c 112 bug-ga2.mtrace bug-ga2-mem bug-glob2.mtrace bug-glob2-mem \
3540d66b
AS
113 tst-vfork3-mem tst-vfork3.mtrace getconf.speclist \
114 tst-fnmatch-mem tst-fnmatch.mtrace
414fd335 115
28f540f4
RM
116include ../Rules
117
03ac099f 118ifeq ($(run-built-tests),yes)
df455ccb
AS
119# globtest and wordexp-test currently only works with shared libraries
120ifeq (yes,$(build-shared))
3f36c563
UD
121tests: $(objpfx)globtest.out $(objpfx)wordexp-tst.out
122$(objpfx)globtest.out: globtest.sh $(objpfx)globtest
740b3dbe
L
123 $(SHELL) $< $(common-objpfx) '$(test-via-rtld-prefix)' \
124 '$(test-program-prefix)' '$(test-wrapper-env)'
3f36c563 125$(objpfx)wordexp-tst.out: wordexp-tst.sh $(objpfx)wordexp-test
740b3dbe 126 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'
61eb22d3 127endif
df455ccb 128endif
61eb22d3 129
09055553
RM
130# If we will use the generic uname implementation, we must figure out what
131# it will say by examining the system, and write the results in config-name.h.
132uname.c: $(objpfx)config-name.h
133$(objpfx)config-name.h: $(..)scripts/config-uname.sh $(common-objpfx)config.make
848917f9 134 $(make-target-directory)
09055553
RM
135 $< '$(config-os)' '$(config-release)' \
136 '$(config-machine)-$(config-vendor)' > $@.new
137 mv -f $@.new $@
138
5a6bbb41 139CFLAGS-regex.c = -Wno-strict-prototypes
3cc3ef96 140CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions
c485e4d2 141CFLAGS-pause.c = -fexceptions -fasynchronous-unwind-tables
7a114794
UD
142CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
143CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
144CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
145CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
146CFLAGS-sleep.c = -fexceptions
147CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
82ee37c5 148CFLAGS-waitid.c = -fexceptions -fasynchronous-unwind-tables
7a114794 149CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
cdbfa9f8 150CFLAGS-getopt.c = -fexceptions
70fb71fd
UD
151CFLAGS-wordexp.c = -fexceptions
152CFLAGS-wordexp.os = -fomit-frame-pointer
28f367c4 153CFLAGS-sysconf.c = -fexceptions -DGETCONF_DIR='"$(libexecdir)/getconf"'
1db52d14
UD
154CFLAGS-pathconf.c = -fexceptions
155CFLAGS-fpathconf.c = -fexceptions
70fb71fd
UD
156CFLAGS-spawn.c = -fexceptions
157CFLAGS-spawn.os = -fomit-frame-pointer
158CFLAGS-spawnp.c = -fexceptions
159CFLAGS-spawnp.os = -fomit-frame-pointer
160CFLAGS-spawni.c = -fexceptions
161CFLAGS-spawni.os = -fomit-frame-pointer
8dab36a1 162CFLAGS-pause.c = -fexceptions
e07bb02a
UD
163CFLAGS-glob.c = $(uses-callbacks) -fexceptions
164CFLAGS-glob64.c = $(uses-callbacks) -fexceptions
28f367c4 165CFLAGS-getconf.c = -DGETCONF_DIR='"$(libexecdir)/getconf"'
70fb71fd
UD
166CFLAGS-execve.os = -fomit-frame-pointer
167CFLAGS-fexecve.os = -fomit-frame-pointer
168CFLAGS-execv.os = -fomit-frame-pointer
169CFLAGS-execle.os = -fomit-frame-pointer
170CFLAGS-execl.os = -fomit-frame-pointer
171CFLAGS-execvp.os = -fomit-frame-pointer
172CFLAGS-execlp.os = -fomit-frame-pointer
7a114794 173
e25054c4 174tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
b64cd08a 175 --none random --col --color --colour
0793d348 176
740b3dbe 177tst-exec-ARGS = -- $(host-test-program-cmd)
4cf8f209 178tst-exec-static-ARGS = $(tst-exec-ARGS)
740b3dbe 179tst-spawn-ARGS = -- $(host-test-program-cmd)
4cf8f209 180tst-spawn-static-ARGS = $(tst-spawn-ARGS)
53e5cdd8 181tst-dir-ARGS = `pwd` `cd $(common-objdir)/$(subdir); pwd` `cd $(common-objdir); pwd` $(objpfx)tst-dir
3aa65137 182tst-chmod-ARGS = $(objdir)
df859a0c 183tst-vfork3-ARGS = --test-dir=$(objpfx)
079199de 184
0d6af3a8 185tst-fnmatch-ENV = LOCPATH=$(common-objpfx)localedata
47b853e8 186tst-regexloc-ENV = LOCPATH=$(common-objpfx)localedata
5c0111e9 187bug-regex1-ENV = LOCPATH=$(common-objpfx)localedata
64333c66 188tst-regex-ENV = LOCPATH=$(common-objpfx)localedata
c06a6956 189tst-regex2-ENV = LOCPATH=$(common-objpfx)localedata
2f76d88d 190bug-regex5-ENV = LOCPATH=$(common-objpfx)localedata
81c64d40 191bug-regex6-ENV = LOCPATH=$(common-objpfx)localedata
74e12fbc
UD
192bug-regex17-ENV = LOCPATH=$(common-objpfx)localedata
193bug-regex18-ENV = LOCPATH=$(common-objpfx)localedata
3c0fb574 194bug-regex19-ENV = LOCPATH=$(common-objpfx)localedata
14744156 195bug-regex20-ENV = LOCPATH=$(common-objpfx)localedata
f39eef7b 196bug-regex22-ENV = LOCPATH=$(common-objpfx)localedata
6c2a04a7 197bug-regex23-ENV = LOCPATH=$(common-objpfx)localedata
33e63e79 198bug-regex25-ENV = LOCPATH=$(common-objpfx)localedata
ba40cc15 199bug-regex26-ENV = LOCPATH=$(common-objpfx)localedata
815d8147 200bug-regex30-ENV = LOCPATH=$(common-objpfx)localedata
b0727fd8 201bug-regex32-ENV = LOCPATH=$(common-objpfx)localedata
71b5d1c5 202bug-regex33-ENV = LOCPATH=$(common-objpfx)localedata
a445af0b 203bug-regex34-ENV = LOCPATH=$(common-objpfx)localedata
7e2f0d2d 204bug-regex35-ENV = LOCPATH=$(common-objpfx)localedata
c13c99fa 205tst-rxspencer-ARGS = --utf8 rxspencer/tests
7f98f180 206tst-rxspencer-no-utf8-ARGS = rxspencer/tests
c13c99fa 207tst-rxspencer-ENV = LOCPATH=$(common-objpfx)localedata
7f98f180 208tst-rxspencer-no-utf8-ENV = LOCPATH=$(common-objpfx)localedata
6c805a2b
UD
209tst-pcre-ARGS = PCRE.tests
210tst-boost-ARGS = BOOST.tests
0da4ee55 211bug-glob1-ARGS = "$(objpfx)"
506cbf1f 212tst-execvp3-ARGS = --test-dir=$(objpfx)
0d6af3a8 213
4cca6b86 214testcases.h: TESTS TESTS2C.sed
3e6bd4b1 215 LC_ALL=C sed -f TESTS2C.sed < $< > $@T
4cca6b86 216 mv -f $@T $@
92040cbc
UD
217
218ptestcases.h: PTESTS PTESTS2C.sed
3e6bd4b1 219 LC_ALL=C sed -f PTESTS2C.sed < $< > $@T
92040cbc 220 mv -f $@T $@
4959e310
UD
221
222# Run a test on the header files we use.
223# XXX Please note that for now we ignore the result of this test.
b647f210 224tests: $(objpfx)annexc.out
03ac099f 225ifeq ($(run-built-tests),yes)
ee70274a 226tests: $(objpfx)bug-regex2-mem $(objpfx)bug-regex14-mem \
7f98f180
JM
227 $(objpfx)bug-regex21-mem $(objpfx)bug-regex31-mem \
228 $(objpfx)tst-rxspencer-no-utf8-mem \
778cddad 229 $(objpfx)tst-pcre-mem $(objpfx)tst-boost-mem $(objpfx)tst-getconf.out \
3540d66b 230 $(objpfx)bug-glob2-mem $(objpfx)tst-vfork3-mem $(objpfx)tst-fnmatch-mem
5605e117 231xtests: $(objpfx)bug-ga2-mem
b647f210
AJ
232endif
233
3f36c563 234$(objpfx)annexc.out: $(objpfx)annexc
8eaaffde 235 -$(dir $<)$(notdir $<) '$(CC)' \
305bb37e 236 '$(patsubst %,-I../%,$(sorted-subdirs)) -I../include $(+sysdep-includes) $(sysincludes) -I..' > $@
4959e310 237
e69924e3 238annexc-CFLAGS = -O
4959e310
UD
239$(objpfx)annexc: annexc.c
240 $(native-compile)
770d454d 241
3540d66b
AS
242tst-fnmatch-ENV += MALLOC_TRACE=$(objpfx)tst-fnmatch.mtrace
243
244$(objpfx)tst-fnmatch-mem: $(objpfx)tst-fnmatch.out
245 $(common-objpfx)malloc/mtrace $(objpfx)tst-fnmatch.mtrace > $@
246
770d454d
UD
247bug-regex2-ENV = MALLOC_TRACE=$(objpfx)bug-regex2.mtrace
248
249$(objpfx)bug-regex2-mem: $(objpfx)bug-regex2.out
250 $(common-objpfx)malloc/mtrace $(objpfx)bug-regex2.mtrace > $@
a3bbce5b 251
240e87c2
RM
252bug-regex14-ENV = MALLOC_TRACE=$(objpfx)bug-regex14.mtrace
253
254$(objpfx)bug-regex14-mem: $(objpfx)bug-regex14.out
255 $(common-objpfx)malloc/mtrace $(objpfx)bug-regex14.mtrace > $@
256
ee70274a
UD
257bug-regex21-ENV = MALLOC_TRACE=$(objpfx)bug-regex21.mtrace
258
259$(objpfx)bug-regex21-mem: $(objpfx)bug-regex21.out
260 $(common-objpfx)malloc/mtrace $(objpfx)bug-regex21.mtrace > $@
261
ef06edbe
UD
262bug-regex31-ENV = MALLOC_TRACE=$(objpfx)bug-regex31.mtrace
263
264$(objpfx)bug-regex31-mem: $(objpfx)bug-regex31.out
265 $(common-objpfx)malloc/mtrace $(objpfx)bug-regex31.mtrace > $@
266
df859a0c
UD
267tst-vfork3-ENV = MALLOC_TRACE=$(objpfx)tst-vfork3.mtrace
268
269$(objpfx)tst-vfork3-mem: $(objpfx)tst-vfork3.out
270 $(common-objpfx)malloc/mtrace $(objpfx)tst-vfork3.mtrace > $@
271
7f98f180
JM
272# tst-rxspencer.mtrace is not generated, only
273# tst-rxspencer-no-utf8.mtrace, since otherwise the file has almost
274# 100M and takes very long time to process.
275tst-rxspencer-no-utf8-ENV += MALLOC_TRACE=$(objpfx)tst-rxspencer-no-utf8.mtrace
276$(objpfx)tst-rxspencer-no-utf8-mem: $(objpfx)tst-rxspencer-no-utf8.out
277 $(common-objpfx)malloc/mtrace $(objpfx)tst-rxspencer-no-utf8.mtrace > $@
ee70274a 278
6c805a2b
UD
279tst-pcre-ENV = MALLOC_TRACE=$(objpfx)tst-pcre.mtrace
280$(objpfx)tst-pcre-mem: $(objpfx)tst-pcre.out
281 $(common-objpfx)malloc/mtrace $(objpfx)tst-pcre.mtrace > $@
282
283tst-boost-ENV = MALLOC_TRACE=$(objpfx)tst-boost.mtrace
284$(objpfx)tst-boost-mem: $(objpfx)tst-boost.out
285 $(common-objpfx)malloc/mtrace $(objpfx)tst-boost.mtrace > $@
286
a3bbce5b 287$(objpfx)tst-getconf.out: tst-getconf.sh $(objpfx)getconf
135948bd 288 $(SHELL) $< $(common-objpfx) '$(built-program-cmd)'
64333c66 289
5605e117
UD
290$(objpfx)bug-ga2-mem: $(objpfx)bug-ga2.out
291 $(common-objpfx)malloc/mtrace $(objpfx)bug-ga2.mtrace > $@
292
293bug-ga2-ENV = MALLOC_TRACE=$(objpfx)bug-ga2.mtrace
778cddad
UD
294
295bug-glob2-ENV = MALLOC_TRACE=$(objpfx)bug-glob2.mtrace
296
297$(objpfx)bug-glob2-mem: $(objpfx)bug-glob2.out
298 $(common-objpfx)malloc/mtrace $(objpfx)bug-glob2.mtrace > $@
28f367c4 299
db502a60
RM
300$(inst_libexecdir)/getconf: $(inst_bindir)/getconf \
301 $(objpfx)getconf.speclist FORCE
28f367c4
UD
302 $(addprefix $(..)./scripts/mkinstalldirs ,\
303 $(filter-out $(wildcard $@),$@))
db502a60
RM
304 while read spec; do \
305 ln -f $< $@/$$spec.new || $(INSTALL_PROGRAM) $< $@/$$spec.new; \
306 mv -f $@/$$spec.new $@/$$spec; \
307 done < $(objpfx)getconf.speclist
308
531f1ae0
JM
309$(objpfx)getconf.speclist: getconf-speclist.c posix-envs.def
310 $(compile.c) -E -o - \
311 | sed -n -e '/@@@PRESENT_/s/@@@PRESENT_//p' > $@.new
d9967a8b 312 mv -f $@.new $@
ad98e30c
RM
313
314# This file is only actually needed at install time. But forcing it to
315# be built both makes it available for eyeball inspection and avoids the
316# surprise of things that look like compilation being done by 'make install'.
317others: $(objpfx)getconf.speclist