1 # Make-lang.in -- Top level -*- makefile -*- fragment for the D frontend.
2 # Copyright (C) 2006-2018 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.
31 # Tell GNU make to ignore these if they exist.
34 # Create the compiler driver for D.
35 CFLAGS-d/d-spec.o += $(DRIVER_DEFINES) $(D_LIBPHOBOS)
37 GDC_OBJS = $(GCC_OBJS) d/d-spec.o
38 gdc$(exeext): $(GDC_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
39 +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
40 $(GDC_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
41 $(EXTRA_GCC_LIBS) $(LIBS)
43 # Create a version of the gdc driver which calls the cross-compiler.
44 gdc-cross$(exeext): gdc$(exeext)
45 -rm -f gdc-cross$(exeext)
46 cp gdc$(exeext) gdc-cross$(exeext)
48 # Filter out pedantic and virtual overload warnings.
49 d-warn = $(filter-out -pedantic -Woverloaded-virtual, $(STRICT_WARN))
51 # Also filter out warnings for missing format attributes in the D Frontend.
52 DMD_WARN_CXXFLAGS = $(filter-out -Wmissing-format-attribute, $(WARN_CXXFLAGS))
53 DMD_COMPILE = $(subst $(WARN_CXXFLAGS), $(DMD_WARN_CXXFLAGS), $(COMPILE))
54 DMDGEN_COMPILE = $(subst $(COMPILER), $(COMPILER_FOR_BUILD), $(DMD_COMPILE))
56 # D Frontend object files.
131 # D Frontend generated files.
132 D_GENERATED_SRCS = d/id.c d/id.h d/impcnvtab.c
133 D_GENERATED_OBJS = d/id.o d/impcnvtab.o
135 # Language-specific object files for D.
137 d/d-attribs.o d/d-builtins.o d/d-codegen.o d/d-convert.o \
138 d/d-diagnostic.o d/d-frontend.o d/d-incpath.o d/d-lang.o \
139 d/d-longdouble.o d/d-target.o d/decl.o d/expr.o d/imports.o \
140 d/intrinsics.o d/modules.o d/runtime.o d/toir.o d/typeinfo.o d/types.o
142 # All language-specific object files for D.
143 D_ALL_OBJS = $(D_FRONTEND_OBJS) $(D_GENERATED_OBJS) $(D_OBJS) $(D_TARGET_OBJS)
145 d_OBJS = $(D_ALL_OBJS) d/d-spec.o
147 d21$(exeext): $(D_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS)
148 +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
149 $(D_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
155 $(gcc_docdir)/include/fdl.texi \
156 $(gcc_docdir)/include/gpl_v3.texi \
157 $(gcc_docdir)/include/gcc-common.texi \
160 doc/gdc.info: $(D_TEXI_FILES)
161 if test "x$(BUILD_INFO)" = xinfo; then \
162 rm -f doc/gdc.info*; \
163 $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
164 -I $(gcc_docdir)/include -o $@ $<; \
167 doc/gdc.dvi: $(D_TEXI_FILES)
168 $(TEXI2DVI) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
170 doc/gdc.pdf: $(D_TEXI_FILES)
171 $(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
173 $(build_htmldir)/d/index.html: $(D_TEXI_FILES)
174 $(mkinstalldirs) $(@D)
176 $(TEXI2HTML) -I $(gcc_docdir) -I $(gcc_docdir)/include \
177 -I $(srcdir)/d -o $(@D) $<
179 .INTERMEDIATE: gdc.pod
182 -$(TEXI2POD) -D gdc < $< > $@
186 d.all.cross: gdc-cross$(exeext)
187 d.start.encap: gdc$(exeext)
192 d.html: $(build_htmldir)/d/index.html
193 d.srcinfo: doc/gdc.info
194 -cp -p $^ $(srcdir)/doc
199 etags -o TAGS.sub *.c *.cc *.h dmd/*.c dmd/*.h dmd/root/*.h dmd/root/*.c; \
200 etags --include TAGS.sub --include ../TAGS.sub
204 -cp -p $^ $(srcdir)/doc
206 # 'make check' in gcc/ looks for check-d, as do all toplevel D-related
207 # check targets. However, our DejaGNU framework requires 'check-gdc' as its
208 # entry point. We feed the former to the latter here.
210 lang_checks += check-gdc
211 lang_checks_parallelized += check-gdc
212 check_gdc_parallelize = 10
214 # No D-specific selftests.
219 d.install-common: installdirs
220 -rm -f $(DESTDIR)$(bindir)/$(D_INSTALL_NAME)$(exeext)
221 $(INSTALL_PROGRAM) gdc$(exeext) $(DESTDIR)$(bindir)/$(D_INSTALL_NAME)$(exeext)
222 -if test -f d21$(exeext); then \
223 if test -f gdc-cross$(exeext); then \
226 rm -f $(DESTDIR)$(bindir)/$(D_TARGET_INSTALL_NAME)$(exeext); \
227 ( cd $(DESTDIR)$(bindir) && \
228 $(LN) $(D_INSTALL_NAME)$(exeext) $(D_TARGET_INSTALL_NAME)$(exeext) ); \
234 d.install-info: $(DESTDIR)$(infodir)/gdc.info
236 d.install-pdf: doc/gdc.pdf
238 test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
239 @for p in doc/gdc.pdf; do \
240 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
241 f=$(pdf__strip_dir) \
242 echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
243 $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
246 d.install-html: $(build_htmldir)/d
248 test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)"
249 @for p in $(build_htmldir)/d; do \
250 if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; fi; \
251 f=$(html__strip_dir) \
252 if test -d "$$d$$p"; then \
253 echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \
254 $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
255 echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
256 $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \
258 echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
259 $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
263 d.install-man: $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext)
265 $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext): doc/gdc.1 installdirs
267 -$(INSTALL_DATA) $< $@
271 -rm -rf $(DESTDIR)$(bindir)/$(D_INSTALL_NAME)$(exeext)
272 -rm -rf $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext)
273 -rm -rf $(DESTDIR)$(bindir)/$(D_TARGET_INSTALL_NAME)$(exeext)
274 -rm -rf $(DESTDIR)$(infodir)/gdc.info*
280 -rm -f d/*$(coverageexts)
281 -rm -f $(D_GENERATED_SRCS)
282 -rm -f d/gdc$(exeext) gdc-cross$(exeext) d/d21$(exeext)
286 -rm -f $(docobjdir)/gdc.1
290 d.stage1: stage1-start
291 -mv d/*$(objext) stage1/d
292 d.stage2: stage2-start
293 -mv d/*$(objext) stage2/d
294 d.stage3: stage3-start
295 -mv d/*$(objext) stage3/d
296 d.stage4: stage4-start
297 -mv d/*$(objext) stage4/d
298 d.stageprofile: stageprofile-start
299 -mv d/*$(objext) stageprofile/d
300 d.stagefeedback: stagefeedback-start
301 -mv d/*$(objext) stagefeedback/d
303 # Include the dfrontend and build directories for headers.
304 D_INCLUDES = -I$(srcdir)/d -I$(srcdir)/d/dmd -Id
306 CFLAGS-d/id.o += $(D_INCLUDES)
307 CFLAGS-d/impcnvtab.o += $(D_INCLUDES)
309 # Override build rules for D frontend.
310 d/%.o: d/dmd/%.c $(D_GENERATED_SRCS)
311 $(DMD_COMPILE) $(D_INCLUDES) $<
314 d/%.o: d/dmd/root/%.c $(D_GENERATED_SRCS)
315 $(DMD_COMPILE) $(D_INCLUDES) $<
318 # Generated programs.
319 d/idgen: d/idgen.dmdgen.o
320 +$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ $^
322 d/impcvgen: d/impcnvgen.dmdgen.o
323 +$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ $^
329 # idgen also generates id.h; just verify it exists.
332 d/impcnvtab.c: d/impcvgen
335 d/%.dmdgen.o: $(srcdir)/d/dmd/%.c
336 $(DMDGEN_COMPILE) $(D_INCLUDES) $<