source: neercs/trunk/configure.ac @ 4791

Last change on this file since 4791 was 4791, checked in by Pascal Terjan, 10 years ago

Include util.h or libutil.h depending on what is available, should help building on FreeBSD

File size: 5.7 KB
Line 
1
2AC_INIT(neercs, 0.0)
3
4AC_PREREQ(2.50)
5AC_CONFIG_SRCDIR(src/main.c)
6AC_CONFIG_AUX_DIR(.auto)
7AC_CANONICAL_SYSTEM
8
9AM_INIT_AUTOMAKE(neercs, 0.0)
10AM_CONFIG_HEADER(config.h)
11
12AM_PROG_CC_C_O
13AC_PROG_CPP
14
15AC_CANONICAL_HOST
16
17if test "$host_os" == "darwin10.2.0"; then
18    case x${target} in
19     x*86*darwin*)
20      MACOSX_SDK="${MACOSX_SDK:-/Developer/SDKs/MacOSX10.6.sdk}"
21      GCC_VERSION="${GCC_VERSION:-4.0}"
22      ARCH="${ARCH:--arch i386}"
23      MACOSX_SDK_CFLAGS="${MACOSX_SDK_CFLAGS:--isysroot ${MACOSX_SDK}}"
24      MACOSX_SDK_CXXFLAGS="${MACOSX_SDK_CXXFLAGS:-${MACOSX_SDK_CFLAGS}}"
25      ;;
26    esac
27    CC="${CC:-gcc-${GCC_VERSION}}"
28    CXX="${CXX:-g++-${GCC_VERSION}}"
29    MACOSX_SDK_FRAMEWORKS="${MACOSX_SDK_FRAMEWORKS:--F${MACOSX_SDK}/System/Library/Frameworks}"
30    CPPFLAGS="${CPPFLAGS} ${ARCH} ${MACOSX_SDK_FRAMEWORKS}"
31    CFLAGS="${CFLAGS} ${MACOSX_SDK_CFLAGS}"
32    CXXFLAGS="${CXXFLAGS} ${MACOSX_SDK_CXXFLAGS}"
33    OBJCFLAGS="${OBJCFLAGS} ${MACOSX_SDK_CFLAGS}"
34    LDFLAGS="${ARCH} ${MACOSX_SDK_LDFLAGS} ${LDFLAGS}"
35fi
36
37
38dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
39dnl now otherwise it might be set in an obscure if statement. Same thing for
40dnl PKG_PROG_PKG_CONFIG which needs to be called first.
41AC_EGREP_CPP(yes, foo)
42PKG_PROG_PKG_CONFIG()
43
44dnl Don't let pkg-config fuck our cross-compilation environment
45m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
46if test "$build" != "$host" -a "${PKG_CONFIG_LIBDIR}" = ""; then
47  export PKG_CONFIG_LIBDIR=/dev/null
48fi
49
50
51dnl conditional builds
52AC_ARG_ENABLE(debug,
53  [  --enable-debug          build debug version of neercs (default no)])
54AC_ARG_ENABLE(profiling,
55  [  --enable-profiling      build profiling version of neercs (gprof)(default no)])
56AC_ARG_ENABLE(python,
57  [  --enable-python         build Python interpreter (default yes)])
58AS_IF([test "x$enable_python" != "xno"], [
59  enable_python="yes"
60])
61AC_ARG_ENABLE(ruby,
62  [  --enable-ruby           build Ruby interpreter (default yes)])
63AS_IF([test "x$enable_ruby" != "xno"], [
64  enable_ruby="yes"
65])
66
67CACA="no"
68PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17,
69 [CACA="yes"],
70 [AC_MSG_RESULT(no)
71  AC_MSG_ERROR([you need libcaca version 0.99.beta17 or later])])
72
73AC_CHECK_HEADERS(libutil.h util.h stdio.h pty.h sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h sys/wait.h linux/kdev_t.h linux/major.h security/pam_appl.h security/pam_misc.h)
74
75case $host_os in
76  darwin*)
77    AC_MSG_RESULT(Disabling lock support on OSX) ;;
78  *)
79    AC_CHECK_LIB(pam, pam_authenticate,
80      [PAM_LIBS="${PAM_LIBS} -lpam"
81      AC_DEFINE(USE_LOCK, 1, [Locking the PTY is supported])]) ;;
82esac
83AC_SUBST(PAM_LIBS)
84
85AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
86AC_SUBST(MATH_LIBS)
87
88AC_CHECK_LIB(util, forkpty, UTIL_LIBS="${UTIL_LIBS} -lutil")
89AC_SUBST(UTIL_LIBS)
90
91AC_MSG_CHECKING(for pty grab support)
92case $target in
93  i?86-*-linux-*|amd64-*-linux-*|x86_64-*-linux-*)
94    AC_DEFINE(USE_GRAB, 1, [Grabbing processes is supported])
95    grab=yes ;;
96  *)
97    grab=no ;;
98esac
99AC_MSG_RESULT($grab)
100
101if test "${enable_debug}" = "yes"; then
102  AC_DEFINE(DEBUG, 1, Define to 1 to activate debug)
103fi
104
105AC_DEFINE(_GNU_SOURCE, 1, [Use GNU extentions])
106
107PYTHON="no"
108if test "${enable_python}" != "no"; then
109PKG_CHECK_MODULES(PYTHON3, python3 >= 3.1,
110 [PYTHON="yes"
111  PYTHON_CFLAGS="${PYTHON3_CFLAGS}"
112  PYTHON_LIBS="${PYTHON3_LIBS}"
113  AC_DEFINE(HAVE_PYTHON3, 1, [Define to 1 if Python 3 is present])
114  AC_DEFINE(HAVE_PYTHON26, 1, [Define to 1 if Python >= 2.6 is present])],
115 [AC_PATH_PROG(PYTHON_CONFIG, python2.6-config, no)
116  if test "${PYTHON_CONFIG}" = "no"; then
117    AC_PATH_PROG(PYTHON_CONFIG, python2.5-config, no)
118  else
119    AC_DEFINE(HAVE_PYTHON26, 1, [Define to 1 if Python >= 2.6 is present])
120  fi
121  if test "${PYTHON_CONFIG}" = "no"; then
122    AC_PATH_PROG(PYTHON_CONFIG, python2.4-config, no)
123  fi
124  if test "${PYTHON_CONFIG}" != "no"; then
125    PYTHON="yes"
126    PYTHON_CFLAGS="`${PYTHON_CONFIG} --cflags`"
127    PYTHON_LIBS="`${PYTHON_CONFIG} --libs`"
128    AC_DEFINE(HAVE_PYTHON2, 1, [Define to 1 if Python 2 is present])
129  fi])
130  if test "${PYTHON}" = "yes"; then
131    AC_DEFINE(USE_PYTHON, 1, [Define to 1 to use Python interpreter])
132  else
133    AC_MSG_RESULT(you need Python 2.4 or later to compile the interpreter)
134  fi
135fi
136
137AC_SUBST(PYTHON_CFLAGS)
138AC_SUBST(PYTHON_LIBS)
139
140# Optimizations / Profiling
141CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce"
142
143if test "${enable_profiling}" = "yes"; then
144  CFLAGS="${CFLAGS} -g -O0 -fno-strength-reduce -pg"
145else
146  CFLAGS="${CFLAGS} -fomit-frame-pointer"
147fi
148
149# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
150CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
151
152# Build documentation?
153DOXYGEN="no"
154LATEX="no"
155if test "${enable_doc}" != "no"; then
156  AC_PATH_PROG(DOXYGEN, doxygen, no)
157  if test "${DOXYGEN}" != "no"; then
158    # Build LaTeX documentation?
159    AC_PATH_PROG(LATEX, pdflatex, no)
160    AC_PATH_PROG(KPSEWHICH, kpsewhich, no)
161    AC_PATH_PROG(DVIPS, dvips, no)
162    if test "${DVIPS}" = "no" -o "${KPSEWHICH}" = "no"; then
163      LATEX="no"
164    fi
165    if test "${LATEX}" != "no"; then
166      AC_MSG_CHECKING(for a4.sty and a4wide.sty)
167      if "${KPSEWHICH}" a4.sty >/dev/null 2>&1; then
168        if "${KPSEWHICH}" a4wide.sty >/dev/null 2>&1; then
169          AC_MSG_RESULT(yes)
170        else
171          LATEX="no"
172          AC_MSG_RESULT(no)
173        fi
174      else
175        LATEX="no"
176        AC_MSG_RESULT(no)
177      fi
178    fi
179  fi
180fi
181AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
182AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
183
184AC_CONFIG_FILES([
185  Makefile
186  doc/Makefile
187  src/Makefile
188  data/Makefile
189  test/Makefile
190])
191AC_CONFIG_FILES([
192  doc/doxygen.cfg
193])
194AC_OUTPUT
195
Note: See TracBrowser for help on using the repository browser.