aboutsummaryrefslogtreecommitdiff
path: root/libgo/Makefile.am
blob: a5d4b6a35251d3ed4edb7eb22e9eaefe9fbd7b7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
# Makefile.am -- Go library Makefile.

# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

# Process this file with autoreconf to produce Makefile.in.

# Go support.
SUFFIXES = .c .go .gox .o .obj .lo .a

if LIBGO_IS_RTEMS
subdirs = testsuite
endif

if LIBGO_IS_DARWIN
GO_EXPORT_SECTION_NAME = __GNU_GO.__go_export
else
GO_EXPORT_SECTION_NAME = .go_export
endif

SUBDIRS = ${subdirs}

gcc_version := $(shell $(GOC) -dumpversion)

MAINT_CHARSET = latin1

mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
PWD_COMMAND = $${PWDCMD-pwd}
STAMP = echo timestamp >

toolexecdir = $(glibgo_toolexecdir)
toolexeclibdir = $(glibgo_toolexeclibdir)
toolexeclibgodir = $(nover_glibgo_toolexeclibdir)/go/$(gcc_version)/$(target_alias)
libexecsubdir = $(libexecdir)/gcc/$(target_alias)/$(gcc_version)

LIBFFI = @LIBFFI@
LIBFFIINCS = @LIBFFIINCS@

LIBATOMIC = @LIBATOMIC@

WARN_CFLAGS = $(WARN_FLAGS) $(WERROR)

# -I/-D flags to pass when compiling.
AM_CPPFLAGS = -I $(srcdir)/runtime $(LIBFFIINCS) $(PTHREAD_CFLAGS)

ACLOCAL_AMFLAGS = -I ./config -I ../config

AM_CFLAGS = -fexceptions -fnon-call-exceptions \
	$(SPLIT_STACK) $(WARN_CFLAGS) \
	$(STRINGOPS_FLAG) $(HWCAP_CFLAGS) $(OSCFLAGS) \
	-I $(srcdir)/../libgcc -I $(srcdir)/../libbacktrace \
	-I $(MULTIBUILDTOP)../../gcc/include

AM_LDFLAGS =

if USING_SPLIT_STACK
AM_LDFLAGS += -XCClinker $(SPLIT_STACK)
endif

if LIBGO_IS_AIX
# Using an import file for libgo avoid requiring to use the -brtl flag
# when builing a go program
AM_LDFLAGS += -Wl,-bbigtoc -Wl,-bI:$(srcdir)/libgo.imp
EXTRA_libgo_la_DEPENDENCIES = libgo.imp
endif

# Multilib support.
MAKEOVERRIDES=

# Work around what appears to be a GNU make  handling MAKEFLAGS
# values defined in terms of make variables, as is the case for CC and
# friends when we are called from the top level Makefile.
AM_MAKEFLAGS = \
	"AR_FLAGS=$(AR_FLAGS)" \
	"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
	"CC_FOR_TARGET=$(CC_FOR_TARGET)" \
	"CFLAGS=$(CFLAGS)" \
	"CXXFLAGS=$(CXXFLAGS)" \
	"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
	"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
	"GOC_FOR_TARGET=$(GOC_FOR_TARGET)" \
	"GOC=$(GOC)" \
	"GOCFLAGS=$(GOCFLAGS)" \
	"INSTALL=$(INSTALL)" \
	"INSTALL_DATA=$(INSTALL_DATA)" \
	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
	"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
	"LDFLAGS=$(LDFLAGS)" \
	"LIBCFLAGS=$(LIBCFLAGS)" \
	"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
	"MAKE=$(MAKE)" \
	"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
	"PICFLAG=$(PICFLAG)" \
	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
	"SHELL=$(SHELL)" \
	"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
	"exec_prefix=$(exec_prefix)" \
	"infodir=$(infodir)" \
	"libdir=$(libdir)" \
	"includedir=$(includedir)" \
	"prefix=$(prefix)" \
	"tooldir=$(tooldir)" \
	"gxx_include_dir=$(gxx_include_dir)" \
	"AR=$(AR)" \
	"AS=$(AS)" \
	"LD=$(LD)" \
	"RANLIB=$(RANLIB)" \
	"NM=$(NM)" \
	"NM_FOR_BUILD=$(NM_FOR_BUILD)" \
	"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
	"DESTDIR=$(DESTDIR)" \
	"WERROR=$(WERROR)"

# Subdir rules rely on $(FLAGS_TO_PASS)
FLAGS_TO_PASS = $(AM_MAKEFLAGS)

if GOC_IS_LLGO
toolexeclib_LTLIBRARIES = libgo-llgo.la
toolexeclib_LIBRARIES = libgobegin-llgo.a
else
toolexeclib_LTLIBRARIES = libgo.la
toolexeclib_LIBRARIES = libgobegin.a libgolibbegin.a
endif

noinst_LIBRARIES = libgotool.a

toolexeclibgo_DATA = \
	bufio.gox \
	bytes.gox \
	context.gox \
	crypto.gox \
	embed.gox \
	encoding.gox \
	errors.gox \
	expvar.gox \
	flag.gox \
	fmt.gox \
	hash.gox \
	html.gox \
	image.gox \
	io.gox \
	log.gox \
	math.gox \
	mime.gox \
	net.gox \
	os.gox \
	path.gox \
	reflect.gox \
	regexp.gox \
	runtime.gox \
	sort.gox \
	strconv.gox \
	strings.gox \
	sync.gox \
	syscall.gox \
	testing.gox \
	time.gox \
	unicode.gox

toolexeclibgoarchivedir = $(toolexeclibgodir)/archive

toolexeclibgoarchive_DATA = \
	archive/tar.gox \
	archive/zip.gox

toolexeclibgocompressdir = $(toolexeclibgodir)/compress

toolexeclibgocompress_DATA = \
	compress/bzip2.gox \
	compress/flate.gox \
	compress/gzip.gox \
	compress/lzw.gox \
	compress/zlib.gox

toolexeclibgocontainerdir = $(toolexeclibgodir)/container

toolexeclibgocontainer_DATA = \
	container/heap.gox \
	container/list.gox \
	container/ring.gox

toolexeclibgocryptodir = $(toolexeclibgodir)/crypto

toolexeclibgocrypto_DATA = \
	crypto/aes.gox \
	crypto/cipher.gox \
	crypto/des.gox \
	crypto/dsa.gox \
	crypto/ecdsa.gox \
	crypto/ed25519.gox \
	crypto/elliptic.gox \
	crypto/hmac.gox \
	crypto/md5.gox \
	crypto/rand.gox \
	crypto/rc4.gox \
	crypto/rsa.gox \
	crypto/sha1.gox \
	crypto/sha256.gox \
	crypto/sha512.gox \
	crypto/subtle.gox \
	crypto/tls.gox \
	crypto/x509.gox

toolexeclibgocryptox509dir = $(toolexeclibgocryptodir)/x509

toolexeclibgocryptox509_DATA = \
	crypto/x509/pkix.gox

toolexeclibgodatabasedir = $(toolexeclibgodir)/database

toolexeclibgodatabase_DATA = \
	database/sql.gox

toolexeclibgodatabasesqldir = $(toolexeclibgodatabasedir)/sql

