1 # Top level -*- makefile -*- fragment for GNU C - C language.
2 # Copyright (C) 1994-2022 Free Software Foundation, Inc.
4 #This file is part of GCC.
6 #GCC is free software; you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation; either version 3, or (at your option)
11 #GCC 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
14 #GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GCC; see the file COPYING3. If not see
18 # <http://www.gnu.org/licenses/>.
20 # This file provides the language dependent support in the main Makefile.
21 # Each language makefile fragment must provide the following targets:
23 # foo.all.cross, foo.start.encap, foo.rest.encap,
24 # foo.install-common, foo.install-man, foo.install-info, foo.install-pdf,
25 # foo.install-html, foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall,
26 # foo.mostlyclean, foo.clean, foo.distclean,
27 # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
29 # where `foo' is the name of the language.
31 # It should also provide rules for:
33 # - making any compiler driver (eg: gcc)
34 # - the compiler proper (eg: cc1)
35 # - define the names for selecting the language in LANGUAGES.
38 # Define the names for selecting c in LANGUAGES.
40 c.serial = cc1$(exeext)
42 # Tell GNU make to ignore these if they exist.
45 # The C front end driver. This is different from the drivers for other
46 # front ends, because there is no C language specific driver (i.e. nothing
47 # is to cc1 as e.g. g++ is to cc1plus, or gfortran is to f951).
48 CFLAGS-c/gccspec.o += $(DRIVER_DEFINES)
50 # The C compiler itself.
52 # Language-specific object files for C and Objective C.
64 # Language-specific object files for C.
69 # c-family/stub-objc.o
71 c_OBJS = $(C_OBJS) c/gccspec.o
73 # Use strict warnings for this front end.
74 c-warn = $(STRICT_WARN)
76 ifeq ($(if $(wildcard ../stage_current),$(shell cat \
77 ../stage_current)),stageautofeedback)
78 $(C_OBJS): ALL_COMPILERFLAGS += -fauto-profile=cc1.fda
82 # compute checksum over all object files and the options
83 # re-use the checksum from the prev-final stage so it passes
84 # the bootstrap comparison and allows comparing of the cc1 binary
85 cc1-checksum.cc : build/genchecksum$(build_exeext) checksum-options \
86 $(C_OBJS) $(BACKEND) $(LIBDEPS)
87 if [ -f ../stage_final ] \
88 && cmp -s ../stage_current ../stage_final; then \
89 cp ../prev-gcc/cc1-checksum.cc cc1-checksum.cc; \
91 build/genchecksum$(build_exeext) $(C_OBJS) \
94 checksum-options > cc1-checksum.cc.tmp && \
95 $(srcdir)/../move-if-change cc1-checksum.cc.tmp cc1-checksum.cc; \
99 cc1$(exeext): $(C_OBJS) $(BACKEND) $(LIBDEPS)
100 @$(call LINK_PROGRESS,$(INDEX.c),start)
101 $(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
102 $(BACKEND) $(LIBS) $(BACKENDLIBS)
103 @$(call LINK_PROGRESS,$(INDEX.c),end)
105 cc1.fda: ../stage1-gcc/cc1$(exeext) ../prev-gcc/$(PERF_DATA)
106 $(CREATE_GCOV) -binary ../stage1-gcc/cc1$(exeext) -gcov cc1.fda -profile ../prev-gcc/$(PERF_DATA) -gcov_version 1
123 c.srcextra: gengtype-lex.cc
126 cd $(srcdir)/c; $(ETAGS) -o TAGS.sub *.c *.h; \
127 $(ETAGS) --include TAGS.sub --include ../TAGS.sub
133 # If C is enabled, require the selftests to be run for it
134 # at each stage of the build:
135 selftest-c: s-selftest-c
137 C_SELFTEST_FLAGS = -xc $(SELFTEST_FLAGS)
138 C_SELFTEST_DEPS = cc1$(exeext) $(SELFTEST_DEPS)
140 # Run the C selftests:
141 s-selftest-c: $(C_SELFTEST_DEPS)
142 $(GCC_FOR_TARGET) $(C_SELFTEST_FLAGS)
145 # Convenience methods for running C selftests under gdb:
146 .PHONY: selftest-c-gdb
147 selftest-c-gdb: $(C_SELFTEST_DEPS)
148 $(GCC_FOR_TARGET) $(C_SELFTEST_FLAGS) \
152 selftest-gdb: selftest-c-gdb
154 # Convenience methods for running C selftests under valgrind:
155 .PHONY: selftest-c-valgrind
156 selftest-c-valgrind: $(C_SELFTEST_DEPS)
157 $(GCC_FOR_TARGET) $(C_SELFTEST_FLAGS) \
158 -wrapper valgrind,--leak-check=full
160 .PHONY: selftest-valgrind
161 selftest-valgrind: selftest-c-valgrind
163 # List of targets that can use the generic check- rule and its // variant.
164 lang_checks += check-gcc
165 lang_checks_parallelized += check-gcc
166 # For description see the check_$lang_parallelize comment in gcc/Makefile.in.
167 check_gcc_parallelize=10000
169 # 'make check' in gcc/ looks for check-c. Redirect it to check-gcc.
174 # cc1 is installed elsewhere as part of $(COMPILERS).
179 c.install-plugin: installdirs
180 # Install import library.
181 ifeq ($(plugin_implib),yes)
182 $(mkinstalldirs) $(DESTDIR)$(plugin_resourcesdir)
183 $(INSTALL_DATA) cc1$(exeext).a $(DESTDIR)$(plugin_resourcesdir)/cc1$(exeext).a
190 # A lot of the ancillary files are deleted by the main makefile.
191 # We just have to delete files specific to us.
196 -rm -f c/*$(coverageexts)
200 -rm -f c/config.status c/Makefile
204 # The main makefile has already created stage?/cp.
206 c.stage1: stage1-start
207 -mv c/*$(objext) stage1/c
208 c.stage2: stage2-start
209 -mv c/*$(objext) stage2/c
210 c.stage3: stage3-start
211 -mv c/*$(objext) stage3/c
212 c.stage4: stage4-start
213 -mv c/*$(objext) stage4/c
214 c.stageprofile: stageprofile-start
215 -mv c/*$(objext) stageprofile/c
216 c.stagefeedback: stagefeedback-start
217 -mv c/*$(objext) stagefeedback/c
218 c.autostageprofile: autostageprofile-start
219 -mv c/*$(objext) autostageprofile/c
220 c.autostagefeedback: autostagefeedback-start
221 -mv c/*$(objext) autostagefeedback/c