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