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
|
dnl
dnl configure.ac for mkelfImage
dnl
dnl
dnl ---Required
AC_INIT(Makefile.conf.in)
AC_CONFIG_AUX_DIR(./config)
dnl --Options
dnl -- Compilation platform configuration
AC_CANONICAL_HOST
#AC_CANONICAL_TARGET
dnl Compute target cpu
case $host_cpu in
i?86 )
target_cpu="i386"
;;
* )
target_cpu="$host_cpu"
;;
esac
dnl ---Options
targets=""
AC_ARG_WITH([i386], AC_HELP_STRING([--with-i386],[enable building i386 code]),
[ if test "withval" = "yes" ; then with_i386="i386"; else with_i386="$withval"; fi],
[ with_i386="no"])
AC_ARG_WITH([ia64], AC_HELP_STRING([--with-ia64],[enable building ia64 code]),
[ if test "withval" = "yes" ; then with_ia64="ia64"; else with_ia64="$withval"; fi],
[ with_ia64="no"])
dnl If no targets are specified use a default
with_default="no"
if test "$with_i386" = "no" &&
test "$with_ia64" = "no" ; then
with_default=`echo $target_cpu | tr [a-z] [A-Z]`
fi
AC_MSG_NOTICE([with_default=$with_default])
AC_MSG_NOTICE([with_i386=$with_i386])
AC_MSG_NOTICE([with_ia64=$with_ia64])
dnl ---Programs
dnl To specify a different compiler, just 'export CC=/path/to/compiler'
AC_PROG_CC
AC_CHECK_PROG([MKDIR], mkdir, mkdir, [], [$PATH])
AC_CHECK_PROG([RM], rm, rm, [], [$PATH])
AC_CHECK_PROG([CP], cp, cp, [], [$PATH])
AC_CHECK_PROG([LN], ln, ln, [], [$PATH])
AC_CHECK_PROG([TAR], tar, tar, [], [$PATH])
AC_CHECK_PROG([RPM], rpm, rpm, [], [$PATH])
AC_CHECK_PROG([SED], sed, sed, [], [$PATH])
AC_CHECK_PROG([FIND], find, find, [], [$PATH])
AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, inflateInit_, [AC_DEFINE(HAVE_ZLIB_H, 1) LIBS="$LIBS -lz"]))
dnl Find the default programs
if test "with_default" != no ; then
if test "$CC" = no; then
AC_MSG_ERROR([cc not found])
fi
eval "${with_default}_CC='$CC'"
AC_PROG_CPP
if test "$CPP" = no; then
AC_MSG_ERROR([cpp not found])
fi
eval "${with_default}_CPP='$CPP'"
AC_CHECK_TOOL([LD], ld, no)
if test "$LD" = no; then
AC_MSG_ERROR([ld not found])
fi
eval "${with_default}_LD='$LD'"
AC_CHECK_TOOL([AS], as, no)
if test "$AS" = no; then
AC_MSG_ERROR([as not found])
fi
eval "${with_default}_AS='$AS'"
AC_CHECK_TOOL([OBJCOPY], objcopy, no)
if test "$OBJCOPY" = no; then
AC_MSG_ERROR([objcopy not found])
fi
eval "${with_default}_OBJCOPY='$OBJCOPY'"
if test "$with_default" = "X86_64" ; then
with_i386=yes
fi
fi
dnl Find the programs for compiling i386 targets
if test "$with_i386" != "no" ; then
cc="gcc -m32"
cpp=cpp
ld=ld
as="as -32"
objcopy=objcopy
if test "$with_i386" != "" -a "$with_i386" != "yes" ; then
cc="$with_i386-$cc"
cpp="$with_i386-$cpp"
ld="$with_i386-$ld"
as="$with_i386-$as"
objcopy="$with_i386-$objcopy"
fi
AC_CHECK_PROG([I386_CC], [$cc], [$cc], [""], [$PATH])
if test "$I386_CC" = no; then
AC_MSG_ERROR([$cc not found])
fi
AC_CHECK_PROG([I386_CPP], [$cpp], [$cpp], [""], [$PATH])
if test "$I386_CPP" = no; then
AC_MSG_ERROR([$cpp not found])
fi
AC_CHECK_PROG([I386_LD], [$ld], [$ld], [""], [$PATH])
if test "$I386_AS" = no; then
AC_MSG_ERROR([$ld not found])
fi
AC_CHECK_PROG([I386_AS], [$as], [$as], [""], [$PATH])
if test "$I386_AS" = no; then
AC_MSG_ERROR([$as not found])
fi
AC_CHECK_PROG([I386_OBJCOPY], [$objcopy], [$objcopy],[""], [$PATH])
if test "$I386_OBJCOPY" = no; then
AC_MSG_ERROR([$objcopy not found])
fi
fi
dnl Find the programs for compiling ia64 targets
if test "$with_ia64" != "no" ; then
cc=gcc
cpp=cpp
ld=ld
as=as
objcopy=objcopy
if test "$with_ia64" != "" -a "$with_ia64" != "yes" ; then
cc="$with_ia64-$cc"
cpp="$with_ia64-$cpp"
ld="$with_ia64-$ld"
as="$with_ia64-$as"
objcopy="$with_ia64-$objcopy"
fi
AC_CHECK_PROG([IA64_CC], [$cc], [$cc], [""], [$PATH])
if test "$IA64_CC" = no; then
AC_MSG_ERROR([$cc not found])
fi
AC_CHECK_PROG([IA64_CPP], [$cpp], [$cpp], [""], [$PATH])
if test "$IA64_CPP" = no; then
AC_MSG_ERROR([$cpp not found])
fi
AC_CHECK_PROG([IA64_LD], [$ld], [$ld], [""], [$PATH])
if test "$IA64_AS" = no; then
AC_MSG_ERROR([$ld not found])
fi
AC_CHECK_PROG([IA64_AS], [$as], [$as], [""], [$PATH])
if test "$IA64_AS" = no; then
AC_MSG_ERROR([$as not found])
fi
AC_CHECK_PROG([IA64_OBJCOPY], [$objcopy], [$objcopy],[""], [$PATH])
if test "$IA64_OBJCOPY" = no; then
AC_MSG_ERROR([$objcopy not found])
fi
fi
dnl ---Output variables...
HOST_CC=$CC
HOST_CFLAGS='-O2 -Wall $(HOST_CPPFLAGS)'
dnl TODO: figure out how to set these appropriately for compilers other than gcc
I386_CFLAGS='-Os -ffreestanding -Wall -W -Wno-format $(I386_CPPFLAGS)'
I386_ASFLAGS=''
I386_LDFLAGS='-static --warn-multiple-gp --warn-common'
dnl TODO: figure out how to set these appropriately for compilers other than gcc
IA64_CFLAGS='-Os -ffreestanding -Wall -W -Wno-format -fpic -mconstant-gp -mauto-pic -fno-unwind-tables $(IA64_CPPFLAGS)'
IA64_ASFLAGS='-mconstant-gp -mauto-pic'
IA64_LDFLAGS='-static --warn-multiple-gp --warn-common'
AC_SUBST([HOST_CC])
AC_SUBST([HOST_CFLAGS])
AC_SUBST([I386_CC])
AC_SUBST([I386_LD])
AC_SUBST([I386_AS])
AC_SUBST([I386_CPP])
AC_SUBST([I386_OBJCOPY])
AC_SUBST([I386_CFLAGS])
AC_SUBST([I386_ASFLAGS])
AC_SUBST([I386_LDFLAGS])
AC_SUBST([IA64_CC])
AC_SUBST([IA64_LD])
AC_SUBST([IA64_AS])
AC_SUBST([IA64_CPP])
AC_SUBST([IA64_OBJCOPY])
AC_SUBST([IA64_CFLAGS])
AC_SUBST([IA64_ASFLAGS])
AC_SUBST([IA64_LDFLAGS])
dnl ---Output
AC_OUTPUT([Makefile.conf])
|