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