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