golang 也需要用到makefile,用makefile編譯生成一個可執行檔案然後執行
TARGET = apibin
SRCS = $(wildcard *.go)
ALLSRCS = $(wildcard *.go ./apis/*.go ./config/*.go ./muduo/*.go ./resources/*.go ./utils/*.go)
VERSION = 0.0.1
BUILDTIME = `date +%FT%T%z`
LDFLAGS = -ldflags "-X main.version=${VERSION}"
GCFLAGS = -gcflags "-N -l"
#GCFLAGS =
BINDIR = $(PWD)
GOTAGS := -tags static
.PHONY: clean all
all : $(TARGET)
$(TARGET) : % : $(BINDIR)/%
$(BINDIR)/% : $(ALLSRCS)
go build $(GOTAGS) -v -x $(GCFLAGS) $(LDFLAGS) -o $@ $(SRCS)
clean :
go clean -i
-rm $(BINDIR)/$(TARGET)
好用