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)
好用