Autoconf book(4) AM_CONDITIONAL
ARG1: the name of a conditional ,
ARG2: a shell statement that is used to determine whether the conditional should be true or false.
If the shell code returns a successful status, then the conditional will be true. Any conditional in your `configure.in' is automatically available for use in any `Makefile.am' in that project.
http://ps-buaa.spaces.live.com/blog/cns!ACFF11BFA33D6971!180.entry
本人移植mount,在powerpc交叉编译时,用到的blkid库,需要到/home/user-name/ltib/rootfs/lib路径下查找。为了不改动源代码,这个问题如何解决呢?我找到了方法如下:
在整个工程的configure.in文件中加入如下代码,即在所有Makefile中引入条件变量MY_CROSS_COMPILE:
#configure.in
if test x$CC = xgcc; then
AC_MSG_WARN($BLKID --------------------------------------) #message only for test
AM_CONDITIONAL(MY_CROSS_COMPILE,false)
else
AC_MSG_WARN($BLKID +++++++++++++++++++++) #message only for test
AM_CONDITIONAL(MY_CROSS_COMPILE,true)
fi
在需要blkid库的Makefile.am文件中
if MY_CROSS_COMPILE #(目标机交叉编译)
AM_CPPFLAGS = -include $(top_builddir)/config.h -I ../include /
-DLOCALEDIR=/"$(localedir)/" -I /home/user-name/ltib/rootfs/usr/include
AM_CFLAGS = -fsigned-char -I /home/user-name/ltib/rootfs/usr/include
else #(PC机编译)
AM_CPPFLAGS = -include $(top_builddir)/config.h -I ../include /
-DLOCALEDIR=/"$(localedir)/"
AM_CFLAGS = -fsigned-char
endif
lib_mount_la_LIBADD = $(LDADD_common)
LDADD_common =
if MY_CROSS_COMPILE #(目标机交叉编译)
LDADD_common += -L$(LTIB_PATH)/rootfs/usr/lib -lblkid -luuid
else #(PC机编译)
LDADD_common += -lblkid -luuid
endif