blob: cb326c24f7658f8c9b4ca81412f6d6b1847e09c1 [file] [log] [blame]
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# ironically, not auto-generated
O_arm=5
O_amd64=6
O_386=8
OS=568vq
O=$(O_$(GOARCH))
GC=$(O)g
CC=$(O)c -FVw
AS=$(O)a
AR=6ar
LD=$(O)l
default: gobuild
clean:
rm -f *.[$(OS)] *.a [$(OS)].out gobuild
%.$O: %.go
$(GC) $*.go
O1=util.$O
O2=makefile.$O
O3=gobuild.$O
phases: a1 a2 a3
gobuild.a: phases
a1: $(O1)
$(AR) grc gobuild.a util.$O
rm -f $(O1)
a2: $(O2)
$(AR) grc gobuild.a makefile.$O
rm -f $(O2)
a3: $(O3)
$(AR) grc gobuild.a gobuild.$O
rm -f $(O3)
newpkg: clean
$(AR) grc gobuild.a
$(O1): newpkg
$(O2): a1
$(O3): a2
# zzgobuild is a fake target that will always run, even if
# "gobuild" existed at the beginning of the make.
# The problem is that if you "make install" and install
# depends on gobuild and this rule says gobuild,
# and gobuild.a depends on phases, "phases" gets
# run, which cleans everything and then rebuilds
# gobuild.a. So now make thinks gobuild was up to date
# to begin with (and it ran "phases" just for good measure)
# but in fact gobuild is gone ("phases" removed it).
#
# Calling the target zzgobuild instead means that
# make will always run this rule, rebuilding gobuild
# before trying to install it. Sigh.
zzgobuild: main.$O gobuild.a
$(LD) -o gobuild main.$O
gobuild: zzgobuild
main.$O: phases
nuke: clean
rm -f $(HOME)/bin/gobuild
install: zzgobuild
cp gobuild $(HOME)/bin/gobuild