008154de9a3c626fadd132841dcc07502fd56969
[platform/upstream/glibc.git] / posix / Makefile
1 # Copyright (C) 1991-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
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
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.
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
12 # Lesser General Public License for more details.
13
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, write to the Free
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 # 02111-1307 USA.
18
19 #
20 #       Sub-makefile for POSIX portion of the library.
21 #
22 subdir  := posix
23
24 headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h          \
25            glob.h regex.h wordexp.h fnmatch.h bits/types.h getopt.h           \
26            bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h               \
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            \
29            bits/sched.h re_comp.h wait.h bits/environments.h cpio.h           \
30            sys/sysmacros.h spawn.h
31
32 distribute := confstr.h TESTS TESTS2C.sed testcases.h \
33               PTESTS PTESTS2C.sed ptestcases.h \
34               globtest.c globtest.sh wordexp-tst.sh annexc.c fnmatch_loop.c   \
35               spawn_int.h tst-getconf.sh regcomp.c regexec.c regex_internal.c \
36               regex_internal.h
37
38 routines :=                                                                   \
39         uname                                                                 \
40         times                                                                 \
41         wait waitpid wait3 wait4 waitid                                       \
42         alarm sleep pause nanosleep                                           \
43         fork vfork _exit                                                      \
44         execve fexecve execv execle execl execvp execlp                       \
45         getpid getppid                                                        \
46         getuid geteuid getgid getegid getgroups setuid setgid group_member    \
47         getpgid setpgid getpgrp bsd-getpgrp setpgrp getsid setsid             \
48         getlogin getlogin_r setlogin                                          \
49         pathconf sysconf fpathconf                                            \
50         glob glob64 fnmatch regex                                             \
51         confstr                                                               \
52         getopt getopt1 getopt_init                                            \
53         sched_setp sched_getp sched_sets sched_gets sched_yield sched_primax  \
54         sched_primin sched_rr_gi                                              \
55         getaddrinfo gai_strerror wordexp                                      \
56         pread pwrite pread64 pwrite64                                         \
57         spawn_faction_init spawn_faction_destroy spawn_faction_addclose       \
58         spawn_faction_addopen spawn_faction_adddup2                           \
59         spawnattr_init spawnattr_destroy                                      \
60         spawnattr_getdefault spawnattr_setdefault                             \
61         spawnattr_getflags spawnattr_setflags                                 \
62         spawnattr_getpgroup spawnattr_setpgroup spawn spawnp spawni           \
63         spawnattr_getsigmask spawnattr_getschedpolicy spawnattr_getschedparam \
64         spawnattr_setsigmask spawnattr_setschedpolicy spawnattr_setschedparam
65
66 include ../Makeconfig
67
68 aux             := init-posix environ
69 tests           := tstgetopt testfnm runtests runptests      \
70                    tst-preadwrite tst-preadwrite64 test-vfork regexbug1 \
71                    tst-getlogin tst-mmap tst-getaddrinfo tst-truncate \
72                    tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \
73                    tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
74                    tst-gnuglob tst-regex bug-regex5
75 ifeq (yes,$(build-shared))
76 test-srcs       := globtest
77 tests           += wordexp-test tst-exec tst-spawn
78 endif
79 others          := getconf
80 install-bin     := getconf
81 gpl2lgpl := getopt.c getopt1.c getopt.h regex.c regex.h
82
83 before-compile  := testcases.h ptestcases.h
84
85 # So they get cleaned up.
86 generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) \
87              annexc annexc.out wordexp-tst.out bug-regex2-mem \
88              bug-regex2.mtrace tst-getconf.out
89
90 include ../Rules
91
92 ifeq (yes,$(build-static-nss))
93 # We need it for "make check" only. We can skip them if they haven't
94 # been built yet during "make".
95 otherlibs += $(wildcard $(nssobjdir)/libnss_files.a \
96                         $(resolvobjdir)/libnss_dns.a \
97                         $(resolvobjdir)/libresolv.a)
98 endif
99
100 ifeq (no,$(cross-compiling))
101 # globtest and wordexp-test currently only works with shared libraries
102 ifeq (yes,$(build-shared))
103 tests: $(objpfx)globtest.out $(objpfx)wordexp-tst.out
104 $(objpfx)globtest.out: globtest.sh $(objpfx)globtest
105         $(SHELL) -e globtest.sh $(common-objpfx) $(elf-objpfx) \
106                  $(rtld-installed-name)
107 $(objpfx)wordexp-tst.out: wordexp-tst.sh $(objpfx)wordexp-test
108         $(SHELL) -e wordexp-tst.sh $(common-objpfx) $(elf-objpfx) \
109                  $(rtld-installed-name)
110 endif
111 endif
112
113 CFLAGS-regex.c = -Wno-strict-prototypes -DRE_ENABLE_I18N
114 CFLAGS-getaddrinfo.c = -DRESOLVER
115 tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
116                 --none random --col --color --colour
117
118 tst-exec-ARGS = -- $(built-program-cmd)
119 tst-spawn-ARGS = -- $(built-program-cmd)
120 tst-dir-ARGS = `pwd` `cd $(common-objdir)/$(subdir); pwd` `cd $(common-objdir); pwd` $(objpfx)tst-dir
121 tst-chmod-ARGS = `pwd`
122
123 tst-fnmatch-ENV = LOCPATH=$(common-objpfx)localedata
124 tst-regexloc-ENV = LOCPATH=$(common-objpfx)localedata
125 bug-regex1-ENV = LOCPATH=$(common-objpfx)localedata
126 tst-regex-ENV = LOCPATH=$(common-objpfx)localedata
127 bug-regex5-ENV = LOCPATH=$(common-objpfx)localedata
128
129 testcases.h: TESTS TESTS2C.sed
130         sed -f TESTS2C.sed < $< > $@T
131         mv -f $@T $@
132 ifeq ($(with-cvs),yes)
133         test ! -d CVS || cvs $(CVSOPTS) commit -mRegenerated $@
134 endif
135
136 ptestcases.h: PTESTS PTESTS2C.sed
137         sed -f PTESTS2C.sed < $< > $@T
138         mv -f $@T $@
139 ifeq ($(with-cvs),yes)
140         test ! -d CVS || cvs $(CVSOPTS) commit -mRegenerated $@
141 endif
142
143 # Run a test on the header files we use.
144 # XXX Please note that for now we ignore the result of this test.
145 tests: $(objpfx)annexc.out
146 ifeq (no,$(cross-compiling))
147 tests:$(objpfx)bug-regex2-mem $(objpfx)tst-getconf.out
148 endif
149
150 $(objpfx)annexc.out: $(objpfx)annexc
151         -$(dir $<)$(notdir $<) '$(CC)' \
152                                '-I../include -I.. $(+sysdep-includes) $(sysincludes)' > $@
153
154 annexc-CFLAGS = -O
155 $(objpfx)annexc: annexc.c
156         $(native-compile)
157
158 bug-regex2-ENV = MALLOC_TRACE=$(objpfx)bug-regex2.mtrace
159
160 $(objpfx)bug-regex2-mem: $(objpfx)bug-regex2.out
161         $(common-objpfx)malloc/mtrace $(objpfx)bug-regex2.mtrace > $@
162
163 $(objpfx)tst-getconf.out: tst-getconf.sh $(objpfx)getconf
164         $(SHELL) -e $< $(common-objpfx) $(elf-objpfx) $(rtld-installed-name)
165
166 ifeq (yes,$(build-shared))
167 $(objpfx)tst-regex: $(common-objpfx)rt/librt.so
168 else
169 $(objpfx)tst-regex: $(common-objpfx)rt/librt.a
170 endif