summaryrefslogtreecommitdiffstats
path: root/c/src/configure.ac
blob: 258b9a157e8163b8ff6da0df4e59f0fcde0f8ed7 (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
## Process this file with autoconf to produce a configure script.
## 
## $Id$

AC_PREREQ(2.59)
AC_INIT([rtems-c-src],[_RTEMS_VERSION],[rtems-bugs@rtems.com])
AC_CONFIG_SRCDIR([optman])
RTEMS_TOP(../..)

RTEMS_ENABLE_CXX
RTEMS_ENABLE_NETWORKING
RTEMS_ENABLE_RDBG

RTEMS_CANONICAL_TARGET_CPU

AM_INIT_AUTOMAKE([no-define subdir-objects no-exeext foreign 1.9])
AM_MAINTAINER_MODE

RTEMS_ENABLE_MULTILIB
RTEMS_ENABLE_MULTIPROCESSING
RTEMS_ENV_RTEMSBSP

AC_ARG_ENABLE(rpcgen,
[AS_HELP_STRING([--enable-rpcgen],[rebuild rpcgen-generated sources])],
[case "${enable_rpcgen}" in 
  yes) enable_rpcgen=yes ;;
  no) enable_rpcgen=no ;;
  *)  enable_rpcgen=no ;;
esac],[enable_rpcgen=no]) 

RTEMS_CHECK_CUSTOM_BSP(RTEMS_BSP)

RTEMS_CHECK_NETWORKING(RTEMS_BSP)
RTEMS_CHECK_POSIX_API(RTEMS_BSP)

AC_CHECK_PROG(RPCGEN,rpcgen,rpcgen)
AC_PROG_AWK

AC_MSG_NOTICE([setting up make/custom])

AS_MKDIR_P([make/custom])
AM_SET_DEPDIR
test -d ${DEPDIR} || mkdir ${DEPDIR}

rm -f ${DEPDIR}/cfg.P
echo "# Do not edit - automatically generated by" > ${DEPDIR}/cfg.P
echo "# $0" >> ${DEPDIR}/cfg.P

# Collect and copy the BSP's make/custom/*.cfg files from the toplevel make 
# directory into the build tree's <bsp>/make/custom subdirectories
CUSTOM_CFG_FILES=
f="${RTEMS_BSP}.cfg"
while test -n "$f"; do
  cfg_file=
  _RTEMS_CHECK_CUSTOM_BSP([$f],cfg_file)
  if test -n "${cfg_file}"; then
    cp ${cfg_file} make/custom/$f
    echo "make/custom/$f: ${cfg_file}" >> ${DEPDIR}/cfg.P
    echo "	cp ${cfg_file} make/custom/$f" >> ${DEPDIR}/cfg.P
    CUSTOM_CFG_FILES="$CUSTOM_CFG_FILES make/custom/$f"
    f=`grep "^include.*make/custom" ${cfg_file} \
    | sed \
      -e 's%^.*custom\/%%' \
      -e s%\$\(RTEMS_HOST\)%${RTEMS_HOST}% \
      -e 's%default\.cfg%%'`;
  else break; fi;
done
cp ${srcdir}/make/custom/default.cfg.in make/custom/default.cfg

AC_MSG_NOTICE([creating make/${RTEMS_BSP}.cache])
${MAKE-make} -f ${srcdir}/make/bsp.mak \
RTEMS_BSP=${RTEMS_BSP} \
RTEMS_HOST=${RTEMS_HOST} \
RTEMS_ROOT=. make/${RTEMS_BSP}.cache

# Read back the cache
AC_CACHE_CHECK([for RTEMS_CPU_MODEL], [ac_cv_env_RTEMS_CPU_MODEL],
[. ./make/${RTEMS_BSP}.cache])
RTEMS_CPU_MODEL=$ac_cv_env_RTEMS_CPU_MODEL
AC_SUBST(RTEMS_CPU_MODEL)
test -n "${RTEMS_CPU_MODEL}" && \
  ac_configure_args="$ac_configure_args 'RTEMS_CPU_MODEL=${RTEMS_CPU_MODEL}'"

AC_CACHE_CHECK([for RTEMS_BSP_FAMILY],[ac_cv_env_RTEMS_BSP_FAMILY],
[. ./make/${RTEMS_BSP}.cache])
RTEMS_BSP_FAMILY=$ac_cv_env_RTEMS_BSP_FAMILY
AC_SUBST(RTEMS_BSP_FAMILY)
test -n "${RTEMS_BSP_FAMILY}" && \
  ac_configure_args="$ac_configure_args 'RTEMS_BSP_FAMILY=${RTEMS_BSP_FAMILY}'"

