1# Make-lang.in -- Top level -*- makefile -*- fragment for gcc BRIG (HSAIL)
2# frontend.
3
4# Copyright (C) 2015-2019 Free Software Foundation, Inc.
5
6# This file is part of GCC.
7
8# GCC is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 3, or (at your option)
11# any later version.
12
13# GCC is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17
18# You should have received a copy of the GNU General Public License
19# along with GCC; see the file COPYING3.  If not see
20# <http://www.gnu.org/licenses/>.
21
22# This file provides the language dependent support in the main Makefile.
23
24# Installation name.
25
26GCCBRIG_INSTALL_NAME := $(shell echo gccbrig|sed '$(program_transform_name)')
27GCCBRIG_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gccbrig|sed \
28	'$(program_transform_name)')
29
30# The name for selecting brig in LANGUAGES.
31brig: brig1$(exeext)
32
33.PHONY: brig
34
35CFLAGS-brig/brigspec.o += $(DRIVER_DEFINES)
36
37GCCBRIG_OBJS = $(GCC_OBJS) brig/brigspec.o
38gccbrig$(exeext): $(GCCBRIG_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
39	$(LIBDEPS)
40	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
41	  $(GCCBRIG_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
42	  $(EXTRA_GCC_LIBS) $(LIBS)
43
44# The cross-compiler version.  This is built mainly as a signal to the
45# brig.install-common target.  If this executable exists, it means that
46# brig.all.cross was run.
47gccbrig-cross$(exeext): gccbrig$(exeext)
48	-rm -f gccbrig-cross$(exeext)
49	cp gccbrig$(exeext) gccbrig-cross$(exeext)
50
51# Use strict warnings.
52brig-warn = $(STRICT_WARN)
53
54BRIG_OBJS = \
55	brig/brig-lang.o \
56	brig/brig-code-entry-handler.o \
57	brig/brig-function-handler.o \
58	brig/brig-variable-handler.o \
59	brig/brig-fbarrier-handler.o \
60	brig/brig-label-handler.o \
61	brig/brig-comment-handler.o \
62	brig/brig-basic-inst-handler.o \
63	brig/brig-cvt-inst-handler.o \
64	brig/brig-seg-inst-handler.o \
65	brig/brig-lane-inst-handler.o \
66	brig/brig-queue-inst-handler.o \
67	brig/brig-copy-move-inst-handler.o \
68	brig/brig-signal-inst-handler.o \
69	brig/brig-atomic-inst-handler.o \
70	brig/brig-arg-block-handler.o \
71	brig/brig-control-handler.o \
72	brig/brig-cmp-inst-handler.o \
73	brig/brig-branch-inst-handler.o \
74	brig/brig-mem-inst-handler.o \
75	brig/brig-module-handler.o \
76	brig/brig-inst-mod-handler.o \
77	brig/brig-function.o \
78	brig/brig-to-generic.o \
79	brig/brig-machine.o \
80	brig/brig-util.o
81
82brig_OBJS = $(BRIG_OBJS) brig/brigspec.o
83
84# brig1$(exeext): $(BRIG_OBJS) attribs.o $(BACKEND) $(LIBDEPS)
85# 	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
86# 	      $(BRIG_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
87
88
89brig1$(exeext): $(BRIG_OBJS) attribs.o $(BACKEND) $(LIBDEPS)
90	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
91	      $(BRIG_OBJS) attribs.o $(BACKEND) $(LIBS) \
92		  $(BACKENDLIBS)
93
94# Documentation.
95
96BRIG_TEXI_FILES = \
97	brig/gccbrig.texi \
98	$(gcc_docdir)/include/fdl.texi \
99	$(gcc_docdir)/include/gpl_v3.texi \
100	$(gcc_docdir)/include/gcc-common.texi \
101	gcc-vers.texi
102
103doc/gccbrig.info: $(BRIG_TEXI_FILES)
104	if test "x$(BUILD_INFO)" = xinfo; then \
105	  rm -f doc/gccbrig.info*; \
106	  $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
107		-I $(gcc_docdir)/include -o $@ $<; \
108	else true; fi
109
110doc/gccbrig.dvi: $(BRIG_TEXI_FILES)
111	$(TEXI2DVI) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
112
113doc/gccbrig.pdf: $(BRIG_TEXI_FILES)
114	$(TEXI2PDF) -I $(abs_docdir) -I $(abs_docdir)/include -o $@ $<
115
116$(build_htmldir)/brig/index.html: $(BRIG_TEXI_FILES)
117	$(mkinstalldirs) $(@D)
118	rm -f $(@D)/*
119	$(TEXI2HTML) -I $(gcc_docdir) -I $(gcc_docdir)/include \
120		-I $(srcdir)/brig -o $(@D) $<
121
122.INTERMEDIATE: gccbrig.pod
123
124gccbrig.pod: brig/gccbrig.texi
125	-$(TEXI2POD) -D gccbrig < $< > $@
126
127# Build hooks.
128
129brig.all.cross: gccbrig-cross$(exeext)
130brig.start.encap: gccbrig$(exeext)
131brig.rest.encap:
132brig.info: doc/gccbrig.info
133brig.dvi: doc/gccbrig.dvi
134brig.pdf: doc/gccbrig.pdf
135brig.html: $(build_htmldir)/brig/index.html
136brig.srcinfo: doc/gccbrig.info
137	-cp -p $^ $(srcdir)/doc
138
139brig.srcextra:
140brig.tags: force
141	cd $(srcdir)/brig; \
142	etags -o TAGS.sub *.c *.h; \
143	etags --include TAGS.sub --include ../TAGS.sub
144
145brig.man: doc/gccbrig.1
146brig.srcman: doc/gccbrig.1
147	-cp -p $^ $(srcdir)/doc
148
149lang_checks += check-brig
150
151# No brig-specific selftests
152selftest-brig:
153
154# Install hooks.
155
156brig.install-common: installdirs
157	-rm -f $(DESTDIR)$(bindir)/$(GCCBRIG_INSTALL_NAME)$(exeext)
158	$(INSTALL_PROGRAM) gccbrig$(exeext) \
159	$(DESTDIR)$(bindir)/$(GCCBRIG_INSTALL_NAME)$(exeext)
160	-if test -f brig1$(exeext); then \
161	  if test -f gccbrig-cross$(exeext); then \
162	    :; \
163	  else \
164	    rm -f $(DESTDIR)$(bindir)/$(GCCBRIG_TARGET_INSTALL_NAME)$(exeext); \
165	    ( cd $(DESTDIR)$(bindir) && \
166	      $(LN) $(GCCBRIG_INSTALL_NAME)$(exeext) \
167	      $(GCCBRIG_TARGET_INSTALL_NAME)$(exeext) ); \
168	  fi; \
169	fi
170
171brig.install-plugin:
172
173brig.install-info: #$(DESTDIR)$(infodir)/gccbrig.info
174
175brig.install-pdf: doc/gccbrig.pdf
176	@$(NORMAL_INSTALL)
177	test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
178	@for p in doc/gccbrig.pdf; do \
179	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
180	  f=$(pdf__strip_dir) \
181	  echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
182	  $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
183	done
184
185brig.install-html: $(build_htmldir)/brig
186	@$(NORMAL_INSTALL)
187	test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)"
188	@for p in $(build_htmldir)/brig; do \
189	  if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; \
190	  fi; \
191	  f=$(html__strip_dir) \
192	  if test -d "$$d$$p"; then \
193	    echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \
194	    $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
195	    echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \
196	    $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \
197	  else \
198	    echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \
199	    $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \
200	  fi; \
201	done
202
203brig.install-man: $(DESTDIR)$(man1dir)/$(GCCBRIG_INSTALL_NAME)$(man1ext)
204
205$(DESTDIR)$(man1dir)/$(GCCBRIG_INSTALL_NAME)$(man1ext): doc/gccbrig.1 \
206	installdirs
207	-rm -f $@
208	-$(INSTALL_DATA) $< $@
209	-chmod a-x $@
210
211brig.uninstall:
212	rm -rf $(DESTDIR)$(bindir)/$(GCCBRIG_INSTALL_NAME)$(exeext)
213	rm -rf $(DESTDIR)$(man1dir)/$(GCCBRIG_INSTALL_NAME)$(man1ext)
214	rm -rf $(DESTDIR)$(bindir)/$(GCCBRIG_TARGET_INSTALL_NAME)$(exeext)
215	rm -rf $(DESTDIR)$(infodir)/gccbrig.info*
216
217# Clean hooks.
218
219brig.mostlyclean:
220	-rm -f brig/*$(objext)
221	-rm -f brig/*$(coverageexts)
222brig.clean:
223brig.distclean:
224brig.maintainer-clean:
225	-rm -f $(docobjdir)/gccbrig.1
226
227# Stage hooks.
228
229brig.stage1: stage1-start
230	-mv brig/*$(objext) stage1/brig
231brig.stage2: stage2-start
232	-mv brig/*$(objext) stage2/brig
233brig.stage3: stage3-start
234	-mv brig/*$(objext) stage3/brig
235brig.stage4: stage4-start
236	-mv brig/*$(objext) stage4/brig
237brig.stageprofile: stageprofile-start
238	-mv brig/*$(objext) stageprofile/brig
239brig.stagefeedback: stagefeedback-start
240	-mv brig/*$(objext) stagefeedback/brig
241
242CFLAGS-brig/brig-lang.o += -DDEFAULT_TARGET_VERSION=\"$(version)\" \
243	-DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\"
244
245BRIGINCLUDES = -I $(srcdir)/brig -I $(srcdir)/brig/brigfrontend
246
247brig/brig-machine.o: brig/brigfrontend/brig-machine.c
248	$(COMPILE) $(BRIGINCLUDES) $<
249	$(POSTCOMPILE)
250
251brig/%.o: brig/brigfrontend/%.cc
252	$(COMPILE) $(BRIGINCLUDES) $<
253	$(POSTCOMPILE)
254