]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: c tools not used during compilation
authorRob Pike <r@golang.org>
Sun, 29 Jan 2012 18:14:36 +0000 (10:14 -0800)
committerRob Pike <r@golang.org>
Sun, 29 Jan 2012 18:14:36 +0000 (10:14 -0800)
cov, nm, pprof, prof

R=rsc, r, rsc
CC=golang-dev
https://golang.org/cl/5576067

src/Make.ctool [new file with mode: 0644]
src/cmd/cov/Makefile
src/cmd/go/tool.go
src/cmd/nm/Makefile
src/cmd/prof/Makefile
src/cmd/prof/pprof [moved from src/cmd/prof/gopprof with 100% similarity]
src/sudo.bash

diff --git a/src/Make.ctool b/src/Make.ctool
new file mode 100644 (file)
index 0000000..715fab6
--- /dev/null
@@ -0,0 +1,50 @@
+# Copyright 2010 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.
+
+# Makefile for commands written in C.
+
+# Tools always go into $GOROOT/bin/go-tool
+
+ifeq (windows,$(findstring windows, $(shell uname | tr A-Z a-z | sed 's/mingw/windows/')))
+TARG:=$(TARG).exe
+endif
+
+$(TARG): $(OFILES) $(LIB)
+       $(HOST_LD) -o $(TARG) -L"$(GOROOT)"/lib $(OFILES) $(LIB) -lmach -lbio -l9 -lm $(HOST_LDFLAGS)
+
+$(OFILES): $(HFILES)
+
+CLEANFILES+=y.tab.[ch]
+
+clean:
+       rm -f *.$(HOST_O) $(TARG) $(CLEANFILES)
+
+nuke: clean
+       rm -f "$(GOROOT)/bin/go-tool/$(TARG)"
+
+ifneq ($(NOINSTALL),1)
+install: $(QUOTED_GOROOT)/bin/go-tool/$(TARG)
+endif
+
+$(QUOTED_GOROOT)/bin/go-tool/$(TARG): $(TARG)
+       mkdir -p "$(GOROOT)/bin/go-tool" && cp $(TARG) "$(GOROOT)/bin/go-tool/$(TARG)"
+
+y.tab.h: $(YFILES)
+       bison -y $(HOST_YFLAGS) $(YFILES)
+
+y.tab.c: y.tab.h
+       test -f y.tab.c && touch y.tab.c
+
+all: $(TARG)
+
+# Use $(PWD)/$*.c so that gdb shows full path in stack traces.
+%.$(HOST_O): %.c
+       $(HOST_CC) $(HOST_CFLAGS) -c "$(PWD)/$*.c"
+
+# These are used by enough different Makefiles to be
+# worth writing down in one place, even if they don't
+# apply to every command that builds with Make.ccmd
+../%l/enam.o:
+       cd ../$*l; $(MAKE) enam.o
+
index c080f4a284d518cd04314179defcda880e238cb2..616e94f647d8b1eff46b5679378d25bef2f8a341 100644 (file)
@@ -9,7 +9,7 @@ O:=$(HOST_O)
 # We call the binary 6cov to avoid confusion and because this binary
 # is linked only with amd64 and x86 support.
 
-TARG=6cov
+TARG=cov
 OFILES=\
        main.$O\
        tree.$O\
@@ -18,7 +18,7 @@ HFILES=\
        tree.h\
 
 NOINSTALL=1
-include ../../Make.ccmd
+include ../../Make.ctool
 
 ifeq ($(GOOS),windows)
 NAME=windows
@@ -38,4 +38,4 @@ install-darwin: $(TARG)
        @true
 
 install-default: $(TARG)
-       cp $(TARG) "$(GOBIN)"/$(TARG)
+       cp $(TARG) "$(GOBIN)"/go-tool/$(TARG)
index 24ed78bdabaccaa3fc66e5582f386c4829f937bc..12be9a8036c4bf5fd894a9bc2a4cf1203e63e2f0 100644 (file)
@@ -87,7 +87,7 @@ func listTools() {
                exitStatus = 2
                return
        }
-       sort.StringSlice(names).Sort()
+       sort.Strings(names)
        for _, name := range names {
                // Unify presentation by going to lower case.
                name = strings.ToLower(name)
index 81bc348deb9d15e7c240b2f62fef720ce257921b..f2a89d83f5895230506eb86d6e1c78e02ad7f274 100644 (file)
@@ -8,8 +8,8 @@ O:=$(HOST_O)
 # The directory is nm because the source is portable and general.
 # We call the binary 6nm to avoid confusion with the host nm.
 
-TARG=6nm
+TARG=nm
 OFILES=\
        nm.$O\
 
-include ../../Make.ccmd
+include ../../Make.ctool
index 292a6482a22978409a5f4b4deccaab760a7cfc22..9266814a0a868a5dddb1b6954b5f1759a1eea01a 100644 (file)
@@ -5,16 +5,14 @@
 include ../../Make.inc
 O:=$(HOST_O)
 
-# The directory is prof because the source is portable and general.
-# We call the binary 6prof to avoid confusion and because this binary
-# is linked only with amd64 and x86 support.
+# This binary is linked only with amd64 and x86 support.
 
-TARG=6prof
+TARG=prof
 OFILES=\
        main.$O\
 
 NOINSTALL=1
-include ../../Make.ccmd
+include ../../Make.ctool
 
 ifeq ($(GOOS),windows)
 NAME=windows
@@ -34,7 +32,7 @@ install-darwin: $(TARG)
        @true
 
 install-default: $(TARG)
-       cp $(TARG) "$(GOBIN)"/$(TARG)
+       cp $(TARG) "$(GOBIN)"/go-tool/$(TARG)
 
-install-pprof: gopprof
-       cp gopprof "$(GOBIN)"/gopprof
+install-pprof: pprof
+       cp pprof "$(GOBIN)"/go-tool/pprof
similarity index 100%
rename from src/cmd/prof/gopprof
rename to src/cmd/prof/pprof
index 3322a1856de60e1a42c01673118b1ea98300f05a..3e4843dc28f0594e8bb2b193141bd5c035280f71 100755 (executable)
@@ -20,7 +20,10 @@ fi
 
 for i in prof cov
 do
-       sudo cp "$GOROOT"/src/cmd/$i/6$i /usr/local/bin/6$i
-       sudo chgrp procmod /usr/local/bin/6$i
-       sudo chmod g+s /usr/local/bin/6$i
+       # Remove old binaries if present
+       sudo rm -f /usr/local/bin/6$i
+       # Install new binaries
+       sudo cp "$GOROOT"/src/cmd/$i/$i /usr/local/bin/go$i
+       sudo chgrp procmod /usr/local/bin/go$i
+       sudo chmod g+s /usr/local/bin/go$i
 done