/Users/crifan/dev/dev_root/gitbook/GitbookTemplate/gitbook_template/common/gitbook_makefile.mk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # 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 |
改为:
根据当前用户 是否是我自己:
1 2 | crifan@licrifandeMacBook-Pro ~ /dev/dev_root/gitbook/GitbookTemplate/gitbook_template master whoami crifan |
自动开启代理
makefile ifeq or
1 2 3 4 5 6 7 | ifeq ($(GCC_MINOR),4) @ echo Supported version else ifeq ($(GCC_MINOR),5) @ echo Supported version else @ echo Unsupported version endif |
可以用else
1 2 3 4 5 6 | 2) 逻辑或变通实现,同样是上面的两个变量 if ( VALUE1 == V1 || VALUE2 == V2 ) {...} 可以用findstring函数做如下变通实现: #如果VALUE1或者VALUE2为V1或V2,则findstring 不会返回空。 ifneq ($(findstring $(VALUE1)$(VALUE2), V1 V2),) do something... endif |
1 2 3 | ifneq ($(filter on,$(TAG1) $(TAG2)),) LD_FLAGS += -ltestlibrary endif |
用:
1 2 3 4 5 6 7 8 9 10 11 | 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)) |
结果:
1 2 3 | CURRENT_USER = crifan ENABLE_COMMIT_GITHUB_IO = false ENABLE_RSYNC_PROXY = false |
去掉引号
1 2 3 4 5 6 7 8 9 | 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 |
结果
1 2 3 | CURRENT_USER = crifan ENABLE_COMMIT_GITHUB_IO = true ENABLE_RSYNC_PROXY = true |
可以的。
【总结】
最后代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 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 。。。 |
最新代码详见: