build-sys: add stuff for $ARCH
authorKarel Zak <kzak@redhat.com>
Wed, 27 Feb 2013 11:39:21 +0000 (12:39 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 1 Mar 2013 09:32:36 +0000 (10:32 +0100)
 - add m4/arch.m4 to setup ARCH_<NAME> automake conditionals
 - use "if ARCH_<NAME>" in build system rather than make ifeq

Signed-off-by: Karel Zak <kzak@redhat.com>
.gitignore
Makefile.am
configure.ac
m4/arch.m4 [new file with mode: 0644]

index 715cdae..cb47f30 100644 (file)
@@ -31,3 +31,6 @@ compile
 depcomp
 install-sh
 missing
+
+# wanted files
+!m4/arch.m4
index 0636cd3..e0de815 100644 (file)
@@ -23,5 +23,5 @@ AM_CPPFLAGS = -include config.h
 AM_CFLAGS =
 AM_LDFLAGS =
 
-
 EXTRA_DIST = autogen.sh README LICENSE
+
index 2d05338..c31780e 100644 (file)
@@ -42,6 +42,23 @@ AC_PROG_GCC_TRADITIONAL
 AC_PROG_MKDIR_P
 AC_PATH_PROG([XSLTPROC], [xsltproc])
 
+dnl Define ARCH_<NAME> conditionals
+SET_ARCH(I686, i686*)
+SET_ARCH(X86_64, x86_64*)
+SET_ARCH(IA64, ia64*)
+
+ARCH=`echo $host | sed "s/\(-\).*$//"`
+
+AM_COND_IF(ARCH_I686, [
+       ARCH=ia32
+       MACHINE_TYPE_NAME=ia32])
+
+AM_COND_IF(ARCH_X86_64, [
+       MACHINE_TYPE_NAME=x64])
+
+AC_SUBST([ARCH])
+AC_SUBST([MACHINE_TYPE_NAME])
+
 # ------------------------------------------------------------------------------
 AC_ARG_ENABLE(blkid, AS_HELP_STRING([--disable-blkid], [disable blkid support]))
 if test "x$enable_blkid" != "xno"; then
@@ -63,6 +80,9 @@ AC_OUTPUT
 AC_MSG_RESULT([
         $PACKAGE_NAME $VERSION
 
+        arch:                    $ARCH
+        machine type:            $MACHINE_TYPE_NAME
+
         prefix:                  ${prefix}
         libdir:                  ${libdir}
 
diff --git a/m4/arch.m4 b/m4/arch.m4
new file mode 100644 (file)
index 0000000..f17b427
--- /dev/null
@@ -0,0 +1,13 @@
+
+dnl SET_ARCH(ARCHNAME, PATTERN)
+dnl
+dnl Define ARCH_<archname> condition if the pattern match with the current
+dnl architecture
+dnl
+AC_DEFUN([SET_ARCH], [
+  cpu_$1=false
+  case "$host" in
+   $2) cpu_$1=true ;;
+  esac
+  AM_CONDITIONAL(AS_TR_CPP(ARCH_$1), [test "x$cpu_$1" = xtrue])
+])