1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4# Copyright (c) 2002  Leon Bottou and Yann Le Cun. (DjVuLibre-3.5)
5# Copyright (c) 2001  AT&T (DjVuLibre-3.5)
6# Copyright (C) 2007, 2008, 2009, 2014  Sylvain Beucler
7
8# This file is part of GNU FreeDink
9
10# GNU FreeDink is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 3 of the License, or
13# (at your option) any later version.
14
15# GNU FreeDink is distributed in the hope that it will be useful, but
16# WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18# General Public License for more details.
19
20# You should have received a copy of the GNU General Public License
21# along with this program.  If not, see
22# <http://www.gnu.org/licenses/>.
23
24AC_PREREQ(2.61)
25AC_INIT([DFArc],[3.14],[bug-freedink@gnu.org])
26AC_CONFIG_AUX_DIR(autotools)
27AC_CONFIG_HEADER([config.h])
28AM_INIT_AUTOMAKE([gnits dist-zip])
29# Terse output - use V=1 for verbose output
30AM_SILENT_RULES(yes)
31
32# Define $host $host_os + distributes config.guess and config.sub
33AC_CANONICAL_HOST
34
35# We use wxWidget's internal gettext-compatible functions, calling
36# AM_PO_SUBDIRS directly (otherwise GETTEXT wants intl/ and such):
37##AM_GNU_GETTEXT()
38AM_PO_SUBDIRS()
39# This one is for .desktop files:
40# Note: IT_PROG_INTLTOOL quits if intltool/gettext dependency isn't satisfied :/
41AC_SUBST(GETTEXT_PACKAGE, $PACKAGE_TARNAME)
42IT_PROG_INTLTOOL(0.31, no-xml)
43
44# Checks for programs.
45AC_PROG_CXX
46# TODO: error if CXX cannot be found
47AC_PROG_LN_S
48AC_ARG_VAR([WXGLADE], [Compiler for UI files (.wxg -> .cpp)])
49AC_PATH_PROG(WXGLADE, wxglade)
50if test x"$WXGLADE" = x""; then
51  AC_MSG_WARN([You may need to install wxGlade (if you're a developer)])
52  LACK_WXGLADE=1
53fi
54AM_CONDITIONAL(HAVE_WXGLADE, test "$WXGLADE" != "")
55
56AC_CHECK_TOOL(WINDRES, windres)
57AM_CONDITIONAL(HAVE_WINDRES, test "$WINDRES" != "")
58
59AC_ARG_VAR([UPX], [Produce self-decompressing executables (if --enable-upx)])
60AC_ARG_ENABLE([upx],
61  AS_HELP_STRING([--enable-upx], [compress executables [[default is disabled]]]),
62  [], [enable_upx=no])
63if test x"$enable_upx" = x"yes"; then
64  AC_PATH_PROG(UPX, upx)
65fi
66AM_CONDITIONAL(HAVE_UPX, test "$UPX" != "")
67
68
69# Dynamic and static builds
70# Dynamic and static builds
71AC_ARG_ENABLE([static],
72  AS_HELP_STRING([--enable-static],[embed wxWidgets and libbz2 in the executable (mingw32 only) [[default is disabled]]]),
73  [], [enable_static=no])
74
75if test x"$enable_static" = x"yes"; then
76    case "${host}" in
77    # (cf. (autoconf.info)Using System Type)
78    # Modified to accept "biplet" instead of "triplet", because at
79    # least Debian's MinGW package uses i586-mingw32msvc (instead of
80    # i586-pc-mingw32msvc)
81    *-*-go32* | *-mingw32* | *-*-cygwin* | *-*-windows*)
82        LDFLAGS="$LDFLAGS -static"
83        ;;
84    esac
85fi
86# TODO: check with Cygwin + -mno-cygwin
87
88
89
90# ----------------------------------------
91# Desktop files
92# ----------------------------------------
93# (inspired by djvulibre's configure.ac)
94
95ac_desktopfiles=yes
96AC_ARG_ENABLE(desktopfiles,
97    AS_HELP_STRING([--disable-desktopfiles],[Do not install scripts to register icons and menus.]),
98    [ac_desktopfiles=$enableval])
99
100# Check for xdg tools
101AC_PATH_PROG(XDG_MIME, xdg-mime)
102AC_PATH_PROG(XDG_ICON_RESOURCE, xdg-icon-resource)
103AC_PATH_PROG(XDG_DESKTOP_MENU, xdg-desktop-menu)
104if test -x "${XDG_MIME}" && \
105   test -x "${XDG_ICON_RESOURCE}" && \
106   test -x "${XDG_DESKTOP_MENU}"
107then
108  true
109elif test "$ac_desktopfiles" != no ; then
110  ac_desktopfiles=no
111  AC_MSG_WARN([Cannot find the Xdg Portland tools.
112--------------------------------------------------------
113*** The scripts to register icons and menus
114*** will not be installed.
115--------------------------------------------------------])
116fi
117
118AM_CONDITIONAL(HAVE_XDG, test "${ac_desktopfiles}" != "no")
119
120
121# Checks for libraries.
122AC_CHECK_LIB([bz2], [BZ2_compressBlock],,AC_MSG_WARN([You need to install libbz2]); LACK_LIBBZ2=1)
123
124# http://www.wxwidgets.org/wiki/index.php/Autoconf
125AM_OPTIONS_WXCONFIG
126reqwx=3.0.0
127if test x"$enable_static" = x"yes"; then
128# Not using $WX_LIBS_STATIC (deprecated anyway) because CFLAGS also
129# change, using '--static' instead:
130AM_PATH_WXCONFIG($reqwx, [wxWin=1], [wxWin=0], [core], [--static])
131else
132AM_PATH_WXCONFIG($reqwx, [wxWin=1], [wxWin=0], [core], [])
133fi
134
135if test "$wxWin" != 1; then
136	AC_MSG_ERROR([
137		wxWidgets must be installed on your system.
138
139		Please check that wx-config is in path, the directory
140		where wxWidgets libraries are installed (returned by
141		'wx-config --libs' or 'wx-config --static --libs' command)
142		is in LD_LIBRARY_PATH or equivalent variable and
143		wxWidgets version is $reqwx or above.
144		])
145fi
146
147CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
148CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
149CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
150LIBS="$LIBS $WX_LIBS"
151
152# <from autoscan>
153# Checks for header files.
154AC_HEADER_DIRENT
155
156# Checks for typedefs, structures, and compiler characteristics.
157AC_HEADER_STDBOOL
158AC_C_CONST
159AC_C_INLINE
160AC_TYPE_SIZE_T
161
162# Checks for library functions.
163#AC_FUNC_MALLOC
164AC_HEADER_STDC
165AC_FUNC_STAT
166AC_CHECK_FUNCS([memset pow])
167# </from autoscan>
168
169# Efficient I/O block size (not available under woe) (BZip.cpp)
170AC_CHECK_MEMBERS([struct stat.st_blksize])
171
172
173# Remove mingwm10.dll dependency for static builds
174# http://www.sourceware.org/ml/pthreads-win32/2000/msg00141.html
175# http://www.thelins.se/johan/2006/11/installing-compressing-and-being.html
176if test x"$enable_static" = x"yes"; then
177    case "${host}" in
178    *-*-go32* | *-mingw32* | *-*-cygwin* | *-*-windows*)
179        LIBS="`echo $LIBS | sed 's/-mthreads //'`"
180	# Needed for 2.6.4:
181        CXXFLAGS="`echo $CXXFLAGS | sed 's/-mthreads //'`"
182        ;;
183    esac
184fi
185
186error=0
187
188if test "$LACK_LIBBZ2" = 1; then
189   echo "* Error: you need to install the libbz2 library (for compression)";
190   error=1
191fi
192
193if test "$enable_upx" = "yes" -a -z "$UPX"; then
194  echo "* Error: UPX is explicitely activated (--enable-upx) but cannot be found"
195  error=1
196fi
197
198if test "$LACK_WXGLADE" = 1; then
199   echo "* Warning: you may need to install wxGlade (if you're a developer)";
200fi
201
202if test $error -eq 1; then
203  exit 1
204fi
205
206AC_CONFIG_FILES([Makefile share/Makefile src/Makefile src/woeres.rc po/Makefile.in])
207AC_OUTPUT
208
209echo
210echo "Options summary:"
211echo "* --enable-upx=$enable_upx"
212echo "* --enable-static=$enable_static"
213echo
214echo "Now you can type 'make' to compile $PACKAGE_STRING"
215