[关闭]
@cyysu 2017-10-16T09:58:34.000000Z 字数 1289 阅读 869

Makefile-基础篇(四)

  • 时间:2017年10月16日
  • 作者:Kali
  • 邮箱:cyysu.github.io@gmail.com
  • 版本:3.0
  • 描述:Makefile-基础四,为Linux 4.4 Makefile中所遇到的知识点汇总

Makefile系列教程


前期准备

  1. # makefile引用其他makefile中的变量,来看下面的例子
  2. mj@DZ:~/桌面$ cat test/test.mk
  3. SIGNAL = $(shell printf "\033[34;1m★\033[0m")
  4. build=stringStrip
  5. mj@DZ:~/桌面$ cat Makefile
  6. SIGNAL = $(shell printf "\033[34;1m★\033[0m")
  7. build=string
  8. build2=Strip
  9. PHONY := _all
  10. include ./test/test.mk
  11. xxx=$(build)
  12. _all:
  13. _all: $(xxx)
  14. string: ;$(info $(SIGNAL) build $@ goal)
  15. @echo "前:" $(string1)
  16. @echo "后:" $(string2)
  17. stringStrip: ;$(info $(SIGNAL) build $@ goal)
  18. @echo "前:" $(stringStrip1)
  19. @echo "后:" $(stringStrip2)
  20. stringWord:
  21. @echo "前:" $(stringword1)
  22. @echo "中:" $(stringword2)
  23. @echo "后:" $(stringword3)
  24. getMakefile:
  25. @echo "当前Makefile有:" $(MAKEFILE_LIST)
  26. @echo $(MAKEFILE_LIST) | cut -d " " -f 1
  27. @echo $(MAKEFILE_LIST) | cut -d " " -f 2
  28. # 执行结果
  29. mj@DZ:~/桌面$ make
  30. build stringStrip goal
  31. 前:
  32. 后:
  33. mj@DZ:~/桌面$
  34. # 然后我们在看一下用 = 号来连接字符串的例子
  35. mj@DZ:~/桌面$ cat Makefile
  36. SIGNAL = $(shell printf "\033[34;1m★\033[0m")
  37. build=string
  38. build2=Strip
  39. PHONY := _all
  40. xxx=$(build)=$(build2)
  41. _all:
  42. _all: $(xxx)
  43. # 运行结果,可以看我我们的目标文件中间加上了 = 号
  44. mj@DZ:~/桌面$ make
  45. Makefile:14: warning: overriding recipe for target '_all'
  46. Makefile:11: warning: ignoring old recipe for target '_all'
  47. make: *** No rule to make target 'string=Strip', needed by '_all' 停止。

这里我建议上面出现的知识点自己最好亲自操作一下,记得要温习这个知识点
这里我建议上面出现的知识点自己最好亲自操作一下,记得要温习这个知识点
这里我建议上面出现的知识点自己最好亲自操作一下,记得要温习这个知识点

打赏

                    支付宝                                                         微信

微信与支付宝支付

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注