Browse files

A first attempt to automate the compiler options selection on x86 arc…

…hitecure.
  • Loading branch information...
1 parent 6c625f5 commit 74e934411ef60e156425d77a83b8fb3aa61896f9 @amontefusco amontefusco committed Sep 9, 2012
View
1 Makefile.am
@@ -1,3 +1,4 @@
+ACLOCAL_AMFLAGS=-I build-aux
SUBDIRS = trunk/src/softrock trunk/src/DttSP trunk/src/dspserver \
trunk/src/widget-server trunk/src/server trunk/bin \
View
73 build-aux/ax_check_compile_flag.m4
@@ -0,0 +1,73 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
+#
+# DESCRIPTION
+#
+# Check whether the given FLAG works with the current language's compiler
+# or gives an error. (Warnings, however, are ignored)
+#
+# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+# success/failure.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 2
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+ [AS_VAR_SET(CACHEVAR,[yes])],
+ [AS_VAR_SET(CACHEVAR,[no])])
+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
+
View
150 build-aux/ax_ext.m4
@@ -0,0 +1,150 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_ext.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_EXT
+#
+# DESCRIPTION
+#
+# Find supported SIMD extensions by requesting cpuid. When an SIMD
+# extension is found, the -m"simdextensionname" is added to SIMD_FLAGS
+# (only if compilator support it) (ie : if "sse2" is available "-msse2" is
+# added to SIMD_FLAGS)
+#
+# This macro calls:
+#
+# AC_SUBST(SIMD_FLAGS)
+#
+# And defines:
+#
+# HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3 /
+# HAVE_SSE41 / HAVE_SSE42 / HAVE_AVX
+#
+# LICENSE
+#
+# Copyright (c) 2008 Christophe Tournayre <turn3r@users.sourceforge.net>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 9
+
+AC_DEFUN([AX_EXT],
+[
+ AC_REQUIRE([AX_GCC_X86_CPUID])
+
+ AX_GCC_X86_CPUID(0x00000001)
+ ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3`
+ edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4`
+
+ AC_CACHE_CHECK([whether mmx is supported], [ax_cv_have_mmx_ext],
+ [
+ ax_cv_have_mmx_ext=no
+ if test "$((0x$edx>>23&0x01))" = 1; then
+ ax_cv_have_mmx_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse is supported], [ax_cv_have_sse_ext],
+ [
+ ax_cv_have_sse_ext=no
+ if test "$((0x$edx>>25&0x01))" = 1; then
+ ax_cv_have_sse_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse2 is supported], [ax_cv_have_sse2_ext],
+ [
+ ax_cv_have_sse2_ext=no
+ if test "$((0x$edx>>26&0x01))" = 1; then
+ ax_cv_have_sse2_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
+ [
+ ax_cv_have_sse3_ext=no
+ if test "$((0x$ecx&0x01))" = 1; then
+ ax_cv_have_sse3_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
+ [
+ ax_cv_have_ssse3_ext=no
+ if test "$((0x$ecx>>9&0x01))" = 1; then
+ ax_cv_have_ssse3_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse4.1 is supported], [ax_cv_have_sse41_ext],
+ [
+ ax_cv_have_sse41_ext=no
+ if test "$((0x$ecx>>19&0x01))" = 1; then
+ ax_cv_have_sse41_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse4.2 is supported], [ax_cv_have_sse42_ext],
+ [
+ ax_cv_have_sse42_ext=no
+ if test "$((0x$ecx>>20&0x01))" = 1; then
+ ax_cv_have_sse42_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether avx is supported], [ax_cv_have_avx_ext],
+ [
+ ax_cv_have_avx_ext=no
+ if test "$((0x$ecx>>28&0x01))" = 1; then
+ ax_cv_have_avx_ext=yes
+ fi
+ ])
+
+ if test "$ax_cv_have_mmx_ext" = yes; then
+ AC_DEFINE(HAVE_MMX,, [Support MMX instructions])
+ AX_CHECK_COMPILE_FLAG(-mmmx, SIMD_FLAGS="$SIMD_FLAGS -mmmx", [])
+ fi
+
+ if test "$ax_cv_have_sse_ext" = yes; then
+ AC_DEFINE(HAVE_SSE,, [Support SSE (Streaming SIMD Extensions) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse, SIMD_FLAGS="$SIMD_FLAGS -msse", [])
+ fi
+
+ if test "$ax_cv_have_sse2_ext" = yes; then
+ AC_DEFINE(HAVE_SSE2,, [Support SSE2 (Streaming SIMD Extensions 2) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse2, SIMD_FLAGS="$SIMD_FLAGS -msse2", [])
+ fi
+
+ if test "$ax_cv_have_sse3_ext" = yes; then
+ AC_DEFINE(HAVE_SSE3,, [Support SSE3 (Streaming SIMD Extensions 3) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse3, SIMD_FLAGS="$SIMD_FLAGS -msse3", [])
+ fi
+
+ if test "$ax_cv_have_ssse3_ext" = yes; then
+ AC_DEFINE(HAVE_SSSE3,, [Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])
+ AX_CHECK_COMPILE_FLAG(-mssse3, SIMD_FLAGS="$SIMD_FLAGS -mssse3", [])
+ fi
+
+ if test "$ax_cv_have_sse41_ext" = yes; then
+ AC_DEFINE(HAVE_SSE41,, [Support SSE4.1 (Streaming SIMD Extensions 4.1) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse4.1, SIMD_FLAGS="$SIMD_FLAGS -msse4.1", [])
+ fi
+
+ if test "$ax_cv_have_sse42_ext" = yes; then
+ AC_DEFINE(HAVE_SSE42, 1,[Support SSE4.2 (Streaming SIMD Extensions 4.2) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse4.2, SIMD_FLAGS="$SIMD_FLAGS -msse4.2", [])
+ fi
+
+ if test "$ax_cv_have_avx_ext" = yes; then
+ AC_DEFINE(HAVE_AVX,,[Support AVX (Advanced Vector Extensions) instructions])
+ AX_CHECK_COMPILE_FLAG(-mavx, SIMD_FLAGS="$SIMD_FLAGS -mavx", [])
+ fi
+
+ AC_SUBST(SIMD_FLAGS)
+])
+
View
80 build-aux/ax_gcc_x86_cpuid.m4
@@ -0,0 +1,80 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_GCC_X86_CPUID(OP)
+#
+# DESCRIPTION
+#
+# On Pentium and later x86 processors, with gcc or a compiler that has a
+# compatible syntax for inline assembly instructions, run a small program
+# that executes the cpuid instruction with input OP. This can be used to
+# detect the CPU type.
+#
+# On output, the values of the eax, ebx, ecx, and edx registers are stored
+# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
+# ax_cv_gcc_x86_cpuid_OP.
+#
+# If the cpuid instruction fails (because you are running a
+# cross-compiler, or because you are not using gcc, or because you are on
+# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP
+# is set to the string "unknown".
+#
+# This macro mainly exists to be used in AX_GCC_ARCHFLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2008 Matteo Frigo
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 7
+
+AC_DEFUN([AX_GCC_X86_CPUID],
+[AC_REQUIRE([AC_PROG_CC])
+AC_LANG_PUSH([C])
+AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
+ int op = $1, eax, ebx, ecx, edx;
+ FILE *f;
+ __asm__("cpuid"
+ : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+ : "a" (op));
+ f = fopen("conftest_cpuid", "w"); if (!f) return 1;
+ fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
+ fclose(f);
+ return 0;
+])],
+ [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
+ [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
+ [ax_cv_gcc_x86_cpuid_$1=unknown])])
+AC_LANG_POP([C])
+])
+
View
20 configure.ac
@@ -13,11 +13,16 @@ AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([README])
AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([build-aux])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_MAKE_SET
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+# compiling `client.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac'
+AM_PROG_CC_C_O
# Python checks for pylauncher
AM_PATH_PYTHON([2.5],, [:])
@@ -30,13 +35,19 @@ case $build_cpu in
i686)
AC_MSG_NOTICE([Platform: ix86 32 bit])
+ # checks for platform dependent compiler optimizations
+ AX_EXT
+ AX_CHECK_COMPILE_FLAG(-ffast-math, SIMD_FLAGS="$SIMD_FLAGS -ffast-math", [])
+ AX_CHECK_COMPILE_FLAG(-fopenmp, SIMD_FLAGS="$SIMD_FLAGS -fopenmp", [])
;;
x86_64)
AC_MSG_NOTICE([Platform: ix86 64 bit])
LDFLAGS="$LDFLAGS -L/lib64 -L/usr/lib64"
export LDFLAGS
- AC_MSG_NOTICE([${LDFLAGS}])
+ AC_MSG_NOTICE([${LDFLAGS}])
+ AX_CHECK_COMPILE_FLAG(-ffast-math, SIMD_FLAGS="$SIMD_FLAGS -ffast-math", [])
+ AX_CHECK_COMPILE_FLAG(-fopenmp, SIMD_FLAGS="$SIMD_FLAGS -fopenmp", [])
;;
armv6l)
@@ -51,11 +62,8 @@ case $build_cpu in
esac
-# compiling `client.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac'
-AM_PROG_CC_C_O
-
-# library (in DttSP) used but `RANLIB' is undefined: the usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
-AC_PROG_RANLIB
+dnl # library (in DttSP) used but `RANLIB' is undefined: the usual way to define `RANLIB' is to add `AC_PROG_RANLIB'
+dnl #AC_PROG_RANLIB
#
View
2 trunk/src/DttSP/Makefile.am
@@ -5,7 +5,7 @@
noinst_LIBRARIES = libDttSP.a
-libDttSP_a_CFLAGS = -g -O3 -msse -ffast-math -Wall -Wno-unused-function
+libDttSP_a_CFLAGS = -g -O3 -Wall -Wno-unused-function @SIMD_FLAGS@
# -DPACKAGE_NAME=\"dttsp\" -DPACKAGE_TARNAME=\"dttsp\" -DPACKAGE_VERSION=\"new\" -DPACKAGE_STRING=\"dttsp\ new\" -DPACKAGE_BUGREPORT=\"ab2kt@arrl.net\>\ or\ \<rwmcgwier@gmail.com\" -DPACKAGE=\"dttsp\" -DVERSION=\"new\"
View
4 trunk/src/dspserver/Makefile.am
@@ -4,9 +4,7 @@ bin_PROGRAMS = dspserver
noinst_LIBRARIES = libsdrutil.a
-dspserver_CFLAGS = -O3 -Wall -I$(top_srcdir)/trunk/src/DttSP -Wno-unused-function -ffast-math $(THREAD_DEBUG_CFLAGS)
-#dspserver_CFLAGS = -g -O3 -Wall -I$(top_srcdir)/trunk/src/DttSP -Wno-unused-function -msse -msse3 -ffast-math -march=core2
-
+dspserver_CFLAGS = -O3 -Wall -I$(top_srcdir)/trunk/src/DttSP -Wno-unused-function $(THREAD_DEBUG_CFLAGS) @SIMD_FLAGS@
dspserver_LDADD = ../DttSP/libDttSP.a libsdrutil.a -lrt
View
2 trunk/src/hiqsdr/Makefile.am
@@ -4,7 +4,7 @@ hiqsdr_test_CPPFLAGS = -g -D__TEST_MODULE__
hiqsdr_test_LDADD = -lrt
hiqsdr_test_SOURCES = hiqsdr.cpp hiqsdr.h
-hiqsdr_server_CPPFLAGS = -g -O3 -Wall
+hiqsdr_server_CPPFLAGS = -g -O3 -Wall @SIMD_FLAGS@
hiqsdr_server_SOURCES = \
View
4 trunk/src/perseus/Makefile.am
@@ -1,5 +1,7 @@
+ACLOCAL_AMFLAGS = -I build-aux
+
bin_PROGRAMS = perseus_server
-perseus_server_CPPFLAGS = -g -O3 -Wall
+perseus_server_CPPFLAGS = -g -O3 -Wall @SIMD_FLAGS@
perseus_server_SOURCES = \
bandscope.cpp \
View
73 trunk/src/perseus/build-aux/ax_check_compile_flag.m4
@@ -0,0 +1,73 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
+#
+# DESCRIPTION
+#
+# Check whether the given FLAG works with the current language's compiler
+# or gives an error. (Warnings, however, are ignored)
+#
+# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+# success/failure.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 2
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+ [AS_VAR_SET(CACHEVAR,[yes])],
+ [AS_VAR_SET(CACHEVAR,[no])])
+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
+
View
150 trunk/src/perseus/build-aux/ax_ext.m4
@@ -0,0 +1,150 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_ext.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_EXT
+#
+# DESCRIPTION
+#
+# Find supported SIMD extensions by requesting cpuid. When an SIMD
+# extension is found, the -m"simdextensionname" is added to SIMD_FLAGS
+# (only if compilator support it) (ie : if "sse2" is available "-msse2" is
+# added to SIMD_FLAGS)
+#
+# This macro calls:
+#
+# AC_SUBST(SIMD_FLAGS)
+#
+# And defines:
+#
+# HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3 /
+# HAVE_SSE41 / HAVE_SSE42 / HAVE_AVX
+#
+# LICENSE
+#
+# Copyright (c) 2008 Christophe Tournayre <turn3r@users.sourceforge.net>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 9
+
+AC_DEFUN([AX_EXT],
+[
+ AC_REQUIRE([AX_GCC_X86_CPUID])
+
+ AX_GCC_X86_CPUID(0x00000001)
+ ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3`
+ edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4`
+
+ AC_CACHE_CHECK([whether mmx is supported], [ax_cv_have_mmx_ext],
+ [
+ ax_cv_have_mmx_ext=no
+ if test "$((0x$edx>>23&0x01))" = 1; then
+ ax_cv_have_mmx_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse is supported], [ax_cv_have_sse_ext],
+ [
+ ax_cv_have_sse_ext=no
+ if test "$((0x$edx>>25&0x01))" = 1; then
+ ax_cv_have_sse_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse2 is supported], [ax_cv_have_sse2_ext],
+ [
+ ax_cv_have_sse2_ext=no
+ if test "$((0x$edx>>26&0x01))" = 1; then
+ ax_cv_have_sse2_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
+ [
+ ax_cv_have_sse3_ext=no
+ if test "$((0x$ecx&0x01))" = 1; then
+ ax_cv_have_sse3_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
+ [
+ ax_cv_have_ssse3_ext=no
+ if test "$((0x$ecx>>9&0x01))" = 1; then
+ ax_cv_have_ssse3_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse4.1 is supported], [ax_cv_have_sse41_ext],
+ [
+ ax_cv_have_sse41_ext=no
+ if test "$((0x$ecx>>19&0x01))" = 1; then
+ ax_cv_have_sse41_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse4.2 is supported], [ax_cv_have_sse42_ext],
+ [
+ ax_cv_have_sse42_ext=no
+ if test "$((0x$ecx>>20&0x01))" = 1; then
+ ax_cv_have_sse42_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether avx is supported], [ax_cv_have_avx_ext],
+ [
+ ax_cv_have_avx_ext=no
+ if test "$((0x$ecx>>28&0x01))" = 1; then
+ ax_cv_have_avx_ext=yes
+ fi
+ ])
+
+ if test "$ax_cv_have_mmx_ext" = yes; then
+ AC_DEFINE(HAVE_MMX,, [Support MMX instructions])
+ AX_CHECK_COMPILE_FLAG(-mmmx, SIMD_FLAGS="$SIMD_FLAGS -mmmx", [])
+ fi
+
+ if test "$ax_cv_have_sse_ext" = yes; then
+ AC_DEFINE(HAVE_SSE,, [Support SSE (Streaming SIMD Extensions) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse, SIMD_FLAGS="$SIMD_FLAGS -msse", [])
+ fi
+
+ if test "$ax_cv_have_sse2_ext" = yes; then
+ AC_DEFINE(HAVE_SSE2,, [Support SSE2 (Streaming SIMD Extensions 2) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse2, SIMD_FLAGS="$SIMD_FLAGS -msse2", [])
+ fi
+
+ if test "$ax_cv_have_sse3_ext" = yes; then
+ AC_DEFINE(HAVE_SSE3,, [Support SSE3 (Streaming SIMD Extensions 3) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse3, SIMD_FLAGS="$SIMD_FLAGS -msse3", [])
+ fi
+
+ if test "$ax_cv_have_ssse3_ext" = yes; then
+ AC_DEFINE(HAVE_SSSE3,, [Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])
+ AX_CHECK_COMPILE_FLAG(-mssse3, SIMD_FLAGS="$SIMD_FLAGS -mssse3", [])
+ fi
+
+ if test "$ax_cv_have_sse41_ext" = yes; then
+ AC_DEFINE(HAVE_SSE41,, [Support SSE4.1 (Streaming SIMD Extensions 4.1) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse4.1, SIMD_FLAGS="$SIMD_FLAGS -msse4.1", [])
+ fi
+
+ if test "$ax_cv_have_sse42_ext" = yes; then
+ AC_DEFINE(HAVE_SSE42, 1,[Support SSE4.2 (Streaming SIMD Extensions 4.2) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse4.2, SIMD_FLAGS="$SIMD_FLAGS -msse4.2", [])
+ fi
+
+ if test "$ax_cv_have_avx_ext" = yes; then
+ AC_DEFINE(HAVE_AVX,,[Support AVX (Advanced Vector Extensions) instructions])
+ AX_CHECK_COMPILE_FLAG(-mavx, SIMD_FLAGS="$SIMD_FLAGS -mavx", [])
+ fi
+
+ AC_SUBST(SIMD_FLAGS)
+])
+
View
80 trunk/src/perseus/build-aux/ax_gcc_x86_cpuid.m4
@@ -0,0 +1,80 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_GCC_X86_CPUID(OP)
+#
+# DESCRIPTION
+#
+# On Pentium and later x86 processors, with gcc or a compiler that has a
+# compatible syntax for inline assembly instructions, run a small program
+# that executes the cpuid instruction with input OP. This can be used to
+# detect the CPU type.
+#
+# On output, the values of the eax, ebx, ecx, and edx registers are stored
+# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
+# ax_cv_gcc_x86_cpuid_OP.
+#
+# If the cpuid instruction fails (because you are running a
+# cross-compiler, or because you are not using gcc, or because you are on
+# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP
+# is set to the string "unknown".
+#
+# This macro mainly exists to be used in AX_GCC_ARCHFLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2008 Matteo Frigo
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 7
+
+AC_DEFUN([AX_GCC_X86_CPUID],
+[AC_REQUIRE([AC_PROG_CC])
+AC_LANG_PUSH([C])
+AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
+ int op = $1, eax, ebx, ecx, edx;
+ FILE *f;
+ __asm__("cpuid"
+ : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+ : "a" (op));
+ f = fopen("conftest_cpuid", "w"); if (!f) return 1;
+ fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
+ fclose(f);
+ return 0;
+])],
+ [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
+ [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
+ [ax_cv_gcc_x86_cpuid_$1=unknown])])
+AC_LANG_POP([C])
+])
+
View
36 trunk/src/perseus/configure.ac
@@ -8,11 +8,47 @@ AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([perseus_audio.cpp])
AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([build-aux])
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
+#
+# Checking for build cpu
+# and, if 64 bit, add some linking option
+#
+case $build_cpu in
+
+ i686)
+ AC_MSG_NOTICE([Platform: ix86 32 bit])
+ # checks for platform dependent compiler optimizations
+ AX_EXT
+ AX_CHECK_COMPILE_FLAG(-ffast-math, SIMD_FLAGS="$SIMD_FLAGS -ffast-math", [])
+ ;;
+
+ x86_64)
+ AC_MSG_NOTICE([Platform: ix86 64 bit])
+ LDFLAGS="$LDFLAGS -L/lib64 -L/usr/lib64"
+ export LDFLAGS
+ AC_MSG_NOTICE([${LDFLAGS}])
+ # checks for platform dependent compiler optimizations
+ AX_EXT
+ AX_CHECK_COMPILE_FLAG(-ffast-math, SIMD_FLAGS="$SIMD_FLAGS -ffast-math", [])
+ ;;
+
+ armv6l)
+ AC_MSG_NOTICE([Platform: ARM 6])
+ CFLAGS="-O3 -pipe -march=armv6 -mfpu=vfp -mfloat-abi=hard"
+ CXXFLAGS="-O3 -pipe -march=armv6 -mfpu=vfp -mfloat-abi=hard"
+ export CFLAGS
+ export CXXFLAGS
+ AC_MSG_NOTICE([${CFLAGS}])
+ AC_MSG_NOTICE([${CXXFLAGS}])
+ ;;
+
+esac
+
# compiling `bandscope.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac'
AM_PROG_CC_C_O
View
2 trunk/src/sdriq/Makefile.am
@@ -1,7 +1,7 @@
bin_PROGRAMS = sdriq-test sdriq-server
-sdriq_test_CPPFLAGS = -g -D__TEST_MODULE__ -DDEBUG=5
+sdriq_test_CPPFLAGS = -g -D__TEST_MODULE__ -DDEBUG=5 @SIMD_FLAGS@
sdriq_test_LDADD = -lrt
sdriq_test_SOURCES = sdriq.c sdriq.h
View
2 trunk/src/server/Makefile.am
@@ -10,7 +10,7 @@ bin_PROGRAMS = hpsdr-server
-hpsdr_server_CFLAGS = -std=gnu99 -g -O3 -Wall
+hpsdr_server_CFLAGS = -std=gnu99 -g -O3 -Wall @SIMD_FLAGS@
hpsdr_server_SOURCES = \
bandscope.c \
View
2 trunk/src/softrock/Makefile.am
@@ -2,7 +2,7 @@
bin_PROGRAMS = softrock
-softrock_CFLAGS = -std=gnu99 -O3 -Wall
+softrock_CFLAGS = -std=gnu99 -O3 -Wall @SIMD_FLAGS@
softrock_SOURCES = client.c client.h \
config_ops.c config_ops.h \
View
6 trunk/src/usrp/Makefile.am
@@ -1,7 +1,9 @@
+ACLOCAL_AMFLAGS = -I build-aux
bin_PROGRAMS = usrp_server
CC = g++
-usrp_server_CPPFLAGS = -g -fopenmp -O3 -Wall -msse3
-usrp_server_CFLAGS = -g -fopenmp -O3 -Wall -msse3
+
+usrp_server_CPPFLAGS = -g -O3 -Wall @SIMD_FLAGS@
+usrp_server_LDADD = -lgomp
usrp_server_SOURCES = \
bandscope.c \
View
73 trunk/src/usrp/build-aux/ax_check_compile_flag.m4
@@ -0,0 +1,73 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
+#
+# DESCRIPTION
+#
+# Check whether the given FLAG works with the current language's compiler
+# or gives an error. (Warnings, however, are ignored)
+#
+# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+# success/failure.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 2
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+ [AS_VAR_SET(CACHEVAR,[yes])],
+ [AS_VAR_SET(CACHEVAR,[no])])
+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
+
View
150 trunk/src/usrp/build-aux/ax_ext.m4
@@ -0,0 +1,150 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_ext.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_EXT
+#
+# DESCRIPTION
+#
+# Find supported SIMD extensions by requesting cpuid. When an SIMD
+# extension is found, the -m"simdextensionname" is added to SIMD_FLAGS
+# (only if compilator support it) (ie : if "sse2" is available "-msse2" is
+# added to SIMD_FLAGS)
+#
+# This macro calls:
+#
+# AC_SUBST(SIMD_FLAGS)
+#
+# And defines:
+#
+# HAVE_MMX / HAVE_SSE / HAVE_SSE2 / HAVE_SSE3 / HAVE_SSSE3 /
+# HAVE_SSE41 / HAVE_SSE42 / HAVE_AVX
+#
+# LICENSE
+#
+# Copyright (c) 2008 Christophe Tournayre <turn3r@users.sourceforge.net>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 9
+
+AC_DEFUN([AX_EXT],
+[
+ AC_REQUIRE([AX_GCC_X86_CPUID])
+
+ AX_GCC_X86_CPUID(0x00000001)
+ ecx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 3`
+ edx=`echo $ax_cv_gcc_x86_cpuid_0x00000001 | cut -d ":" -f 4`
+
+ AC_CACHE_CHECK([whether mmx is supported], [ax_cv_have_mmx_ext],
+ [
+ ax_cv_have_mmx_ext=no
+ if test "$((0x$edx>>23&0x01))" = 1; then
+ ax_cv_have_mmx_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse is supported], [ax_cv_have_sse_ext],
+ [
+ ax_cv_have_sse_ext=no
+ if test "$((0x$edx>>25&0x01))" = 1; then
+ ax_cv_have_sse_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse2 is supported], [ax_cv_have_sse2_ext],
+ [
+ ax_cv_have_sse2_ext=no
+ if test "$((0x$edx>>26&0x01))" = 1; then
+ ax_cv_have_sse2_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse3 is supported], [ax_cv_have_sse3_ext],
+ [
+ ax_cv_have_sse3_ext=no
+ if test "$((0x$ecx&0x01))" = 1; then
+ ax_cv_have_sse3_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether ssse3 is supported], [ax_cv_have_ssse3_ext],
+ [
+ ax_cv_have_ssse3_ext=no
+ if test "$((0x$ecx>>9&0x01))" = 1; then
+ ax_cv_have_ssse3_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse4.1 is supported], [ax_cv_have_sse41_ext],
+ [
+ ax_cv_have_sse41_ext=no
+ if test "$((0x$ecx>>19&0x01))" = 1; then
+ ax_cv_have_sse41_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether sse4.2 is supported], [ax_cv_have_sse42_ext],
+ [
+ ax_cv_have_sse42_ext=no
+ if test "$((0x$ecx>>20&0x01))" = 1; then
+ ax_cv_have_sse42_ext=yes
+ fi
+ ])
+
+ AC_CACHE_CHECK([whether avx is supported], [ax_cv_have_avx_ext],
+ [
+ ax_cv_have_avx_ext=no
+ if test "$((0x$ecx>>28&0x01))" = 1; then
+ ax_cv_have_avx_ext=yes
+ fi
+ ])
+
+ if test "$ax_cv_have_mmx_ext" = yes; then
+ AC_DEFINE(HAVE_MMX,, [Support MMX instructions])
+ AX_CHECK_COMPILE_FLAG(-mmmx, SIMD_FLAGS="$SIMD_FLAGS -mmmx", [])
+ fi
+
+ if test "$ax_cv_have_sse_ext" = yes; then
+ AC_DEFINE(HAVE_SSE,, [Support SSE (Streaming SIMD Extensions) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse, SIMD_FLAGS="$SIMD_FLAGS -msse", [])
+ fi
+
+ if test "$ax_cv_have_sse2_ext" = yes; then
+ AC_DEFINE(HAVE_SSE2,, [Support SSE2 (Streaming SIMD Extensions 2) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse2, SIMD_FLAGS="$SIMD_FLAGS -msse2", [])
+ fi
+
+ if test "$ax_cv_have_sse3_ext" = yes; then
+ AC_DEFINE(HAVE_SSE3,, [Support SSE3 (Streaming SIMD Extensions 3) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse3, SIMD_FLAGS="$SIMD_FLAGS -msse3", [])
+ fi
+
+ if test "$ax_cv_have_ssse3_ext" = yes; then
+ AC_DEFINE(HAVE_SSSE3,, [Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions])
+ AX_CHECK_COMPILE_FLAG(-mssse3, SIMD_FLAGS="$SIMD_FLAGS -mssse3", [])
+ fi
+
+ if test "$ax_cv_have_sse41_ext" = yes; then
+ AC_DEFINE(HAVE_SSE41,, [Support SSE4.1 (Streaming SIMD Extensions 4.1) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse4.1, SIMD_FLAGS="$SIMD_FLAGS -msse4.1", [])
+ fi
+
+ if test "$ax_cv_have_sse42_ext" = yes; then
+ AC_DEFINE(HAVE_SSE42, 1,[Support SSE4.2 (Streaming SIMD Extensions 4.2) instructions])
+ AX_CHECK_COMPILE_FLAG(-msse4.2, SIMD_FLAGS="$SIMD_FLAGS -msse4.2", [])
+ fi
+
+ if test "$ax_cv_have_avx_ext" = yes; then
+ AC_DEFINE(HAVE_AVX,,[Support AVX (Advanced Vector Extensions) instructions])
+ AX_CHECK_COMPILE_FLAG(-mavx, SIMD_FLAGS="$SIMD_FLAGS -mavx", [])
+ fi
+
+ AC_SUBST(SIMD_FLAGS)
+])
+
View
80 trunk/src/usrp/build-aux/ax_gcc_x86_cpuid.m4
@@ -0,0 +1,80 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_GCC_X86_CPUID(OP)
+#
+# DESCRIPTION
+#
+# On Pentium and later x86 processors, with gcc or a compiler that has a
+# compatible syntax for inline assembly instructions, run a small program
+# that executes the cpuid instruction with input OP. This can be used to
+# detect the CPU type.
+#
+# On output, the values of the eax, ebx, ecx, and edx registers are stored
+# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
+# ax_cv_gcc_x86_cpuid_OP.
+#
+# If the cpuid instruction fails (because you are running a
+# cross-compiler, or because you are not using gcc, or because you are on
+# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP
+# is set to the string "unknown".
+#
+# This macro mainly exists to be used in AX_GCC_ARCHFLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2008 Matteo Frigo
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 7
+
+AC_DEFUN([AX_GCC_X86_CPUID],
+[AC_REQUIRE([AC_PROG_CC])
+AC_LANG_PUSH([C])
+AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
+ int op = $1, eax, ebx, ecx, edx;
+ FILE *f;
+ __asm__("cpuid"
+ : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+ : "a" (op));
+ f = fopen("conftest_cpuid", "w"); if (!f) return 1;
+ fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
+ fclose(f);
+ return 0;
+])],
+ [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
+ [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
+ [ax_cv_gcc_x86_cpuid_$1=unknown])])
+AC_LANG_POP([C])
+])
+
View
45 trunk/src/usrp/configure.ac
@@ -8,13 +8,52 @@ AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([usrp_audio.c])
AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([build-aux])
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
-
-# compiling `bandscope.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac'
-AM_PROG_CC_C_O
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+dnl # compiling `bandscope.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac'
+dnl AM_PROG_CC_C_O
+
+#
+# Checking for build cpu
+# and, if 64 bit, add some linking option
+#
+case $build_cpu in
+
+ i686)
+ AC_MSG_NOTICE([Platform: ix86 32 bit])
+ # checks for platform dependent compiler optimizations
+ AX_EXT
+ AX_CHECK_COMPILE_FLAG(-ffast-math, SIMD_FLAGS="$SIMD_FLAGS -ffast-math", [])
+ AX_CHECK_COMPILE_FLAG(-fopenmp, SIMD_FLAGS="$SIMD_FLAGS -fopenmp", [])
+ ;;
+
+ x86_64)
+ AC_MSG_NOTICE([Platform: ix86 64 bit])
+ LDFLAGS="$LDFLAGS -L/lib64 -L/usr/lib64"
+ export LDFLAGS
+ AC_MSG_NOTICE([${LDFLAGS}])
+ # checks for platform dependent compiler optimizations
+ AX_EXT
+ AX_CHECK_COMPILE_FLAG(-ffast-math, SIMD_FLAGS="$SIMD_FLAGS -ffast-math", [])
+ AX_CHECK_COMPILE_FLAG(-fopenmp, SIMD_FLAGS="$SIMD_FLAGS -fopenmp", [])
+ ;;
+
+ armv6l)
+ AC_MSG_NOTICE([Platform: ARM 6])
+ CFLAGS="-O3 -pipe -march=armv6 -mfpu=vfp -mfloat-abi=hard"
+ CXXFLAGS="-O3 -pipe -march=armv6 -mfpu=vfp -mfloat-abi=hard"
+ export CFLAGS
+ export CXXFLAGS
+ AC_MSG_NOTICE([${CFLAGS}])
+ AC_MSG_NOTICE([${CXXFLAGS}])
+ ;;
+
+esac
# Checks for libraries.
View
2 trunk/src/widget-server/Makefile.am
@@ -1,6 +1,6 @@
bin_PROGRAMS = widget-server
-widget_server_CFLAGS = -O3 -std=gnu99
+widget_server_CFLAGS = -O3 -std=gnu99 @SIMD_FLAGS@
widget_server_SOURCES = \
bandscope.c \

0 comments on commit 74e9344

Please sign in to comment.