Sat May 11 13:43:41 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc/history.git] / csu / Makefile
blob144a82653ad36d7e5a70b488f0e37ba0f9af2941
1 # Makefile for csu code for GNU C library.
3 # Copyright (C) 1995, 1996 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
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.
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.
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
18 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 # Cambridge, MA 02139, USA.
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.
28 subdir := csu
30 csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
31 extra-objs = start.o gmon-start.o \
32 $(start-installed-name) g$(start-installed-name) \
33 $(csu-dummies)
34 omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \
35 $(csu-dummies))
36 install-lib = $(start-installed-name) g$(start-installed-name) \
37 $(csu-dummies)
38 distribute = initfini.c
40 all: # Make this the default target; it will be defined in Rules.
42 include ../Makeconfig
44 ifneq ($(elf),yes)
46 # When not using ELF, there is just one startfile, called crt0.o.
47 start-installed-name = crt0.o
49 else
51 # In the ELF universe, crt0.o is called crt1.o, and there are
52 # some additional bizarre files.
53 start-installed-name = crt1.o
54 have-initfini = yes
56 endif
58 ifeq (yes,$(have-initfini))
60 CPPFLAGS += -DHAVE_INITFINI
62 # These are the special initializer/finalizer files. They are always the
63 # first and last file in the link. crti.o ... crtn.o define the global
64 # "functions" _init and _fini to run the .init and .fini sections.
65 crtstuff = crti crtn
67 install-lib += $(crtstuff:=.o)
68 extra-objs += $(crtstuff:=.o)
69 generated += $(crtstuff:=.s)
70 omit-deps += $(crtstuff)
72 # Compile initfini.c to assembly code, which contains embedded shell
73 # commands that prodice crti.s-new and crtn.s-new when run. We need to
74 # disable emission of .size directives and debugging information, since
75 # they will get confused by the splitting of the output we do.
76 $(objpfx)cr%i.s $(objpfx)cr%n.s: initfini.c; $(initfini)
78 define initfini
79 -rm -f $(objpfx)crtcommon.tmp
80 (echo 'cat > crtcommon.tmp <<\EOF_common'; \
81 $(CC) $< $(CPPFLAGS) $(CFLAGS) \
82 -fPIC -finhibit-size-directive -g0 -S -o -; \
83 echo 'EOF_common') | (cd $(@D); $(SHELL))
84 cat $(objpfx)crtcommon.tmp >> $(objpfx)crti.s-new
85 cat $(objpfx)crtcommon.tmp >> $(objpfx)crtn.s-new
86 rm -f $(objpfx)crtcommon.tmp
87 mv -f $(objpfx)crti.s-new $(subst crtn,crti,$@)
88 mv -f $(objpfx)crtn.s-new $(subst crti,crtn,$@)
89 endef
91 endif
93 include ../Rules
95 ifndef start-installed-name-rule
96 # The startfile is installed under different names, so we just call our
97 # source file `start.c' and copy to the installed name after compiling.
98 $(objpfx)$(start-installed-name): $(objpfx)start.o
99 -rm -f $@
100 ln $< $@
101 endif
103 # The profiling startfile is made by linking together the normal
104 # startfile with gmon-start.o, which defines a constructor function
105 # to turn on profiling code at startup.
106 $(objpfx)g$(start-installed-name): $(objpfx)start.o $(objpfx)gmon-start.o
107 $(CC) -nostdlib -nostartfiles -r -o $@ $^
109 # These extra files are sometimes expected by system standard linking
110 # procedures, but we have nothing for them to do. So compile empty files.
111 $(addprefix $(objpfx),$(filter-out $(start-installed-name),$(csu-dummies))):
112 cp /dev/null $(@:.o=.c)
113 $(COMPILE.c) $(@:.o=.c) $(OUTPUT_OPTION)
114 rm -f $(@:.o=.c)