Commit 01fe6a9c authored by Russ Cox's avatar Russ Cox

more build refinements:

 * use new Make.$GOARCH files in gobuild.
 * rename 6ar to arch-generic gopack.
 * place objects in $GOROOT/pkg/$GOOS_$GOARCH
   (makes cross-compiling easier, and no one
   ever types these paths by hand anyway).

R=r
DELTA=29  (6 added, 8 deleted, 15 changed)
OCL=29923
CL=29967
parent b90960e0
......@@ -7,3 +7,4 @@ AS=${O}a
CC=${O}c
GC=${O}g
LD=${O}l
OS=568vq
\ No newline at end of file
......@@ -7,3 +7,4 @@ AS=${O}a
CC=${O}c
GC=${O}g
LD=${O}l
OS=568vq
\ No newline at end of file
......@@ -7,3 +7,4 @@ AS=${O}a
CC=${O}c
GC=${O}g
LD=${O}l
OS=568vq
......@@ -689,7 +689,7 @@ addlib(char *src, char *obj)
if(access(pname, AEXIST) < 0 && LIBDIR != nil)
snprint(pname, sizeof pname, "%s/%s", LIBDIR, name);
if(access(pname, AEXIST) < 0)
snprint(pname, sizeof pname, "%s/pkg/%s", goroot, name);
snprint(pname, sizeof pname, "%s/pkg/%s_%s/%s", goroot, goos, goarch, name);
strcpy(name, pname);
}
if(debug['v'])
......
......@@ -655,7 +655,7 @@ addlib(char *src, char *obj)
if(access(pname, AEXIST) < 0 && LIBDIR != nil)
snprint(pname, sizeof pname, "%s/%s", LIBDIR, name);
if(access(pname, AEXIST) < 0)
snprint(pname, sizeof pname, "%s/pkg/%s", goroot, name);
snprint(pname, sizeof pname, "%s/pkg/%s_%s/%s", goroot, goos, goarch, name);
strcpy(name, pname);
}
if(debug['v'])
......
......@@ -8,7 +8,7 @@ include ../../Make.conf
# We call the binary 6ar to avoid confusion and because this binary
# is linked only with amd64 and x86 support.
TARG=6ar
TARG=gopack
OFILES=\
ar.$O\
......
......@@ -212,11 +212,13 @@ addidir(char* dir)
int
findpkg(Strlit *name)
{
static char* goroot;
Idir* p;
static char *goroot, *goos, *goarch;
Idir *p;
if(goroot == nil) {
goroot = getenv("GOROOT");
goos = getenv("GOOS");
goarch = getenv("GOARCH");
}
// try .a before .6. important for building libraries:
......@@ -238,10 +240,10 @@ findpkg(Strlit *name)
if(access(namebuf, 0) >= 0)
return 1;
if(goroot != nil) {
snprint(namebuf, sizeof(namebuf), "%s/pkg/%Z.a", goroot, name);
snprint(namebuf, sizeof(namebuf), "%s/pkg/%s_%s/%Z.a", goroot, goos, goarch, name);
if(access(namebuf, 0) >= 0)
return 1;
snprint(namebuf, sizeof(namebuf), "%s/pkg/%Z.%c", goroot, name, thechar);
snprint(namebuf, sizeof(namebuf), "%s/pkg/%s_%s/%Z.%c", goroot, goos, goarch, name, thechar);
if(access(namebuf, 0) >= 0)
return 1;
}
......
......@@ -18,16 +18,8 @@ var makefileTemplate =
"\n"
"D={.section Dir}/{@}{.end}\n"
"\n"
"O_arm=5\n" // TODO(rsc): include something here?
"O_amd64=6\n"
"O_386=8\n"
"OS=568vq\n"
"\n"
"O=$(O_$(GOARCH))\n"
"GC=$(O)g -I{ObjDir}\n"
"CC=$(O)c -FVw\n"
"AS=$(O)a\n"
"AR=6ar\n"
"include $(GOROOT)/src/Make.$(GOARCH)\n"
"AR=gopack\n"
"\n"
"default: packages\n"
"\n"
......@@ -42,7 +34,7 @@ var makefileTemplate =
" 6cov -g `pwd` | grep -v '_test\\.go:'\n"
"\n"
"%.$O: %.go\n"
" $(GC) $*.go\n"
" $(GC) -I{ObjDir} $*.go\n"
"\n"
"%.$O: %.c\n"
" $(CC) $*.c\n"
......@@ -86,14 +78,14 @@ var makefileTemplate =
"{.end}\n"
"\n"
"nuke: clean\n"
" rm -f{.repeated section Packages} $(GOROOT)/pkg$D/{Name}.a{.end}\n"
" rm -f{.repeated section Packages} $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/{Name}.a{.end}\n"
"\n"
"packages:{.repeated section Packages} {ObjDir}$D/{Name}.a{.end}\n"
"\n"
"install: packages\n"
" test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg$D\n"
" test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D\n"
"{.repeated section Packages}\n"
" cp {ObjDir}$D/{Name}.a $(GOROOT)/pkg$D/{Name}.a\n"
" cp {ObjDir}$D/{Name}.a $(GOROOT)/pkg/$(GOOS)_$(GOARCH)$D/{Name}.a\n"
"{.end}\n"
func argsFmt(w io.Writer, x interface{}, format string) {
......
......@@ -59,7 +59,7 @@ func init() {
theChar + "g",
theChar + "c",
theChar + "a",
"6ar", // sic
"gopack",
};
for i, v := range binaries {
......@@ -138,7 +138,7 @@ func Build(cmd []string, file string, flag int) (ok bool) {
}
func Archive(pkg string, files []string) {
argv := []string{ "6ar", "grc", pkg };
argv := []string{ "gopack", "grc", pkg };
for i, file := range files {
PushString(&argv, file);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment