我正在使用自动工具来构建我的项目,并且我想将 AM_CPPFLAGS 全局设置为 -I$(top_srcdir)/include。
https://stackoverflow.com/a/325436/2592351这个答案帮助了我,我正在做“include $(top_srcdir)/include” hack,它可以工作。
但是我想做那里描述的“AC_SUBST”方式,因为它看起来更干净。问题是当我将它添加到我的 configure.ac 时:
AC_SUBST([AM_CPPFLAGS], [-I$(top_srcdir)/include])
然后 $(top_srcdir) 扩展得太快,我得到 AM_CPPFLAGS = -I/include in subdir/Makefile{,.in}。
而且我不知道如何逃脱它。
-I@top_srcdir@/include
-I\$(top_srcdir)/include
-I$$(top_srcdir)/include
由于各种原因,所有这些都失败了。
请帮忙。我应该如何编写 AC_SUBST 以便 $(top_srcdir) 在到达 Makefile{,.in} 之前不会被转义?或者也许我应该使用 AC_SUBST 以外的东西?