summaryrefslogtreecommitdiff
path: root/configure.ac
blob: c0be62026c27709d72e1925b13eeaf91cb69229c (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
AC_PREREQ(2.59)

m4_define([spectre_major_version], [0])
m4_define([spectre_minor_version], [0])
m4_define([spectre_micro_version], [1])
m4_define([spectre_version],
          [spectre_major_version.spectre_minor_version.spectre_micro_version])

AC_INIT(libspectre, [spectre_version])
AC_CONFIG_HEADERS(config.h)

AM_INIT_AUTOMAKE([1.7])

AM_MAINTAINER_MODE

# libtool versioning
#
# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
#

## increment if the interface has additions, changes, removals.
LT_CURRENT=1

## increment any time the source changes; set to
##  0 if you increment CURRENT
LT_REVISION=0

## increment if any interfaces have been added; set to 0
## if any interfaces have been changed or removed. removal has
## precedence over adding, so set to 0 if both happened.
LT_AGE=0

VERSION_INFO="$LT_CURRENT:$LT_REVISION:$LT_AGE"
AC_SUBST(VERSION_INFO)

LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
AC_SUBST(LT_CURRENT_MINUS_AGE)

AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

SPECTRE_MAJOR_VERSION=spectre_major_version
SPECTRE_MINOR_VERSION=spectre_minor_version
SPECTRE_MICRO_VERSION=spectre_micro_version
SPECTRE_VERSION=spectre_major_version.spectre_minor_version.spectre_micro_version

AC_SUBST(SPECTRE_MAJOR_VERSION)
AC_SUBST(SPECTRE_MINOR_VERSION)
AC_SUBST(SPECTRE_MICRO_VERSION)
AC_SUBST(SPECTRE_VERSION)

AC_PROG_LIBTOOL
AC_PROG_CC
AC_ISC_POSIX
AC_PROG_CC_STDC
AC_STDC_HEADERS

LIBGS_REQUIRED="8.61"

AC_CHECK_LIB(gs, gsapi_new_instance, have_libgs=yes, have_libgs=no)
if test "x$have_libgs" = "xyes"; then
    LIB_GS="-lgs"
    save_LIBS=$LIBS
    LIBS="$LIBS -lgs"
    AC_LANG_PUSH(C)
    AC_MSG_CHECKING([for libgs >= $LIBGS_REQUIRED])
    AC_RUN_IFELSE([AC_LANG_PROGRAM(
[[
#include <ghostscript/iapi.h>
]],
[[
    gsapi_revision_t gsrev;

    if (gsapi_revision (&gsrev, sizeof (gsrev)) != 0)
        return 1;
    if (gsrev.revision < `echo "$LIBGS_REQUIRED" | sed -e 's/\.//'`)
        return 1;
]])],
                   [have_libgs=yes],
		   [have_libgs=no],
		   [have_libgs=yes]
    )
    AC_MSG_RESULT($have_libgs)
    AC_LANG_POP(C)
    LIBS=$save_LIBS
    if test "x$have_libgs" = "xno"; then
        AC_MSG_ERROR([You need libgs >= $LIBGS_REQUIRED in order to compile libspectre])
    fi
else
    AC_MSG_ERROR([You need libgs in order to compile libspectre])
fi
AC_SUBST(LIB_GS)

AC_ARG_ENABLE(asserts,
	AS_HELP_STRING([--enable-asserts],[include assertion checks]),
	enable_asserts=$enableval,
	enable_asserts=$USE_MAINTAINER_MODE)

if test x$enable_asserts = xno; then
   AC_DEFINE(SPECTRE_DISABLE_ASSERT,[1],[Disable assertion checking])
fi
	
AC_ARG_ENABLE(checks,
	AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),
	enable_checks=$enableval,
	enable_checks=yes)

if test x$enable_checks = xno; then
   AC_DEFINE(SPECTRE_DISABLE_CHECKS,[1],[Disable public API sanity checking])
fi
	
dnl Test
AC_ARG_ENABLE(test,
              [AC_HELP_STRING([--enable-test], [Compile tests])],enable_test="$enableval",enable_test=yes)

if test "x$enable_test" = "xyes"; then
    PKG_CHECK_MODULES(CAIRO, cairo cairo-png, enable_test=yes,enable_test=no)

    if test "x$enable_test" != "xyes"; then
        AC_MSG_WARN("Tests disabled since required cairo library was not found")
    fi
fi

AM_CONDITIONAL(ENABLE_TEST, test x$enable_test = xyes)

dnl ===========================================================================
dnl check compiler flags (From cairo)
AC_DEFUN([SPECTRE_CC_TRY_FLAG], [
  AC_MSG_CHECKING([whether $CC supports $1])

  spectre_save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $1"

  AC_COMPILE_IFELSE([ ], [spectre_cc_flag=yes], [spectre_cc_flag=no])
  CFLAGS="$spectre_save_CFLAGS"

  if test "x$spectre_cc_flag" = "xyes"; then
    ifelse([$2], , :, [$2])
  else
    ifelse([$3], , :, [$3])
  fi
  AC_MSG_RESULT([$spectre_cc_flag])
])


dnl Use lots of warning flags with with gcc and compatible compilers

dnl Note: if you change the following variable, the cache is automatically
dnl skipped and all flags rechecked.  So there's no need to do anything
dnl else.  If for any reason you need to force a recheck, just change
dnl MAYBE_WARN in an ignorable way (like adding whitespace)

MAYBE_WARN="-Wall -ansi \
-Wsign-compare -Werror-implicit-function-declaration \
-Wpointer-arith -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
-Wpacked -Wswitch-enum \
-Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
-Wdeclaration-after-statement \
-Wno-missing-field-initializers -Wno-unused-parameter \
-Wno-attributes -Wno-long-long -Winline"


# invalidate cached value if MAYBE_WARN has changed
if test "x$spectre_cv_warn_maybe" != "x$MAYBE_WARN"; then
	unset spectre_cv_warn_cflags
fi
AC_CACHE_CHECK([for supported warning flags], spectre_cv_warn_cflags, [
	echo
	WARN_CFLAGS=""

	# Some warning options are not supported by all versions of
	# gcc, so test all desired options against the current
	# compiler.
	#
	# Note that there are some order dependencies
	# here. Specifically, an option that disables a warning will
	# have no net effect if a later option then enables that
	# warnings, (perhaps implicitly). So we put some grouped
	# options (-Wall and -Wextra) up front and the -Wno options
	# last.

	for W in $MAYBE_WARN; do
		SPECTRE_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
	done

	spectre_cv_warn_cflags=$WARN_CFLAGS
	spectre_cv_warn_maybe=$MAYBE_WARN

	AC_MSG_CHECKING([which warning flags were supported])])
WARN_CFLAGS="$spectre_cv_warn_cflags"
SPECTRE_CFLAGS="$SPECTRE_CFLAGS $WARN_CFLAGS"

AC_SUBST(SPECTRE_CFLAGS)

AC_OUTPUT([
Makefile
Doxyfile
libspectre/Makefile
libspectre/spectre-version.h
libspectre/ghostscript/Makefile
test/Makefile
libspectre.pc
])