AC_CACHE_CHECK([for CPU_CFLAGS],[ac_cv_env_CPU_CFLAGS],
[. ./make/${RTEMS_BSP}.cache])
CPU_CFLAGS=$ac_cv_env_CPU_CFLAGS
test -n "${CPU_CFLAGS}" && \
  ac_configure_args="$ac_configure_args 'CPU_CFLAGS=${CPU_CFLAGS}'"

AC_CACHE_CHECK([for CFLAGS_OPTIMIZE_V],[ac_cv_env_CFLAGS_OPTIMIZE_V],
[. ./make/${RTEMS_BSP}.cache])
CFLAGS_OPTIMIZE_V=$ac_cv_env_CFLAGS_OPTIMIZE_V
test -n "${CFLAGS_OPTIMIZE_V}" && \
  ac_configure_args="$ac_configure_args 'CFLAGS_OPTIMIZE_V=${CFLAGS_OPTIMIZE_V}'"

RTEMS_PROG_CC_FOR_TARGET
AM_PROG_CC_C_O
RTEMS_PROG_CCAS
RTEMS_CANONICALIZE_TOOLS

AS_IF([test "$HAS_NETWORKING" = "yes"],[
  AS_IF([test "$RTEMS_HAS_RDBG" = "yes"],[
    RTEMS_CHECK_RDBG(RTEMS_BSP)
  ])
])

RTEMS_CHECK_GCC_WEAK

AC_SUBST(CUSTOM_CFG_FILES)
AC_SUBST(cfg_dir)

RTEMS_CHECK_MULTIPROCESSING

BSP_SUBDIRS=
## Configure ${srcdir}/../../cpukit as cpukit/ if multilibs are disabled
RTEMS_BSP_CONFIG_SUBDIR(
  [cpukit],[../../cpukit],
  ['--with-project-root=${with_project_root}../$RTEMS_BSP/' \
   '--includedir=${exec_prefix}/${RTEMS_BSP}/lib/include' \
   '--libdir=${exec_prefix}/${RTEMS_BSP}/lib' \
   'CFLAGS="${CFLAGS}"' \
  ],
  [test x"$multilib" = xno])

## Note: the order of the directories below is essential
AC_CONFIG_SUBDIRS([make])
BSP_SUBDIRS="$BSP_SUBDIRS make"

RTEMS_CPU_SUBDIRS(lib/libcpu)
if test -d "${srcdir}/lib/libcpu/${RTEMS_CPU}"; then
  libcpu_cpu_subdir="${RTEMS_CPU}"
else
  libcpu_cpu_subdir=
fi
AC_SUBST(libcpu_cpu_subdir)

# Is there code where there should be for this BSP?
# The bare bsp is a special case as it is not under the RTEMS_CPU path
if test "$RTEMS_BSP_FAMILY" = bare ; then
  AC_CONFIG_SUBDIRS([lib/libbsp/bare])
  AC_SUBST(libbsp_cpu_subdir,bare)
else
  RTEMS_CPU_SUBDIRS([lib/libbsp])
  AC_SUBST(libbsp_cpu_subdir,$RTEMS_CPU)
fi

BSP_SUBDIRS="$BSP_SUBDIRS lib"
BSP_SUBDIRS="$BSP_SUBDIRS libchip"
BSP_SUBDIRS="$BSP_SUBDIRS librdbg"

AS_IF([test "$RTEMS_HAS_CPLUSPLUS" = "yes"],[
  AC_CONFIG_SUBDIRS([librtems++])
  BSP_SUBDIRS="$BSP_SUBDIRS librtems++"
])

BSP_SUBDIRS="$BSP_SUBDIRS support"
BSP_SUBDIRS="$BSP_SUBDIRS ada"
BSP_SUBDIRS="$BSP_SUBDIRS wrapup"

BSP_SUBDIRS="$BSP_SUBDIRS optman"

AC_ARG_ENABLE([ada],
[AS_HELP_STRING(--enable-ada,enable ada support)],
[case "${enable_ada}" in
  yes) ;;
  no) ;;
  *)  AC_MSG_ERROR(bad value ${enable_ada} for --enable-ada) ;;
esac],[enable_ada=no])

