1 # Makefile for csu code for GNU C library.
3 # Copyright (C) 1995 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); and some initialization code which
24 # is in the C library itself. In ELF we also install crti.o and crtn.o,
25 # special "initializer" and "finalizer" files in used in the link to make
26 # the .init and .fini sections work right; both these files are built (in
27 # an arcane manner) from initfini.c.
31 csu-dummies
= $(filter-out $(start-installed-name
),crt1.o Mcrt1.o
)
32 extra-objs
= start.o
$(start-installed-name
) $(csu-dummies
)
33 omit-deps
= $(patsubst %.o
,%,$(start-installed-name
) $(csu-dummies
))
34 install-lib
= $(start-installed-name
) $(csu-dummies
)
35 distribute
= initfini.c
37 all: # Make this the default target; it will be defined in Rules.
43 # When not using ELF, there is just one startfile, called crt0.o.
44 start-installed-name
= crt0.o
48 # In the ELF universe, crt0.o is called crt1.o, and there are
49 # some additional bizarre files.
50 start-installed-name
= crt1.o
52 # These are the special initializer/finalizer files. They are always the
53 # first and last file in the link. crti.o ... crtn.o are used for normal
54 # linking; they define the global "functions" _init and _fini to run the
55 # .init and .fini sections. crti_s.o ... crtn_s.o are for making shared
56 # library objects; they put the prologue/epilogue code into the .init and
57 # .fini sections, but define no global symbols.
58 crtstuff
= crti crtn crti_s crtn_s
60 install-lib
+= $(crtstuff
:=.o
)
61 extra-objs
+= $(crtstuff
:=.o
)
62 generated
+= $(crtstuff
:=.s
)
63 omit-deps
+= $(crtstuff
)
65 # Compile initfini.c to assembly code, which contains embedded shell
66 # commands that prodice crti.s-new and crtn.s-new when run. We need to
67 # disable emission of .size directives and debugging information, since
68 # they will get confused by the splitting of the output we do.
69 $(objpfx
)cr
%i.s
$(objpfx
)cr
%n.s
: initfini.c
; $(initfini
)
70 $(objpfx
)cr
%i_s.s
$(objpfx
)cr
%n_s.s
: initfini.c
; $(initfini
)
73 -rm -f
$(objpfx
)crtcommon.tmp
74 (echo
'cat > crtcommon.tmp <<\EOF_common'; \
75 $(CC
) $< $(CPPFLAGS
) $(CFLAGS
) \
76 $(patsubst %,-DGLOBAL
=static
,$(filter %_s.s
,$@
)) \
77 -finhibit-size-directive
-g0
-S
-o
-; \
78 echo
'EOF_common') |
(cd
$(@D
); $(SHELL
))
79 cat
$(objpfx
)crtcommon.tmp
>> $(objpfx
)crti.s-new
80 cat
$(objpfx
)crtcommon.tmp
>> $(objpfx
)crtn.s-new
81 rm -f
$(objpfx
)crtcommon.tmp
82 mv
-f
$(objpfx
)crti.s-new
$(subst crtn
,crti
,$@
)
83 mv
-f
$(objpfx
)crtn.s-new
$(subst crti
,crtn
,$@
)
90 # The startfile is installed under different names, so we just call our
91 # source file `start.c' and copy to the installed name after compiling.
92 $(objpfx
)$(start-installed-name
): $(objpfx
)start.o
96 # These extra files are sometimes expected by system standard linking
97 # procedures, but we have nothing for them to do. So compile empty files.
98 $(addprefix $(objpfx
),$(filter-out $(start-installed-name
),$(csu-dummies
))):
99 cp
/dev
/null
$(@
:.o
=.c
)
100 $(COMPILE.c
) $(@
:.o
=.c
) $(OUTPUT_OPTION
)