beautified --disable-*-port options
[fw/sdcc] / configure.in
1 #!/bin/sh
2
3 AC_INIT(Makefile)
4 AC_CONFIG_HEADER(sdccconf.h:sdccconf_in.h)
5
6 AC_PROG_AWK
7
8 AC_MSG_CHECKING(version of the package)
9 if test -f .version; then
10   VERSION=`cat .version`
11 elif test -f ../.version; then
12   VERSION=`cat ../.version`
13 else
14   VERSION="0.0.0"
15 fi
16 VERSIONHI=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $1}'`
17 VERSIONLO=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $2}'`
18 VERSIONP=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $3}'`
19 AC_MSG_RESULT(${VERSION})
20 AC_SUBST(VERSION)
21 AC_SUBST(VERSIONHI)
22 AC_SUBST(VERSIONLO)
23 AC_SUBST(VERSIONP)
24 AC_DEFINE_UNQUOTED(SDCC_VERSION_LO, ${VERSIONLO})
25 AC_DEFINE_UNQUOTED(SDCC_VERSION_HI, ${VERSIONHI})
26 AC_DEFINE_UNQUOTED(SDCC_VERSION_P, ${VERSIONP})
27 AC_DEFINE_UNQUOTED(SDCC_VERSION_STR, "${VERSION}")
28 sdcc_cv_version=$VERSION
29 sdcc_cv_versionhi=$VERSIONHI
30 sdcc_cv_versionlo=$VERSIONLO
31 sdcc_cv_versionp=$VERSIONP
32
33 # Required programs
34 #-------------------
35 AC_PROG_CC
36 AC_PROG_CXX
37 AC_PROG_CPP
38 AC_PROG_INSTALL
39 AC_PROG_RANLIB
40 AC_PROG_LEX(flex, :)
41 AC_CHECK_PROG(YACC, bison, bison -y, :)
42 AC_CHECK_PROG(AUTOCONF, autoconf, autoconf, :)
43 AC_CHECK_PROG(AS, as, as, :)
44 AC_CHECK_PROG(CP, cp, cp, :)
45
46 AC_DEFUN(SDCC_REQUIRE_PROG, 
47 [if test "$1" = ":"; then
48   AC_MSG_ERROR([Cannot find required program $2.])
49  fi
50 ])
51
52 SDCC_REQUIRE_PROG($YACC, bison)
53 SDCC_REQUIRE_PROG($LEX, lex)
54
55 AC_LANG_C
56
57 # Checking for header files.
58 # ===========================================================================
59 AC_HEADER_STDC
60 AC_CHECK_HEADERS(getopt.h)
61 AC_CHECK_HEADERS(unistd.h)
62 AC_CHECK_HEADERS(endian.h)
63 AC_CHECK_HEADERS(malloc.h)
64 AC_CHECK_HEADERS(sys/isa_defs.h)
65 AC_CHECK_HEADERS(sys/socket.h)
66 AC_HEADER_DIRENT
67
68 # This must be after CPP
69
70 AC_CACHE_CHECK(which header file defines FD_ macros, s51_cv_fd,
71 [sdcc_cv_fd="unknown"
72 AC_EGREP_CPP(yes, [
73 #include <sys/time.h>
74 #ifdef FD_ZERO
75 yes
76 #endif], sdcc_cv_fd="<sys/time.h>")
77 AC_EGREP_CPP(yes, [
78 #include <sys/types.h>
79 #ifdef FD_ZERO
80 yes
81 #endif], sdcc_cv_fd="<sys/types.h>")
82 AC_EGREP_CPP(yes, [
83 #include <sys/select.h>
84 #ifdef FD_ZERO
85 yes
86 #endif], sdcc_cv_fd="<sys/types.h>")])
87
88 AC_DEFINE(FD_HEADER_OK, 0)
89 if echo $sdcc_cv_fd|grep time >/dev/null 2>&1; then
90 AC_DEFINE(FD_NEED_TIME_H, 1)
91 AC_DEFINE(FD_HEADER_OK, 1)
92 else
93 AC_DEFINE(FD_NEED_TIME_H, 0)
94 fi
95 if echo $sdcc_cv_fd|grep types >/dev/null 2>&1; then
96 AC_DEFINE(FD_NEED_TYPES_H, 1)
97 AC_DEFINE(FD_HEADER_OK, 1)
98 else
99 AC_DEFINE(FD_NEED_TYPES_H, 0)
100 fi
101 if echo $sdcc_cv_fd|grep select >/dev/null 2>&1; then
102 AC_DEFINE(FD_NEED_SELECT_H, 1)
103 AC_DEFINE(FD_HEADER_OK, 1)
104 else
105 AC_DEFINE(FD_NEED_SELECT_H, 0)
106 fi
107
108 AC_DEFINE_UNQUOTED(HEADER_FD, ${sdcc_cv_fd})
109
110
111 # Checking for functions
112 # ===========================================================================
113 AC_CHECK_FUNCS(strlen strcpy strcat strstr strcmp strerror strtok strdup)
114 AC_CHECK_FUNCS(strchr memcpy)
115 dnl AC_CHECK_FUNCS(getline)
116 dnl AC_CHECK_FUNCS(getdelim)
117 AC_CHECK_FUNCS(fgets)
118 AC_CHECK_FUNCS(yylex)
119
120 # check if -lsocket && -lxnet is required to compile socket stuff
121 AC_SEARCH_LIBS(socket,socket)
122 AC_SEARCH_LIBS(inet_addr,nsl xnet)
123
124 # Macro definitions
125 ###################
126
127 # DD_COPT macro checks if the compiler specified as the 1st parameter
128 # supports option specified as the 2nd parameter
129 # For example: DD_CPORT(CXX, fPIC)
130
131 AC_DEFUN(DD_COPT, [
132 AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2,
133 cat >_test_.c <<EOF
134 #include <stdio.h>
135 void main(void) {}
136 EOF
137 $$1 -v -$2 -c _test_.c 1>&5 2>&5
138 if test "$?" = "0"; then
139   sdcc_cv_$1$2="yes"
140 else
141   sdcc_cv_$1$2="no"
142 fi
143 rm -f _test_.* a.out)
144 ])
145
146
147 # Checking characteristics of compilers and other programs
148 # --------------------------------------------------------
149 AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,sdcc_cv_MM,
150 echo "#include <stdio.h>" >_test_.c
151 echo "" >>_test_.c
152 $CPP -v -MM _test_.c 1>&5 2>&5
153 if test "$?" = "0"; then
154   sdcc_cv_MM="-MM"
155 else
156   sdcc_cv_MM="-M"
157 fi
158 rm -f _test_.*)
159 M_OR_MM=$sdcc_cv_MM
160 AC_SUBST(M_OR_MM)
161
162 # This is the first time when CFLAGS are set/modified!!
163 DD_COPT(CC, ggdb)
164 if test "$sdcc_cv_CCggdb" = "yes"; then
165   CFLAGS="-ggdb -O2"
166 fi
167
168 DD_COPT(CC, pipe)
169 if test "$sdcc_cv_CCpipe" = "yes"; then
170   CFLAGS="$CFLAGS -pipe"
171 fi
172
173
174 # Checks for typedefs, structures, and compiler characteristics.
175 # ===========================================================================
176 AC_TYPE_SIGNAL
177
178 #
179 #
180 if test "${prefix}" = "NONE"; then
181     prefix="/usr/local"
182 fi
183
184 config_in=`pwd`
185 sdcc_datadir=${datadir}/sdcc
186 AC_SUBST(sdcc_datadir)
187
188 # For some unknown reason, putting this assignment in a subshell
189 # like this causes the rvalue to be fully substituted. We need this
190 # for the defines below to generate the right thing. We keep this
191 # separate from the substituted sdcc_datadir because we want the
192 # latter for makefiles.
193 if test "${datadir}" = "\${prefix}/share"; then
194     sdcc_datadir_tmp=${prefix}/share/sdcc
195 else
196     sdcc_datadir_tmp=${datadir}/sdcc
197 fi
198
199
200 AC_DEFINE_UNQUOTED(STANDARD_INCLUDE_DIR, "${sdcc_datadir_tmp}/include")
201 AC_DEFINE_UNQUOTED(SDCC_INCLUDE_DIR, "${sdcc_datadir_tmp}/include")
202 AC_DEFINE_UNQUOTED(SDCC_LIB_DIR, "${sdcc_datadir_tmp}/lib")
203 AC_DEFINE_UNQUOTED(STD_LIB, "libsdcc")
204 AC_DEFINE_UNQUOTED(STD_INT_LIB, "libint")
205 AC_DEFINE_UNQUOTED(STD_LONG_LIB, "liblong")
206 AC_DEFINE_UNQUOTED(STD_FP_LIB, "libfloat")
207 AC_DEFINE_UNQUOTED(STD_DS390_LIB, "libds390")
208
209 AC_DEFINE_UNQUOTED(PREFIX, "${prefix}")
210 AC_DEFINE_UNQUOTED(DATADIR, "${sdcc_datadir_tmp}")
211 AC_DEFINE_UNQUOTED(SRCDIR, "${config_in}")
212
213
214
215 # Now handle the port selection
216 rm -f ports.all ports.build
217 AC_ARG_ENABLE(mcs51-port,[  --disable-mcs51-port    Excludes the Intel mcs51 port])
218 echo mcs51 >>ports.all
219 if test "$enable_mcs51_port" = "no"; then
220     AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 1)
221 else
222     echo mcs51 >>ports.build
223     AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 0)
224 fi
225
226 AC_ARG_ENABLE(gbz80-port,[  --disable-gbz80-port    Excludes the Gameboy gbz80 port])
227 echo z80 >>ports.all
228 if test "$enable_gbz80_port" = "no"; then
229     AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 1)
230 else
231     echo z80 >>ports.build
232     AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 0)
233 fi
234
235 AC_ARG_ENABLE(z80-port,[  --disable-z80-port      Excludes the z80 port])
236 echo z80 >>ports.all
237 if test "$enable_z80_port" = "no"; then
238     AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 1)
239 else
240     echo z80 >>ports.build
241     AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 0)
242 fi
243
244 AC_ARG_ENABLE(avr-port,[  --disable-avr-port      Excludes the AVR port])
245 echo avr >>ports.all
246 if test "$enable_avr_port" = "no"; then
247     AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 1)
248 else
249     echo avr >>ports.build
250     AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 0)
251 fi
252
253 AC_ARG_ENABLE(ds390-port,[  --disable-ds390-port    Excludes the DS390 port])
254 echo ds390 >>ports.all
255 if test "$enable_ds390_port" = "no"; then
256     AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 1)
257 else
258     echo ds390 >>ports.build
259     AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 0)
260 fi
261
262 AC_ARG_ENABLE(pic-port,[  --disable-pic-port      Excludes the PIC port])
263 echo pic >>ports.all
264 if test "$enable_pic_port" = "no"; then
265     AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 1)
266 else
267     echo pic >>ports.build
268     AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 0)
269 fi
270
271 AC_ARG_ENABLE(i186-port,[  --disable-i186-port     Excludes the I186 port])
272 echo izt >>ports.all
273 if test "$enable_i186_port" = "no"; then
274     AC_DEFINE_UNQUOTED(OPT_DISABLE_I186, 1)
275 else
276     echo izt >>ports.build
277     AC_DEFINE_UNQUOTED(OPT_DISABLE_I186, 0)
278 fi
279
280 AC_ARG_ENABLE(tlcs900h-port,[  --disable-tlcs900h-port Excludes the TLCS900H port])
281 echo izt >>ports.all
282 if test "$enable_tlcs900h_port" = "no"; then
283     AC_DEFINE_UNQUOTED(OPT_DISABLE_TLCS900H, 1)
284 else
285     echo izt >>ports.build
286     AC_DEFINE_UNQUOTED(OPT_DISABLE_TLCS900H, 0)
287 fi
288
289 #remove duplicates
290 cat ports.all | uniq >ports
291 mv ports ports.all
292 cat ports.build | uniq >ports
293 mv ports ports.build
294
295 # Generating output files
296 # ===========================================================================
297 AC_CONFIG_SUBDIRS(sim/ucsim)
298 AC_CONFIG_SUBDIRS(packihx)
299 # MLH: removed as the rules are already in Makefile.common
300 #as/z80/Makefile
301 #link/z80/Makefile
302 AC_OUTPUT(main.mk:main_in.mk
303 src/Makefile
304 as/mcs51/Makefile
305 support/cpp/Makefile
306 device/include/Makefile
307 device/lib/Makefile
308 debugger/mcs51/Makefile
309 Makefile.common:Makefile.common.in
310 )
311
312 # End of configure/configure.in