Always Get Better

Archive for the ‘Go Language’ Category

A Simple Makefile for the Go Language

Tuesday, January 19th, 2010

Hey folks, it’s been awhile!

I’ve been playing with Google’s Go language, and will be sharing what I’ve learned over the coming weeks.

First off, which seems like the easier way to compile your source code? This:

6g fib.go
6l fib.6
mv 6.out fib

or this?


Personally, I prefer using a Makefile, even for a small project with one source file.

Without further adieu, a simple Makefile for the Go Language:

GC = 6g
LD = 6l
TARG = fib

O_FILES = fib.6

make clean
make $(TARG)

$(LD) -o $@ $(O_FILES)
@echo "Done. Executable is: $@"

$(O_FILES): %.6: %.go
$(GC) -c $<

rm -rf *.[$(OS)o] *.a [$(OS)].out _obj $(TARG) *.6