2 # Copyright (C) 2015-2016 Free Software Foundation, Inc.
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
18 ACLOCAL_AMFLAGS = -I ./config -I ../config
20 gcc_version := $(shell $(GCC_FOR_TARGET) -dumpversion)
22 libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version)
24 mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
25 PWD_COMMAND = $${PWDCMD-pwd}
26 STAMP = echo timestamp >
28 libgodir = ../$(target_noncanonical)/libgo
29 LIBGODEP = $(libgodir)/libgo.la
32 # Use the compiler we just built.
33 GOCOMPILER = $(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET)
38 GOCFLAGS = $(CFLAGS_FOR_TARGET)
39 GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
41 AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
42 GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
44 cmdsrcdir = $(srcdir)/../libgo/go/cmd
47 $(cmdsrcdir)/go/alldocs.go \
48 $(cmdsrcdir)/go/bug.go \
49 $(cmdsrcdir)/go/build.go \
50 $(cmdsrcdir)/go/clean.go \
51 $(cmdsrcdir)/go/context.go \
52 $(cmdsrcdir)/go/discovery.go \
53 $(cmdsrcdir)/go/doc.go \
54 $(cmdsrcdir)/go/env.go \
55 $(cmdsrcdir)/go/fix.go \
56 $(cmdsrcdir)/go/fmt.go \
57 $(cmdsrcdir)/go/generate.go \
58 $(cmdsrcdir)/go/get.go \
59 $(cmdsrcdir)/go/go11.go \
60 $(cmdsrcdir)/go/help.go \
61 $(cmdsrcdir)/go/http.go \
62 $(cmdsrcdir)/go/list.go \
63 $(cmdsrcdir)/go/main.go \
64 $(cmdsrcdir)/go/note.go \
65 $(cmdsrcdir)/go/pkg.go \
66 $(cmdsrcdir)/go/run.go \
67 $(cmdsrcdir)/go/signal.go \
68 $(cmdsrcdir)/go/signal_unix.go \
69 $(cmdsrcdir)/go/test.go \
70 $(cmdsrcdir)/go/testflag.go \
71 $(cmdsrcdir)/go/tool.go \
72 $(cmdsrcdir)/go/vcs.go \
73 $(cmdsrcdir)/go/version.go \
74 $(cmdsrcdir)/go/vet.go \
75 $(libgodir)/zstdpkglist.go
77 go_cmd_gofmt_files = \
78 $(cmdsrcdir)/gofmt/doc.go \
79 $(cmdsrcdir)/gofmt/gofmt.go \
80 $(cmdsrcdir)/gofmt/internal.go \
81 $(cmdsrcdir)/gofmt/rewrite.go \
82 $(cmdsrcdir)/gofmt/simplify.go
85 $(cmdsrcdir)/cgo/ast.go \
86 $(cmdsrcdir)/cgo/doc.go \
87 $(cmdsrcdir)/cgo/gcc.go \
88 $(cmdsrcdir)/cgo/godefs.go \
89 $(cmdsrcdir)/cgo/main.go \
90 $(cmdsrcdir)/cgo/out.go \
91 $(cmdsrcdir)/cgo/util.go
93 GCCGO_INSTALL_NAME := $(shell echo gccgo|sed '$(program_transform_name)')
94 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
95 GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
97 zdefaultcc.go: s-zdefaultcc; @true
98 s-zdefaultcc: Makefile
99 echo 'package main' > zdefaultcc.go.tmp
100 echo 'const defaultGCCGO = "$(bindir)/$(GCCGO_INSTALL_NAME)"' >> zdefaultcc.go.tmp
101 echo 'const defaultCC = "$(bindir)/$(GCC_INSTALL_NAME)"' >> zdefaultcc.go.tmp
102 echo 'const defaultCXX = "$(bindir)/$(GXX_INSTALL_NAME)"' >> zdefaultcc.go.tmp
103 echo 'const defaultPkgConfig = "pkg-config"' >> zdefaultcc.go.tmp
104 $(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
107 MOSTLYCLEANFILES = zdefaultcc.go s-zdefaultcc
111 # For a native build we build the programs using the newly built libgo
112 # and install them as regular programs.
114 bin_PROGRAMS = go$(EXEEXT) gofmt$(EXEEXT)
115 noinst_PROGRAMS = cgo$(EXEEXT)
116 man_MANS = go.1 gofmt.1
118 go$(EXEEXT): $(go_cmd_go_files) zdefaultcc.go $(LIBGODEP)
119 $(GOLINK) $(go_cmd_go_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
120 gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
121 $(GOLINK) $(go_cmd_gofmt_files) $(LIBS) $(NET_LIBS)
122 cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
123 $(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
125 install-exec-local: cgo$(EXEEXT)
126 $(MKDIR_P) $(DESTDIR)$(libexecsubdir)
127 rm -f $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
128 $(INSTALL_PROGRAM) cgo$(exeext) $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
131 rm -f $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
135 # For a non-native build we have to build the programs using a
136 # previously built host (or build -> host) Go compiler. We should
137 # only do this if such a compiler is available. We also need to get
138 # the right values for GOARCH and GOOS in the default build context in
139 # the go/build package. Figure this out later.