--- /dev/null
+# 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
+
# 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\
tree.h\
NOINSTALL=1
-include ../../Make.ccmd
+include ../../Make.ctool
ifeq ($(GOOS),windows)
NAME=windows
@true
install-default: $(TARG)
- cp $(TARG) "$(GOBIN)"/$(TARG)
+ cp $(TARG) "$(GOBIN)"/go-tool/$(TARG)
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)
# 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
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
@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
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