diff options
Diffstat (limited to 'src/cmd/goinstall/make.go')
-rw-r--r-- | src/cmd/goinstall/make.go | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/src/cmd/goinstall/make.go b/src/cmd/goinstall/make.go index e2d99bb47..ceb119e5a 100644 --- a/src/cmd/goinstall/make.go +++ b/src/cmd/goinstall/make.go @@ -52,12 +52,6 @@ func makeMakefile(dir, pkg string) ([]byte, os.Error) { return nil, err } - if len(dirInfo.cgoFiles) == 0 && len(dirInfo.cFiles) > 0 { - // When using cgo, .c files are compiled with gcc. Without cgo, - // they may be intended for 6c. Just error out for now. - return nil, os.ErrorString("C files found in non-cgo package") - } - cgoFiles := dirInfo.cgoFiles isCgo := make(map[string]bool, len(cgoFiles)) for _, file := range cgoFiles { @@ -67,26 +61,40 @@ func makeMakefile(dir, pkg string) ([]byte, os.Error) { isCgo[file] = true } - oFiles := make([]string, 0, len(dirInfo.cFiles)) - for _, file := range dirInfo.cFiles { + goFiles := make([]string, 0, len(dirInfo.goFiles)) + for _, file := range dirInfo.goFiles { if !safeName(file) { return nil, os.ErrorString("unsafe name: " + file) } - oFiles = append(oFiles, file[:len(file)-2]+".o") + if !isCgo[file] { + goFiles = append(goFiles, file) + } } - goFiles := make([]string, 0, len(dirInfo.goFiles)) - for _, file := range dirInfo.goFiles { + oFiles := make([]string, 0, len(dirInfo.cFiles)+len(dirInfo.sFiles)) + cgoOFiles := make([]string, 0, len(dirInfo.cFiles)) + for _, file := range dirInfo.cFiles { if !safeName(file) { return nil, os.ErrorString("unsafe name: " + file) } - if !isCgo[file] { - goFiles = append(goFiles, file) + // When cgo is in use, C files are compiled with gcc, + // otherwise they're compiled with gc. + if len(cgoFiles) > 0 { + cgoOFiles = append(cgoOFiles, file[:len(file)-2]+".o") + } else { + oFiles = append(oFiles, file[:len(file)-2]+".$O") } } + for _, file := range dirInfo.sFiles { + if !safeName(file) { + return nil, os.ErrorString("unsafe name: " + file) + } + oFiles = append(oFiles, file[:len(file)-2]+".$O") + } + var buf bytes.Buffer - md := makedata{pkg, goFiles, cgoFiles, oFiles} + md := makedata{pkg, goFiles, oFiles, cgoFiles, cgoOFiles} if err := makefileTemplate.Execute(&buf, &md); err != nil { return nil, err } @@ -106,10 +114,11 @@ func safeName(s string) bool { // makedata is the data type for the makefileTemplate. type makedata struct { - Pkg string // package import path - GoFiles []string // list of non-cgo .go files - CgoFiles []string // list of cgo .go files - OFiles []string // list of ofiles for cgo + Pkg string // package import path + GoFiles []string // list of non-cgo .go files + OFiles []string // list of .$O files + CgoFiles []string // list of cgo .go files + CgoOFiles []string // list of cgo .o files, without extension } var makefileTemplate = template.MustParse(` @@ -124,6 +133,13 @@ GOFILES=\ {.end} {.end} +{.section OFiles} +OFILES=\ +{.repeated section OFiles} + {@}\ +{.end} + +{.end} {.section CgoFiles} CGOFILES=\ {.repeated section CgoFiles} @@ -131,9 +147,9 @@ CGOFILES=\ {.end} {.end} -{.section OFiles} +{.section CgoOFiles} CGO_OFILES=\ -{.repeated section OFiles} +{.repeated section CgoOFiles} {@}\ {.end} |