]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/jit/Make-lang.in
jit: port libgccjit to Windows
[thirdparty/gcc.git] / gcc / jit / Make-lang.in
CommitLineData
35485da9 1# Top level -*- makefile -*- fragment for libgccjit.so.
8d9254fc 2# Copyright (C) 2013-2020 Free Software Foundation, Inc.
35485da9
DM
3
4#This file is part of GCC.
5
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)
9#any later version.
10
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.
15
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/>.
19
20# This file provides the language dependent support in the main Makefile.
21# Each language makefile fragment must provide the following targets:
22#
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
28#
29# where `foo' is the name of the language.
30#
31# It should also provide rules for:
32#
33# - making any compiler driver (eg: g++)
34# - the compiler proper (eg: cc1plus)
35# - define the names for selecting the language in LANGUAGES.
36
37#\f
38# Define the names for selecting jit in LANGUAGES.
39# Note that it would be nice to move the dependency on g++
40# into the jit rule, but that needs a little bit of work
41# to do the right thing within all.cross.
42
c83027f3
NB
43ifneq (,$(findstring mingw,$(target)))
44LIBGCCJIT_FILENAME = libgccjit.dll
45
46jit: $(LIBGCCJIT_FILENAME) \
47 $(FULL_DRIVER_NAME)
48
49else
50
35485da9
DM
51LIBGCCJIT_LINKER_NAME = libgccjit.so
52LIBGCCJIT_VERSION_NUM = 0
53LIBGCCJIT_MINOR_NUM = 0
54LIBGCCJIT_RELEASE_NUM = 1
c83027f3 55
35485da9
DM
56LIBGCCJIT_SONAME = $(LIBGCCJIT_LINKER_NAME).$(LIBGCCJIT_VERSION_NUM)
57LIBGCCJIT_FILENAME = \
58 $(LIBGCCJIT_SONAME).$(LIBGCCJIT_MINOR_NUM).$(LIBGCCJIT_RELEASE_NUM)
59
60LIBGCCJIT_LINKER_NAME_SYMLINK = $(LIBGCCJIT_LINKER_NAME)
61LIBGCCJIT_SONAME_SYMLINK = $(LIBGCCJIT_SONAME)
62
deb3da39
DM
63# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and
64# LD_SONAME_OPTION depending if configure found them, using $(if)
65# We have to define a COMMA here, otherwise the commas in the "true"
66# result are treated as separators by the $(if).
67COMMA := ,
68LIBGCCJIT_VERSION_SCRIPT_OPTION = \
69 $(if $(LD_VERSION_SCRIPT_OPTION),\
70 -Wl$(COMMA)$(LD_VERSION_SCRIPT_OPTION)$(COMMA)$(srcdir)/jit/libgccjit.map)
71
72LIBGCCJIT_SONAME_OPTION = \
73 $(if $(LD_SONAME_OPTION), \
74 -Wl$(COMMA)$(LD_SONAME_OPTION)$(COMMA)$(LIBGCCJIT_SONAME))
75
35485da9
DM
76jit: $(LIBGCCJIT_FILENAME) \
77 $(LIBGCCJIT_SYMLINK) \
78 $(LIBGCCJIT_LINKER_NAME_SYMLINK) \
79 $(FULL_DRIVER_NAME)
c83027f3 80endif
35485da9
DM
81
82# Tell GNU make to ignore these if they exist.
83.PHONY: jit
84
85jit_OBJS = attribs.o \
86 jit/dummy-frontend.o \
87 jit/libgccjit.o \
eb4c16eb 88 jit/jit-logging.o \
35485da9
DM
89 jit/jit-recording.o \
90 jit/jit-playback.o \
56dea35f 91 jit/jit-result.o \
d1e5f2c7 92 jit/jit-tempdir.o \
2cb844ce
DM
93 jit/jit-builtins.o \
94 jit/jit-spec.o \
95 gcc.o
35485da9 96
c83027f3
NB
97ifneq (,$(findstring mingw,$(target)))
98jit_OBJS += jit/jit-w32.o
99endif
100
35485da9
DM
101# Use strict warnings for this front end.
102jit-warn = $(STRICT_WARN)
103
c83027f3
NB
104ifneq (,$(findstring mingw,$(target)))
105# Create import library libgccjit.dll.a
106LIBGCCJIT_EXTRA_OPTS = -Wl,--out-implib,$(LIBGCCJIT_FILENAME).a
107else
108LIBGCCJIT_EXTRA_OPTS = $(LIBGCCJIT_VERSION_SCRIPT_OPTION) \
109 $(LIBGCCJIT_SONAME_OPTION)
110endif
111
35485da9
DM
112# We avoid using $(BACKEND) from Makefile.in in order to avoid pulling
113# in main.o
114$(LIBGCCJIT_FILENAME): $(jit_OBJS) \
115 libbackend.a libcommon-target.a libcommon.a \
116 $(CPPLIB) $(LIBDECNUMBER) \
2cb844ce
DM
117 $(LIBDEPS) $(srcdir)/jit/libgccjit.map \
118 $(EXTRA_GCC_OBJS)
35485da9
DM
119 +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ -shared \
120 $(jit_OBJS) libbackend.a libcommon-target.a libcommon.a \
ea143da7 121 $(CPPLIB) $(LIBDECNUMBER) $(EXTRA_GCC_LIBS) $(LIBS) $(BACKENDLIBS) \
2cb844ce 122 $(EXTRA_GCC_OBJS) \
c83027f3 123 $(LIBGCCJIT_EXTRA_OPTS)
35485da9 124
c83027f3
NB
125# Create symlinks when not building for Windows
126ifeq (,$(findstring mingw,$(target)))
35485da9
DM
127$(LIBGCCJIT_SONAME_SYMLINK): $(LIBGCCJIT_FILENAME)
128 ln -sf $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SONAME_SYMLINK)
129
130$(LIBGCCJIT_LINKER_NAME_SYMLINK): $(LIBGCCJIT_SONAME_SYMLINK)
131 ln -sf $(LIBGCCJIT_SONAME_SYMLINK) $(LIBGCCJIT_LINKER_NAME_SYMLINK)
c83027f3 132endif
35485da9
DM
133
134#\f
135# Build hooks:
136
137jit.all.cross:
138jit.start.encap:
139jit.rest.encap:
140
141# Documentation build hooks.
142#
143# The documentation can be built using the texinfo toolchain, or
144# the sphinx toolchain
145#
146# The jit documentation is authored using Sphinx, which has numerous
147# advantages over Texinfo, including:
148#
149# * much faster
150#
151# * use of CSS and JS to provide less of a 1990s feel in the generated
152# HTML.
153#
154# * sane, stable HTML page and anchor names
155#
156# * sane HTML navigation: ability to move forward and back in the HTML
157# at every node to read the HTML like a book
158#
159# * syntax-coloring of examples
160#
161# * the ability to "include" fragments of code inline. This is used
162# heavily by the jit docs, so that the example code is shared by both
163# the test suite and the documentation to ensure that the examples
164# appearing in the docs actually compile and work
165#
166# Sphinx is not a "blessed" dependency, and so a prebuilt libgccjit.texinfo
167# file built by Sphinx is checked into the source tree to avoid requiring
168# everyone to have Sphinx installed.
169#
170# This prebuilt libgccjit.texinfo has the "include" fragments "baked in",
171# and so contains the content from the sphinx toolchain, but lacks the
172# syntax-coloring, and the generated HTML is (IMHO) greatly inferior to
173# that generated by Sphinx.
174
175# These targets redirect HTML creation and installation to either
176# jit.sphinx.(install-)html or jit.texinfo.(install-)html.
177jit.html: jit.$(doc_build_sys).html
178jit.install-html: jit.$(doc_build_sys).install-html
179
180# For now, use texinfo for pdf, since the sphinx latex toolchain currently
181# fails for me deep inside pdflatex (see notes below)
182jit.pdf: jit.texinfo.pdf
183jit.install-pdf: jit.texinfo.install-pdf
184
185# Hooks for building docs using texinfo
186JIT_TEXI_FILES = $(srcdir)/jit/docs/_build/texinfo/libgccjit.texi
187
188jit.info: doc/libgccjit.info
189doc/libgccjit.info: $(JIT_TEXI_FILES)
190 if test "x$(BUILD_INFO)" = xinfo; then \
191 rm -f doc/libgccjit.info*; \
192 $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
193 -I $(gcc_docdir)/include -o $@ $<; \
194 else true; fi
195
196jit.install-info: $(DESTDIR)$(infodir)/libgccjit.info
197
198jit.dvi: doc/libgccjit.dvi
199doc/libgccjit.dvi: $(JIT_TEXI_FILES)
200 $(TEXI2DVI) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
201
202jit.texinfo.html: $(build_htmldir)/jit/index.html
203
204$(build_htmldir)/jit/index.html: $(srcdir)/jit/docs/_build/texinfo/libgccjit.texi
205 $(mkinstalldirs) $(@D)
206 rm -f $(@D)/*
207 $(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/jit -o $(@D) $<
208
209jit.texinfo.install-html: jit.texinfo.html
210 @$(NORMAL_INSTALL)
211 test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)"
212 @for p in $(build_htmldir)/jit; do \
213 if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; fi; \
214 f=$(html__strip_dir) \
215 if test -d "$$d$$p"; then \
216 echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \
217 $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
218 echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
219 $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \
220 else \
221 echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
222 $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
223 fi; \
224 done
225
226jit.texinfo.pdf: doc/libgccjit.pdf
227
228doc/libgccjit.pdf: $(JIT_TEXI_FILES)
229 $(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
230
231jit.texinfo.install-pdf: doc/libgccjit.pdf
232 @$(NORMAL_INSTALL)
233 test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
234 @for p in doc/libgccjit.pdf; do \
235 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
236 f=$(pdf__strip_dir) \
237 echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
238 $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
239 done
240
241# Hooks for building docs using the Sphinx toolchain:
242
243SPHINX_BUILD_DIR=jit/sphinx-build
244
245jit.sphinx.html:
246 mkdir -p $(SPHINX_BUILD_DIR)
247 (cd $(srcdir)/jit/docs && \
248 make html BUILDDIR=$(PWD)/$(SPHINX_BUILD_DIR) )
249
250jit_htmldir=$(htmldir)/jit
251
252jit.sphinx.install-html: jit.sphinx.html
253 @$(NORMAL_INSTALL)
254 test -z "$(jit_htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(jit_htmldir)"
255 @for f in $(shell cd $(SPHINX_BUILD_DIR)/html && find) ; do \
256 if test -f $(SPHINX_BUILD_DIR)/html/"$$f"; then \
257 $(INSTALL_DATA) $(SPHINX_BUILD_DIR)/html/"$$f" $(DESTDIR)$(jit_htmldir)/"$$f"; \
258 else \
259 mkdir $(DESTDIR)$(jit_htmldir)/"$$f"; \
260 fi; \
261 done
262
263# (This one is currently failing deep inside pdflatex for me;
264# see https://bugzilla.redhat.com/show_bug.cgi?id=1148845 )
265jit.sphinx.pdf: $(SPHINX_BUILD_DIR)/latex/libgccjit.pdf
266$(SPHINX_BUILD_DIR)/latex/libgccjit.pdf:
267 mkdir -p $(SPHINX_BUILD_DIR)
268 (cd $(srcdir)/jit/docs && \
269 make latexpdf BUILDDIR=$(PWD)/$(SPHINX_BUILD_DIR) )
270
271jit.sphinx.install-pdf: $(SPHINX_BUILD_DIR)/latex/libgccjit.pdf
272 @$(NORMAL_INSTALL)
273 test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
274 @for p in $(SPHINX_BUILD_DIR)/latex/libgccjit.pdf; do \
275 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
276 f=$(pdf__strip_dir) \
277 echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
278 $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
279 done
280
281jit.srcinfo:
282jit.srcextra:
283
284jit.tags:
285
286jit.man:
287
288jit.srcman:
289
290lang_checks += check-jit
499de348
DM
291lang_checks_parallelized += check-jit
292# This number is somewhat arbitrary. Two tests are much slower
293# than all the others (test-combination.c and test-threads.c) so
294# we want them to be placed in different "buckets".
295check_jit_parallelize = 10
35485da9 296
033eb567
DM
297# No jit-specific selftests
298selftest-jit:
299
35485da9
DM
300#\f
301# Install hooks:
c83027f3
NB
302jit.install-headers:
303 $(INSTALL_DATA) $(srcdir)/jit/libgccjit.h \
304 $(DESTDIR)$(includedir)/libgccjit.h
305 $(INSTALL_DATA) $(srcdir)/jit/libgccjit++.h \
306 $(DESTDIR)$(includedir)/libgccjit++.h
307
308ifneq (,$(findstring mingw,$(target)))
309jit.install-common: installdirs jit.install-headers
310# Install import library
311 $(INSTALL_PROGRAM) $(LIBGCCJIT_FILENAME).a \
312 $(DESTDIR)$(libdir)/$(LIBGCCJIT_FILENAME).a
313# Install DLL file
35485da9 314 $(INSTALL_PROGRAM) $(LIBGCCJIT_FILENAME) \
c83027f3
NB
315 $(DESTDIR)$(bindir)/$(LIBGCCJIT_FILENAME)
316else
317jit.install-common: installdirs jit.install-headers
318 $(INSTALL_PROGRAM) $(LIBGCCJIT_FILENAME) \
319 $(DESTDIR)$(libdir)/$(LIBGCCJIT_FILENAME)
35485da9
DM
320 ln -sf \
321 $(LIBGCCJIT_FILENAME) \
c83027f3 322 $(DESTDIR)$(libdir)/$(LIBGCCJIT_SONAME_SYMLINK)
35485da9
DM
323 ln -sf \
324 $(LIBGCCJIT_SONAME_SYMLINK)\
c83027f3
NB
325 $(DESTDIR)$(libdir)/$(LIBGCCJIT_LINKER_NAME_SYMLINK)
326endif
35485da9
DM
327
328jit.install-man:
329
330jit.install-plugin:
331
332jit.uninstall:
333
334#\f
335# Clean hooks:
336# A lot of the ancillary files are deleted by the main makefile.
337# We just have to delete files specific to us.
338
339jit.mostlyclean:
46bf0b0a
JW
340 -rm -f $(LIBGCCJIT_FILENAME) $(LIBGCCJIT_SYMLINK)
341 -rm -f $(LIBGCCJIT_LINKER_NAME_SYMLINK) $(FULL_DRIVER_NAME)
342 -rm -f $(LIBGCCJIT_SONAME)
343 -rm -f $(jit_OBJS)
35485da9
DM
344
345jit.clean:
346
347jit.distclean:
348
349jit.maintainer-clean:
350
351#\f
352# Stage hooks:
353# The main makefile has already created stage?/jit.
354
355jit.stage1: stage1-start
356 -mv jit/*$(objext) stage1/jit
357jit.stage2: stage2-start
358 -mv jit/*$(objext) stage2/jit
359jit.stage3: stage3-start
360 -mv jit/*$(objext) stage3/jit
361jit.stage4: stage4-start
362 -mv jit/*$(objext) stage4/jit
363jit.stageprofile: stageprofile-start
364 -mv jit/*$(objext) stageprofile/jit
365jit.stagefeedback: stagefeedback-start
366 -mv jit/*$(objext) stagefeedback/jit