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