RISC-V: Make stack_save_restore tests more robust
[official-gcc.git] / gcc / d / Make-lang.in
blob264ae03a89e03ba8aeec8bac85d5bf5b414081bb
1 # Make-lang.in -- Top level -*- makefile -*- fragment for the D frontend.
2 # Copyright (C) 2006-2023 Free Software Foundation, Inc.
4 # GCC is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3, or (at your option)
7 # any later version.
9 # GCC is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3.  If not see
16 # <http://www.gnu.org/licenses/>.
18 # This file provides the language dependent support in the main Makefile.
20 # Installation name.
22 D_INSTALL_NAME = $(shell echo gdc|sed '$(program_transform_name)')
23 D_TARGET_INSTALL_NAME = $(target_noncanonical)-$(shell echo gdc|sed '$(program_transform_name)')
25 # Name of phobos library
26 D_LIBPHOBOS = -DLIBPHOBOS=\"gphobos\"
28 # The name for selecting d in LANGUAGES.
29 d: d21$(exeext)
30 d.serial = d21$(exeext)
32 # Tell GNU make to ignore these if they exist.
33 .PHONY: d
35 # Create the compiler driver for D.
36 CFLAGS-d/d-spec.o += $(DRIVER_DEFINES) $(D_LIBPHOBOS)
38 GDC_OBJS = $(GCC_OBJS) d/d-spec.o
39 gdc$(exeext): $(GDC_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
40         +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
41           $(GDC_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
42           $(EXTRA_GCC_LIBS) $(LIBS)
44 # Create a version of the gdc driver which calls the cross-compiler.
45 gdc-cross$(exeext): gdc$(exeext)
46         -rm -f gdc-cross$(exeext)
47         cp gdc$(exeext) gdc-cross$(exeext)
49 # Use strict warnings.
50 d-warn = $(STRICT_WARN)
52 # D compiler and flags for building the front-end.
53 ifeq ($(TREECHECKING),)
54 CHECKING_DFLAGS = -frelease
55 else
56 CHECKING_DFLAGS =
57 endif
58 WARN_DFLAGS = -Wall -Wdeprecated $(NOCOMMON_FLAG)
60 # D front-end doesn't use exceptions, but it does require RTTI.
61 NOEXCEPTION_DFLAGS = $(filter-out -fno-rtti, $(NOEXCEPTION_FLAGS))
63 ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \
64         $(PICFLAG) $(ALIASING_FLAGS) $(NOEXCEPTION_DFLAGS) $(COVERAGE_FLAGS) \
65         $(WARN_DFLAGS)
67 DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
68 DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
69 DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
70 DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
72 # Like LINKER, but use a mutex for serializing front end links.
73 ifeq ($(DO_LINK_MUTEX),true)
74 DLLINKER = $(SHELL) $(srcdir)/lock-and-run.sh linkfe.lck $(DLINKER)
75 else
76 DLLINKER = $(DLINKER)
77 endif
79 # D Frontend object files.
80 D_FRONTEND_OBJS = \
81         d/access.o \
82         d/aggregate.o \
83         d/aliasthis.o \
84         d/arrayop.o \
85         d/arraytypes.o \
86         d/attrib.o \
87         d/ast_node.o \
88         d/astcodegen.o \
89         d/astenums.o \
90         d/blockexit.o \
91         d/builtin.o \
92         d/canthrow.o \
93         d/chkformat.o \
94         d/clone.o \
95         d/common-bitfields.o \
96         d/common-file.o \
97         d/common-outbuffer.o \
98         d/common-string.o \
99         d/compiler.o \
100         d/cond.o \
101         d/constfold.o \
102         d/cparse.o \
103         d/cppmangle.o \
104         d/ctfeexpr.o \
105         d/ctorflow.o \
106         d/dcast.o \
107         d/dclass.o \
108         d/declaration.o \
109         d/delegatize.o \
110         d/denum.o \
111         d/dimport.o \
112         d/dinterpret.o \
113         d/dmacro.o \
114         d/dmangle.o \
115         d/dmodule.o \
116         d/doc.o \
117         d/dscope.o \
118         d/dstruct.o \
119         d/dsymbol.o \
120         d/dsymbolsem.o \
121         d/dtemplate.o \
122         d/dtoh.o \
123         d/dversion.o \
124         d/entity.o \
125         d/errors.o \
126         d/errorsink.o \
127         d/escape.o \
128         d/expression.o \
129         d/expressionsem.o \
130         d/file_manager.o \
131         d/foreachvar.o \
132         d/func.o \
133         d/globals.o \
134         d/gluelayer.o \
135         d/hdrgen.o \
136         d/iasm.o \
137         d/iasmgcc.o \
138         d/id.o \
139         d/identifier.o \
140         d/impcnvtab.o \
141         d/imphint.o \
142         d/importc.o \
143         d/init.o \
144         d/initsem.o \
145         d/inline.o \
146         d/intrange.o \
147         d/json.o \
148         d/lambdacomp.o \
149         d/lexer.o \
150         d/location.o \
151         d/mtype.o \
152         d/mustuse.o \
153         d/nogc.o \
154         d/nspace.o \
155         d/ob.o \
156         d/objc.o \
157         d/opover.o \
158         d/optimize.o \
159         d/parse.o \
160         d/parsetimevisitor.o \
161         d/permissivevisitor.o \
162         d/postordervisitor.o \
163         d/printast.o \
164         d/root-aav.o \
165         d/root-array.o \
166         d/root-bitarray.o \
167         d/root-complex.o \
168         d/root-ctfloat.o \
169         d/root-file.o \
170         d/root-filename.o \
171         d/root-hash.o \
172         d/root-longdouble.o \
173         d/root-optional.o \
174         d/root-port.o \
175         d/root-region.o \
176         d/root-rmem.o \
177         d/root-rootobject.o \
178         d/root-speller.o \
179         d/root-string.o \
180         d/root-stringtable.o \
181         d/root-utf.o \
182         d/safe.o \
183         d/sapply.o \
184         d/semantic2.o \
185         d/semantic3.o \
186         d/sideeffect.o \
187         d/statement.o \
188         d/statement_rewrite_walker.o \
189         d/statementsem.o \
190         d/staticassert.o \
191         d/staticcond.o \
192         d/stmtstate.o \
193         d/target.o \
194         d/templateparamsem.o \
195         d/tokens.o \
196         d/traits.o \
197         d/transitivevisitor.o \
198         d/typesem.o \
199         d/typinf.o \
200         d/utils.o \
201         d/visitor.o
203 # Language-specific object files for D.
204 D_OBJS = \
205         d/d-attribs.o \
206         d/d-builtins.o \
207         d/d-codegen.o \
208         d/d-compiler.o \
209         d/d-convert.o \
210         d/d-ctfloat.o \
211         d/d-diagnostic.o \
212         d/d-frontend.o \
213         d/d-gimplify.o \
214         d/d-incpath.o \
215         d/d-lang.o \
216         d/d-longdouble.o \
217         d/d-port.o \
218         d/d-target.o \
219         d/decl.o \
220         d/expr.o \
221         d/imports.o \
222         d/intrinsics.o \
223         d/modules.o \
224         d/runtime.o \
225         d/toir.o \
226         d/typeinfo.o \
227         d/types.o
229 # All language-specific object files for D.
230 D_ALL_OBJS = $(D_FRONTEND_OBJS) $(D_OBJS) $(D_TARGET_OBJS)
232 d_OBJS = $(D_ALL_OBJS) d/d-spec.o
234 d21$(exeext): $(D_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) $(d.prev)
235         @$(call LINK_PROGRESS,$(INDEX.d),start)
236         +$(DLLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -static-libphobos -o $@ \
237                 $(D_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
238         @$(call LINK_PROGRESS,$(INDEX.d),end)
240 # Documentation.
242 D_TEXI_FILES = \
243         d/gdc.texi \
244         d/implement-d.texi \
245         $(gcc_docdir)/include/fdl.texi \
246         $(gcc_docdir)/include/gpl_v3.texi \
247         $(gcc_docdir)/include/gcc-common.texi \
248         gcc-vers.texi
250 doc/gdc.info: $(D_TEXI_FILES)
251         if test "x$(BUILD_INFO)" = xinfo; then \
252           rm -f doc/gdc.info*; \
253           $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
254                 -I $(gcc_docdir)/include -o $@ $<; \
255         else true; fi
257 doc/gdc.dvi: $(D_TEXI_FILES)
258         $(TEXI2DVI) -I $(abs_docdir)/include -o $@ $<
260 doc/gdc.pdf: $(D_TEXI_FILES)
261         $(TEXI2PDF) -I $(abs_docdir)/include -o $@ $<
263 $(build_htmldir)/gdc/index.html: $(D_TEXI_FILES)
264         $(mkinstalldirs) $(@D)
265         rm -f $(@D)/*
266         $(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/d -o $(@D) $<
268 .INTERMEDIATE: gdc.pod
270 gdc.pod: d/gdc.texi
271         -$(TEXI2POD) -D gdc < $< > $@
273 # Build hooks.
275 d.all.cross: gdc-cross$(exeext)
276 d.start.encap: gdc$(exeext)
277 d.rest.encap:
278 d.info: doc/gdc.info
279 d.dvi: doc/gdc.dvi
280 d.pdf: doc/gdc.pdf
281 d.html: $(build_htmldir)/gdc/index.html
282 d.srcinfo: doc/gdc.info
283         -cp -p $^ $(srcdir)/doc
284 d.srcextra:
286 d.tags: force
287         cd $(srcdir)/d; \
288         $(ETAGS) -o TAGS.sub *.cc *.h dmd/*.h dmd/root/*.h; \
289         $(ETAGS) --include TAGS.sub --include ../TAGS.sub
291 d.man: doc/gdc.1
292 d.srcman: doc/gdc.1
293         -cp -p $^ $(srcdir)/doc
295 # 'make check' in gcc/ looks for check-d, as do all toplevel D-related
296 # check targets.  However, our DejaGNU framework requires 'check-gdc' as its
297 # entry point.  We feed the former to the latter here.
298 check-d: check-gdc
299 lang_checks += check-gdc
300 lang_checks_parallelized += check-gdc
301 check_gdc_parallelize = 10
303 # No D-specific selftests.
304 selftest-d:
306 # Install hooks.
308 d.install-common: installdirs
309         -rm -f $(DESTDIR)$(bindir)/$(D_INSTALL_NAME)$(exeext)
310         $(INSTALL_PROGRAM) gdc$(exeext) $(DESTDIR)$(bindir)/$(D_INSTALL_NAME)$(exeext)
311         -if test -f d21$(exeext); then \
312           if test -f gdc-cross$(exeext); then \
313             :; \
314           else \
315             rm -f $(DESTDIR)$(bindir)/$(D_TARGET_INSTALL_NAME)$(exeext); \
316             ( cd $(DESTDIR)$(bindir) && \
317               $(LN) $(D_INSTALL_NAME)$(exeext) $(D_TARGET_INSTALL_NAME)$(exeext) ); \
318           fi; \
319         fi
321 d.install-plugin:
323 d.install-info: $(DESTDIR)$(infodir)/gdc.info
325 d.install-pdf: doc/gdc.pdf
326         @$(NORMAL_INSTALL)
327         test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
328         @for p in doc/gdc.pdf; do \
329           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
330           f=$(pdf__strip_dir) \
331           echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
332           $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
333         done
335 d.install-dvi: doc/gdc.dvi
336         @$(NORMAL_INSTALL)
337         test -z "$(dvidir)" || $(mkinstalldirs) "$(DESTDIR)$(dvidir)/gcc"
338         @for p in doc/gdc.dvi; do \
339           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
340           f=$(dvi__strip_dir) \
341           echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(dvidir)/gcc/$$f'"; \
342           $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(dvidir)/gcc/$$f"; \
343         done
345 d.install-html: $(build_htmldir)/gdc
346         @$(NORMAL_INSTALL)
347         test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)"
348         @for p in $(build_htmldir)/gdc; do \
349           if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; fi; \
350           f=$(html__strip_dir) \
351           if test -d "$$d$$p"; then \
352             echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \
353             $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
354             echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
355             $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \
356           else \
357             echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
358             $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
359           fi; \
360         done
362 d.install-man: $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext)
364 $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext): doc/gdc.1 installdirs
365         -rm -f $@
366         -$(INSTALL_DATA) $< $@
367         -chmod a-x $@
369 d.uninstall:
370         -rm -rf $(DESTDIR)$(bindir)/$(D_INSTALL_NAME)$(exeext)
371         -rm -rf $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext)
372         -rm -rf $(DESTDIR)$(bindir)/$(D_TARGET_INSTALL_NAME)$(exeext)
373         -rm -rf $(DESTDIR)$(infodir)/gdc.info*
375 # Clean hooks.
377 d.mostlyclean:
378         -rm -f d/*$(objext)
379         -rm -f d/*$(coverageexts)
380         -rm -f gdc$(exeext) gdc-cross$(exeext) d21$(exeext)
381 d.clean:
382 d.distclean:
383 d.maintainer-clean:
384         -rm -f $(docobjdir)/gdc.1
386 # Stage hooks.
388 d.stage1: stage1-start
389         -mv d/*$(objext) stage1/d
390 d.stage2: stage2-start
391         -mv d/*$(objext) stage2/d
392 d.stage3: stage3-start
393         -mv d/*$(objext) stage3/d
394 d.stage4: stage4-start
395         -mv d/*$(objext) stage4/d
396 d.stageprofile: stageprofile-start
397         -mv d/*$(objext) stageprofile/d
398 d.stagefeedback: stagefeedback-start
399         -mv d/*$(objext) stagefeedback/d
401 # Include the dfrontend and build directories for headers.
402 D_INCLUDES = -I$(srcdir)/d -J$(srcdir)/d/dmd -J$(srcdir)/d/dmd/res
404 # Override build rules for D frontend.
405 d/%.o: d/dmd/%.d
406         $(DCOMPILE) $(D_INCLUDES) $<
407         $(DPOSTCOMPILE)
409 d/common-%.o: d/dmd/common/%.d
410         $(DCOMPILE) $(D_INCLUDES) $<
411         $(DPOSTCOMPILE)
413 d/root-%.o: d/dmd/root/%.d
414         $(DCOMPILE) $(D_INCLUDES) $<
415         $(DPOSTCOMPILE)