aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: ab9f60fefc9dee81a4c2324eac8b6d62ed4fbbf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
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
71
72
73
74
75
76
77
78
79
80
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
AC_PREREQ(2.53)
AC_INIT([libmatchbox], 1.12, [yocto@yoctoproject.org])
AC_CONFIG_SRCDIR([libmb/mbtray.c])

AC_CONFIG_AUX_DIR(.)
AM_INIT_AUTOMAKE()
AC_CONFIG_HEADERS([config.h])

m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

# Checks for programs.
AC_GNU_SOURCE
AC_PROG_CC
AC_PROG_LIBTOOL

SUPPORTS_PNG=0
SUPPORTS_JPEG=0
SUPPORTS_XFT=0
SUPPORTS_PANGO=0

dnl ----- Args -------------------------------------------------------------

AC_ARG_ENABLE(xft,
  [  --disable-xft           disable xft (anti-aliased) support, [default=enabled]],
  enable_xft=$enableval, enable_xft=yes)

AC_ARG_ENABLE(pango,
  [  --enable-pango          enable Pango support.],
  enable_pango=$enableval, enable_pango=no)

AC_ARG_ENABLE(jpeg,
  [  --enable-jpeg           enable jpeg image support.],
  enable_jpeg=$enableval, enable_jpeg=no)

AC_ARG_ENABLE(png,
  [  --disable-png           disable PNG support [default=enabled]],
     enable_png=$enableval, enable_png=yes )

AC_ARG_ENABLE(doxygen-docs,     
  [  --enable-doxygen-docs   build DOXYGEN API documentation (requires Doxygen)], 
     enable_doxygen_docs=$enableval,enable_doxygen_docs=no)

AC_ARG_ENABLE(debug,
  [  --enable-debug          enable debug ( verbose ) build],
     enable_debug=$enableval, enable_debug=no )

AC_ARG_ENABLE(gcov,
  [  --enable-gcov           enable gcov coverage ( testing only ) build],
     enable_gcov=$enableval, enable_gcov=no )

AC_ARG_ENABLE(gprof,
  [  --enable-gprof          enable gprof profiler ( testing only ) build],
     enable_gprof=$enableval, enable_gprof=no )

AC_ARG_ENABLE(unit-tests,
  [  --enable-unit-tests          enable unit tests ( Requires check )],
     enable_unit_tests=$enableval, enable_unit_tests=no )



if test x$enable_pango = xyes -a x$enable_xft = xyes; then
   AC_MSG_WARN([Pango enabled, disabling Xft])
   enable_xft=no
fi

dnl ------ Check for X Stuff ------------------------------------------------

PKG_CHECK_MODULES(X11, x11, [have_libx11pc="yes"], [have_libx11pc="no"])

if test $have_libx11pc = yes; then
   xft_pkg=
   if test x$enable_xft != xno; then
      xft_pkg=xft
      SUPPORTS_XFT=1
      AC_DEFINE(USE_XFT, [1], [Use Xft])	
      XFT_REQUIRED="xft"
   fi
# XXX : xau is missing from x11.pc - workaround is too add here 
   PKG_CHECK_MODULES(XLIBS, x11 xext  $xft_pkg)
   XLIBS_REQUIRED="x11 xext"
else

AC_PATH_XTRA
if test x"$no_x" = x"yes"; then
    AC_MSG_ERROR([*** Required X11 Headers and libraries not found.***])
fi

XFT_LIBS=
XFT_CFLAGS=
 
# FIXME: Should check for shm 

if test x$enable_xft != xno; then
  AC_MSG_CHECKING([for xft])
  if test x$PKG_CONFIG != xno && $PKG_CONFIG --exists xft; then 
    XFT_CFLAGS="`pkg-config --cflags xft`"
    XFT_LIBS="`pkg-config --libs xft`"
    AC_DEFINE(USE_XFT, [1], [Use Xft])
    SUPPORTS_XFT=1
    AC_MSG_RESULT(yes)
    XFT_REQUIRED="xft"
  else

    AC_PATH_PROG(XFT_CONFIG, xft-config, no)
    
    if test x$XFT_CONFIG = xno; then
      AC_MSG_RESULT(no)
      AC_MSG_WARN([*** Cannot find Xft librarys, disabling support])
      enable_xft = no
    else
      XFT_CFLAGS="`xft-config --cflags`"
      XFT_LIBS="`xft-config --libs`"
      AC_DEFINE(USE_XFT, [1], [Use Xft])
      SUPPORTS_XFT=1    
      AC_MSG_RESULT(yes)
      MB_EXTRA_CFLAGS="$MB_EXTRA_CFLAGS $XFT_CFLAGS"
      MB_EXTRA_LIBS="$MB_EXTRA_LIBS $XFT_LIBS"
    fi
  fi
fi

XLIBS_CFLAGS="$XLIBS_CLAGS $XFT_CFLAGS"
XLIBS_LIBS="$XLIBS_LIBS $XFT_LIBS -lX11 -lXext"

fi

dnl ------ Check for Pango ---------------------------------------------------

if test x$enable_pango != xno; then
  PKG_CHECK_MODULES(PANGO, pango pangoxft, [have_pango="yes"], [have_pango="no"])
  if test x$have_pango=xyes; then
    AC_DEFINE(USE_PANGO, [1], [Use Pango])
    SUPPORTS_PANGO=1
    PANGO_REQUIRED="pango pangoxft"
  else
    AC_MSG_WARN([*** Cannot find pango, disabling support])
    enable_pango=no
  fi
