Update copyright notices with scripts/update-copyrights.
[jlayton/glibc.git] / debug / Makefile
1 # Copyright (C) 1998-2013 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, see
16 # <http://www.gnu.org/licenses/>.
17
18 #
19 #       Sub-makefile for debug portion of the library.
20 #
21 subdir  := debug
22
23 headers := execinfo.h
24
25 routines  = backtrace backtracesyms backtracesymsfd noophooks \
26             memcpy_chk memmove_chk mempcpy_chk memset_chk stpcpy_chk \
27             strcat_chk strcpy_chk strncat_chk strncpy_chk stpncpy_chk \
28             sprintf_chk vsprintf_chk snprintf_chk vsnprintf_chk \
29             printf_chk fprintf_chk vprintf_chk vfprintf_chk \
30             gets_chk chk_fail readonly-area fgets_chk fgets_u_chk \
31             read_chk pread_chk pread64_chk recv_chk recvfrom_chk \
32             readlink_chk readlinkat_chk getwd_chk getcwd_chk \
33             realpath_chk ptsname_r_chk fread_chk fread_u_chk \
34             wctomb_chk wcscpy_chk wmemcpy_chk wmemmove_chk wmempcpy_chk \
35             wcpcpy_chk wcsncpy_chk wcscat_chk wcsncat_chk wmemset_chk \
36             wcpncpy_chk \
37             swprintf_chk vswprintf_chk wprintf_chk fwprintf_chk \
38             vwprintf_chk vfwprintf_chk fgetws_chk fgetws_u_chk \
39             confstr_chk getgroups_chk ttyname_r_chk getlogin_r_chk \
40             gethostname_chk getdomainname_chk wcrtomb_chk mbsnrtowcs_chk \
41             wcsnrtombs_chk mbsrtowcs_chk wcsrtombs_chk mbstowcs_chk \
42             wcstombs_chk asprintf_chk vasprintf_chk dprintf_chk \
43             vdprintf_chk obprintf_chk \
44             longjmp_chk ____longjmp_chk \
45             fdelt_chk poll_chk ppoll_chk \
46             stack_chk_fail fortify_fail \
47             $(static-only-routines)
48 static-only-routines := warning-nop stack_chk_fail_local
49
50 CFLAGS-backtrace.c = -fno-omit-frame-pointer
51 CFLAGS-sprintf_chk.c = $(libio-mtsafe)
52 CFLAGS-snprintf_chk.c = $(libio-mtsafe)
53 CFLAGS-vsprintf_chk.c = $(libio-mtsafe)
54 CFLAGS-vsnprintf_chk.c = $(libio-mtsafe)
55 CFLAGS-asprintf_chk.c = $(libio-mtsafe)
56 CFLAGS-vasprintf_chk.c = $(libio-mtsafe)
57 CFLAGS-obprintf_chk.c = $(libio-mtsafe)
58 CFLAGS-dprintf_chk.c = $(libio-mtsafe) $(exceptions)
59 CFLAGS-vdprintf_chk.c = $(libio-mtsafe) $(exceptions)
60 CFLAGS-printf_chk.c = $(libio-mtsafe) $(exceptions)
61 CFLAGS-fprintf_chk.c = $(libio-mtsafe) $(exceptions)
62 CFLAGS-vprintf_chk.c = $(libio-mtsafe) $(exceptions)
63 CFLAGS-vfprintf_chk.c = $(libio-mtsafe) $(exceptions)
64 CFLAGS-gets_chk.c = $(libio-mtsafe) $(exceptions)
65 CFLAGS-fgets_chk.c = $(libio-mtsafe) $(exceptions)
66 CFLAGS-fgets_u_chk.c = $(libio-mtsafe) $(exceptions)
67 CFLAGS-fread_chk.c = $(libio-mtsafe) $(exceptions)
68 CFLAGS-fread_u_chk.c = $(libio-mtsafe) $(exceptions)
69 CFLAGS-swprintf_chk.c = $(libio-mtsafe)
70 CFLAGS-vswprintf_chk.c = $(libio-mtsafe)
71 CFLAGS-wprintf_chk.c = $(libio-mtsafe) $(exceptions)
72 CFLAGS-fwprintf_chk.c = $(libio-mtsafe) $(exceptions)
73 CFLAGS-vwprintf_chk.c = $(libio-mtsafe) $(exceptions)
74 CFLAGS-vfwprintf_chk.c = $(libio-mtsafe) $(exceptions)
75 CFLAGS-fgetws_chk.c = $(libio-mtsafe) $(exceptions)
76 CFLAGS-fgetws_u_chk.c = $(libio-mtsafe) $(exceptions)
77 CFLAGS-read_chk.c = -fexceptions -fasynchronous-unwind-tables
78 CFLAGS-pread_chk.c = -fexceptions -fasynchronous-unwind-tables
79 CFLAGS-pread64_chk.c = -fexceptions -fasynchronous-unwind-tables
80 CFLAGS-recv_chk.c = -fexceptions -fasynchronous-unwind-tables
81 CFLAGS-recvfrom_chk.c = -fexceptions -fasynchronous-unwind-tables
82
83 # Need to make sure the settings here override what configure might have
84 # set up for us, so keep the CFLAGS/CPPFLAGS split logical as the order is:
85 # <user CFLAGS> <test CFLAGS> <user CPPFLAGS> <test CPPFLAGS>
86 CFLAGS-tst-longjmp_chk.c = -fexceptions -fasynchronous-unwind-tables
87 CPPFLAGS-tst-longjmp_chk.c = -D_FORTIFY_SOURCE=1
88 CFLAGS-tst-longjmp_chk2.c = -fexceptions -fasynchronous-unwind-tables
89 CPPFLAGS-tst-longjmp_chk2.c = -D_FORTIFY_SOURCE=1
90
91 # We know these tests have problems with format strings, this is what
92 # we are testing.  Disable that warning.
93 CFLAGS-tst-chk1.c = -Wno-format
94 CFLAGS-tst-chk2.c = -Wno-format
95 CFLAGS-tst-chk3.c = -Wno-format
96 CFLAGS-tst-chk4.cc = -Wno-format
97 CFLAGS-tst-chk5.cc = -Wno-format
98 CFLAGS-tst-chk6.cc = -Wno-format
99 CFLAGS-tst-lfschk1.c = -Wno-format
100 CFLAGS-tst-lfschk2.c = -Wno-format
101 CFLAGS-tst-lfschk3.c = -Wno-format
102 CFLAGS-tst-lfschk4.cc = -Wno-format
103 CFLAGS-tst-lfschk5.cc = -Wno-format
104 CFLAGS-tst-lfschk6.cc = -Wno-format
105 tst-chk1-ENV = LOCPATH=$(common-objpfx)localedata
106 tst-chk2-ENV = LOCPATH=$(common-objpfx)localedata
107 tst-chk3-ENV = LOCPATH=$(common-objpfx)localedata
108 tst-chk4-ENV = LOCPATH=$(common-objpfx)localedata
109 tst-chk5-ENV = LOCPATH=$(common-objpfx)localedata
110 tst-chk6-ENV = LOCPATH=$(common-objpfx)localedata
111 tst-lfschk1-ENV = LOCPATH=$(common-objpfx)localedata
112 tst-lfschk2-ENV = LOCPATH=$(common-objpfx)localedata
113 tst-lfschk3-ENV = LOCPATH=$(common-objpfx)localedata
114 tst-lfschk4-ENV = LOCPATH=$(common-objpfx)localedata
115 tst-lfschk5-ENV = LOCPATH=$(common-objpfx)localedata
116 tst-lfschk6-ENV = LOCPATH=$(common-objpfx)localedata
117 LDLIBS-tst-chk4 = -lstdc++
118 LDLIBS-tst-chk5 = -lstdc++
119 LDLIBS-tst-chk6 = -lstdc++
120 LDLIBS-tst-lfschk4 = -lstdc++
121 LDLIBS-tst-lfschk5 = -lstdc++
122 LDLIBS-tst-lfschk6 = -lstdc++
123
124 tests = backtrace-tst tst-longjmp_chk tst-chk1 tst-chk2 tst-chk3 \
125         tst-lfschk1 tst-lfschk2 tst-lfschk3 test-strcpy_chk test-stpcpy_chk \
126         tst-chk4 tst-chk5 tst-chk6 tst-lfschk4 tst-lfschk5 tst-lfschk6 \
127         tst-longjmp_chk2
128
129 tests-ifunc := $(stpcpy_chk strcpy_chk:%=test-%-ifunc)
130 tests += $(tests-ifunc)
131
132 extra-libs = libSegFault libpcprofile
133 extra-libs-others = $(extra-libs)
134
135 libSegFault-routines = segfault
136 libSegFault-inhibit-o = $(filter-out .os,$(object-suffixes))
137
138 libpcprofile-routines = pcprofile
139 libpcprofile-inhibit-o = $(filter-out .os,$(object-suffixes))
140
141 others = pcprofiledump
142 install-bin = pcprofiledump
143 install-bin-script = xtrace
144
145 include ../Makeconfig
146
147 ifeq ($(build-shared),yes)
148 install-bin-script += catchsegv
149 endif
150 generated = catchsegv xtrace
151
152 include ../Rules
153
154 sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
155
156 $(objpfx)catchsegv: catchsegv.sh $(common-objpfx)soversions.mk \
157                     $(common-objpfx)config.make
158         slibpfx=`echo $(slibdir)|sed 's/lib\(64\|\)$$/\\\\\\\\$$LIB/'`; \
159         sed -e 's|@VERSION@|$(version)|' -e "s|@SLIB@|$$slibpfx|" \
160             -e 's|@PKGVERSION@|$(PKGVERSION)|' \
161             -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $< > $@.new
162         chmod 555 $@.new
163         mv -f $@.new $@
164
165 $(objpfx)pcprofiledump: $(objpfx)pcprofiledump.o
166
167 $(objpfx)xtrace: xtrace.sh
168         rm -f $@.new
169         sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
170             -e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' \
171             -e 's|@PKGVERSION@|$(PKGVERSION)|' \
172             -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
173         && rm -f $@ && mv $@.new $@ && chmod +x $@
174
175 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
176 # This ensures they will load libc.so for needed symbols if loaded by
177 # a statically-linked program that hasn't already loaded it.
178 $(objpfx)libSegFault.so: $(common-objpfx)libc.so \
179                          $(common-objpfx)libc_nonshared.a \
180                          $(elf-objpfx)$(rtld-installed-name)
181 $(objpfx)libpcprofile.so: $(common-objpfx)libc.so \
182                           $(common-objpfx)libc_nonshared.a \
183                           $(elf-objpfx)$(rtld-installed-name)