2 # Copyright 2015 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)
38 GOCFLAGS = $(CFLAGS_FOR_TARGET)
39 GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
41 AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
42 GOLINK = $(GOCOMPILER) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
44 cmdsrcdir = $(srcdir)/../libgo/go/cmd
47 $(cmdsrcdir)/go/build.go \
48 $(cmdsrcdir)/go/clean.go \
49 $(cmdsrcdir)/go/context.go \
50 $(cmdsrcdir)/go/discovery.go \
51 $(cmdsrcdir)/go/env.go \
52 $(cmdsrcdir)/go/fix.go \
53 $(cmdsrcdir)/go/fmt.go \
54 $(cmdsrcdir)/go/generate.go \
55 $(cmdsrcdir)/go/get.go \
56 $(cmdsrcdir)/go/go11.go \
57 $(cmdsrcdir)/go/help.go \
58 $(cmdsrcdir)/go/http.go \
59 $(cmdsrcdir)/go/list.go \
60 $(cmdsrcdir)/go/main.go \
61 $(cmdsrcdir)/go/pkg.go \
62 $(cmdsrcdir)/go/run.go \
63 $(cmdsrcdir)/go/signal.go \
64 $(cmdsrcdir)/go/signal_unix.go \
65 $(cmdsrcdir)/go/test.go \
66 $(cmdsrcdir)/go/testflag.go \
67 $(cmdsrcdir)/go/tool.go \
68 $(cmdsrcdir)/go/vcs.go \
69 $(cmdsrcdir)/go/version.go \
70 $(cmdsrcdir)/go/vet.go
72 go_cmd_gofmt_files = \
73 $(cmdsrcdir)/gofmt/doc.go \
74 $(cmdsrcdir)/gofmt/gofmt.go \
75 $(cmdsrcdir)/gofmt/rewrite.go \
76 $(cmdsrcdir)/gofmt/simplify.go
79 $(cmdsrcdir)/cgo/ast.go \
80 $(cmdsrcdir)/cgo/doc.go \
81 $(cmdsrcdir)/cgo/gcc.go \
82 $(cmdsrcdir)/cgo/godefs.go \
83 $(cmdsrcdir)/cgo/main.go \
84 $(cmdsrcdir)/cgo/out.go \
85 $(cmdsrcdir)/cgo/util.go
87 GCCGO_INSTALL_NAME := $(shell echo gccgo|sed '$(program_transform_name)')
88 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
89 GXX_INSTALL_NAME := $(shell echo g++|sed '$(program_transform_name)')
91 zdefaultcc.go: s-zdefaultcc; @true
92 s-zdefaultcc: Makefile
93 echo 'package main' > zdefaultcc.go.tmp
94 echo 'const defaultGCCGO = "$(bindir)/$(GCCGO_INSTALL_NAME)"' >> zdefaultcc.go.tmp
95 echo 'const defaultCC = "$(bindir)/$(GCC_INSTALL_NAME)"' >> zdefaultcc.go.tmp
96 echo 'const defaultCXX = "$(bindir)/$(GXX_INSTALL_NAME)"' >> zdefaultcc.go.tmp
97 $(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
100 MOSTLYCLEANFILES = zdefaultcc.go s-zdefaultcc
104 # For a native build we build the programs using the newly built libgo
105 # and install them as regular programs.
107 bin_PROGRAMS = go$(EXEEXT) gofmt$(EXEEXT)
108 noinst_PROGRAMS = cgo$(EXEEXT)
109 man_MANS = go.1 gofmt.1
111 go$(EXEEXT): $(go_cmd_go_files) zdefaultcc.go $(LIBGODEP)
112 $(GOLINK) $(go_cmd_go_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
113 gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
114 $(GOLINK) $(go_cmd_gofmt_files) $(LIBS) $(NET_LIBS)
115 cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
116 $(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
118 install-exec-local: cgo$(EXEEXT)
119 $(MKDIR_P) $(DESTDIR)$(libexecsubdir)
120 rm -f $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
121 $(INSTALL_PROGRAM) cgo$(exeext) $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
124 rm -f $(DESTDIR)$(libexecsubdir)/cgo$(exeext)
128 # For a non-native build we have to build the programs using a
129 # previously built host (or build -> host) Go compiler. We should
130 # only do this if such a compiler is available. We also need to get
131 # the right values for GOARCH and GOOS in the default build context in
132 # the go/build package. Figure this out later.