mirror of
https://github.com/golang/go
synced 2024-11-24 21:10:04 -07:00
Factor the Makefiles to make writing outside Makefiles easier.
R=rsc CC=golang-dev https://golang.org/cl/650042
This commit is contained in:
parent
60c2e5f453
commit
14abacf108
21
src/Make.cmd
21
src/Make.cmd
@ -2,22 +2,22 @@
|
|||||||
# Use of this source code is governed by a BSD-style
|
# Use of this source code is governed by a BSD-style
|
||||||
# license that can be found in the LICENSE file.
|
# license that can be found in the LICENSE file.
|
||||||
|
|
||||||
# GNU Make syntax:
|
|
||||||
ifndef GOBIN
|
|
||||||
GOBIN=$(HOME)/bin
|
|
||||||
endif
|
|
||||||
|
|
||||||
# ugly hack to deal with whitespaces in $GOBIN
|
# ugly hack to deal with whitespaces in $GOROOT
|
||||||
nullstring :=
|
nullstring :=
|
||||||
space := $(nullstring) # a space at the end
|
space := $(nullstring) # a space at the end
|
||||||
QUOTED_GOBIN=$(subst $(space),\ ,$(GOBIN))
|
QUOTED_GOROOT:=$(subst $(space),\ ,$(GOROOT))
|
||||||
|
|
||||||
|
include $(QUOTED_GOROOT)/src/Make.common
|
||||||
|
|
||||||
|
PREREQ+=$(patsubst %,%.make,$(DEPS))
|
||||||
|
|
||||||
all: $(TARG)
|
all: $(TARG)
|
||||||
|
|
||||||
$(TARG): _go_.$O $(OFILES)
|
$(TARG): _go_.$O $(OFILES)
|
||||||
$(QUOTED_GOBIN)/$(LD) -o $@ _go_.$O $(OFILES)
|
$(QUOTED_GOBIN)/$(LD) -o $@ _go_.$O $(OFILES)
|
||||||
|
|
||||||
_go_.$O: $(GOFILES)
|
_go_.$O: $(GOFILES) $(PREREQ)
|
||||||
$(QUOTED_GOBIN)/$(GC) -o $@ $(GOFILES)
|
$(QUOTED_GOBIN)/$(GC) -o $@ $(GOFILES)
|
||||||
|
|
||||||
install: $(QUOTED_GOBIN)/$(TARG)
|
install: $(QUOTED_GOBIN)/$(TARG)
|
||||||
@ -25,8 +25,7 @@ install: $(QUOTED_GOBIN)/$(TARG)
|
|||||||
$(QUOTED_GOBIN)/$(TARG): $(TARG)
|
$(QUOTED_GOBIN)/$(TARG): $(TARG)
|
||||||
cp -f $(TARG) $(QUOTED_GOBIN)
|
cp -f $(TARG) $(QUOTED_GOBIN)
|
||||||
|
|
||||||
clean:
|
CLEANFILES+=$(TARG)
|
||||||
rm -f *.[$(OS)] $(TARG) $(CLEANFILES)
|
|
||||||
|
|
||||||
nuke:
|
nuke: clean
|
||||||
rm -f *.[$(OS)] $(TARG) $(CLEANFILES) $(QUOTED_GOBIN)/$(TARG)
|
rm -f $(QUOTED_GOBIN)/$(TARG)
|
||||||
|
26
src/Make.common
Normal file
26
src/Make.common
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
# GNU Make syntax:
|
||||||
|
ifndef GOBIN
|
||||||
|
GOBIN=$(HOME)/bin
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ugly hack to deal with whitespaces in $GOBIN
|
||||||
|
nullstring :=
|
||||||
|
space := $(nullstring) # a space at the end
|
||||||
|
ifndef GOBIN
|
||||||
|
QUOTED_HOME=$(subst $(space),\ ,$(HOME))
|
||||||
|
GOBIN=$(QUOTED_HOME)/bin
|
||||||
|
endif
|
||||||
|
QUOTED_GOBIN=$(subst $(space),\ ,$(GOBIN))
|
||||||
|
|
||||||
|
# ugly hack to deal with whitespaces in $GOROOT
|
||||||
|
QUOTED_GOROOT:=$(subst $(space),\ ,$(GOROOT))
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf *.o *.a *.[$(OS)] [$(OS)].out $(CLEANFILES)
|
||||||
|
|
||||||
|
%.make:
|
||||||
|
(cd $* && $(QUOTED_GOBIN)/gomake install)
|
21
src/Make.pkg
21
src/Make.pkg
@ -6,13 +6,12 @@ all: package
|
|||||||
package: _obj/$(TARG).a
|
package: _obj/$(TARG).a
|
||||||
testpackage: _test/$(TARG).a
|
testpackage: _test/$(TARG).a
|
||||||
|
|
||||||
|
# ugly hack to deal with whitespaces in $GOROOT
|
||||||
nullstring :=
|
nullstring :=
|
||||||
space := $(nullstring) # a space at the end
|
space := $(nullstring) # a space at the end
|
||||||
ifndef GOBIN
|
QUOTED_GOROOT:=$(subst $(space),\ ,$(GOROOT))
|
||||||
QUOTED_HOME=$(subst $(space),\ ,$(HOME))
|
|
||||||
GOBIN=$(QUOTED_HOME)/bin
|
include $(QUOTED_GOROOT)/src/Make.common
|
||||||
endif
|
|
||||||
QUOTED_GOBIN=$(subst $(space),\ ,$(GOBIN))
|
|
||||||
|
|
||||||
# GNU Make 3.80 has a bug in lastword
|
# GNU Make 3.80 has a bug in lastword
|
||||||
# elem=$(lastword $(subst /, ,$(TARG)))
|
# elem=$(lastword $(subst /, ,$(TARG)))
|
||||||
@ -25,9 +24,6 @@ else
|
|||||||
dir=$(patsubst %/$(elem),%,$(TARG))
|
dir=$(patsubst %/$(elem),%,$(TARG))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# ugly hack to deal with whitespaces in $GOROOT
|
|
||||||
QUOTED_GOROOT=$(subst $(space),\ ,$(GOROOT))
|
|
||||||
|
|
||||||
pkgdir=$(QUOTED_GOROOT)/pkg/$(GOOS)_$(GOARCH)
|
pkgdir=$(QUOTED_GOROOT)/pkg/$(GOOS)_$(GOARCH)
|
||||||
|
|
||||||
INSTALLFILES+=$(pkgdir)/$(TARG).a
|
INSTALLFILES+=$(pkgdir)/$(TARG).a
|
||||||
@ -40,15 +36,15 @@ GOFILES+=_cgo_gotypes.go
|
|||||||
OFILES+=_cgo_defun.$O
|
OFILES+=_cgo_defun.$O
|
||||||
GCC_OFILES=$(patsubst %.go,%.cgo2.o,$(CGOFILES))
|
GCC_OFILES=$(patsubst %.go,%.cgo2.o,$(CGOFILES))
|
||||||
INSTALLFILES+=$(pkgdir)/$(TARG).so
|
INSTALLFILES+=$(pkgdir)/$(TARG).so
|
||||||
PREREQ+=$(patsubst %,%.make,$(DEPS))
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
PREREQ+=$(patsubst %,%.make,$(DEPS))
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
$(QUOTED_GOBIN)/gotest
|
$(QUOTED_GOBIN)/gotest
|
||||||
$(QUOTED_GOBIN)/6cov -g $(shell pwd) $O.out | grep -v '_test\.go:'
|
$(QUOTED_GOBIN)/6cov -g $(shell pwd) $O.out | grep -v '_test\.go:'
|
||||||
|
|
||||||
clean:
|
CLEANFILES+=*.cgo1.go *.cgo2.c _cgo_defun.c _cgo_gotypes.go *.so _obj _test _testmain.go
|
||||||
rm -rf *.[$(OS)o] *.a [$(OS)].out *.cgo1.go *.cgo2.c _cgo_defun.c _cgo_gotypes.go *.so _obj _test _testmain.go $(CLEANFILES)
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
$(QUOTED_GOBIN)/gotest
|
$(QUOTED_GOBIN)/gotest
|
||||||
@ -90,9 +86,6 @@ importpath:
|
|||||||
dir:
|
dir:
|
||||||
@echo $(dir)
|
@echo $(dir)
|
||||||
|
|
||||||
%.make:
|
|
||||||
(cd $* && $(QUOTED_GOBIN)/gomake)
|
|
||||||
|
|
||||||
# To use cgo in a Go package, add a line
|
# To use cgo in a Go package, add a line
|
||||||
#
|
#
|
||||||
# CGOFILES=x.go y.go
|
# CGOFILES=x.go y.go
|
||||||
|
Loading…
Reference in New Issue
Block a user