toolexeclibgodatabasesql_DATA = \
	database/sql/driver.gox

toolexeclibgodebugdir = $(toolexeclibgodir)/debug

toolexeclibgodebug_DATA = \
	debug/buildinfo.gox \
	debug/dwarf.gox \
	debug/elf.gox \
	debug/gosym.gox \
	debug/macho.gox \
	debug/pe.gox \
	debug/plan9obj.gox

toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding

toolexeclibgoencoding_DATA = \
	encoding/ascii85.gox \
	encoding/asn1.gox \
	encoding/base32.gox \
	encoding/base64.gox \
	encoding/binary.gox \
	encoding/csv.gox \
	encoding/gob.gox \
	encoding/hex.gox \
	encoding/json.gox \
	encoding/pem.gox \
	encoding/xml.gox

toolexeclibgogodir = $(toolexeclibgodir)/go

toolexeclibgogo_DATA = \
	go/ast.gox \
	go/build.gox \
	go/constant.gox \
	go/doc.gox \
	go/format.gox \
	go/importer.gox \
	go/parser.gox \
	go/printer.gox \
	go/scanner.gox \
	go/token.gox \
	go/types.gox

toolexeclibgogobuilddir = $(toolexeclibgogodir)/build

toolexeclibgogobuild_DATA = \
	go/build/constraint.gox

toolexeclibgohashdir = $(toolexeclibgodir)/hash

toolexeclibgohash_DATA = \
	hash/adler32.gox \
	hash/crc32.gox \
	hash/crc64.gox \
	hash/fnv.gox \
	hash/maphash.gox

toolexeclibgohtmldir = $(toolexeclibgodir)/html

toolexeclibgohtml_DATA = \
	html/template.gox

toolexeclibgoimagedir = $(toolexeclibgodir)/image

toolexeclibgoimage_DATA = \
	image/color.gox \
	image/draw.gox \
	image/gif.gox \
	image/jpeg.gox \
	image/png.gox

toolexeclibgoimagecolordir = $(toolexeclibgoimagedir)/color

toolexeclibgoimagecolor_DATA = \
	image/color/palette.gox

toolexeclibgoindexdir = $(toolexeclibgodir)/index

toolexeclibgoindex_DATA = \
	index/suffixarray.gox

toolexeclibgoiodir = $(toolexeclibgodir)/io

toolexeclibgoio_DATA = \
	io/fs.gox \
	io/ioutil.gox

toolexeclibgologdir = $(toolexeclibgodir)/log

toolexeclibgolog_DATA = \
	log/syslog.gox

toolexeclibgomathdir = $(toolexeclibgodir)/math

toolexeclibgomath_DATA = \
	math/big.gox \
	math/bits.gox \
	math/cmplx.gox \
	math/rand.gox

toolexeclibgomimedir = $(toolexeclibgodir)/mime

toolexeclibgomime_DATA = \
	mime/multipart.gox \
	mime/quotedprintable.gox

toolexeclibgonetdir = $(toolexeclibgodir)/net

toolexeclibgonet_DATA = \
	net/http.gox \
	net/mail.gox \
	net/netip.gox \
	net/rpc.gox \
	net/smtp.gox \
	net/textproto.gox \
	net/url.gox

toolexeclibgonethttpdir = $(toolexeclibgonetdir)/http

toolexeclibgonethttp_DATA = \
	net/http/cgi.gox \
	net/http/cookiejar.gox \
	net/http/fcgi.gox \
	net/http/httptest.gox \
	net/http/httptrace.gox \
	net/http/httputil.gox \
	net/http/pprof.gox

toolexeclibgonetrpcdir = $(toolexeclibgonetdir)/rpc

toolexeclibgonetrpc_DATA = \
	net/rpc/jsonrpc.gox

toolexeclibgoosdir = $(toolexeclibgodir)/os

toolexeclibgoos_DATA = \
	os/exec.gox \
	os/signal.gox \
	os/user.gox

toolexeclibgopathdir = $(toolexeclibgodir)/path

toolexeclibgopath_DATA = \
	path/filepath.gox

toolexeclibgoregexpdir = $(toolexeclibgodir)/regexp

toolexeclibgoregexp_DATA = \
	regexp/syntax.gox

toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime

toolexeclibgoruntime_DATA = \
	runtime/cgo.gox \
	runtime/debug.gox \
	runtime/metrics.gox \
	runtime/pprof.gox \
	runtime/trace.gox

toolexeclibgosyncdir = $(toolexeclibgodir)/sync

toolexeclibgosync_DATA = \
	sync/atomic.gox

toolexeclibgotestingdir = $(toolexeclibgodir)/testing

toolexeclibgotesting_DATA = \
	testing/fstest.gox \
	testing/iotest.gox \
	testing/quick.gox

toolexeclibgotestinginternaldir = $(toolexeclibgotestingdir)/internal

toolexeclibgotestinginternal_DATA = \
	testing/internal/testdeps.gox

toolexeclibgotextdir = $(toolexeclibgodir)/text

toolexeclibgotext_DATA = \
	text/scanner.gox \
	text/tabwriter.gox \
	text/template.gox

toolexeclibgotexttemplatedir = $(toolexeclibgotextdir)/template

toolexeclibgotexttemplate_DATA = \
	text/template/parse.gox

toolexeclibgotimedir = $(toolexeclibgodir)/time

toolexeclibgotime_DATA = \
	time/tzdata.gox

toolexeclibgounicodedir = $(toolexeclibgodir)/unicode

toolexeclibgounicode_DATA = \
	unicode/utf16.gox \
	unicode/utf8.gox

# Some internal packages are needed to bootstrap the gc toolchain.
toolexeclibgointernaldir = $(toolexeclibgodir)/internal
toolexeclibgointernal_DATA = \
	internal/reflectlite.gox \
	internal/unsafeheader.gox

# Some packages are only needed for tests, so unlike the other
# internal packages nothing will explicitly depend on them.
# Force them to be built.
noinst_DATA = \
	golang.org/x/net/nettest.gox \
	internal/cfg.gox \
	internal/obscuretestdata.gox \
	internal/profile.gox \
	internal/testenv.gox \
	internal/trace.gox \
	net/internal/socktest.gox \
	os/exec/internal/fdtest.gox \
	os/signal/internal/pty.gox \
	reflect/internal/example1.gox \
	reflect/internal/example2.gox

if LIBGO_IS_RTEMS
rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
else
rtems_task_variable_add_file =
endif

runtime_context_asm_file =
if LIBGO_IS_X86
if LIBGO_IS_LINUX
runtime_context_asm_file += runtime/go-context.S
endif
endif

runtime_files = \
	runtime/aeshash.c \
	runtime/go-assert.c \
	runtime/go-caller.c \
	runtime/go-callers.c \
	runtime/go-cgo.c \
	runtime/go-construct-map.c \
	runtime/go-ffi.c \
	runtime/go-fieldtrack.c \
	runtime/go-matherr.c \
	runtime/go-memclr.c \
	runtime/go-memmove.c \
	runtime/go-memequal.c \
	runtime/go-nanotime.c \
	runtime/go-now.c \
	runtime/go-nosys.c \
	runtime/go-reflect-call.c \
	runtime/go-setenv.c \
	runtime/go-signal.c \
	runtime/go-unsafe-pointer.c \
	runtime/go-unsetenv.c \
	runtime/go-unwind.c \
	runtime/go-varargs.c \
	runtime/env_posix.c \
	runtime/panic.c \
	runtime/print.c \
	runtime/proc.c \
	runtime/runtime_c.c \
	runtime/stack.c \
	runtime/yield.c \
	$(runtime_context_asm_file) \
	$(rtems_task_variable_add_file)

