]> git.saurik.com Git - wxWidgets.git/blobdiff - configure.in
min/max -> wxMin/wxMax
[wxWidgets.git] / configure.in
index 091bad732f36f778620ceb8838bd0e861d938f6c..3f64ad4ccdab1f6cb8d1df9c1cd9c9952bedf7ca 100644 (file)
@@ -148,6 +148,8 @@ esac
 if test "$USE_UNIX" = 1 ; then
   wxUSE_UNIX=yes
   AC_DEFINE(__UNIX__)
+  EXTRA_VPATH="$EXTRA_VPATH:\$(srcdir)/unix"
+  INCLUDE_SUBDIRS="$INCLUDE_SUBDIRS unix"
 fi
 
 dnl Linux: test for libc5/glibc2: glibc2 has gettext() included
@@ -371,13 +373,13 @@ AC_ARG_WITH(gtk-prefix,        [  --with-gtk-prefix=PFX   prefix where GTK is in
 AC_ARG_WITH(gtk-exec-prefix,    [  --with-gtk-exec-prefix=PFX  exec prefix where GTK is installed],
             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
 AC_ARG_WITH(gtk,        [  --with-gtk              use GTK+],
-            wxUSE_GTK="$withval",wxUSE_GTK=0)
+            [wxUSE_GTK="$withval" TOOLKIT_GIVEN=1])
 AC_ARG_WITH(motif,        [  --with-motif            use Motif/Lesstif],
-            wxUSE_MOTIF="$withval",wxUSE_MOTIF=0)
+            [wxUSE_MOTIF="$withval" TOOLKIT_GIVEN=1])
 AC_ARG_WITH(cygwin,        [  --with-cygwin           use Cygwin for MS-Windows],
-            wxUSE_CYGWIN="$withval",wxUSE_CYGWIN=0)
+            [wxUSE_CYGWIN="$withval" TOOLKIT_GIVEN=1])
 AC_ARG_WITH(mingw,        [  --with-mingw            use GCC Minimal MS-Windows],
-            wxUSE_MINGW="$withval",wxUSE_MINGW=0)
+            [wxUSE_MINGW="$withval" TOOLKIT_GIVEN=1])
 
 AC_ARG_WITH(dmalloc,        [  --with-dmalloc          use dmalloc library (www.letters.com/dmalloc)],
             wxUSE_DMALLOC="$withval",wxUSE_DMALLOC=$DEFAULT_wxUSE_DMALLOC)
@@ -406,6 +408,17 @@ AC_ARG_ENABLE(optimise,        [  --enable-optimise       create optimised code]
             wxUSE_OPTIMISE="$enableval",wxUSE_OPTIMISE=$DEFAULT_wxUSE_OPTIMISE)
 AC_ARG_ENABLE(optimize,        [  --enable-optimize       create optimized code],
             wxUSE_OPTIMISE="$enableval",wxUSE_OPTIMISE=$DEFAULT_wxUSE_OPTIMISE)
+AC_ARG_ENABLE(debug, [  --enable-debug          same as debug_flag and debug_info],
+            wxUSE_DEBUG="${enableval}",wxUSE_DEBUG=$DEFAULT_wxUSE_DEBUG)
+
+if test "$wxUSE_DEBUG" = "yes"; then
+  DEFAULT_wxUSE_DEBUG_FLAG=yes
+  DEFAULT_wxUSE_DEBUG_INFO=yes
+elif test "$wxUSE_DEBUG" = "no"; then
+  DEFAULT_wxUSE_DEBUG_FLAG=no
+  DEFAULT_wxUSE_DEBUG_INFO=no
+fi
+
 AC_ARG_ENABLE(debug_flag,    [  --enable-debug_flag     set __WXDEBUG__ flag (recommended for developers!)],
             wxUSE_DEBUG_FLAG="$enableval",wxUSE_DEBUG_FLAG=$DEFAULT_wxUSE_DEBUG_FLAG)
 AC_ARG_ENABLE(debug_info,    [  --enable-debug_info     create code with debugging information],
@@ -664,7 +677,19 @@ AC_ARG_ENABLE(validators, [  --enable-validators     use wxValidator and derived
 
 dnl check that no more than one toolkit is given and that if none are given that
 dnl we have a default one
-dnl
+
+if test "$TOOLKIT_GIVEN" = 1; then
+  dnl convert "yes" to 1 and "no" to 0
+  wxUSE_GTK=`echo $wxUSE_GTK | sed -e 's/yes/1/' -e 's/no/0/'`
+  wxUSE_MOTIF=`echo $wxUSE_MOTIF | sed -e 's/yes/1/' -e 's/no/0/'`
+  wxUSE_MSW=`echo $wxUSE_MSW | sed -e 's/yes/1/' -e 's/no/0/'`
+else
+  dnl try to guess the most apropriate toolkit for this platform
+  wxUSE_GTK=$DEFAULT_wxUSE_GTK
+  wxUSE_MOTIF=$DEFAULT_wxUSE_MOTIF
+  wxUSE_MSW=$DEFAULT_wxUSE_MSW
+fi
+
 dnl NB: this supposes that the shell is able to handle arithmetic expansion and
 dnl     the ${VAR:-VALUE} construction. It does simplify our life though...
 NUM_TOOLKITS="$((${wxUSE_GTK:-0}+${wxUSE_MOTIF:-0}+${wxUSE_MSW:-0}))"
@@ -673,13 +698,7 @@ case "$NUM_TOOLKITS" in
   1)
   ;;
   0)
-    if test "$((${DEFAULT_wxUSE_GTK:-0}+${DEFAULT_wxUSE_MOTIF:-0}+${DEFAULT_wxUSE_MSW:-0}))" = 0; then
-      AC_MSG_ERROR(Please specify a toolkit)
-    fi
-
-    wxUSE_GTK=$DEFAULT_wxUSE_GTK
-    wxUSE_MOTIF=$DEFAULT_wxUSE_MOTIF
-    wxUSE_MSW=$DEFAULT_wxUSE_MSW
+    AC_MSG_ERROR(Please specify a toolkit)
   ;;
   *)
     AC_MSG_ERROR(Please specify at most one toolkit)
