]> sourceware.org Git - glibc.git/blob - csu/Makefile
Use 64-bit loading.
[glibc.git] / csu / Makefile
1 # Makefile for csu code for GNU C library.
2 # Copyright (C) 1995,96,97,98,99,2000,01,2002 Free Software Foundation, Inc.
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
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.
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
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
14
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
19
20 # This directory contains the C startup code (that which calls main). This
21 # consists of the startfile, built from start.c and installed as crt0.o
22 # (traditionally) or crt1.o (for ELF). In ELF we also install crti.o and
23 # crtn.o, special "initializer" and "finalizer" files used in the link
24 # to make the .init and .fini sections work right; both these files are
25 # built (in an arcane manner) from initfini.c.
26
27 subdir := csu
28
29 routines = init-first libc-start $(libc-init) sysdep version check_fds \
30 libc-tls elf-init dso_handle
31 aux = errno
32 elide-routines.os = libc-tls
33 static-only-routines = elf-init
34 csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
35 extra-objs = start.o gmon-start.o \
36 $(start-installed-name) g$(start-installed-name) $(csu-dummies)
37 omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
38 b$(start-installed-name) $(csu-dummies))
39 install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies)
40 distribute = initfini.c gmon-start.c start.c defs.awk munch.awk \
41 abi-note.S init.c munch-tmpl.c
42 generated = version-info.h
43 before-compile = $(objpfx)version-info.h
44
45 all: # Make this the default target; it will be defined in Rules.
46
47 include ../Makeconfig
48
49 ifeq (yes,$(build-bounded))
50 extra-objs += b$(start-installed-name)
51 install-lib += b$(start-installed-name)
52 endif
53
54 ifneq ($(start-installed-name),$(static-start-installed-name))
55 extra-objs += $(static-start-installed-name) g$(static-start-installed-name)
56 omit-deps += $(patsubst %.o,%,$(static-start-installed-name) \
57 g$(static-start-installed-name))
58 install-lib += $(static-start-installed-name) g$(static-start-installed-name)
59 endif
60
61 ifeq (yes,$(elf))
62 before-compile += $(objpfx)abi-tag.h
63 generated += abi-tag.h
64 endif
65
66 ifneq (yes,$(gnu-ld))
67 libc-init = munch-init
68 $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
69 $(AWK) -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
70 mv -f $@-t $@
71 generated += munch-init.c
72
73 # All initialization source files.
74 +subdir_inits := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
75 # All subdirectories containing initialization source files.
76 +init_subdirs := $(patsubst %/,%,$(dir $(+subdir_inits)))
77 endif
78
79 ifeq ($(have-initfini),yes)
80
81 CPPFLAGS += -DHAVE_INITFINI
82
83 # We don't want this compiled with PIC.
84 # It's never included in shared libraries, unlike the rest of libc_nonshared.a.
85 CPPFLAGS-elf-init.oS = $(patsubst %,-UPIC,$(pic-ccflag))
86 CFLAGS-elf-init.oS = $(patsubst -f%,-fno-%,$(pic-ccflag))
87
88 # These are the special initializer/finalizer files. They are always the
89 # first and last file in the link. crti.o ... crtn.o define the global
90 # "functions" _init and _fini to run the .init and .fini sections.
91 crtstuff = crti crtn
92
93 install-lib += $(crtstuff:=.o)
94 extra-objs += $(crtstuff:=.o)
95 generated += $(crtstuff:=.S) initfini.s defs.h
96 omit-deps += $(crtstuff)
97
98 # Special rules for the building of crti.o and crtn.o
99 $(objpfx)crt%.o: $(objpfx)crt%.S $(objpfx)defs.h
100 $(compile.S) -g0 $(ASFLAGS-.os) -o $@
101
102 CFLAGS-initfini.s = -g0 -fPIC -fno-inline-functions
103
104 vpath initfini.c $(full_config_sysdirs)
105
106 $(objpfx)initfini.s: initfini.c
107 $(compile.c) -S $(CFLAGS-initfini.s) -finhibit-size-directive \
108 $(patsubst -f%,-fno-%,$(exceptions)) -o $@
109
110 # We only have one kind of startup code files. Static binaries and
111 # shared libraries are build using the PIC version.
112 $(objpfx)crti.S: $(objpfx)initfini.s
113 sed -n -e '1,/@HEADER_ENDS/p' \
114 -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
115 -e '/@TRAILER_BEGINS/,$$p' $< > $@
116
117 $(objpfx)crtn.S: $(objpfx)initfini.s
118 sed -n -e '1,/@HEADER_ENDS/p' \
119 -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
120 -e '/@TRAILER_BEGINS/,$$p' $< > $@
121
122 # These explicit rules are necessary when the $(objpfx) subdirectory
123 # did not exist at the time make considered the implicit rules using it.
124 # This comes up with a fresh build using no_deps=t.
125 $(patsubst %,$(objpfx)crt%.o,i n): %.o: %.S
126
127 $(objpfx)defs.h: $(objpfx)initfini.s
128 sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
129 $(AWK) -f defs.awk > $@
130
131 endif
132
133 ifeq (yes,$(elf))
134 extra-objs += abi-note.o init.o
135 asm-CPPFLAGS += -I$(objpfx).
136 endif
137
138 include ../Rules
139
140 # Make these in the lib pass so they're available in time to link things with.
141 subdir_lib: $(extra-objs:%=$(objpfx)%)
142
143 define link-relocatable
144 $(CC) -nostdlib -nostartfiles -r -o $@ $^
145 endef
146
147 ifndef start-installed-name-rule
148 ifeq (yes,$(elf))
149 # We link the ELF startfile along with a SHT_NOTE section indicating
150 # the kernel ABI the binaries linked with this library will require.
151 $(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
152 $(objpfx)init.o
153 $(link-relocatable)
154 $(objpfx)b$(start-installed-name): $(objpfx)start.ob $(objpfx)abi-note.ob \
155 $(objpfx)init.ob
156 $(link-relocatable)
157 else
158 # The startfile is installed under different names, so we just call our
159 # source file `start.c' and copy to the installed name after compiling.
160 $(objpfx)$(start-installed-name): $(objpfx)start.o
161 rm -f $@
162 ln $< $@
163 $(objpfx)b$(start-installed-name): $(objpfx)start.ob
164 rm -f $@
165 ln $< $@
166 endif
167 endif
168
169 # The profiling startfile is made by linking together the normal
170 # startfile with gmon-start.o, which defines a constructor function
171 # to turn on profiling code at startup.
172 $(addprefix $(objpfx),$(sort g$(start-installed-name) \
173 g$(static-start-installed-name))): \
174 $(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o
175 $(link-relocatable)
176
177 # These extra files are sometimes expected by system standard linking
178 # procedures, but we have nothing for them to do. So compile empty files.
179 $(addprefix $(objpfx),$(filter-out $(start-installed-name),$(csu-dummies))):
180 @-rm -f $(@:.o=.c)
181 echo > $(@:.o=.c)
182 $(COMPILE.c) $(@:.o=.c) $(OUTPUT_OPTION)
183 rm -f $(@:.o=.c)
184
185 # These headers are used by the startup code.
186 $(objpfx)abi-tag.h: $(..)abi-tags
187 $(make-target-directory)
188 rm -f $@.new
189 sed -e 's/#.*$$//' -e '/^[ ]*$$/d' $< | \
190 while read conf tagos tagver; do \
191 test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
192 : "$$conf"` != 0 || continue; \
193 ( echo "$$tagos" | \
194 sed -e 's/[^0-9xXa-fA-F ]//' \
195 -e 's/^/#define __ABI_TAG_OS /'; \
196 echo "#ifndef __ABI_TAG_VERSION"; \
197 echo "$$tagver" | \
198 sed -e 's/[^0-9xXa-fA-F]/ /g' -e 's/ *$$//' \
199 -e 's/ /,/g' -e 's/^/# define __ABI_TAG_VERSION /'; \
200 echo "#endif" ) > $@.new; \
201 done
202 if test -r $@.new; then mv -f $@.new $@; \
203 else echo >&2 'This configuration not matched in $<'; exit 1; fi
204
205 all-Banner-files = $(wildcard $(addsuffix /Banner, \
206 $(addprefix $(..), $(subdirs))))
207 $(objpfx)version-info.h: $(common-objpfx)config.make $(all-Banner-files)
208 $(make-target-directory)
209 (case $(config-os) in \
210 linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
211 | $(CC) -E -P - | \
212 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
213 if [ -z "$$version" ]; then \
214 if [ -r /proc/version ]; then \
215 version=`sed 's/.*Linux version \([^ ]*\) .*/>>\1<</' \
216 < /proc/version`; \
217 else \
218 version=`uname -r`; \
219 fi; \
220 fi; \
221 os=`uname -s 2> /dev/null`; \
222 if [ -z "$$os" ]; then \
223 os=Linux; \
224 fi; \
225 echo "\"Compiled on a $$os $$version system" \
226 "on `date +%Y-%m-%d`.\\n\"" ;; \
227 *) ;; \
228 esac; \
229 files="$(all-Banner-files)"; \
230 if test -n "$$files"; then \
231 echo "\"Available extensions:\\n\""; \
232 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' \
233 -e 's/\(^.*$$\)/\"\1\\n\"/' $$files; \
234 fi) > $@T
235 mv -f $@T $@
This page took 0.042972 seconds and 5 git commands to generate.