version.go: s-version; @true
s-version: Makefile
	rm -f version.go.tmp
	echo "package sys" > version.go.tmp
	echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp
	echo 'const StackGuardMultiplierDefault = 1' >> version.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
	$(STAMP) $@

zgoarch.go: s-zgoarch; @true
s-zgoarch: Makefile goarch.sh
	rm -f zgoarch.go.tmp
	echo "package goarch" > zgoarch.go.tmp
	echo >> zgoarch.go.tmp
	echo 'const GOARCH = "'$(GOARCH)'"' >> zgoarch.go.tmp
	echo >> zgoarch.go.tmp
	echo 'const (' >> zgoarch.go.tmp
	echo "  _ArchFamily = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) family`" >> zgoarch.go.tmp
	echo "  _BigEndian = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) bigendian`" >> zgoarch.go.tmp
	echo "  _DefaultPhysPageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) defaultphyspagesize`" >> zgoarch.go.tmp
	echo "  _Int64Align = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) int64align`" >> zgoarch.go.tmp
	echo "  _MinFrameSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) minframesize`" >> zgoarch.go.tmp
	echo "  _PCQuantum = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) pcquantum`" >> zgoarch.go.tmp
	echo "  _StackAlign = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) stackalign`" >> zgoarch.go.tmp
	echo ")" >> zgoarch.go.tmp
	echo >> zgoarch.go.tmp
	echo "const (" >> zgoarch.go.tmp
	echo "	UNKNOWN ArchFamilyType = iota" >> zgoarch.go.tmp
	for a in $(ALLGOARCHFAMILY); do \
	  echo "	$${a}" >> zgoarch.go.tmp; \
	done
	echo ")" >> zgoarch.go.tmp
	echo >> zgoarch.go.tmp
	for a in $(ALLGOARCH); do \
	  f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
	  n="$${f}`echo $${a} | sed -e 's/.//'`"; \
	  if test "$${a}" = "$(GOARCH)"; then \
	    echo "const Is$${n} = 1" >> zgoarch.go.tmp; \
	  else \
	    echo "const Is$${n} = 0" >> zgoarch.go.tmp; \
	  fi; \
	done
	$(SHELL) $(srcdir)/mvifdiff.sh zgoarch.go.tmp zgoarch.go
	$(STAMP) $@

zgoos.go: s-zgoos; @true
s-zgoos: Makefile
	rm -f zgoos.go.tmp
	echo "package goos" > zgoos.go.tmp
	echo >> zgoos.go.tmp
	echo 'const GOOS = "'$(GOOS)'"' >> zgoos.go.tmp
	echo >> zgoos.go.tmp
	for a in $(ALLGOOS); do \
	  f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
	  n="$${f}`echo $${a} | sed -e 's/.//'`"; \
	  if test "$${a}" = "$(GOOS)"; then \
	    echo "const Is$${n} = 1" >> zgoos.go.tmp; \
	  else \
	    echo "const Is$${n} = 0" >> zgoos.go.tmp; \
	  fi; \
	done
	$(SHELL) $(srcdir)/mvifdiff.sh zgoos.go.tmp zgoos.go
	$(STAMP) $@

cpugen.go: s-cpu; @true
s-cpu: Makefile goarch.sh
	rm -f cpugen.go.tmp
	echo "package cpu" > cpugen.go.tmp
	echo "const CacheLinePadSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp
	echo "const FunctionDescriptors = $(FUNCTION_DESCRIPTORS)" >> cpugen.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh cpugen.go.tmp cpugen.go
	$(STAMP) $@

gcpugen.go: s-gcpu; @true
s-gcpu: Makefile goarch.sh
	rm -f gcpugen.go.tmp
	echo "package cpu" > gcpugen.go.tmp
	echo "const cacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> gcpugen.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh gcpugen.go.tmp gcpugen.go
	$(STAMP) $@

goroot.go: s-goroot; @true
s-goroot: Makefile
	rm -f goroot.go.tmp
	echo "package runtime" > goroot.go.tmp
	echo 'var defaultGOROOT = `$(prefix)`' >> goroot.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh goroot.go.tmp goroot.go
	$(STAMP) $@

buildcfg.go: s-buildcfg; @true
s-buildcfg: Makefile
	rm -f buildcfg.go.tmp
	echo "package buildcfg" > buildcfg.go.tmp
	echo "import \"runtime\"" >> buildcfg.go.tmp
	echo 'func defaultGOROOTValue() string { return `$(prefix)` }' >> buildcfg.go.tmp
	echo 'const defaultGO386 = `sse2`' >> buildcfg.go.tmp
	echo 'const defaultGOAMD64 = `v1`' >> buildcfg.go.tmp
	echo 'const defaultGOARM = `5`' >> buildcfg.go.tmp
	echo 'const defaultGOMIPS = `hardfloat`' >> buildcfg.go.tmp
	echo 'const defaultGOMIPS64 = `hardfloat`' >> buildcfg.go.tmp
	echo 'const defaultGOPPC64 = `power8`' >> buildcfg.go.tmp
	echo 'const defaultGOEXPERIMENT = `fieldtrack`' >> buildcfg.go.tmp
	echo 'const defaultGO_EXTLINK_ENABLED = ``' >> buildcfg.go.tmp
	echo 'const defaultGO_LDSO = ``' >> buildcfg.go.tmp
	echo 'const version = `'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'`' >> buildcfg.go.tmp
	echo 'const defaultGOOS = runtime.GOOS' >> buildcfg.go.tmp
	echo 'const defaultGOARCH = runtime.GOARCH' >> buildcfg.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh buildcfg.go.tmp buildcfg.go
	$(STAMP) $@

objabi.go: s-objabi; @true
s-objabi: Makefile
	rm -f objabi.go.tmp
	echo "package objabi" > objabi.go.tmp
	echo 'const stackGuardMultiplierDefault = 1' >> objabi.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh objabi.go.tmp objabi.go
	$(STAMP) $@

gccgosizes.go: s-gccgosizes; @true
s-gccgosizes: Makefile goarch.sh
	rm -f gccgosizes.go.tmp
	echo "package types" > gccgosizes.go.tmp
	echo >> gccgosizes.go.tmp
	echo "var gccgoArchSizes = map[string]*StdSizes{" >> gccgosizes.go.tmp
	for a in $(ALLGOARCH); do \
	  ptrsize=`$(SHELL) $(srcdir)/goarch.sh $$a ptrsize`; \
	  maxalign=`$(SHELL) $(srcdir)/goarch.sh $$a maxalign`; \
	  echo "	\"$$a\": {$${ptrsize}, $${maxalign}}," >> gccgosizes.go.tmp; \
	done
	echo "}" >> gccgosizes.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh gccgosizes.go.tmp gccgosizes.go
	$(STAMP) $@

