]> Cypherpunks repositories - gostls13.git/commitdiff
Documentation: how to write Makefiles for commands.
authorYves Junqueira <yves.junqueira@gmail.com>
Mon, 22 Nov 2010 23:42:04 +0000 (10:42 +1100)
committerAndrew Gerrand <adg@golang.org>
Mon, 22 Nov 2010 23:42:04 +0000 (10:42 +1100)
Fixes #1282.

R=adg
CC=golang-dev
https://golang.org/cl/3152041

doc/code.html

index 8e72d5ace25249ff6bad6105f8def2be0b299905..a5783ce740835f1416b035a5f4a27d76adfc9f7f 100644 (file)
@@ -177,6 +177,32 @@ Writing clean, idiomatic Go code is beyond the scope of this document.
 that topic.
 </p>
 
+<h2 id="Building_programs">Building programs</h2>
+<p>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
+<code>Make.cmd</code> instead of <code>Make.pkg</code>:
+
+<pre>
+include $(GOROOT)/src/Make.inc
+
+TARG=helloworld
+GOFILES=\
+       helloworld.go\
+
+include $(GOROOT)/src/Make.cmd
+</pre>
+
+<p>Running <code>gomake build</code> will compile <code>helloworld.go</code>
+and produce an executable named <code>helloworld</code> in the current
+directory.
+</p>
+
+<p>
+Running <code>gomake install</code> will build <code>helloworld</code> if
+necessary and copy it to the <code>$GOBIN</code> directory
+(<code>$GOROOT/bin/</code> is the default).
+</p>
+
 <h2 id="Testing">Testing</h2>
 
 <p>