summaryrefslogtreecommitdiff
path: root/configure.ac
blob: c387349f3540680cb1504c7b6ec02aaec1a283f2 (plain)
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
dnl Configure script for GNU Mach.

dnl Copyright (C) 1997, 1998, 1999, 2004, 2006, 2007
dnl Free Software Foundation, Inc.

dnl Permission to use, copy, modify and distribute this software and its
dnl documentation is hereby granted, provided that both the copyright
dnl notice and this permission notice appear in all copies of the
dnl software, derivative works or modified versions, and any portions
dnl thereof, and that both notices appear in supporting documentation.
dnl
dnl THE FREE SOFTWARE FOUNDATION ALLOWS FREE USE OF THIS SOFTWARE IN ITS
dnl "AS IS" CONDITION.  THE FREE SOFTWARE FOUNDATION DISCLAIMS ANY
dnl LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
dnl USE OF THIS SOFTWARE.

AC_PREREQ([2.57])

m4_include([version.m4])
AC_INIT([AC_PACKAGE_NAME], [AC_PACKAGE_VERSION], [AC_PACKAGE_BUGREPORT],
  [AC_PACKAGE_TARNAME])
AC_CONFIG_SRCDIR([kern/ipc_kobject.c])

AC_CONFIG_AUX_DIR([build-aux])

AM_INIT_AUTOMAKE(
dnl Don't define `PACKAGE' and `VERSION'.
  [no-define]
dnl Do not clutter the main build directory.
  [subdir-objects]
dnl This is only a very rough estimation of the version we actually need.  Feel
dnl free to refine that.
  [1.9]
dnl We require GNU make.
  [-Wall -Wno-portability]
)

#
# Deduce the architecture we're building for.
#

AC_CANONICAL_HOST

AC_ARG_ENABLE([platform],
  AS_HELP_STRING([--enable-platform=PLATFORM], [specify the platform to build a
    kernel for.  Defaults to `at' for `i?86'.  No other possibilities.]),
  [host_platform=$enable_platform],
  [host_platform=default])
[# Supported configurations.
case $host_platform:$host_cpu in
  default:i?86)
    host_platform=at;;
  at:i?86)
    :;;
  *)]
    AC_MSG_ERROR([unsupported combination of cpu type `$host_cpu' and platform
      `$host_platform'.])[;;
esac]
AC_SUBST([host_platform])

[# This is used in a few places.
case $host_cpu in
  i?86)
    systype=i386;;
  *)
    systype=$host_cpu;;
esac]
AC_SUBST([systype])

#
# Programs.
#

AC_PROG_AWK
AM_PROG_AS
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_CHECK_TOOL([AR], [ar])
AC_CHECK_TOOL([LD], [ld])
AC_CHECK_TOOL([NM], [nm])

AC_CHECK_TOOL([MIG], [mig], [mig])

dnl Needed for the Automake option `subdir-objects'.
AM_PROG_CC_C_O

dnl Makerules can make use of these.
AC_CHECK_PROG([GZIP], [gzip], [gzip], [gzip-not-found])
AC_CHECK_TOOL([STRIP], [strip])

dnl See below why we need to patch stuff during build...
AC_CHECK_PROG([PATCH], [patch], [patch], [patch-not-found])

#
# configure fragments.
#

# The test suite.
m4_include([tests/configfrag.ac])

# Default set of device drivers.
AC_ARG_ENABLE([device-drivers],
  AS_HELP_STRING([--enable-device-drivers=WHICH], [specify WHICH (on `ix86-at'
    one of `default', `qemu', `none') to preset a certain subset of all
    available device drivers, as indicated by the below-metioned ``enabled
    ...'' comments; you can then still use further `--enable-*' or
    `--disable-*' options to refine the selection of drivers to include in
    order to choose only those you actually want to have enabled]))
[case $enable_device_drivers in
  '')
    enable_device_drivers=default;;
  no)
    enable_device_drivers=none;;
  default | none | qemu)
    :;;
  *)]
    AC_MSG_ERROR([invalid choice of]
      [`--enable-device-drivers=$enable_device_drivers'.])
    [;;
esac]

# Platform-specific configuration.

# PC AT.
# TODO.  Currently handled in `i386/configfrag.ac'.

# Machine-specific configuration.

# ix86.
m4_include([i386/configfrag.ac])

# General options.
m4_include([configfrag.ac])

# Linux code snarfed into GNU Mach.
m4_include([linux/configfrag.ac])

#
# Compiler features.
#

# Smashing stack protector.
[ssp_possible=yes]
AC_MSG_CHECKING([whether the compiler accepts `-fstack-protector'])
# Is this a reliable test case?
AC_LANG_CONFTEST([[void foo (void) { volatile char a[8]; a[3]; }]])
[# `$CC -c -o ...' might not be portable.  But, oh, well...  Is calling
# `ac_compile' like this correct, after all?
if eval "$ac_compile -S -fstack-protector -o conftest.s" 2> /dev/null; then]
  AC_MSG_RESULT([yes])
  [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'?
  rm -f conftest.s
else
  ssp_possible=no]
  AC_MSG_RESULT([no])
[fi
# Need that, because some distributions ship compilers that include
# `-fstack-protector' in the default specs.]
AM_CONDITIONAL([disable_smashing_stack_protector],
  [[[ x"$ssp_possible" = xyes ]]])

#
# Output.
#

AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile version.c])

#
# The remaining ugly, dark corners...
#
# Attention, parents: don't show this to your children...
#

#
# config.status.dep.patch
#
# This is a (ugly --- I admit) bootstrap hack to get to-be-generated files
# created before any other source files are compiled.
#
# See <http://lists.gnu.org/archive/html/automake/2006-05/msg00038.html>.
#
# We don't use `BUILT_SOURCES' (as it was suggested in the follow-up message),
# as we also want things like `make SPECIFIC_TARGET' to work.
#
# This affair is especially ugly because internals are used (the `# dummy'
# tag): internals that may be subject to changes.  That's the reason why a
# real patch is being used here and not some `sed' magic: to make it fail
# loudly in case.
#
# For all shipped source files a dependency file is tried to be created where
# it is simply stated that the respective source file depends on _all_
# to-be-generated files.  Depending on all of them doesn't do any harm, as they
# will nevertheless have to be created, sooner or later.  The problem is, that
# `config.status' doesn't know about the source file of the file it is
# currently creating the dependency file for.  So we have it do an educated
# guess...  Later, when compiling the source files, these dependency files will
# be rewritten to contain the files's actual dependencies.  From then on this
# bootstrap hack will be forgotten.
#

dnl AC_CONFIG_COMMANDS_POST([
dnl   sed -i -e \
dnl     's%#\ dummy%Makefile: $(filter-out $(DIST_SOURCES),$(SOURCES))%' \
dnl     config.status
dnl ])
AC_CONFIG_COMMANDS_POST([
  if "$PATCH" -f < "$srcdir"/config.status.dep.patch
  then] AC_MSG_NOTICE([Applied a patch to work around a deficiency in]
    [Automake.  See `configure.ac' for details.])
  [else] AC_MSG_ERROR([failed to patch using `config.status.dep.patch'.]
      [You have a serious problem.  Please contact <$PACKAGE_BUGREPORT>.])
  [fi
])


#
# Makefile.correct_output_files_for_.S_files.patch
#
# The used version of Automake might emit rules that don't put compiled (pre
# processed) Assembler files where they belong.  We're bitten by this bug
# because we use the Automake option `subdir-objects', to not clutter the main
# build directory with all the object files.  The problem is that the emitted
# rules will place those in the main build directory, but later, when creating
# the libraries, look for them in the subdirectories.
#
# See <http://sourceware.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=automake&pr=492>.
#
# Another note: even with versions of Automake that don't have this issue
# fixed, a correct rule is emitted for linux/src/arch/i386/lib/semaphore.S, see
# the comment by Thomas Schwinge on 2006-10-10 on the above bug report.
#
# Again, a real patch is being used here and not some `sed' magic, so that
# it'll fail loudly in case some internals we're relying on are changed.
#
# TODO.  Remove this block as soon as we don't want to support such legacy
# versions of Automake anymore.
#

AC_CONFIG_COMMANDS([frob_Makefile_for_correct_output_files_for_.S_files],[
  # Do we have a version of Automake that doesn't have this bug?
  if grep -q CPPASCOMPILE.\*-c.\*-o < "$srcdir"/Makefile.in
  then] AC_MSG_NOTICE([... not a problem with the used version of Automake.])
  [# We don't.
  elif "$PATCH" -f \
    < "$srcdir"/Makefile.correct_output_files_for_.S_files.patch
  then]
    AC_MSG_NOTICE([Applied a patch to fix a bug in your version of Automake.]
      [The applied fix should work in most cases.  You could also consider]
      [updating to Automake 1.10 or better.])
  [else]
    AC_MSG_ERROR([failed to patch using ]
      [`Makefile.correct_output_files_for_.S_files.patch'.]
      [You have a serious problem.  Please contact <$PACKAGE_BUGREPORT>.])
  [fi
],[
  PACKAGE_BUGREPORT=$PACKAGE_BUGREPORT
  PATCH=$PATCH
])


#
# Dependency tracking for `.S' files
#
# The used version of Automake might not support automatic dependency tracking
# for (preprocessed) Assembler source files.  We might add such support here.
# But since adding such support is nontrivial and the nonexistent dependency
# tracking (missing only for .S files) is not considered a fundamental problem,
# we save the costs of adding such support here.  You should instead consider
# updating to Automake 1.10 or better.
#
# TODO.  Remove this block as soon as we don't want to support such legacy
# versions of Automake anymore.
#

AC_CONFIG_COMMANDS([frob_Makefile_for_dependency_tracking_for_.S_files],[
  # Do we have a version of Automake that doesn't have this bug?
  if grep -q CPPASCOMPILE.\*depbase < "$srcdir"/Makefile.in
  then] AC_MSG_NOTICE([... not a problem with the used version of Automake.])
  [# We don't.
  else]
    AC_MSG_NOTICE([Your build of GNU Mach won't have dependency tracking for]
      [(preprocessed) Assembler source files.  Consider updating to Automake]
      [1.10 or better if you need such support.])
    [# Make ``make -j'' parallel builds work at least.
    cat >> Makefile <<"EOT"

i386/i386at/boothdr.o: i386/i386/i386asm.h
i386/i386at/interrupt.o: i386/i386/i386asm.h
i386/i386/cswitch.o: i386/i386/i386asm.h
i386/i386/locore.o: i386/i386/i386asm.h
EOT]
dnl In case someone feels like completing this instead of simply using a fixed
dnl version of Automake...
dnl    if "$PATCH" -f; then :; else]
dnl      AC_MSG_ERROR([failed to patch using]
dnl        [`Makefile.dependency_tracking_for_.S_files.patch'.]
dnl        [You have a serious problem.  Please contact <$PACKAGE_BUGREPORT>.])
dnl    [fi < "$srcdir"/Makefile.dependency_tracking_for_.S_files.patch
dnl
dnl    # Change the Makefile to care for dependencies of .S files.
dnl    ( cd "$srcdir"/ &&
dnl      find ./ -name \*.S ) | \
dnl        sed -e 's%^\./%%' -e 's%\.S$%%' -e 's%^\(.*\)/%\1 %' | \
dnl	  while read d f; do
dnl	    echo &&
dnl	    echo "$d"/"$f"'.$(OBJEXT): '"$d"'/$(am__dirstamp) ' \
dnl	      "$d"'/$(DEPDIR)/$(am__dirstamp)' &&
dnl	    echo 'include '"$d"'/$(DEPDIR)/'"$f"'.Po' &&
dnl
dnl	    # Create the dependency files if they don't exist so far.
dnl	    if test -f "$d"/"$DEPDIR"/"$f"'.Po'; then :; else
dnl	      echo '# dummy' > "$d"/"$DEPDIR"/"$f"'.Po'
dnl	    fi
dnl	  done >> Makefile
dnl
dnl TODO.  linux/src/arch/i386/lib/.deps/liblinux_a-semaphore.Po vs.
dnl linux/src/arch/i386/lib/.deps/semaphore.Po.  Because of the above
dnl mentioned special rule for `semaphore.S' the .S.o rule is not used.
dnl
dnl gcc -nostdinc -imacros config.h -Ii386 -I. -I../i386 -I../include -I../i386/include/mach/sa -DASSEMBLER -g -O2 -c ../i386/i386at/boothdr.S
dnl
dnl Makefile
dnl
dnl COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
dnl .c.o:
dnl         depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`; \
dnl         if $(COMPILE) -MT $@ -MD -MP -MF "$$depbase.Tpo" -c -o $@ $<; \
dnl         then mv -f "$$depbase.Tpo" "$$depbase.Po"; else rm -f "$$depbase.Tpo"; exit 1; fi
dnl #       source='$<' object='$@' libtool=no \
dnl #       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
dnl #       $(COMPILE) -c -o $@ $<
dnl
dnl CCAS = gcc
dnl CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
dnl .S.o:
dnl        $(CCASCOMPILE) -c $<
dnl
dnl source=../i386/i386at/boothdr.S object=i386/i386at/boothdr.o libtool=no DEPDIR=.deps depmode=gcc3 ../depcomp gcc -nostdinc -imacros config.h -Ii386 -I. -I../i386 -I../include -I../i386/include/mach/sa -DASSEMBLER -g -O2 -c -o i386/i386at/boothdr.o ../i386/i386at/boothdr.S
dnl ... creates a correct i386/i386at/.deps/boothdr.Po.
  [fi
dnl ],[
dnl  DEPDIR=$DEPDIR
dnl  PACKAGE_BUGREPORT=$PACKAGE_BUGREPORT
dnl  PATCH=$PATCH
])

#
# Fire.
#

AC_OUTPUT