File: configure.ac

package info (click to toggle)
primesieve 5.7.2+ds-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,064 kB
  • ctags: 1,079
  • sloc: cpp: 5,871; makefile: 232; ansic: 176; sh: 102
file content (133 lines) | stat: -rw-r--r-- 4,195 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
AC_INIT([primesieve], [5.7.2], [kim.walisch@gmail.com])
AC_SUBST([primesieve_lib_version], [7:2:0])

AC_PREREQ([2.62])
AC_LANG([C++])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([subdir-objects foreign -Wall -Werror])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
AM_MAINTAINER_MODE([enable])
AC_PROG_CC
AC_PROG_CXX
AC_OPENMP
AC_CANONICAL_HOST
# Silence warning: ar: 'u' modifier ignored since 'D' is the default
AC_SUBST(AR_FLAGS, [cr])
AM_PROG_AR
# Needed for automake <= 1.13
AM_PROG_CC_C_O
LT_INIT

# doxygen is used to generate C/C++ API documentation
AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen])
AM_CONDITIONAL([HAVE_DOXYGEN], [test x$DOXYGEN = xdoxygen])

# help2man is used to generate manpages (maintainer mode)
AC_CHECK_PROG([HELP2MAN], [help2man], [help2man])
AM_CONDITIONAL([HAVE_HELP2MAN], [test x$HELP2MAN = xhelp2man])

# Check if graphviz is installed
AC_CHECK_PROG([HAVE_DOT], [dot], [YES], [NO])

AC_ARG_WITH([help2man],
    [AS_HELP_STRING([--with-help2man], [Use help2man to generate man pages])],
    WITH_HELP2MAN="yes")


AC_ARG_ENABLE(examples,
    [AS_HELP_STRING([--enable-examples], [Compile the examples programs])],
    ENABLE_EXAMPLES="yes")

AM_CONDITIONAL(MAKE_EXAMPLES, test "x$ENABLE_EXAMPLES" = "xyes")

# Force building shared library on Windows
# Reference: <http://article.gmane.org/gmane.comp.gnu.mingw.user/18727>
case "$host_os" in
    cygwin*) AM_CONDITIONAL(FORCE_SHARED_LIBRARY, true);;
    mingw*)  AM_CONDITIONAL(FORCE_SHARED_LIBRARY, true);;
    *)       AM_CONDITIONAL(FORCE_SHARED_LIBRARY, false);;
esac

AC_ARG_VAR([L1_DCACHE_SIZE], [CPU L1 data cache size in kilobytes])

AS_IF([test "x$L1_DCACHE_SIZE" != "x"],
    [L1_DETECTED="yes"])

# This is a very portable shell script that finds the CPU's L1
# cache size (in kilobytes) on most Unix-like systems
AS_IF([test "x$L1_DCACHE_SIZE" = "x"],
    [[
    # Default L1 cache size
    L1_DCACHE_SIZE=32

    command -v getconf >/dev/null 2>/dev/null
    if [ $? -eq 0 ];
    then
        # Returns L1 cache size in bytes
        L1_DCACHE_BYTES=$(getconf LEVEL1_DCACHE_SIZE 2>/dev/null)
    fi

    if test "x$L1_DCACHE_BYTES" = "x" || test "$L1_DCACHE_BYTES" = "0";
    then
        # Returns L1 cache size like e.g. 32K, 1M
        L1_DCACHE_BYTES=$(cat /sys/devices/system/cpu/cpu0/cache/index0/size 2>/dev/null)

        if test "x$L1_DCACHE_BYTES" != "x";
        then
            is_kilobytes=$(echo $L1_DCACHE_BYTES | grep K)
            if test "x$is_kilobytes" != "x";
            then
                L1_DCACHE_BYTES=$(expr $(echo $L1_DCACHE_BYTES | sed -e s'/K$//') '*' 1024)
            fi
            is_megabytes=$(echo $L1_DCACHE_BYTES | grep M)
            if test "x$is_megabytes" != "x";
            then
                L1_DCACHE_BYTES=$(expr $(echo $L1_DCACHE_BYTES | sed -e s'/M$//') '*' 1024 '*' 1024)
            fi
        else
            command -v sysctl >/dev/null 2>/dev/null
            if [ $? -eq 0 ];
            then
                # Returns L1 cache size in bytes
                L1_DCACHE_BYTES=$(sysctl hw.l1dcachesize 2>/dev/null | sed -e 's/^.* //')
            fi
        fi
    fi

    if test "x$L1_DCACHE_BYTES" != "x";
    then
        if [ $L1_DCACHE_BYTES -ge 2048 2>/dev/null ];
        then
            # Convert L1 cache size to kilobytes
            L1_DCACHE_SIZE=$(expr $L1_DCACHE_BYTES '/' 1024)
            L1_DETECTED="yes"
        fi
    fi]])

AC_DEFINE_UNQUOTED([L1_DCACHE_SIZE],
    [$L1_DCACHE_SIZE],
    [CPU L1 data cache size in kilobytes])

AC_ARG_VAR([SIEVESIZE], [Default sieve size in kilobytes])

AS_IF([test "x$SIEVESIZE" = "x"], [SIEVESIZE=$L1_DCACHE_SIZE])

AC_DEFINE_UNQUOTED([SIEVESIZE],
    [$SIEVESIZE],
    [Default sieve size in kilobytes])

AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
    Makefile
    primesieve.pc
    doc/Doxyfile])
AC_OUTPUT

AS_IF([test "x$L1_DETECTED" != "x"],
    [AC_MSG_NOTICE([NOTICE: using L1_DCACHE_SIZE=$L1_DCACHE_SIZE (kilobytes)])])

AS_IF([test "x$L1_DETECTED" = "x"],
    [AC_MSG_WARN([CPU L1 data cache size not detected, using L1_DCACHE_SIZE=$L1_DCACHE_SIZE (kilobytes)])])

AC_MSG_NOTICE([NOTICE: using SIEVESIZE=$SIEVESIZE (kilobytes)])