source: branches/libc-0.6/src/libctests/glibc/csu/Makefile

Last change on this file was 2036, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1# Makefile for csu code for GNU C library.
2# Copyright (C) 1995-2004, 2005 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
27subdir := csu
28
29routines = init-first libc-start $(libc-init) sysdep version check_fds \
30 libc-tls elf-init dso_handle
31aux = errno
32elide-routines.os = libc-tls
33static-only-routines = elf-init
34csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
35extra-objs = start.o gmon-start.o \
36 $(start-installed-name) g$(start-installed-name) $(csu-dummies) \
37 S$(start-installed-name)
38omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
39 b$(start-installed-name) $(csu-dummies) \
40 S$(start-installed-name))
41install-lib = $(start-installed-name) g$(start-installed-name) $(csu-dummies)
42distribute = initfini.c gmon-start.c start.c defs.awk munch.awk \
43 abi-note.S init.c munch-tmpl.c not-cancel.h
44generated = version-info.h
45before-compile = $(objpfx)version-info.h
46
47tests := tst-empty tst-atomic tst-atomic-long
48tests-static := tst-empty
49
50all: # Make this the default target; it will be defined in Rules.
51
52include ../Makeconfig
53
54ifeq (yes,$(build-shared))
55extra-objs += S$(start-installed-name)
56install-lib += S$(start-installed-name)
57generated += start.os
58endif
59
60ifeq (yes,$(build-bounded))
61extra-objs += b$(start-installed-name)
62install-lib += b$(start-installed-name)
63generated += start.ob
64endif
65
66ifneq ($(start-installed-name),$(static-start-installed-name))
67extra-objs += $(static-start-installed-name) g$(static-start-installed-name)
68omit-deps += $(patsubst %.o,%,$(static-start-installed-name) \
69 g$(static-start-installed-name))
70install-lib += $(static-start-installed-name) g$(static-start-installed-name)
71endif
72
73ifeq (yes,$(elf))
74before-compile += $(objpfx)abi-tag.h
75generated += abi-tag.h
76endif
77
78ifneq (yes,$(gnu-ld))
79libc-init = munch-init
80$(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
81 $(AWK) -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
82 mv -f $@-t $@
83generated += munch-init.c
84
85# All initialization source files.
86+subdir_inits := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
87# All subdirectories containing initialization source files.
88+init_subdirs := $(patsubst %/,%,$(dir $(+subdir_inits)))
89endif
90
91ifeq ($(have-initfini),yes)
92
93CPPFLAGS += -DHAVE_INITFINI
94
95# These are the special initializer/finalizer files. They are always the
96# first and last file in the link. crti.o ... crtn.o define the global
97# "functions" _init and _fini to run the .init and .fini sections.
98crtstuff = crti crtn
99
100install-lib += $(crtstuff:=.o)
101extra-objs += $(crtstuff:=.o)
102generated += $(crtstuff:=.S) initfini.s defs.h
103omit-deps += $(crtstuff)
104
105# Special rules for the building of crti.o and crtn.o
106$(crtstuff:%=$(objpfx)%.o): %.o: %.S $(objpfx)defs.h
107 $(compile.S) -g0 $(ASFLAGS-.os) -o $@
108
109CFLAGS-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
110
111vpath initfini.c $(full_config_sysdirs)
112
113$(objpfx)initfini.s: initfini.c $(before-compile)
114 $(compile.c) -S $(CFLAGS-initfini.s) -finhibit-size-directive \
115 $(patsubst -f%,-fno-%,$(exceptions)) -o $@
116
117# We only have one kind of startup code files. Static binaries and
118# shared libraries are build using the PIC version.
119$(objpfx)crti.S: $(objpfx)initfini.s
120 sed -n -e '1,/@HEADER_ENDS/p' \
121 -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
122 -e '/@TRAILER_BEGINS/,$$p' $< > $@
123
124$(objpfx)crtn.S: $(objpfx)initfini.s
125 sed -n -e '1,/@HEADER_ENDS/p' \
126 -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
127 -e '/@TRAILER_BEGINS/,$$p' $< > $@
128
129# These explicit rules are necessary when the $(objpfx) subdirectory
130# did not exist at the time make considered the implicit rules using it.
131# This comes up with a fresh build using no_deps=t.
132$(patsubst %,$(objpfx)crt%.o,i n): %.o: %.S
133
134$(objpfx)defs.h: $(objpfx)initfini.s
135 sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
136 $(AWK) -f defs.awk > $@
137
138endif
139
140ifeq (yes,$(elf))
141extra-objs += abi-note.o init.o
142asm-CPPFLAGS += -I$(objpfx).
143endif
144
145include ../Rules
146
147# Make these in the lib pass so they're available in time to link things with.
148subdir_lib: $(extra-objs:%=$(objpfx)%)
149
150define link-relocatable
151$(CC) -nostdlib -nostartfiles -r -o $@ $^
152endef
153
154ifndef start-installed-name-rule
155ifeq (yes,$(elf))
156# We link the ELF startfile along with a SHT_NOTE section indicating
157# the kernel ABI the binaries linked with this library will require.
158$(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \
159 $(objpfx)init.o
160 $(link-relocatable)
161$(objpfx)S$(start-installed-name): $(objpfx)start.os $(objpfx)abi-note.o \
162 $(objpfx)init.o
163 $(link-relocatable)
164$(objpfx)b$(start-installed-name): $(objpfx)start.ob $(objpfx)abi-note.ob \
165 $(objpfx)init.ob
166 $(link-relocatable)
167else
168# The startfile is installed under different names, so we just call our
169# source file `start.c' and copy to the installed name after compiling.
170$(objpfx)$(start-installed-name): $(objpfx)start.o
171 rm -f $@
172 ln $< $@
173$(objpfx)S$(start-installed-name): $(objpfx)start.os
174 rm -f $@
175 ln $< $@
176$(objpfx)b$(start-installed-name): $(objpfx)start.ob
177 rm -f $@
178 ln $< $@
179endif
180endif
181
182# The profiling startfile is made by linking together the normal
183# startfile with gmon-start.o, which defines a constructor function
184# to turn on profiling code at startup.
185$(addprefix $(objpfx),$(sort g$(start-installed-name) \
186 g$(static-start-installed-name))): \
187 $(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o
188 $(link-relocatable)
189
190# These extra files are sometimes expected by system standard linking
191# procedures, but we have nothing for them to do. So compile empty files.
192$(addprefix $(objpfx),$(filter-out $(start-installed-name), $(csu-dummies))):\
193 $(before-compile)
194 $(COMPILE.c) -o $@ -x c /dev/null
195
196# These headers are used by the startup code.
197$(objpfx)abi-tag.h: $(..)abi-tags
198 $(make-target-directory)
199 rm -f $@.new
200 sed -e 's/#.*$$//' -e '/^[ ]*$$/d' $< | \
201 while read conf tagos tagver; do \
202 test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
203 : "$$conf"` != 0 || continue; \
204 ( echo "$$tagos" | \
205 sed -e 's/[^0-9xXa-fA-F ]//' \
206 -e 's/^/#define __ABI_TAG_OS /'; \
207 echo "#ifndef __ABI_TAG_VERSION"; \
208 echo "$$tagver" | \
209 sed -e 's/[^0-9xXa-fA-F]/ /g' -e 's/ *$$//' \
210 -e 's/ /,/g' -e 's/^/# define __ABI_TAG_VERSION /'; \
211 echo "#endif" ) > $@.new; \
212 done
213 if test -r $@.new; then mv -f $@.new $@; \
214 else echo >&2 'This configuration not matched in $<'; exit 1; fi
215
216all-Banner-files = $(wildcard $(addsuffix /Banner, \
217 $(addprefix $(..), $(subdirs))))
218$(objpfx)version-info.h: $(common-objpfx)config.make $(all-Banner-files)
219 $(make-target-directory)
220 (case $(config-os) in \
221 linux*) version=`(printf '%s\n%s\n' \
222 '#include <linux/version.h>' \
223 UTS_RELEASE \
224 | $(CC) $(CPPFLAGS) -E -P - -DNOT_IN_libc=1 | \
225 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
226 if [ -z "$$version" ]; then \
227 if [ -r /proc/version ]; then \
228 version=`sed 's/.*Linux version \([^ ]*\) .*/>>\1<</' \
229 < /proc/version`; \
230 else \
231 version=`uname -r`; \
232 fi; \
233 fi; \
234 os=`uname -s 2> /dev/null`; \
235 if [ -z "$$os" ]; then \
236 os=Linux; \
237 fi; \
238 printf '"Compiled on a %s %s system on %s.\\n"\n' \
239 "$$os" "$$version" "`date +%Y-%m-%d`";; \
240 *) ;; \
241 esac; \
242 files="$(all-Banner-files)"; \
243 if test -n "$$files"; then \
244 printf '"Available extensions:\\n"\n'; \
245 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' \
246 -e 's/^\(.*\)$$/\"\1\\n\"/' $$files; \
247 fi) > $@T
248 mv -f $@T $@
Note: See TracBrowser for help on using the repository browser.