configure.in 10.4 KB
Newer Older
1 2 3 4 5 6 7 8 9
dnl Process this file with autoconf to produce a configure script.

dnl Prolog

AC_INIT(NX.h)
AC_PREREQ(2.13)

dnl Set our default compilation flags.

Mike Gabriel's avatar
Mike Gabriel committed
10 11
CXXFLAGS="-O3 -fno-rtti -fno-exceptions"
CFLAGS="-O3"
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

dnl Reset default linking directives.

LIBSTATIC=""
LIBSHARED=""

dnl Prefer headers and libraries from nx-X11, if present.

if test -d "../nx-X11/include" ; then
    CXXFLAGS="$CXXFLAGS -I../nx-X11/exports/include"
    CFLAGS="$CFLAGS -I../nx-X11/exports/include"
    LIBS="$LIBS -L../nx-X11/exports/lib"
fi

dnl Check whether --with-ipaq was given.

if test "${with_ipaq}" = yes; then
  echo -e "enabling IPAQ configuration"
  CXX="arm-linux-c++"
  CC="arm-linux-gcc"
  unset ac_cv_prog_armcxx
  unset ac_cv_prog_armcc
  unset ac_cv_prog_CXXCPP
  AC_CHECK_PROG([armcxx],["$CXX"],[yes],[no],[$PATH])
  AC_CHECK_PROG([armcc],["$CC"],[yes],[no],[$PATH])
  if test $armcxx = "yes" && test $armcc = "yes" ; then
    ac_cv_prog_CXX="$CXX"
    ac_cv_prog_CC="$CC"
  else
    AC_MSG_ERROR(Installation or configuration problem. Cannot find compiler for arm-linux.)
  fi
else
  unset ac_cv_prog_CXX
  unset ac_cv_prog_CC
  unset ac_cv_prog_CXXCPP
fi  

dnl Check for programs.

AC_PROG_CXX
AC_PROG_CC
AC_LANG_CPLUSPLUS

dnl Check whether option -Wno-deprecated
dnl is needed by GCC compiler.

AC_MSG_CHECKING([whether compiler needs -Wno-deprecated])
gcc_version=`${CC} --version | grep 'gcc (GCC) [[3-4]].' | head -n 1`
case "${gcc_version}" in
     gcc*)
        AC_MSG_RESULT([yes])
        CXXFLAGS="$CXXFLAGS -Wno-deprecated"
        ;;

     *)
        AC_MSG_RESULT([no])
        ;;
esac

71
AC_MSG_CHECKING([whether compiler accepts -Wmissing-declarations])
72 73 74 75 76 77 78 79
gcc_version=`${CC} --version | grep 'gcc (GCC) [[3-4]].' | head -n 1`
case "${gcc_version}" in
     gcc*)
        AC_MSG_RESULT([no])
        ;;

     *)
        AC_MSG_RESULT([yes])
80
        CXXFLAGS="$CXXFLAGS -Wmissing-declarations"
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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
        ;;
esac

dnl Check for BSD compatible install.

AC_PROG_INSTALL

dnl Check for extra header files.

AC_PATH_XTRA

dnl Custom addition.

ac_help="$ac_help
  --with-symbols          add the -g flag to produce the debug symbols
  --with-use-malloc       add the __USE_MALLOC flag to avoid the STL allocators
  --with-info             define INFO at compile time to get basic log output
  --with-valgrind         clean up allocated buffers to avoid valgrind warnings
  --with-version          use this version for produced libraries

  --with-static-png       enable static linking of PNG library
  --with-static-jpeg      enable static linking of JPEG library
  --with-static-z         enable static linking of Z library"

dnl Check to see if we're running under Cygwin32.

AC_DEFUN(nxconf_CYGWIN32,
[AC_CACHE_CHECK(for Cygwin32 environment, nxconf_cv_cygwin32,
[AC_TRY_COMPILE(,[return __CYGWIN32__;],
nxconf_cv_cygwin32=yes, nxconf_cv_cygwin32=no)
rm -f conftest*])
CYGWIN32=
test "$nxconf_cv_cygwin32" = yes && CYGWIN32=yes])
nxconf_CYGWIN32

dnl Check whether we're building on a AMD64.

AC_DEFUN(nxconf_AMD64,
[AC_CACHE_CHECK(for Amd64 environment, nxconf_cv_amd64,
[AC_TRY_COMPILE(,[return (__amd64__ || __x86_64__);],
nxconf_cv_amd64=yes, nxconf_cv_amd64=no)
rm -f conftest*])
AMD64=
test "$nxconf_cv_amd64" = yes && AMD64=yes])
nxconf_AMD64

dnl Check for Darwin environment.

AC_DEFUN(nxconf_DARWIN,
[AC_CACHE_CHECK(for Darwin environment, nxconf_cv_darwin,
[AC_TRY_COMPILE(,[return __APPLE__;],
nxconf_cv_darwin=yes, nxconf_cv_darwin=no)
rm -f conftest*])
DARWIN=
test "$nxconf_cv_darwin" = yes && DARWIN=yes])
nxconf_DARWIN

