File: base_checks.m4

package info (click to toggle)
ocaml-shine 0.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 300 kB
  • sloc: ansic: 138; ml: 135; makefile: 89; sh: 12
file content (164 lines) | stat: -rw-r--r-- 5,292 bytes parent folder | download | duplicates (53)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
AC_DEFUN([AC_BASE_CHECKS],
[AC_REQUIRE([AC_PROG_CC])
dnl check that running user is not root
AC_MSG_CHECKING([that calling user is not root])
RUNNING_USER="$USER"
if test -z "$RUNNING_USER"; then
  RUNNING_USER=`whoami`
fi
if test $RUNNING_USER = "root"; then
  AC_MSG_ERROR([configure script must not be run with root user!])
else
  AC_MSG_RESULT([ok])
fi

dnl check for base compilers
AC_CANONICAL_HOST()
# AC_CANONICAL_HOST needs those files
AUTOCONF_INSTALL_FILES="config.guess config.sub install-sh m4/*.m4"
AC_SUBST(AUTOCONF_INSTALL_FILES)

AC_PROG_CC()
AC_PROG_INSTALL()
AC_CHECK_TOOL([AR],[ar],no)
AC_SUBST(AR)
AC_CHECK_OCAML_COMPILERS()


dnl add some flags
AC_DETECT_PIC_FLAGS()

CXXFLAGS="$CXXFLAGS $PIC_FLAGS"
CPPFLAGS="$CPPFLAGS $PIC_FLAGS"

# Add prefix to compilation variables
# if passed
if test "x$prefix" != "xNONE"; then
  CFLAGS="$CFLAGS -I$prefix/include"
  LDFLAGS="$LDFLAGS -L$prefix/lib"
  CPPFLAGS="$CPPFLAGS -I$prefix/include"
  CXXFLAGS="$CXXFLAGS -I$prefix/include"
fi
])

dnl Check for basic stuff
dnl The following was stolen from mesa..
dnl A few convenience macros for Mesa, mostly to keep all the platform
dnl specifics out of configure.ac.

dnl AC_DETECT_PIC_FLAGS()
dnl
dnl Find out whether to build PIC code using the option --enable-pic and
dnl the configure enable_static/enable_shared settings. If PIC is needed,
dnl figure out the necessary flags for the platform and compiler.
dnl
dnl The platform checks have been shamelessly taken from libtool and
dnl stripped down to just what's needed for Mesa. See _LT_COMPILER_PIC in
dnl /usr/share/aclocal/libtool.m4 or
dnl http://git.savannah.gnu.org/gitweb/?p=libtool.git;a=blob;f=libltdl/m4/libtool.m4;hb=HEAD
dnl
AC_DEFUN([AC_DETECT_PIC_FLAGS],
[AC_ARG_VAR([PIC_FLAGS], [compiler flags for PIC code])
AC_ARG_ENABLE([pic],
    [AS_HELP_STRING([--disable-pic],
        [compile PIC objects @<:@default=enabled for shared builds
        on supported platforms@:>@])],
    [enable_pic="$enableval"
    test "x$enable_pic" = x && enable_pic=auto],
    [enable_pic=auto])
dnl disable PIC by default for static builds
if test "$enable_pic" = auto && test "$enable_static" = yes; then
    enable_pic=no
fi
dnl if PIC hasn't been explicitly disabled, try to figure out the flags
if test "$enable_pic" != no; then
    AC_MSG_CHECKING([for $CC option to produce PIC])
    dnl allow the user's flags to override
    if test "x$PIC_FLAGS" = "x"; then
        dnl see if we're using GCC
        if test "x$GCC" = "xyes"; then
            case "$host_os" in
            aix*|beos*|cygwin*|irix5*|irix6*|osf3*|osf4*|osf5*)
                dnl PIC is the default for these OSes.
                ;;
            mingw*|os2*|pw32*)
                dnl This hack is so that the source file can tell whether
                dnl it is being built for inclusion in a dll (and should
                dnl export symbols for example).
                PIC_FLAGS="-DDLL_EXPORT"
                ;;
            darwin*|rhapsody*)
                dnl PIC is the default on this platform
                dnl Common symbols not allowed in MH_DYLIB files
                PIC_FLAGS="-fno-common"
                ;;
            hpux*)
                dnl PIC is the default for IA64 HP-UX and 64-bit HP-UX,
                dnl but not for PA HP-UX.
                case $host_cpu in
                hppa*64*|ia64*)
                    ;;
                *)
                    PIC_FLAGS="-fPIC"
                    ;;
                esac
                ;;
            *)
                dnl Everyone else on GCC uses -fPIC
                PIC_FLAGS="-fPIC"
                ;;
            esac
        else dnl !GCC
            case "$host_os" in
            hpux9*|hpux10*|hpux11*)
                dnl PIC is the default for IA64 HP-UX and 64-bit HP-UX,
                dnl but not for PA HP-UX.
                case "$host_cpu" in
                hppa*64*|ia64*)
                    dnl +Z the default
                    ;;
                *)
                    PIC_FLAGS="+Z"
                    ;;
                esac
                ;;
            linux*|k*bsd*-gnu)
                case `basename "$CC"` in
                icc*|ecc*|ifort*)
                    PIC_FLAGS="-KPIC"
                    ;;
                pgcc*|pgf77*|pgf90*|pgf95*)
                    dnl Portland Group compilers (*not* the Pentium gcc
                    dnl compiler, which looks to be a dead project)
                    PIC_FLAGS="-fpic"
                    ;;
                ccc*)
                    dnl All Alpha code is PIC.
                    ;;
                xl*)
                    dnl IBM XL C 8.0/Fortran 10.1 on PPC
                    PIC_FLAGS="-qpic"
                    ;;
                *)
                    case `$CC -V 2>&1 | sed 5q` in
                    *Sun\ C*|*Sun\ F*)
                        dnl Sun C 5.9 or Sun Fortran
                        PIC_FLAGS="-KPIC"
                        ;;
                    esac
                esac
                ;;
            solaris*)
                PIC_FLAGS="-KPIC"
                ;;
            sunos4*)
                PIC_FLAGS="-PIC"
                ;;
            esac
        fi
    fi 
    AC_MSG_RESULT([$PIC_FLAGS])
fi
AC_SUBST([PIC_FLAGS])
])dnl PIC_FLAGS