2 dnl configure.ac for mkelfImage
7 AC_INIT(Makefile.conf.in)
8 AC_CONFIG_AUX_DIR(./config)
13 dnl -- Compilation platform configuration
18 dnl Compute target cpu
24 target_cpu="$host_cpu"
31 AC_ARG_WITH([i386], AC_HELP_STRING([--with-i386],[enable building i386 code]),
32 [ if test "withval" = "yes" ; then with_i386="i386"; else with_i386="$withval"; fi],
35 AC_ARG_WITH([ia64], AC_HELP_STRING([--with-ia64],[enable building ia64 code]),
36 [ if test "withval" = "yes" ; then with_ia64="ia64"; else with_ia64="$withval"; fi],
39 dnl If no targets are specified use a default
41 if test "$with_i386" = "no" &&
42 test "$with_ia64" = "no" ; then
43 with_default=`echo $target_cpu | tr [a-z] [A-Z]`
46 AC_MSG_NOTICE([with_default=$with_default])
47 AC_MSG_NOTICE([with_i386=$with_i386])
48 AC_MSG_NOTICE([with_ia64=$with_ia64])
51 dnl To specify a different compiler, just 'export CC=/path/to/compiler'
56 AC_CHECK_PROG([MKDIR], mkdir, mkdir, [], [$PATH])
57 AC_CHECK_PROG([RM], rm, rm, [], [$PATH])
58 AC_CHECK_PROG([CP], cp, cp, [], [$PATH])
59 AC_CHECK_PROG([LN], ln, ln, [], [$PATH])
60 AC_CHECK_PROG([TAR], tar, tar, [], [$PATH])
61 AC_CHECK_PROG([RPM], rpm, rpm, [], [$PATH])
62 AC_CHECK_PROG([SED], sed, sed, [], [$PATH])
63 AC_CHECK_PROG([FIND], find, find, [], [$PATH])
65 AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, inflateInit_, [AC_DEFINE(HAVE_ZLIB_H, 1) LIBS="$LIBS -lz"]))
67 dnl Find the default programs
68 if test "with_default" != no ; then
69 if test "$CC" = no; then
70 AC_MSG_ERROR([cc not found])
72 eval "${with_default}_CC='$CC'"
74 if test "$CPP" = no; then
75 AC_MSG_ERROR([cpp not found])
77 eval "${with_default}_CPP='$CPP'"
78 AC_CHECK_TOOL([LD], ld, no)
79 if test "$LD" = no; then
80 AC_MSG_ERROR([ld not found])
82 eval "${with_default}_LD='$LD'"
83 AC_CHECK_TOOL([AS], as, no)
84 if test "$AS" = no; then
85 AC_MSG_ERROR([as not found])
87 eval "${with_default}_AS='$AS'"
88 AC_CHECK_TOOL([OBJCOPY], objcopy, no)
89 if test "$OBJCOPY" = no; then
90 AC_MSG_ERROR([objcopy not found])
92 eval "${with_default}_OBJCOPY='$OBJCOPY'"
93 if test "$with_default" = "X86_64" ; then
98 dnl Find the programs for compiling i386 targets
99 if test "$with_i386" != "no" ; then
105 if test "$with_i386" != "" -a "$with_i386" != "yes" ; then
107 cpp="$with_i386-$cpp"
110 objcopy="$with_i386-$objcopy"
112 AC_CHECK_PROG([I386_CC], [$cc], [$cc], [""], [$PATH])
113 if test "$I386_CC" = no; then
115 AC_MSG_ERROR([$cc not found])
117 AC_CHECK_PROG([I386_CPP], [$cpp], [$cpp], [""], [$PATH])
118 if test "$I386_CPP" = no; then
119 AC_MSG_ERROR([$cpp not found])
121 AC_CHECK_PROG([I386_LD], [$ld], [$ld], [""], [$PATH])
122 if test "$I386_AS" = no; then
123 AC_MSG_ERROR([$ld not found])
125 AC_CHECK_PROG([I386_AS], [$as], [$as], [""], [$PATH])
126 if test "$I386_AS" = no; then
127 AC_MSG_ERROR([$as not found])
129 AC_CHECK_PROG([I386_OBJCOPY], [$objcopy], [$objcopy],[""], [$PATH])
130 if test "$I386_OBJCOPY" = no; then
131 AC_MSG_ERROR([$objcopy not found])
135 dnl Find the programs for compiling ia64 targets
136 if test "$with_ia64" != "no" ; then
142 if test "$with_ia64" != "" -a "$with_ia64" != "yes" ; then
144 cpp="$with_ia64-$cpp"
147 objcopy="$with_ia64-$objcopy"
149 AC_CHECK_PROG([IA64_CC], [$cc], [$cc], [""], [$PATH])
150 if test "$IA64_CC" = no; then
152 AC_MSG_ERROR([$cc not found])
154 AC_CHECK_PROG([IA64_CPP], [$cpp], [$cpp], [""], [$PATH])
155 if test "$IA64_CPP" = no; then
156 AC_MSG_ERROR([$cpp not found])
158 AC_CHECK_PROG([IA64_LD], [$ld], [$ld], [""], [$PATH])
159 if test "$IA64_AS" = no; then
160 AC_MSG_ERROR([$ld not found])
162 AC_CHECK_PROG([IA64_AS], [$as], [$as], [""], [$PATH])
163 if test "$IA64_AS" = no; then
164 AC_MSG_ERROR([$as not found])
166 AC_CHECK_PROG([IA64_OBJCOPY], [$objcopy], [$objcopy],[""], [$PATH])
167 if test "$IA64_OBJCOPY" = no; then
168 AC_MSG_ERROR([$objcopy not found])
173 dnl ---Output variables...
176 HOST_CFLAGS="$HOST_CFLAGS -O2 -Wall \$(HOST_CPPFLAGS)"
178 dnl TODO: figure out how to set these appropriately for compilers other than gcc
179 I386_CFLAGS="$I386_CFLAGS -Os -ffreestanding -Wall -W -Wno-format \$(I386_CPPFLAGS)"
181 I386_LDFLAGS='-static --warn-multiple-gp --warn-common'
183 dnl TODO: figure out how to set these appropriately for compilers other than gcc
184 IA64_CFLAGS="$IA64_CFLAGS -Os -ffreestanding -Wall -W -Wno-format -fpic -mconstant-gp -mauto-pic -fno-unwind-tables \$(IA64_CPPFLAGS)"
185 IA64_ASFLAGS='-mconstant-gp -mauto-pic'
186 IA64_LDFLAGS='-static --warn-multiple-gp --warn-common'
190 AC_CACHE_CHECK(for -fno-stack-protector, libc_cv_fno_stack_protector, [
191 cat > conftest.c <<EOF
195 if AC_TRY_COMMAND([$I386_CC -fno-stack-protector
196 -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
198 libc_cv_fno_stack_protector=yes
200 libc_cv_fno_stack_protector=no
203 if test $libc_cv_fno_stack_protector = yes; then
204 I386_CFLAGS="$I386_CFLAGS -fno-stack-protector"
205 IA64_CFLAGS="$IA64_CFLAGS -fno-stack-protector"
208 AC_SUBST(libc_cv_fno_stack_protector)
210 AC_SUBST([HOST_CFLAGS])
216 AC_SUBST([I386_OBJCOPY])
217 AC_SUBST([I386_CFLAGS])
218 AC_SUBST([I386_ASFLAGS])
219 AC_SUBST([I386_LDFLAGS])
225 AC_SUBST([IA64_OBJCOPY])
226 AC_SUBST([IA64_CFLAGS])
227 AC_SUBST([IA64_ASFLAGS])
228 AC_SUBST([IA64_LDFLAGS])
231 AC_OUTPUT([Makefile.conf])