dnl Check to see if we're running under Solaris.

AC_DEFUN(nxconf_SUN,
[AC_CACHE_CHECK(for Solaris environment, nxconf_cv_sun,
[AC_TRY_COMPILE(,[return __sun;],
nxconf_cv_sun=yes, nxconf_cv_sun=no)
rm -f conftest*])
SUN=
test "$nxconf_cv_sun" = yes && SUN=yes])
nxconf_SUN

dnl Check to see if we're running under FreeBSD.

AC_DEFUN(nxconf_FreeBSD,
[AC_CACHE_CHECK(for FreeBSD environment, nxconf_cv_freebsd,
[AC_TRY_COMPILE(,[return __FreeBSD__;],
nxconf_cv_freebsd=yes, nxconf_cv_freebsd=no)
rm -f conftest*])
FreeBSD=
test "$nxconf_cv_freebsd" = yes && FreeBSD=yes])
nxconf_FreeBSD

dnl Build PIC libraries.

if test "$CYGWIN32" != yes -a "$DARWIN" != yes; then
  CXXFLAGS="$CXXFLAGS -fPIC"
  CFLAGS="$CFLAGS -fPIC"
fi

dnl Solaris requires the socket and gcc_s libs explicitly linked.
dnl Note also that headers from default /usr/openwin/include/X11
dnl cause a warning due to pragma in Xmd.h.

if test "$SUN" = yes; then
  LIBS="$LIBS -L/usr/sfw/lib -lsocket "
  CXXFLAGS="$CXXFLAGS -I/usr/sfw/include"
  CFLAGS="$CFLAGS -I/usr/sfw/include"
fi

dnl On FreeBSD search libraries and includes under /usr/local.

if test "$FreeBSD" = yes; then
  LIBS="$LIBS -L/usr/local/lib"
  CXXFLAGS="$CXXFLAGS -I/usr/local/include"
  CFLAGS="$CFLAGS -I/usr/local/include"
fi

dnl Under Darwin we don't have support for -soname option and
dnl we need the -bundle flag. Under Solaris, instead, we need
dnl the options -G -h.

if test "$DARWIN" = yes; then
  LDFLAGS="$LDFLAGS -bundle"
elif test "$SUN" = yes; then
  LDFLAGS="$LDFLAGS -G -h \$(LIBLOAD)"
else
  LDFLAGS="$LDFLAGS -Wl,-soname,\$(LIBLOAD)"
fi

dnl Check to see if in_addr_t is defined.
dnl Could use a specific configure test.

