File: lqt_opt_cflags.m4

package info (click to toggle)
gmerlin-encoders 1.2.0-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 3,460 kB
  • sloc: ansic: 11,619; sh: 11,014; makefile: 203; sed: 16
file content (104 lines) | stat: -rw-r--r-- 2,445 bytes parent folder | download | duplicates (18)
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
#
# Automatic OPT_CFLAGS generation by Burkhard Plaum (2005-05-24)
#

dnl LQT_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
dnl check if $CC supports a given set of cflags
AC_DEFUN([LQT_TRY_CFLAGS],
    [AC_MSG_CHECKING([if $CC supports $1 flags])
    SAVE_CFLAGS="$CFLAGS"
    CFLAGS="$1"
    AC_TRY_COMPILE([],[],[lqt_try_cflags_ok=yes],[lqt_try_cflags_ok=no])
    CFLAGS="$SAVE_CFLAGS"
    AC_MSG_RESULT([$lqt_try_cflags_ok])
    if test x"$lqt_try_cflags_ok" = x"yes"; then
        ifelse([$2],[],[:],[$2])
    else
        ifelse([$3],[],[:],[$3])
    fi])

dnl LQT_OPT_CFLAGS(CPU_TYPE [, ADDITIONAL_OPT_FLAGS])
dnl Get proper optimization flags. 
dnl
dnl CPU_TYPE: host_cpu variable as obtained from AC_CANONICAL_HOST
dnl ADDITIONAL_OPT_FLAGS:  Additional optimization flags (e.g. -O3 --fast-math)
dnl On output, the Variable LQT_OPT_CFLAGS will be set to the compiler flags
dnl Furthermore, is debuggind was requested, the variable LQT_DEBUG will be
dnl set to "true"

AC_DEFUN([LQT_OPT_CFLAGS],[

dnl
dnl Debugging Support
dnl


LQT_DEBUG=false

AC_ARG_ENABLE(debug,
[AC_HELP_STRING([--enable-debug],[Enable debugging, disable optimization])],
[case "${enableval}" in
   yes) LQT_DEBUG=true ;;
   no)  LQT_DEBUG=false ;;
esac],[LQT_DEBUG=false])


dnl
dnl Extra cflags from the commandline. Can have the special values "none" or "auto"
dnl

AC_ARG_WITH(cpuflags, 
AC_HELP_STRING([--with-cpuflags],[Set CPU specific compiler flags. Default is auto, which
               does autodetection. Specify none for compiling the most portable binaries]),
               lqt_cpuflags="$withval", lqt_cpuflags="auto")

if test x$lqt_cpuflags = xnone; then
lqt_cpuflags=""
fi

dnl
dnl Autodetect CPU specific flags
dnl

if test x$lqt_cpuflags = xauto; then

lqt_cpu_family=""
case [$1] in
  i[[3-7]]86)
    lqt_cpu_family=x86;;
  x86_64*)
    lqt_cpu_family=x86;;
  powerpc | powerpc64)
    lqt_cpu_family=ppc;;
  *)
    lqt_cpu_family="";;
esac

if test x$lqt_cpu_family = x; then
  lqt_cpuflags=""
else
  lqt_cpuflags=`$srcdir/cpuinfo.sh $lqt_cpu_family`
fi

fi

dnl
dnl Build the final flags
dnl

lqt_additional_opt_flags=ifelse([$2],[],[],[$2])

lqt_test_flags=$lqt_cpuflags

if test x$LQT_DEBUG = xtrue; then
  lqt_test_cflags="$lqt_test_flags -g -DDEBUG"
else
  lqt_test_cflags="$lqt_test_flags $lqt_additional_opt_flags"
fi

OPT_CFLAGS=""
for i in $lqt_test_cflags; do
  LQT_TRY_CFLAGS($i, OPT_CFLAGS="$OPT_CFLAGS $i") ;
done

])