]> sourceware.org Git - glibc.git/blob - csu/Makefile
Update from main archive 961219
[glibc.git] / csu / Makefile
1 # Makefile for csu code for GNU C library.
2
3 # Copyright (C) 1995, 1996 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
5
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Library General Public License
8 # as published by the Free Software Foundation; either version 2 of
9 # the License, or (at your option) any later version.
10
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Library General Public License for more details.
15
16 # You should have received a copy of the GNU Library General Public
17 # License along with the GNU C Library; see the file COPYING.LIB. If not,
18 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
20
21 # This directory contains the C startup code (that which calls main). This
22 # consists of the startfile, built from start.c and installed as crt0.o
23 # (traditionally) or crt1.o (for ELF). In ELF we also install crti.o and
24 # crtn.o, special "initializer" and "finalizer" files in used in the link
25 # to make the .init and .fini sections work right; both these files are
26 # built (in an arcane manner) from initfini.c.
27
28 subdir := csu
29
30 routines = init-first
31 csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
32 extra-objs = start.o gmon-start.o \
33 $(start-installed-name) g$(start-installed-name) \
34 $(csu-dummies)
35 omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
36 $(csu-dummies))
37 install-lib = $(start-installed-name) g$(start-installed-name) \
38 $(csu-dummies)
39 distribute = initfini.c gmon-start.c start.c
40
41 all: # Make this the default target; it will be defined in Rules.
42
43 include ../Makeconfig
44
45 ifneq ($(elf),yes)
46
47 # When not using ELF, there is just one startfile, called crt0.o.
48 start-installed-name = crt0.o
49
50 else
51
52 # In the ELF universe, crt0.o is called crt1.o, and there are
53 # some additional bizarre files.
54 start-installed-name = crt1.o
55 have-initfini = yes
56
57 endif
58
59 ifeq (yes,$(have-initfini))
60
61 CPPFLAGS += -DHAVE_INITFINI
62
63 # These are the special initializer/finalizer files. They are always the
64 # first and last file in the link. crti.o ... crtn.o define the global
65 # "functions" _init and _fini to run the .init and .fini sections.
66 crtstuff = crti crtn
67
68 install-lib += $(crtstuff:=.o)
69 extra-objs += $(crtstuff:=.o)
70 generated += $(crtstuff:=.s)
71 omit-deps += $(crtstuff)
72
73 # Compile initfini.c to assembly code, which contains embedded shell
74 # commands that produce crti.s-new and crtn.s-new when run. We need to
75 # disable emission of .size directives and debugging information, since
76 # they will get confused by the splitting of the output we do.
77 $(objpfx)cr%i.s $(objpfx)cr%n.s: initfini.c; $(initfini)
78
79 define initfini
80 -rm -f $(objpfx)crtcommon.tmp
81 (echo 'cat > crtcommon.tmp <<\EOF_common'; \
82 $(CC) $< $(CPPFLAGS) $(CFLAGS) \
83 -fPIC -finhibit-size-directive $(no-exceptions) -g0 -S -o -; \
84 echo 'EOF_common') | (cd $(@D); $(SHELL))
85 cat $(objpfx)crtcommon.tmp >> $(objpfx)crti.s-new
86 cat $(objpfx)crtcommon.tmp >> $(objpfx)crtn.s-new
87 rm -f $(objpfx)crtcommon.tmp
88 mv -f $(objpfx)crti.s-new $(subst crtn,crti,$@)
89 mv -f $(objpfx)crtn.s-new $(subst crti,crtn,$@)
90 endef
91
92 endif
93
94 include ../Rules
95
96 ifndef start-installed-name-rule
97 # The startfile is installed under different names, so we just call our
98 # source file `start.c' and copy to the installed name after compiling.
99 $(objpfx)$(start-installed-name): $(objpfx)start.o
100 -rm -f $@
101 ln $< $@
102 endif
103
104 # The profiling startfile is made by linking together the normal
105 # startfile with gmon-start.o, which defines a constructor function
106 # to turn on profiling code at startup.
107 $(objpfx)g$(start-installed-name): $(objpfx)start.o $(objpfx)gmon-start.o
108 $(CC) -nostdlib -nostartfiles -r -o $@ $^
109
110 # These extra files are sometimes expected by system standard linking
111 # procedures, but we have nothing for them to do. So compile empty files.
112 $(addprefix $(objpfx),$(filter-out $(start-installed-name),$(csu-dummies))):
113 cp /dev/null $(@:.o=.c)
114 $(COMPILE.c) $(@:.o=.c) $(OUTPUT_OPTION)
115 rm -f $(@:.o=.c)
This page took 0.045521 seconds and 6 git commands to generate.