]> git.ipfire.org Git - thirdparty/gcc.git/blame - gotools/Makefile.am
graphite-scop-detection.c (scop_detection::can_represent_loop): Do not iterate to...
[thirdparty/gcc.git] / gotools / Makefile.am
CommitLineData
bf1de3f0 1# Makefile for gotools
48eae472 2# Copyright (C) 2015-2016 Free Software Foundation, Inc.
bf1de3f0
ILT
3#
4# This file 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 of the License, or
7# (at your option) any later version.
8#
9# This program 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.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING3. If not see
16# <http://www.gnu.org/licenses/>.
17
18ACLOCAL_AMFLAGS = -I ./config -I ../config
19
20gcc_version := $(shell $(GCC_FOR_TARGET) -dumpversion)
21
22libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version)
23
24mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
25PWD_COMMAND = $${PWDCMD-pwd}
26STAMP = echo timestamp >
27
28libgodir = ../$(target_noncanonical)/libgo
29LIBGODEP = $(libgodir)/libgo.la
30
bc998d03
ILT
31LIBGOTOOL = $(libgodir)/libgotool.a
32
6b3762e4
ILT
33if NATIVE
34# Use the compiler we just built.
105b682e 35GOCOMPILER = $(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET)
6b3762e4
ILT
36else
37GOCOMPILER = $(GOC)
38endif
39
bf1de3f0 40GOCFLAGS = $(CFLAGS_FOR_TARGET)
6b3762e4 41GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
bf1de3f0 42
afbc9ecb 43AM_GOCFLAGS = -I $(libgodir)
0b855aa3 44AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
fafa095c 45GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
bf1de3f0 46
eec2130e
ILT
47libgosrcdir = $(srcdir)/../libgo/go
48cmdsrcdir = $(libgosrcdir)/cmd
fac877a1 49libgomiscdir = $(srcdir)/../libgo/misc
bf1de3f0
ILT
50
51go_cmd_go_files = \
da235df8 52 $(cmdsrcdir)/go/alldocs.go \
bf1de3f0 53 $(cmdsrcdir)/go/go11.go \
bc998d03 54 $(cmdsrcdir)/go/main.go
bf1de3f0
ILT
55
56go_cmd_gofmt_files = \
57 $(cmdsrcdir)/gofmt/doc.go \
58 $(cmdsrcdir)/gofmt/gofmt.go \
f98dd1a3 59 $(cmdsrcdir)/gofmt/internal.go \
bf1de3f0
ILT
60 $(cmdsrcdir)/gofmt/rewrite.go \
61 $(cmdsrcdir)/gofmt/simplify.go
62
63go_cmd_cgo_files = \
64 $(cmdsrcdir)/cgo/ast.go \
65 $(cmdsrcdir)/cgo/doc.go \
66 $(cmdsrcdir)/cgo/gcc.go \
67 $(cmdsrcdir)/cgo/godefs.go \
68 $(cmdsrcdir)/cgo/main.go \
69 $(cmdsrcdir)/cgo/out.go \
70 $(cmdsrcdir)/cgo/util.go
71
72GCCGO_INSTALL_NAME := $(shell echo gccgo|sed '$(program_transform_name)')
73GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
74GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
75
76zdefaultcc.go: s-zdefaultcc; @true
77s-zdefaultcc: Makefile
78 echo 'package main' > zdefaultcc.go.tmp
79 echo 'const defaultGCCGO = "$(bindir)/$(GCCGO_INSTALL_NAME)"' >> zdefaultcc.go.tmp
8e51be62
ILT
80 echo 'const defaultCC = "$(GCC_INSTALL_NAME)"' >> zdefaultcc.go.tmp
81 echo 'const defaultCXX = "$(GXX_INSTALL_NAME)"' >> zdefaultcc.go.tmp
c2047754 82 echo 'const defaultPkgConfig = "pkg-config"' >> zdefaultcc.go.tmp
bf1de3f0
ILT
83 $(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
84 $(STAMP) $@
85
fac877a1
ILT
86MOSTLYCLEANFILES = \
87 zdefaultcc.go s-zdefaultcc \
1913c1bf
ILT
88 check-gccgo check-gcc gotools.head *-testlog gotools.sum gotools.log \
89 *.sent
fac877a1
ILT
90
91mostlyclean-local:
92 rm -rf check-go-dir check-runtime-dir cgo-test-dir carchive-test-dir
6b3762e4 93
bf1de3f0
ILT
94if NATIVE
95
96# For a native build we build the programs using the newly built libgo
97# and install them as regular programs.
98
99bin_PROGRAMS = go$(EXEEXT) gofmt$(EXEEXT)
fa3340ec 100noinst_PROGRAMS = cgo$(EXEEXT)
c92e723d 101man_MANS = go.1 gofmt.1
bf1de3f0 102
bc998d03
ILT
103go$(EXEEXT): $(go_cmd_go_files) $(LIBGOTOOL) $(LIBGODEP)
104 $(GOLINK) $(go_cmd_go_files) $(LIBGOTOOL) $(LIBS) $(NET_LIBS)
bf1de3f0 105gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
5bd8d5c1 106 $(GOLINK) $(go_cmd_gofmt_files) $(LIBS) $(NET_LIBS)
bf1de3f0 107cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
5bd8d5c1 108 $(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
bf1de3f0 109
fa3340ec
ILT
110install-exec-local: cgo$(EXEEXT)
111 $(MKDIR_P) $(DESTDIR)$(libexecsubdir)
112 rm -f $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
113 $(INSTALL_PROGRAM) cgo$(exeext) $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
114
115uninstall-local:
116 rm -f $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
117
eec2130e
ILT
118# Run tests using the go tool, and frob the output to look like that
119# generated by DejaGNU. The main output of this is two files:
120# gotools.sum and gotools.log.
121
122# check-head starts generating the log files in DejaGNU format. This
123# is a separate target so that the date is approximately when we start
124# running the tests.
125check-head:
126 @echo "Test Run By $${USER} on `date`" > gotools.head
127 @echo "Native configuration is $(host_triplet)" >> gotools.head
128 @echo >> gotools.head
129 @echo " === gotools tests ===" >> gotools.head
130 @echo >> gotools.head
131
132# check-gccgo is a little shell script that executes gccgo with the
133# options to pick up the newly built libgo.
134check-gccgo: Makefile
1913c1bf
ILT
135 rm -f $@ $@.tmp
136 echo "#!/bin/sh" > $@.tmp
eec2130e 137 abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
1913c1bf
ILT
138 echo "$(GOCOMPILE)" '"$$@"' "-I $${abs_libgodir} -L $${abs_libgodir} -L $${abs_libgodir}/.libs" >> $@.tmp
139 chmod +x $@.tmp
140 mv -f $@.tmp $@
141
142# check-gcc is a little shell script that executes the newly built gcc
143# with the options to pick up the newly built libgo.
144check-gcc: Makefile
145 rm -f $@ $@.tmp
146 echo "#!/bin/sh" > $@.tmp
147 abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
148 echo "$(GCC_FOR_TARGET)" '"$$@"' "-L $${abs_libgodir} -L $${abs_libgodir}/.libs" >> $@.tmp
149 chmod +x $@.tmp
150 mv -f $@.tmp $@
eec2130e
ILT
151
152# CHECK_ENV sets up the environment to run the newly built go tool.
fac877a1 153# If you change this, change ECHO_ENV, below.
bc998d03
ILT
154# The fl shell variable is used to avoid having FAIL appear
155# in the log unnecessarily.
eec2130e
ILT
156CHECK_ENV = \
157 PATH=`echo $(abs_builddir):$${PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
158 export PATH; \
159 GCCGO="$(abs_builddir)/check-gccgo"; \
160 export GCCGO; \
1913c1bf
ILT
161 CC="$(abs_builddir)/check-gcc"; \
162 export CC; \
eec2130e
ILT
163 GCCGOTOOLDIR="$(abs_builddir)"; \
164 export GCCGOTOOLDIR; \
165 GO_TESTING_GOTOOLS=yes; \
166 export GO_TESTING_GOTOOLS; \
167 abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
168 LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
1e9a0e88
ILT
169 export LD_LIBRARY_PATH; \
170 GOROOT=$${abs_libgodir}; \
bc998d03
ILT
171 export GOROOT; \
172 fl1="FA"; fl2="IL"; fl="$${fl1}$${fl2}";
eec2130e 173
fac877a1
ILT
174# ECHO_ENV is a variant of CHECK_ENV to put into a testlog file.
175# It assumes that abs_libgodir is set.
1913c1bf 176ECHO_ENV = PATH=`echo $(abs_builddir):$${PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'` GCCGO='$(abs_builddir)/check-gccgo' CC='$(abs_builddir)/check-gcc' GCCGOTOOLDIR='$(abs_builddir)' GO_TESTING_GOTOOLS=yes LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'` GOROOT=`echo $${abs_libgodir}`
fac877a1 177
eec2130e 178# check-go-tools runs `go test cmd/go` in our environment.
1913c1bf 179check-go-tool: go$(EXEEXT) cgo$(EXEEXT) check-head check-gccgo check-gcc
fac877a1 180 rm -rf check-go-dir cmd_go-testlog
eec2130e
ILT
181 $(MKDIR_P) check-go-dir/src/cmd/go
182 cp $(cmdsrcdir)/go/*.go check-go-dir/src/cmd/go/
bc998d03
ILT
183 cp -r $(cmdsrcdir)/go/internal check-go-dir/src/cmd/go/
184 cp $(libgodir)/zstdpkglist.go check-go-dir/src/cmd/go/internal/load/
185 cp $(libgodir)/zdefaultcc.go check-go-dir/src/cmd/go/internal/cfg/
eec2130e 186 cp -r $(cmdsrcdir)/go/testdata check-go-dir/src/cmd/go/
bc998d03 187 cp -r $(cmdsrcdir)/internal check-go-dir/src/cmd/
fac877a1
ILT
188 @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
189 abs_checkdir=`cd check-go-dir && $(PWD_COMMAND)`; \
190 echo "cd check-go-dir/src/cmd/go && $(ECHO_ENV) GOPATH=$${abs_checkdir} $(abs_builddir)/go$(EXEEXT) test -test.short -test.v" > cmd_go-testlog
eec2130e
ILT
191 $(CHECK_ENV) \
192 GOPATH=`cd check-go-dir && $(PWD_COMMAND)`; \
193 export GOPATH; \
bc998d03 194 (cd check-go-dir/src/cmd/go && $(abs_builddir)/go$(EXEEXT) test -test.short -test.v) >> cmd_go-testlog 2>&1 || echo "--- $${fl} go test cmd/go (0.00s)" >> cmd_go-testlog
eec2130e
ILT
195 grep '^--- ' cmd_go-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/'
196
fac877a1
ILT
197# check-runtime runs `go test runtime` in our environment.
198# The runtime package is also tested as part of libgo,
199# but the runtime tests use the go tool heavily, so testing
200# here too will catch more problems.
1913c1bf 201check-runtime: go$(EXEEXT) cgo$(EXEEXT) check-head check-gccgo check-gcc
fac877a1
ILT
202 rm -rf check-runtime-dir runtime-testlog
203 $(MKDIR_P) check-runtime-dir
204 @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
205 LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
206 GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
207 GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
208 files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \
209 echo "$(ECHO_ENV) GC='$(abs_builddir)/check-gccgo -fgo-compiling-runtime' GOARCH=$${GOARCH} GOOS=$${GOOS} $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles='$${files}' -test.v" > runtime-testlog
210 $(CHECK_ENV) \
211 GC="$${GCCGO} -fgo-compiling-runtime"; \
212 export GC; \
213 GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
214 GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
215 files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \
bc998d03 216 $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles="$${files}" -test.v >> runtime-testlog 2>&1 || echo "--- $${fl} go test runtime (0.00s)" >> runtime-testlog
fac877a1
ILT
217 grep '^--- ' runtime-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/'
218
219# check-cgo-test runs `go test misc/cgo/test` in our environment.
1913c1bf 220check-cgo-test: go$(EXEEXT) cgo$(EXEEXT) check-head check-gccgo check-gcc
fac877a1
ILT
221 rm -rf cgo-test-dir cgo-testlog
222 $(MKDIR_P) cgo-test-dir/misc/cgo
223 cp -r $(libgomiscdir)/cgo/test cgo-test-dir/misc/cgo/
224 @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
225 echo "cd cgo-test-dir/misc/cgo/test && $(ECHO_ENV) GOTRACEBACK=2 $(abs_builddir)/go$(EXEEXT) test -test.short -test.v" > cgo-testlog
226 $(CHECK_ENV) \
227 GOTRACEBACK=2; \
228 export GOTRACEBACK; \
bc998d03 229 (cd cgo-test-dir/misc/cgo/test && $(abs_builddir)/go$(EXEEXT) test -test.short -test.v) >> cgo-testlog 2>&1 || echo "--- $${fl} go test misc/cgo/test (0.00s)" >> cgo-testlog
fac877a1
ILT
230 grep '^--- ' cgo-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/'
231
232# check-carchive-test runs `go test misc/cgo/testcarchive/carchive_test.go`
233# in our environment.
1913c1bf 234check-carchive-test: go$(EXEEXT) cgo$(EXEEXT) check-head check-gccgo check-gcc
fac877a1
ILT
235 rm -rf carchive-test-dir carchive-testlog
236 $(MKDIR_P) carchive-test-dir/misc/cgo
237 cp -r $(libgomiscdir)/cgo/testcarchive carchive-test-dir/misc/cgo/
238 @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
239 echo "cd carchive-test-dir/misc/cgo/testcarchive && $(ECHO_ENV) LIBRARY_PATH=`echo $${abs_libgodir}/.libs` $(abs_builddir)/go$(EXEEXT) test -test.v carchive_test.go" > carchive-testlog
240 $(CHECK_ENV) \
241 LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
242 export LIBRARY_PATH; \
bc998d03 243 (cd carchive-test-dir/misc/cgo/testcarchive && $(abs_builddir)/go$(EXEEXT) test -test.v carchive_test.go) >> carchive-testlog 2>&1 || echo "--- $${fl} go test misc/cgo/testcarchive (0.00s)" >> carchive-testlog
fac877a1
ILT
244 grep '^--- ' carchive-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/'
245
eec2130e 246# The check targets runs the tests and assembles the output files.
fac877a1
ILT
247check: check-head check-go-tool check-runtime check-cgo-test check-carchive-test
248 @mv gotools.head gotools.sum
249 @cp gotools.sum gotools.log
250 @for file in cmd_go-testlog runtime-testlog cgo-testlog carchive-testlog; do \
eec2130e
ILT
251 testname=`echo $${file} | sed -e 's/-testlog//' -e 's|_|/|'`; \
252 echo "Running $${testname}" >> gotools.sum; \
253 echo "Running $${testname}" >> gotools.log; \
254 sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' < $${file} >> gotools.log; \
255 grep '^--- ' $${file} | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' -e 's/SKIP/UNTESTED/' >> gotools.sum; \
256 done
257 @echo >> gotools.sum
258 @echo " === gotools Summary ===" >> gotools.sum
fac877a1 259 @pass=`grep -c '^PASS' gotools.sum`; \
eec2130e
ILT
260 if test "$${pass}" -ne "0"; then \
261 echo "# of expected passes $${pass}" >> gotools.sum; \
262 fi
fac877a1 263 @fail=`grep -c '^FAIL' gotools.sum`; \
eec2130e
ILT
264 if test "$${fail}" -ne "0"; then \
265 echo "# of unexpected failures $${fail}" >> gotools.sum; \
266 fi
fac877a1 267 @untested=`grep -c '^UNTESTED' gotools.sum`; \
eec2130e
ILT
268 if test "$${untested}" -ne "0"; then \
269 echo "# of untested testcases $${untested}" >> gotools.sum; \
270 fi
fac877a1
ILT
271 @echo `echo $(GOC_FOR_TARGET) | sed -e 's/ .*//'` `$(GOC_FOR_TARGET) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> gotools.sum
272 @echo >> gotools.log
273 @echo "runtest completed at `date`" >> gotools.log
274 @if grep '^FAIL' gotools.sum >/dev/null 2>&1; then exit 1; fi
eec2130e 275
fac877a1 276.PHONY: check check-head check-go-tool check-runtime check-cgo-test check-carchive-test
eec2130e 277
bf1de3f0
ILT
278else
279
280# For a non-native build we have to build the programs using a
281# previously built host (or build -> host) Go compiler. We should
282# only do this if such a compiler is available. We also need to get
283# the right values for GOARCH and GOOS in the default build context in
284# the go/build package. Figure this out later.
285
286endif