1# Makefile.am -- Go library Makefile.
2
3# Copyright 2009 The Go Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style
5# license that can be found in the LICENSE file.
6
7# Process this file with autoreconf to produce Makefile.in.
8
9# Go support.
10SUFFIXES = .c .go .gox .o .obj .lo .a
11
12if LIBGO_IS_RTEMS
13subdirs = testsuite
14endif
15
16SUBDIRS = ${subdirs}
17
18gcc_version := $(shell $(GOC) -dumpversion)
19
20MAINT_CHARSET = latin1
21
22mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
23PWD_COMMAND = $${PWDCMD-pwd}
24STAMP = echo timestamp >
25
26toolexecdir = $(glibgo_toolexecdir)
27toolexeclibdir = $(glibgo_toolexeclibdir)
28toolexeclibgodir = $(nover_glibgo_toolexeclibdir)/go/$(gcc_version)/$(target_alias)
29libexecsubdir = $(libexecdir)/gcc/$(target_alias)/$(gcc_version)
30
31LIBFFI = @LIBFFI@
32LIBFFIINCS = @LIBFFIINCS@
33
34LIBATOMIC = @LIBATOMIC@
35
36WARN_CFLAGS = $(WARN_FLAGS) $(WERROR)
37
38# -I/-D flags to pass when compiling.
39AM_CPPFLAGS = -I $(srcdir)/runtime $(LIBFFIINCS) $(PTHREAD_CFLAGS)
40
41ACLOCAL_AMFLAGS = -I ./config -I ../config
42
43AM_CFLAGS = -fexceptions -fnon-call-exceptions \
44	$(SPLIT_STACK) $(WARN_CFLAGS) \
45	$(STRINGOPS_FLAG) $(HWCAP_CFLAGS) $(OSCFLAGS) \
46	-I $(srcdir)/../libgcc -I $(srcdir)/../libbacktrace \
47	-I $(MULTIBUILDTOP)../../gcc/include
48
49AM_LDFLAGS =
50
51if USING_SPLIT_STACK
52AM_LDFLAGS += -XCClinker $(SPLIT_STACK)
53endif
54
55if LIBGO_IS_AIX
56# Using an import file for libgo avoid requiring to use the -brtl flag
57# when builing a go program
58AM_LDFLAGS += -Wl,-bbigtoc -Wl,-bI:$(srcdir)/libgo.imp
59EXTRA_libgo_la_DEPENDENCIES = libgo.imp
60endif
61
62# Multilib support.
63MAKEOVERRIDES=
64
65# Work around what appears to be a GNU make  handling MAKEFLAGS
66# values defined in terms of make variables, as is the case for CC and
67# friends when we are called from the top level Makefile.
68AM_MAKEFLAGS = \
69	"AR_FLAGS=$(AR_FLAGS)" \
70	"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
71	"CC_FOR_TARGET=$(CC_FOR_TARGET)" \
72	"CFLAGS=$(CFLAGS)" \
73	"CXXFLAGS=$(CXXFLAGS)" \
74	"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
75	"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
76	"GOC_FOR_TARGET=$(GOC_FOR_TARGET)" \
77	"GOC=$(GOC)" \
78	"GOCFLAGS=$(GOCFLAGS)" \
79	"INSTALL=$(INSTALL)" \
80	"INSTALL_DATA=$(INSTALL_DATA)" \
81	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
82	"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
83	"LDFLAGS=$(LDFLAGS)" \
84	"LIBCFLAGS=$(LIBCFLAGS)" \
85	"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
86	"MAKE=$(MAKE)" \
87	"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
88	"PICFLAG=$(PICFLAG)" \
89	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
90	"SHELL=$(SHELL)" \
91	"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
92	"exec_prefix=$(exec_prefix)" \
93	"infodir=$(infodir)" \
94	"libdir=$(libdir)" \
95	"includedir=$(includedir)" \
96	"prefix=$(prefix)" \
97	"tooldir=$(tooldir)" \
98	"gxx_include_dir=$(gxx_include_dir)" \
99	"AR=$(AR)" \
100	"AS=$(AS)" \
101	"LD=$(LD)" \
102	"RANLIB=$(RANLIB)" \
103	"NM=$(NM)" \
104	"NM_FOR_BUILD=$(NM_FOR_BUILD)" \
105	"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
106	"DESTDIR=$(DESTDIR)" \
107	"WERROR=$(WERROR)"
108
109# Subdir rules rely on $(FLAGS_TO_PASS)
110FLAGS_TO_PASS = $(AM_MAKEFLAGS)
111
112if GOC_IS_LLGO
113toolexeclib_LTLIBRARIES = libgo-llgo.la
114toolexeclib_LIBRARIES = libgobegin-llgo.a
115else
116toolexeclib_LTLIBRARIES = libgo.la
117toolexeclib_LIBRARIES = libgobegin.a libgolibbegin.a
118endif
119
120noinst_LIBRARIES = libgotool.a
121
122toolexeclibgo_DATA = \
123	bufio.gox \
124	bytes.gox \
125	context.gox \
126	crypto.gox \
127	encoding.gox \
128	errors.gox \
129	expvar.gox \
130	flag.gox \
131	fmt.gox \
132	hash.gox \
133	html.gox \
134	image.gox \
135	io.gox \
136	log.gox \
137	math.gox \
138	mime.gox \
139	net.gox \
140	os.gox \
141	path.gox \
142	reflect.gox \
143	regexp.gox \
144	runtime.gox \
145	sort.gox \
146	strconv.gox \
147	strings.gox \
148	sync.gox \
149	syscall.gox \
150	testing.gox \
151	time.gox \
152	unicode.gox
153
154toolexeclibgoarchivedir = $(toolexeclibgodir)/archive
155
156toolexeclibgoarchive_DATA = \
157	archive/tar.gox \
158	archive/zip.gox
159
160toolexeclibgocompressdir = $(toolexeclibgodir)/compress
161
162toolexeclibgocompress_DATA = \
163	compress/bzip2.gox \
164	compress/flate.gox \
165	compress/gzip.gox \
166	compress/lzw.gox \
167	compress/zlib.gox
168
169toolexeclibgocontainerdir = $(toolexeclibgodir)/container
170
171toolexeclibgocontainer_DATA = \
172	container/heap.gox \
173	container/list.gox \
174	container/ring.gox
175
176toolexeclibgocryptodir = $(toolexeclibgodir)/crypto
177
178toolexeclibgocrypto_DATA = \
179	crypto/aes.gox \
180	crypto/cipher.gox \
181	crypto/des.gox \
182	crypto/dsa.gox \
183	crypto/ecdsa.gox \
184	crypto/elliptic.gox \
185	crypto/hmac.gox \
186	crypto/md5.gox \
187	crypto/rand.gox \
188	crypto/rc4.gox \
189	crypto/rsa.gox \
190	crypto/sha1.gox \
191	crypto/sha256.gox \
192	crypto/sha512.gox \
193	crypto/subtle.gox \
194	crypto/tls.gox \
195	crypto/x509.gox
196
197toolexeclibgocryptox509dir = $(toolexeclibgocryptodir)/x509
198
199toolexeclibgocryptox509_DATA = \
200	crypto/x509/pkix.gox
201
202toolexeclibgodatabasedir = $(toolexeclibgodir)/database
203
204toolexeclibgodatabase_DATA = \
205	database/sql.gox
206
207toolexeclibgodatabasesqldir = $(toolexeclibgodatabasedir)/sql
208
209toolexeclibgodatabasesql_DATA = \
210	database/sql/driver.gox
211
212toolexeclibgodebugdir = $(toolexeclibgodir)/debug
213
214toolexeclibgodebug_DATA = \
215	debug/dwarf.gox \
216	debug/elf.gox \
217	debug/gosym.gox \
218	debug/macho.gox \
219	debug/pe.gox \
220	debug/plan9obj.gox \
221	debug/xcoff.gox
222
223toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding
224
225toolexeclibgoencoding_DATA = \
226	encoding/ascii85.gox \
227	encoding/asn1.gox \
228	encoding/base32.gox \
229	encoding/base64.gox \
230	encoding/binary.gox \
231	encoding/csv.gox \
232	encoding/gob.gox \
233	encoding/hex.gox \
234	encoding/json.gox \
235	encoding/pem.gox \
236	encoding/xml.gox
237
238toolexeclibgogodir = $(toolexeclibgodir)/go
239
240toolexeclibgogo_DATA = \
241	go/ast.gox \
242	go/build.gox \
243	go/constant.gox \
244	go/doc.gox \
245	go/format.gox \
246	go/importer.gox \
247	go/parser.gox \
248	go/printer.gox \
249	go/scanner.gox \
250	go/token.gox \
251	go/types.gox
252
253toolexeclibgohashdir = $(toolexeclibgodir)/hash
254
255toolexeclibgohash_DATA = \
256	hash/adler32.gox \
257	hash/crc32.gox \
258	hash/crc64.gox \
259	hash/fnv.gox
260
261toolexeclibgohtmldir = $(toolexeclibgodir)/html
262
263toolexeclibgohtml_DATA = \
264	html/template.gox
265
266toolexeclibgoimagedir = $(toolexeclibgodir)/image
267
268toolexeclibgoimage_DATA = \
269	image/color.gox \
270	image/draw.gox \
271	image/gif.gox \
272	image/jpeg.gox \
273	image/png.gox
274
275toolexeclibgoimagecolordir = $(toolexeclibgoimagedir)/color
276
277toolexeclibgoimagecolor_DATA = \
278	image/color/palette.gox
279
280toolexeclibgoindexdir = $(toolexeclibgodir)/index
281
282toolexeclibgoindex_DATA = \
283	index/suffixarray.gox
284
285toolexeclibgoiodir = $(toolexeclibgodir)/io
286
287toolexeclibgoio_DATA = \
288	io/ioutil.gox
289
290toolexeclibgologdir = $(toolexeclibgodir)/log
291
292toolexeclibgolog_DATA = \
293	log/syslog.gox
294
295toolexeclibgomathdir = $(toolexeclibgodir)/math
296
297toolexeclibgomath_DATA = \
298	math/big.gox \
299	math/bits.gox \
300	math/cmplx.gox \
301	math/rand.gox
302
303toolexeclibgomimedir = $(toolexeclibgodir)/mime
304
305toolexeclibgomime_DATA = \
306	mime/multipart.gox \
307	mime/quotedprintable.gox
308
309toolexeclibgonetdir = $(toolexeclibgodir)/net
310
311toolexeclibgonet_DATA = \
312	net/http.gox \
313	net/mail.gox \
314	net/rpc.gox \
315	net/smtp.gox \
316	net/textproto.gox \
317	net/url.gox
318
319toolexeclibgonethttpdir = $(toolexeclibgonetdir)/http
320
321toolexeclibgonethttp_DATA = \
322	net/http/cgi.gox \
323	net/http/cookiejar.gox \
324	net/http/fcgi.gox \
325	net/http/httptest.gox \
326	net/http/httptrace.gox \
327	net/http/httputil.gox \
328	net/http/pprof.gox
329
330toolexeclibgonetrpcdir = $(toolexeclibgonetdir)/rpc
331
332toolexeclibgonetrpc_DATA = \
333	net/rpc/jsonrpc.gox
334
335toolexeclibgoosdir = $(toolexeclibgodir)/os
336
337toolexeclibgoos_DATA = \
338	os/exec.gox \
339	os/signal.gox \
340	os/user.gox
341
342toolexeclibgopathdir = $(toolexeclibgodir)/path
343
344toolexeclibgopath_DATA = \
345	path/filepath.gox
346
347toolexeclibgoregexpdir = $(toolexeclibgodir)/regexp
348
349toolexeclibgoregexp_DATA = \
350	regexp/syntax.gox
351
352toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
353
354toolexeclibgoruntime_DATA = \
355	runtime/debug.gox \
356	runtime/pprof.gox \
357	runtime/trace.gox
358
359toolexeclibgosyncdir = $(toolexeclibgodir)/sync
360
361toolexeclibgosync_DATA = \
362	sync/atomic.gox
363
364toolexeclibgotestingdir = $(toolexeclibgodir)/testing
365
366toolexeclibgotesting_DATA = \
367	testing/iotest.gox \
368	testing/quick.gox
369
370toolexeclibgotestinginternaldir = $(toolexeclibgotestingdir)/internal
371
372toolexeclibgotestinginternal_DATA = \
373	testing/internal/testdeps.gox
374
375toolexeclibgotextdir = $(toolexeclibgodir)/text
376
377toolexeclibgotext_DATA = \
378	text/scanner.gox \
379	text/tabwriter.gox \
380	text/template.gox
381
382toolexeclibgotexttemplatedir = $(toolexeclibgotextdir)/template
383
384toolexeclibgotexttemplate_DATA = \
385	text/template/parse.gox
386
387toolexeclibgounicodedir = $(toolexeclibgodir)/unicode
388
389toolexeclibgounicode_DATA = \
390	unicode/utf16.gox \
391	unicode/utf8.gox
392
393# Some packages are only needed for tests, so unlike the other
394# internal packages nothing will explicitly depend on them.
395# Force them to be built.
396noinst_DATA = \
397	golang_org/x/net/internal/nettest.gox \
398	golang_org/x/net/nettest.gox \
399	internal/testenv.gox \
400	internal/trace.gox \
401	net/internal/socktest.gox \
402	os/signal/internal/pty.gox \
403	runtime/pprof/internal/profile.gox
404
405if LIBGO_IS_RTEMS
406rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
407else
408rtems_task_variable_add_file =
409endif
410
411if LIBGO_IS_LINUX
412runtime_getncpu_file = runtime/getncpu-linux.c
413else
414if LIBGO_IS_DARWIN
415runtime_getncpu_file = runtime/getncpu-bsd.c
416else
417if LIBGO_IS_IRIX
418runtime_getncpu_file = runtime/getncpu-irix.c
419else
420if LIBGO_IS_SOLARIS
421runtime_getncpu_file = runtime/getncpu-solaris.c
422else
423if LIBGO_IS_FREEBSD
424runtime_getncpu_file = runtime/getncpu-bsd.c
425else
426if LIBGO_IS_NETBSD
427runtime_getncpu_file = runtime/getncpu-bsd.c
428else
429if LIBGO_IS_AIX
430runtime_getncpu_file = runtime/getncpu-aix.c
431else
432runtime_getncpu_file = runtime/getncpu-none.c
433endif
434endif
435endif
436endif
437endif
438endif
439endif
440
441runtime_files = \
442	runtime/aeshash.c \
443	runtime/go-assert.c \
444	runtime/go-caller.c \
445	runtime/go-callers.c \
446	runtime/go-cdiv.c \
447	runtime/go-cgo.c \
448	runtime/go-construct-map.c \
449	runtime/go-ffi.c \
450	runtime/go-fieldtrack.c \
451	runtime/go-matherr.c \
452	runtime/go-memclr.c \
453	runtime/go-memcmp.c \
454	runtime/go-memequal.c \
455	runtime/go-memmove.c \
456	runtime/go-nanotime.c \
457	runtime/go-now.c \
458	runtime/go-nosys.c \
459	runtime/go-reflect-call.c \
460	runtime/go-runtime-error.c \
461	runtime/go-setenv.c \
462	runtime/go-signal.c \
463	runtime/go-strslice.c \
464	runtime/go-typedesc-equal.c \
465	runtime/go-unsafe-pointer.c \
466	runtime/go-unsetenv.c \
467	runtime/go-unwind.c \
468	runtime/go-varargs.c \
469	runtime/env_posix.c \
470	runtime/panic.c \
471	runtime/print.c \
472	runtime/proc.c \
473	runtime/runtime_c.c \
474	runtime/stack.c \
475	runtime/thread.c \
476	runtime/yield.c \
477	$(rtems_task_variable_add_file) \
478	$(runtime_getncpu_file)
479
480version.go: s-version; @true
481s-version: Makefile
482	rm -f version.go.tmp
483	echo "package sys" > version.go.tmp
484	echo 'func init() { DefaultGoroot = "$(prefix)" }' >> version.go.tmp
485	echo 'const TheVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp
486	echo 'const Goexperiment = ``' >> version.go.tmp
487	echo 'const GOARCH = "'$(GOARCH)'"' >> version.go.tmp
488	echo 'const GOOS = "'$(GOOS)'"' >> version.go.tmp
489	echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp
490	echo >> version.go.tmp
491	echo "type ArchFamilyType int" >> version.go.tmp
492	echo >> version.go.tmp
493	echo "const (" >> version.go.tmp
494	echo "	UNKNOWN ArchFamilyType = iota" >> version.go.tmp
495	for a in $(ALLGOARCHFAMILY); do \
496	  echo "	$${a}" >> version.go.tmp; \
497	done
498	echo ")" >> version.go.tmp
499	echo >> version.go.tmp
500	for a in $(ALLGOARCH); do \
501	  f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
502	  n="$${f}`echo $${a} | sed -e 's/.//'`"; \
503	  if test "$${a}" = "$(GOARCH)"; then \
504	    echo "const Goarch$${n} = 1" >> version.go.tmp; \
505	  else \
506	    echo "const Goarch$${n} = 0" >> version.go.tmp; \
507	  fi; \
508	done
509	echo >> version.go.tmp
510	echo "const (" >> version.go.tmp
511	echo "  ArchFamily = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) family`" >> version.go.tmp
512	echo "  BigEndian = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) bigendian`" >> version.go.tmp
513	echo "  CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> version.go.tmp
514	echo "  DefaultPhysPageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) defaultphyspagesize`" >> version.go.tmp
515	echo "  HugePageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) hugepagesize`" >> version.go.tmp
516	echo "  Int64Align = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) int64align`" >> version.go.tmp
517	echo "  MinFrameSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) minframesize`" >> version.go.tmp
518	echo "  PCQuantum = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) pcquantum`" >> version.go.tmp
519	echo ")" >> version.go.tmp
520	echo >> version.go.tmp
521	for a in $(ALLGOOS); do \
522	  f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
523	  n="$${f}`echo $${a} | sed -e 's/.//'`"; \
524	  if test "$${a}" = "$(GOOS)"; then \
525	    echo "const Goos$${n} = 1" >> version.go.tmp; \
526	  else \
527	    echo "const Goos$${n} = 0" >> version.go.tmp; \
528	  fi; \
529	done
530	echo >> version.go.tmp
531	echo "type Uintreg uintptr" >> version.go.tmp
532	$(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
533	$(STAMP) $@
534
535objabi.go: s-objabi; @true
536s-objabi: Makefile
537	rm -f objabi.go.tmp
538	echo "package objabi" > objabi.go.tmp
539	echo "import \"runtime\"" >> objabi.go.tmp
540	echo 'func init() { defaultGOROOT = `$(prefix)` }' >> objabi.go.tmp
541	echo 'const defaultGO386 = `sse2`' >> objabi.go.tmp
542	echo 'const defaultGOARM = `5`' >> objabi.go.tmp
543	echo 'const defaultGOMIPS = `hardfloat`' >> objabi.go.tmp
544	echo 'const defaultGOOS = runtime.GOOS' >> objabi.go.tmp
545	echo 'const defaultGOARCH = runtime.GOARCH' >> objabi.go.tmp
546	echo 'const defaultGO_EXTLINK_ENABLED = ``' >> objabi.go.tmp
547	echo 'const version = `'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'`' >> objabi.go.tmp
548	echo 'const stackGuardMultiplier = 1' >> objabi.go.tmp
549	echo 'const goexperiment = ``' >> objabi.go.tmp
550	$(SHELL) $(srcdir)/mvifdiff.sh objabi.go.tmp objabi.go
551	$(STAMP) $@
552
553gccgosizes.go: s-gccgosizes; @true
554s-gccgosizes: Makefile goarch.sh
555	rm -f gccgosizes.go.tmp
556	echo "package types" > gccgosizes.go.tmp
557	echo >> gccgosizes.go.tmp
558	echo "var gccgoArchSizes = map[string]*StdSizes{" >> gccgosizes.go.tmp
559	for a in $(ALLGOARCH); do \
560	  ptrsize=`$(SHELL) $(srcdir)/goarch.sh $$a ptrsize`; \
561	  maxalign=`$(SHELL) $(srcdir)/goarch.sh $$a maxalign`; \
562	  echo "	\"$$a\": {$${ptrsize}, $${maxalign}}," >> gccgosizes.go.tmp; \
563	done
564	echo "}" >> gccgosizes.go.tmp
565	$(SHELL) $(srcdir)/mvifdiff.sh gccgosizes.go.tmp gccgosizes.go
566	$(STAMP) $@
567
568runtime_sysinfo.go: s-runtime_sysinfo; @true
569s-runtime_sysinfo: $(srcdir)/mkrsysinfo.sh gen-sysinfo.go
570	GOARCH=$(GOARCH) GOOS=$(GOOS) $(SHELL) $(srcdir)/mkrsysinfo.sh
571	$(SHELL) $(srcdir)/mvifdiff.sh tmp-runtime_sysinfo.go runtime_sysinfo.go
572	$(STAMP) $@
573
574sigtab.go: s-sigtab; @true
575s-sigtab: $(srcdir)/mksigtab.sh gen-sysinfo.go
576	GOOS=$(GOOS) $(SHELL) $(srcdir)/mksigtab.sh > tmp-sigtab.go
577	$(SHELL) $(srcdir)/mvifdiff.sh tmp-sigtab.go sigtab.go
578	$(STAMP) $@
579
580GCCGO_INSTALL_NAME := $(shell echo gccgo|sed '$(program_transform_name)')
581GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
582GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
583
584zdefaultcc.go: s-zdefaultcc; @true
585s-zdefaultcc: Makefile
586	echo 'package cfg' > zdefaultcc.go.tmp
587	echo >> zdefaultcc.go.tmp
588	echo 'func DefaultGCCGO(goos, goarch string) string { return "$(bindir)/$(GCCGO_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
589	echo 'func DefaultCC(goos, goarch string) string { return "$(GCC_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
590	echo 'func DefaultCXX(goos, goarch string) string { return "$(GXX_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
591	echo 'const DefaultPkgConfig = "pkg-config"' >> zdefaultcc.go.tmp
592	echo 'var OSArchSupportsCgo = map[string]bool{}' >> zdefaultcc.go.tmp
593	$(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
594	$(STAMP) $@
595
596# _Complex_lock and _Reader_lock are Go translations of some AIX system
597# types and should not be exported back to C
598# semt is a Go translation of the C type sem_t; it fails to convert on
599# some systems and need not be exported back to C.
600# sigset conflicts with system type sigset on AIX, so we need to rename it
601runtime.inc: s-runtime-inc; @true
602s-runtime-inc: runtime.lo Makefile
603	rm -f runtime.inc.tmp2 runtime.inc.tmp3
604	grep -v "#define _" runtime.inc.tmp | grep -v "#define [cm][01234] " | grep -v "#define empty " > runtime.inc.tmp2
605	for pattern in '_[GP][a-z]' _Max _Lock _Sig _Trace _MHeap _Num; do \
606	  grep "#define $$pattern" runtime.inc.tmp >> runtime.inc.tmp2; \
607	done
608	for TYPE in _Complex_lock _Reader_lock semt; do \
609	  sed -e '/struct '$${TYPE}' {/,/^}/s/^.*$$//' runtime.inc.tmp2 > runtime.inc.tmp3; \
610	  mv runtime.inc.tmp3 runtime.inc.tmp2; \
611	done
612	sed -e 's/sigset/sigset_go/' runtime.inc.tmp2 > runtime.inc.tmp3
613	$(SHELL) $(srcdir)/mvifdiff.sh runtime.inc.tmp3 runtime.inc
614	rm -f runtime.inc.tmp2 runtime.inc.tmp3
615	$(STAMP) $@
616
617noinst_DATA += zdefaultcc.go
618
619# Generate the list of go std packages that were included in libgo
620zstdpkglist.go: s-zstdpkglist; @true
621s-zstdpkglist: Makefile
622	rm -f zstdpkglist.go.tmp
623	echo 'package build' > zstdpkglist.go.tmp
624	echo "" >> zstdpkglist.go.tmp
625	echo 'var stdpkg = map[string]bool{' >> zstdpkglist.go.tmp
626	echo $(libgo_go_objs) 'unsafe.lo' 'runtime/cgo.lo' | sed 's|[a-z0-9_/]*_c\.lo||g' | sed 's|\([a-z0-9_/]*\)\.lo|"\1": true,|g' >> zstdpkglist.go.tmp
627	echo '}' >> zstdpkglist.go.tmp
628	$(SHELL) $(srcdir)/mvifdiff.sh zstdpkglist.go.tmp zstdpkglist.go
629	$(STAMP) $@
630
631if LIBGO_IS_LINUX
632syscall_epoll_file = epoll.go
633else
634syscall_epoll_file =
635endif
636
637libcalls.go: s-libcalls; @true
638s-libcalls: libcalls-list go/syscall/mksyscall.awk $(srcdir)/go/syscall/*.go
639	rm -f libcalls.go.tmp
640	$(AWK) -f $(srcdir)/go/syscall/mksyscall.awk `cat libcalls-list` > libcalls.go.tmp
641	$(SHELL) $(srcdir)/mvifdiff.sh libcalls.go.tmp libcalls.go
642	$(STAMP) $@
643
644libcalls-list: s-libcalls-list; @true
645s-libcalls-list: Makefile $(srcdir)/go/syscall/*.go
646	rm -f libcalls-list.tmp
647	$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/syscall $(matchargs_syscall) > libcalls-list.tmp
648	$(SHELL) $(srcdir)/mvifdiff.sh libcalls-list.tmp libcalls-list
649	$(STAMP) $@
650
651syscall_arch.go: s-syscall_arch; @true
652s-syscall_arch: Makefile
653	rm -f syscall_arch.go.tmp
654	echo "package syscall" > syscall_arch.go.tmp
655	echo 'const ARCH = "'$(GOARCH)'"' >> syscall_arch.go.tmp
656	echo 'const OS = "'$(GOOS)'"' >> syscall_arch.go.tmp
657	$(SHELL) $(srcdir)/mvifdiff.sh syscall_arch.go.tmp syscall_arch.go
658	$(STAMP) $@
659
660SYSINFO_FLAGS = \
661	$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
662	$(CPPFLAGS) $(OSCFLAGS) -O
663
664gen-sysinfo.go: s-gen-sysinfo; @true
665s-gen-sysinfo: $(srcdir)/sysinfo.c config.h
666	$(CC) $(SYSINFO_FLAGS) -fdump-go-spec=tmp-gen-sysinfo.go -std=gnu99 -S -o sysinfo.s $(srcdir)/sysinfo.c
667	rm -f sysinfo.s
668	$(SHELL) $(srcdir)/mvifdiff.sh tmp-gen-sysinfo.go gen-sysinfo.go
669	$(STAMP) $@
670
671errno.i: s-errno; @true
672s-errno:
673	echo '#include <errno.h>' | $(CC) $(SYSINFO_FLAGS) -x c - -E -dM > tmp-errno.i
674	$(SHELL) $(srcdir)/mvifdiff.sh tmp-errno.i errno.i
675	$(STAMP) $@
676
677sysinfo.go: s-sysinfo; @true
678s-sysinfo: $(srcdir)/mksysinfo.sh gen-sysinfo.go errno.i
679	GOARCH=$(GOARCH) GOOS=$(GOOS) $(SHELL) $(srcdir)/mksysinfo.sh
680	$(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go
681	$(STAMP) $@
682
683# The epoll struct has an embedded union and is packed on x86_64,
684# which is too complicated for mksysinfo.sh.  We find the offset of
685# the only field we care about in configure.ac, and generate the
686# struct here.
687epoll.go: s-epoll; @true
688s-epoll: Makefile
689	rm -f epoll.go.tmp
690	echo 'package syscall' > epoll.go.tmp
691	echo 'type EpollEvent struct {' >> epoll.go.tmp
692	echo '	Events uint32' >> epoll.go.tmp
693	case "$(SIZEOF_STRUCT_EPOLL_EVENT),$(STRUCT_EPOLL_EVENT_FD_OFFSET)" in \
694	0,0) echo 1>&2 "*** struct epoll_event data.fd offset unknown"; \
695	   exit 1; ;; \
696	8,4) echo '	Fd int32' >> epoll.go.tmp; ;; \
697	12,4) echo '	Fd int32' >> epoll.go.tmp; \
698	   echo '	Pad [4]byte' >> epoll.go.tmp; ;; \
699	12,8) echo '	Pad [4]byte' >> epoll.go.tmp; \
700	   echo '	Fd int32' >> epoll.go.tmp; ;; \
701	16,8) echo '	Pad [4]byte' >> epoll.go.tmp; \
702	   echo '	Fd int32' >> epoll.go.tmp; \
703	   echo '	Pad2 [4]byte' >> epoll.go.tmp; ;; \
704	*) echo 1>&2 "*** struct epoll_event unsupported"; \
705	   exit 1; ;; \
706	esac
707	echo '}' >> epoll.go.tmp
708	$(SHELL) $(srcdir)/mvifdiff.sh epoll.go.tmp epoll.go
709	$(STAMP) $@
710
711if LIBGO_IS_LINUX
712syscall_lib_clone_lo = syscall/clone_linux.lo
713else
714syscall_lib_clone_lo =
715endif
716
717PACKAGES = \
718	archive/tar \
719	archive/zip \
720	bufio \
721	bytes \
722	compress/bzip2 \
723	compress/flate \
724	compress/gzip \
725	compress/lzw \
726	compress/zlib \
727	container/heap \
728	container/list \
729	container/ring \
730	context \
731	crypto \
732	crypto/aes \
733	crypto/cipher \
734	crypto/des \
735	crypto/dsa \
736	crypto/ecdsa \
737	crypto/elliptic \
738	crypto/hmac \
739	crypto/internal/cipherhw \
740	crypto/md5 \
741	crypto/rand \
742	crypto/rc4 \
743	crypto/rsa \
744	crypto/sha1 \
745	crypto/sha256 \
746	crypto/sha512 \
747	crypto/subtle \
748	crypto/tls \
749	crypto/x509 \
750	crypto/x509/pkix \
751	database/sql \
752	database/sql/driver \
753	debug/dwarf \
754	debug/elf \
755	debug/gosym \
756	debug/macho \
757	debug/pe \
758	debug/plan9obj \
759	debug/xcoff \
760	encoding \
761	encoding/ascii85 \
762	encoding/asn1 \
763	encoding/base32 \
764	encoding/base64 \
765	encoding/binary \
766	encoding/csv \
767	encoding/gob \
768	encoding/hex \
769	encoding/json \
770	encoding/pem \
771	encoding/xml \
772	errors \
773	expvar \
774	flag \
775	fmt \
776	go/ast \
777	go/build \
778	go/constant \
779	go/doc \
780	go/format \
781	go/importer \
782	go/internal/gccgoimporter \
783	go/internal/gcimporter \
784	go/internal/srcimporter \
785	go/parser \
786	go/printer \
787	go/scanner \
788	go/token \
789	go/types \
790	golang_org/x/crypto/chacha20poly1305 \
791	golang_org/x/crypto/chacha20poly1305/internal/chacha20 \
792	golang_org/x/crypto/cryptobyte \
793	golang_org/x/crypto/cryptobyte/asn1 \
794	golang_org/x/crypto/curve25519 \
795	golang_org/x/crypto/poly1305 \
796	golang_org/x/net/http2/hpack \
797	golang_org/x/net/idna \
798	golang_org/x/net/internal/nettest \
799	golang_org/x/net/lex/httplex \
800	golang_org/x/net/nettest \
801	golang_org/x/net/proxy \
802	golang_org/x/text/secure/bidirule \
803	golang_org/x/text/transform \
804	golang_org/x/text/unicode/bidi \
805	golang_org/x/text/unicode/norm \
806	golang_org/x/text/width \
807	hash \
808	hash/adler32 \
809	hash/crc32 \
810	hash/crc64 \
811	hash/fnv \
812	html \
813	html/template \
814	image \
815	image/color \
816	image/color/palette \
817	image/draw \
818	image/gif \
819	image/internal/imageutil \
820	image/jpeg \
821	image/png \
822	index/suffixarray \
823	internal/nettrace \
824	internal/poll \
825	internal/race \
826	internal/singleflight \
827	internal/syscall/unix \
828	internal/testenv \
829	internal/testlog \
830	internal/trace \
831	io \
832	io/ioutil \
833	log \
834	log/syslog \
835	math \
836	math/big \
837	math/bits \
838	math/cmplx \
839	math/rand \
840	mime \
841	mime/multipart \
842	mime/quotedprintable \
843	net \
844	net/http \
845	net/http/cgi \
846	net/http/cookiejar \
847	net/http/fcgi \
848	net/http/httptest \
849	net/http/httptrace \
850	net/http/httputil \
851	net/http/internal \
852	net/http/pprof \
853	net/internal/socktest \
854	net/mail \
855	net/rpc \
856	net/rpc/jsonrpc \
857	net/smtp \
858	net/textproto \
859	net/url \
860	os \
861	os/exec \
862	os/signal \
863	os/signal/internal/pty \
864	os/user \
865	path \
866	path/filepath \
867	reflect \
868	regexp \
869	regexp/syntax \
870	runtime \
871	runtime/debug \
872	runtime/internal/atomic \
873	runtime/internal/sys \
874	runtime/pprof \
875	runtime/pprof/internal/profile \
876	runtime/trace \
877	sort \
878	strconv \
879	strings \
880	sync \
881	sync/atomic \
882	syscall \
883	testing \
884	testing/internal/testdeps \
885	testing/iotest \
886	testing/quick \
887	text/scanner \
888	text/tabwriter \
889	text/template \
890	text/template/parse \
891	time \
892	unicode \
893	unicode/utf16 \
894	unicode/utf8
895
896libgo_go_objs = \
897	$(addsuffix .lo,$(PACKAGES)) \
898	bytes/index.lo \
899	reflect/makefunc_ffi_c.lo \
900	strings/index.lo \
901	$(syscall_lib_clone_lo) \
902	syscall/errno.lo \
903	syscall/signame.lo \
904	syscall/wait.lo \
905	$(golang_org_x_net_lif_lo) \
906	$(golang_org_x_net_route_lo) \
907	log/syslog/syslog_c.lo \
908	$(os_lib_inotify_lo) \
909	runtime/internal/atomic_c.lo \
910	sync/atomic_c.lo
911
912libgo_ldflags = \
913	-version-info $(libtool_VERSION) $(PTHREAD_CFLAGS) $(AM_LDFLAGS)
914
915libgo_libadd = \
916	$(libgo_go_objs) ../libbacktrace/libbacktrace.la \
917	$(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)
918
919libgo_la_SOURCES = $(runtime_files)
920libgo_la_LDFLAGS = $(libgo_ldflags)
921libgo_la_LIBADD = $(libgo_libadd)
922
923libgo_llgo_la_SOURCES = $(runtime_files)
924libgo_llgo_la_LDFLAGS = $(libgo_ldflags)
925libgo_llgo_la_LIBADD = $(libgo_libadd)
926
927libgobegin_a_SOURCES = \
928	runtime/go-main.c
929
930libgobegin_llgo_a_SOURCES = \
931	runtime/go-main.c
932
933# Use -fPIC for libgobegin so that it can be put in a PIE.
934libgobegin_a_CFLAGS = $(AM_CFLAGS) -fPIC
935libgobegin_llgo_a_CFLAGS = $(AM_CFLAGS) -fPIC
936
937libgolibbegin_a_SOURCES = \
938	runtime/go-libmain.c
939
940libgolibbegin_a_CFLAGS = $(AM_CFLAGS) -fPIC
941
942GOTOOL_PACKAGES = \
943	cmd/go/internal/base \
944	cmd/go/internal/bug \
945	cmd/go/internal/cache \
946	cmd/go/internal/cfg \
947	cmd/go/internal/clean \
948	cmd/go/internal/cmdflag \
949	cmd/go/internal/doc \
950	cmd/go/internal/envcmd \
951	cmd/go/internal/fix \
952	cmd/go/internal/fmtcmd \
953	cmd/go/internal/generate \
954	cmd/go/internal/get \
955	cmd/go/internal/help \
956	cmd/go/internal/list \
957	cmd/go/internal/load \
958	cmd/go/internal/run \
959	cmd/go/internal/str \
960	cmd/go/internal/test \
961	cmd/go/internal/tool \
962	cmd/go/internal/version \
963	cmd/go/internal/vet \
964	cmd/go/internal/web \
965	cmd/go/internal/work \
966	cmd/internal/browser \
967	cmd/internal/buildid \
968	cmd/internal/edit \
969	cmd/internal/objabi \
970	cmd/internal/test2json \
971	cmd/vet/internal/cfg \
972	cmd/vet/internal/whitelist
973
974libgotool_a_SOURCES =
975libgotool_a_DEPENDENCIES = $(addsuffix .lo,$(GOTOOL_PACKAGES))
976libgotool_a_LIBADD = $(addsuffix .o,$(GOTOOL_PACKAGES))
977
978define STATIC_template
979$(subst -,_,$(subst .,_,$(subst /,_,$(1))))_GOCFLAGS = -static
980endef
981
982$(foreach package,$(GOTOOL_PACKAGES),$(eval $(call STATIC_template,$(package).lo)))
983
984# Make sure runtime.inc is built before compiling any .c file.
985$(libgo_la_OBJECTS): runtime.inc
986$(libgo_llgo_la_OBJECTS): runtime.inc
987$(libgobegin_a_OBJECTS): runtime.inc
988$(libgobegin_llgo_a_OBJECTS): runtime.inc
989$(libgolibbegin_a_OBJECTS): runtime.inc
990
991LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
992
993GOCFLAGS = $(CFLAGS)
994AM_GOCFLAGS = $(STRINGOPS_FLAG) $(GO_SPLIT_STACK)
995GOCOMPILE = $(GOC) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_GOCFLAGS) $(GOCFLAGS)
996
997LTGOCOMPILE = $(LIBTOOL) --tag GO --mode=compile $(GOC) $(INCLUDES) \
998	$(AM_GOCFLAGS) $(GOCFLAGS)
999
1000GOLINK = $(LIBTOOL) --tag GO --mode-link $(GOC) \
1001	$(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_GOCFLAGS) $(LTLDFLAGS) -o $@
1002
1003# Build the dependencies for a Go package.
1004BUILDDEPS = \
1005	$(MKDIR_P) $(@D); \
1006	dir=`echo $@ | sed -e 's/.lo.dep$$//'`; \
1007	files=`$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/$$dir --extrafiles="$(extra_go_files_$(subst /,_,$(subst .lo.dep,,$@)))" $(matchargs_$(subst /,_,$(subst .lo.dep,,$@)))`; \
1008	$(SHELL) $(srcdir)/godeps.sh `echo $@ | sed -e 's/.dep$$//'` $$files > $@.tmp; \
1009	if ! cmp $@.tmp $@ >/dev/null 2>/dev/null; then \
1010	  rm -f `echo $@ | sed -e 's/\.dep$$//'`; \
1011	fi; \
1012	mv -f $@.tmp $@
1013
1014# Build the .go files for a package, generating a .lo file.
1015BUILDPACKAGE = \
1016	$(MKDIR_P) $(@D); \
1017	files=`echo $^ | sed -e 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; \
1018	$(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's|golang_org|vendor/golang_org|'` $($(subst -,_,$(subst .,_,$(subst /,_,$@)))_GOCFLAGS) -o $@ $$files
1019
1020# How to build a .gox file from a .lo file.
1021# Matching .o file can either be in the same directory as the .lo (non-PIC
1022# object) or in the .libs directory (PIC object).
1023BUILDGOX = \
1024	f="$(basename $<).o"; \
1025	if test ! -f $$f; then \
1026	  f="$(basename $(<D)/.libs/$(<F)).o"; \
1027	fi; \
1028	$(OBJCOPY) -j .go_export $$f $@.tmp; \
1029	$(SHELL) $(srcdir)/mvifdiff.sh $@.tmp `echo $@ | sed -e 's/s-gox/gox/'`
1030
1031GOTESTFLAGS =
1032GOBENCH =
1033
1034# Check a package.
1035CHECK = \
1036	GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \
1037	export GC; \
1038	GOLIBS="$(extra_check_libs_$(subst /,_,$(@D))) $(MATH_LIBS) $(NET_LIBS) $(LIBS)"; \
1039	export GOLIBS; \
1040	RUNTESTFLAGS="$(RUNTESTFLAGS)"; \
1041	export RUNTESTFLAGS; \
1042	MAKE="$(MAKE)"; \
1043	export MAKE; \
1044	NM="$(NM)"; \
1045	export NM; \
1046	libgccdir=`${GOC} ${GOCFLAGS} -print-libgcc-file-name | sed -e 's|/[^/]*$$||'`; \
1047	LD_LIBRARY_PATH="`${PWD_COMMAND}`/.libs:$${libgccdir}:${LD_LIBRARY_PATH}"; \
1048	LD_LIBRARY_PATH=`echo $${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
1049	export LD_LIBRARY_PATH; \
1050	$(MKDIR_P) $(@D); \
1051	rm -f $@-testsum $@-testlog; \
1052	files=`$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/$(@D) --extrafiles="$(extra_go_files_$(subst /,_,$(@D)))" $(matchargs_$(subst /,_,$(@D)))`; \
1053	if test "$(USE_DEJAGNU)" = "yes"; then \
1054	  $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --testname="$(@D)" $(GOTESTFLAGS); \
1055	elif test "$(GOBENCH)" != ""; then \
1056	  $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --bench="$(GOBENCH)" $(GOTESTFLAGS); \
1057	else \
1058	  if $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" $(GOTESTFLAGS) >>$@-testlog 2>&1; then \
1059	    echo "PASS: $(@D)" >> $@-testlog; \
1060	    echo "PASS: $(@D)"; \
1061	    echo "PASS: $(@D)" > $@-testsum; \
1062	  else \
1063	    echo "FAIL: $(@D)" >> $@-testlog; \
1064	    cat $@-testlog; \
1065	    echo "FAIL: $(@D)" > $@-testsum; \
1066	    exit 1; \
1067	  fi; \
1068	fi
1069
1070# Build all packages before checking any.
1071CHECK_DEPS = \
1072	$(toolexeclibgo_DATA) \
1073	$(toolexeclibgoarchive_DATA) \
1074	$(toolexeclibgocompress_DATA) \
1075	$(toolexeclibgocontainer_DATA) \
1076	$(toolexeclibgocrypto_DATA) \
1077	$(toolexeclibgodebug_DATA) \
1078	$(toolexeclibgoencoding_DATA) \
1079	$(toolexeclibgogo_DATA) \
1080	$(toolexeclibgohash_DATA) \
1081	$(toolexeclibgoimage_DATA) \
1082	$(toolexeclibgoindex_DATA) \
1083	$(toolexeclibgoio_DATA) \
1084	$(toolexeclibgolog_DATA) \
1085	$(toolexeclibgomath_DATA) \
1086	$(toolexeclibgomime_DATA) \
1087	$(toolexeclibgonet_DATA) \
1088	$(toolexeclibgonethttp_DATA) \
1089	$(toolexeclibgoos_DATA) \
1090	$(toolexeclibgopath_DATA) \
1091	$(toolexeclibgorpc_DATA) \
1092	$(toolexeclibgoruntime_DATA) \
1093	$(toolexeclibgosync_DATA) \
1094	$(toolexeclibgotesting_DATA) \
1095	$(toolexeclibgotext_DATA) \
1096	$(toolexeclibgotexttemplate_DATA) \
1097	$(toolexeclibgounicode_DATA) \
1098	$(noinst_DATA) \
1099	$(noinst_LIBRARIES)
1100
1101if GOC_IS_LLGO
1102CHECK_DEPS += libgo-llgo.la libgobegin-llgo.a
1103else
1104CHECK_DEPS += libgo.la libgobegin.a
1105endif
1106
1107# PACKAGE_template defines the rules for each package.
1108# For example, for the package bufio, it produces:
1109#
1110# @go_include@ bufio.lo.dep
1111# bufio.lo.dep: $(srcdir)/go/bufio/*.go
1112# 	$(BUILDDEPS)
1113# bufio.lo:
1114# 	$(BUILDPACKAGE)
1115# bufio/check: $(CHECK_DEPS)
1116# 	@$(CHECK)
1117# .PHONY: bufio/check
1118#
1119# This is invoked with $(1) set to a package, which is a directory name,
1120# such as "bufio" or "archive/tar".
1121define PACKAGE_template
1122@go_include@ $(1).lo.dep
1123$(1).lo.dep: $(srcdir)/go/$(1)/*.go
1124	$$(BUILDDEPS)
1125$(1).lo:
1126	$$(BUILDPACKAGE)
1127$(1)/check: $$(CHECK_DEPS)
1128	@$$(CHECK)
1129.PHONY: $(1)/check
1130$(1).gox: $(1).s-gox; @true
1131$(1).s-gox: $(1).lo
1132	$$(BUILDGOX)
1133	$$(STAMP) $$@
1134endef
1135
1136# This line expands PACKAGE_template once for each package name listed
1137# in $(PACKAGES).
1138$(foreach package,$(PACKAGES),$(eval $(call PACKAGE_template,$(package))))
1139$(foreach package,$(GOTOOL_PACKAGES),$(eval $(call PACKAGE_template,$(package))))
1140
1141# Pass -ffp-contract=off, or 386-specific options, when building the
1142# math package.  MATH_FLAG is defined in configure.ac.
1143math_lo_GOCFLAGS = $(MATH_FLAG)
1144math_check_GOCFLAGS = $(MATH_FLAG)
1145
1146# Add the generated file runtime_sysinfo.go to the runtime package.
1147extra_go_files_runtime = runtime_sysinfo.go sigtab.go
1148runtime.lo.dep: $(extra_go_files_runtime)
1149
1150# Add generated files to the syscall package.
1151extra_go_files_syscall = \
1152	libcalls.go \
1153	sysinfo.go \
1154	syscall_arch.go \
1155	$(syscall_epoll_file)
1156syscall.lo.dep: $(extra_go_files_syscall)
1157
1158# Pass -fgo-compiling-runtime when compiling the runtime package.
1159runtime_lo_GOCFLAGS = -fgo-c-header=runtime.inc.tmp -fgo-compiling-runtime
1160runtime_check_GOCFLAGS = -fgo-compiling-runtime
1161runtime_internal_atomic_lo_GOCFLAGS = -fgo-compiling-runtime
1162runtime_internal_atomic_lo_check_GOCFLAGS = -fgo-compiling-runtime
1163runtime_internal_sys_lo_GOCFLAGS = -fgo-compiling-runtime
1164runtime_internal_sys_lo_check_GOCFLAGS = -fgo-compiling-runtime
1165
1166# If libffi is supported (the normal case) use the ffi build tag for
1167# the runtime package.
1168if USE_LIBFFI
1169matchargs_runtime = --tag=libffi
1170else
1171matchargs_runtime =
1172endif
1173
1174# At least for now, we need -static-libgo for this test, because
1175# otherwise we can't get the line numbers.
1176# Also use -fno-inline to get better results from the memory profiler.
1177runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline
1178
1179extra_go_files_runtime_internal_sys = version.go
1180runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys)
1181
1182extra_go_files_go_build = zstdpkglist.go
1183go/build.lo.dep: $(extra_go_files_go_build)
1184
1185extra_go_files_go_types = gccgosizes.go
1186go/types.lo.dep: $(extra_go_files_go_types)
1187
1188extra_go_files_cmd_internal_objabi = objabi.go
1189cmd/internal/objabi.lo.dep: $(extra_go_files_cmd_internal_objabi)
1190
1191extra_go_files_cmd_go_internal_cfg = zdefaultcc.go
1192cmd/go/internal/cfg.lo.dep: $(extra_go_files_cmd_go_internal_cfg)
1193
1194extra_check_libs_cmd_go_internal_cache = $(abs_builddir)/libgotool.a
1195extra_check_libs_cmd_go_internal_generate = $(abs_builddir)/libgotool.a
1196extra_check_libs_cmd_go_internal_get = $(abs_builddir)/libgotool.a
1197extra_check_libs_cmd_go_internal_load = $(abs_builddir)/libgotool.a
1198extra_check_libs_cmd_go_internal_work = $(abs_builddir)/libgotool.a
1199
1200extra_check_libs_cmd_vet_internal_cfg = $(abs_builddir)/libgotool.a
1201
1202# FIXME: The following C files may as well move to the runtime
1203# directory and be treated like other C files.
1204
1205# Use C code to speed up {bytes,strings}.IndexByte and friends.
1206bytes/index.lo: go/bytes/indexbyte.c runtime.inc
1207	@$(MKDIR_P) bytes
1208	$(LTCOMPILE) -c -o $@ $(srcdir)/go/bytes/indexbyte.c
1209strings/index.lo: go/strings/indexbyte.c runtime.inc
1210	@$(MKDIR_P) strings
1211	$(LTCOMPILE) -c -o $@ $(srcdir)/go/strings/indexbyte.c
1212
1213# Use a C function with a fixed number of arguments to call a C
1214# varargs function.
1215log/syslog/syslog_c.lo: go/log/syslog/syslog_c.c runtime.inc
1216	@$(MKDIR_P) log/syslog
1217	$(LTCOMPILE) -c -o $@ $(srcdir)/go/log/syslog/syslog_c.c
1218
1219# The interface to libffi from the reflect package is written in C.
1220reflect/makefunc_ffi_c.lo: go/reflect/makefunc_ffi_c.c runtime.inc
1221	@$(MKDIR_P) reflect
1222	$(LTCOMPILE) -c -o $@ $(srcdir)/go/reflect/makefunc_ffi_c.c
1223
1224# The atomic functions are written in C.
1225runtime/internal/atomic_c.lo: go/runtime/internal/atomic/atomic.c runtime.inc
1226	@$(MKDIR_P) runtime/internal
1227	$(LTCOMPILE) -c -o $@ $(srcdir)/go/runtime/internal/atomic/atomic.c
1228sync/atomic_c.lo: go/sync/atomic/atomic.c runtime.inc
1229	@$(MKDIR_P) sync
1230	$(LTCOMPILE) -c -o $@ $(srcdir)/go/sync/atomic/atomic.c
1231
1232# A few syscall functions are written in C.
1233syscall/clone_linux.lo: go/syscall/clone_linux.c runtime.inc
1234	@$(MKDIR_P) syscall
1235	$(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/clone_linux.c
1236syscall/errno.lo: go/syscall/errno.c runtime.inc
1237	@$(MKDIR_P) syscall
1238	$(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/errno.c
1239syscall/signame.lo: go/syscall/signame.c runtime.inc
1240	@$(MKDIR_P) syscall
1241	$(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/signame.c
1242syscall/wait.lo: go/syscall/wait.c runtime.inc
1243	@$(MKDIR_P) syscall
1244	$(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/wait.c
1245
1246# Solaris 11.4 changed the type of fields in struct stat.
1247# Use a build tag, based on a configure check, to cope.
1248if LIBGO_IS_SOLARIS
1249if HAVE_STAT_TIMESPEC
1250matchargs_os = --tag=solaristag
1251else
1252matchargs_os =
1253endif
1254else
1255matchargs_os =
1256endif
1257
1258if LIBGO_IS_BSD
1259
1260# Build golang_org/x/net/route only on BSD systems.
1261
1262$(eval $(call PACKAGE_template,golang_org/x/net/route))
1263
1264golang_org_x_net_route_lo = \
1265	golang_org/x/net/route.lo
1266golang_org_x_net_route_check = \
1267	golang_org/x/net/route/check
1268
1269endif
1270
1271if LIBGO_IS_SOLARIS
1272
1273# Build golang_org/x/net/lif only on Solaris systems.
1274
1275$(eval $(call PACKAGE_template,golang_org/x/net/lif))
1276
1277golang_org_x_net_lif_lo = \
1278	golang_org/x/net/lif.lo
1279golang_org_x_net_lif_check = \
1280	golang_org/x/net/lif/check
1281
1282endif
1283
1284TEST_PACKAGES = \
1285	bufio/check \
1286	bytes/check \
1287	context/check \
1288	crypto/check \
1289	errors/check \
1290	expvar/check \
1291	flag/check \
1292	fmt/check \
1293	hash/check \
1294	html/check \
1295	image/check \
1296	io/check \
1297	log/check \
1298	math/check \
1299	mime/check \
1300	net/check \
1301	os/check \
1302	path/check \
1303	reflect/check \
1304	regexp/check \
1305	runtime/check \
1306	sort/check \
1307	strconv/check \
1308	strings/check \
1309	sync/check \
1310	syscall/check \
1311	time/check \
1312	unicode/check \
1313	archive/tar/check \
1314	archive/zip/check \
1315	cmd/go/internal/cache/check \
1316	cmd/go/internal/generate/check \
1317	cmd/go/internal/get/check \
1318	cmd/go/internal/load/check \
1319	cmd/go/internal/work/check \
1320	cmd/internal/buildid/check \
1321	cmd/internal/edit/check \
1322	cmd/internal/objabi/check \
1323	cmd/internal/test2json/check \
1324	cmd/vet/internal/cfg/check \
1325	compress/bzip2/check \
1326	compress/flate/check \
1327	compress/gzip/check \
1328	compress/lzw/check \
1329	compress/zlib/check \
1330	container/heap/check \
1331	container/list/check \
1332	container/ring/check \
1333	crypto/aes/check \
1334	crypto/cipher/check \
1335	crypto/des/check \
1336	crypto/dsa/check \
1337	crypto/ecdsa/check \
1338	crypto/elliptic/check \
1339	crypto/hmac/check \
1340	crypto/md5/check \
1341	crypto/rand/check \
1342	crypto/rc4/check \
1343	crypto/rsa/check \
1344	crypto/sha1/check \
1345	crypto/sha256/check \
1346	crypto/sha512/check \
1347	crypto/subtle/check \
1348	crypto/tls/check \
1349	crypto/x509/check \
1350	database/sql/check \
1351	database/sql/driver/check \
1352	debug/dwarf/check \
1353	debug/elf/check \
1354	debug/macho/check \
1355	debug/pe/check \
1356	debug/plan9obj/check \
1357	debug/xcoff/check \
1358	encoding/ascii85/check \
1359	encoding/asn1/check \
1360	encoding/base32/check \
1361	encoding/base64/check \
1362	encoding/binary/check \
1363	encoding/csv/check \
1364	encoding/gob/check \
1365	encoding/hex/check \
1366	encoding/json/check \
1367	encoding/pem/check \
1368	encoding/xml/check \
1369	html/template/check \
1370	go/ast/check \
1371	go/build/check \
1372	go/constant/check \
1373	go/doc/check \
1374	go/format/check \
1375	go/importer/check \
1376	go/internal/gcimporter/check \
1377	go/internal/gccgoimporter/check \
1378	go/internal/srcimporter/check \
1379	go/parser/check \
1380	go/printer/check \
1381	go/scanner/check \
1382	go/token/check \
1383	go/types/check \
1384	golang_org/x/crypto/chacha20poly1305/check \
1385	golang_org/x/crypto/chacha20poly1305/internal/chacha20/check \
1386	golang_org/x/crypto/cryptobyte/check \
1387	golang_org/x/crypto/curve25519/check \
1388	golang_org/x/crypto/poly1305/check \
1389	golang_org/x/net/http2/hpack/check \
1390	golang_org/x/net/idna/check \
1391	golang_org/x/net/lex/httplex/check \
1392	$(golang_org_x_net_lif_check) \
1393	golang_org/x/net/proxy/check \
1394	$(golang_org_x_net_route_check) \
1395	hash/adler32/check \
1396	hash/crc32/check \
1397	hash/crc64/check \
1398	hash/fnv/check \
1399	image/color/check \
1400	image/draw/check \
1401	image/jpeg/check \
1402	image/png/check \
1403	index/suffixarray/check \
1404	internal/poll/check \
1405	internal/singleflight/check \
1406	internal/trace/check \
1407	io/ioutil/check \
1408	log/syslog/check \
1409	math/big/check \
1410	math/bits/check \
1411	math/cmplx/check \
1412	math/rand/check \
1413	mime/multipart/check \
1414	mime/quotedprintable/check \
1415	net/http/check \
1416	net/http/cgi/check \
1417	net/http/cookiejar/check \
1418	net/http/fcgi/check \
1419	net/http/httptest/check \
1420	net/http/httptrace/check \
1421	net/http/httputil/check \
1422	net/http/internal/check \
1423	net/http/pprof/check \
1424	net/internal/socktest/check \
1425	net/mail/check \
1426	net/rpc/check \
1427	net/smtp/check \
1428	net/textproto/check \
1429	net/url/check \
1430	net/rpc/jsonrpc/check \
1431	os/exec/check \
1432	os/signal/check \
1433	os/user/check \
1434	path/filepath/check \
1435	regexp/syntax/check \
1436	runtime/debug/check \
1437	runtime/internal/atomic/check \
1438	runtime/internal/sys/check \
1439	runtime/pprof/check \
1440	runtime/pprof/internal/profile/check \
1441	runtime/trace/check \
1442	sync/atomic/check \
1443	text/scanner/check \
1444	text/tabwriter/check \
1445	text/template/check \
1446	text/template/parse/check \
1447	testing/quick/check \
1448	unicode/utf16/check \
1449	unicode/utf8/check
1450
1451check: check-tail
1452check-recursive: check-head
1453
1454check-head:
1455	@echo "Test Run By $${USER} on `date`" > libgo.head
1456	@echo "Native configuration is $(host_triplet)" >> libgo.head
1457	@echo >> libgo.head
1458	@echo "		=== libgo tests ===" >> libgo.head
1459	@echo >> libgo.head
1460
1461check-tail: check-recursive check-multi
1462	@if test "$(USE_DEJAGNU)" = "yes"; then \
1463	  exit 0; \
1464	fi; \
1465	lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
1466	for dir in . $(MULTIDIRS); do \
1467	  mv ../$${dir}/$${lib}/libgo.sum ../$${dir}/$${lib}/libgo.sum.sep; \
1468	  mv ../$${dir}/$${lib}/libgo.log ../$${dir}/$${lib}/libgo.log.sep; \
1469	done; \
1470	mv libgo.head libgo.sum; \
1471	cp libgo.sum libgo.log; \
1472	echo "Schedule of variations:" >> libgo.sum; \
1473	for dir in . $(MULTIDIRS); do \
1474	  multidir=../$${dir}/$${lib}; \
1475	  multivar=`cat $${multidir}/libgo.var`; \
1476	  echo "    $${multivar}" >> libgo.sum; \
1477	done; \
1478	echo >> libgo.sum; \
1479	pass=0; fail=0; untested=0; \
1480	for dir in . $(MULTIDIRS); do \
1481	  multidir=../$${dir}/$${lib}; \
1482	  multivar=`cat $${multidir}/libgo.var`; \
1483	  echo "Running target $${multivar}" >> libgo.sum; \
1484	  echo "Running $(srcdir)/libgo.exp ..." >> libgo.sum; \
1485	  cat $${multidir}/libgo.sum.sep >> libgo.sum; \
1486	  cat $${multidir}/libgo.log.sep >> libgo.log; \
1487	  if test -n "${MULTIDIRS}"; then \
1488	    echo "		=== libgo Summary for $${multivar} ===" >> libgo.sum; \
1489	    echo >> libgo.sum; \
1490	  fi; \
1491	  p=`grep -c PASS $${multidir}/libgo.sum.sep`; \
1492	  pass=`expr $$pass + $$p`; \
1493	  if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
1494	    echo "# of expected passes		$$p" >> libgo.sum; \
1495	  fi; \
1496	  p=`grep -c FAIL $${multidir}/libgo.sum.sep`; \
1497	  fail=`expr $$fail + $$p`; \
1498	  if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
1499	    echo "# of unexpected failures	$$p" >> libgo.sum; \
1500	  fi; \
1501	  p=`grep -c UNTESTED $${multidir}/libgo.sum.sep`; \
1502	  untested=`expr $$untested + $$p`; \
1503	  if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
1504	    echo "# of untested testcases		$$p" >> libgo.sum; \
1505	  fi; \
1506	done; \
1507	echo >> libgo.sum; \
1508	echo "		=== libgo Summary ===" >> libgo.sum; \
1509	echo >> libgo.sum; \
1510	if test "$$pass" -ne "0"; then \
1511	  echo "# of expected passes		$$pass" >> libgo.sum; \
1512	fi; \
1513	if test "$$fail" -ne "0"; then \
1514	  echo "# of unexpected failures	$$fail" >> libgo.sum; \
1515	fi; \
1516	if test "$$untested" -ne "0"; then \
1517	  echo "# of untested testcases		$$untested" >> libgo.sum; \
1518	fi; \
1519	echo `echo $(GOC) | sed -e 's/ .*//'`  `$(GOC) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> libgo.sum; \
1520	echo >> libgo.log; \
1521	echo "runtest completed at `date`" >> libgo.log; \
1522	if test "$$fail" -ne "0"; then \
1523	  status=1; \
1524	else \
1525	  status=0; \
1526	fi; \
1527	exit $$status
1528
1529check-am:
1530	@rm -f libgo.sum libgo.log libgo.tail
1531	@multivar="unix"; \
1532	[ -z "$(MULTIFLAGS)" ] || multivar="$${multivar}/$(MULTIFLAGS)"; \
1533	echo "$${multivar}" > libgo.var
1534	@for f in $(TEST_PACKAGES); do \
1535	   rm -f $$f-testsum $$f-testlog; \
1536	 done
1537	-@$(MAKE) $(AM_MAKEFLAGS) -k $(TEST_PACKAGES)
1538	@for f in $(TEST_PACKAGES); do \
1539	  if test -f $$f-testsum; then \
1540	    cat $$f-testsum >> libgo.sum; \
1541	  fi; \
1542	  if test -f $$f-testlog; then \
1543	    cat $$f-testlog >> libgo.log; \
1544	  fi; \
1545	done
1546
1547check-multi:
1548	$(MULTIDO) $(AM_MAKEFLAGS) DO=check-am multi-do # $(MAKE)
1549
1550bench:
1551	-@$(MAKE) $(AM_MAKEFLAGS) -k $(TEST_PACKAGES) GOBENCH=.
1552
1553MOSTLYCLEANFILES = \
1554	s-runtime_sysinfo s-sigtab s-runtime-inc s-zstdpkglist \
1555	s-libcalls s-libcalls-list s-syscall_arch s-gen-sysinfo s-sysinfo \
1556	s-errno s-epoll \
1557	libgo.head libgo.sum.sep libgo.log.sep libgo.var \
1558	libcalls-list runtime.inc runtime.inc.tmp2 runtime.inc.tmp3
1559
1560mostlyclean-local:
1561	find . -name '*.lo' -print | xargs $(LIBTOOL) --mode=clean rm -f
1562	find . -name '*.$(OBJEXT)' -print | xargs rm -f
1563	find . -name '*-testsum' -print | xargs rm -f
1564	find . -name '*-testlog' -print | xargs rm -f
1565
1566CLEANFILES = *.go *.c s-* libgo.sum libgo.log runtime.inc
1567
1568clean-local:
1569	find . -name '*.la' -print | xargs $(LIBTOOL) --mode=clean rm -f
1570	find . -name '*.a' -print | xargs rm -f
1571	find . -name '*.gox' -print | xargs rm -f
1572	find . -name '*.s-gox' -print | xargs rm -f
1573
1574distclean-local:
1575	find . -name '*.lo.dep' -print | xargs rm -f
1576