/Users/crifan/dev/dev_root/gitbook/GitbookTemplate/gitbook_template/common/gitbook_makefile.mk
# ENABLE_COMMIT_GITHUB_IO = false ENABLE_COMMIT_GITHUB_IO = true ifeq ($(ENABLE_COMMIT_GITHUB_IO), true) # if need commit, enable and change to yours path GITHUB_IO_PATH=/Users/crifan/dev/dev_root/github/github.io/crifan.github.io # GITHUB_IO_PATH=/Users/xxx/dev/crifan/crifan.github.io # ENABLE_UPDATE_GITHUB_IO_README = false ENABLE_UPDATE_GITHUB_IO_README = true endif # ENABLE_RSYNC_PROXY = false ENABLE_RSYNC_PROXY = true ifeq ($(ENABLE_RSYNC_PROXY), true) # for rsync use sock5 proxy PROXY_SOCK5 = 127.0.0.1:51837 RSYNC_PROXY = -e "ssh -o 'ProxyCommand nc -X 5 -x $(PROXY_SOCK5) %h %p' -o ServerAliveInterval=30 -o ServerAliveCountMax=5" else # for rsync not use any proxy RSYNC_PROXY = endif
改为:
根据当前用户 是否是我自己:
crifan@licrifandeMacBook-Pro ~/dev/dev_root/gitbook/GitbookTemplate/gitbook_template master whoami crifan
自动开启代理
makefile ifeq or
ifeq ($(GCC_MINOR),4) @echo Supported version else ifeq ($(GCC_MINOR),5) @echo Supported version else @echo Unsupported version endif
可以用else
2) 逻辑或变通实现,同样是上面的两个变量 if( VALUE1 == V1 || VALUE2 == V2 ) {...} 可以用findstring函数做如下变通实现: #如果VALUE1或者VALUE2为V1或V2,则findstring 不会返回空。 ifneq ($(findstring $(VALUE1)$(VALUE2), V1 V2),) do something... endif
ifneq ($(filter on,$(TAG1) $(TAG2)),) LD_FLAGS += -ltestlibrary endif
用:
CURRENT_USER := $(shell whoami) $(info CURRENT_USER=$(CURRENT_USER)) ifeq ($(CURRENT_USER), "crifan") ENABLE_COMMIT_GITHUB_IO = true ENABLE_RSYNC_PROXY = true else ifeq ($(CURRENT_USER), "xxx") ENABLE_COMMIT_GITHUB_IO = true ENABLE_RSYNC_PROXY = true endif $(info ENABLE_COMMIT_GITHUB_IO=$(ENABLE_COMMIT_GITHUB_IO)) $(info ENABLE_RSYNC_PROXY=$(ENABLE_RSYNC_PROXY))
结果:
CURRENT_USER=crifan ENABLE_COMMIT_GITHUB_IO=false ENABLE_RSYNC_PROXY=false
去掉引号
CURRENT_USER := $(shell whoami) $(info CURRENT_USER=$(CURRENT_USER)) ifeq ($(CURRENT_USER), crifan) ENABLE_COMMIT_GITHUB_IO = true ENABLE_RSYNC_PROXY = true else ifeq ($(CURRENT_USER), xxx) ENABLE_COMMIT_GITHUB_IO = true ENABLE_RSYNC_PROXY = true endif
结果
CURRENT_USER=crifan ENABLE_COMMIT_GITHUB_IO=true ENABLE_RSYNC_PROXY=true
可以的。
【总结】
最后代码:
ENABLE_COMMIT_GITHUB_IO = false ENABLE_UPDATE_GITHUB_IO_README = false ENABLE_RSYNC_PROXY = false # default: rsync not use any proxy RSYNC_PROXY = CURRENT_USER := $(shell whoami) $(info CURRENT_USER=$(CURRENT_USER)) ifeq ($(CURRENT_USER), crifan) ENABLE_COMMIT_GITHUB_IO = true # if need commit, enable and change to yours path GITHUB_IO_PATH=/Users/crifan/dev/dev_root/github/github.io/crifan.github.io ENABLE_UPDATE_GITHUB_IO_README = true ENABLE_RSYNC_PROXY = true else ifeq ($(CURRENT_USER), xxx) ENABLE_COMMIT_GITHUB_IO = true ENABLE_UPDATE_GITHUB_IO_README = true # if need commit, enable and change to yours path GITHUB_IO_PATH=/Users/xxx/dev/crifan/crifan.github.io ENABLE_RSYNC_PROXY = true endif $(info ENABLE_COMMIT_GITHUB_IO=$(ENABLE_COMMIT_GITHUB_IO)) $(info ENABLE_RSYNC_PROXY=$(ENABLE_RSYNC_PROXY)) ifeq ($(ENABLE_RSYNC_PROXY), true) # for rsync use sock5 proxy PROXY_SOCK5 = 127.0.0.1:51837 RSYNC_PROXY = -e "ssh -o 'ProxyCommand nc -X 5 -x $(PROXY_SOCK5) %h %p' -o ServerAliveInterval=30 -o ServerAliveCountMax=5" endif 。。。
最新代码详见: