7aebd36e54f029eaf2d3b5d946488a124a20de6b
[coreboot.git] / util / mkelfImage / configure.ac
1 dnl
2 dnl configure.ac for mkelfImage
3 dnl
4 dnl
5
6 dnl ---Required
7 AC_INIT(Makefile.conf.in)
8 AC_CONFIG_AUX_DIR(./config)
9
10 dnl --Options
11
12
13 dnl -- Compilation platform configuration
14 AC_CANONICAL_HOST
15 #AC_CANONICAL_TARGET
16
17
18 dnl Compute target cpu
19 case $host_cpu in
20         i?86 )
21                 target_cpu="i386"
22                 ;;
23         * )
24                 target_cpu="$host_cpu"
25                 ;;
26 esac
27
28 dnl ---Options
29 targets=""
30
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],
33         [ with_i386="no"])
34
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],
37         [ with_ia64="no"])
38
39 dnl If no targets are specified use a default
40 with_default="no"
41 if      test "$with_i386" = "no" &&
42         test "$with_ia64" = "no" ; then
43         with_default=`echo $target_cpu | tr [a-z] [A-Z]`
44 fi
45
46 AC_MSG_NOTICE([with_default=$with_default])
47 AC_MSG_NOTICE([with_i386=$with_i386])
48 AC_MSG_NOTICE([with_ia64=$with_ia64])
49
50 dnl ---Programs
51 dnl To specify a different compiler, just 'export CC=/path/to/compiler'
52
53 AC_PROG_CC
54
55
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])
64
65 AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, inflateInit_, [AC_DEFINE(HAVE_ZLIB_H, 1) LIBS="$LIBS -lz"]))
66
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])
71         fi
72         eval "${with_default}_CC='$CC'"
73         AC_PROG_CPP
74         if test "$CPP" = no; then
75                 AC_MSG_ERROR([cpp not found])
76         fi
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])
81         fi
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])
86         fi
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])
91         fi
92         eval "${with_default}_OBJCOPY='$OBJCOPY'"
93         if test "$with_default" = "X86_64" ; then
94                 with_i386=yes
95         fi
96 fi
97
98 dnl Find the programs for compiling i386 targets
99 if test "$with_i386" != "no" ; then
100         cc="gcc -m32"
101         cpp=cpp
102         ld=ld
103         as="as -32"
104         objcopy=objcopy
105         if test "$with_i386" != "" -a "$with_i386" != "yes" ; then
106                 cc="$with_i386-$cc"
107                 cpp="$with_i386-$cpp"
108                 ld="$with_i386-$ld"
109                 as="$with_i386-$as"
110                 objcopy="$with_i386-$objcopy"
111         fi
112         AC_CHECK_PROG([I386_CC], [$cc], [$cc], [""], [$PATH])
113         if test "$I386_CC" = no; then
114
115                 AC_MSG_ERROR([$cc not found])
116         fi
117         AC_CHECK_PROG([I386_CPP], [$cpp], [$cpp], [""], [$PATH])
118         if test "$I386_CPP" = no; then
119                 AC_MSG_ERROR([$cpp not found])
120         fi
121         AC_CHECK_PROG([I386_LD], [$ld], [$ld], [""], [$PATH])
122         if test "$I386_AS" = no; then
123                 AC_MSG_ERROR([$ld not found])
124         fi
125         AC_CHECK_PROG([I386_AS], [$as], [$as], [""], [$PATH])
126         if test "$I386_AS" = no; then
127                 AC_MSG_ERROR([$as not found])
128         fi
129         AC_CHECK_PROG([I386_OBJCOPY], [$objcopy], [$objcopy],[""], [$PATH])
130         if test "$I386_OBJCOPY" = no; then
131                 AC_MSG_ERROR([$objcopy not found])
132         fi
133 fi
134
135 dnl Find the programs for compiling ia64 targets
136 if test "$with_ia64" != "no" ; then
137         cc=gcc
138         cpp=cpp
139         ld=ld
140         as=as
141         objcopy=objcopy
142         if test "$with_ia64" != "" -a "$with_ia64" != "yes" ; then
143                 cc="$with_ia64-$cc"
144                 cpp="$with_ia64-$cpp"
145                 ld="$with_ia64-$ld"
146                 as="$with_ia64-$as"
147                 objcopy="$with_ia64-$objcopy"
148         fi
149         AC_CHECK_PROG([IA64_CC], [$cc], [$cc], [""], [$PATH])
150         if test "$IA64_CC" = no; then
151
152                 AC_MSG_ERROR([$cc not found])
153         fi
154         AC_CHECK_PROG([IA64_CPP], [$cpp], [$cpp], [""], [$PATH])
155         if test "$IA64_CPP" = no; then
156                 AC_MSG_ERROR([$cpp not found])
157         fi
158         AC_CHECK_PROG([IA64_LD], [$ld], [$ld], [""], [$PATH])
159         if test "$IA64_AS" = no; then
160                 AC_MSG_ERROR([$ld not found])
161         fi
162         AC_CHECK_PROG([IA64_AS], [$as], [$as], [""], [$PATH])
163         if test "$IA64_AS" = no; then
164                 AC_MSG_ERROR([$as not found])
165         fi
166         AC_CHECK_PROG([IA64_OBJCOPY], [$objcopy], [$objcopy],[""], [$PATH])
167         if test "$IA64_OBJCOPY" = no; then
168                 AC_MSG_ERROR([$objcopy not found])
169         fi
170 fi
171
172
173 dnl ---Output variables...
174
175 HOST_CC=$CC
176 HOST_CFLAGS="$HOST_CFLAGS -O2 -Wall \$(HOST_CPPFLAGS)"
177
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)"
180 I386_ASFLAGS=''
181 I386_LDFLAGS='-static --warn-multiple-gp --warn-common'
182
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'
187
188 AC_SUBST([HOST_CC])
189 AC_SUBST([HOST_CFLAGS])
190
191 AC_SUBST([I386_CC])
192 AC_SUBST([I386_LD])
193 AC_SUBST([I386_AS])
194 AC_SUBST([I386_CPP])
195 AC_SUBST([I386_OBJCOPY])
196 AC_SUBST([I386_CFLAGS])
197 AC_SUBST([I386_ASFLAGS])
198 AC_SUBST([I386_LDFLAGS])
199
200 AC_SUBST([IA64_CC])
201 AC_SUBST([IA64_LD])
202 AC_SUBST([IA64_AS])
203 AC_SUBST([IA64_CPP])
204 AC_SUBST([IA64_OBJCOPY])
205 AC_SUBST([IA64_CFLAGS])
206 AC_SUBST([IA64_ASFLAGS])
207 AC_SUBST([IA64_LDFLAGS])
208
209 dnl ---Output
210 AC_OUTPUT([Makefile.conf])
211
212