os_linknames.go: s-os_linknames; @true
s-os_linknames: os-list gen-sysinfo.go $(srcdir)/mklinknames.awk $(srcdir)/go/os/*.go
	rm -f os_linknames.go.tmp
	$(AWK) -f $(srcdir)/mklinknames.awk -v package=os `cat os-list` > os_linknames.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh os_linknames.go.tmp os_linknames.go
	$(STAMP) $@

os-list: s-os-list; @true
s-os-list: Makefile $(srcdir)/go/os/*.go
	rm -f os-list.tmp
	$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/os > os-list.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh os-list.tmp os-list
	$(STAMP) $@

os_user_linknames.go: s-os_user_linknames; @true
s-os_user_linknames: os-user-list gen-sysinfo.go $(srcdir)/mklinknames.awk $(srcdir)/go/os/user/*.go
	rm -f os_user_linknames.go.tmp
	$(AWK) -f $(srcdir)/mklinknames.awk -v package=user `cat os-user-list` > os_user_linknames.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh os_user_linknames.go.tmp os_user_linknames.go
	$(STAMP) $@

os-user-list: s-os-user-list; @true
s-os-user-list: Makefile $(srcdir)/go/os/user/*.go
	rm -f os-user-list.tmp
	$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/os/user > os-user-list.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh os-user-list.tmp os-user-list
	$(STAMP) $@

runtime_linknames.go: s-runtime_linknames; @true
s-runtime_linknames: runtime-list gen-sysinfo.go $(srcdir)/mklinknames.awk $(srcdir)/go/runtime/*.go
	rm -f runtime_linknames.go.tmp
	$(AWK) -f $(srcdir)/mklinknames.awk -v package=runtime `cat runtime-list` > runtime_linknames.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh runtime_linknames.go.tmp runtime_linknames.go
	$(STAMP) $@

runtime-list: s-runtime-list; @true
s-runtime-list: Makefile $(srcdir)/go/runtime/*.go
	rm -f runtime-list.tmp
	$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/runtime > runtime-list.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh runtime-list.tmp runtime-list
	$(STAMP) $@

runtime_sysinfo.go: s-runtime_sysinfo; @true
s-runtime_sysinfo: $(srcdir)/mkrsysinfo.sh gen-sysinfo.go
	GOARCH=$(GOARCH) GOOS=$(GOOS) $(SHELL) $(srcdir)/mkrsysinfo.sh
	$(SHELL) $(srcdir)/mvifdiff.sh tmp-runtime_sysinfo.go runtime_sysinfo.go
	$(STAMP) $@

sigtab.go: s-sigtab; @true
s-sigtab: $(srcdir)/mksigtab.sh gen-sysinfo.go
	GOOS=$(GOOS) $(SHELL) $(srcdir)/mksigtab.sh > tmp-sigtab.go
	$(SHELL) $(srcdir)/mvifdiff.sh tmp-sigtab.go sigtab.go
	$(STAMP) $@

GCCGO_INSTALL_NAME := $(shell echo gccgo|sed '$(program_transform_name)')
GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')

zdefaultcc.go: s-zdefaultcc; @true
s-zdefaultcc: Makefile
	echo 'package cfg' > zdefaultcc.go.tmp
	echo >> zdefaultcc.go.tmp
	echo 'func DefaultGCCGO(goos, goarch string) string { return "$(bindir)/$(GCCGO_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
	echo 'func DefaultCC(goos, goarch string) string { return "$(GCC_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
	echo 'func DefaultCXX(goos, goarch string) string { return "$(GXX_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
	echo 'const DefaultPkgConfig = "pkg-config"' >> zdefaultcc.go.tmp
	echo 'var OSArchSupportsCgo = map[string]bool{}' >> zdefaultcc.go.tmp
	$(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
	$(STAMP) $@ 

# Post-process runtime.inc.raw (raw output of -fgo-c-header option when
# compiling runtime) to prune out certain types that should not be
# exported back to C. See comments in mkruntimeinc.sh for more details.
runtime.inc: s-runtime-inc; @true
s-runtime-inc: runtime.lo mkruntimeinc.sh Makefile
	$(SHELL) $(srcdir)/mkruntimeinc.sh
	$(SHELL) $(srcdir)/mvifdiff.sh tmp-runtime.inc runtime.inc
	$(STAMP) $@

noinst_DATA += zdefaultcc.go

# Generate the list of go std packages that were included in libgo
zstdpkglist.go: s-zstdpkglist; @true
s-zstdpkglist: Makefile libgo-packages.txt
	rm -f zstdpkglist.go.tmp
	echo 'package goroot' > zstdpkglist.go.tmp
	echo "" >> zstdpkglist.go.tmp
	echo 'var stdpkg = map[string]bool{' >> zstdpkglist.go.tmp
	echo $(libgo_go_objs) 'unsafe.lo' | sed 's|[a-z0-9_./]*_c\.lo||g' | sed 's|golang\.org/[a-z0-9_./]*\.lo||g' | sed 's|\([a-z0-9_./]*\)\.lo|"\1": true,|g' >> zstdpkglist.go.tmp
	echo '}' >> zstdpkglist.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh zstdpkglist.go.tmp zstdpkglist.go
	$(STAMP) $@

if LIBGO_IS_LINUX
syscall_epoll_file = epoll.go
else
syscall_epoll_file =
endif

libcalls.go: s-libcalls; @true
s-libcalls: libcalls-list go/syscall/mksyscall.awk $(srcdir)/go/syscall/*.go
	rm -f libcalls.go.tmp
	$(AWK) -f $(srcdir)/go/syscall/mksyscall.awk `cat libcalls-list` > libcalls.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh libcalls.go.tmp libcalls.go
	$(STAMP) $@

libcalls-list: s-libcalls-list; @true
s-libcalls-list: Makefile $(srcdir)/go/syscall/*.go
	rm -f libcalls-list.tmp
	$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/syscall $(matchargs_syscall) > libcalls-list.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh libcalls-list.tmp libcalls-list
	$(STAMP) $@

syscall_arch.go: s-syscall_arch; @true
s-syscall_arch: Makefile
	rm -f syscall_arch.go.tmp
	echo "package syscall" > syscall_arch.go.tmp
	echo 'const ARCH = "'$(GOARCH)'"' >> syscall_arch.go.tmp
	echo 'const OS = "'$(GOOS)'"' >> syscall_arch.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh syscall_arch.go.tmp syscall_arch.go
	$(STAMP) $@

syscall_linknames.go: s-syscall_linknames; @true
s-syscall_linknames: libcalls.go gen-sysinfo.go $(srcdir)/mklinknames.awk
	rm -f syscall_linknames.go.tmp
	$(AWK) -v package=syscall -f $(srcdir)/mklinknames.awk libcalls.go > syscall_linknames.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh syscall_linknames.go.tmp syscall_linknames.go
	$(STAMP) $@

SYSINFO_FLAGS = \
	$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
	$(CPPFLAGS) $(OSCFLAGS) -O

gen-sysinfo.go: s-gen-sysinfo; @true
s-gen-sysinfo: $(srcdir)/sysinfo.c config.h
	$(CC) $(SYSINFO_FLAGS) -fdump-go-spec=tmp-gen-sysinfo.go -std=gnu99 -S -o sysinfo.s $(srcdir)/sysinfo.c
	rm -f sysinfo.s
	$(SHELL) $(srcdir)/mvifdiff.sh tmp-gen-sysinfo.go gen-sysinfo.go
	$(STAMP) $@

errno.i: s-errno; @true
s-errno:
	echo '#include <errno.h>' | $(CC) $(SYSINFO_FLAGS) -x c - -E -dM > tmp-errno.i
	$(SHELL) $(srcdir)/mvifdiff.sh tmp-errno.i errno.i
	$(STAMP) $@

sysinfo.go: s-sysinfo; @true
s-sysinfo: $(srcdir)/mksysinfo.sh gen-sysinfo.go errno.i
	GOARCH=$(GOARCH) GOOS=$(GOOS) $(SHELL) $(srcdir)/mksysinfo.sh
	$(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go
	$(STAMP) $@

# The epoll struct has an embedded union and is packed on x86_64,
# which is too complicated for mksysinfo.sh.  We find the offset of
# the only field we care about in configure.ac, and generate the
# struct here.
epoll.go: s-epoll; @true
s-epoll: Makefile
	rm -f epoll.go.tmp
	echo 'package syscall' > epoll.go.tmp
	echo 'type EpollEvent struct {' >> epoll.go.tmp
	echo '	Events uint32' >> epoll.go.tmp
	case "$(SIZEOF_STRUCT_EPOLL_EVENT),$(STRUCT_EPOLL_EVENT_FD_OFFSET)" in \
	0,0) echo 1>&2 "*** struct epoll_event data.fd offset unknown"; \
	   exit 1; ;; \
	8,4) echo '	Fd int32' >> epoll.go.tmp; ;; \
	12,4) echo '	Fd int32' >> epoll.go.tmp; \
	   echo '	Pad [4]byte' >> epoll.go.tmp; ;; \
	12,8) echo '	Pad [4]byte' >> epoll.go.tmp; \
	   echo '	Fd int32' >> epoll.go.tmp; ;; \
	16,8) echo '	Pad [4]byte' >> epoll.go.tmp; \
	   echo '	Fd int32' >> epoll.go.tmp; \
	   echo '	Pad2 [4]byte' >> epoll.go.tmp; ;; \
	*) echo 1>&2 "*** struct epoll_event unsupported"; \
	   exit 1; ;; \
	esac
	echo '}' >> epoll.go.tmp
	$(SHELL) $(srcdir)/mvifdiff.sh epoll.go.tmp epoll.go
	$(STAMP) $@

if LIBGO_IS_LINUX
syscall_lib_clone_lo = syscall/clone_linux.lo
else
syscall_lib_clone_lo =
endif

if LIBGO_IS_X86
golangorg_x_sys_cpu_gccgo_x86_lo = golang.org/x/sys/cpu_gccgo_x86.lo
else
golangorg_x_sys_cpu_gccgo_x86_lo =
endif

PACKAGES = $(shell cat $(srcdir)/libgo-packages.txt)

libgo_go_objs = \
	$(addsuffix .lo,$(PACKAGES)) \
	internal/bytealg/bytealg.lo \
	reflect/makefunc_ffi_c.lo \
	$(syscall_lib_clone_lo) \
	syscall/errno.lo \
	syscall/signame.lo \
	syscall/wait.lo \
	runtime/internal/syscall/errno.lo \
	os/dir_gccgo_c.lo \
	$(golangorg_x_net_lif_lo) \
	$(golangorg_x_net_route_lo) \
	log/syslog/syslog_c.lo \
	$(os_lib_inotify_lo) \
	runtime/internal/atomic_c.lo \
	sync/atomic_c.lo \
	internal/cpu/cpu_gccgo.lo \
	$(golangorg_x_sys_cpu_gccgo_x86_lo)

libgo_ldflags = \
	-version-info $(libtool_VERSION) $(PTHREAD_CFLAGS) $(AM_LDFLAGS)

libgo_libadd = \
	$(libgo_go_objs) ../libbacktrace/libbacktrace.la \
	$(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)

libgo_la_SOURCES = $(runtime_files)
libgo_la_LDFLAGS = $(libgo_ldflags)
libgo_la_LIBADD = $(libgo_libadd)

libgo_llgo_la_SOURCES = $(runtime_files)
libgo_llgo_la_LDFLAGS = $(libgo_ldflags)
libgo_llgo_la_LIBADD = $(libgo_libadd)

libgobegin_a_SOURCES = \
	runtime/go-main.c

libgobegin_llgo_a_SOURCES = \
	runtime/go-main.c

# Use -fPIC for libgobegin so that it can be put in a PIE.
libgobegin_a_CFLAGS = $(AM_CFLAGS) -fPIC
libgobegin_llgo_a_CFLAGS = $(AM_CFLAGS) -fPIC

libgolibbegin_a_SOURCES = \
	runtime/go-libmain.c

libgolibbegin_a_CFLAGS = $(AM_CFLAGS) -fPIC

GOTOOL_PACKAGES = $(shell cat $(srcdir)/gotool-packages.txt)

libgotool_a_SOURCES =
libgotool_a_DEPENDENCIES = $(addsuffix .lo,$(GOTOOL_PACKAGES))
libgotool_a_LIBADD = $(addsuffix .o,$(GOTOOL_PACKAGES))

define STATIC_template
$(subst -,_,$(subst .,_,$(subst /,_,$(1))))_GOCFLAGS = -static
endef

$(foreach package,$(GOTOOL_PACKAGES),$(eval $(call STATIC_template,$(package).lo)))

# Make sure runtime.inc is built before compiling any .c file.
$(libgo_la_OBJECTS): runtime.inc
$(libgo_llgo_la_OBJECTS): runtime.inc
$(libgobegin_a_OBJECTS): runtime.inc
$(libgobegin_llgo_a_OBJECTS): runtime.inc
$(libgolibbegin_a_OBJECTS): runtime.inc

LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))

GOCFLAGS = $(CFLAGS)
AM_GOCFLAGS = $(STRINGOPS_FLAG) $(GO_SPLIT_STACK)
GOCOMPILE = $(GOC) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_GOCFLAGS) $(GOCFLAGS)

LTGOCOMPILE = $(LIBTOOL) --tag GO --mode=compile $(GOC) $(INCLUDES) \
	$(AM_GOCFLAGS) $(GOCFLAGS)

GOLINK = $(LIBTOOL) --tag GO --mode-link $(GOC) \
	$(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_GOCFLAGS) $(LTLDFLAGS) -o $@

# Build the dependencies for a Go package.
BUILDDEPS = \
	$(MKDIR_P) $(@D); \
	dir=`echo $@ | sed -e 's/.lo.dep$$//'`; \
	files=`$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/$$dir --extrafiles="$(extra_go_files_$(subst .,_,$(subst /,_,$(subst .lo.dep,,$@))))" $(matchargs_$(subst /,_,$(subst .lo.dep,,$@)))`; \
	$(SHELL) $(srcdir)/godeps.sh `echo $@ | sed -e 's/.dep$$//'` $$files > $@.tmp; \
	if ! cmp $@.tmp $@ >/dev/null 2>/dev/null; then \
	  rm -f `echo $@ | sed -e 's/\.dep$$//'`; \
	fi; \
	mv -f $@.tmp $@

# Build the .go files for a package, generating a .lo file.
BUILDPACKAGE = \
	$(MKDIR_P) $(@D); \
	files=`echo $^ | sed -e 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; \
	$(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//'` $($(subst -,_,$(subst .,_,$(subst /,_,$@)))_GOCFLAGS) -o $@ $$files

# How to build a .gox file from a .lo file.
# Matching .o file can either be in the same directory as the .lo (non-PIC
# object) or in the .libs directory (PIC object).
BUILDGOX = \
	f="$(basename $<).o"; \
	if test ! -f $$f; then \
	  f="$(basename $(<D)/.libs/$(<F)).o"; \
	fi; \
	$(OBJCOPY) -j $(GO_EXPORT_SECTION_NAME) $$f $@.tmp; \
	$(SHELL) $(srcdir)/mvifdiff.sh $@.tmp `echo $@ | sed -e 's/s-gox/gox/'`

GOTESTFLAGS =
GOBENCH = 

# Check a package.
CHECK = \
	GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \
	export GC; \
	GOLIBS="$(extra_check_libs_$(subst .,_,$(subst /,_,$(@D)))) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS) $(LIBS)"; \
	export GOLIBS; \
	RUNTESTFLAGS="$(RUNTESTFLAGS)"; \
	export RUNTESTFLAGS; \
	MAKE="$(MAKE)"; \
	export MAKE; \
	NM="$(NM)"; \
	export NM; \
	libgccdir=`${GOC} ${GOCFLAGS} -print-libgcc-file-name | sed -e 's|/[^/]*$$||'`; \
	LD_LIBRARY_PATH="`${PWD_COMMAND}`/.libs:$${libgccdir}:${LD_LIBRARY_PATH}"; \
	LD_LIBRARY_PATH=`echo $${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
	export LD_LIBRARY_PATH; \
	$(MKDIR_P) $(@D); \
	rm -f $@-testsum $@-testlog; \
	files=`$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/$(@D) --extrafiles="$(extra_go_files_$(subst .,_,$(subst /,_,$(@D))))" $(matchargs_$(subst /,_,$(@D)))`; \
	if test "$(USE_DEJAGNU)" = "yes"; then \
	  $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --testname="$(@D)" $(GOTESTFLAGS); \
	elif test "$(GOBENCH)" != ""; then \
	  $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --bench="$(GOBENCH)" $(GOTESTFLAGS); \
	else \
	  if $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" $(GOTESTFLAGS) >>$@-testlog 2>&1; then \
	    echo "PASS: $(@D)" >> $@-testlog; \
	    echo "PASS: $(@D)"; \
	    echo "PASS: $(@D)" > $@-testsum; \
	  else \
	    echo "FAIL: $(@D)" >> $@-testlog; \
	    cat $@-testlog; \
	    echo "FAIL: $(@D)" > $@-testsum; \
	    exit 1; \
	  fi; \
	fi

# Build all packages before checking any.
CHECK_DEPS = \
	$(toolexeclibgo_DATA) \
	$(toolexeclibgoarchive_DATA) \
	$(toolexeclibgocompress_DATA) \
	$(toolexeclibgocontainer_DATA) \
	$(toolexeclibgocrypto_DATA) \
	$(toolexeclibgodebug_DATA) \
	$(toolexeclibgoencoding_DATA) \
	$(toolexeclibgogo_DATA) \
	$(toolexeclibgohash_DATA) \
	$(toolexeclibgoimage_DATA) \
	$(toolexeclibgoindex_DATA) \
	$(toolexeclibgoio_DATA) \
	$(toolexeclibgolog_DATA) \
	$(toolexeclibgomath_DATA) \
	$(toolexeclibgomime_DATA) \
	$(toolexeclibgonet_DATA) \
	$(toolexeclibgonethttp_DATA) \
	$(toolexeclibgoos_DATA) \
	$(toolexeclibgopath_DATA) \
	$(toolexeclibgorpc_DATA) \
	$(toolexeclibgoruntime_DATA) \
	$(toolexeclibgosync_DATA) \
	$(toolexeclibgotesting_DATA) \
	$(toolexeclibgotext_DATA) \
	$(toolexeclibgotexttemplate_DATA) \
	$(toolexeclibgounicode_DATA) \
	$(noinst_DATA) \
	$(noinst_LIBRARIES)

if GOC_IS_LLGO
CHECK_DEPS += libgo-llgo.la libgobegin-llgo.a
else
CHECK_DEPS += libgo.la libgobegin.a
endif

# PACKAGE_template defines the rules for each package.
# For example, for the package bufio, it produces:
#
# @go_include@ bufio.lo.dep
# bufio.lo.dep: $(srcdir)/go/bufio/*.go
# 	$(BUILDDEPS)
# bufio.lo:
# 	$(BUILDPACKAGE)
# bufio/check: $(CHECK_DEPS)
# 	@$(CHECK)
# .PHONY: bufio/check
#
# This is invoked with $(1) set to a package, which is a directory name,
# such as "bufio" or "archive/tar".
define PACKAGE_template
@go_include@ $(1).lo.dep
$(1).lo.dep: $(srcdir)/go/$(1)/*.go
	$$(BUILDDEPS)
$(1).lo:
	$$(BUILDPACKAGE)
$(1)/check: $$(CHECK_DEPS)
	@$$(CHECK)
.PHONY: $(1)/check
$(1).gox: $(1).s-gox; @true
$(1).s-gox: $(1).lo
	$$(BUILDGOX)
	$$(STAMP) $$@
endef

# This line expands PACKAGE_template once for each package name listed
# in $(PACKAGES).
$(foreach package,$(PACKAGES),$(eval $(call PACKAGE_template,$(package))))
$(foreach package,$(GOTOOL_PACKAGES),$(eval $(call PACKAGE_template,$(package))))

# Pass -ffp-contract=off, or 386-specific options, when building the
# math package.  MATH_FLAG is defined in configure.ac.
math_lo_GOCFLAGS = $(MATH_FLAG)
math_check_GOCFLAGS = $(MATH_FLAG)

# Add generated files to the runtime package.
extra_go_files_runtime = \
	runtime_linknames.go runtime_sysinfo.go sigtab.go goroot.go
runtime.lo.dep: $(extra_go_files_runtime)

# Add generated files to the syscall package.
extra_go_files_syscall = \
	libcalls.go \
	sysinfo.go \
	syscall_arch.go \
	syscall_linknames.go \
	$(syscall_epoll_file)
syscall.lo.dep: $(extra_go_files_syscall)

# Pass -fgo-compiling-runtime when compiling the runtime package.
runtime_lo_GOCFLAGS = -fgo-c-header=runtime.inc.raw -fgo-compiling-runtime
runtime_check_GOCFLAGS = -fgo-compiling-runtime
runtime_internal_atomic_lo_GOCFLAGS = -fgo-compiling-runtime
runtime_internal_atomic_lo_check_GOCFLAGS = -fgo-compiling-runtime
runtime_internal_sys_lo_GOCFLAGS = -fgo-compiling-runtime
runtime_internal_sys_lo_check_GOCFLAGS = -fgo-compiling-runtime

# If libffi is supported (the normal case) use the ffi build tag for
# the runtime package.
if USE_LIBFFI
matchargs_runtime = --tag=libffi
else
matchargs_runtime =
endif

# At least for now, we need -static-libgo for this test, because
# otherwise we can't get the line numbers.
# Also use -fno-inline to get better results from the memory profiler.
runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline

if LIBGO_IS_AIX
# reflect tests must be done with -static-libgo. Otherwize,
# there will be a duplication of the canonicalization map.
reflect_check_GOCFLAGS = -static-libgo -Wl,-bbigtoc
endif

if HAVE_STATIC_LINK
# Use -static for the syscall tests if possible, because otherwise when
# running as root the re-execs ignore LD_LIBRARY_PATH.
syscall_check_GOCFLAGS = -static
endif

extra_go_files_runtime_internal_sys = version.go
runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys)

extra_go_files_internal_cpu = cpugen.go
internal/cpu.lo.dep: $(extra_go_files_internal_cpu)

extra_go_files_internal_goarch = zgoarch.go
internal/goarch.lo.dep: $(extra_go_files_internal_goarch)

extra_go_files_internal_goos = zgoos.go
internal/goos.lo.dep: $(extra_go_files_internal_goos)

extra_go_files_golang_org_x_sys_cpu = gcpugen.go
golang.org/x/sys/cpu.lo.dep: $(extra_go_files_golang_org_x_sys_cpu)

extra_go_files_internal_buildcfg = buildcfg.go
cmd/internal/buildcfg.lo.dep: $(extra_go_files_internal_buildcfg)

extra_go_files_internal_goroot = zstdpkglist.go
internal/goroot.lo.dep: $(extra_go_files_internal_goroot)

extra_go_files_go_types = gccgosizes.go
go/types.lo.dep: $(extra_go_files_go_types)

extra_go_files_cmd_internal_objabi = objabi.go
cmd/internal/objabi.lo.dep: $(extra_go_files_cmd_internal_objabi)

extra_go_files_cmd_go_internal_cfg = zdefaultcc.go
cmd/go/internal/cfg.lo.dep: $(extra_go_files_cmd_go_internal_cfg)

extra_go_files_os = os_linknames.go
os.lo.dep: $(extra_go_files_os)

extra_go_files_os_user = os_user_linknames.go
os/user.lo.dep: $(extra_go_files_os_user)

extra_check_libs_cmd_go_internal_cache = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_fsys = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_generate = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_get = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_load = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_lockedfile = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_imports = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_modconv = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_modfetch = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_modfetch_codehost = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_modfile = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_modload = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_module = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_mvs = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_search = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_str = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_test = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_vcs = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_web2 = $(abs_builddir)/libgotool.a
extra_check_libs_cmd_go_internal_work = $(abs_builddir)/libgotool.a

extra_check_libs_cmd_internal_buildid = $(abs_builddir)/libgotool.a

extra_check_libs_cmd_vet_internal_cfg = $(abs_builddir)/libgotool.a

# FIXME: The following C files may as well move to the runtime
# directory and be treated like other C files.

# Use C code to speed up internal/bytealg.IndexByte and friends.
internal/bytealg/bytealg.lo: go/internal/bytealg/bytealg.c runtime.inc
	@$(MKDIR_P) internal/bytealg
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/bytealg/bytealg.c

# Use a C function with a fixed number of arguments to call a C
# varargs function.
log/syslog/syslog_c.lo: go/log/syslog/syslog_c.c runtime.inc
	@$(MKDIR_P) log/syslog
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/log/syslog/syslog_c.c

# The interface to libffi from the reflect package is written in C.
reflect/makefunc_ffi_c.lo: go/reflect/makefunc_ffi_c.c runtime.inc
	@$(MKDIR_P) reflect
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/reflect/makefunc_ffi_c.c

# The atomic functions are written in C.
runtime/internal/atomic_c.lo: go/runtime/internal/atomic/atomic.c runtime.inc
	@$(MKDIR_P) runtime/internal
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/runtime/internal/atomic/atomic.c
sync/atomic_c.lo: go/sync/atomic/atomic.c runtime.inc
	@$(MKDIR_P) sync
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/sync/atomic/atomic.c

# A few syscall functions are written in C.
syscall/clone_linux.lo: go/syscall/clone_linux.c runtime.inc
	@$(MKDIR_P) syscall
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/clone_linux.c
syscall/errno.lo: go/syscall/errno.c runtime.inc
	@$(MKDIR_P) syscall
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/errno.c
syscall/signame.lo: go/syscall/signame.c runtime.inc
	@$(MKDIR_P) syscall
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/signame.c
syscall/wait.lo: go/syscall/wait.c runtime.inc
	@$(MKDIR_P) syscall
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/wait.c

# Some runtime/internal/syscall functions are written in C.
runtime/internal/syscall/errno.lo: go/runtime/internal/syscall/errno.c runtime.inc
	@$(MKDIR_P) runtime/internal/syscall
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/runtime/internal/syscall/errno.c

# An os function is written in C.
os/dir_gccgo_c.lo: go/os/dir_gccgo_c.c runtime.inc
	@$(MKDIR_P) os
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/os/dir_gccgo_c.c

# internal/cpu needs some C code.
internal/cpu/cpu_gccgo.lo: go/internal/cpu/cpu_gccgo.c runtime.inc
	@$(MKDIR_P) internal/cpu
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/cpu/cpu_gccgo.c

# Similarly, golang.org/x/sys/cpu needs some C code.
golang.org/x/sys/cpu_gccgo_x86.lo: go/golang.org/x/sys/cpu/cpu_gccgo_x86.c runtime.inc
	@$(MKDIR_P) golang.org/x/sys
	$(LTCOMPILE) -c -o $@ $(srcdir)/go/golang.org/x/sys/cpu/cpu_gccgo_x86.c

# Solaris 11.4 changed the type of fields in struct stat.
# Use a build tag, based on a configure check, to cope.
if LIBGO_IS_SOLARIS
if HAVE_STAT_TIMESPEC
matchargs_os = --tag=solaristag
else
matchargs_os =
endif
else
matchargs_os =
endif

if LIBGO_IS_BSD

# Build golang.org/x/net/route only on BSD systems.

$(eval $(call PACKAGE_template,golang.org/x/net/route))

golangorg_x_net_route_lo = \
	golang.org/x/net/route.lo

endif

if LIBGO_IS_SOLARIS

# Build golang.org/x/net/lif only on Solaris systems.

$(eval $(call PACKAGE_template,golang.org/x/net/lif))

golangorg_x_net_lif_lo = \
	golang.org/x/net/lif.lo

endif

TEST_PACKAGES = $(addsuffix /check,$(shell cat $(srcdir)/check-packages.txt))

check: check-tail
check-recursive: check-head

check-head:
	@echo "Test Run By $${USER} on `date`" > libgo.head
	@echo "Native configuration is $(host_triplet)" >> libgo.head
	@echo >> libgo.head
	@echo "		=== libgo tests ===" >> libgo.head
	@echo >> libgo.head

check-tail: check-recursive check-multi
	@if test "$(USE_DEJAGNU)" = "yes"; then \
	  exit 0; \
	fi; \
	lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
	for dir in . $(MULTIDIRS); do \
	  mv ../$${dir}/$${lib}/libgo.sum ../$${dir}/$${lib}/libgo.sum.sep; \
	  mv ../$${dir}/$${lib}/libgo.log ../$${dir}/$${lib}/libgo.log.sep; \
	done; \
	mv libgo.head libgo.sum; \
	cp libgo.sum libgo.log; \
	echo "Schedule of variations:" >> libgo.sum; \
	for dir in . $(MULTIDIRS); do \
	  multidir=../$${dir}/$${lib}; \
	  multivar=`cat $${multidir}/libgo.var`; \
	  echo "    $${multivar}" >> libgo.sum; \
	done; \
	echo >> libgo.sum; \
	pass=0; fail=0; untested=0; \
	for dir in . $(MULTIDIRS); do \
	  multidir=../$${dir}/$${lib}; \
	  multivar=`cat $${multidir}/libgo.var`; \
	  echo "Running target $${multivar}" >> libgo.sum; \
	  echo "Running $(srcdir)/libgo.exp ..." >> libgo.sum; \
	  cat $${multidir}/libgo.sum.sep >> libgo.sum; \
	  cat $${multidir}/libgo.log.sep >> libgo.log; \
	  if test -n "${MULTIDIRS}"; then \
	    echo "		=== libgo Summary for $${multivar} ===" >> libgo.sum; \
	    echo >> libgo.sum; \
	  fi; \
	  p=`grep -c PASS $${multidir}/libgo.sum.sep`; \
	  pass=`expr $$pass + $$p`; \
	  if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
	    echo "# of expected passes		$$p" >> libgo.sum; \
	  fi; \
	  p=`grep -c FAIL $${multidir}/libgo.sum.sep`; \
	  fail=`expr $$fail + $$p`; \
	  if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
	    echo "# of unexpected failures	$$p" >> libgo.sum; \
	  fi; \
	  p=`grep -c UNTESTED $${multidir}/libgo.sum.sep`; \
	  untested=`expr $$untested + $$p`; \
	  if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
	    echo "# of untested testcases		$$p" >> libgo.sum; \
	  fi; \
	done; \
	echo >> libgo.sum; \
	echo "		=== libgo Summary ===" >> libgo.sum; \
	echo >> libgo.sum; \
	if test "$$pass" -ne "0"; then \
	  echo "# of expected passes		$$pass" >> libgo.sum; \
	fi; \
	if test "$$fail" -ne "0"; then \
	  echo "# of unexpected failures	$$fail" >> libgo.sum; \
	fi; \
	if test "$$untested" -ne "0"; then \
	  echo "# of untested testcases		$$untested" >> libgo.sum; \
	fi; \
	echo `echo $(GOC) | sed -e 's/ .*//'`  `$(GOC) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*\)$$/\1/p'` >> libgo.sum; \
	echo >> libgo.log; \
	echo "runtest completed at `date`" >> libgo.log; \
	if test "$$fail" -ne "0"; then \
	  status=1; \
	else \
	  status=0; \
	fi; \
	exit $$status

check-am:
	@rm -f libgo.sum libgo.log libgo.tail
	@multivar="unix"; \
	[ -z "$(MULTIFLAGS)" ] || multivar="$${multivar}/$(MULTIFLAGS)"; \
	echo "$${multivar}" > libgo.var
	@for f in $(TEST_PACKAGES); do \
	   rm -f $$f-testsum $$f-testlog; \
	 done
	-@$(MAKE) $(AM_MAKEFLAGS) -k $(TEST_PACKAGES)
	@for f in $(TEST_PACKAGES); do \
	  if test -f $$f-testsum; then \
	    cat $$f-testsum >> libgo.sum; \
	  fi; \
	  if test -f $$f-testlog; then \
	    cat $$f-testlog >> libgo.log; \
	  fi; \
	done

check-multi:
	$(MULTIDO) $(AM_MAKEFLAGS) DO=check-am multi-do # $(MAKE)

bench:
	-@$(MAKE) $(AM_MAKEFLAGS) -k $(TEST_PACKAGES) GOBENCH=.

MOSTLYCLEANFILES = \
	s-runtime_sysinfo s-sigtab s-runtime-inc s-zstdpkglist \
	s-libcalls s-libcalls-list s-syscall_arch s-gen-sysinfo s-sysinfo \
	s-errno s-epoll \
	libgo.head libgo.sum.sep libgo.log.sep libgo.var \
	libcalls-list \
	runtime.inc runtime.inc.tmp2 runtime.inc.tmp3 runtime.inc.raw

mostlyclean-local:
	find . -name '*.lo' -print | xargs $(LIBTOOL) --mode=clean rm -f
	find . -name '*.$(OBJEXT)' -print | xargs rm -f
	find . -name '*-testsum' -print | xargs rm -f
	find . -name '*-testlog' -print | xargs rm -f

CLEANFILES = *.go *.c s-* libgo.sum libgo.log runtime.inc

clean-local:
	find . -name '*.la' -print | xargs $(LIBTOOL) --mode=clean rm -f
	find . -name '*.a' -print | xargs rm -f
	find . -name '*.gox' -print | xargs rm -f
	find . -name '*.s-gox' -print | xargs rm -f

distclean-local:
	find . -name '*.lo.dep' -print | xargs rm -f

include $(top_srcdir)/../multilib.am

if LIBGO_IS_AIX
ALL_LOCAL_DEPS = add-aix-fat-library
else
ALL_LOCAL_DEPS =
endif
all-local: $(ALL_LOCAL_DEPS)

MAJOR=$(firstword $(subst :, ,$(libtool_VERSION)))

# If we want to use "AR -r" when creating AIX FAT archives,
# AR must be stripped of all its -X flags.
# Otherwize, if AR was defined with -X32_64, the replace option would
# erase the default .so when adding the extra one. There is no
# order priority within -X flags.
add-aix-fat-library: all-multi
	@if test "$(MULTIBUILDTOP)" = ""; then \
	  arx=`echo $(AR) | sed -e 's/-X[^ ]*//g'`; \
	  $${arx} -X$(AIX_EXTRA_ARCH) rc .libs/$(PACKAGE).a ../ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
	  $${arx} -X$(AIX_EXTRA_ARCH) rc ../pthread/$(PACKAGE)/.libs/$(PACKAGE).a ../pthread/ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
	  $${arx} -X$(AIX_EXTRA_ARCH) rc libgobegin.a ../ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/$(libgobegin_a_OBJECTS); \
	  $${arx} -X$(AIX_EXTRA_ARCH) rc ../pthread/$(PACKAGE)/libgobegin.a ../pthread/ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/$(libgobegin_a_OBJECTS); \
	  $${arx} -X$(AIX_EXTRA_ARCH) rc libgolibbegin.a ../ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/$(libgolibbegin_a_OBJECTS); \
	  $${arx} -X$(AIX_EXTRA_ARCH) rc ../pthread/$(PACKAGE)/libgolibbegin.a ../pthread/ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/$(libgolibbegin_a_OBJECTS); \
	fi