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
17 GO_EXPORT_SECTION_NAME = __GNU_GO.__go_export
19 GO_EXPORT_SECTION_NAME = .go_export
24 gcc_version := $(shell $(GOC) -dumpversion)
26 MAINT_CHARSET = latin1
28 mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
29 PWD_COMMAND = $${PWDCMD-pwd}
30 STAMP = echo timestamp >
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)
38 LIBFFIINCS = @LIBFFIINCS@
40 LIBATOMIC = @LIBATOMIC@
42 WARN_CFLAGS = $(WARN_FLAGS) $(WERROR)
44 # -I/-D flags to pass when compiling.
45 AM_CPPFLAGS = -I $(srcdir)/runtime $(LIBFFIINCS) $(PTHREAD_CFLAGS)
47 ACLOCAL_AMFLAGS = -I ./config -I ../config
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
58 AM_LDFLAGS += -XCClinker $(SPLIT_STACK)
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
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.
75 "AR_FLAGS=$(AR_FLAGS)" \
76 "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
77 "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
79 "CXXFLAGS=$(CXXFLAGS)" \
80 "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
81 "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
82 "GOC_FOR_TARGET=$(GOC_FOR_TARGET)" \
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)" \
93 "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
94 "PICFLAG=$(PICFLAG)" \
95 "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
97 "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
98 "exec_prefix=$(exec_prefix)" \
99 "infodir=$(infodir)" \
101 "includedir=$(includedir)" \
103 "tooldir=$(tooldir)" \
104 "gxx_include_dir=$(gxx_include_dir)" \
110 "NM_FOR_BUILD=$(NM_FOR_BUILD)" \
111 "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
112 "DESTDIR=$(DESTDIR)" \
115 # Subdir rules rely on $(FLAGS_TO_PASS)
116 FLAGS_TO_PASS = $(AM_MAKEFLAGS)
119 toolexeclib_LTLIBRARIES = libgo-llgo.la
120 toolexeclib_LIBRARIES = libgobegin-llgo.a
122 toolexeclib_LTLIBRARIES = libgo.la
123 toolexeclib_LIBRARIES = libgobegin.a libgolibbegin.a
126 noinst_LIBRARIES = libgotool.a
128 toolexeclibgo_DATA = \
160 toolexeclibgoarchivedir = $(toolexeclibgodir)/archive
162 toolexeclibgoarchive_DATA = \
166 toolexeclibgocompressdir = $(toolexeclibgodir)/compress
168 toolexeclibgocompress_DATA = \
175 toolexeclibgocontainerdir = $(toolexeclibgodir)/container
177 toolexeclibgocontainer_DATA = \
182 toolexeclibgocryptodir = $(toolexeclibgodir)/crypto
184 toolexeclibgocrypto_DATA = \
190 crypto/elliptic.gox \
203 toolexeclibgocryptox509dir = $(toolexeclibgocryptodir)/x509
205 toolexeclibgocryptox509_DATA = \
208 toolexeclibgodatabasedir = $(toolexeclibgodir)/database
210 toolexeclibgodatabase_DATA = \
213 toolexeclibgodatabasesqldir = $(toolexeclibgodatabasedir)/sql
215 toolexeclibgodatabasesql_DATA = \
216 database/sql/driver.gox
218 toolexeclibgodebugdir = $(toolexeclibgodir)/debug
220 toolexeclibgodebug_DATA = \
228 toolexeclibgoencodingdir = $(toolexeclibgodir)/encoding
230 toolexeclibgoencoding_DATA = \
231 encoding/ascii85.gox \
233 encoding/base32.gox \
234 encoding/base64.gox \
235 encoding/binary.gox \
243 toolexeclibgogodir = $(toolexeclibgodir)/go
245 toolexeclibgogo_DATA = \
258 toolexeclibgohashdir = $(toolexeclibgodir)/hash
260 toolexeclibgohash_DATA = \
266 toolexeclibgohtmldir = $(toolexeclibgodir)/html
268 toolexeclibgohtml_DATA = \
271 toolexeclibgoimagedir = $(toolexeclibgodir)/image
273 toolexeclibgoimage_DATA = \
280 toolexeclibgoimagecolordir = $(toolexeclibgoimagedir)/color
282 toolexeclibgoimagecolor_DATA = \
283 image/color/palette.gox
285 toolexeclibgoindexdir = $(toolexeclibgodir)/index
287 toolexeclibgoindex_DATA = \
288 index/suffixarray.gox
290 toolexeclibgoiodir = $(toolexeclibgodir)/io
292 toolexeclibgoio_DATA = \
295 toolexeclibgologdir = $(toolexeclibgodir)/log
297 toolexeclibgolog_DATA = \
300 toolexeclibgomathdir = $(toolexeclibgodir)/math
302 toolexeclibgomath_DATA = \
308 toolexeclibgomimedir = $(toolexeclibgodir)/mime
310 toolexeclibgomime_DATA = \
312 mime/quotedprintable.gox
314 toolexeclibgonetdir = $(toolexeclibgodir)/net
316 toolexeclibgonet_DATA = \
324 toolexeclibgonethttpdir = $(toolexeclibgonetdir)/http
326 toolexeclibgonethttp_DATA = \
328 net/http/cookiejar.gox \
330 net/http/httptest.gox \
331 net/http/httptrace.gox \
332 net/http/httputil.gox \
335 toolexeclibgonetrpcdir = $(toolexeclibgonetdir)/rpc
337 toolexeclibgonetrpc_DATA = \
340 toolexeclibgoosdir = $(toolexeclibgodir)/os
342 toolexeclibgoos_DATA = \
347 toolexeclibgopathdir = $(toolexeclibgodir)/path
349 toolexeclibgopath_DATA = \
352 toolexeclibgoregexpdir = $(toolexeclibgodir)/regexp
354 toolexeclibgoregexp_DATA = \
357 toolexeclibgoruntimedir = $(toolexeclibgodir)/runtime
359 toolexeclibgoruntime_DATA = \
364 toolexeclibgosyncdir = $(toolexeclibgodir)/sync
366 toolexeclibgosync_DATA = \
369 toolexeclibgotestingdir = $(toolexeclibgodir)/testing
371 toolexeclibgotesting_DATA = \
375 toolexeclibgotestinginternaldir = $(toolexeclibgotestingdir)/internal
377 toolexeclibgotestinginternal_DATA = \
378 testing/internal/testdeps.gox
380 toolexeclibgotextdir = $(toolexeclibgodir)/text
382 toolexeclibgotext_DATA = \
387 toolexeclibgotexttemplatedir = $(toolexeclibgotextdir)/template
389 toolexeclibgotexttemplate_DATA = \
390 text/template/parse.gox
392 toolexeclibgounicodedir = $(toolexeclibgodir)/unicode
394 toolexeclibgounicode_DATA = \
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.
402 internal/x/net/internal/nettest.gox \
403 internal/x/net/nettest.gox \
404 internal/testenv.gox \
406 net/internal/socktest.gox \
407 os/signal/internal/pty.gox \
408 runtime/pprof/internal/profile.gox
411 rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
413 rtems_task_variable_add_file =
417 runtime_getncpu_file = runtime/getncpu-linux.c
420 runtime_getncpu_file = runtime/getncpu-bsd.c
423 runtime_getncpu_file = runtime/getncpu-irix.c
426 runtime_getncpu_file = runtime/getncpu-solaris.c
429 runtime_getncpu_file = runtime/getncpu-bsd.c
432 runtime_getncpu_file = runtime/getncpu-bsd.c
435 runtime_getncpu_file = runtime/getncpu-aix.c
438 runtime_getncpu_file = runtime/getncpu-hurd.c
440 runtime_getncpu_file = runtime/getncpu-none.c
452 runtime/go-assert.c \
453 runtime/go-caller.c \
454 runtime/go-callers.c \
457 runtime/go-construct-map.c \
459 runtime/go-fieldtrack.c \
460 runtime/go-matherr.c \
461 runtime/go-memclr.c \
462 runtime/go-memequal.c \
463 runtime/go-nanotime.c \
466 runtime/go-reflect-call.c \
467 runtime/go-runtime-error.c \
468 runtime/go-setenv.c \
469 runtime/go-signal.c \
470 runtime/go-unsafe-pointer.c \
471 runtime/go-unsetenv.c \
472 runtime/go-unwind.c \
473 runtime/go-varargs.c \
474 runtime/env_posix.c \
478 runtime/runtime_c.c \
481 runtime/go-context.S \
482 $(rtems_task_variable_add_file) \
483 $(runtime_getncpu_file)
485 version.go: s-version; @true
488 echo "package sys" > version.go.tmp
489 echo 'func init() { DefaultGoroot = "$(prefix)" }' >> version.go.tmp
490 echo 'const TheVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp
491 echo 'const Goexperiment = ``' >> version.go.tmp
492 echo 'const GOARCH = "'$(GOARCH)'"' >> version.go.tmp
493 echo 'const GOOS = "'$(GOOS)'"' >> version.go.tmp
494 echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp
495 echo >> version.go.tmp
496 echo "type ArchFamilyType int" >> version.go.tmp
497 echo >> version.go.tmp
498 echo "const (" >> version.go.tmp
499 echo " UNKNOWN ArchFamilyType = iota" >> version.go.tmp
500 for a in $(ALLGOARCHFAMILY); do \
501 echo " $${a}" >> version.go.tmp; \
503 echo ")" >> version.go.tmp
504 echo >> version.go.tmp
505 for a in $(ALLGOARCH); do \
506 f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
507 n="$${f}`echo $${a} | sed -e 's/.//'`"; \
508 if test "$${a}" = "$(GOARCH)"; then \
509 echo "const Goarch$${n} = 1" >> version.go.tmp; \
511 echo "const Goarch$${n} = 0" >> version.go.tmp; \
514 echo >> version.go.tmp
515 echo "const (" >> version.go.tmp
516 echo " ArchFamily = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) family`" >> version.go.tmp
517 echo " BigEndian = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) bigendian`" >> version.go.tmp
518 echo " CacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> version.go.tmp
519 echo " DefaultPhysPageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) defaultphyspagesize`" >> version.go.tmp
520 echo " HugePageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) hugepagesize`" >> version.go.tmp
521 echo " Int64Align = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) int64align`" >> version.go.tmp
522 echo " MinFrameSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) minframesize`" >> version.go.tmp
523 echo " PCQuantum = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) pcquantum`" >> version.go.tmp
524 echo ")" >> version.go.tmp
525 echo >> version.go.tmp
526 for a in $(ALLGOOS); do \
527 f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
528 n="$${f}`echo $${a} | sed -e 's/.//'`"; \
529 if test "$${a}" = "$(GOOS)"; then \
530 echo "const Goos$${n} = 1" >> version.go.tmp; \
532 echo "const Goos$${n} = 0" >> version.go.tmp; \
535 echo >> version.go.tmp
536 echo "type Uintreg uintptr" >> version.go.tmp
537 $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
540 cpugen.go: s-cpu; @true
543 echo "package cpu" > cpugen.go.tmp
544 echo "const CacheLinePadSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) cachelinesize`" >> cpugen.go.tmp
545 echo "const FunctionDescriptors = $(FUNCTION_DESCRIPTORS)" >> cpugen.go.tmp
546 $(SHELL) $(srcdir)/mvifdiff.sh cpugen.go.tmp cpugen.go
549 objabi.go: s-objabi; @true
552 echo "package objabi" > objabi.go.tmp
553 echo "import \"runtime\"" >> objabi.go.tmp
554 echo 'func init() { defaultGOROOT = `$(prefix)` }' >> objabi.go.tmp
555 echo 'const defaultGO386 = `sse2`' >> objabi.go.tmp
556 echo 'const defaultGOARM = `5`' >> objabi.go.tmp
557 echo 'const defaultGOMIPS = `hardfloat`' >> objabi.go.tmp
558 echo 'const defaultGOMIPS64 = `hardfloat`' >> objabi.go.tmp
559 echo 'const defaultGOOS = runtime.GOOS' >> objabi.go.tmp
560 echo 'const defaultGOARCH = runtime.GOARCH' >> objabi.go.tmp
561 echo 'const defaultGO_EXTLINK_ENABLED = ``' >> objabi.go.tmp
562 echo 'const version = `'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'`' >> objabi.go.tmp
563 echo 'const stackGuardMultiplierDefault = 1' >> objabi.go.tmp
564 echo 'const goexperiment = ``' >> objabi.go.tmp
565 $(SHELL) $(srcdir)/mvifdiff.sh objabi.go.tmp objabi.go
568 gccgosizes.go: s-gccgosizes; @true
569 s-gccgosizes: Makefile goarch.sh
570 rm -f gccgosizes.go.tmp
571 echo "package types" > gccgosizes.go.tmp
572 echo >> gccgosizes.go.tmp
573 echo "var gccgoArchSizes = map[string]*StdSizes{" >> gccgosizes.go.tmp
574 for a in $(ALLGOARCH); do \
575 ptrsize=`$(SHELL) $(srcdir)/goarch.sh $$a ptrsize`; \
576 maxalign=`$(SHELL) $(srcdir)/goarch.sh $$a maxalign`; \
577 echo " \"$$a\": {$${ptrsize}, $${maxalign}}," >> gccgosizes.go.tmp; \
579 echo "}" >> gccgosizes.go.tmp
580 $(SHELL) $(srcdir)/mvifdiff.sh gccgosizes.go.tmp gccgosizes.go
583 runtime_sysinfo.go: s-runtime_sysinfo; @true
584 s-runtime_sysinfo: $(srcdir)/mkrsysinfo.sh gen-sysinfo.go
585 GOARCH=$(GOARCH) GOOS=$(GOOS) $(SHELL) $(srcdir)/mkrsysinfo.sh
586 $(SHELL) $(srcdir)/mvifdiff.sh tmp-runtime_sysinfo.go runtime_sysinfo.go
589 sigtab.go: s-sigtab; @true
590 s-sigtab: $(srcdir)/mksigtab.sh gen-sysinfo.go
591 GOOS=$(GOOS) $(SHELL) $(srcdir)/mksigtab.sh > tmp-sigtab.go
592 $(SHELL) $(srcdir)/mvifdiff.sh tmp-sigtab.go sigtab.go
595 GCCGO_INSTALL_NAME := $(shell echo gccgo|sed '$(program_transform_name)')
596 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
597 GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
599 zdefaultcc.go: s-zdefaultcc; @true
600 s-zdefaultcc: Makefile
601 echo 'package cfg' > zdefaultcc.go.tmp
602 echo >> zdefaultcc.go.tmp
603 echo 'func DefaultGCCGO(goos, goarch string) string { return "$(bindir)/$(GCCGO_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
604 echo 'func DefaultCC(goos, goarch string) string { return "$(GCC_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
605 echo 'func DefaultCXX(goos, goarch string) string { return "$(GXX_INSTALL_NAME)" }' >> zdefaultcc.go.tmp
606 echo 'const DefaultPkgConfig = "pkg-config"' >> zdefaultcc.go.tmp
607 echo 'var OSArchSupportsCgo = map[string]bool{}' >> zdefaultcc.go.tmp
608 $(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
611 # Post-process runtime.inc.raw (raw output of -fgo-c-header option when
612 # compiling runtime) to prune out certain types that should not be
613 # exported back to C. See comments in mkruntimeinc.sh for more details.
614 runtime.inc: s-runtime-inc; @true
615 s-runtime-inc: runtime.lo Makefile
616 $(SHELL) $(srcdir)/mkruntimeinc.sh
617 $(SHELL) $(srcdir)/mvifdiff.sh tmp-runtime.inc runtime.inc
620 noinst_DATA += zdefaultcc.go
622 # Generate the list of go std packages that were included in libgo
623 zstdpkglist.go: s-zstdpkglist; @true
624 s-zstdpkglist: Makefile
625 rm -f zstdpkglist.go.tmp
626 echo 'package goroot' > zstdpkglist.go.tmp
627 echo "" >> zstdpkglist.go.tmp
628 echo 'var stdpkg = map[string]bool{' >> zstdpkglist.go.tmp
629 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
630 echo '}' >> zstdpkglist.go.tmp
631 $(SHELL) $(srcdir)/mvifdiff.sh zstdpkglist.go.tmp zstdpkglist.go
635 syscall_epoll_file = epoll.go
640 libcalls.go: s-libcalls; @true
641 s-libcalls: libcalls-list go/syscall/mksyscall.awk $(srcdir)/go/syscall/*.go
642 rm -f libcalls.go.tmp
643 $(AWK) -f $(srcdir)/go/syscall/mksyscall.awk `cat libcalls-list` > libcalls.go.tmp
644 $(SHELL) $(srcdir)/mvifdiff.sh libcalls.go.tmp libcalls.go
647 libcalls-list: s-libcalls-list; @true
648 s-libcalls-list: Makefile $(srcdir)/go/syscall/*.go
649 rm -f libcalls-list.tmp
650 $(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/syscall $(matchargs_syscall) > libcalls-list.tmp
651 $(SHELL) $(srcdir)/mvifdiff.sh libcalls-list.tmp libcalls-list
654 syscall_arch.go: s-syscall_arch; @true
655 s-syscall_arch: Makefile
656 rm -f syscall_arch.go.tmp
657 echo "package syscall" > syscall_arch.go.tmp
658 echo 'const ARCH = "'$(GOARCH)'"' >> syscall_arch.go.tmp
659 echo 'const OS = "'$(GOOS)'"' >> syscall_arch.go.tmp
660 $(SHELL) $(srcdir)/mvifdiff.sh syscall_arch.go.tmp syscall_arch.go
664 $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
665 $(CPPFLAGS) $(OSCFLAGS) -O
667 gen-sysinfo.go: s-gen-sysinfo; @true
668 s-gen-sysinfo: $(srcdir)/sysinfo.c config.h
669 $(CC) $(SYSINFO_FLAGS) -fdump-go-spec=tmp-gen-sysinfo.go -std=gnu99 -S -o sysinfo.s $(srcdir)/sysinfo.c
671 $(SHELL) $(srcdir)/mvifdiff.sh tmp-gen-sysinfo.go gen-sysinfo.go
674 errno.i: s-errno; @true
676 echo '#include <errno.h>' | $(CC) $(SYSINFO_FLAGS) -x c - -E -dM > tmp-errno.i
677 $(SHELL) $(srcdir)/mvifdiff.sh tmp-errno.i errno.i
680 sysinfo.go: s-sysinfo; @true
681 s-sysinfo: $(srcdir)/mksysinfo.sh gen-sysinfo.go errno.i
682 GOARCH=$(GOARCH) GOOS=$(GOOS) $(SHELL) $(srcdir)/mksysinfo.sh
683 $(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go
686 # The epoll struct has an embedded union and is packed on x86_64,
687 # which is too complicated for mksysinfo.sh. We find the offset of
688 # the only field we care about in configure.ac, and generate the
690 epoll.go: s-epoll; @true
693 echo 'package syscall' > epoll.go.tmp
694 echo 'type EpollEvent struct {' >> epoll.go.tmp
695 echo ' Events uint32' >> epoll.go.tmp
696 case "$(SIZEOF_STRUCT_EPOLL_EVENT),$(STRUCT_EPOLL_EVENT_FD_OFFSET)" in \
697 0,0) echo 1>&2 "*** struct epoll_event data.fd offset unknown"; \
699 8,4) echo ' Fd int32' >> epoll.go.tmp; ;; \
700 12,4) echo ' Fd int32' >> epoll.go.tmp; \
701 echo ' Pad [4]byte' >> epoll.go.tmp; ;; \
702 12,8) echo ' Pad [4]byte' >> epoll.go.tmp; \
703 echo ' Fd int32' >> epoll.go.tmp; ;; \
704 16,8) echo ' Pad [4]byte' >> epoll.go.tmp; \
705 echo ' Fd int32' >> epoll.go.tmp; \
706 echo ' Pad2 [4]byte' >> epoll.go.tmp; ;; \
707 *) echo 1>&2 "*** struct epoll_event unsupported"; \
710 echo '}' >> epoll.go.tmp
711 $(SHELL) $(srcdir)/mvifdiff.sh epoll.go.tmp epoll.go
715 syscall_lib_clone_lo = syscall/clone_linux.lo
717 syscall_lib_clone_lo =
720 PACKAGES = $(shell cat $(srcdir)/libgo-packages.txt)
723 $(addsuffix .lo,$(PACKAGES)) \
724 internal/bytealg/bytealg.lo \
725 reflect/makefunc_ffi_c.lo \
726 $(syscall_lib_clone_lo) \
730 $(internal_x_net_lif_lo) \
731 $(internal_x_net_route_lo) \
732 log/syslog/syslog_c.lo \
733 $(os_lib_inotify_lo) \
734 runtime/internal/atomic_c.lo \
736 internal/cpu/cpu_gccgo.lo
739 -version-info $(libtool_VERSION) $(PTHREAD_CFLAGS) $(AM_LDFLAGS)
742 $(libgo_go_objs) ../libbacktrace/libbacktrace.la \
743 $(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)
745 libgo_la_SOURCES = $(runtime_files)
746 libgo_la_LDFLAGS = $(libgo_ldflags)
747 libgo_la_LIBADD = $(libgo_libadd)
749 libgo_llgo_la_SOURCES = $(runtime_files)
750 libgo_llgo_la_LDFLAGS = $(libgo_ldflags)
751 libgo_llgo_la_LIBADD = $(libgo_libadd)
753 libgobegin_a_SOURCES = \
756 libgobegin_llgo_a_SOURCES = \
759 # Use -fPIC for libgobegin so that it can be put in a PIE.
760 libgobegin_a_CFLAGS = $(AM_CFLAGS) -fPIC
761 libgobegin_llgo_a_CFLAGS = $(AM_CFLAGS) -fPIC
763 libgolibbegin_a_SOURCES = \
766 libgolibbegin_a_CFLAGS = $(AM_CFLAGS) -fPIC
768 GOTOOL_PACKAGES = $(shell cat $(srcdir)/gotool-packages.txt)
770 libgotool_a_SOURCES =
771 libgotool_a_DEPENDENCIES = $(addsuffix .lo,$(GOTOOL_PACKAGES))
772 libgotool_a_LIBADD = $(addsuffix .o,$(GOTOOL_PACKAGES))
774 define STATIC_template
775 $(subst -,_,$(subst .,_,$(subst /,_,$(1))))_GOCFLAGS = -static
778 $(foreach package,$(GOTOOL_PACKAGES),$(eval $(call STATIC_template,$(package).lo)))
780 # Make sure runtime.inc is built before compiling any .c file.
781 $(libgo_la_OBJECTS): runtime.inc
782 $(libgo_llgo_la_OBJECTS): runtime.inc
783 $(libgobegin_a_OBJECTS): runtime.inc
784 $(libgobegin_llgo_a_OBJECTS): runtime.inc
785 $(libgolibbegin_a_OBJECTS): runtime.inc
787 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
790 AM_GOCFLAGS = $(STRINGOPS_FLAG) $(GO_SPLIT_STACK)
791 GOCOMPILE = $(GOC) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_GOCFLAGS) $(GOCFLAGS)
793 LTGOCOMPILE = $(LIBTOOL) --tag GO --mode=compile $(GOC) $(INCLUDES) \
794 $(AM_GOCFLAGS) $(GOCFLAGS)
796 GOLINK = $(LIBTOOL) --tag GO --mode-link $(GOC) \
797 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_GOCFLAGS) $(LTLDFLAGS) -o $@
799 # Build the dependencies for a Go package.
802 dir=`echo $@ | sed -e 's/.lo.dep$$//'`; \
803 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,,$@)))`; \
804 $(SHELL) $(srcdir)/godeps.sh `echo $@ | sed -e 's/.dep$$//'` $$files > $@.tmp; \
805 if ! cmp $@.tmp $@ >/dev/null 2>/dev/null; then \
806 rm -f `echo $@ | sed -e 's/\.dep$$//'`; \
810 # Build the .go files for a package, generating a .lo file.
813 files=`echo $^ | sed -e 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; \
814 $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//'` $($(subst -,_,$(subst .,_,$(subst /,_,$@)))_GOCFLAGS) -o $@ $$files
816 # How to build a .gox file from a .lo file.
817 # Matching .o file can either be in the same directory as the .lo (non-PIC
818 # object) or in the .libs directory (PIC object).
820 f="$(basename $<).o"; \
821 if test ! -f $$f; then \
822 f="$(basename $(<D)/.libs/$(<F)).o"; \
824 $(OBJCOPY) -j $(GO_EXPORT_SECTION_NAME) $$f $@.tmp; \
825 $(SHELL) $(srcdir)/mvifdiff.sh $@.tmp `echo $@ | sed -e 's/s-gox/gox/'`
832 GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \
834 GOLIBS="$(extra_check_libs_$(subst /,_,$(@D))) $(MATH_LIBS) $(NET_LIBS) $(LIBS)"; \
836 RUNTESTFLAGS="$(RUNTESTFLAGS)"; \
837 export RUNTESTFLAGS; \
842 libgccdir=`${GOC} ${GOCFLAGS} -print-libgcc-file-name | sed -e 's|/[^/]*$$||'`; \
843 LD_LIBRARY_PATH="`${PWD_COMMAND}`/.libs:$${libgccdir}:${LD_LIBRARY_PATH}"; \
844 LD_LIBRARY_PATH=`echo $${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
845 export LD_LIBRARY_PATH; \
847 rm -f $@-testsum $@-testlog; \
848 files=`$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/$(@D) --extrafiles="$(extra_go_files_$(subst /,_,$(@D)))" $(matchargs_$(subst /,_,$(@D)))`; \
849 if test "$(USE_DEJAGNU)" = "yes"; then \
850 $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --testname="$(@D)" $(GOTESTFLAGS); \
851 elif test "$(GOBENCH)" != ""; then \
852 $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --bench="$(GOBENCH)" $(GOTESTFLAGS); \
854 if $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" $(GOTESTFLAGS) >>$@-testlog 2>&1; then \
855 echo "PASS: $(@D)" >> $@-testlog; \
856 echo "PASS: $(@D)"; \
857 echo "PASS: $(@D)" > $@-testsum; \
859 echo "FAIL: $(@D)" >> $@-testlog; \
861 echo "FAIL: $(@D)" > $@-testsum; \
866 # Build all packages before checking any.
868 $(toolexeclibgo_DATA) \
869 $(toolexeclibgoarchive_DATA) \
870 $(toolexeclibgocompress_DATA) \
871 $(toolexeclibgocontainer_DATA) \
872 $(toolexeclibgocrypto_DATA) \
873 $(toolexeclibgodebug_DATA) \
874 $(toolexeclibgoencoding_DATA) \
875 $(toolexeclibgogo_DATA) \
876 $(toolexeclibgohash_DATA) \
877 $(toolexeclibgoimage_DATA) \
878 $(toolexeclibgoindex_DATA) \
879 $(toolexeclibgoio_DATA) \
880 $(toolexeclibgolog_DATA) \
881 $(toolexeclibgomath_DATA) \
882 $(toolexeclibgomime_DATA) \
883 $(toolexeclibgonet_DATA) \
884 $(toolexeclibgonethttp_DATA) \
885 $(toolexeclibgoos_DATA) \
886 $(toolexeclibgopath_DATA) \
887 $(toolexeclibgorpc_DATA) \
888 $(toolexeclibgoruntime_DATA) \
889 $(toolexeclibgosync_DATA) \
890 $(toolexeclibgotesting_DATA) \
891 $(toolexeclibgotext_DATA) \
892 $(toolexeclibgotexttemplate_DATA) \
893 $(toolexeclibgounicode_DATA) \
898 CHECK_DEPS += libgo-llgo.la libgobegin-llgo.a
900 CHECK_DEPS += libgo.la libgobegin.a
903 # PACKAGE_template defines the rules for each package.
904 # For example, for the package bufio, it produces:
906 # @go_include@ bufio.lo.dep
907 # bufio.lo.dep: $(srcdir)/go/bufio/*.go
911 # bufio/check: $(CHECK_DEPS)
913 # .PHONY: bufio/check
915 # This is invoked with $(1) set to a package, which is a directory name,
916 # such as "bufio" or "archive/tar".
917 define PACKAGE_template
918 @go_include@ $(1).lo.dep
919 $(1).lo.dep: $(srcdir)/go/$(1)/*.go
923 $(1)/check: $$(CHECK_DEPS)
926 $(1).gox: $(1).s-gox; @true
932 # This line expands PACKAGE_template once for each package name listed
934 $(foreach package,$(PACKAGES),$(eval $(call PACKAGE_template,$(package))))
935 $(foreach package,$(GOTOOL_PACKAGES),$(eval $(call PACKAGE_template,$(package))))
937 # Pass -ffp-contract=off, or 386-specific options, when building the
938 # math package. MATH_FLAG is defined in configure.ac.
939 math_lo_GOCFLAGS = $(MATH_FLAG)
940 math_check_GOCFLAGS = $(MATH_FLAG)
942 # Add the generated file runtime_sysinfo.go to the runtime package.
943 extra_go_files_runtime = runtime_sysinfo.go sigtab.go
944 runtime.lo.dep: $(extra_go_files_runtime)
946 # Add generated files to the syscall package.
947 extra_go_files_syscall = \
951 $(syscall_epoll_file)
952 syscall.lo.dep: $(extra_go_files_syscall)
954 # Pass -fgo-compiling-runtime when compiling the runtime package.
955 runtime_lo_GOCFLAGS = -fgo-c-header=runtime.inc.raw -fgo-compiling-runtime
956 runtime_check_GOCFLAGS = -fgo-compiling-runtime
957 runtime_internal_atomic_lo_GOCFLAGS = -fgo-compiling-runtime
958 runtime_internal_atomic_lo_check_GOCFLAGS = -fgo-compiling-runtime
959 runtime_internal_sys_lo_GOCFLAGS = -fgo-compiling-runtime
960 runtime_internal_sys_lo_check_GOCFLAGS = -fgo-compiling-runtime
962 # If libffi is supported (the normal case) use the ffi build tag for
963 # the runtime package.
965 matchargs_runtime = --tag=libffi
970 # At least for now, we need -static-libgo for this test, because
971 # otherwise we can't get the line numbers.
972 # Also use -fno-inline to get better results from the memory profiler.
973 runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline
975 extra_go_files_runtime_internal_sys = version.go
976 runtime/internal/sys.lo.dep: $(extra_go_files_runtime_internal_sys)
978 extra_go_files_internal_cpu = cpugen.go
979 internal/cpu.lo.dep: $(extra_go_files_internal_cpu)
981 extra_go_files_internal_goroot = zstdpkglist.go
982 internal/goroot.lo.dep: $(extra_go_files_internal_goroot)
984 extra_go_files_go_types = gccgosizes.go
985 go/types.lo.dep: $(extra_go_files_go_types)
987 extra_go_files_cmd_internal_objabi = objabi.go
988 cmd/internal/objabi.lo.dep: $(extra_go_files_cmd_internal_objabi)
990 extra_go_files_cmd_go_internal_cfg = zdefaultcc.go
991 cmd/go/internal/cfg.lo.dep: $(extra_go_files_cmd_go_internal_cfg)
993 extra_check_libs_cmd_go_internal_cache = $(abs_builddir)/libgotool.a
994 extra_check_libs_cmd_go_internal_generate = $(abs_builddir)/libgotool.a
995 extra_check_libs_cmd_go_internal_get = $(abs_builddir)/libgotool.a
996 extra_check_libs_cmd_go_internal_load = $(abs_builddir)/libgotool.a
997 extra_check_libs_cmd_go_internal_lockedfile = $(abs_builddir)/libgotool.a
998 extra_check_libs_cmd_go_internal_imports = $(abs_builddir)/libgotool.a
999 extra_check_libs_cmd_go_internal_modconv = $(abs_builddir)/libgotool.a
1000 extra_check_libs_cmd_go_internal_modfetch = $(abs_builddir)/libgotool.a
1001 extra_check_libs_cmd_go_internal_modfetch_codehost = $(abs_builddir)/libgotool.a
1002 extra_check_libs_cmd_go_internal_modfile = $(abs_builddir)/libgotool.a
1003 extra_check_libs_cmd_go_internal_modload = $(abs_builddir)/libgotool.a
1004 extra_check_libs_cmd_go_internal_module = $(abs_builddir)/libgotool.a
1005 extra_check_libs_cmd_go_internal_mvs = $(abs_builddir)/libgotool.a
1006 extra_check_libs_cmd_go_internal_search = $(abs_builddir)/libgotool.a
1007 extra_check_libs_cmd_go_internal_web2 = $(abs_builddir)/libgotool.a
1008 extra_check_libs_cmd_go_internal_work = $(abs_builddir)/libgotool.a
1010 extra_check_libs_cmd_vet_internal_cfg = $(abs_builddir)/libgotool.a
1012 # FIXME: The following C files may as well move to the runtime
1013 # directory and be treated like other C files.
1015 # Use C code to speed up internal/bytealg.IndexByte and friends.
1016 internal/bytealg/bytealg.lo: go/internal/bytealg/bytealg.c runtime.inc
1017 @$(MKDIR_P) internal/bytealg
1018 $(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/bytealg/bytealg.c
1020 # Use a C function with a fixed number of arguments to call a C
1022 log/syslog/syslog_c.lo: go/log/syslog/syslog_c.c runtime.inc
1023 @$(MKDIR_P) log/syslog
1024 $(LTCOMPILE) -c -o $@ $(srcdir)/go/log/syslog/syslog_c.c
1026 # The interface to libffi from the reflect package is written in C.
1027 reflect/makefunc_ffi_c.lo: go/reflect/makefunc_ffi_c.c runtime.inc
1029 $(LTCOMPILE) -c -o $@ $(srcdir)/go/reflect/makefunc_ffi_c.c
1031 # The atomic functions are written in C.
1032 runtime/internal/atomic_c.lo: go/runtime/internal/atomic/atomic.c runtime.inc
1033 @$(MKDIR_P) runtime/internal
1034 $(LTCOMPILE) -c -o $@ $(srcdir)/go/runtime/internal/atomic/atomic.c
1035 sync/atomic_c.lo: go/sync/atomic/atomic.c runtime.inc
1037 $(LTCOMPILE) -c -o $@ $(srcdir)/go/sync/atomic/atomic.c
1039 # A few syscall functions are written in C.
1040 syscall/clone_linux.lo: go/syscall/clone_linux.c runtime.inc
1042 $(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/clone_linux.c
1043 syscall/errno.lo: go/syscall/errno.c runtime.inc
1045 $(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/errno.c
1046 syscall/signame.lo: go/syscall/signame.c runtime.inc
1048 $(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/signame.c
1049 syscall/wait.lo: go/syscall/wait.c runtime.inc
1051 $(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/wait.c
1053 # internal/cpu needs some C code.
1054 internal/cpu/cpu_gccgo.lo: go/internal/cpu/cpu_gccgo.c runtime.inc
1055 @$(MKDIR_P) internal/cpu
1056 $(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/cpu/cpu_gccgo.c
1058 # Solaris 11.4 changed the type of fields in struct stat.
1059 # Use a build tag, based on a configure check, to cope.
1061 if HAVE_STAT_TIMESPEC
1062 matchargs_os = --tag=solaristag
1072 # Build internal/x/net/route only on BSD systems.
1074 $(eval $(call PACKAGE_template,internal/x/net/route))
1076 internal_x_net_route_lo = \
1077 internal/x/net/route.lo
1078 internal_x_net_route_check = \
1079 internal/x/net/route/check
1085 # Build internal/x/net/lif only on Solaris systems.
1087 $(eval $(call PACKAGE_template,internal/x/net/lif))
1089 internal_x_net_lif_lo = \
1090 internal/x/net/lif.lo
1091 internal_x_net_lif_check = \
1092 internal/x/net/lif/check
1096 TPACKAGES = $(shell cat $(srcdir)/check-packages.txt)
1097 TEST_PACKAGES = $(addsuffix /check,$(TPACKAGES)) \
1098 $(internal_x_net_lif_check) \
1099 $(internal_x_net_route_check)
1102 check-recursive: check-head
1105 @echo "Test Run By $${USER} on `date`" > libgo.head
1106 @echo "Native configuration is $(host_triplet)" >> libgo.head
1108 @echo " === libgo tests ===" >> libgo.head
1111 check-tail: check-recursive check-multi
1112 @if test "$(USE_DEJAGNU)" = "yes"; then \
1115 lib=`${PWD_COMMAND} | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
1116 for dir in . $(MULTIDIRS); do \
1117 mv ../$${dir}/$${lib}/libgo.sum ../$${dir}/$${lib}/libgo.sum.sep; \
1118 mv ../$${dir}/$${lib}/libgo.log ../$${dir}/$${lib}/libgo.log.sep; \
1120 mv libgo.head libgo.sum; \
1121 cp libgo.sum libgo.log; \
1122 echo "Schedule of variations:" >> libgo.sum; \
1123 for dir in . $(MULTIDIRS); do \
1124 multidir=../$${dir}/$${lib}; \
1125 multivar=`cat $${multidir}/libgo.var`; \
1126 echo " $${multivar}" >> libgo.sum; \
1128 echo >> libgo.sum; \
1129 pass=0; fail=0; untested=0; \
1130 for dir in . $(MULTIDIRS); do \
1131 multidir=../$${dir}/$${lib}; \
1132 multivar=`cat $${multidir}/libgo.var`; \
1133 echo "Running target $${multivar}" >> libgo.sum; \
1134 echo "Running $(srcdir)/libgo.exp ..." >> libgo.sum; \
1135 cat $${multidir}/libgo.sum.sep >> libgo.sum; \
1136 cat $${multidir}/libgo.log.sep >> libgo.log; \
1137 if test -n "${MULTIDIRS}"; then \
1138 echo " === libgo Summary for $${multivar} ===" >> libgo.sum; \
1139 echo >> libgo.sum; \
1141 p=`grep -c PASS $${multidir}/libgo.sum.sep`; \
1142 pass=`expr $$pass + $$p`; \
1143 if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
1144 echo "# of expected passes $$p" >> libgo.sum; \
1146 p=`grep -c FAIL $${multidir}/libgo.sum.sep`; \
1147 fail=`expr $$fail + $$p`; \
1148 if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
1149 echo "# of unexpected failures $$p" >> libgo.sum; \
1151 p=`grep -c UNTESTED $${multidir}/libgo.sum.sep`; \
1152 untested=`expr $$untested + $$p`; \
1153 if test "$$p" -ne "0" && test -n "${MULTIDIRS}"; then \
1154 echo "# of untested testcases $$p" >> libgo.sum; \
1157 echo >> libgo.sum; \
1158 echo " === libgo Summary ===" >> libgo.sum; \
1159 echo >> libgo.sum; \
1160 if test "$$pass" -ne "0"; then \
1161 echo "# of expected passes $$pass" >> libgo.sum; \
1163 if test "$$fail" -ne "0"; then \
1164 echo "# of unexpected failures $$fail" >> libgo.sum; \
1166 if test "$$untested" -ne "0"; then \
1167 echo "# of untested testcases $$untested" >> libgo.sum; \
1169 echo `echo $(GOC) | sed -e 's/ .*//'` `$(GOC) -v 2>&1 | grep " version" | sed -n -e 's/.* \(version.*$$\)/\1/p'` >> libgo.sum; \
1170 echo >> libgo.log; \
1171 echo "runtest completed at `date`" >> libgo.log; \
1172 if test "$$fail" -ne "0"; then \
1180 @rm -f libgo.sum libgo.log libgo.tail
1182 [ -z "$(MULTIFLAGS)" ] || multivar="$${multivar}/$(MULTIFLAGS)"; \
1183 echo "$${multivar}" > libgo.var
1184 @for f in $(TEST_PACKAGES); do \
1185 rm -f $$f-testsum $$f-testlog; \
1187 -@$(MAKE) $(AM_MAKEFLAGS) -k $(TEST_PACKAGES)
1188 @for f in $(TEST_PACKAGES); do \
1189 if test -f $$f-testsum; then \
1190 cat $$f-testsum >> libgo.sum; \
1192 if test -f $$f-testlog; then \
1193 cat $$f-testlog >> libgo.log; \
1198 $(MULTIDO) $(AM_MAKEFLAGS) DO=check-am multi-do # $(MAKE)
1201 -@$(MAKE) $(AM_MAKEFLAGS) -k $(TEST_PACKAGES) GOBENCH=.
1203 MOSTLYCLEANFILES = \
1204 s-runtime_sysinfo s-sigtab s-runtime-inc s-zstdpkglist \
1205 s-libcalls s-libcalls-list s-syscall_arch s-gen-sysinfo s-sysinfo \
1207 libgo.head libgo.sum.sep libgo.log.sep libgo.var \
1208 libcalls-list runtime.inc runtime.inc.tmp2 runtime.inc.tmp3
1211 find . -name '*.lo' -print | xargs $(LIBTOOL) --mode=clean rm -f
1212 find . -name '*.$(OBJEXT)' -print | xargs rm -f
1213 find . -name '*-testsum' -print | xargs rm -f
1214 find . -name '*-testlog' -print | xargs rm -f
1216 CLEANFILES = *.go *.c s-* libgo.sum libgo.log runtime.inc
1219 find . -name '*.la' -print | xargs $(LIBTOOL) --mode=clean rm -f
1220 find . -name '*.a' -print | xargs rm -f
1221 find . -name '*.gox' -print | xargs rm -f
1222 find . -name '*.s-gox' -print | xargs rm -f
1225 find . -name '*.lo.dep' -print | xargs rm -f
1227 include $(top_srcdir)/../multilib.am