]> sourceware.org Git - glibc.git/blame - csu/Makefile
Always check dtv before freeing dtv[-1]
[glibc.git] / csu / Makefile
CommitLineData
28f540f4 1# Makefile for csu code for GNU C library.
0269750c 2# Copyright (C) 1995-2006, 2010, 2012 Free Software Foundation, Inc.
28f540f4
RM
3# This file is part of the GNU C Library.
4
5# The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
28f540f4
RM
9
10# The GNU C Library is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
41bdb6e2
AJ
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
28f540f4 14
41bdb6e2 15# You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16# License along with the GNU C Library; if not, see
17# <http://www.gnu.org/licenses/>.
28f540f4
RM
18
19# This directory contains the C startup code (that which calls main). This
20# consists of the startfile, built from start.c and installed as crt0.o
0f9cc699 21# (traditionally) or crt1.o (for ELF). In ELF we also install crti.o and
b5ca0fb0 22# crtn.o, special "initializer" and "finalizer" files used in the link
0e7dfaef 23# to make the .init and .fini sections work right.
28f540f4
RM
24
25subdir := csu
26
8a30f00f 27routines = init-first libc-start $(libc-init) sysdep version check_fds \
ee2a5ae8 28 libc-tls elf-init dso_handle
ce460d04 29aux = errno
2a76f7ef 30elide-routines.os = libc-tls
06b31ad3 31static-only-routines = elf-init
b6da933b 32csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
11c981a9 33extra-objs = start.o gmon-start.o \
b6da933b
UD
34 $(start-installed-name) g$(start-installed-name) $(csu-dummies) \
35 S$(start-installed-name)
11c981a9 36omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
bc4647a1
UD
37 b$(start-installed-name) $(csu-dummies) \
38 S$(start-installed-name))
98186375 39install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies)
c7562c74
UD
40generated = version-info.h
41before-compile = $(objpfx)version-info.h
28f540f4 42
78c9da10
RM
43tests := tst-empty tst-atomic tst-atomic-long
44tests-static := tst-empty
d15851ec 45
28f540f4
RM
46all: # Make this the default target; it will be defined in Rules.
47
48include ../Makeconfig
49
bc4647a1
UD
50ifeq (yes,$(build-shared))
51extra-objs += S$(start-installed-name)
52install-lib += S$(start-installed-name)
95fa8590 53generated += start.os
bc4647a1
UD
54endif
55
ac556388
GM
56ifeq (yes,$(build-bounded))
57extra-objs += b$(start-installed-name)
58install-lib += b$(start-installed-name)
95fa8590 59generated += start.ob
ac556388
GM
60endif
61
083973f3
RM
62ifneq ($(start-installed-name),$(static-start-installed-name))
63extra-objs += $(static-start-installed-name) g$(static-start-installed-name)
64omit-deps += $(patsubst %.o,%,$(static-start-installed-name) \
65 g$(static-start-installed-name))
66install-lib += $(static-start-installed-name) g$(static-start-installed-name)
67endif
68
c7562c74 69before-compile += $(objpfx)abi-tag.h
da2d1bc5 70generated += abi-tag.h
b8dc6a10 71
37f91d33 72# These are the special initializer/finalizer files. They are always the
4e1bac76
RM
73# first and last file in the link. crti.o ... crtn.o define the global
74# "functions" _init and _fini to run the .init and .fini sections.
75crtstuff = crti crtn
37f91d33
RM
76
77install-lib += $(crtstuff:=.o)
78extra-objs += $(crtstuff:=.o)
3add8e13 79
6973fc01 80extra-objs += abi-note.o init.o
92f1da4d 81asm-CPPFLAGS += -I$(objpfx).
51702635 82
28f540f4
RM
83include ../Rules
84
71cf0361
UD
85# Make these in the lib pass so they're available in time to link things with.
86subdir_lib: $(extra-objs:%=$(objpfx)%)
87
779ae82e
UD
88define link-relocatable
89$(CC) -nostdlib -nostartfiles -r -o $@ $^
90endef
91
b8dc6a10 92ifndef start-installed-name-rule
779ae82e 93# We link the ELF startfile along with a SHT_NOTE section indicating
3081378b 94# the kernel ABI the binaries linked with this library will require.
6973fc01
UD
95$(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
96 $(objpfx)init.o
779ae82e 97 $(link-relocatable)
bc4647a1
UD
98$(objpfx)S$(start-installed-name): $(objpfx)start.os $(objpfx)abi-note.o \
99 $(objpfx)init.o
100 $(link-relocatable)
58ff985d
GM
101$(objpfx)b$(start-installed-name): $(objpfx)start.ob $(objpfx)abi-note.ob \
102 $(objpfx)init.ob
103 $(link-relocatable)
779ae82e 104endif
28f540f4 105
11c981a9
RM
106# The profiling startfile is made by linking together the normal
107# startfile with gmon-start.o, which defines a constructor function
108# to turn on profiling code at startup.
083973f3
RM
109$(addprefix $(objpfx),$(sort g$(start-installed-name) \
110 g$(static-start-installed-name))): \
111 $(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o
779ae82e 112 $(link-relocatable)
11c981a9 113
28f540f4
RM
114# These extra files are sometimes expected by system standard linking
115# procedures, but we have nothing for them to do. So compile empty files.
b6da933b 116$(addprefix $(objpfx),$(filter-out $(start-installed-name), $(csu-dummies))):\
c6696b79
RM
117 $(before-compile)
118 $(COMPILE.c) -o $@ -x c /dev/null
92f1da4d 119
c7562c74 120# These headers are used by the startup code.
92f1da4d 121$(objpfx)abi-tag.h: $(..)abi-tags
39e16978 122 $(make-target-directory)
92f1da4d 123 rm -f $@.new
0f9cc699 124 sed -e 's/#.*$$//' -e '/^[ ]*$$/d' $< | \
a986484f 125 while read conf tagos tagver; do \
92f1da4d
UD
126 test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
127 : "$$conf"` != 0 || continue; \
a986484f
UD
128 ( echo "$$tagos" | \
129 sed -e 's/[^0-9xXa-fA-F ]//' \
130 -e 's/^/#define __ABI_TAG_OS /'; \
131 echo "#ifndef __ABI_TAG_VERSION"; \
132 echo "$$tagver" | \
133 sed -e 's/[^0-9xXa-fA-F]/ /g' -e 's/ *$$//' \
134 -e 's/ /,/g' -e 's/^/# define __ABI_TAG_VERSION /'; \
135 echo "#endif" ) > $@.new; \
92f1da4d
UD
136 done
137 if test -r $@.new; then mv -f $@.new $@; \
138 else echo >&2 'This configuration not matched in $<'; exit 1; fi
c7562c74 139
04dca8d3
RM
140all-Banner-files = $(wildcard $(addsuffix /Banner,\
141 $(sort $(subdir-srcdirs) \
142 $(sysdeps-srcdirs))))
c7562c74
UD
143$(objpfx)version-info.h: $(common-objpfx)config.make $(all-Banner-files)
144 $(make-target-directory)
145 (case $(config-os) in \
e7f4d2bf
RM
146 linux*) version=`(printf '%s\n%s\n' \
147 '#include <linux/version.h>' \
148 UTS_RELEASE \
9e37946d 149 | $(CC) $(CPPFLAGS) -O -E -P - -DNOT_IN_libc=1 | \
c7562c74 150 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
9e37946d
UD
151 if [ -z "$$version" ]; then \
152 version=`(printf '%s\n%s\n' \
153 '#include <linux/version.h>' \
154 LINUX_VERSION_CODE \
155 | $(CC) $(CPPFLAGS) -O -E -P - -DNOT_IN_libc=1 \
156 | sed -n -e '/^[123456789].*/p' \
157 | awk '{v=$$1; \
158 printf("%d.%d.%d\n", \
159 v/65535, v/256%256, v%256)}') \
160 2>/dev/null`; \
161 fi; \
c7562c74
UD
162 if [ -z "$$version" ]; then \
163 if [ -r /proc/version ]; then \
b48abe3c 164 version=`sed 's/.*Linux version \([^ ]*\) .*/>>\1<</' \
c7562c74
UD
165 < /proc/version`; \
166 else \
167 version=`uname -r`; \
168 fi; \
169 fi; \
c269fdb4
UD
170 os=`uname -s 2> /dev/null`; \
171 if [ -z "$$os" ]; then \
172 os=Linux; \
173 fi; \
e7f4d2bf
RM
174 printf '"Compiled on a %s %s system on %s.\\n"\n' \
175 "$$os" "$$version" "`date +%Y-%m-%d`";; \
c7562c74
UD
176 *) ;; \
177 esac; \
178 files="$(all-Banner-files)"; \
179 if test -n "$$files"; then \
9db670f0 180 printf '"Available extensions:\\n"\n'; \
0f9cc699 181 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' \
63461e75 182 -e 's/^\(.*\)$$/\"\1\\n\"/' $$files; \
c7562c74
UD
183 fi) > $@T
184 mv -f $@T $@
This page took 0.336595 seconds and 5 git commands to generate.