From 52c23f300972fefdb7cbc57eadbc524afeea0cf5 Mon Sep 17 00:00:00 2001 From: Yves Junqueira Date: Tue, 23 Nov 2010 10:42:04 +1100 Subject: [PATCH] Documentation: how to write Makefiles for commands. Fixes #1282. R=adg CC=golang-dev https://golang.org/cl/3152041 --- doc/code.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/doc/code.html b/doc/code.html index 8e72d5ace25..a5783ce7408 100644 --- a/doc/code.html +++ b/doc/code.html @@ -177,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 build 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