RTEMS_BSP_CONFIG_SUBDIR(
  [ada-tests],[ada-tests],
  ['--enable-rtems-root=../' \
   '--with-project-root=${with_project_root}../' \
   '--with-project-top=${with_project_top}../' \
   '--enable-rtemsbsp=$RTEMS_BSP' \
  ],
  [test x"$enable_tests" = xyes && test x"$enable_ada" = xyes])

# HACK ALERT!

# FIXME: Assume multilib implies in-source-tree multilibs
# Build testsuites multilibbed
RTEMS_BSP_CONFIG_SUBDIR(
  [testsuites],[../../testsuites],
  ['--enable-rtems-root=../' \
   '--enable-project-root=${with_project_root}../$RTEMS_BSP' \
   '--with-project-top=${with_project_top}../' \
   '--enable-rtemsbsp=$RTEMS_BSP' \
   '--includedir=${exec_prefix}/${RTEMS_BSP}/lib/include' \
   '--libdir=${exec_prefix}/${RTEMS_BSP}/lib' \
   'CFLAGS="${CFLAGS}"' \
  ],
  [test x"$enable_tests" != x"no" && test x"$multilib" = xno])

# Build testsuites non-multilibbed
RTEMS_BSP_CONFIG_SUBDIR(
  [testsuites],[../../testsuites],
  ['--enable-rtems-root=../' \
   '--enable-cpukit-root=${with_project_root}..' \
   '--enable-project-root=${with_project_root}../$RTEMS_BSP' \
   '--with-project-top=${with_project_top}../' \
   '--enable-rtemsbsp=$RTEMS_BSP' \
   '--includedir=${exec_prefix}/${RTEMS_BSP}/lib/include' \
   '--libdir=${exec_prefix}/${RTEMS_BSP}/lib' \
   'CFLAGS="${CFLAGS}"' \
  ],
  [test x"$enable_tests" != x"no" && test x"$multilib" = xyes])

AC_SUBST([BSP_SUBDIRS],[$BSP_SUBDIRS])

AS_IF([test "$host_cpu" = sparc],[
  AC_DEFINE_UNQUOTED([CPU_U32_FIX],[1],
    [whether to enable ipalignment work-around])
])

AM_CONDITIONAL([HAS_NETWORKING],[test "$HAS_NETWORKING" = "yes"])

# FIXME: This is sick
AM_CONDITIONAL([HAS_RDBG],[test "$HAS_RDBG" = "yes"])
AM_CONDITIONAL([HAS_RDBG_i386],[test "$HAS_RDBG" = "yes" \
 && test $RTEMS_CPU = "i386"])
AM_CONDITIONAL([HAS_RDBG_m68k],[test "$HAS_RDBG" = "yes" \
 && test $RTEMS_CPU = "m68k"])
AM_CONDITIONAL([HAS_RDBG_powerpc],[test "$HAS_RDBG" = "yes" \
 && test $RTEMS_CPU = "powerpc"])

AM_CONDITIONAL(HAS_POSIX,test "$HAS_POSIX_API" = "yes")

# The posix bsp doesn't support libchip
# FIXME: We should use a feature based check, here
AM_CONDITIONAL([LIBCHIP],[test "$RTEMS_BSP_FAMILY" != "posix"])

# The bare bsp doesn't have libbsp.a
# FIXME: We should use a feature based check, here
AM_CONDITIONAL([HAS_LIBBSP],[test "$RTEMS_BSP_FAMILY" != "bare"])

AM_CONDITIONAL([MULTILIB],[test x"${enable_multilib}" = x"yes"])

AM_CONDITIONAL([RPCTOOLS],[test "$RPCGEN" = rpcgen \
&& test -n "$AWK" \
&& test "$enable_rpcgen" = yes])

AM_CONDITIONAL(RTEMS_ADA,[test x"$enable_ada" = x"yes" \
  && test x"$rtems_cv_HAS_POSIX_API" = x"yes"])

RTEMS_PROJECT_ROOT

AC_PATH_PROG([AMPOLISH3],[ampolish3],[])
AM_CONDITIONAL([AMPOLISH3],[test x"$USE_MAINTAINER_MODE" = x"yes" \
  && test -n "$AMPOLISH3"])

# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile],
[${MAKE} make/${RTEMS_BSP}.cache],
[RTEMS_BSP=${RTEMS_BSP}
 MAKE=${MAKE}])

AC_CONFIG_FILES([
support/Makefile 

librdbg/Makefile

libchip/Makefile

optman/Makefile

lib/Makefile

lib/libcpu/Makefile

lib/libbsp/Makefile

ada/Makefile

wrapup/Makefile
])

AC_OUTPUT