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)
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.
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.
30 d.serial = d21$(exeext)
32 # Tell GNU make to ignore these if they exist.
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
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) \
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)
79 # D Frontend object files.
95 d/common-bitfields.o \
97 d/common-outbuffer.o \
160 d/parsetimevisitor.o \
161 d/permissivevisitor.o \
162 d/postordervisitor.o \
172 d/root-longdouble.o \
177 d/root-rootobject.o \
180 d/root-stringtable.o \
188 d/statement_rewrite_walker.o \
194 d/templateparamsem.o \
197 d/transitivevisitor.o \
203 # Language-specific object files for D.
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)
245 $(gcc_docdir)/include/fdl.texi \
246 $(gcc_docdir)/include/gpl_v3.texi \
247 $(gcc_docdir)/include/gcc-common.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 $@ $<; \
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)
266 $(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/d -o $(@D) $<
268 .INTERMEDIATE: gdc.pod
271 -$(TEXI2POD) -D gdc < $< > $@
275 d.all.cross: gdc-cross$(exeext)
276 d.start.encap: gdc$(exeext)
281 d.html: $(build_htmldir)/gdc/index.html
282 d.srcinfo: doc/gdc.info
283 -cp -p $^ $(srcdir)/doc
288 $(ETAGS) -o TAGS.sub *.cc *.h dmd/*.h dmd/root/*.h; \
289 $(ETAGS) --include TAGS.sub --include ../TAGS.sub
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.
299 lang_checks += check-gdc
300 lang_checks_parallelized += check-gdc
301 check_gdc_parallelize = 10
303 # No D-specific selftests.
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 \
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) ); \
323 d.install-info: $(DESTDIR)$(infodir)/gdc.info
325 d.install-pdf: doc/gdc.pdf
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"; \
335 d.install-dvi: doc/gdc.dvi
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"; \
345 d.install-html: $(build_htmldir)/gdc
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"; \
357 echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
358 $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
362 d.install-man: $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext)
364 $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext): doc/gdc.1 installdirs
366 -$(INSTALL_DATA) $< $@
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*
379 -rm -f d/*$(coverageexts)
380 -rm -f gdc$(exeext) gdc-cross$(exeext) d21$(exeext)
384 -rm -f $(docobjdir)/gdc.1
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.
406 $(DCOMPILE) $(D_INCLUDES) $<
409 d/common-%.o: d/dmd/common/%.d
410 $(DCOMPILE) $(D_INCLUDES) $<
413 d/root-%.o: d/dmd/root/%.d
414 $(DCOMPILE) $(D_INCLUDES) $<