linux – 如何使用automake检查 *** 作系统

linux – 如何使用automake检查 *** 作系统,第1张

概述我有一个项目,使用automake创建配置和所有相关文件(我使用autoreconf命令来制作所有这些东西).因此,我正在尝试设置一些条件文件,以便在项目编译macOS(OS X), Windows或 Linux时进行编译.但它失败了以下内容: $autoreconf -i ..src/Makefile.am:30: error: LINUX does not appear in AM_COND 我有一个项目,使用automake创建配置和所有相关文件(我使用autoreconf命令来制作所有这些东西).因此,我正在尝试设置一些条件文件,以便在项目编译macOS(OS X),Windows或 Linux时进行编译.但它失败了以下内容:
$autoreconf -i ..src/Makefile.am:30: error: liNUX does not appear in AM_CONDITIONALautoreconf: automake Failed with exit status: 1

包含Makefile.am中的错误的部分如下:

if OSX    butt_SOURCES += CurrentTrackOSX.h CurrentTrackOSX.mendifif liNUX    butt_SOURCES += currentTrack.h currentTracklinux.cppendifif windows    butt_SOURCES += currentTrack.h currentTrack.cppendif

我的问题是,如何检查 *** 作系统是否为linux?如果有可能,有没有更好的方法来检查automake中的 *** 作系统?

解决方法 您可以检测它 directly in the Makefile,或者在配置源文件(可能是configure.ac)中定义条件,因为您使用的是autoreconf:
# AC_CANONICAL_HOST is needed to access the 'host_os' variable    AC_CANONICAL_HOSTbuild_linux=nobuild_windows=nobuild_mac=no# Detect the target systemcase "${host_os}" in    linux*)        build_linux=yes        ;;    cygwin*|mingw*)        build_windows=yes        ;;    darwin*)        build_mac=yes        ;;    *)        AC_MSG_ERROR(["OS $host_os is not supported"])        ;;esac# Pass the conditionals to automakeAM_CONDITIONAL([liNUX],[test "$build_linux" = "yes"])AM_CONDITIONAL([windows],[test "$build_windows" = "yes"])AM_CONDITIONAL([OSX],[test "$build_mac" = "yes"])

Note: host_os refers to the target system,so if you are cross-compiling it sets the OS conditional of the system you are compiling to.

总结

以上是内存溢出为你收集整理的linux – 如何使用automake检查 *** 作系统全部内容,希望文章能够帮你解决linux – 如何使用automake检查 *** 作系统所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1050071.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存