From 3e45412327a2654a77944249962b3652e6142299 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Mon, 17 Jan 2011 12:40:45 +0100 Subject: Imported Upstream version 2011.01.12 --- doc/code.html | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) (limited to 'doc/code.html') diff --git a/doc/code.html b/doc/code.html index 14bb6f9fe..55afe09af 100644 --- a/doc/code.html +++ b/doc/code.html @@ -64,7 +64,7 @@ is illustrated by src/pkg/c

-include ../../../Make.$(GOARCH)
+include ../../../Make.inc
 
 TARG=container/vector
 GOFILES=\
@@ -80,7 +80,7 @@ Outside the Go source tree (for personal packages), the standard form is
 

-include $(GOROOT)/src/Make.$(GOARCH)
+include $(GOROOT)/src/Make.inc
 
 TARG=mypackage
 GOFILES=\
@@ -98,6 +98,14 @@ even if $(GOROOT) contains spaces.
 This makes it easy for programmers to try Go.
 

+

+If you have not set $GOROOT in your environment, +you must run gomake to use this form of makefile. +Gomake also takes care to invoke GNU Make +even on systems where it is installed as gmake +rather than make. +

+

TARG is the target install path for the package, the string that clients will use to import it. @@ -131,8 +139,8 @@ cd $GOROOT/src/pkg

to update the dependency file Make.deps. -(This happens automatically each time you run make all -or make build.) +(This happens automatically each time you run all.bash +or make.bash.)

@@ -169,6 +177,32 @@ Writing clean, idiomatic Go code is beyond the scope of this document. that topic.

+

Building programs

+

To build a Go program with gomake, create a Makefile alongside your program's +source files. It should be similar to the example above, but include +Make.cmd instead of Make.pkg: + +

+include $(GOROOT)/src/Make.inc
+
+TARG=helloworld
+GOFILES=\
+	helloworld.go\
+
+include $(GOROOT)/src/Make.cmd
+
+ +

Running gomake will compile helloworld.go +and produce an executable named helloworld in the current +directory. +

+ +

+Running gomake install will build helloworld if +necessary and copy it to the $GOBIN directory +($GOROOT/bin/ is the default). +

+

Testing

@@ -259,7 +293,7 @@ Finally, the Makefile:

-include $(GOROOT)/src/Make.$(GOARCH)
+include $(GOROOT)/src/Make.inc
 
 TARG=numbers
 GOFILES=\
@@ -269,13 +303,13 @@ include $(GOROOT)/src/Make.pkg
 

-Running make install will build and install the package to +Running gomake install will build and install the package to the $GOROOT/pkg/ directory (it can then be used by any program on the system).

-Running make test (or just running the command +Running gomake test (or just running the command gotest) will rebuild the package, including the numbers_test.go file, and then run the TestDouble function. The output "PASS" indicates that all tests passed -- cgit v1.2.3