From 6609d2f88d05666e504e8bfc2b0656f09be9a73c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 5 Jun 2009 10:59:55 -0700 Subject: [PATCH] restructure makefiles, scripts to factor out O= logic. remove a few hardcoded paths elsewhere too. R=r,gri DELTA=123 (44 added, 15 deleted, 64 changed) OCL=29914 CL=29945 --- doc/progs/run | 23 +++++++++++++++-------- src/Make.386 | 9 +++++++++ src/Make.amd64 | 9 +++++++++ src/Make.arm | 9 +++++++++ src/cmd/gc/mkbuiltin | 9 ++++++++- src/cmd/gotest/gotest | 20 +++++++++++--------- src/cmd/ld/go.c | 20 ++++++++++---------- src/cmd/make.bash | 11 ++++------- src/lib/Makefile | 2 -- usr/gri/pretty/Makefile | 25 ++++++++++++------------- usr/gri/pretty/test.sh | 12 +++++++++--- 11 files changed, 96 insertions(+), 53 deletions(-) create mode 100644 src/Make.386 create mode 100644 src/Make.amd64 create mode 100644 src/Make.arm diff --git a/doc/progs/run b/doc/progs/run index 7b9ebfa80c6..3b07db4cceb 100755 --- a/doc/progs/run +++ b/doc/progs/run @@ -3,7 +3,14 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -rm -f *.6 +. $GOROOT/src/Make.$GOARCH + +if [ -z "$O" ]; then + echo 'missing $O - maybe no Make.$GOARCH?' 1>&2 + exit 1 +fi + +rm -f *.$O for i in \ file.go \ @@ -23,12 +30,12 @@ for i in \ ; do BASE=$(basename $i .go) - 6g $i + $GC $i done function testit { - 6l $1.6 - x=$(echo $(./6.out $2 2>&1)) # extra echo canonicalizes + $LD $1.$O + x=$(echo $(./$O.out $2 2>&1)) # extra echo canonicalizes if [ "$x" != "$3" ] then echo $1 failed: '"'$x'"' is not '"'$3'"' @@ -36,8 +43,8 @@ function testit { } function testitpipe { - 6l $1.6 - x=$(echo $(./6.out | $2 2>&1)) # extra echo canonicalizes + $LD $1.$O + x=$(echo $(./$O.out | $2 2>&1)) # extra echo canonicalizes if [ "$x" != "$3" ] then echo $1 failed: '"'$x'"' is not '"'$3'"' @@ -65,7 +72,7 @@ testitpipe sieve "sed 10q" "2 3 5 7 11 13 17 19 23 29" testitpipe sieve "sed 10q" "2 3 5 7 11 13 17 19 23 29" # server hangs; don't run it, just compile it -6g server.go +$GC server.go testit server1 "" "" -rm -f 6.out *.6 +rm -f $O.out *.$O diff --git a/src/Make.386 b/src/Make.386 new file mode 100644 index 00000000000..d97965f1cf0 --- /dev/null +++ b/src/Make.386 @@ -0,0 +1,9 @@ +# 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. + +O=8 +AS=${O}a +CC=${O}c +GC=${O}g +LD=${O}l diff --git a/src/Make.amd64 b/src/Make.amd64 new file mode 100644 index 00000000000..a6bc9c67d48 --- /dev/null +++ b/src/Make.amd64 @@ -0,0 +1,9 @@ +# 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. + +O=6 +AS=${O}a +CC=${O}c +GC=${O}g +LD=${O}l diff --git a/src/Make.arm b/src/Make.arm new file mode 100644 index 00000000000..ef907329dc3 --- /dev/null +++ b/src/Make.arm @@ -0,0 +1,9 @@ +# 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. + +O=5 +AS=${O}a +CC=${O}c +GC=${O}g +LD=${O}l diff --git a/src/cmd/gc/mkbuiltin b/src/cmd/gc/mkbuiltin index 97d98fd8220..ba01cbb457e 100755 --- a/src/cmd/gc/mkbuiltin +++ b/src/cmd/gc/mkbuiltin @@ -4,11 +4,18 @@ # license that can be found in the LICENSE file. set -e + +. $GOROOT/src/Make.$GOARCH +if [ -z "$GC" ]; then + echo 'missing $GC - maybe no Make.$GOARCH?' 1>&2 + exit 1 +fi + gcc -o mkbuiltin1 mkbuiltin1.c rm -f _builtin.c for i in sys unsafe do - 6g $i.go + $GC $i.go ./mkbuiltin1 $i >>_builtin.c done diff --git a/src/cmd/gotest/gotest b/src/cmd/gotest/gotest index 7574926ab80..7d64d56cc51 100755 --- a/src/cmd/gotest/gotest +++ b/src/cmd/gotest/gotest @@ -8,18 +8,20 @@ # tests. # If files are named on the command line, use them instead of test*.go. -case "$GOARCH" in -amd64) O=6;; -arm) O=5;; -386) O=8;; -*) echo 'unknown $GOARCH' 1>&2 -esac +_GC=$GC # Make.$GOARCH will overwrite this -GC=${GC:-${O}g} -GL=${GL:-${O}l} -export GC GL +. $GOROOT/src/Make.$GOARCH +if [ -z "$O" ]; then + echo 'missing $O - maybe no Make.$GOARCH?' 1>&2 + exit 1 +fi + +# Allow overrides +GC=${_GC:-$GC} +GL=${GL:-$LD} GC="$GC -I _obj" GL="$GL -L _obj" +export GC GL gofiles="" loop=true diff --git a/src/cmd/ld/go.c b/src/cmd/ld/go.c index e20f10a1476..6990d732925 100644 --- a/src/cmd/ld/go.c +++ b/src/cmd/ld/go.c @@ -100,12 +100,12 @@ ldpkg(Biobuf *f, int64 len, char *filename) return; if((int)len != len) { - fprint(2, "6l: too much pkg data in %s\n", filename); + fprint(2, "%s: too much pkg data in %s\n", argv0, filename); return; } data = mal(len+1); if(Bread(f, data, len) != len) { - fprint(2, "6l: short pkg read %s\n", filename); + fprint(2, "%s: short pkg read %s\n", argv0, filename); return; } data[len] = '\0'; @@ -121,13 +121,13 @@ ldpkg(Biobuf *f, int64 len, char *filename) // second marks end of exports / beginning of local data p1 = strstr(p0, "\n$$"); if(p1 == nil) { - fprint(2, "6l: cannot find end of exports in %s\n", filename); + fprint(2, "%s: cannot find end of exports in %s\n", argv0, filename); return; } while(*p0 == ' ' || *p0 == '\t' || *p0 == '\n') p0++; if(strncmp(p0, "package ", 8) != 0) { - fprint(2, "6l: bad package section in %s\n", filename); + fprint(2, "%s: bad package section in %s\n", argv0, filename); return; } p0 += 8; @@ -147,7 +147,7 @@ ldpkg(Biobuf *f, int64 len, char *filename) // local types end at next \n$$. p1 = strstr(p0, "\n$$"); if(p1 == nil) { - fprint(2, "6l: cannot find end of local types in %s\n", filename); + fprint(2, "%s: cannot find end of local types in %s\n", argv0, filename); return; } @@ -173,13 +173,13 @@ loadpkgdata(char *file, char *data, int len) x->export = export; } else { if(strcmp(x->prefix, prefix) != 0) { - fprint(2, "6l: conflicting definitions for %s\n", name); + fprint(2, "%s: conflicting definitions for %s\n", argv0, name); fprint(2, "%s:\t%s %s ...\n", x->file, x->prefix, name); fprint(2, "%s:\t%s %s ...\n", file, prefix, name); nerrors++; } else if(strcmp(x->def, def) != 0) { - fprint(2, "6l: conflicting definitions for %s\n", name); + fprint(2, "%s: conflicting definitions for %s\n", argv0, name); fprint(2, "%s:\t%s %s %s\n", x->file, x->prefix, name, x->def); fprint(2, "%s:\t%s %s %s\n", file, prefix, name, def); nerrors++; @@ -232,7 +232,7 @@ parsepkgdata(char *file, char **pp, char *ep, int *exportp, char **prefixp, char else if(strncmp(p, "const ", 6) == 0) p += 6; else{ - fprint(2, "6l: confused in pkg data near <<%.20s>>\n", p); + fprint(2, "%s: confused in pkg data near <<%.20s>>\n", argv0, p); nerrors++; return -1; } @@ -265,7 +265,7 @@ parsepkgdata(char *file, char **pp, char *ep, int *exportp, char **prefixp, char // indented we could do something more complicated, // but for now just diagnose the problem and assume // 6g will keep indenting for us. - fprint(2, "6l: %s: expected methods to be indented %p %p %.10s\n", + fprint(2, "%s: %s: expected methods to be indented %p %p %.10s\n", argv0, file, edef, meth, meth); nerrors++; return -1; @@ -305,7 +305,7 @@ parsemethod(char **pp, char *ep, char **methp) while(p < ep && *p != '\n') p++; if(p >= ep) { - fprint(2, "6l: lost end of line in method definition\n"); + fprint(2, "%s: lost end of line in method definition\n", argv0); *pp = ep; return -1; } diff --git a/src/cmd/make.bash b/src/cmd/make.bash index f406e358af2..ca4517218e3 100644 --- a/src/cmd/make.bash +++ b/src/cmd/make.bash @@ -7,14 +7,11 @@ set -e bash clean.bash -case "$GOARCH" in -386) O=8;; -amd64) O=6;; -arm) O=5;; -*) - echo 'unknown $GOARCH' 1>&2 +. $GOROOT/src/Make.$GOARCH +if [ -z "$O" ]; then + echo 'missing $O - maybe no Make.$GOARCH?' 1>&2 exit 1 -esac +fi cd ${O}l bash mkenam diff --git a/src/lib/Makefile b/src/lib/Makefile index bdcfa0194e9..6627f586e7f 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -11,8 +11,6 @@ all: install -GC=6g - DIRS=\ bignum\ bufio\ diff --git a/usr/gri/pretty/Makefile b/usr/gri/pretty/Makefile index 0ede5d470a8..96f1184b951 100644 --- a/usr/gri/pretty/Makefile +++ b/usr/gri/pretty/Makefile @@ -2,19 +2,18 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -G=6g -L=6l +include $(GOROOT)/src/Make.$(GOARCH) all: untab godoc pretty -untab: untab.6 - $(L) -o untab untab.6 +untab: untab.$O + $(LD) -o untab untab.$O -godoc: godoc.6 - $(L) -o godoc godoc.6 +godoc: godoc.$O + $(LD) -o godoc godoc.$O -pretty: pretty.6 - $(L) -o pretty pretty.6 +pretty: pretty.$O + $(LD) -o pretty pretty.$O test: pretty ./test.sh @@ -28,11 +27,11 @@ install: pretty godoc untab cp untab $(HOME)/bin/untab clean: - rm -f pretty untab godoc *.6 *.a 6.out *~ + rm -f pretty untab godoc *.$O *.a 6.out *~ -godoc.6: astprinter.6 +godoc.$O: astprinter.$O -pretty.6: astprinter.6 +pretty.$O: astprinter.$O -%.6: %.go - $(G) $(F) $< +%.$O: %.go + $(GC) $(F) $< diff --git a/usr/gri/pretty/test.sh b/usr/gri/pretty/test.sh index ffc3fc091ac..c3308211552 100755 --- a/usr/gri/pretty/test.sh +++ b/usr/gri/pretty/test.sh @@ -4,6 +4,12 @@ #!/bin/bash +. $GOROOT/src/Make.$GOARCH +if [ -z "$O" ]; then + echo 'missing $O - maybe no Make.$GOARCH?' 1>&2 + exit 1 +fi + CMD="./pretty -format=ast.txt" TMP1=test_tmp1.go TMP2=test_tmp2.go @@ -73,7 +79,7 @@ idempotent() { echo "Error (step 1 of idempotency test): test.sh $1" exit 1 fi - + $CMD $TMP1 > $TMP2 if [ $? != 0 ]; then echo "Error (step 2 of idempotency test): test.sh $1" @@ -103,7 +109,7 @@ valid() { exit 1 fi - 6g -o /dev/null $TMP1 + $GC -o /dev/null $TMP1 if [ $? != 0 ]; then echo "Error (step 2 of validity test): test.sh $1" exit 1 @@ -125,7 +131,7 @@ runtest() { runtests() { if [ $# == 0 ]; then runtest apply - # verify the pretty-printed files can be compiled with 6g again + # verify the pretty-printed files can be compiled with $GC again # do it in local directory only because of the prerequisites required #echo "Testing validity" cleanup