Visar inlägg med etikett Go Lang. Visa alla inlägg
Visar inlägg med etikett Go Lang. Visa alla inlägg

söndag 18 december 2011

Generic Makefile for Go

If you want to have a directory with alot of Go files for testing you can use this Makefile.

# Generic Makefile for GO
ifeq ($(GOARCH),386)
O:=8
else
O:=6
endif

GC=${O}g
LD=${O}l

GO_FILES = $(wildcard *.go)
GO_PRGS = $(basename $(GO_FILES))
GO_OBJS = $(addsuffix .$O, $(GO_PRGS))

all: $(GO_PRGS)

$(GO_PRGS): $(GO_OBJS)
        $(LD) -o $@ $@.$O;

$(GO_OBJS): %.$O: %.go
        $(GC) $<
 

clean:
        rm $(GO_OBJS) $(GO_PRGS)