文章目录
Makefile文件
PREFIX=/usr/local
BINDIR=${PREFIX}/bin
DESTDIR=
BLDDIR = build
BLDFLAGS=
EXT=
ifeq (${GOOS},windows)
EXT=.exe
endif
APPS = nsqd nsqlookupd nsqadmin nsq_to_nsq nsq_to_file nsq_to_http nsq_tail nsq_stat to_nsq
all: $(APPS)
$(BLDDIR)/nsqd: $(wildcard apps/nsqd/*.go nsqd/*.go nsq/*.go internal/*/*.go)
$(BLDDIR)/nsqlookupd: $(wildcard apps/nsqlookupd/*.go nsqlookupd/*.go nsq/*.go internal/*/*.go)
$(BLDDIR)/nsqadmin: $(wildcard apps/nsqadmin/*.go nsqadmin/*.go nsqadmin/templates/*.go internal/*/*.go)
$(BLDDIR)/nsq_to_nsq: $(wildcard apps/nsq_to_nsq/*.go nsq/*.go internal/*/*.go)
$(BLDDIR)/nsq_to_file: $(wildcard apps/nsq_to_file/*.go nsq/*.go internal/*/*.go)
$(BLDDIR)/nsq_to_http: $(wildcard apps/nsq_to_http/*.go nsq/*.go internal/*/*.go)
$(BLDDIR)/nsq_tail: $(wildcard apps/nsq_tail/*.go nsq/*.go internal/*/*.go)
$(BLDDIR)/nsq_stat: $(wildcard apps/nsq_stat/*.go internal/*/*.go)
$(BLDDIR)/to_nsq: $(wildcard apps/to_nsq/*.go internal/*/*.go)
$(BLDDIR)/%:
@mkdir -p $(dir $@)
go build ${BLDFLAGS} -o $@ ./apps/$*
$(APPS): %: $(BLDDIR)/%
clean:
rm -fr $(BLDDIR)
.PHONY: install clean all
.PHONY: $(APPS)
install: $(APPS)
install -m 755 -d ${DESTDIR}${BINDIR}
for APP in $^ ; do install -m 755 ${BLDDIR}/$$APP ${DESTDIR}${BINDIR}/$$APP${EXT} ; done
在此文件中包含命令有
make all
此命令用作构建nsq项目的所有可执行文件,执行以下子命令
make nsqd
make nsqlookupd
make nsqadmin
make nsq_to_nsq
make nsq_to_file
make nsq_to_http
make nsq_tail
make nsq_stat
make to_nsq
# 以下是所有子命令的运行命令
mkdir -p build
go build -o build/nsqd ./apps/nsqd
go build -o build/nsqlookupd ./apps/nsqlookupd
go build -o build/nsqadmin ./apps/nsqadmin
go build -o build/nsq_to_nsq ./apps/nsq_to_nsq
go build -o build/nsq_to_file ./apps/nsq_to_file
go build -o build/nsq_to_http ./apps/nsq_to_http
go build -o build/nsq_tail ./apps/nsq_tail
go build -o build/nsq_stat ./apps/nsq_stat
go build -o build/to_nsq ./apps/to_nsq
make install
此命令需root权限运行,用于nsq项目的安装部署操作,执行此命令时会自动执行make all
命令,将可执行文件存放到./build
目录下,此命令会给/usr/local/bin
755权限,若目录不存在则创建,后面会执行install -m 755 build/$APP /usr/local/bin/$APP
命令,安装到/usr/local/bin/
目录,赋予755权限,命令执行完后,终端可以使用nsqd nsqlookupd nsqadmin nsq_to_nsq nsq_to_file nsq_to_http nsq_tail nsq_stat to_nsq
任一命令make clean
清理nsq项目构建的可执行文件,子命令rm -fr build
make nsqd
构建nsqd可执行文件make nsqlookupd
构建nsqlookupd可执行文件make nsqadmin
构建nsqadmin可执行文件make nsq_to_nsq
构建nsq_to_nsq可执行文件make nsq_to_file
构建nsq_to_file可执行文件make nsq_to_http
构建nsq_to_http可执行文件make nsq_tail
构建nsq_tail可执行文件make nsq_stat
构建nsq_stat可执行文件make to_nsq
构建to_nsq可执行文件
收获
此文件告诉我们nsq项目的所有入口文件对应的位置
- nsqd的入口文件在
./apps/nsqd
下即./apps/nsqd/main.go
- nsqlookupd的入口文件在
./apps/nsqlookupd
下即./apps/nsqlookupd/main.go
- nsqadmin的入口文件在
./apps/nsqadmin
下即./apps/nsqadmin/main.go
- nsq_to_nsq的入口文件在
./apps/nsq_to_nsq
下即./apps/nsq_to_nsq/nsq_to_nsq.go
- nsq_to_file的入口文件在
./apps/nsq_to_file
下即./apps/nsq_to_file/nsq_to_file.go
- nsq_to_http的入口文件在
./apps/nsq_to_http
下即./apps/nsq_to_http/nsq_to_http.go
- nsq_tail的入口文件在
./apps/nsq_tail
下即./apps/nsq_tail/nsq_tail.go
- nsq_stat的入口文件在
./apps/nsq_stat
下即./apps/nsq_stat/nsq_stat.go
- to_nsq的入口文件在
./apps/to_nsq
下即./apps/to_nsq/to_nsq.go