Index: c/src/ChangeLog
===================================================================
--- c/src/ChangeLog	(revision fcf00342a6cf14ce1cb191d688bb780ed587408c)
+++ c/src/ChangeLog	(revision 789694a1417d66be04dfea4e4cf18c7d1293cc44)
@@ -1,2 +1,13 @@
+2004-02-20	Ralf Corsepius <corsepiu@faw.uni-ulm.de>
+
+	* acinclude.m4: Fix loosing arguments when configuring cpukit and
+	testsuites (Was exposed with --enable-multilib, only).
+	Remove RTEMS_SUBCONFIGURE_ARGS_QUOTE. RTEMS_CONFIG_SUBDIR.
+	 Add RTEMS_BSP_CONFIG_SUBDIR.
+	* configure.ac: Reflect changes to acinclude.m4. Reflect new args to
+	testsuites's configure.
+	* aclocal/rtems-top.m4: Remove ENDIF hack. 
+	Rework and fix setting up PROJECT_TOPdir (PACKHEX wasn't found).
+
 2004-02-20	Ralf Corsepius <corsepiu@faw.uni-ulm.de>
 
Index: c/src/acinclude.m4
===================================================================
--- c/src/acinclude.m4	(revision fcf00342a6cf14ce1cb191d688bb780ed587408c)
+++ c/src/acinclude.m4	(revision 789694a1417d66be04dfea4e4cf18c7d1293cc44)
@@ -6,11 +6,6 @@
 # subdirectory handling solution is introduced to RTEMS.
 
-AC_DEFUN([RTEMS_SUBCONFIGURE_ARGS_QUOTE],
+AC_DEFUN([_RTEMS_CONFIG_SUBDIR],
 [
-   RTEMS_CONFIGURE_ARGS_QUOTE([ac_sub_configure_args])
-])
-
-AC_DEFUN([RTEMS_CONFIG_SUBDIR],
-[AC_REQUIRE([RTEMS_SUBCONFIGURE_ARGS_QUOTE])
 if test "$no_recursion" != yes; then
   ac_sub_sourcedir=$2
@@ -82,2 +77,10 @@
 fi
 ])
+
+## RTEMS_BSP_CONFIG_SUBDIR(builddir,srcdir,configargs,condition)
+AC_DEFUN([RTEMS_BSP_CONFIG_SUBDIR],[
+m4_expand_once([RTEMS_CONFIGURE_ARGS_QUOTE([ac_sub_configure_args])])
+AS_IF([$4],[BSP_SUBDIRS="$BSP_SUBDIRS $1"])
+AC_CONFIG_COMMANDS_POST([
+AS_IF([$4],[_RTEMS_CONFIG_SUBDIR([$1],[$2],[$3])])])
+])
Index: c/src/aclocal/rtems-top.m4
===================================================================
--- c/src/aclocal/rtems-top.m4	(revision fcf00342a6cf14ce1cb191d688bb780ed587408c)
+++ c/src/aclocal/rtems-top.m4	(revision 789694a1417d66be04dfea4e4cf18c7d1293cc44)
@@ -18,24 +18,15 @@
 AC_PREFIX_DEFAULT([/opt/rtems-][RTEMS_API])
 
-## HACK to allow gnu-make conditionals in automake-Makefiles.
-ENDIF=endif
-AC_SUBST(ENDIF)
-
-RTEMS_TOPdir="$1";
-AC_SUBST(RTEMS_TOPdir)
+AC_SUBST([RTEMS_TOPdir],["$1"])
 
 ## with_target_subdirs is handled implicitly by autoconf
-test -n "$with_target_subdir" || with_target_subdir="."
+dots=`echo $with_target_subdir|\
+sed -e 's,^\.$,,' -e 's%^\./%%' -e 's%[[^/]]$%&/%' -e 's%[[^/]]*/%../%g'`
 
-if test "$with_target_subdir" = "." ; then
-# Native
-PROJECT_TOPdir=${RTEMS_TOPdir}/'$(top_builddir)'
-else
-# Cross
-dots=`echo $with_target_subdir|\
-sed -e 's%^\./%%' -e 's%[[^/]]$%&/%' -e 's%[[^/]]*/%../%g'`
 PROJECT_TOPdir=${dots}${RTEMS_TOPdir}/'$(top_builddir)'
-fi
-AC_SUBST(PROJECT_TOPdir)
+AC_SUBST([PROJECT_TOPdir])
+
+RTEMS_ROOT=`echo "$1/" | sed -e 's,^../../,,'`'$(top_builddir)'
+AC_SUBST([RTEMS_ROOT])
 
 PROJECT_ROOT="${RTEMS_TOPdir}/\$(top_builddir)"
Index: c/src/configure.ac
===================================================================
--- c/src/configure.ac	(revision fcf00342a6cf14ce1cb191d688bb780ed587408c)
+++ c/src/configure.ac	(revision 789694a1417d66be04dfea4e4cf18c7d1293cc44)
@@ -118,14 +118,10 @@
 RTEMS_CHECK_MULTIPROCESSING
 
+BSP_SUBDIRS=
 ## Configure ${srcdir}/../../cpukit as cpukit/ if multilibs are disabled
-AS_IF([test x"$multilib" = x"no"],[
-  AC_CONFIG_COMMANDS_POST([
-    if test x"$multilib" = x"no"; then
-    RTEMS_CONFIG_SUBDIR([cpukit],[../../cpukit],
-      ['--with-project-root=../../..' '--enable-rtemsbsp=$RTEMS_BSP'])
-    fi
-  ])
-  BSP_SUBDIRS="cpukit"
-])
+RTEMS_BSP_CONFIG_SUBDIR(
+  [cpukit],[../../cpukit],
+  ['--with-project-root=../../..' '--enable-rtemsbsp=$RTEMS_BSP'],
+  [test x"$multilib" = x"no"])
 
 ## Note: the order of the directories below is essential
@@ -180,12 +176,12 @@
 ])
 
-AS_IF([test -d ${srcdir}/../../testsuites],[
-  BSP_SUBDIRS="$BSP_SUBDIRS testsuites"
-])
-
-  AC_CONFIG_COMMANDS_POST([
-    RTEMS_CONFIG_SUBDIR([testsuites],[../../testsuites],
-      ['--with-project-root=../../' '--enable-rtemsbsp=$RTEMS_BSP'])
-  ])
+RTEMS_BSP_CONFIG_SUBDIR(
+  [testsuites],[../../testsuites],
+  ['--with-target-subdir=$with_target_subdir/c/$RTEMS_BSP' \
+   '--with-rtems-root=../' \
+   '--with-project-root=../../../' \
+   '--enable-rtemsbsp=$RTEMS_BSP' \
+   ],
+  [test x"$enable_tests" != x"no"])
 
 AC_SUBST([BSP_SUBDIRS],[$BSP_SUBDIRS])
