]> Cypherpunks repositories - gostls13.git/commitdiff
restructure makefiles, scripts to factor out O= logic.
authorRuss Cox <rsc@golang.org>
Fri, 5 Jun 2009 17:59:55 +0000 (10:59 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 5 Jun 2009 17:59:55 +0000 (10:59 -0700)
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
src/Make.386 [new file with mode: 0644]
src/Make.amd64 [new file with mode: 0644]
src/Make.arm [new file with mode: 0644]
src/cmd/gc/mkbuiltin
src/cmd/gotest/gotest
src/cmd/ld/go.c
src/cmd/make.bash
src/lib/Makefile
usr/gri/pretty/Makefile
usr/gri/pretty/test.sh

index 7b9ebfa80c6c93cd2a186fe05470bf82409a26bc..3b07db4cceb1211f8c75037c13e1da4c98b6c696 100755 (executable)
@@ -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 (file)
index 0000000..d97965f
--- /dev/null
@@ -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 (file)
index 0000000..a6bc9c6
--- /dev/null
@@ -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 (file)
index 0000000..ef90732
--- /dev/null
@@ -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
index 97d98fd8220594f5feb7810588e6b60ae60b3559..ba01cbb457e7147fd5eb27298600a164c7c87b86 100755 (executable)
@@ -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
 
index 7574926ab80c060acaa1838ba1efd0031e421994..7d64d56cc515d19645400d49fcc78997f5b14d9a 100755 (executable)
@@ -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
index e20f10a1476d85a8cb52ba834db919259898103c..6990d7329257a08e311e91766f3df84881b8f579 100644 (file)
@@ -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;
        }
index f406e358af2e0796c2b4a3fbe48ae1befdaa0811..ca4517218e3bf22d5aaa56b3e64242e6f6e38e8f 100644 (file)
@@ -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
index bdcfa0194e9d4a68dbe838800ddff6051e1f5255..6627f586e7fdda1dffba48d42a232ff738aef0a6 100644 (file)
@@ -11,8 +11,6 @@
 
 all: install
 
-GC=6g
-
 DIRS=\
        bignum\
        bufio\
index 0ede5d470a8810117fc17f429945ff5026e107b4..96f1184b951f971e5f2cd1b3218a3418fcd62d2a 100644 (file)
@@ -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) $<
index ffc3fc091ac8707406a1bd045a43da34dfb61be3..c3308211552cf14ee021365dfdc684d67f6b436f 100755 (executable)
@@ -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