1
#  Copyright (c) 2009 Nokia Corporation
2
#  All rights reserved.
3
# 
4
#  Redistribution and use in source and binary forms, with or without
5
#  modification, are permitted provided that the following conditions are
6
#  met:
7
# 
8
#  * Redistributions of source code must retain the above copyright
9
#    notice, this list of conditions and the following disclaimer.
10
#  * Redistributions in binary form must reproduce the above copyright
11
#    notice, this list of conditions and the following disclaimer in the
12
#    documentation and/or other materials provided with the distribution.
13
#  * Neither the name of the Nokia Corporation nor the names of its
14
#    contributors may be used to endorse or promote products derived from
15
#    this software without specific prior written permission.
16
# 
17
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18
#  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19
#  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20
#  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21
#  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24
#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26
#  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#
29
# Author(s): Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
30
#           
31
#
32
33
# NOTE: if there's 'unlicensed' in the next line, don't change it!
34
AC_INIT([libnota-h-in],[3.0-2010.01],[http://notaworld.org])
35
AC_CONFIG_HEADERS([config.h])
36
37
AC_CONFIG_SRCDIR(h_core/h_core.c)
38
AC_CONFIG_MACRO_DIR([platform/m4])
39
AM_INIT_AUTOMAKE([dist-bzip2])
40
41
if test x$prefix = xNONE; then
42
   prefix=/usr/local
43
fi
44
AC_SUBST(prefix)
45
46
AC_PROG_CC
47
AM_PROG_CC_C_O
48
AC_HEADER_STDC
49
AC_PROG_LIBTOOL
50
51
# libtool versioning
52
# REVISION gets incremented for non-ABI/API-break changes
53
# CURRENT/AGE get incremented for API/ABI-breaks; REVISION goes back to 0 
54
LTVERSION_REVISION=0
55
LTVERSION_CURRENT=3
56
LTVERSION_AGE=3
57
LIBH_IN_LTVERSION=${LTVERSION_CURRENT}:${LTVERSION_REVISION}:${LTVERSION_AGE}
58
AC_SUBST([LIBH_IN_LTVERSION])
59
60
61
AC_CHECK_HEADERS(assert.h)
62
63
64
# libtool release, some number we can decide
65
LIBL_IN_RELEASE=3:0:0
66
AC_SUBST([LIBH_IN_RELEASE])
67
68
# require pkg-config
69
AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no]) 
70
if test "x$PKG_CONFIG" = "xno"; then
71
   AC_MSG_ERROR([
72
   *** The pkg-config script could not be found. Make sure it is
73
   *** in your path, or set the PKG_CONFIG environment variable
74
   *** to the full path to pkg-config.]) 
75
fi
76
77
78
79
#
80
# optionally, use an uninstalled l_in
81
AC_ARG_WITH([l_in_builddir],AC_HELP_STRING([--with-l-in-builddir[=PFX]],[Prefix for l_in]),
82
   [l_in_builddir="$withval"], [l_in_builddir="none"])
83
if test "x$l_in_builddir" != "xnone"; then
84
  
85
   test -e $withval/l_in_up/libl_in.la || 
86
   	AC_MSG_ERROR($withval/l_in_up/libl_in.la not found)
87
   test -d $withval/inc/l_in || 
88
   	AC_MSG_ERROR($withval/inc/l_in not found)
89
  
90
   NOTA_L_IN_LIBS=$withval/l_in_up/libl_in.la
91
   NOTA_L_IN_CFLAGS=-I$withval/inc/
92
else
93
   PKG_CHECK_MODULES(NOTA_L_IN,nota-l_in-3.0)   		
94
fi
95
96
AC_SUBST(NOTA_L_IN_LIBS)
97
AC_SUBST(NOTA_L_IN_CFLAGS)
98
						      
99
100
AC_ARG_WITH(platform, [AC_HELP_STRING([--with-platform],
101
	[platform to build for: posix, symbian32, t-kernel])],
102
[case "${with_platform}" in
103
      posix)      NOTA_PLATFORM=${with_platform};;
104
      symbian32)  NOTA_PLATFORM=${with_platform};;
105
      t-kernel)   NOTA_PLATFORM=${with_platform};;
106
      *)          AC_MSG_ERROR([unsupported platform]);;
107
 esac], [NOTA_PLATFORM=posix])
108
NOTA_PLATFORM_DIR=${top_srcdir}/platform/${NOTA_PLATFORM}
109
AC_SUBST(NOTA_PLATFORM_DIR)
110
AC_SUBST(NOTA_PLATFORM)
111
112
dnl what kind of threadlib to use?
113
ACX_PTHREAD
114
LIBS="$PTHREAD_LIBS $LIBS"
115
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
116
CC="$PTHREAD_CC"
117
118
AC_MSG_CHECKING([for the meaning of life])
119
echo "not found"
120
121
# endianness -- 
122
# note, we can use AC_C_BIGENDIAN, but we also allow overriding it,
123
# as it won't work when cross-compiling.
124
AC_ARG_WITH(endianness,	[AC_HELP_STRING([--with-endianness],
125
	[endianness to use: big or little])],
126
[case "${with_endianness}" in
127
      big|small)  NOTA_ENDIANNESS=${with_endianness};;
128
      *)              AC_MSG_ERROR([unsupported endianness]);;
129
 esac], [AC_C_BIGENDIAN([NOTA_ENDIANNESS=big],[NOTA_ENDIANNESS=little])])
130
	
131
AC_SUBST(NOTA_ENDIANNESS)
132
133
# define some stuff, easier in Makefile.am...
134
AM_CONDITIONAL(NOTA_BIG_ENDIAN,[test "x$NOTA_ENDIANNESS" == "xbig"])
135
AM_CONDITIONAL(NOTA_LITTLE_ENDIAN,[test "x$NOTA_ENDIANNESS" == "xlittle"])
136
137
138
# FIXME: make an easy -D for posix.c, so we don't need source changes
139
# yet; this should be handled with config.h instead
140
if test "x$NOTA_ENDIANNESS" == "xbig"; then
141
   ENDIAN_FLAGS="-DBIG_ENDIAN_MACHINE"
142
else
143
   ENDIAN_FLAGS="-DLITTLE_ENDIAN_MACHINE"
144
fi
145
AC_SUBST(ENDIAN_FLAGS)
146
147
148
# check for cygwin
149
# TODO: a more precise check for the specific BSD
150
# thing some system (Cygwin or otherwise) is missing
151
AC_CANONICAL_HOST
152
case $host_os in
153
        *cygwin* ) CYGWIN=yes;;
154
               * ) CYGWIN=no;;
155
         esac
156
AM_CONDITIONAL(NOTA_HAVE_CYGWIN,[test "x$CYGWIN" == "xyes"])
157
158
159
# 
160
# Enable multiple H_IN cores 
161
AC_ARG_ENABLE(multi-reference-h_in_core,
162
              [AC_HELP_STRING([--enable-multi-reference-h_in_core],[enable multiple H_IN core creation (default=no)])],
163
              [with_multihcore=yes], [with_multihcore=no])
164
if test "x$with_multihcore" == "xyes" ; then
165
  H_IN_MULTI_HCORE="-DNOTA_MULTIPLE_HCORE"
166
  AC_SUBST(H_IN_MULTI_HCORE)
167
else
168
  H_IN_MULTI_HCORE=""
169
fi
170
171
172
#
173
# Enable branch coverage
174
AC_ARG_ENABLE(coverage,
175
              [AC_HELP_STRING([--enable-coverage],[enable measuring brachcoverage on H_IN core files using gcov, (requires static linking on singleprocess, with targets software linked with -fprofile-arcs to have gcov runtime support)])],
176
              [with_coverage=yes], [with_coverage=no])
177
if test "x$with_coverage" == "xyes" ; then
178
  CFLAGS="-g -O0 -ftest-coverage -fprofile-arcs -static -pedantic"
179
  NOTA_COVERAGE_FLAGS="-DNOTA_H_IN_BRANCH_COVERAGE"
180
  AC_SUBST(NOTA_COVERAGE_FLAGS)
181
fi
182
183
# 
184
# Disable NOTA_INLINE 
185
AC_ARG_ENABLE(h_in_inline,
186
              [AC_HELP_STRING([--disable-h_in_inline],[disable forced inline function usage in H_IN core])],
187
              [disable_inline=yes])
188
if test "x$disable_inline" == "xyes" ; then
189
  H_IN_DISABLE_NOTA_INLINE="-DDISABLE_INLINE_OPTIMIZATION"
190
  AC_SUBST(H_IN_DISABLE_NOTA_INLINE)
191
else
192
  H_IN_DISABLE_NOTA_INLINE=""
193
  NOTA_FLAGS=`echo $CFLAGS | tr -d "-"` 
194
  for flag in ${NOTA_FLAGS}; do
195
     if test "x$flag" == "xO0"; then
196
        dnl disabling NOTA_INLINE as no optimizations are expected
197
        H_IN_DISABLE_NOTA_INLINE="-DDISABLE_INLINE_OPTIMIZATION"
198
        AC_SUBST(H_IN_DISABLE_NOTA_INLINE)
199
     fi
200
  done
201
fi
202
203
AC_OUTPUT([
204
Makefile
205
inc/Makefile
206
inc/h_in/Makefile
207
h_core/Makefile
208
daemon/Makefile
209
sp/Makefile
210
test/Makefile
211
man/Makefile
212
contrib/Makefile
213
contrib/python/Makefile
214
platform/posix/Makefile
215
platform/symbian32/Makefile
216
platform/t-kernel/Makefile
217
platform/m4/Makefile
218
platform/Makefile
219
nota-h_in-sp-3.0.pc
220
nota-h_in-3.0.pc])
221
222
echo
223
echo "H_IN configure results"
224
echo "-----------------------------------"
225
echo "Platform          : $NOTA_PLATFORM"
226
echo "Endianness        : $NOTA_ENDIANNESS"
227
echo "Cygwin            : $CYGWIN"
228
echo "Multiple Hcores   : ${with_multihcore}"
229
echo "Branch coverage   : ${with_coverage}"
230
echo "CFLAGS            : ${CFLAGS}"
231
echo "NOTA_INLINE       : ${H_IN_DISABLE_NOTA_INLINE}" 
232
echo ""
233
echo "Prefix            : ${prefix}"
234
echo ""
235
echo "Now, run 'make' to compile h_in"