Bump version
[unicode-screensaver.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2
3 #AC_PREREQ(2.60)
4 AC_INIT(unicode-screensaver, 0.5.1, mail@joachim-breitner.de)
5 AC_CONFIG_SRCDIR([unicode.c])
6 AC_CONFIG_HEADER([config.h])
7 # AC_CONFIG_MACRO_DIR([m4])
8 AM_INIT_AUTOMAKE
9
10 ###############################################################################
11 #
12 #       Handle the --with-hackdir option
13 #
14 ###############################################################################
15
16 have_hackdir=yes
17 with_hackdir_req=unspecified
18 AC_ARG_WITH(hackdir,[
19
20 Installation options:
21   --with-hackdir=DIR      Where to install the hundreds of demo executables.
22                           Default: PREFIX/libexec/xscreensaver/],
23   [with_hackdir="$withval"; with_hackdir_req="$withval"],[with_hackdir=yes])
24
25 if test x"$with_hackdir" = xyes; then
26   HACKDIR='${libexecdir}/xscreensaver'
27 elif test x"$with_hackdir" = xno; then
28   HACKDIR='${bindir}'
29 else
30   HACKDIR=$with_hackdir
31 fi
32
33 # canonicalize slashes.
34 HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
35 AC_SUBST(HACKDIR)
36
37 ###############################################################################
38 #
39 #       Handle the --with-desktopdir option
40 #
41 ###############################################################################
42
43 have_desktopdir=yes
44 with_desktopdir_req=unspecified
45 AC_ARG_WITH(desktopdir,
46 [  --with-desktopdir=DIR   Where to install the hundreds of demo executables.
47                           Default: PREFIX/share/applications/screensavers/],
48   [with_desktopdir="$withval"; with_desktopdir_req="$withval"],[with_desktopdir=yes])
49
50 if test x"$with_desktopdir" = xyes; then
51   DESKTOPDIR='${prefix}/share/applications/screensavers'
52 elif test x"$with_desktopdir" = xno; then
53   echo "error: must be yes, or a pathname: --with-desktopdir=$with_desktopdir"
54   exit 1
55 else
56   DESKTOPDIR=$with_desktopdir
57 fi
58
59 # canonicalize slashes.
60 DESKTOPDIR=`echo "${DESKTOPDIR}" | sed 's@/$@@;s@//*@/@g'`
61 AC_SUBST(DESKTOPDIR)
62
63 ###############################################################################
64 #
65 #       Handle the --with-configdir option
66 #       Help for --with-x-app-defaults option added..
67 #
68 ###############################################################################
69
70 have_configdir=yes
71 with_configdir_req=unspecified
72 AC_ARG_WITH(configdir,
73 [  --with-configdir=DIR    Where to install the data files that describe each
74                           of the display modes to the GUI.
75                           Default: PREFIX/share/xscreensaver/config/
76 ],
77   [with_configdir="$withval"; with_configdir_req="$withval"],
78   [with_configdir=yes])
79
80 if test x"$with_configdir" = xyes; then
81   HACK_CONF_DIR='${datadir}/xscreensaver/config'
82 elif test x"$with_configdir" = xno; then
83   echo "error: must be yes, or a pathname: --with-configdir=$with_configdir"
84   exit 1
85 else
86   # there must be a better way than this...
87   if test -z "`echo $with_configdir | sed 's@^/.*@@'`" ; then
88     # absolute path
89     HACK_CONF_DIR=$with_configdir
90   else
91     # relative path
92     HACK_CONF_DIR="\${exec_prefix}$with_configdir"
93   fi
94 fi
95
96 AC_SUBST(HACK_CONF_DIR)
97
98
99
100 # Checks for programs.
101
102 ###############################################################################
103 #
104 #       Function to figure out how to run the compiler.
105 #
106 ###############################################################################
107
108 AC_DEFUN(AC_PROG_CC_ANSI,
109  [AC_PROG_CC
110
111   if test -z "$GCC"; then
112     # not using GCC
113     AC_MSG_CHECKING(how to request ANSI compilation)
114     case "$host" in
115       *-hpux* )
116         AC_MSG_RESULT(HPUX: adding -Ae)
117         CC="$CC -Ae"
118       ;;
119       *-aix* )
120         AC_MSG_RESULT(AIX: adding -qlanglvl=ansi -qhalt=e)
121         CC="$CC -qlanglvl=ansi -qhalt=e"
122       ;;
123       *-dec-* )
124         AC_MSG_RESULT(DEC: adding -std1 -ieee)
125         CC="$CC -std1"
126       ;;
127       *)
128         AC_MSG_RESULT(no idea)
129       ;;
130     esac
131   else
132     # using GCC
133     case "$host" in
134       *-solaris*)
135         AC_MSG_RESULT(Solaris: adding -D__EXTENSIONS__)
136         CC="$CC -D__EXTENSIONS__"
137       ;;
138     esac
139   fi
140
141   OBJCC="$CC"
142
143   AC_MSG_CHECKING([whether the compiler works on ANSI C])
144   AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
145      AC_MSG_RESULT(yes),
146      AC_MSG_RESULT(no)
147      AC_MSG_ERROR(Couldn't build even a trivial ANSI C program: check CC.),
148      AC_MSG_RESULT(cross compiling... assuming yes))
149
150   if test -n "$GCC"; then
151     AC_MSG_RESULT(Turning on gcc compiler warnings.)
152     CC="$CC -pedantic -Wall -Wstrict-prototypes -Wnested-externs -Wmissing-prototypes"
153     OBJCC="$OBJCC -Wall"
154     # As of gcc 3.4, we have "-Wdeclaration-after-statement"
155     # and so perhaps now we can do without -pedantic?
156   else
157     case "$host" in
158       *-irix5* |*-irix6.[0-3]* )
159         AC_MSG_RESULT(Turning on SGI compiler warnings.)
160         CC="$CC -fullwarn -use_readonly_const -rdata_shared -g3"
161       ;;
162 #     *-dec-osf* )
163 #       if test -z "$GCC"; then
164 #         AC_MSG_RESULT(Turning on DEC C compiler warnings.)
165 #         CC="$CC -migrate -w0 -verbose -warnprotos"
166 #       fi
167 #     ;;
168     esac
169   fi
170 ])
171
172 ###############################################################################
173 #
174 #       Check for availability of various gcc command-line options.
175 #
176 ###############################################################################
177
178 AC_DEFUN(AC_CHECK_GCC_ARG,
179  [if test -n "$GCC"; then
180    AC_CACHE_CHECK([whether gcc accepts [$2]],
181      ac_cv_gcc_accepts_[$1],
182     [rm -rf conftest.$ac_ext
183      touch conftest.$ac_ext
184      if ( ( gcc -c [$2] conftest.$ac_ext -o/dev/null >/dev/null ) 2>&1 | \
185           grep unrecognized >/dev/null ); then
186        ac_cv_gcc_accepts_[$1]=no
187      else
188        ac_cv_gcc_accepts_[$1]=yes
189        CC="$CC [$2]"
190      fi])
191    ac_gcc_accepts_[$1]="$ac_cv_gcc_accepts_[$1]"
192   fi
193 ])
194
195 AC_DEFUN(AC_NO_LONG_STRING_WARNINGS,
196          [AC_CHECK_GCC_ARG(no_overlength, -Wno-overlength-strings)])
197
198 AC_DEFUN(AC_NO_MISPLACED_DECLARATIONS,
199          [AC_CHECK_GCC_ARG(no_decl_after, -Wdeclaration-after-statement)])
200
201 AC_PROG_CC
202 AC_PROG_CC_ANSI
203 AC_NO_LONG_STRING_WARNINGS
204 AC_NO_MISPLACED_DECLARATIONS
205 AC_PROG_INSTALL
206 AC_PROG_MAKE_SET
207
208 # Checks for libraries.
209 AM_PROG_LIBTOOL
210
211 PKG_CHECK_MODULES(X11, x11)
212 AC_SUBST(X11_CFLAGS)
213 AC_SUBST(X11_LIBS)
214
215 PKG_CHECK_MODULES(XMU, xmu)
216 AC_SUBST(XMU_CFLAGS)
217 AC_SUBST(XMU_LIBS)
218
219 PKG_CHECK_MODULES(XT, xt)
220 AC_SUBST(XT_CFLAGS)
221 AC_SUBST(XT_LIBS)
222
223 PKG_CHECK_MODULES(XFT, xft)
224 AC_SUBST(XFT_CFLAGS)
225 AC_SUBST(XFT_LIBS)
226
227 PKG_CHECK_MODULES(FC, fontconfig)
228 AC_SUBST(FC_CFLAGS)
229 AC_SUBST(FC_LIBS)
230
231 # Checks for header files.
232
233 # Checks for typedefs, structures, and compiler characteristics.
234
235
236 ###############################################################################
237 #
238 #       Function to check whether gettimeofday() exists, and how to call it.
239 #       This may define HAVE_GETTIMEOFDAY and GETTIMEOFDAY_TWO_ARGS.
240 #
241 ###############################################################################
242
243 AH_TEMPLATE([HAVE_GETTIMEOFDAY],
244             [Define this if you have the gettimeofday function.])
245
246 AH_TEMPLATE([GETTIMEOFDAY_TWO_ARGS],
247             [Define this if gettimeofday() takes two arguments.])
248
249 AC_DEFUN([AC_GETTIMEOFDAY_ARGS],
250  [AC_MSG_CHECKING(how to call gettimeofday)
251   AC_CACHE_VAL(ac_cv_gettimeofday_args,
252    [AC_TRY_COMPILE([#include <stdlib.h>
253                     #include <sys/time.h>],
254                    [struct timeval tv; struct timezone tzp;
255                     gettimeofday(&tv, &tzp);],
256                    [ac_gettimeofday_args=2],
257                    [AC_TRY_COMPILE([#include <stdlib.h>
258                                     #include <sys/time.h>],
259                                    [struct timeval tv; gettimeofday(&tv);],
260                                    [ac_gettimeofday_args=1],
261                                    [ac_gettimeofday_args=0])])
262     ac_cv_gettimeofday_args=$ac_gettimeofday_args])
263   ac_gettimeofday_args=$ac_cv_gettimeofday_args
264   if test "$ac_gettimeofday_args" = 1 ; then
265     AC_DEFINE(HAVE_GETTIMEOFDAY)
266     AC_MSG_RESULT(one argument)
267   elif test "$ac_gettimeofday_args" = 2 ; then
268     AC_DEFINE(HAVE_GETTIMEOFDAY)
269     AC_DEFINE(GETTIMEOFDAY_TWO_ARGS)
270     AC_MSG_RESULT(two arguments)
271   else
272     AC_MSG_RESULT(unknown)
273   fi
274 ])
275
276 AC_GETTIMEOFDAY_ARGS
277
278 # Checks for library functions.
279
280 AC_CONFIG_FILES([Makefile])
281 AC_OUTPUT