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