如何访问在Makefile.am文件顶部定义的用户定义变量? [英] How do I access a user defined variable as defined at the top of a Makefile.am file?

查看:122
本文介绍了如何访问在Makefile.am文件顶部定义的用户定义变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,我想按照以下几行做一些事情.对于定义了应如何构建库文件的Makefile.am脚本,我希望能够始终访问通用库名称.例如,假设我希望将库的名称命名为"name",则可以从以下变量开始:

Specifically, I want to do something along the following lines. For a Makefile.am script that defines how a library file should be built, I want to be able to access a common library name throughout. For example, assuming I want the name of the library to be called 'name', I might start with the following variable:

LIBNAME = name

然后我可能会遇到这样的事情:

Then I might have something like this:

lib_LTLIBRARIES = lib$(LIBNAME).la

但是,当我想要执行以下操作时,automake就会开始抱怨:

But then automake starts to complain when I want to do something like the following:

lib$(LIBNAME)_la_SOURCES = file1.cpp file2.cpp
lib$(LIBNAME)_la_LIBADD = ...

是否可以使用其他语法来实现这种目的,这样我就不必乘以重复该库的名称了?

Is anything like this possible using some other syntax so that I don't have to multiply repeat the name of the library?

干杯

本.

推荐答案

如果您在configure时间而不是在Makefile本身中定义变量,则可以执行此操作.

You can do it if you define your variable at configure time instead of in the Makefile itself.

例如,在configure.ac中:

LIBNAME=name
AC_SUBST(LIBNAME)

然后您可以像这样在Makefile.am中访问它:

Then you can access it in Makefile.am like this:

lib_LTLIBRARIES = lib@LIBNAME@.la

这篇关于如何访问在Makefile.am文件顶部定义的用户定义变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