@@ -750,10 +769,6 @@ dnl install checks
 dnl   defines INSTALL with the appropriate command
 AC_PROG_INSTALL
 
-dnl does ln -s works
-dnl   defines LN_S with the appropriate command
-AC_PROG_LN_S
-
 dnl strip command
 dnl   defines STRIP as strip or nothing if not found
 AC_CHECK_PROG(STRIP, strip, strip, true)
@@ -805,6 +820,9 @@ dnl   defines LEX_OUTPUT_ROOT as to the base of the
 dnl                           filename output by the lexer
 AM_PROG_LEX
 
+dnl needed for making link to setup.h
+AC_PROG_LN_S
+
 dnl libtool checks (disable static libs by default, this takes too much time...)
 AM_DISABLE_STATIC
 AM_PROG_LIBTOOL
@@ -970,7 +988,7 @@ if test "$wxUSE_MOTIF" = 1; then
         AC_MSG_WARN(library will be compiled without support for images in XPM format)
     fi
 
-    GUI_TK_LINK="-lXm $(XPM_LINK)-lXmu -lXt -lX11 -lm"
+    GUI_TK_LINK="-lXm $XPM_LINK -lXmu -lXt -lX11 -lm"
     GUI_TK_LIBRARY="$CHECK_LIB $GUI_TK_LINK"
     TOOLKIT=MOTIF
 fi
@@ -981,8 +999,8 @@ TOOLKIT_DIR=`echo ${TOOLKIT} | tr "A-Z" "a-z"`
 dnl the symbol which allows conditional compilation for the given toolkit
 TOOLKIT_DEF=-D__WX${TOOLKIT}__
 
-dnl the name (without leading 'wx_') of the library
-WX_LIBRARY=${TOOLKIT_DIR}2
+dnl the name of the (libtool) library
+WX_LIBRARY_NAME="libwx_${TOOLKIT_DIR}2.la"
 
 dnl ------------------------------------------------------------------------
 dnl Check for headers
@@ -1144,7 +1162,6 @@ if test "$wxUSE_THREADS" = "yes"; then
   CXXFLAGS="${CXXFLAGS} -D_REENTRANT"
 
   SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS thread"
-  EXTRA_VPATH="$EXTRA_VPATH:\$(srcdir)/unix"
   LTLIBOBJS="$LTLIBOBJS $THREADS_OBJ"
 
   dnl define autoconf macro to check for given function in both pthread and
@@ -1421,6 +1438,7 @@ if test "$wxUSE_SOCKETS" = "yes" ; then
         AC_DEFINE(wxUSE_SOCKETS)
         LTLIBOBJS="$LTLIBOBJS sckint.lo socket.lo sckaddr.lo protocol.lo http.lo ftp.lo url.lo"
         SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS wxsocket"