fi


dnl ------ Check for PNG ---------------------------------------------------

if test x$enable_png != xno; then
  PKG_CHECK_MODULES(PNG, libpng)
  AC_DEFINE(USE_PNG, [1], [Use PNG])
  SUPPORTS_PNG=1
  PNG_REQUIRED="libpng"
fi


dnl ------ Check for JPEG ---------------------------------------------------

if test x$enable_jpeg != xno; then
  # AC_CHECK_HEADERS(jpeglib.h, [ have_jpg_h="yes" ], [ have_jpg_h="no" ] )
  AC_CHECK_LIB([jpeg], [jpeg_read_header], [have_jpg="yes"], [have_jpg="no"])

  if test x$have_jpg=xyes && test x$have_jpg_h=xyes; then 
        AC_DEFINE(USE_JPG, [1], [Use JPEG])
	SUPPORTS_JPEG=1
	JPEG_LIBS="-ljpeg"
        MB_EXTRA_LIBS="$MB_EXTRA_LIBS -ljpeg"
  else
	AC_MSG_WARN([*** Cannot find libjpeg, disabling support])
        enable_jpeg=no
  fi
fi

dnl ------ Debug -----------------------------------------------------------

if test x$enable_debug != xno; then
  XLIBS_CFLAGS="-DDEBUG $XLIBS_CFLAGS"	
fi


dnl ------ Doxygen docs ----------------------------------------------------

if test x$enable_doxygen_docs = xyes ; then

  AC_PATH_PROG(DOXYGEN, doxygen, no)

  AC_MSG_CHECKING([whether to build Doxygen documentation])

  if test x$DOXYGEN = xno ; then
    have_doxygen=no
  else
    have_doxygen=yes
  fi

  if test x$have_doxygen = xno; then
    AC_MSG_ERROR([Building Doxygen docs explicitly required, but Doxygen not found])
  fi


  AC_MSG_RESULT(yes)

fi

AM_CONDITIONAL(HAVE_DOXYGEN, test x$enable_doxygen_docs = xyes)	

dnl ------ GCC flags --------------------------------------------------------

if test "x$GCC" = "xyes"; then

   if test x$enable_gprof = xyes; then
         GCC_WARNINGS="$GCC_WARNINGS -pg"
	 AC_MSG_RESULT([Enabling gprof Support.])	
   fi	 

   if test x$enable_gcov = xyes; then
         GCC_WARNINGS="$GCC_WARNINGS -fprofile-arcs -ftest-coverage"
	 AC_MSG_RESULT([Enabling gcov Support.])	
   fi	 

   GCC_WARNINGS="-g -Wall -fno-strict-aliasing $GCC_WARNINGS"

else
   if test x$enable_gprof = xyes; then
      AC_MSG_WARN([*** Need gcc compiler for gprof support])
   fi

   if test x$enable_gcov = xyes; then
      AC_MSG_WARN([*** Need gcc compiler for gcov support])
   fi
fi

dnl ------ 'check' for unit tests -------------------------------------------

have_check=no

if test x$enable_unit_tests = xyes; then
  PKG_CHECK_MODULES([CHECK], [check], have_check=yes, have_check=no)
fi

AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xyes)

dnl ------ Substitute in found libs, clags to Makefiles etc -----------------

AC_SUBST(XLIBS_CFLAGS)
AC_SUBST(XLIBS_LIBS)
AC_SUBST(PANGO_CFLAGS)
AC_SUBST(PANGO_LIBS)
AC_SUBST(PNG_CFLAGS)
AC_SUBST(PNG_LIBS)
AC_SUBST(JPEG_LIBS)
AC_SUBST(GCC_WARNINGS)
AC_SUBST(CHECK_CFLAGS)

AC_SUBST(MB_EXTRA_LIBS)
AC_SUBST(MB_EXTRA_CFLAGS)
AC_SUBST(XLIBS_REQUIRED)
AC_SUBST(PANGO_REQUIRED)
AC_SUBST(PNG_REQUIRED)
AC_SUBST(XFT_REQUIRED)

dnl ------ Below used for mbconfig.h ----------------------------------------

AC_SUBST(SUPPORTS_PNG)
AC_SUBST(SUPPORTS_JPEG)
AC_SUBST(SUPPORTS_XFT)
AC_SUBST(SUPPORTS_PANGO)

dnl ------ 'Built in' checks ------------------------------------------------ 

AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([langinfo.h locale.h stdlib.h string.h sys/time.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME

# Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STAT
AC_FUNC_STRCOLL
AC_CHECK_FUNCS([memset select setlocale strcasecmp strchr strdup strncasecmp strstr])

AC_C_BIGENDIAN

AC_OUTPUT([
Makefile
libmb.pc
libmb/Makefile
libmb/mbconfig.h
doc/Doxyfile
doc/Makefile
tests/Makefile
tests/menu/Makefile
])

dnl ==========================================================================
echo "
                    LibMatchbox $VERSION
                  ======================

        prefix:                 ${prefix}
        source code location:   ${srcdir}

        Building with Debug:                ${enable_debug}
        Building with gcov:                 ${enable_gcov}
        Building with gprof:                ${enable_gprof}
	Building unit tests:                ${have_check}

        Building with Xft:                  ${enable_xft}
        Building with Pango:                ${enable_pango}
        Building with PNG:                  ${enable_png}
        Building with JPG:                  ${enable_jpeg}
        Building with API Documentation:    ${enable_doxygen_docs}

"