1 # Makefile for csu code for GNU C library.
3 # Copyright (C) 1995, 1996, 1997 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 not,
18 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, 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.
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
) \
35 omit-deps
= $(patsubst %.o
,%,$(start-installed-name
) g
$(start-installed-name
) \
37 install-lib
= $(start-installed-name
) g
$(start-installed-name
) \
39 distribute
= initfini.c gmon-start.c start.c defs.awk
41 all: # Make this the default target; it will be defined in Rules.
47 # When not using ELF, there is just one startfile, called crt0.o.
48 start-installed-name
= crt0.o
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
59 ifeq ($(have-initfini
),yes
)
61 CPPFLAGS
+= -DHAVE_INITFINI
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.
68 install-lib
+= $(crtstuff
:=.o
)
69 extra-objs
+= $(crtstuff
:=.o
)
70 generated
+= $(crtstuff
:=.S
) initfini.s align.h end.h
71 omit-deps
+= $(crtstuff
)
73 # Special rules for the building of crti.o and crtn.o
74 $(objpfx
)crt
%.o
: $(objpfx
)crt
%.S
$(objpfx
)defs.h
75 $(CC
) -c
-fPIC
-g0
-I
$(..
) -I
$(common-objpfx
) -DASSEMBLER
$< -o
$@
77 $(objpfx
)initfini.s
: initfini.c
78 $(CC
) $(CPPFLAGS
) $(CFLAGS
) -g0
-S
-fPIC
-finhibit-size-directive \
79 -fno-inline-functions
$(no-exceptions
) $< -o
$@
81 $(objpfx
)crti.S
: $(objpfx
)initfini.s
82 sed
-n
-e
'1,/@HEADER_ENDS/p' \
83 -e
'/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
84 -e
'/@TRAILER_BEGINS/,$$p' $< > $@
86 $(objpfx
)crtn.S
: $(objpfx
)initfini.s
87 sed
-n
-e
'1,/@HEADER_ENDS/p' \
88 -e
'/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
89 -e
'/@TRAILER_BEGINS/,$$p' $< > $@
91 $(objpfx
)defs.h
: $(objpfx
)initfini.s
92 sed
-n
-e
'/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
99 ifndef start-installed-name-rule
100 # The startfile is installed under different names, so we just call our
101 # source file `start.c' and copy to the installed name after compiling.
102 $(objpfx
)$(start-installed-name
): $(objpfx
)start.o
107 # The profiling startfile is made by linking together the normal
108 # startfile with gmon-start.o, which defines a constructor function
109 # to turn on profiling code at startup.
110 $(objpfx
)g
$(start-installed-name
): $(objpfx
)start.o
$(objpfx
)gmon-start.o
111 $(CC
) -nostdlib
-nostartfiles
-r
-o
$@
$^
113 # These extra files are sometimes expected by system standard linking
114 # procedures, but we have nothing for them to do. So compile empty files.
115 $(addprefix $(objpfx
),$(filter-out $(start-installed-name
),$(csu-dummies
))):
116 cp
/dev
/null
$(@
:.o
=.c
)
117 $(COMPILE.c
) $(@
:.o
=.c
) $(OUTPUT_OPTION
)