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

AC_PREREQ([2.68])
AC_INIT([rtems-c-src],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
AC_CONFIG_SRCDIR([libchip])
RTEMS_TOP(../..)

RTEMS_ENABLE_CXX
RTEMS_ENABLE_NETWORKING

RTEMS_CANONICAL_TARGET_CPU

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

RTEMS_ENABLE_MULTILIB
RTEMS_ENABLE_MULTIPROCESSING
RTEMS_ENV_RTEMSBSP

RTEMS_CHECK_CUSTOM_BSP(RTEMS_BSP)

RTEMS_CHECK_NETWORKING(RTEMS_BSP)
RTEMS_CHECK_POSIX_API(RTEMS_BSP)

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
cp ${srcdir}/make/custom/default.cfg.in make/custom/default.cfg
cat << EOF > ${DEPDIR}/cfg.P
# Do not edit - automatically generated by $0
make/custom/default.cfg: \$(srcdir)/make/custom/default.cfg.in
	@\$(MKDIR_P) make/custom
	cp \$(srcdir)/make/custom/default.cfg.in make/custom/default.cfg
EOF

# 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
cat << EOF >> ${DEPDIR}/cfg.P
make/custom/$f: ${cfg_file} make/custom/default.cfg
	cp ${cfg_file} make/custom/$f
EOF
    CUSTOM_CFG_FILES="$CUSTOM_CFG_FILES make/custom/$f"
    f=`grep "^include.*make/custom" ${cfg_file} \
    | sed \
      -e 's%^.*custom\/%%' \
      -e 's%default\.cfg%%'`;
  else break; fi;
done

AC_MSG_NOTICE([creating make/${RTEMS_BSP}.cache])
${MAKE-make} -f ${srcdir}/make/bsp.mak \
RTEMS_BSP=${RTEMS_BSP} \
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],
[RTEMS_BSP_ALIAS([${RTEMS_BSP}],[ac_cv_env_RTEMS_BSP_FAMILY])])
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

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

# Was CFLAGS set?
rtems_cv_CFLAGS_set="${CFLAGS+set}"

CFLAGS="${CFLAGS-${CPU_CFLAGS} ${CFLAGS_OPTIMIZE_V}}"

RTEMS_PROG_CC_FOR_TARGET
AM_PROG_CC_C_O
RTEMS_PROG_CCAS
RTEMS_CANONICALIZE_TOOLS

# Append warning flags if CFLAGS wasn't set.
AS_IF([test "$GCC" = yes && test "$rtems_cv_CFLAGS_set" != set],
[CFLAGS="$CFLAGS -Wall -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs"])

AS_IF([test -n "${CFLAGS}"],[
ac_configure_args="$ac_configure_args 'CFLAGS=${CFLAGS}'"])

RTEMS_CHECK_GCC_WEAK

AC_SUBST(CUSTOM_CFG_FILES)

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' \
  ],
  [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?
RTEMS_CPU_SUBDIRS([lib/libbsp])
AC_SUBST(libbsp_cpu_subdir,$RTEMS_CPU)

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

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"

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=../' \
   '--enable-project-root=${with_project_root}../$RTEMS_BSP' \
   '--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' \
  ],
  [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' \
  ],
  [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"])

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

RTEMS_PROJECT_ROOT

# 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
libchip/Makefile
lib/Makefile
lib/libcpu/Makefile
lib/libbsp/Makefile
ada/Makefile
wrapup/Makefile
])

AC_OUTPUT