免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2129 | 回复: 2
打印 上一主题 下一主题

[其他] [makefile]GNU-make-mannul-chapter8.9, LINK.o是什么变量? [复制链接]

论坛徽章:
20
程序设计版块每日发帖之星
日期:2015-08-17 06:20:00程序设计版块每日发帖之星
日期:2016-07-16 06:20:00程序设计版块每日发帖之星
日期:2016-07-18 06:20:00每日论坛发贴之星
日期:2016-07-18 06:20:00黑曼巴
日期:2016-12-26 16:00:3215-16赛季CBA联赛之江苏
日期:2017-06-26 11:05:5615-16赛季CBA联赛之上海
日期:2017-07-21 18:12:5015-16赛季CBA联赛之青岛
日期:2017-09-04 17:32:0515-16赛季CBA联赛之吉林
日期:2018-03-26 10:02:16程序设计版块每日发帖之星
日期:2016-07-15 06:20:0015-16赛季CBA联赛之江苏
日期:2016-07-07 18:37:512015亚冠之萨济拖拉机
日期:2015-08-17 12:21:08
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-08-04 15:45 |只看该作者 |倒序浏览
本帖最后由 nswcfd 于 2015-08-04 15:52 编辑

http://www.gnu.org/software/make/manual/make.html#Eval-Function
页面加载时间较长,请耐心等待。在页面中搜索8.9即可。

8.9节介绍eval函数,其中加粗的部分,$(LINK.o)是什么?

此外,PROGRAM_template展开后,变成了
server: $(server_OBJS) $(server_LIBS:%=-l%)
斜体部分怎么理解?server依赖于-lpriv -lprotocol?感觉template的定义不完整?
  1. PROGRAMS    = server client

  2. server_OBJS = server.o server_priv.o server_access.o
  3. server_LIBS = priv protocol

  4. client_OBJS = client.o client_api.o client_mem.o
  5. client_LIBS = protocol

  6. # Everything after this is generic

  7. .PHONY: all
  8. all: $(PROGRAMS)

  9. define PROGRAM_template =
  10. $(1): $($(1)_OBJS) $($(1)_LIBS:%=-l%)     ############## server_LIBS/client_LIBS 这里替换为-l是什么意思?
  11. ALL_OBJS   += $($(1)_OBJS)
  12. endef

  13. $(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog))))

  14. $(PROGRAMS):
  15.        $(LINK.o) $^ $(LDLIBS) -o $@        ################### 这里的LINK.o是什么预定义的变量?

  16. clean:
  17.         rm -f $(ALL_OBJS) $(PROGRAMS)
复制代码

论坛徽章:
20
程序设计版块每日发帖之星
日期:2015-08-17 06:20:00程序设计版块每日发帖之星
日期:2016-07-16 06:20:00程序设计版块每日发帖之星
日期:2016-07-18 06:20:00每日论坛发贴之星
日期:2016-07-18 06:20:00黑曼巴
日期:2016-12-26 16:00:3215-16赛季CBA联赛之江苏
日期:2017-06-26 11:05:5615-16赛季CBA联赛之上海
日期:2017-07-21 18:12:5015-16赛季CBA联赛之青岛
日期:2017-09-04 17:32:0515-16赛季CBA联赛之吉林
日期:2018-03-26 10:02:16程序设计版块每日发帖之星
日期:2016-07-15 06:20:0015-16赛季CBA联赛之江苏
日期:2016-07-07 18:37:512015亚冠之萨济拖拉机
日期:2015-08-17 12:21:08
2 [报告]
发表于 2015-08-04 16:19 |只看该作者
第一个问题,明白了,4.5.6
4.5.6 Directory Search for Link Libraries

Directory search applies in a special way to libraries used with the linker. This special feature comes into play when you write a prerequisite whose name is of the form ‘-lname’. (You can tell something strange is going on here because the prerequisite is normally the name of a file, and the file name of a library generally looks like libname.a, not like ‘-lname’.)

When a prerequisite’s name has the form ‘-lname’, make handles it specially by searching for the file libname.so, and, if it is not found, for the file libname.a in the current directory, in directories specified by matching vpath search paths and the VPATH search path, and then in the directories /lib, /usr/lib, and prefix/lib (normally /usr/local/lib, but MS-DOS/MS-Windows versions of make behave as if prefix is defined to be the root of the DJGPP installation tree).

第二个问题,据实测,LINK.o的值就是CC的值,但是没有在文档中找到依据。

论坛徽章:
20
程序设计版块每日发帖之星
日期:2015-08-17 06:20:00程序设计版块每日发帖之星
日期:2016-07-16 06:20:00程序设计版块每日发帖之星
日期:2016-07-18 06:20:00每日论坛发贴之星
日期:2016-07-18 06:20:00黑曼巴
日期:2016-12-26 16:00:3215-16赛季CBA联赛之江苏
日期:2017-06-26 11:05:5615-16赛季CBA联赛之上海
日期:2017-07-21 18:12:5015-16赛季CBA联赛之青岛
日期:2017-09-04 17:32:0515-16赛季CBA联赛之吉林
日期:2018-03-26 10:02:16程序设计版块每日发帖之星
日期:2016-07-15 06:20:0015-16赛季CBA联赛之江苏
日期:2016-07-07 18:37:512015亚冠之萨济拖拉机
日期:2015-08-17 12:21:08
3 [报告]
发表于 2015-08-04 16:31 |只看该作者
找到了,10.2 Catalogue of Built-In Rules

However, the recipes in built-in implicit rules actually use variables such as COMPILE.c, LINK.p, and PREPROCESS.S, whose values contain the recipes listed above.

make follows the convention that the rule to compile a .x source file uses the variable COMPILE.x. Similarly, the rule to produce an executable from a .x file uses LINK.x; and the rule to preprocess a .x file uses PREPROCESS.x.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP