dnl
dnl autoconf input for wmCoinCoin
dnl rcsid=$id$
dnl ChangeLog: 
dnl   $Log: configure.ac,v $
dnl   Revision 1.45  2005/09/27 16:59:13  pouaite
dnl   2.5.1c
dnl
dnl   Revision 1.44  2005/09/26 21:40:24  pouaite
dnl   v 2.5.1b
dnl
dnl   Revision 1.43  2005/09/25 12:08:55  pouaite
dnl   ca marche encore ca ?
dnl
dnl   Revision 1.42  2005/06/11 22:47:39  pouaite
dnl   prout?
dnl
dnl   Revision 1.41  2005/02/22 18:44:43  pouaite
dnl   *** empty log message ***
dnl
dnl   Revision 1.40  2004/05/16 12:54:28  pouaite
dnl   250c
dnl
dnl   Revision 1.39  2004/04/28 22:18:57  pouaite
dnl   bugfixes dae + des trucs que j'ai oublie
dnl
dnl   Revision 1.38  2004/04/26 20:32:15  pouaite
dnl   roger demande le commit
dnl
dnl   Revision 1.37  2004/04/18 15:37:27  pouaite
dnl   un deux un deux
dnl
dnl   Revision 1.36  2004/03/07 13:51:11  pouaite
dnl   commit du dimanche
dnl
dnl   Revision 1.35  2004/02/29 19:01:26  pouaite
dnl   et hop
dnl
dnl   Revision 1.34  2004/02/29 15:01:18  pouaite
dnl   May the charles bronson spirit be with you
dnl
dnl   Revision 1.33  2003/08/26 21:50:47  pouaite
dnl   2.6.4b au mastic
dnl
dnl   Revision 1.32  2003/07/20 22:22:27  pouaite
dnl   ce commit est dedie a Pierre Tramo
dnl
dnl   Revision 1.31  2003/06/29 23:58:35  pouaite
dnl   suppression de l'overrideredirect du palmi et ajout de pinnipede_totoz.c et wmcoincoin-totoz-get etc
dnl
dnl   Revision 1.30  2003/06/25 20:18:21  pouaite
dnl   support xinerama qui marche
dnl
dnl   Revision 1.29  2003/06/23 22:43:46  pouaite
dnl   shift-enter pour le post anonyme + fix ouinouin
dnl
dnl   Revision 1.28  2003/06/22 12:17:17  pouaite
dnl   2.4.5a a la piscine
dnl
dnl   Revision 1.27  2003/06/21 14:48:44  pouaite
dnl   g cho
dnl
dnl   Revision 1.26  2003/05/07 18:44:55  pouaite
dnl   bugfix divers+solaris7
dnl
dnl   Revision 1.25  2003/03/12 21:09:35  pouaite
dnl   mega patch de gle + micro fix du referer
dnl
dnl   Revision 1.24  2003/03/11 23:40:32  pouaite
dnl   rajout fake-getaddrinfo .. si ça compile alors cygwin remarche (pas testé)
dnl
dnl   Revision 1.23  2003/03/06 20:24:08  pouaite
dnl   cygwin remarche, ou pas
dnl
dnl   Revision 1.22  2003/03/02 17:56:25  pouaite
dnl   wmcoincoin-2.4.4a.tar.gz is ready for distribution
dnl
dnl   Revision 1.21  2003/03/02 16:45:22  pouaite
dnl   autoconferies
dnl
dnl   Revision 1.20  2003/03/02 14:41:21  pouaite
dnl   ce commit est dédié à la mémoire de jacques martin
dnl
dnl   Revision 1.19  2003/02/28 19:08:42  pouaite
dnl   trucs divers
dnl
dnl   Revision 1.18  2003/01/19 18:52:20  pouaite
dnl   patch gle (couleur de fond du palmi)
dnl
dnl   Revision 1.17  2003/01/12 18:42:17  pouaite
dnl   et une baguette bien cuite pour le monsieur avec l'ornythorinque
dnl
dnl   Revision 1.16  2003/01/11 17:44:10  pouaite
dnl   ajout de stats/coinping sur les sites
dnl
dnl   Revision 1.15  2003/01/11 14:10:06  pouaite
dnl   fix du palmi pour xf 4.3
dnl
dnl   Revision 1.14  2002/12/20 17:40:48  pouaite
dnl   ornythorinque en gelée
dnl
dnl   Revision 1.13  2002/12/20 15:49:51  pouaite
dnl   prout 2.4.2b ?
dnl
dnl   Revision 1.12  2002/12/20 11:26:35  pouaite
dnl   deux trois conneries
dnl
dnl   Revision 1.11  2002/11/30 00:10:38  pouaite
dnl   2.4.2a
dnl
dnl   Revision 1.10  2002/10/16 20:41:44  pouaite
dnl   killall toto
dnl
dnl   Revision 1.9  2002/10/05 18:08:13  pouaite
dnl   ajout menu contextuel + fix de la coloration des boutons du wmccc
dnl
dnl   Revision 1.8  2002/09/22 23:16:33  pouaite
dnl   i had a friend, but he does not move anymore
dnl
dnl   Revision 1.7  2002/09/08 18:44:07  pouaite
dnl   mouaissssss
dnl
dnl   Revision 1.6  2002/09/08 18:21:25  pouaite
dnl   microfix pou cygwin + compil
dnl
dnl   Revision 1.5  2002/09/08 14:28:44  pouaite
dnl   bugfixes salutaires
dnl
dnl   Revision 1.4  2002/09/07 16:21:15  pouaite
dnl   ça va releaser en douce
dnl
dnl   Revision 1.3  2002/09/03 22:42:17  pouaite
dnl   coin
dnl
dnl   Revision 1.2  2002/08/31 21:26:46  pouaite
dnl   ajout du wmccc
dnl
dnl   Revision 1.1  2002/08/22 20:04:16  pouaite
dnl   fin de la premiere manche contre gettextize
dnl
dnl   Revision 1.30  2002/08/18 19:00:27  pouaite
dnl   plop
dnl
dnl   Revision 1.29  2002/08/17 18:33:37  pouaite
dnl   grosse commition
dnl
dnl   Revision 1.28  2002/06/26 22:19:48  pouaite
dnl   ptit fix pour la tribune de f-cpu + patch de lordoric
dnl
dnl   Revision 1.27  2002/06/23 14:01:36  pouaite
dnl   ouups, j'avais flingué les modifs depuis la v2.3.8b
dnl
dnl   Revision 1.26  2002/06/23 10:44:05  pouaite
dnl   i18n-isation of the coincoin(kwakkwak), thanks to the incredible jjb !
dnl
dnl   Revision 1.24  2002/06/02 12:37:36  pouaite
dnl   fix gethostbyname --> version 2.3.8b
dnl
dnl   Revision 1.23  2002/06/01 20:21:18  pouaite
dnl   version 2.3.8a
dnl
dnl   Revision 1.22  2002/06/01 17:54:04  pouaite
dnl   nettoyage
dnl
dnl   Revision 1.21  2002/05/29 22:38:12  pouaite
dnl   bidouilles dans configure.in et cie
dnl
dnl   Revision 1.20  2002/05/13 10:51:46  pouaite
dnl   bugfix lecture xpm
dnl
dnl   Revision 1.19  2002/04/26 23:25:38  pouaite
dnl   v2.3.7b
dnl
dnl   Revision 1.18  2002/04/23 23:16:29  pouaite
dnl   \o/ j'ai enfin réussi à chopper le bug mysterieux de l'autoscroll du pinni \o/
dnl
dnl   Revision 1.17  2002/04/14 23:24:21  pouaite
dnl   re-fix pour kde ..
dnl
dnl   Revision 1.16  2002/04/09 00:28:19  pouaite
dnl   quelques modifs faites dans un état d'hébétude avancé /!\ travaux en cours /!\
dnl
dnl   Revision 1.15  2002/03/18 22:46:49  pouaite
dnl   1 ou 2 bugfix mineurs, et surtout suppression de la dependance avec la libXpm .. un premier pas vers wmc² en 8bits
dnl
dnl   Revision 1.14  2002/03/10 16:07:10  pouaite
dnl   pseudo transp basique dans le pinnipede (en cours..)
dnl
dnl   Revision 1.13  2002/03/09 19:45:52  pouaite
dnl   microbugfix du plopifieur et ajout d'une macro PATCH_LEVEL
dnl
dnl   Revision 1.12  2002/03/08 23:53:40  pouaite
dnl   derniers bugfixes pour la v2.3.6
dnl
dnl   Revision 1.11  2002/03/05 21:04:28  pouaite
dnl   bugfixes suite à l'upgrade de dlfp [et retour au comportement à l'ancienne du clic sur les horloges pour les moules ronchonnes]
dnl
dnl   Revision 1.10  2002/02/24 22:13:56  pouaite
dnl   modifs pour la v2.3.5 (selection, scrollcoin, plopification, bugfixes)
dnl
dnl   Revision 1.9  2002/01/30 21:03:45  pouaite
dnl   correction du bug du au signe des char, et d'un petit bug dans les reference d'horloges
dnl
dnl   Revision 1.8  2002/01/20 20:53:22  pouaite
dnl   bugfix configure.in && http_win.c pour cygwin + 2-3 petis trucs
dnl
dnl   Revision 1.7  2002/01/13 20:38:31  pouaite
dnl   fix du configure.in qui detecte cygwin a tors et à travers avec les v. recentes de autoconf
dnl
dnl   Revision 1.6  2002/01/10 09:03:07  pouaite
dnl   integration du patch de glandium (requetes http/1.1 avec header 'If-Modified-Since' --> coincoin plus gentil avec dacode)
dnl
dnl   Revision 1.5  2002/01/03 22:15:31  pouaite
dnl   patch top moumoute de glandium pour la gestion du wiki
dnl
dnl   Revision 1.4  2001/12/17 18:11:07  pouaite
dnl   attention chérie ça va releaser
dnl
dnl   Revision 1.3  2001/12/16 01:43:33  pouaite
dnl   filtrage des posts, meilleure gestion des posts multiples
dnl
dnl   Revision 1.2  2001/12/02 18:32:05  pouaite
dnl   update suite à la modif sur http.c et a la generation automatique de src/default*.h
dnl

AC_INIT(wmcoincoin, 2.6.4-git, triton@kumal.info)
AC_CONFIG_SRCDIR([src/wmcoincoin.c])

AC_PREREQ(2.52)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)

dnl Checks for host/os name
dnl =======================
AC_CANONICAL_HOST
COIN_ARCH="${host_cpu}-${host_vendor}-${host_os}"
AC_SUBST(COIN_ARCH)
case $host_os in
  *cygwin* ) CYGWIN=yes; EXEEXT=".exe";;
         * ) CYGWIN=no; EXEEXT="";;
esac

dnl internationalization macros
ALL_LINGUAS="fr"
AM_GNU_GETTEXT
AM_GNU_GETTEXT_VERSION([0.17])



dnl Checks for programs.
dnl ===================
AC_PROG_CC
AC_ISC_POSIX


dnl don't want the -g flag
dnl update: jjb< do want the -g flag
dnl CFLAGS=`echo "x $CFLAGS"|sed 's/^x //; s/\(^\| \)-g\($\| \)/ /g'`


dnl based on http://www.gnu.org/software/ac-archive/htmldoc/ac_check_cc_opt.html
dnl from Guido Draheim <guidod@gmx.de>
AC_DEFUN([AC_CHECK_CC_FLAG],
[AC_MSG_CHECKING([whether ${CC} accepts [$1] ])

echo 'int main(){}' > conftest.c
if test -z "`${CC} $1 -o conftest conftest.c 2>&1`"; then
  $2="${$2} $1"
  echo "yes"
else
  echo "no"
fi
dnl echo "$2=${$2}"
rm -f conftest*
])
      

dnl additional compile flags when using gcc
if test x$GCC = xyes; then
  CFLAGS="$CFLAGS -Wall -W -fsigned-char";
dnl  if test x$CYGWIN = xno; then
dnl    LDFLAGS="$LDFLAGS -rdynamic"; dnl juste pour avoir les noms de fonction dans le backtrace /o\
dnl  fi
  AC_CHECK_CC_FLAG([-rdynamic],LDFLAGS)
  AC_CHECK_CC_FLAG([-Wno-pointer-sign],CFLAGS)
else
          echo "Vous n'utilisez pas gcc .. attention coincoin peut avoir quelque bugs si les char ne sont pas signés"
fi

YELLOW="\\033\\1331;33m"
RESET="\\033\\1330m"


AC_PATH_X
AC_PATH_XTRA
echo x_cflags=$X_CFLAGS libs=$LIBS pre_lib=$X_PRE_LIBS x_libs=$X_LIBS x_extra=$X_EXTRA_LIBS

if test x$no_x = xyes; then
  echo "You need to supply the path to the X headers and libraries with --x-includes=dir and --x-libraries=dir";
  exit 1;
fi;

dnl AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,,
dnl  AC_MSG_ERROR(The XPM library is required but wasn't found.),
dnl  $X_LIBS -lX11 -lXext)


LIBS="${X_PRE_LIBS} ${X_LIBS} -lX11 -lXext -lXmu ${LIBS} ${X_EXTRA_LIBS} -lfreetype"
CFLAGS="$CFLAGS $X_CFLAGS"
dnl  -I/usr/include/X11/Xft -I/usr/include/freetype2"

dnl le PKG_CONFIG_PATH pour cygwin qui est un peu con
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/X11R6/lib/pkgconfig
PKG_CHECK_MODULES(XFT, [xft])
AC_SUBST(XFT_CFLAGS)
AC_SUBST(XFT_LIBS)

dnl XINERAMA support (stolen from wmaker)
dnl ================
xinerama=yes
AC_ARG_ENABLE(xinerama, 
[  --disable-xinerama	  disable XInerama extension support],
		xinerama=$enableval, xinerama=yes)
if test x$xinerama = xyes; then
	AC_CHECK_LIB(Xinerama, XineramaQueryScreens, [LIBS="-lXinerama $LIBS"
                AC_DEFINE([XINERAMA],1,[define if xinerama API is supported])], xinerama=no)
fi




build_wmccc="yes"
AC_ARG_ENABLE(wmccc,
 [  --enable-wmccc        Builds the wmccc (requires gtk2), the graphical wmcoincoin configuration tool (Default is yes)
  --disable-wmccc         Do not build wmccc],
 [ if   test "x$enableval" = "xno" ; then
	build_wmccc="no"
	echo you disabled wmccc
   fi
 ], [build_wmccc="yes"])

build_wmcc_player="yes"
AC_ARG_ENABLE(wmcoincoin_player,
 [  --enable-wmcoincoin_player Builds the wmcoincoin_player (requires imlib2) (viewer for totoz.eu pictures)
  --disable-wmcoincoin_player  Do not build wmcoincoin_player],
 [ if   test "x$enableval" = "xno" ; then
	build_wmcc_player="no"
	echo you disabled wmcoincoin_player
   fi
 ], [build_wmcc_player="yes"])

if test "x$build_wmccc" = "xno"; then
  echo wmccc disabled...
  WMCCC=""
else
  echo building with WMCCC, checking for gtk..
dnl si le test sur gtk ne passe pas (solaris... ?), il suffit de comment la ligne am_path_gtk et de decommenter les 4 lignes suivantes
dnl GTK_CFLAGS="`gtk-config --cflags`"
dnl GTK_LIBS="`gtk-config --libs`"
dnl AC_SUBST(GTK_CFLAGS)
dnl AC_SUBST(GTK_LIBS)
  pkg_modules="gtk+-2.0 >= 2.0.0"
  PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])

  GTK_CFLAGS=$PACKAGE_CFLAGS;
  GTK_LIBS=$PACKAGE_LIBS;
  AC_SUBST(GTK_CFLAGS)
  AC_SUBST(GTK_LIBS)

  dnl Add the languages which your application supports here.
        dnl  ALL_LINGUAS=""
        dnl  AM_GLIB_GNU_GETTEXT

  dnl AM_PATH_GTK(1.2.0, , AC_MSG_ERROR(Cannot find GTK: Is gtk-config in path? If you dont have gtk you wont be able to build the wmccc try running configure with --disable-wmccc))
  WMCCC="wmccc$EXEEXT"
fi
AC_SUBST(WMCCC)

dnl AC_DEFINE([PACKAGE_DATA_DIR], [], [data directory for wmcc])
dnl AC_DEFINE([PACKAGE_SOURCE_DIR], [], [source directory for wmcc])

dnl Set PACKAGE_DATA_DIR in config.h.
dnl if test "x${datadir}" = 'x${prefix}/share'; then
dnl  if test "x${prefix}" = "xNONE"; then
dnl    AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}")
dnl  else
dnl    AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/share/${PACKAGE}")
dnl  fi
dnl else
dnl  AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${datadir}/${PACKAGE}")
dnl fi

dnl Checks for library functions.
dnl ============================
AC_FUNC_VPRINTF
AC_CHECK_HEADERS(string.h stdarg.h unistd.h sys/time.h utime.h sys/utime.h)
AC_CHECK_HEADERS(sys/select.h sys/utsname.h pwd.h signal.h windows.h)
AC_CHECK_HEADERS(inttypes.h unistd.h)
AC_HEADER_TIME
AC_CHECK_FUNCS(strdup strstr strcasecmp strncasecmp)
AC_CHECK_FUNCS(strerror snprintf vsnprintf select signal)
AC_CHECK_FUNCS(uname)


dnl NOTE POUR PLUS TARD:
dnl en l'an de grace 2005, le 23 mai, je, soussigné pouaite, ai pris
dnl la decision de commenter les quatre AC_DEFINE du dessous, sur le 
dnl conseil de la moule nommee "twolife" (qui est un macqueux tiger-ophile).

dnl AC_DEFINE_UNQUOTED(uint8_t, unsigned char,[unsigned 8 bits integers])
dnl AC_DEFINE_UNQUOTED(uint16_t, unsigned short,[unsigned 16 bits integers])
dnl AC_DEFINE_UNQUOTED(uint32_t, unsigned int, [unsigned 32 bits integers])
dnl AC_DEFINE_UNQUOTED(int32_t, int, [signed 32 bits integers])

dnl les fonctions bidon pour cygouin
dnl AC_CHECK_LIB(ws2_32, getaddrinfo, LIBS="-lws2_32 $LIBS")
AC_CHECK_FUNCS(getaddrinfo freeaddrinfo gai_strerror getnameinfo inet_aton)

AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM


dnl those two tests were taken from openssh-3.5p1
AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
	AC_TRY_COMPILE(
		[
#ifdef HAVE_WINDOWS_H
#include <winsock2.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#endif
		],
		[ struct sockaddr_storage s; ],
		[ ac_cv_have_struct_sockaddr_storage="yes" ],
		[ ac_cv_have_struct_sockaddr_storage="no" ]
	)
])
if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE,1,[struct sockaddr])
fi
AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
	AC_TRY_COMPILE(
		[
#ifdef HAVE_WINDOWS_H
#include <winsock2.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#endif
	],
		[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
		[ ac_cv_have_struct_addrinfo="yes" ],
		[ ac_cv_have_struct_addrinfo="no" ]
	)
])
if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
	AC_DEFINE(HAVE_STRUCT_ADDRINFO,1,[struct addrinfo])
fi

AC_CACHE_CHECK([for execinfo.h and backtrace], ac_have_backtrace, [
        AC_TRY_COMPILE(
                [ #include <execinfo.h>       
                ],
                [ void* trace[256]; int n = backtrace(trace, 256); ],
                [ ac_have_backtrace="yes" ],
                [ ac_have_backtrace="no"  ])])
