使用Automake确定Makefile.am中的体系结构 [英] Determining Architecture In Makefile.am using Automake

查看:123
本文介绍了使用Automake确定Makefile.am中的体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要查看我要执行的操作,请参见以下内容:

To see what I am trying to do see below:

我的问题是如何有条件地设置AM_CPPFLAGS或 我的Makefile.am中的my_lib_la_CPPFLAGS.这样在配置时 是设置了正确的CPPFLAGS吗?

My question is how can I conditionally set AM_CPPFLAGS or my_lib_la_CPPFLAGS inside of my Makefile.am. Such that when configure is run the right CPPFLAGS are set?

目前,我正在做一些影响以下事情的事情:

Currently I am doing something to the affect of:

lib_xml_wrapper_la_CPPFLAGS = -I../../

UNAME_S = $(shell uname -s)   
UNAME_P = $(shell uname -p)   
ifeq ($(UNAME_S),Linux)       
    lib_xml_wrapper_la_CPPFLAGS += -DLINUX
    ifeq ($(UNAME_P),x86_64)  
        lib_xml_wrapper_la_CPPFLAGS += -D AMD64
    endif
    ifeq ($(UNAME_P),x86_64)  
        lib_xml_wrapper_la_CPPFLAGS += -I../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include/
    endif
    ifneq ($(filter %86,$(UNAME_P)),)
        lib_xml_wrapper_la_CPPFLAGS += -I../../../external/xerces-c-3.1.1-x86-linux-gcc-3.4/include/
    endif
    ifneq ($(filter arm%,$(UNAME_P)),)
        lib_xml_wrapper_la_CPPFLAGS += 
    endif
endif
ifeq ($(UNAME_S),Darwin)
    lib_xml_wrapper_la_CPPFLAGS += -DOSX
    ifneq ($(filter %86,$(UNAME_P)),)
        lib_xml_wrapper_la_CPPFLAGS += -I../../../external/xerces-c-3.1.1-x86-macosx-gcc-3.4/include/
    endif
    ifneq ($(filter arm%,$(UNAME_P)),)
        lib_xml_wrapper_la_CPPFLAGS += 
    endif
endif

这在Makefile.am中似乎不起作用.我收到以下错误:

This does not seem to work in Makefile.am. I am getting the following errors:

xml_wrapper/Makefile.am:26: error: endif without if
xml_wrapper/Makefile.am:35: error: endif without if
automake: warnings are treated as errors
xml_wrapper/Makefile.am:10: warning: shell uname -s: non-POSIX variable name
xml_wrapper/Makefile.am:10: (probably a GNU make extension)
xml_wrapper/Makefile.am:11: warning: shell uname -p: non-POSIX variable name
xml_wrapper/Makefile.am:11: (probably a GNU make extension)
xml_wrapper/Makefile.am:20: warning: filter %86,$(UNAME_P: non-POSIX variable name
xml_wrapper/Makefile.am:20: (probably a GNU make extension)
xml_wrapper/Makefile.am:23: warning: filter arm%,$(UNAME_P: non-POSIX variable name
xml_wrapper/Makefile.am:23: (probably a GNU make extension)
xml_wrapper/Makefile.am:29: warning: filter %86,$(UNAME_P: non-POSIX variable name
xml_wrapper/Makefile.am:29: (probably a GNU make extension)
xml_wrapper/Makefile.am:32: warning: filter arm%,$(UNAME_P: non-POSIX variable name
xml_wrapper/Makefile.am:32: (probably a GNU make extension)

推荐答案

configure.ac中更好地选择了CPU和OS,该软件具有AC_CANONICAL_HOST可以解析uname的输出并将其以标准格式进行处理:

Selecting the CPU and OS is better handled in configure.ac, which has AC_CANONICAL_HOST which parses the output from uname and puts it in a standard format:

configure.ac

...
AC_CANONICAL_HOST
WRAPPER_CPPFLAGS=""
AS_CASE([$host_os],
        [linux*],
        [
           WRAPPER_CPPFLAGS="$WRAPPER_CPPFLAGS -DLINUX"
           AS_CASE([$host_cpu],
                   [x86_64],
                   [
                       WRAPPER_CPPFLAGS="$WRAPPER_CPPFLAGS -DAMD64 -I../../../external/xerces-c-3.1.1-x86_64-linux-gcc-3.4/include"
                   ],
                   [i?86],
                   [
                       WRAPPER_CPPFLAGS="$WRAPPER_CPPFLAGS -I../../../external/xerces-c-3.1.1-x86-linux-gcc-3.4/include"
                   ])
        ],
        [darwin*],
        [
           WRAPPER_CPPFLAGS="$WRAPPER_CPPFLAGS -DOSX"
           AS_CASE([$host_cpu],
                   [i?86],
                   [
                       WRAPPER_CPPFLAGS="$WRAPPER_CPPFLAGS -I../../../external/xerces-c-3.1.1-x86-macosx-gcc-3.4/include"
                   ])
        ])
AC_SUBST([WRAPPER_CPPFLAGS])

Makefile.am

...
lib_xml_wrapper_la_CPPFLAGS = -I../.. $(WRAPPER_CPPFLAGS)

这篇关于使用Automake确定Makefile.am中的体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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