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