+        INCLUDE_SUBDIRS="$INCLUDE_SUBDIRS protocol"
     else
         AC_MSG_WARN(socket classes require --with-threads and won't be compiled without it)
         wxUSE_SOCKETS=0
@@ -1804,9 +1822,10 @@ dnl ---------------------------------------------------------------------------
 dnl misc options
 dnl ---------------------------------------------------------------------------
 
-if test "$wxUSE_WXTREE" = "yes"; then
-  AC_DEFINE(wxUSE_WXTREE)
-fi
+dnl TODO this is unused for now...
+dnl if test "$wxUSE_WXTREE" = "yes"; then
+dnl   AC_DEFINE(wxUSE_WXTREE)
+dnl fi
 
 if test "$wxUSE_METAFILE" = "yes"; then
   AC_DEFINE(wxUSE_METAFILE)
@@ -1864,7 +1883,7 @@ EXTRA_LIBS="$LIBS $POSIX4_LINK $WCHAR_LINK $THREADS_LINK $DMALLOC_LINK $GUILIBS"
 
 dnl all the libraries needed to link wxWindows programs (when the library is not
 dnl yet installed)
-LIBS="\${top_builddir}/src/libwx_${WX_LIBRARY}.la $EXTRA_LIBS"
+LIBS="\${top_builddir}/src/${WX_LIBRARY_NAME} $EXTRA_LIBS"
 
 dnl all -I options we must pass to the compiler
 INCLUDES="$TOOLKIT_INCLUDE $ZLIB_INCLUDE $LIBPNG_INCLUDE -I. -I\${top_builddir}/include -I\${top_srcdir}/include"
@@ -1892,11 +1911,23 @@ if test "$wxUSE_GUI" = "yes"; then
                    forty fractal image wxpoem"
 fi
 
+dnl for convenience, sort the files to build in alphabetical order
+dnl
+dnl another shell command to do it which might be faster but is less clear:
+dnl  LTLIBOBJS="`for obj in $LTLIBOBJS; do echo $obj; done | sort | sed 's@^@ @'`"
+LTLIBOBJS="`echo $LTLIBOBJS | tr -s ' ' | tr ' ' '\n' | sort | tr '\n' ' '`"
+
+dnl for convenience, sort the samples in alphabetical order
+dnl
+dnl FIXME For some mysterious reasons, sometimes the directories are duplicated
+dnl       in this list - hence uniq. But normally, this shouldn't be needed!
+SAMPLES_SUBDIRS="`echo $SAMPLES_SUBDIRS | tr -s ' ' | tr ' ' '\n' | sort | uniq | tr '\n' ' '`"
+
 dnl global options
 AC_SUBST(WX_MAJOR_VERSION_NUMBER)
 AC_SUBST(WX_MINOR_VERSION_NUMBER)
 AC_SUBST(WX_RELEASE_NUMBER)
-AC_SUBST(WX_LIBRARY)
+AC_SUBST(WX_LIBRARY_NAME)
 
 dnl suppress libtool's informational messages - they duplicate its command line
 LIBTOOL="$LIBTOOL --silent"
@@ -1916,6 +1947,7 @@ AC_SUBST(EXTRA_VPATH)
 AC_SUBST(LTLIBOBJS)
 
 dnl additional subdirectories where we will build
+AC_SUBST(INCLUDE_SUBDIRS)
 AC_SUBST(UTILS_SUBDIRS)
 AC_SUBST(DOCS_SUBDIRS)
 AC_SUBST(SAMPLES_SUBDIRS)
@@ -1926,9 +1958,11 @@ AC_SUBST(EXTRA_LIBS)
 AC_SUBST(LIBS)
 
 dnl create the configuration header file from the template
-SETUPH_DIR=include/wx/${TOOLKIT_DIR}
-mkdir -p ${SETUPH_DIR}
-AM_CONFIG_HEADER(${SETUPH_DIR}/setup.h:include/wx/unix/setup.h.in)
+dnl
+dnl NB: automake can't work correctly if our header lives in a directory which
+dnl     is only determined at configure time, so we create it on the top-level
+dnl     and make a link to allow '#include "wx/setup.h"' to still work
+AM_CONFIG_HEADER(setup.h)
 
 dnl MAKE_SET will be replaced with "MAKE=..." or nothing if make sets MAKE
 dnl itself (this is macro is required if SUBDIRS variable is used in Makefile.am
@@ -1939,7 +1973,16 @@ dnl create each of the files in the space separated list from the file.in
 dnl (the original file name may be overriden by appending another name after a
 dnl colon)
 AC_OUTPUT([
-            Makefile src/Makefile wx-config
+            wx-config
+            Makefile src/Makefile
+            include/Makefile
+            include/wx/Makefile
+            include/wx/generic/Makefile
+            include/wx/gtk/Makefile
+            include/wx/motif/Makefile
+            include/wx/msw/Makefile
+            include/wx/protocol/Makefile
+            include/wx/unix/Makefile
             samples/Makefile
             samples/bombs/Makefile
             samples/caret/Makefile
@@ -1989,5 +2032,15 @@ AC_OUTPUT([
             samples/wxpoem/Makefile
             samples/wxsocket/Makefile
           ],
-          [chmod +x wx-config], [SETUPH_DIR=${SETUPH_DIR}])
+          [
+            chmod +x wx-config
+            if test ! -e include/wx/${TOOLKIT_DIR}/setup.h; then
+              ${LN_S} `pwd`/setup.h include/wx/${TOOLKIT_DIR}/setup.h
+            fi
+          ],
+          [
+            LN_S="${ac_cv_prog_LN_S}"
+            TOOLKIT_DIR="${TOOLKIT_DIR}"
+          ]
+         )