AC_DEFUN(nxconf_INADDRT,
[AC_CACHE_CHECK(for in_addr_t, nxconf_cv_inaddrt,
[AC_TRY_COMPILE([#include <netinet/in.h>],[in_addr_t t; t = 1; return t;],
nxconf_cv_inaddrt=yes, nxconf_cv_inaddrt=no)
rm -f conftest*])
INADDRT=
test "$nxconf_cv_inaddrt" = yes && INADDRT=yes])
nxconf_INADDRT

dnl If in_addr_t is not defined use unsigned int.

if test "$INADDRT" != yes ; then
  echo -e "using unsigned int for type in_addr_t"
  CXXFLAGS="$CXXFLAGS -DIN_ADDR_T=unsigned"
  CFLAGS="$CFLAGS -DIN_ADDR_T=unsigned"
else
  CXXFLAGS="$CXXFLAGS -DIN_ADDR_T=in_addr_t"
  CFLAGS="$CFLAGS -DIN_ADDR_T=in_addr_t"
fi

dnl Check whether --with-version was given.

AC_SUBST(LIBVERSION)
AC_SUBST(VERSION)
if test "${with_version}" = yes; then
  VERSION=${ac_option}
else
  VERSION=`cat VERSION`
fi
echo -e "compiling version ${VERSION}"

LIBVERSION=`echo ${VERSION} | cut -d '.' -f 1`

CXXFLAGS="$CXXFLAGS -DVERSION=\\\"${VERSION}\\\""
CFLAGS="$CFLAGS -DVERSION=\\\"${VERSION}\\\""

dnl Check whether --with-static-png was given and
dnl add -lpng or libpng.a to linking.

if test "${with_static_png}" = yes; then
  echo -e "enabling static linking of PNG library"
  if test "$SUN" = yes && test -f "/usr/sfw/lib/libpng.a"; then
    LIBSTATIC="$LIBSTATIC /usr/sfw/lib/libpng.a"
  else
    if test -f "/usr/lib/libpng.a" ; then
      LIBSTATIC="$LIBSTATIC /usr/lib/libpng.a"
    else
      if test -f "/usr/local/lib/libpng.a" ; then
        echo -e "assuming libpng.a in /usr/local/lib"
        LIBSTATIC="$LIBSTATIC /usr/local/lib/libpng.a"
      else
        echo -e "Warning: assuming libpng.a in the local path"
        LIBSTATIC="$LIBSTATIC libpng.a"
      fi
    fi
  fi
else
  echo -e "enabling dynamic linking of PNG library"
  LIBSHARED="$LIBSHARED -lpng"
fi

dnl Check whether --with-static-jpeg was given and
dnl add -ljpeg or libjpeg.a to linking.

if test "${with_static_jpeg}" = yes; then
  echo -e "enabling static linking of JPEG library"
  if test "$SUN" = yes && test -f "/usr/sfw/lib/libjpeg.a"; then
    LIBSTATIC="$LIBSTATIC /usr/sfw/lib/libjpeg.a"
  else
    if test -f "/usr/lib/libjpeg.a" ; then
      LIBSTATIC="$LIBSTATIC /usr/lib/libjpeg.a"
    else
      if test -f "/usr/local/lib/libjpeg.a" ; then
        echo -e "assuming libjpeg.a in /usr/local/lib"
        LIBSTATIC="$LIBSTATIC /usr/local/lib/libjpeg.a"
      else
        echo -e "Warning: assuming libjpeg.a in the local path"
        LIBSTATIC="$LIBSTATIC libjpeg.a"
      fi
    fi
  fi
else
  echo -e "enabling dynamic linking of JPEG library"
  LIBSHARED="$LIBSHARED -ljpeg"
fi

dnl Check whether --with-static-z was given and
dnl add -lz or libz.a to linking.

if test "${with_static_z}" = yes; then
  echo -e "enabling static linking of Z library"
  if test "$SUN" = yes && test -f "/usr/sfw/lib/libz.a"; then
    LIBSTATIC="$LIBSTATIC /usr/sfw/lib/libz.a"
  else
    if test -f "/usr/lib/libz.a" ; then
      LIBSTATIC="$LIBSTATIC /usr/lib/libz.a"
    else
      if test -f "/usr/local/lib/libz.a" ; then
        echo -e "assuming libz.a in /usr/local/lib"
        LIBSTATIC="$LIBSTATIC /usr/local/lib/libz.a"
      else
        echo -e "Warning: assuming libz.a in the local path"
        LIBSTATIC="$LIBSTATIC libz.a"
      fi
    fi
  fi
else
  echo -e "enabling dynamic linking of Z library"
  LIBSHARED="$LIBSHARED -lz"
fi

dnl Finally compose the LIB variable.

if test "$DARWIN" = yes ; then
  LIBS="$LIBS $LIBSTATIC $LIBSHARED"
elif test "$SUN" = yes ; then
  LIBS="$LIBS $LIBSTATIC $LIBSHARED"
else
  LIBS="$LIBS $LIBSTATIC -shared $LIBSHARED"
fi

dnl Check whether --with-symbols or --without-symbols was
dnl given and set the required optimization level.

if test "${with_symbols}" = yes; then
  echo -e "enabling production of debug symbols"
  CXXFLAGS="-g $CXXFLAGS"
  CFLAGS="-g $CFLAGS"
else
  echo -e "disabling production of debug symbols"
fi

dnl Check whether --with-use-malloc or --without-use-malloc
dnl was given.

if test "${with_use_malloc}" = yes; then
  echo -e "disabling use of the STL allocators"
  CXXFLAGS="$CXXFLAGS -D__USE_MALLOC"
else
  echo -e "enabling use of the STL allocators"
fi

dnl Check whether --with-info or --without-info was given.

if test "${with_info}" = yes; then
  echo -e "enabling info output in the log file"
  CXXFLAGS="$CXXFLAGS -DINFO"
  CFLAGS="$CFLAGS -DINFO"
else
  echo -e "disabling info output in the log file"
fi

dnl Check whether --with-valgrind or --without-valgrind was given.

if test "${with_valgrind}" = yes; then
  echo -e "enabling valgrind memory checker workarounds"
  CXXFLAGS="$CXXFLAGS -DVALGRIND"
  CFLAGS="$CFLAGS -DVALGRIND"
else
  echo -e "disabling valgrind memory checker workarounds"
fi

dnl Find makedepend somewhere.

AC_SUBST(MAKEDEPEND)

if test -x "../nx-X11/config/makedepend/makedepend" ; then
  MAKEDEPEND=../nx-X11/config/makedepend/makedepend
else
  if test -x "/usr/X11R6/bin/makedepend" ; then
    MAKEDEPEND=/usr/X11R6/bin/makedepend
  else
    if test -x "/usr/openwin/bin/makedepend" ; then
      MAKEDEPEND=/usr/openwin/bin/makedepend
    else
      MAKEDEPEND=/usr/bin/makedepend
    fi
  fi
fi

dnl Determine what to build based on the platform.
dnl Override the LIBS settings on Cygwin32 so that
dnl we always link with the exact set of libraries.

AC_SUBST(ALL)

if test "$CYGWIN32" = yes; then
    ALL="\$(LIBCYGARCHIVE) \$(LIBCYGSHARED) \$(LIBARCHIVE)"
    LIBS="-lstdc++ -lpng -ljpeg -lz"
else
    ALL="\$(LIBFULL) \$(LIBLOAD) \$(LIBSHARED) \$(LIBARCHIVE)"
fi

AC_OUTPUT(Makefile)