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