1 # Makefile.am -- Go library Makefile.
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.
7 # Process this file with autoreconf to produce Makefile.in.
10 SUFFIXES = .c .go .gox .o .obj .lo .a
18 gcc_version := $(shell $(GOC) -dumpversion)
20 MAINT_CHARSET = latin1
22 mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
23 PWD_COMMAND = $${PWDCMD-pwd}
24 STAMP = echo timestamp >
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)
32 LIBFFIINCS = @LIBFFIINCS@
34 LIBATOMIC = @LIBATOMIC@
36 WARN_CFLAGS = $(WARN_FLAGS) $(WERROR)
38 # -I/-D flags to pass when compiling.
39 AM_CPPFLAGS = -I $(srcdir)/runtime $(LIBFFIINCS) $(PTHREAD_CFLAGS)
41 ACLOCAL_AMFLAGS = -I ./config -I ../config
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
52 AM_LDFLAGS += -XCClinker $(SPLIT_STACK)
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
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.
69 "AR_FLAGS=$(AR_FLAGS)" \
70 "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
71 "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
73 "CXXFLAGS=$(CXXFLAGS)" \
74 "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
75 "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
76 "GOC_FOR_TARGET=$(GOC_FOR_TARGET)" \
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)" \
87 "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
88 "PICFLAG=$(PICFLAG)" \
89 "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
91 "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
92 "exec_prefix=$(exec_prefix)" \
93 "infodir=$(infodir)" \
95 "includedir=$(includedir)" \
97 "tooldir=$(tooldir)" \
98 "gxx_include_dir=$(gxx_include_dir)" \
104 "NM_FOR_BUILD=$(NM_FOR_BUILD)" \
105 "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
106 "DESTDIR=$(DESTDIR)" \
109 # Subdir rules rely on $(FLAGS_TO_PASS)
110 FLAGS_TO_PASS = $(AM_MAKEFLAGS)
113 toolexeclib_LTLIBRARIES = libgo-llgo.la
114 toolexeclib_LIBRARIES = libgobegin-llgo.a
116 toolexeclib_LTLIBRARIES = libgo.la
117 toolexeclib_LIBRARIES = libgobegin.a libgolibbegin.a
120 noinst_LIBRARIES = libgotool.a
122 toolexeclibgo_DATA = \
154 toolexeclibgoarchivedir = $(toolexeclibgodir)/archive
156 toolexeclibgoarchive_DATA = \
160 toolexeclibgocompressdir = $(toolexeclibgodir)/compress
162 toolexeclibgocompress_DATA = \
169 toolexeclibgocontainerdir = $(toolexeclibgodir)/container
171 toolexeclibgocontainer_DATA = \
176 toolexeclibgocryptodir = $(toolexeclibgodir)/crypto
178 toolexeclibgocrypto_DATA = \
184 crypto/elliptic.gox \
197 toolexeclibgocryptox509dir = $(toolexeclibgocryptodir)/x509
199 toolexeclibgocryptox509_DATA = \
202 toolexeclibgodatabasedir = $(toolexeclibgodir)/database
204 toolexeclibgodatabase_DATA = \
207 toolexeclibgodatabasesqldir = $(toolexeclibgodatabasedir)/sql
209 toolexeclibgodatabasesql_DATA = \
210 database/sql/driver.gox
212 toolexeclibgodebugdir = $(toolexeclibgodir)/debug
214 toolexeclibgodebug_DATA = \
222 toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding
224 toolexeclibgoencoding_DATA = \
225 encoding/ascii85.gox \
227 encoding/base32.gox \
228 encoding/base64.gox \
229 encoding/binary.gox \
237 toolexeclibgogodir = $(toolexeclibgodir)/go
239 toolexeclibgogo_DATA = \
252 toolexeclibgohashdir = $(toolexeclibgodir)/hash
254 toolexeclibgohash_DATA = \
260 toolexeclibgohtmldir = $(toolexeclibgodir)/html
262 toolexeclibgohtml_DATA = \
265 toolexeclibgoimagedir = $(toolexeclibgodir)/image
267 toolexeclibgoimage_DATA = \
274 toolexeclibgoimagecolordir = $(toolexeclibgoimagedir)/color
276 toolexeclibgoimagecolor_DATA = \
277 image/color/palette.gox
279 toolexeclibgoindexdir = $(toolexeclibgodir)/index
281 toolexeclibgoindex_DATA = \
282 index/suffixarray.gox
284 toolexeclibgoiodir = $(toolexeclibgodir)/io
286 toolexeclibgoio_DATA = \
289 toolexeclibgologdir = $(toolexeclibgodir)/log
291 toolexeclibgolog_DATA = \
294 toolexeclibgomathdir = $(toolexeclibgodir)/math
296 toolexeclibgomath_DATA = \
302 toolexeclibgomimedir = $(toolexeclibgodir)/mime
304 toolexeclibgomime_DATA = \
306 mime/quotedprintable.gox
308 toolexeclibgonetdir = $(toolexeclibgodir)/net
310 toolexeclibgonet_DATA = \
318 toolexeclibgonethttpdir = $(toolexeclibgonetdir)/http
320 toolexeclibgonethttp_DATA = \
322 net/http/cookiejar.gox \
324 net/http/httptest.gox \
325 net/http/httptrace.gox \
326 net/http/httputil.gox \
329 toolexeclibgonetrpcdir = $(toolexeclibgonetdir)/rpc
331 toolexeclibgonetrpc_DATA = \
334 toolexeclibgoosdir = $(toolexeclibgodir)/os
336 toolexeclibgoos_DATA = \
341 toolexeclibgopathdir = $(toolexeclibgodir)/path
343 toolexeclibgopath_DATA = \
346 toolexeclibgoregexpdir = $(toolexeclibgodir)/regexp
348 toolexeclibgoregexp_DATA = \
351 toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
353 toolexeclibgoruntime_DATA = \
358 toolexeclibgosyncdir = $(toolexeclibgodir)/sync
360 toolexeclibgosync_DATA = \
363 toolexeclibgotestingdir = $(toolexeclibgodir)/testing
365 toolexeclibgotesting_DATA = \
369 toolexeclibgotestinginternaldir = $(toolexeclibgotestingdir)/internal
371 toolexeclibgotestinginternal_DATA = \
372 testing/internal/testdeps.gox
374 toolexeclibgotextdir = $(toolexeclibgodir)/text
376 toolexeclibgotext_DATA = \
381 toolexeclibgotexttemplatedir = $(toolexeclibgotextdir)/template
383 toolexeclibgotexttemplate_DATA = \
384 text/template/parse.gox
386 toolexeclibgounicodedir = $(toolexeclibgodir)/unicode
388 toolexeclibgounicode_DATA = \
392 # Some packages are only needed for tests, so unlike the other
393 # internal packages nothing will explicitly depend on them.
394 # Force them to be built.
396 internal/x/net/internal/nettest.gox \
397 internal/x/net/nettest.gox \
398 internal/testenv.gox \
400 net/internal/socktest.gox \
401 os/signal/internal/pty.gox \
402 runtime/pprof/internal/profile.gox
405 rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
407 rtems_task_variable_add_file =
411 runtime_getncpu_file = runtime/getncpu-linux.c
414 runtime_getncpu_file = runtime/getncpu-bsd.c
417 runtime_getncpu_file = runtime/getncpu-irix.c
420 runtime_getncpu_file = runtime/getncpu-solaris.c
423 runtime_getncpu_file = runtime/getncpu-bsd.c
426 runtime_getncpu_file = runtime/getncpu-bsd.c
429 runtime_getncpu_file = runtime/getncpu-aix.c
431 runtime_getncpu_file = runtime/getncpu-none.c
442 runtime/go-assert.c \
443 runtime/go-caller.c \
444 runtime/go-callers.c \
447 runtime/go-construct-map.c \
449 runtime/go-fieldtrack.c \
450 runtime/go-matherr.c \
451 runtime/go-memclr.c \
452 runtime/go-memcmp.c \
453 runtime/go-memequal.c \
454 runtime/go-memmove.c \
455 runtime/go-nanotime.c \
458 runtime/go-reflect-call.c \
459 runtime/go-runtime-error.c \
460 runtime/go-setenv.c \
461 runtime/go-signal.c \
462 runtime/go-strslice.c \
463 runtime/go-typedesc-equal.c \
464 runtime/go-unsafe-pointer.c \
465 runtime/go-unsetenv.c \
466 runtime/go-unwind.c \
467 runtime/go-varargs.c \
468 runtime/env_posix.c \
472 runtime/runtime_c.c \
476 $(rtems_task_variable_add_file) \
477 $(runtime_getncpu_file)
479 version.go: s-version; @true
482 echo "package sys" > version.go.tmp
483 echo 'func init() { DefaultGoroot = "$(prefix)" }' >> version.go.tmp
484 echo 'const TheVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp
485 echo 'const Goexperiment = ``' >> version.go.tmp
486 echo 'const GOARCH = "'$(GOARCH)'"' >> version.go.tmp
487 echo 'const GOOS = "'$(GOOS)'"' >> version.go.tmp
488 echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp
489 echo >> version.go.tmp
490 echo "type ArchFamilyType int" >> version.go.tmp
491 echo >> version.go.tmp
492 echo "const (" >> version.go.tmp
493 echo " UNKNOWN ArchFamilyType = iota" >> version.go.tmp
494 for a in $(ALLGOARCHFAMILY); do \
495 echo " $${a}" >> version.go.tmp; \
497 echo ")" >> version.go.tmp
498 echo >> version.go.tmp
499 for a in $(ALLGOARCH); do \
500 f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
501 n="$${f}`echo $${a} | sed -e 's/.//'`"; \
502 if test "$${a}" = "$(GOARCH)"; then \
503 echo "const Goarch$${n} = 1" >> version.go.tmp; \
505 echo "const Goarch$${n} = 0" >> version.go.tmp; \
508 echo >> version.go.tmp
509 echo "const (" >> version.go.tmp
510 echo " ArchFamily = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) family`" >> version.go.tmp
511 echo " BigEndian = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) bigendian`" >> version.go.tmp
512 echo " CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> version.go.tmp
513 echo " DefaultPhysPageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) defaultphyspagesize`" >> version.go.tmp
514 echo " HugePageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) hugepagesize`" >> version.go.tmp
515 echo " Int64Align = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) int64align`" >> version.go.tmp
516 echo " MinFrameSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) minframesize`" >> version.go.tmp
517 echo " PCQuantum = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) pcquantum`" >> version.go.tmp
518 echo ")" >> version.go.tmp
519 echo >> version.go.tmp
520 for a in $(ALLGOOS); do \
521 f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
522 n="$${f}`echo $${a} | sed -e 's/.//'`"; \
523 if test "$${a}" = "$(GOOS)"; then \
524 echo "const Goos$${n} = 1" >> version.go.tmp; \
526 echo "const Goos$${n} = 0" >> version.go.tmp; \
529 echo >> version.go.tmp
530 echo "type Uintreg uintptr" >> version.go.tmp
531 $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
534 cpugen.go: s-cpu; @true
537 echo "package cpu" > cpugen.go.tmp
538 echo "const CacheLinePadSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp
539 $(SHELL) $(srcdir)/mvifdiff.sh cpugen.go.tmp cpugen.go
542 objabi.go: s-objabi; @true
545 echo "package objabi" > objabi.go.tmp
546 echo "import \"runtime\"" >> objabi.go.tmp
547 echo 'func init() { defaultGOROOT = `$(prefix)` }' >> objabi.go.tmp
548 echo 'const defaultGO386 = `sse2`' >> objabi.go.tmp
549 echo 'const defaultGOARM = `5`' >> objabi.go.tmp
550 echo 'const defaultGOMIPS = `hardfloat`' >> objabi.go.tmp
551 echo 'const defaultGOMIPS64 = `hardfloat`' >> objabi.go.tmp
552 echo 'const defaultGOOS = runtime.GOOS' >> objabi.go.tmp
553 echo 'const defaultGOARCH = runtime.GOARCH' >> objabi.go.tmp
554 echo 'const defaultGO_EXTLINK_ENABLED = ``' >> objabi.go.tmp
555 echo 'const version = `'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'`' >> objabi.go.tmp
556 echo 'const stackGuardMultiplierDefault = 1' >> objabi.go.tmp
557 echo 'const goexperiment = ``' >> objabi.go.tmp
558 $(SHELL) $(srcdir)/mvifdiff.sh objabi.go.tmp objabi.go
561 gccgosizes.go: s-gccgosizes; @true
562 s-gccgosizes: Makefile goarch.sh
563 rm -f gccgosizes.go.tmp
564 echo "package types" > gccgosizes.go.tmp
565 echo >> gccgosizes.go.tmp
566 echo "var gccgoArchSizes = map[string]*StdSizes{" >> gccgosizes.go.tmp
567 for a in $(ALLGOARCH); do \
568 ptrsize=`$(SHELL) $(srcdir)/goarch.sh $$a ptrsize`; \
569 maxalign=`$(SHELL) $(srcdir)/goarch.sh $$a maxalign`; \
570 echo " \"$$a\": {$${ptrsize}, $${maxalign}}," >> gccgosizes.go.tmp; \
572 echo "}" >> gccgosizes.go.tmp
573 $(SHELL) $(srcdir)/mvifdiff.sh gccgosizes.go.tmp gccgosizes.go
576 runtime_sysinfo.go: s-runtime_sysinfo; @true
577 s-runtime_sysinfo: $(srcdir)/mkrsysinfo.sh gen-sysinfo.go
578 GOARCH=$(GOARCH) GOOS=$(GOOS) $(SHELL) $(srcdir)/mkrsysinfo.sh
579 $(SHELL) $(srcdir)/mvifdiff.sh tmp-runtime_sysinfo.go runtime_sysinfo.go
582 sigtab.go: s-sigtab; @true
583 s-sigtab: $(srcdir)/mksigtab.sh gen-sysinfo.go
584 GOOS=$(GOOS) $(SHELL) $(srcdir)/mksigtab.sh > tmp-sigtab.go
585 $(SHELL) $(srcdir)/mvifdiff.sh tmp-sigtab.go sigtab.go
588 GCCGO_INSTALL_NAME := $(shell echo gccgo|sed '$(program_transform_name)')
589 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
590 GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
592 zdefaultcc.go: s-zdefaultcc; @true
593 s-zdefaultcc: Makefile
594 echo 'package cfg' > zdefaultcc.go.tmp
595 echo >> zdefaultcc.go.tmp
596 echo 'func DefaultGCCGO(goos, goarch string) string { return "$(bindir)/$(GCCGO_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
597 echo 'func DefaultCC(goos, goarch string) string { return "$(GCC_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
598 echo 'func DefaultCXX(goos, goarch string) string { return "$(GXX_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
599 echo 'const DefaultPkgConfig = "pkg-config"' >> zdefaultcc.go.tmp
600 echo 'var OSArchSupportsCgo = map[string]bool{}' >> zdefaultcc.go.tmp
601 $(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
604 # Post-process runtime.inc.raw (raw output of -fgo-c-header option when
605 # compiling runtime) to prune out certain types that should not be
606 # exported back to C. See comments in mkruntimeinc.sh for more details.
607 runtime.inc: s-runtime-inc; @true
608 s-runtime-inc: runtime.lo Makefile
609 $(SHELL) $(srcdir)/mkruntimeinc.sh
610 $(SHELL) $(srcdir)/mvifdiff.sh tmp-runtime.inc runtime.inc
613 noinst_DATA += zdefaultcc.go
615 # Generate the list of go std packages that were included in libgo
616 zstdpkglist.go: s-zstdpkglist; @true
617 s-zstdpkglist: Makefile
618 rm -f zstdpkglist.go.tmp
619 echo 'package goroot' > zstdpkglist.go.tmp
620 echo "" >> zstdpkglist.go.tmp
621 echo 'var stdpkg = map[string]bool{' >> zstdpkglist.go.tmp
622 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
623 echo '}' >> zstdpkglist.go.tmp
624 $(SHELL) $(srcdir)/mvifdiff.sh zstdpkglist.go.tmp zstdpkglist.go
628 syscall_epoll_file = epoll.go
633 libcalls.go: s-libcalls; @true
634 s-libcalls: libcalls-list go/syscall/mksyscall.awk $(srcdir)/go/syscall/*.go
635 rm -f libcalls.go.tmp
636 $(AWK) -f $(srcdir)/go/syscall/mksyscall.awk `cat libcalls-list` > libcalls.go.tmp
637 $(SHELL) $(srcdir)/mvifdiff.sh libcalls.go.tmp libcalls.go
640 libcalls-list: s-libcalls-list; @true
641 s-libcalls-list: Makefile $(srcdir)/go/syscall/*.go
642 rm -f libcalls-list.tmp
643 $(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/syscall $(matchargs_syscall) > libcalls-list.tmp
644 $(SHELL) $(srcdir)/mvifdiff.sh libcalls-list.tmp libcalls-list
647 syscall_arch.go: s-syscall_arch; @true
648 s-syscall_arch: Makefile
649 rm -f syscall_arch.go.tmp
650 echo "package syscall" > syscall_arch.go.tmp
651 echo 'const ARCH = "'$(GOARCH)'"' >> syscall_arch.go.tmp
652 echo 'const OS = "'$(GOOS)'"' >> syscall_arch.go.tmp
653 $(SHELL) $(srcdir)/mvifdiff.sh syscall_arch.go.tmp syscall_arch.go
657 $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
658 $(CPPFLAGS) $(OSCFLAGS) -O
660 gen-sysinfo.go: s-gen-sysinfo; @true
661 s-gen-sysinfo: $(srcdir)/sysinfo.c config.h
662 $(CC) $(SYSINFO_FLAGS) -fdump-go-spec=tmp-gen-sysinfo.go -std=gnu99 -S -o sysinfo.s $(srcdir)/sysinfo.c
664 $(SHELL) $(srcdir)/mvifdiff.sh tmp-gen-sysinfo.go gen-sysinfo.go
667 errno.i: s-errno; @true
669 echo '#include <errno.h>' | $(CC) $(SYSINFO_FLAGS) -x c - -E -dM > tmp-errno.i
670 $(SHELL) $(srcdir)/mvifdiff.sh tmp-errno.i errno.i
673 sysinfo.go: s-sysinfo; @true
674 s-sysinfo: $(srcdir)/mksysinfo.sh gen-sysinfo.go errno.i
675 GOARCH=$(GOARCH) GOOS=$(GOOS) $(SHELL) $(srcdir)/mksysinfo.sh
676 $(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go
679 # The epoll struct has an embedded union and is packed on x86_64,
680 # which is too complicated for mksysinfo.sh. We find the offset of
681 # the only field we care about in configure.ac, and generate the
683 epoll.go: s-epoll; @true
686 echo 'package syscall' > epoll.go.tmp
687 echo 'type EpollEvent struct {' >> epoll.go.tmp
688 echo ' Events uint32' >> epoll.go.tmp
689 case "$(SIZEOF_STRUCT_EPOLL_EVENT),$(STRUCT_EPOLL_EVENT_FD_OFFSET)" in \
690 0,0) echo 1>&2 "*** struct epoll_event data.fd offset unknown"; \
692 8,4) echo ' Fd int32' >> epoll.go.tmp; ;; \
693 12,4) echo ' Fd int32' >> epoll.go.tmp; \
694 echo ' Pad [4]byte' >> epoll.go.tmp; ;; \
695 12,8) echo ' Pad [4]byte' >> epoll.go.tmp; \
696 echo ' Fd int32' >> epoll.go.tmp; ;; \
697 16,8) echo ' Pad [4]byte' >> epoll.go.tmp; \
698 echo ' Fd int32' >> epoll.go.tmp; \
699 echo ' Pad2 [4]byte' >> epoll.go.tmp; ;; \
700 *) echo 1>&2 "*** struct epoll_event unsupported"; \
703 echo '}' >> epoll.go.tmp
704 $(SHELL) $(srcdir)/mvifdiff.sh epoll.go.tmp epoll.go
708 syscall_lib_clone_lo = syscall/clone_linux.lo
710 syscall_lib_clone_lo =
713 PACKAGES = $(shell cat $(srcdir)/libgo-packages.txt)
716 $(addsuffix .lo,$(PACKAGES)) \
717 internal/bytealg/bytealg.lo \
718 reflect/makefunc_ffi_c.lo \
719 $(syscall_lib_clone_lo) \
723 $(internal_x_net_lif_lo) \
724 $(internal_x_net_route_lo) \
725 log/syslog/syslog_c.lo \
726 $(os_lib_inotify_lo) \
727 runtime/internal/atomic_c.lo \
729 internal/cpu/cpu_gccgo.lo
732 -version-info $(libtool_VERSION) $(PTHREAD_CFLAGS) $(AM_LDFLAGS)
735 $(libgo_go_objs) ../libbacktrace/libbacktrace.la \
736 $(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)
738 libgo_la_SOURCES = $(runtime_files)
739 libgo_la_LDFLAGS = $(libgo_ldflags)
740 libgo_la_LIBADD = $(libgo_libadd)
742 libgo_llgo_la_SOURCES = $(runtime_files)
743 libgo_llgo_la_LDFLAGS = $(libgo_ldflags)
744 libgo_llgo_la_LIBADD = $(libgo_libadd)
746 libgobegin_a_SOURCES = \
749 libgobegin_llgo_a_SOURCES = \
752 # Use -fPIC for libgobegin so that it can be put in a PIE.
753 libgobegin_a_CFLAGS = $(AM_CFLAGS) -fPIC
754 libgobegin_llgo_a_CFLAGS = $(AM_CFLAGS) -fPIC
756 libgolibbegin_a_SOURCES = \
759 libgolibbegin_a_CFLAGS = $(AM_CFLAGS) -fPIC
761 GOTOOL_PACKAGES = $(shell cat $(srcdir)/gotool-packages.txt)
763 libgotool_a_SOURCES =
764 libgotool_a_DEPENDENCIES = $(addsuffix .lo,$(GOTOOL_PACKAGES))
765 libgotool_a_LIBADD = $(addsuffix .o,$(GOTOOL_PACKAGES))
767 define STATIC_template
768 $(subst -,_,$(subst .,_,$(subst /,_,$(1))))_GOCFLAGS = -static
771 $(foreach package,$(GOTOOL_PACKAGES),$(eval $(call STATIC_template,$(package).lo)))
773 # Make sure runtime.inc is built before compiling any .c file.
774 $(libgo_la_OBJECTS): runtime.inc
775 $(libgo_llgo_la_OBJECTS): runtime.inc
776 $(libgobegin_a_OBJECTS): runtime.inc
777 $(libgobegin_llgo_a_OBJECTS): runtime.inc
778 $(libgolibbegin_a_OBJECTS): runtime.inc
780 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
783 AM_GOCFLAGS = $(STRINGOPS_FLAG) $(GO_SPLIT_STACK)
784 GOCOMPILE = $(GOC) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_GOCFLAGS) $(GOCFLAGS)
786 LTGOCOMPILE = $(LIBTOOL) --tag GO --mode=compile $(GOC) $(INCLUDES) \
787 $(AM_GOCFLAGS) $(GOCFLAGS)
789 GOLINK = $(LIBTOOL) --tag GO --mode-link $(GOC) \
790 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_GOCFLAGS) $(LTLDFLAGS) -o $@
792 # Build the dependencies for a Go package.
795 dir=`echo $@ | sed -e 's/.lo.dep$$//'`; \
796 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,,$@)))`; \
797 $(SHELL) $(srcdir)/godeps.sh `echo $@ | sed -e 's/.dep$$//'` $$files > $@.tmp; \
798 if ! cmp $@.tmp $@ >/dev/null 2>/dev/null; then \
799 rm -f `echo $@ | sed -e 's/\.dep$$//'`; \
803 # Build the .go files for a package, generating a .lo file.
806 files=`echo $^ | sed -e 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; \
807 $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//'` $($(subst -,_,$(subst .,_,$(subst /,_,$@)))_GOCFLAGS) -o $@ $$files
809 # How to build a .gox file from a .lo file.
810 # Matching .o file can either be in the same directory as the .lo (non-PIC
811 # object) or in the .libs directory (PIC object).
813 f="$(basename $<).o"; \
814 if test ! -f $$f; then \
815 f="$(basename $(<D)/.libs/$(<F)).o"; \
817 $(OBJCOPY) -j .go_export $$f $@.tmp; \
818 $(SHELL) $(srcdir)/mvifdiff.sh $@.tmp `echo $@ | sed -e 's/s-gox/gox/'`
825 GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \
827 GOLIBS="$(extra_check_libs_$(subst /,_,$(@D))) $(MATH_LIBS) $(NET_LIBS) $(LIBS)"; \
829 RUNTESTFLAGS="$(RUNTESTFLAGS)"; \
830 export RUNTESTFLAGS; \
835 libgccdir=`${GOC} ${GOCFLAGS} -print-libgcc-file-name | sed -e 's|/[^/]*$$||'`; \
836 LD_LIBRARY_PATH="`${PWD_COMMAND}`/.libs:$${libgccdir}:${LD_LIBRARY_PATH}"; \
837 LD_LIBRARY_PATH=`echo $${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
838 export LD_LIBRARY_PATH; \
840 rm -f $@-testsum $@-testlog; \
841 files=`$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/$(@D) --extrafiles="$(extra_go_files_$(subst /,_,$(@D)))" $(matchargs_$(subst /,_,$(@D)))`; \
842 if test "$(USE_DEJAGNU)" = "yes"; then \
843 $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --testname="$(@D)" $(GOTESTFLAGS); \
844 elif test "$(GOBENCH)" != ""; then \
845 $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --bench="$(GOBENCH)" $(GOTESTFLAGS); \
847 if $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" $(GOTESTFLAGS) >>$@-testlog 2>&1; then \
848 echo "PASS: $(@D)" >> $@-testlog; \
849 echo "PASS: $(@D)"; \
850 echo "PASS: $(@D)" > $@-testsum; \
852 echo "FAIL: $(@D)" >> $@-testlog; \
854 echo "FAIL: $(@D)" > $@-testsum; \
859 # Build all packages before checking any.
861 $(toolexeclibgo_DATA) \
862 $(toolexeclibgoarchive_DATA) \
863 $(toolexeclibgocompress_DATA) \
864 $(toolexeclibgocontainer_DATA) \
865 $(toolexeclibgocrypto_DATA) \
866 $(toolexeclibgodebug_DATA) \
867 $(toolexeclibgoencoding_DATA) \
868 $(toolexeclibgogo_DATA) \
869 $(toolexeclibgohash_DATA) \
870 $(toolexeclibgoimage_DATA) \
871 $(toolexeclibgoindex_DATA) \
872 $(toolexeclibgoio_DATA) \
873 $(toolexeclibgolog_DATA) \
874 $(toolexeclibgomath_DATA) \
875 $(toolexeclibgomime_DATA) \
876 $(toolexeclibgonet_DATA) \
877 $(toolexeclibgonethttp_DATA) \
878 $(toolexeclibgoos_DATA) \
879 $(toolexeclibgopath_DATA) \
880 $(toolexeclibgorpc_DATA) \
881 $(toolexeclibgoruntime_DATA) \
882 $(toolexeclibgosync_DATA) \
883 $(toolexeclibgotesting_DATA) \
884 $(toolexeclibgotext_DATA) \
885 $(toolexeclibgotexttemplate_DATA) \
886 $(toolexeclibgounicode_DATA) \
891 CHECK_DEPS += libgo-llgo.la libgobegin-llgo.a
893 CHECK_DEPS += libgo.la libgobegin.a
896 # PACKAGE_template defines the rules for each package.
897 # For example, for the package bufio, it produces:
899 # @go_include@ bufio.lo.dep
900 # bufio.lo.dep: $(srcdir)/go/bufio/*.go
904 # bufio/check: $(CHECK_DEPS)
906 # .PHONY: bufio/check
908 # This is invoked with $(1) set to a package, which is a directory name,
909 # such as "bufio" or "archive/tar".
910 define PACKAGE_template
911 @go_include@ $(1).lo.dep
912 $(1).lo.dep: $(srcdir)/go/$(1)/*.go
916 $(1)/check: $$(CHECK_DEPS)
919 $(1).gox: $(1).s-gox; @true
925 # This line expands PACKAGE_template once for each package name listed
927 $(foreach package,$(PACKAGES),$(eval $(call PACKAGE_template,$(package))))
928 $(foreach package,$(GOTOOL_PACKAGES),$(eval $(call PACKAGE_template,$(package))))
930 # Pass -ffp-contract=off, or 386-specific options, when building the
931 # math package. MATH_FLAG is defined in configure.ac.
932 math_lo_GOCFLAGS = $(MATH_FLAG)
933 math_check_GOCFLAGS = $(MATH_FLAG)
935 # Add the generated file runtime_sysinfo.go to the runtime package.
936 extra_go_files_runtime = runtime_sysinfo.go sigtab.go
937 runtime.lo.dep: $(extra_go_files_runtime)
939 # Add generated files to the syscall package.
940 extra_go_files_syscall = \
944 $(syscall_epoll_file)
945 syscall.lo.dep: $(extra_go_files_syscall)
947 # Pass -fgo-compiling-runtime when compiling the runtime package.
948 runtime_lo_GOCFLAGS = -fgo-c-header=runtime.inc.raw -fgo-compiling-runtime
949 runtime_check_GOCFLAGS = -fgo-compiling-runtime
950 runtime_internal_atomic_lo_GOCFLAGS = -fgo-compiling-runtime
951 runtime_internal_atomic_lo_check_GOCFLAGS = -fgo-compiling-runtime
952 runtime_internal_sys_lo_GOCFLAGS = -fgo-compiling-runtime
953 runtime_internal_sys_lo_check_GOCFLAGS = -fgo-compiling-runtime
955 # If libffi is supported (the normal case) use the ffi build tag for
956 # the runtime package.
958 matchargs_runtime = --tag=libffi
963 # At least for now, we need -static-libgo for this test, because
964 # otherwise we can't get the line numbers.
965 # Also use -fno-inline to get better results from the memory profiler.
966 runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline
968 extra_go_files_runtime_internal_sys = version.go
969 runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys)
971 extra_go_files_internal_cpu = cpugen.go
972 internal/cpu.lo.dep: $(extra_go_files_internal_cpu)
974 extra_go_files_internal_goroot = zstdpkglist.go
975 internal/goroot.lo.dep: $(extra_go_files_internal_goroot)
977 extra_go_files_go_types = gccgosizes.go
978 go/types.lo.dep: $(extra_go_files_go_types)
980 extra_go_files_cmd_internal_objabi = objabi.go
981 cmd/internal/objabi.lo.dep: $(extra_go_files_cmd_internal_objabi)
983 extra_go_files_cmd_go_internal_cfg = zdefaultcc.go
984 cmd/go/internal/cfg.lo.dep: $(extra_go_files_cmd_go_internal_cfg)
986 extra_check_libs_cmd_go_internal_cache = $(abs_builddir)/libgotool.a
987 extra_check_libs_cmd_go_internal_generate = $(abs_builddir)/libgotool.a
988 extra_check_libs_cmd_go_internal_get = $(abs_builddir)/libgotool.a
989 extra_check_libs_cmd_go_internal_load = $(abs_builddir)/libgotool.a
990 extra_check_libs_cmd_go_internal_lockedfile = $(abs_builddir)/libgotool.a
991 extra_check_libs_cmd_go_internal_imports = $(abs_builddir)/libgotool.a
992 extra_check_libs_cmd_go_internal_modconv = $(abs_builddir)/libgotool.a
993 extra_check_libs_cmd_go_internal_modfetch = $(abs_builddir)/libgotool.a
994 extra_check_libs_cmd_go_internal_modfetch_codehost = $(abs_builddir)/libgotool.a
995 extra_check_libs_cmd_go_internal_modfile = $(abs_builddir)/libgotool.a
996 extra_check_libs_cmd_go_internal_modload = $(abs_builddir)/libgotool.a
997 extra_check_libs_cmd_go_internal_module = $(abs_builddir)/libgotool.a
998 extra_check_libs_cmd_go_internal_mvs = $(abs_builddir)/libgotool.a
999 extra_check_libs_cmd_go_internal_search = $(abs_builddir)/libgotool.a
1000 extra_check_libs_cmd_go_internal_web2 = $(abs_builddir)/libgotool.a
1001 extra_check_libs_cmd_go_internal_work = $(abs_builddir)/libgotool.a
1003 extra_check_libs_cmd_vet_internal_cfg = $(abs_builddir)/libgotool.a
1005 # FIXME: The following C files may as well move to the runtime
1006 # directory and be treated like other C files.
1008 # Use C code to speed up internal/bytealg.IndexByte and friends.
1009 internal/bytealg/bytealg.lo: go/internal/bytealg/bytealg.c runtime.inc
1010 @$(MKDIR_P) internal/bytealg
1011 $(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/bytealg/bytealg.c
1013 # Use a C function with a fixed number of arguments to call a C
1015 log/syslog/syslog_c.lo: go/log/syslog/syslog_c.c runtime.inc
1016 @$(MKDIR_P) log/syslog
1017 $(LTCOMPILE) -c -o $@ $(srcdir)/go/log/syslog/syslog_c.c
1019 # The interface to libffi from the reflect package is written in C.
1020 reflect/makefunc_ffi_c.lo: go/reflect/makefunc_ffi_c.c runtime.inc
1022 $(LTCOMPILE) -c -o $@ $(srcdir)/go/reflect/makefunc_ffi_c.c
1024 # The atomic functions are written in C.
1025 runtime/internal/atomic_c.lo: go/runtime/internal/atomic/atomic.c runtime.inc
1026 @$(MKDIR_P) runtime/internal
1027 $(LTCOMPILE) -c -o $@ $(srcdir)/go/runtime/internal/atomic/atomic.c
1028 sync/atomic_c.lo: go/sync/atomic/atomic.c runtime.inc
1030 $(LTCOMPILE) -c -o $@ $(srcdir)/go/sync/atomic/atomic.c
1032 # A few syscall functions are written in C.
1033 syscall/clone_linux.lo: go/syscall/clone_linux.c runtime.inc
1035 $(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/clone_linux.c
1036 syscall/errno.lo: go/syscall/errno.c runtime.inc
1038 $(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/errno.c
1039 syscall/signame.lo: go/syscall/signame.c runtime.inc
1041 $(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/signame.c
1042 syscall/wait.lo: go/syscall/wait.c runtime.inc
1044 $(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/wait.c
1046 # internal/cpu needs some C code.
1047 internal/cpu/cpu_gccgo.lo: go/internal/cpu/cpu_gccgo.c runtime.inc
1048 @$(MKDIR_P) internal/cpu
1049 $(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/cpu/cpu_gccgo.c
1051 # Solaris 11.4 changed the type of fields in struct stat.
1052 # Use a build tag, based on a configure check, to cope.
1054 if HAVE_STAT_TIMESPEC
1055 matchargs_os = --tag=solaristag
1065 # Build internal/x/net/route only on BSD systems.
1067 $(eval $(call PACKAGE_template,internal/x/net/route))
1069 internal_x_net_route_lo = \
1070 internal/x/net/route.lo
1071 internal_x_net_route_check = \
1072 internal/x/net/route/check
1078 # Build internal/x/net/lif only on Solaris systems.
1080 $(eval $(call PACKAGE_template,internal/x/net/lif))
1082 internal_x_net_lif_lo = \
1083 internal/x/net/lif.lo
1084 internal_x_net_lif_check = \
1085 internal_org/x/net/lif/check
1089 TPACKAGES = $(shell cat $(srcdir)/check-packages.txt)
1090 TEST_PACKAGES = $(addsuffix /check,$(TPACKAGES)) \
1091 $(internal_x_net_lif_check) \
1092 $(internal_x_net_route_check)
1095 check-recursive: check-head
1098 @echo "Test Run By $${USER} on `date`" > libgo.head
1099 @echo "Native configuration is $(host_triplet)" >> libgo.head
1101 @echo " === libgo tests ===" >> libgo.head
1104 check-tail: check-recursive check-multi
1105 @if test "$(USE_DEJAGNU)" = "yes"; then \
1108 lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
1109 for dir in . $(MULTIDIRS); do \
1110 mv ../$${dir}/$${lib}/libgo.sum ../$${dir}/$${lib}/libgo.sum.sep; \
1111 mv ../$${dir}/$${lib}/libgo.log ../$${dir}/$${lib}/libgo.log.sep; \
1113 mv libgo.head libgo.sum; \
1114 cp libgo.sum libgo.log; \
1115 echo "Schedule of variations:" >> libgo.sum; \
1116 for dir in . $(MULTIDIRS); do \
1117 multidir=../$${dir}/$${lib}; \
1118 multivar=`cat $${multidir}/libgo.var`; \
1119 echo " $${multivar}" >> libgo.sum; \
1121 echo >> libgo.sum; \
1122 pass=0; fail=0; untested=0; \
1123 for dir in . $(MULTIDIRS); do \
1124 multidir=../$${dir}/$${lib}; \
1125 multivar=`cat $${multidir}/libgo.var`; \
1126 echo "Running target $${multivar}" >> libgo.sum; \
1127 echo "Running $(srcdir)/libgo.exp ..." >> libgo.sum; \
1128 cat $${multidir}/libgo.sum.sep >> libgo.sum; \
1129 cat $${multidir}/libgo.log.sep >> libgo.log; \
1130 if test -n "${MULTIDIRS}"; then \
1131 echo " === libgo Summary for $${multivar} ===" >> libgo.sum; \
1132 echo >> libgo.sum; \
1134 p=`grep -c PASS $${multidir}/libgo.sum.sep`; \
1135 pass=`expr $$pass + $$p`; \
1136 if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
1137 echo "# of expected passes $$p" >> libgo.sum; \
1139 p=`grep -c FAIL $${multidir}/libgo.sum.sep`; \
1140 fail=`expr $$fail + $$p`; \
1141 if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
1142 echo "# of unexpected failures $$p" >> libgo.sum; \
1144 p=`grep -c UNTESTED $${multidir}/libgo.sum.sep`; \
1145 untested=`expr $$untested + $$p`; \
1146 if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
1147 echo "# of untested testcases $$p" >> libgo.sum; \
1150 echo >> libgo.sum; \
1151 echo " === libgo Summary ===" >> libgo.sum; \
1152 echo >> libgo.sum; \
1153 if test "$$pass" -ne "0"; then \
1154 echo "# of expected passes $$pass" >> libgo.sum; \
1156 if test "$$fail" -ne "0"; then \
1157 echo "# of unexpected failures $$fail" >> libgo.sum; \
1159 if test "$$untested" -ne "0"; then \
1160 echo "# of untested testcases $$untested" >> libgo.sum; \
1162 echo `echo $(GOC) | sed -e 's/ .*//'` `$(GOC) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> libgo.sum; \
1163 echo >> libgo.log; \
1164 echo "runtest completed at `date`" >> libgo.log; \
1165 if test "$$fail" -ne "0"; then \
1173 @rm -f libgo.sum libgo.log libgo.tail
1175 [ -z "$(MULTIFLAGS)" ] || multivar="$${multivar}/$(MULTIFLAGS)"; \
1176 echo "$${multivar}" > libgo.var
1177 @for f in $(TEST_PACKAGES); do \
1178 rm -f $$f-testsum $$f-testlog; \
1180 -@$(MAKE) $(AM_MAKEFLAGS) -k $(TEST_PACKAGES)
1181 @for f in $(TEST_PACKAGES); do \
1182 if test -f $$f-testsum; then \
1183 cat $$f-testsum >> libgo.sum; \
1185 if test -f $$f-testlog; then \
1186 cat $$f-testlog >> libgo.log; \
1191 $(MULTIDO) $(AM_MAKEFLAGS) DO=check-am multi-do # $(MAKE)
1194 -@$(MAKE) $(AM_MAKEFLAGS) -k $(TEST_PACKAGES) GOBENCH=.
1196 MOSTLYCLEANFILES = \
1197 s-runtime_sysinfo s-sigtab s-runtime-inc s-zstdpkglist \
1198 s-libcalls s-libcalls-list s-syscall_arch s-gen-sysinfo s-sysinfo \
1200 libgo.head libgo.sum.sep libgo.log.sep libgo.var \
1201 libcalls-list runtime.inc runtime.inc.tmp2 runtime.inc.tmp3
1204 find . -name '*.lo' -print | xargs $(LIBTOOL) --mode=clean rm -f
1205 find . -name '*.$(OBJEXT)' -print | xargs rm -f
1206 find . -name '*-testsum' -print | xargs rm -f
1207 find . -name '*-testlog' -print | xargs rm -f
1209 CLEANFILES = *.go *.c s-* libgo.sum libgo.log runtime.inc
1212 find . -name '*.la' -print | xargs $(LIBTOOL) --mode=clean rm -f
1213 find . -name '*.a' -print | xargs rm -f
1214 find . -name '*.gox' -print | xargs rm -f
1215 find . -name '*.s-gox' -print | xargs rm -f
1218 find . -name '*.lo.dep' -print | xargs rm -f
1220 include $(top_srcdir)/../multilib.am