if test "x$ac_have_backtrace" = "xyes"; then
        AC_DEFINE(HAVE_BACKTRACE,1,[glibc backtrace function])
fi;     

WMCOINCOIN_PLAYER=""
if test "x$build_wmcc_player" = "xyes"; then
  AC_CHECK_PROG([IMLIB2_CONFIG_IN_PATH],[imlib2-config],[yes],[no])
  if test "x$IMLIB2_CONFIG_IN_PATH" = "xno"; then
        echo " *********************** YOU ARE NOT READY FOR THE DESKTOP ***********************"
        echo " * no arms                              ==> no chocolate                         *"
        echo " * imlib2-config was not found in path  ==> wmcoincoin_player will not be built. *"
        echo " ************************* Thank you for your attention **************************"
        build_wmcc_player="no"
  else
        AC_DEFINE(HAVE_IMLIB2,1,[use imlib2 for the player])
        WMCOINCOIN_PLAYER="wmcoincoin_player${EXEEXT}"
        build_wmcc_player="yes"
        AC_DEFINE(HAVE_WMCOINCOIN_PLAYER,1,[wmcoincoin_player is supported])
  fi
dnl  AC_CHECK_PROG([CURL_IN_PATH],[curl],[yes],[no])
dnl  if test "x$CURL_IN_PATH" = "xno"; then
dnl         echo " *********************** YOU ARE NOT READY FOR THE DESKTOP ***********************"
dnl         echo " * no arms                     ==> no chocolate                                  *"
dnl         echo " * curl was not found in path  ==> wmcoincoin-totoz-get won't work               *"
dnl         echo " *                             ==> wmcoincoin_player will not be built.          *"
dnl         echo " ************************* Thank you for your attention **************************"
dnl         build_wmcc_player="no"
dnl   fi
fi
AC_SUBST([WMCOINCOIN_PLAYER])

YELLOW="\\033\\1331;33m"
RESET="\\033\\1330m"

case "$host" in
    *-linux-*)
          echo -e "\n${YELLOW}you are using GNU/linux, it's Good(c)(tm) !${RESET}\n"
          ;;
    *-solaris*)
          echo -e "\noh oh !! wmcc runs quite well on solaris (even solaris 7 which stinks from the back), good luck !\n"
          ;;
    *bsd*)
          echo -e "\nbsd detected!\n"
	  ;;
    *-cygwin*)
	  echo -e "\n${YELLOW}cygwin detected !, may the force be with you, young mussel${RESET}\n"
     	  AC_CHECK_LIB(wsock32,select)
	  dnl correct a bug in cygwin: incorrect regex included in -lm
	  LIBS="`echo ${LIBS} | sed -e 's/-lm//'`"
	  LIBS="${LIBS} -liconv -lm"        
	  ;;
    *-darwin*)
          echo -e "\n${YELLOW}darwin detected, vilain macounet !${RESET}\n"
	  dnl LDFLAGS="`echo ${LDFLAGS} | sed -e 's/-rdynamic//'`"
          ;;
    *GNU*)
	  echo -e "\n${YELLOW}GNU/Hurd ! you need to shave yourself${RESET}\n"
	  ;;
    *hpux*)
          echo "HPUX detected !! you are hairy"
          ;;
    *)
	  echo -e "\n${YELLOW}you are compiling on $host , it's original${RESET}\n"
         ;;
esac

AC_CONFIG_FILES([Makefile intl/Makefile po/Makefile.in m4/Makefile src/Makefile scripts/Makefile platypus/Makefile])
AC_CONFIG_COMMANDS([default],[[ echo timestamp > stamp-h ]],[[]])
AC_OUTPUT

if test "x$build_wmccc" = "xno"; then
  echo "    **** I recall you that you choosed to disable wmccc ****"
else
  echo "    wmcc will be built with wmccc"
fi
if test "x$build_wmcc_player" = "xno"; then
  echo "    **** I recall you that wmcoincoin_player won't be built ****"
else
  echo "    wmcc will be built with wmcoincoin_player"
fi
