1dnl Copyright (c) 2005, Regents of the University of California
2AC_INIT(xblas, 1.0, extended_blas@cs.berkeley.edu)
3AC_PREREQ(2.59)
4AC_CONFIG_SRCDIR(src/blas_extended.h)
5AC_CONFIG_AUX_DIR(config)
6
7AC_CANONICAL_TARGET
8
9AC_PROG_CC
10
11CC_BASE=`basename $CC`
12case $target in
13  powerpc*)
14    case "$CC_BASE" in
15      cc* | xlc* | c99 | c89 )
16        save_CFLAGS="$CFLAGS"
17        CFLAGS="$CFLAGS -qstrict"
18        AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [], [CFLAGS="$save_CFLAGS"])
19      ;;
20    esac
21  ;;
22  i?86-*-* | k?*-*-* | athlon-*-* | ia64-*-* | x86_64-*-*)
23    case "$CC_BASE" in
24      icc | ecc)
25        save_CFLAGS="$CFLAGS"
26        CFLAGS="$CFLAGS -mp"
27        AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [], [CFLAGS="$save_CFLAGS"])
28      ;;
29    esac
30  ;;
31esac
32
33AC_PROG_RANLIB
34
35AC_ARG_ENABLE([fortran], AC_HELP_STRING(--enable-fortran,
36    [build Fortran wrapper.  [[default=auto]]]))
37if test "x$enable_fortran" = "x"; then
38  enable_fortran="auto"
39fi
40
41if test "x$enable_fortran" != "xno"; then
42  AC_PROG_FC([], [Fortran 77])
43  if test "x$FC" = "x"; then
44    enable_fortran="no"
45  else
46    enable_fortran="yes"
47    # Set appropriate C preprocessor definitions based on name mangling scheme.
48    AC_FC_FUNC(f_func)
49    case "$f_func" in
50      f_func_)
51        CFLAGS="$CFLAGS -DCONFIG_FC_UNDERSCORE"
52      ;;
53      f_func__)
54        CFLAGS="$CFLAGS -DCONFIG_FC_DBL_UNDERSCORE"
55      ;;
56      F_FUNC_)
57        CFLAGS="$CFLAGS -DCONFIG_FC_UCASE -DCONFIG_FC_UNDERSCORE"
58      ;;
59      F_FUNC__)
60        CFLAGS="$CFLAGS -DCONFIG_FC_UCASE -DCONFIG_FC_DBL_UNDERSCORE"
61      ;;
62      F_FUNC)
63        CFLAGS="$CFLAGS -DCONFIG_FC_UCASE"
64      ;;
65      f_func) ;;
66      *)
67        AC_ERROR([Could not figure out Fortran name mangling scheme.])
68      ;;
69    esac
70
71    # If --enable-xerbla is specified we need to link in Fortran libraries
72    AC_ARG_ENABLE(xerbla, AC_HELP_STRING(--enable-xerbla, [use LAPACK's xerbla in BLAS_error.  [[default=no]]]))
73    AC_ARG_VAR(EXTRA_LIBS, [Extra libraries used for linking Fortran libraries with C programs])
74    if test "x$enable_xerbla" = "xyes"; then
75      CFLAGS="$CFLAGS -DCONFIG_USE_XERBLA"
76      if test "x$FC_DUMMY_MAIN" != "xnone"; then
77        CFLAGS="$CFLAGS -DFC_DUMMY_MAIN=$FC_DUMMY_MAIN"
78      fi
79      EXTRA_LIBS="$EXTRA_LIBS $FCLIBS"
80    fi
81  fi
82fi
83
84x86_fix="no"
85case "$target" in
86  i?86-*-* | k?*-*-* | athlon-*-* | x86_64-*-*)
87    AC_CHECK_HEADER([fpu_control.h], [CFLAGS="$CFLAGS -DHAVE_FPU_CONTROL_H"])
88  ;;
89esac
90
91AC_MSG_CHECKING([whether x86 FPU control code is needed])
92x86_fix="no"
93case "$target" in
94  i?86-*-* | k?*-*-* | athlon-*-* | x86_64-*-*)
95    CFLAGS="$CFLAGS -Dx86"
96    x86_fix="yes"
97  ;;
98esac
99AC_MSG_RESULT($x86_fix)
100
101# Check for m4
102AC_ARG_VAR(M4, [M4 program])
103AC_CHECK_PROG(M4, [m4], [m4])
104if test "x$M4" = "x"; then
105  AC_ERROR([M4 not found])
106fi
107
108# Non-GNU m4 require expanded buffer size
109# Detect GNU m4 by its behaviour on __gnu__.
110dnl Note we need to quote __gnu__ since autoconf goes through GNU m4.
111AC_ARG_VAR(M4_OPTS, [Flags to pass to M4])
112AC_MSG_CHECKING([whether we are using GNU m4])
113tmp=`echo [__gnu__] | $M4 -`
114if test "x$tmp" != "x"; then
115  M4_OPTS="$M4_OPTS -B65536"
116  AC_MSG_RESULT([no])
117else
118  AC_MSG_RESULT([yes])
119fi
120
121# Check for indent.  If none found, use : (do nothing).
122AC_ARG_VAR(INDENT, [Indent program])
123AC_ARG_VAR(INDENT_OPTS, [Flags to pass to indent])
124AC_CHECK_PROG(INDENT, [indent], [indent], [:])
125if test "x$INDENT_OPTS" == "x" && test "$INDENT" != ":"; then
126  INDENT_OPTS="-ce -i2 -nfc1 -br -brs -cs -npcs -nprs -npsl"
127  cat >conftest.c <<EOF
128int main() { }
129EOF
130  $INDENT $INDENT_OPTS conftest.c || INDENT_OPTS=""
131  rm -f conftest.c
132fi
133
134AC_ARG_ENABLE([plain-blas],
135  AC_HELP_STRING(--enable-plain-blas,
136    [build plain (no extended or mixed precision) BLAS.  [[default=yes]]]))
137if test "x$enable_plain_blas" = "xno"; then
138  M4_OPTS="$M4_OPTS -D no_plain_blas"
139fi
140
141if test "x$enable_fortran" = "xno"; then
142  M4_OPTS="$M4_OPTS -D no_f2c"
143fi
144
145EXTRA_LIBS="$EXTRA_LIBS -lm"
146
147AC_CONFIG_COMMANDS([gen_makefile],
148                   [$M4 $M4_OPTS Makefile.m4 >Makefile], [M4=$M4; M4_OPTS="$M4_OPTS"])
149
150AC_SUBST(EXTRA_LIBS, $EXTRA_LIBS)
151AC_CONFIG_FILES([make.inc])
152AC_OUTPUT
153
154