* Makefile.common.in: unused PORT, SCC and SAS removed, fixed docdir
[fw/sdcc] / configure.in
1 #!/bin/sh
2
3 AC_PREREQ(2.54)
4 AC_INIT
5 AC_CONFIG_SRCDIR([Makefile])
6 AC_CONFIG_HEADER(sdccconf.h:sdccconf_in.h)
7
8 AC_PROG_AWK
9
10 AC_MSG_CHECKING(version of the package)
11 if test -f .version; then
12   VERSION=`cat .version`
13 elif test -f ../.version; then
14   VERSION=`cat ../.version`
15 else
16   VERSION="0.0.0"
17 fi
18 VERSIONHI=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $1}'`
19 VERSIONLO=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $2}'`
20 VERSIONP=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $3}'`
21 # Assume no special extension
22 EXEEXT=`echo $EXEEXT`
23
24 AC_MSG_RESULT(${VERSION})
25 AC_SUBST(VERSION)
26 AC_SUBST(VERSIONHI)
27 AC_SUBST(VERSIONLO)
28 AC_SUBST(VERSIONP)
29 AC_DEFINE_UNQUOTED(SDCC_VERSION_LO, ${VERSIONLO})
30 AC_DEFINE_UNQUOTED(SDCC_VERSION_HI, ${VERSIONHI})
31 AC_DEFINE_UNQUOTED(SDCC_VERSION_P, ${VERSIONP})
32 AC_DEFINE_UNQUOTED(SDCC_VERSION_STR, "${VERSION}")
33 AC_ARG_PROGRAM
34 sdcc_cv_version=$VERSION
35 sdcc_cv_versionhi=$VERSIONHI
36 sdcc_cv_versionlo=$VERSIONLO
37 sdcc_cv_versionp=$VERSIONP
38
39
40 # Required programs
41 # ===========================================================================
42 AC_PROG_CC
43 AC_PROG_CXX
44 AC_PROG_CPP
45 AC_PROG_INSTALL
46 AC_PROG_RANLIB
47 AC_PROG_LEX
48 AC_PROG_YACC
49 AC_CHECK_PROG(AUTOCONF, autoconf, autoconf, :)
50 AC_CHECK_PROG(STRIP, strip, strip, :)
51 AC_CHECK_PROG(AS, as, as, :)
52 AC_CHECK_PROG(CP, cp, cp, :)
53
54 AC_CHECK_PROG(LYX,        lyx,        lyx, :)
55 AC_CHECK_PROG(LATEX,      latex,      latex, :)
56 AC_CHECK_PROG(LATEX2HTML, latex2html, latex2html, :)
57 AC_CHECK_PROG(PDFLATEX,   pdflatex,   pdflatex, :)
58 AC_CHECK_PROG(DVIPDF,     dvipdf,     dvipdf, :)
59
60 AC_DEFUN(SDCC_REQUIRE_PROG, 
61 [if test "$1" = ":"; then
62   AC_MSG_ERROR([Cannot find required program $2.])
63  fi
64 ])
65
66 SDCC_REQUIRE_PROG($YACC, bison)
67 SDCC_REQUIRE_PROG($LEX, lex)
68
69 AC_LANG([C])
70
71
72 # Checking for header files.
73 # ===========================================================================
74 AC_CHECK_HEADERS(sys/socket.h)
75
76
77 # Checking for functions
78 # ===========================================================================
79 AC_CHECK_FUNCS(strerror)
80 AC_CHECK_FUNCS(vsnprintf snprintf vsprintf mkstemp)
81
82
83 # Macro definitions
84 # ===========================================================================
85
86 # DD_COPT macro checks if the compiler specified as the 1st parameter
87 # supports option specified as the 2nd parameter
88 # For example: DD_CPORT(CXX, fPIC)
89
90 AC_DEFUN(DD_COPT, [
91 AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2,
92 cat >_test_.c <<EOF
93 #include <stdio.h>
94 void main(void) {}
95 EOF
96 $$1 -v -$2 -c _test_.c 1>&5 2>&5
97 if test "$?" = "0"; then
98   sdcc_cv_$1$2="yes"
99 else
100   sdcc_cv_$1$2="no"
101 fi
102 rm -f _test_.* a.out)
103 ])
104
105 # This macro _AC_DEFINEs VARNAME to the expansion of the DIR variable,
106 # taking care of fixing up ${prefix} and such.
107 #
108 # Note that the 3 argument form is only supported with autoconf 2.13
109 # and later (i.e. only where _AC_DEFINE supports 3 arguments).
110 #
111 # Examples:
112 #
113 #  AC_DEFINE_DIR(DATADIR, datadir)
114 #  AC_DEFINE_DIR(PROG_PATH, bindir, [Location of installed binaries])
115
116 AC_DEFUN([AC_DEFINE_DIR], [
117   test "x$prefix" = xNONE && prefix="$ac_default_prefix"
118   test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
119   ac_define_dir=`eval echo [$]$2`
120   ac_define_dir=`eval echo [$]ac_define_dir`
121   ifelse($3, ,
122     AC_DEFINE_UNQUOTED($1, "$ac_define_dir"),
123     AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3))
124 ])
125
126
127 # Checking characteristics of compilers and other programs
128 # ===========================================================================
129 AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,sdcc_cv_MM,
130 echo "#include <stdio.h>" >_test_.c
131 echo "" >>_test_.c
132 $CPP -v -MM _test_.c 1>&5 2>&5
133 if test "$?" = "0"; then
134   sdcc_cv_MM="-MM"
135 else
136   sdcc_cv_MM="-M"
137 fi
138 rm -f _test_.*)
139 M_OR_MM=$sdcc_cv_MM
140 AC_SUBST(M_OR_MM)
141
142 # This is the first time when CFLAGS are set/modified!!
143 DD_COPT(CC, ggdb)
144 if test "$sdcc_cv_CCggdb" = "yes"; then
145   CFLAGS="-ggdb -O2"
146 fi
147
148 DD_COPT(CC, pipe)
149 if test "$sdcc_cv_CCpipe" = "yes"; then
150   CFLAGS="$CFLAGS -pipe"
151 fi
152
153 # Checks for typedefs, structures, and compiler characteristics.
154 # ===========================================================================
155 AC_TYPE_SIGNAL
156
157 AC_CHECK_SIZEOF(char)
158 AC_CHECK_SIZEOF(short)
159 AC_CHECK_SIZEOF(int)
160 AC_CHECK_SIZEOF(long)
161
162 type_name()
163 {
164     if expr "$ac_cv_sizeof_char" '>=' "$1" >/dev/null; then
165         echo "char"
166         exit
167     fi
168     if expr "$ac_cv_sizeof_short" '>=' "$1" >/dev/null; then
169         echo "short"
170         exit
171     fi
172     if expr "$ac_cv_sizeof_int" '>=' "$1" >/dev/null; then
173         echo "int"
174         exit
175     fi
176     if expr "$ac_cv_sizeof_long" '>=' "$1" >/dev/null; then
177         echo "long"
178         exit
179     fi
180     echo "long"
181 }
182
183 AC_MSG_CHECKING(type name for byte)
184 TYPE_BYTE=`type_name 1`
185 AC_MSG_RESULT($TYPE_BYTE)
186 AC_MSG_CHECKING(type name for word)
187 TYPE_WORD=`type_name 2`
188 AC_MSG_RESULT($TYPE_WORD)
189 AC_MSG_CHECKING(type name for dword)
190 TYPE_DWORD=`type_name 4`
191 AC_MSG_RESULT($TYPE_DWORD)
192 AC_DEFINE_UNQUOTED(TYPE_BYTE,  $TYPE_BYTE)
193 AC_DEFINE_UNQUOTED(TYPE_WORD,  $TYPE_WORD)
194 AC_DEFINE_UNQUOTED(TYPE_DWORD, $TYPE_DWORD)
195
196 AC_C_BIGENDIAN
197
198 # Set standard installation paths
199 # ===========================================================================
200 case $host in
201     *mingw32*)
202         MINGW32_HOST="yes"
203         ;;
204     *)
205         MINGW32_HOST="no"
206         ;;
207 esac
208
209 AC_MSG_CHECKING(host mingw32)
210 AC_MSG_RESULT($MINGW32_HOST)
211
212 # prefix: *nix default is "NONE"
213 # prefix: mingw32 default is "/sdcc"
214 if test "$prefix" = NONE; then
215     if test "$MINGW32_HOST" = "no"; then
216         prefix="/usr/local"
217     else
218         prefix="/sdcc"
219     fi
220 fi
221
222 # datadir: *nix default is "${prefix}/share"
223 if test "$datadir" = "\${prefix}/share"; then
224     if test "$MINGW32_HOST" = "no"; then
225         datadir="\${prefix}/share/sdcc"
226     fi
227 # mingw32 default is "/sdcc"
228 elif test "$datadir" = "/sdcc"; then
229     if test "$MINGW32_HOST" = "yes"; then
230         datadir="\${prefix}"
231     fi
232 fi
233
234 # standard libs
235 AC_DEFINE_UNQUOTED(STD_LIB,       "libsdcc")
236 AC_DEFINE_UNQUOTED(STD_INT_LIB,   "libint")
237 AC_DEFINE_UNQUOTED(STD_LONG_LIB,  "liblong")
238 AC_DEFINE_UNQUOTED(STD_FP_LIB,    "libfloat")
239 AC_DEFINE_UNQUOTED(STD_DS390_LIB, "libds390")
240 AC_DEFINE_UNQUOTED(STD_xa51_LIB,  "xa51")
241
242 AC_DEFINE_DIR(PREFIX,  "${prefix}")
243 AC_DEFINE_DIR(DATADIR, "$datadir")
244 AC_SUBST(datadir)
245
246 # search paths
247 bin_dir_suffix="bin"
248 AC_DEFINE_DIR(BIN_DIR_SUFFIX, "${bin_dir_suffix}")
249
250     if test "$MINGW32_HOST" = "no"; then
251         search_suffix="share/sdcc"
252     else
253         search_suffix=""
254     fi
255 AC_DEFINE_DIR(SEARCH_SUFFIX, "${search_suffix}")
256
257 include_dir_suffix="include"
258 AC_DEFINE_DIR(INCLUDE_DIR_SUFFIX, "${include_dir_suffix}")
259
260 lib_dir_suffix="lib"
261 AC_DEFINE_UNQUOTED(LIB_DIR_SUFFIX, "${lib_dir_suffix}")
262
263 ### <Obsolete>
264 # sdcc_datadir is still used in [device,lib]/Makefile
265 sdcc_datadir=${datadir}
266 AC_SUBST(sdcc_datadir)
267
268 # SDCC_[INCLUDE,LIB]_DIR is still used in SDCCmain.c
269 if test "${includedir}" = "\${prefix}/include"; then
270     includedir="${datadir}/include"
271 fi
272 AC_DEFINE_DIR(SDCC_INCLUDE_DIR, "${includedir}")
273 AC_DEFINE_DIR(SDCC_LIB_DIR,     "${datadir}/lib")
274 ### </Obsolete>
275
276 # environment variables
277 sdcc_dir_name="SDCC_HOME"
278 AC_DEFINE_DIR(SDCC_DIR_NAME, "${sdcc_dir_name}")
279 sdcc_include_name="SDCC_INCLUDE"
280 AC_DEFINE_DIR(SDCC_INCLUDE_NAME, "${sdcc_include_name}")
281 sdcc_lib_name="SDCC_LIB"
282 AC_DEFINE_DIR(SDCC_LIB_NAME, "${sdcc_lib_name}")
283
284 # Now handle the port selection
285 # ===========================================================================
286 rm -f ports.all ports.build
287 AC_ARG_ENABLE(mcs51-port,
288             AC_HELP_STRING([--disable-mcs51-port],
289                            [Excludes the Intel mcs51 port]))
290 echo mcs51 >>ports.all
291 if test "$enable_mcs51_port" = "no"; then
292     AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 1)
293 else
294     echo mcs51 >>ports.build
295     AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 0)
296 fi
297
298 AC_ARG_ENABLE(gbz80-port,
299             AC_HELP_STRING([--disable-gbz80-port],
300                            [Excludes the Gameboy gbz80 port]))
301 echo z80 >>ports.all
302 if test "$enable_gbz80_port" = "no"; then
303     AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 1)
304 else
305     echo z80 >>ports.build
306     AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 0)
307 fi
308
309 AC_ARG_ENABLE(z80-port,
310             AC_HELP_STRING([--disable-z80-port],
311                            [Excludes the z80 port]))
312 echo z80 >>ports.all
313 if test "$enable_z80_port" = "no"; then
314     AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 1)
315 else
316     echo z80 >>ports.build
317     AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 0)
318 fi
319
320 AC_ARG_ENABLE(avr-port,
321             AC_HELP_STRING([--disable-avr-port],
322                            [Excludes the AVR port]))
323 echo avr >>ports.all
324 if test "$enable_avr_port" = "no"; then
325     AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 1)
326 else
327     echo avr >>ports.build
328     AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 0)
329 fi
330
331 AC_ARG_ENABLE(ds390-port,
332             AC_HELP_STRING([--disable-ds390-port],
333                            [Excludes the DS390 port]))
334 echo ds390 >>ports.all
335 if test "$enable_ds390_port" = "no"; then
336     AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 1)
337     AC_DEFINE_UNQUOTED(OPT_DISABLE_TININative, 1)
338 else
339     echo ds390 >>ports.build
340     AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 0)
341     AC_DEFINE_UNQUOTED(OPT_DISABLE_TININative, 0)
342 fi
343
344 AC_ARG_ENABLE(pic-port,
345             AC_HELP_STRING([--disable-pic-port],
346                            [Excludes the PIC port]))
347 echo pic >>ports.all
348 if test "$enable_pic_port" = "no"; then
349     AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 1)
350 else
351     echo pic >>ports.build
352     AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 0)
353 fi
354
355 AC_ARG_ENABLE(xa51-port,
356             AC_HELP_STRING([--disable-xa51-port],
357                            [Excludes the XA51 port]))
358 echo xa51 >>ports.all
359 if test "$enable_xa51_port" = "no"; then
360     AC_DEFINE_UNQUOTED(OPT_DISABLE_XA51, 1)
361 else
362     echo xa51 >>ports.build
363     AC_DEFINE_UNQUOTED(OPT_DISABLE_XA51, 0)
364 fi
365
366 AC_ARG_ENABLE(ucsim,
367               AC_HELP_STRING([--disable-ucsim],
368                              [Disables configuring and building of ucsim]))
369 OPT_ENABLE_UCSIM=$enable_ucsim
370 AC_SUBST(OPT_ENABLE_UCSIM)
371
372 AC_ARG_ENABLE(device-lib-build,
373               AC_HELP_STRING([--disable-device-lib-build],
374                              [Disables automatically building device libraries]))
375 OPT_ENABLE_DEVICE_LIB_BUILD=$enable_device_lib_build
376 AC_SUBST(OPT_ENABLE_DEVICE_LIB_BUILD)
377
378 AC_ARG_ENABLE(packihx,
379               AC_HELP_STRING([--disable-packihx],
380                              [Disables building packihx]))
381 OPT_ENABLE_PACKIHX=$enable_packihx
382 AC_SUBST(OPT_ENABLE_PACKIHX)
383
384 AC_ARG_ENABLE(libgc,
385               AC_HELP_STRING([--enable-libgc],
386                              [Use the Bohem memory allocator. Lower runtime footprint.]))
387 if test "$enable_libgc" = "yes"; then
388         AC_CHECK_LIB(gc, GC_malloc)
389         OPT_ENABLE_LIBGC=1
390 else
391         OPT_ENABLE_LIBGC=0
392 fi
393 AC_DEFINE_UNQUOTED(OPT_ENABLE_LIBGC, $OPT_ENABLE_LIBGC)
394
395 #remove duplicates
396 cat ports.all | uniq >ports
397 mv ports ports.all
398 cat ports.build | uniq >ports
399 mv ports ports.build
400
401 # Generating output files
402 # ===========================================================================
403 AC_CONFIG_SUBDIRS(support/cpp2)
404 AC_CONFIG_SUBDIRS(packihx)
405 AC_CONFIG_SUBDIRS(sim/ucsim)
406 AC_CONFIG_FILES([main.mk:main_in.mk
407 src/Makefile
408 as/mcs51/Makefile
409 device/include/Makefile
410 device/lib/Makefile
411 debugger/mcs51/Makefile
412 Makefile.common:Makefile.common.in
413 ])
414 AC_OUTPUT
415
416 # End of configure/configure.in