Patchwork MARS: Build files cleanup

login
register
mail settings
Submitter Yuji Mano
Date Sept. 11, 2008, 7:35 p.m.
Message ID <48C972EE.5060804@am.sony.com>
Download mbox | patch
Permalink /patch/245/
State New
Delegated to: Yuji Mano
Headers show

Comments

Yuji Mano - Sept. 11, 2008, 7:35 p.m.
From: Geoff Levand <geoffrey.levand@am.sony.com>

Cleanup build files:
 o Use the git revision in default package version.
 o Add configure option --with-mars-platform to support platform
   specific builds.
 o Move embedspu from mpu makefile to host makefile.
 o Add makefile variable MARS_KERNEL.
 o Change default prefix from /usr to /usr/local.
 o Remove 'host_alias=spu' hack with top level configure logic.
 o Remove unneeded Makefile.am files.
 o Remove unneeded files config.sub.patch, VERSION.
 o Update README file.

Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
Acked-by: Kazunori Asayama <asayama@sm.sony.co.jp>

Patch

--- a/Makefile.am
+++ b/Makefile.am
@@ -36,15 +36,8 @@ 
 #  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
 #
 
-SUBDIRS = include src
+SUBDIRS = src/mpu src/host/lib
 
-EXTRA_DIST = \
-	bootstrap \
-	configure.ac.in \
-	config.sub.patch \
-	COPYING \
-	INSTALL \
-	README \
-	VERSION
+EXTRA_DIST = bootstrap configure.ac.in
 
 MAINTAINERCLEANFILES = Makefile.in
--- a/README
+++ b/README
@@ -37,24 +37,14 @@ 
 
 MARS Library README
 
-Index
-=====
-	* Overview
-	* Building Source
-	* Installing Library
-	* Using Library
-
-
 Overview
 ========
-The MARS (Multicore Application Runtime System) provides an API to easily manage
+
+The MARS (Multicore Application Runtime System) provides an API to manage
 and create user programs that will be scheduled to run on various MPUs of a
 multicore-core environment with minimal runtime support required of the host.
 
-For more specific details, please refer to the MARS Reference Manual
-documentation that is generated from the build.
-
-/mars-lib
+/mars
 |
 |---/include		Include directory
 |   |
@@ -81,54 +71,35 @@  documentation that is generated from the
 
 Building Source
 ================
-Run configure and make
-----------------------
-To build the MARS library source, you need to first run ./configure from the
-top-level directory, and then do a ./make. The build supports both native and
-cross compiling.
-
-You need to specify whether you are building libraries for a 32-bit host or
-64-bit host.
-
-32-bit host
----------------------
-[mars-lib]$ ./configure --host=ppu --libdir="/usr/lib"
-[mars-lib]$ make HOST_FLAGS=-m32
-
-64-bit host
----------------------
-[mars-lib]$ ./configure --host=ppu --libdir="/usr/lib64"
-[mars-lib]$ make HOST_FLAGS=-m64
-
-The '--libdir' option to './configure' specifies the target directory to where
-the compiled libraries will be installed. Make sure to specify the correct path
-to the target userland path when doing a cross compile.
-
-
-Installing Library
-==================
-After building of the library is complete, you need to install the library to
-the system standard paths. As an alternative you can also choose to install the
-library using the RPMs explained in the previous section.
-
-[mars-lib]$ make install
-
-When installation is complete, the MARS library files can be found in the
-following locations:
-
-MARS host includes:	/usr/include
-MARS host libraries:	/usr/lib or /usr/lib64
-MARS MPU includes:	/usr/mpu/include
-MARS MPU libraries:	/usr/mpu/lib
 
+* See the source file INSTALL for generic build info.
 
-Using Library
-=============
-Using the library is a matter of including the MARS library headers in your
-programs and linking the appropriate MARS library and C runtime.
+* The configure scripts require the option --with-mars-platform.  Currently,
+only the Cell Broadband Engine (--with-mars-platfrom=cell) is supported.
 
-For more information regarding MARS library usage, please refer to the MARS Docs
-package.
+* Use the prefixes PPU_ and SPU_ on command line variables to the top level
+configure to specify variables for the different Cell toolchains.
 
-For sample code that shows usage of the MARS library, please refer to the MARS
-Samples package.
+* When building 64-bit libraries for a powerpc host it is customary to use
+the --libdir configure option to install the libraries in a EPREFIX/lib64
+directory.  Run configure with the --help option for more info.
+
+For example, when using the Cell SDK toolchains use options similar to these:
+
+32-bit powerpc host
+-------------------
+  ./configure \
+    --with-mars-platform=cell \
+    PPU_EMBEDSPU=ppu-embedspu \
+    PPU_CC=ppu-gcc PPU_CFLAGS="-O3 -funroll-loops -m32" \
+    SPU_CC=spu-gcc SPU_CFLAGS="-O3 -funroll-loops"
+
+64-bit powerpc host
+-------------------
+  ./configure \
+    --libdir="/usr/lib64" \
+    --with-mars-platform=cell \
+    PPU_EMBEDSPU=ppu-embedspu \
+    PPU_CC=ppu-gcc PPU_CFLAGS="-O3 -funroll-loops -m64" \
+    SPU_CC=spu-gcc SPU_CFLAGS="-O3 -funroll-loops"
+
--- a/VERSION
+++ /dev/null
@@ -1,2 +0,0 @@ 
-0.9.2
-
--- a/bootstrap
+++ b/bootstrap
@@ -37,33 +37,54 @@ 
 #  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
 #
 
-if [ $VERSION ]; then
-	version=$VERSION
-	echo "VERSION =" $version
-elif [ -f VERSION ]; then
-	version=`cat VERSION`
-	echo "VERSION =" $version
+version=
+
+if [ "$1" ]; then
+	version=$1
+elif head=$(git rev-parse --short --verify HEAD 2>/dev/null); then
+
+	# If available, use the git commit revision for the package version.
+
+	months="Jan:01 Feb:02 Mar:03 Apr:04 May:05 Jun:06 Jul:07 Aug:08 \
+		Sep:09 Oct:10 Nov:11 Dec:12"
+
+	# Add a date prefix for easy reading.
+
+	date=$(git-log --pretty=format:"%cD" -1 HEAD)
+
+	# date='Fri, 2 Aug 2007 19:36:06 -0700'
+
+	date=${date##*, }
+	date=${date% [0-9][0-9]:*}
+	day=${date%* [A-Z][a-z][a-z] *}
+	year=${date##* [A-Z][a-z][a-z] 20}
+	month=${date##${day} }
+	month=${month%% 20${year}}
+	month=${months##*${month}:}
+	month=${month%% *}
+	[ ! ${day#[0-9][0-9]} ] || day="0$day"
+
+	version=$(printf '%s.%s.%s-%s%s' ${year} ${month} ${day} g ${head})
+
+	# Add a '-dirty' postfix for uncommitted changes.
+
+	if git diff-index HEAD | read dummy; then
+		version=`printf '%s%s' ${version} -dirty`
+	fi
 else
-	version=""
-	echo "No VERSION file found!"
+	# Default to date and time.
+
+	version="dev-$(date +%y.%m.%d-%H.%M.%S)"
 fi
 
-version_maj=$(echo ${version} | sed -e 's/\.[0-9.]*//')
-version_min=$(echo ${version} | sed -e 's/^[0-9]*\.//' | sed -e 's/\.[0-9]*$//')
-version_rev=$(echo ${version} | sed -e 's/[0-9.]*\.//')
+set -x
 
-sed -e s,@version@,${version},g \
-	configure.ac.in > configure.ac
+sed -e s,@version@,${version},g configure.ac.in > configure.ac
 
 aclocal
-libtoolize --force --copy
 autoheader
 automake --foreign --add-missing --copy
 autoconf
 
-pushd src/host && ./bootstrap $version && popd
-pushd src/mpu && ./bootstrap $version && popd
-
-if [ -e config.sub ]; then
-	patch -p1 < config.sub.patch
-fi
+pushd src/mpu > /dev/null && ./bootstrap ${version} && popd > /dev/null
+pushd src/host > /dev/null && ./bootstrap ${version} && popd > /dev/null
--- a/config.sub.patch
+++ /dev/null
@@ -1,24 +0,0 @@ 
---- a/config.sub	2005-11-22 05:18:02.000000000 -0800
-+++ b/config.sub	2006-07-11 12:09:36.000000000 -0700
-@@ -816,6 +816,10 @@
- 	ppc64le-* | powerpc64little-*)
- 		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
- 		;;
-+	ppu)
-+		basic_machine=powerpc64-cell
-+		os=-linux
-+		;;
- 	ps2)
- 		basic_machine=i386-ibm
- 		;;
-@@ -868,6 +872,10 @@
- 	spur)
- 		basic_machine=spur-unknown
- 		;;
-+	spu)
-+		basic_machine=spu-cell
-+		os=-none
-+		;;
- 	st2000)
- 		basic_machine=m68k-tandem
- 		;;
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -36,28 +36,89 @@ 
 #  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
 #
 
-AC_INIT(mars, @version@, Yuji Mano <yuji.mano@am.sony.com>)
+AC_INIT([mars], [@version@], [MARS <cbe-oss-dev@ozlabs.org>])
 
-AC_PREFIX_DEFAULT(/usr)
+AC_PREFIX_DEFAULT([/usr])
+
+AC_ARG_WITH([mars-platform],
+	[AS_HELP_STRING([--with-mars-platform=TYPE],
+		[specify mars platform TYPE (cell | spursengine)])],
+	[],
+	[AC_MSG_ERROR([missing option --with-mars-platform=])])
+AS_CASE([${with_mars_platform}],
+	[cell],[],
+	[spursengine],[],
+	[AC_MSG_ERROR([invalid option --with-mars-platform=${with_mars_platform}])])
+AM_CONDITIONAL([MARS_PLATFORM_CELL],
+	[test "x${with_mars_platform}" = "xcell"])
+AM_CONDITIONAL([MARS_PLATFORM_SPURSENGINE],
+	[test "x${with_mars_platform}" = "xspursengine"])
+AC_MSG_RESULT([using mars-platform ${with_mars_platform}])
+
+AC_ARG_ENABLE(
+	[debug],
+	[AS_HELP_STRING([--enable-debug], [build debug versions of mars])])
+AM_CONDITIONAL([DEBUG], [test "x${enable_debug}" = "xyes"])
+AC_MSG_RESULT([using enable-debug ${enable_debug}])
+
+AC_CONFIG_AUX_DIR([.])
+
+AM_INIT_AUTOMAKE
+AC_SUBST([DESTDIR])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_FILES([Makefile])
+
+mars_args_host=
+mars_args_prefix=
+mars_args_libdir=
+mars_args_other=
 
 if test "x${prefix}" = "xNONE"; then
 	prefix=$ac_default_prefix
-	ac_configure_args="$ac_configure_args --prefix $prefix"
+	ac_configure_args="$ac_configure_args '--prefix=$prefix'"
 fi
 
-AM_INIT_AUTOMAKE
-AC_PROG_LIBTOOL
-
-AC_CONFIG_HEADERS(config.h)
-AC_CONFIG_FILES([
-	Makefile
-	include/Makefile
-	src/Makefile
-])
-
-AC_CONFIG_SUBDIRS([
-	src/host
-	src/mpu
-])
+for a in $ac_configure_args; do
+	case ${a} in
+	\'--host=*\' )
+		mars_args_host=${a}
+		;;
+	\'--prefix=*\' )
+		mars_args_prefix=${a}
+		;;
+	\'--libdir=*\' )
+		mars_args_libdir=${a}
+		;;
+	\'host_alias=*\' )
+		# ignore
+		;;
+	* )
+		mars_arg_other="${mars_arg_other} ${a}"
+		;;
+	esac
+done
+
+mars_args_prefix_spu=`echo "$mars_args_prefix" | sed 's,'\''$,/spu'\'',g'`
+mars_args_libdir_spu=`echo "$mars_args_prefix" | sed 's,'\''$,/spu/lib'\'',g' | sed 's,--prefix,--libdir,g'`
+
+mars_args_ppu=`echo "$mars_arg_other" | sed 's,'\''PPU_,'\'',g'`
+mars_args_ppu="$mars_args_ppu $mars_args_prefix $mars_args_libdir $mars_args_host"
+
+mars_args_spu=`echo "$mars_arg_other" | sed 's,'\''SPU_,'\'',g'`
+mars_args_spu="$mars_args_spu $mars_args_prefix_spu $mars_args_libdir_spu --host=spu"
+
+AC_MSG_RESULT([using mars_srcdir $ac_abs_confdir])
+AC_MSG_RESULT([using mars_builddir $ac_pwd])
+
+echo "mars_args_ppu=@$mars_args_ppu@"
+echo "mars_args_spu=@$mars_args_spu@"
+
+mkdir -p ${ac_pwd}/src/mpu
+pushd ${ac_pwd}/src/mpu > /dev/null && \
+	eval "${ac_abs_confdir}/src/mpu/configure $mars_args_spu"; popd
+
+mkdir -p ${ac_pwd}/src/host
+pushd ${ac_pwd}/src/host > /dev/null && \
+	eval "${ac_abs_confdir}/src/host/configure $mars_args_ppu" ; popd
 
 AC_OUTPUT
--- a/include/Makefile.am
+++ /dev/null
@@ -1,88 +0,0 @@ 
-## Makefile.am -- Process this file with automake to produce Makefile.in
-#
-#  Copyright 2008 Sony Corporation of America
-#
-#
-#  Permission is hereby granted, free of charge, to any person obtaining
-#  a copy of this Library and associated documentation files (the
-#  "Library"), to deal in the Library without restriction, including
-#  without limitation the rights to use, copy, modify, merge, publish,
-#  distribute, sublicense, and/or sell copies of the Library, and to
-#  permit persons to whom the Library is furnished to do so, subject to
-#  the following conditions:
-#
-#   The above copyright notice and this permission notice shall be
-#   included in all copies or substantial portions of the Library.
-#
-#   If you modify the Library, you may copy and distribute your modified
-#   version of the Library in object code or as an executable provided
-#   that you also do one of the following:
-#
-#    Accompany the modified version of the Library with the complete
-#    corresponding machine-readable source code for the modified version
-#    of the Library; or,
-#
-#    Accompany the modified version of the Library with a written offer
-#    for a complete machine-readable copy of the corresponding source
-#    code of the modified version of the Library.
-#
-#
-#  THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-#  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-#  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-#  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-#  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-#  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-#  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
-#
-
-MAINTAINERCLEANFILES = Makefile.in
-
-hostdir = $(prefix)/include/mars
-mpudir = $(prefix)/spu/include/mars
-
-host_HEADERS = \
-	common/mars/mars_error.h \
-	common/mars/mars_mutex_types.h \
-	common/mars/mars_task_types.h \
-	common/mars/mars_task_barrier_types.h \
-	common/mars/mars_task_event_flag_types.h \
-	common/mars/mars_task_queue_types.h \
-	common/mars/mars_task_semaphore_types.h \
-	host/mars/mars.h \
-	host/mars/mars_context.h \
-	host/mars/mars_mutex.h \
-	host/mars/mars_task.h \
-	host/mars/mars_task_barrier.h \
-	host/mars/mars_task_event_flag.h \
-	host/mars/mars_task_queue.h \
-	host/mars/mars_task_semaphore.h \
-	host/mars/mars_task_signal.h
-
-mpu_HEADERS = \
-	common/mars/mars_error.h \
-	common/mars/mars_mutex_types.h \
-	common/mars/mars_task_types.h \
-	common/mars/mars_task_barrier_types.h \
-	common/mars/mars_task_event_flag_types.h \
-	common/mars/mars_task_queue_types.h \
-	common/mars/mars_task_semaphore_types.h \
-	mpu/mars/mars.h \
-	mpu/mars/mars_mutex.h \
-	mpu/mars/mars_task.h \
-	mpu/mars/mars_task_barrier.h \
-	mpu/mars/mars_task_event_flag.h \
-	mpu/mars/mars_task_queue.h \
-	mpu/mars/mars_task_semaphore.h \
-	mpu/mars/mars_task_signal.h
-
-EXTRA_DIST = \
-	common/mars/mars_debug.h \
-	common/mars/mars_kernel_types.h \
-	common/mars/mars_workload_types.h \
-	host/mars/mars_timer.h \
-	host/mars/mars_workload_queue.h \
-	mpu/mars/mars_dma.h \
-	mpu/mars/mars_kernel.h \
-	mpu/mars/mars_timer.h \
-	mpu/mars/mars_syscalls.h
--- a/src/Makefile.am
+++ /dev/null
@@ -1,41 +0,0 @@ 
-## Makefile.am -- Process this file with automake to produce Makefile.in
-#
-#  Copyright 2008 Sony Corporation of America
-#
-#
-#  Permission is hereby granted, free of charge, to any person obtaining
-#  a copy of this Library and associated documentation files (the
-#  "Library"), to deal in the Library without restriction, including
-#  without limitation the rights to use, copy, modify, merge, publish,
-#  distribute, sublicense, and/or sell copies of the Library, and to
-#  permit persons to whom the Library is furnished to do so, subject to
-#  the following conditions:
-#
-#   The above copyright notice and this permission notice shall be
-#   included in all copies or substantial portions of the Library.
-#
-#   If you modify the Library, you may copy and distribute your modified
-#   version of the Library in object code or as an executable provided
-#   that you also do one of the following:
-#
-#    Accompany the modified version of the Library with the complete
-#    corresponding machine-readable source code for the modified version
-#    of the Library; or,
-#
-#    Accompany the modified version of the Library with a written offer
-#    for a complete machine-readable copy of the corresponding source
-#    code of the modified version of the Library.
-#
-#
-#  THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-#  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-#  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-#  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-#  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-#  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-#  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
-#
-
-SUBDIRS = mpu host
-
-MAINTAINERCLEANFILES = Makefile.in
--- a/src/host/bootstrap
+++ b/src/host/bootstrap
@@ -39,15 +39,10 @@ 
 
 version="$1"
 
-sed -e s,@version@,${version},g \
-	configure.ac.in > configure.ac
+sed -e s,@version@,${version},g configure.ac.in > configure.ac
 
 aclocal
 libtoolize --force --copy
 autoheader
 automake --foreign --add-missing --copy
 autoconf
-
-if [ -e config.sub ]; then
-	patch -p1 < config.sub.patch
-fi
--- a/src/host/config.sub.patch
+++ /dev/null
@@ -1,24 +0,0 @@ 
---- a/config.sub	2005-11-22 05:18:02.000000000 -0800
-+++ b/config.sub	2006-07-11 12:09:36.000000000 -0700
-@@ -816,6 +816,10 @@
- 	ppc64le-* | powerpc64little-*)
- 		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
- 		;;
-+	ppu)
-+		basic_machine=powerpc64-cell
-+		os=-linux
-+		;;
- 	ps2)
- 		basic_machine=i386-ibm
- 		;;
-@@ -868,6 +872,10 @@
- 	spur)
- 		basic_machine=spur-unknown
- 		;;
-+	spu)
-+		basic_machine=spu-cell
-+		os=-none
-+		;;
- 	st2000)
- 		basic_machine=m68k-tandem
- 		;;
--- a/src/host/configure.ac.in
+++ b/src/host/configure.ac.in
@@ -36,20 +36,37 @@ 
 #  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
 #
 
-AC_INIT(host, @version@, Yuji Mano <yuji.mano@am.sony.com>)
+AC_INIT([mars], [@version@], [MARS <cbe-oss-dev@ozlabs.org>])
 
-host_alias=ppu
-AC_SUBST(host_alias)
+AC_ARG_WITH([mars-platform],
+	[AS_HELP_STRING([--with-mars-platform=TYPE],
+		[specify mars platform TYPE (cell | spursengine)])],
+	[],
+	[AC_MSG_ERROR([missing option --with-mars-platform=])])
+AS_CASE([${with_mars_platform}],
+	[cell],[],
+	[spursengine],[],
+	[AC_MSG_ERROR([invalid option --with-mars-platform=${with_mars_platform}])])
+AM_CONDITIONAL([MARS_PLATFORM_CELL],
+	[test "x${with_mars_platform}" = "xcell"])
+AM_CONDITIONAL([MARS_PLATFORM_SPURSENGINE],
+	[test "x${with_mars_platform}" = "xspursengine"])
+AC_MSG_RESULT([using mars-platform ${with_mars_platform}])
+
+AC_ARG_ENABLE(
+	[debug],
+	[AS_HELP_STRING([--enable-debug], [build debug versions of mars])])
+AM_CONDITIONAL([DEBUG], [test "x${enable_debug}" = "xyes"])
+AC_MSG_RESULT([using enable-debug ${enable_debug}])
 
 AC_CONFIG_AUX_DIR([.])
 
+AC_CHECK_TARGET_TOOL([EMBEDSPU], [embedspu], [embedspu-not-found])
+
 AC_PROG_LIBTOOL
 AM_INIT_AUTOMAKE
-
-AC_CONFIG_HEADERS(config.h)
-AC_CONFIG_FILES([
-	Makefile
-	lib/Makefile
-])
+AC_SUBST([DESTDIR])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_FILES([Makefile lib/Makefile])
 
 AC_OUTPUT
--- a/src/host/lib/Makefile.am
+++ b/src/host/lib/Makefile.am
@@ -36,16 +36,61 @@ 
 #  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
 #
 
+extra_cppflags =
+extra_cflags =
+extra_ldflags =
+
+MARS_KERNEL = ${top_builddir}/../mpu/kernel/mars-kernel
+
+if DEBUG
+ extra_cppflags += "-DDEBUG"
+else
+ extra_cppflags += "-DNDEBUG"
+endif
+
+if MARS_PLATFORM_CELL
+endif
+
+if MARS_PLATFORM_SPURSENGINE
+endif
+
+EXTRA_DIST = bootstrap configure.ac.in
+
 MAINTAINERCLEANFILES = Makefile.in
 
-lib_LTLIBRARIES = libmars.la
+pkginclude_HEADERS = \
+	$(srcdir)/../../../include/common/mars/mars_error.h \
+	$(srcdir)/../../../include/common/mars/mars_mutex_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_barrier_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_event_flag_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_queue_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_semaphore_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_types.h \
+	$(srcdir)/../../../include/host/mars/mars.h \
+	$(srcdir)/../../../include/host/mars/mars_context.h \
+	$(srcdir)/../../../include/host/mars/mars_mutex.h \
+	$(srcdir)/../../../include/host/mars/mars_task.h \
+	$(srcdir)/../../../include/host/mars/mars_task_barrier.h \
+	$(srcdir)/../../../include/host/mars/mars_task_event_flag.h \
+	$(srcdir)/../../../include/host/mars/mars_task_queue.h \
+	$(srcdir)/../../../include/host/mars/mars_task_semaphore.h \
+	$(srcdir)/../../../include/host/mars/mars_task_signal.h
+
+EXTRA_DIST += \
+	$(srcdir)/../../../include/host/mars/mars_timer.h \
+	$(srcdir)/../../../include/host/mars/mars_workload_queue.h \
+	$(srcdir)/../../../include/common/mars/mars_debug.h \
+	$(srcdir)/../../../include/common/mars/mars_kernel_types.h \
+	$(srcdir)/../../../include/common/mars/mars_workload_types.h
 
-libmars_la_CPPFLAGS = \
+AM_CPPFLAGS = \
+	$(extra_cppflags) \
 	-I$(srcdir)/../../../include/host \
 	-I$(srcdir)/../../../include/common
 
-libmars_la_CFLAGS = \
-	$(HOST_FLAGS)
+AM_CFLAGS = \
+	$(extra_cflags) \
+	-W \
 	-Wall \
 	-Wunused \
 	-Winline \
@@ -54,19 +99,10 @@  libmars_la_CFLAGS = \
 	-Wmissing-prototypes \
 	-Wmissing-declarations
 
-# version-info rules (current:revision:age):
-# * If the library source code has changed since the last release, then
-#   increment revision.
-# * If any interfaces have been added, removed, or changed since the
-#   last release, then increment current and set revision to 0.
-# * If any interfaces have been added since the last release, then
-#   increment age.
-# * If any interfaces have been removed since the last release, then
-#   set age to 0.
+AM_LDFLAGS = \
+	$(extra_ldflags)
 
-libmars_la_LDFLAGS = \
-	-version-info 0:0:0 \
-	-Wl,../../mpu/kernel/mars_kernel.eo
+lib_LTLIBRARIES = libmars.la
 
 libmars_la_SOURCES = \
 	mars_context.c \
@@ -78,3 +114,27 @@  libmars_la_SOURCES = \
 	mars_task_queue.c \
 	mars_task_semaphore.c \
 	mars_task_signal.c
+
+libmars_la_DEPENDENCIES = mars-kernel.eo
+
+# library version-info rules (current:revision:age):
+# * If the library source code has changed since the last release, then
+#   increment revision.
+# * If any interfaces have been added, removed, or changed since the
+#   last release, then increment current and set revision to 0.
+# * If any interfaces have been added since the last release, then
+#   increment age.
+# * If any interfaces have been removed since the last release, then
+#   set age to 0.
+
+libmars_la_LDFLAGS = \
+	-version-info 0:0:0 \
+	-Wl,-Map -Wl,$@.map -Wl,--cref \
+	-Wl,mars-kernel.eo
+
+libmars_la_LIBADD = -lspe2
+
+mars-kernel.eo: ${MARS_KERNEL}
+	$(EMBEDSPU) $(CFLAGS) mars_kernel_entry  $< $@
+
+CLEANFILES = *.eo *.map
--- a/src/mpu/Makefile.am
+++ b/src/mpu/Makefile.am
@@ -38,9 +38,6 @@ 
 
 SUBDIRS = lib kernel
 
-EXTRA_DIST = \
-	bootstrap \
-	configure.ac.in \
-	config.sub.patch
+EXTRA_DIST = bootstrap configure.ac.in
 
 MAINTAINERCLEANFILES = Makefile.in
--- a/src/mpu/bootstrap
+++ b/src/mpu/bootstrap
@@ -39,15 +39,10 @@ 
 
 version="$1"
 
-sed -e s,@version@,${version},g \
-	configure.ac.in > configure.ac
+sed -e s,@version@,${version},g configure.ac.in > configure.ac
 
 aclocal
 libtoolize --force --copy
 autoheader
 automake --foreign --add-missing --copy
 autoconf
-
-if [ -e config.sub ]; then
-	patch -p1 < config.sub.patch
-fi
--- a/src/mpu/config.sub.patch
+++ /dev/null
@@ -1,24 +0,0 @@ 
---- a/config.sub	2005-11-22 05:18:02.000000000 -0800
-+++ b/config.sub	2006-07-11 12:09:36.000000000 -0700
-@@ -816,6 +816,10 @@
- 	ppc64le-* | powerpc64little-*)
- 		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
- 		;;
-+	ppu)
-+		basic_machine=powerpc64-cell
-+		os=-linux
-+		;;
- 	ps2)
- 		basic_machine=i386-ibm
- 		;;
-@@ -868,6 +872,10 @@
- 	spur)
- 		basic_machine=spur-unknown
- 		;;
-+	spu)
-+		basic_machine=spu-cell
-+		os=-none
-+		;;
- 	st2000)
- 		basic_machine=m68k-tandem
- 		;;
--- a/src/mpu/configure.ac.in
+++ b/src/mpu/configure.ac.in
@@ -36,30 +36,36 @@ 
 #  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
 #
 
-AC_INIT(mpu, @version@, Yuji Mano <yuji.mano@am.sony.com>)
+AC_INIT([mars], [@version@], [MARS <cbe-oss-dev@ozlabs.org>])
 
-host_alias=spu
-AC_SUBST(host_alias)
-
-libdir=${prefix}/spu/lib
-ac_configure_args="$ac_configure_args --libdir $libdir"
+AC_ARG_WITH([mars-platform],
+	[AS_HELP_STRING([--with-mars-platform=TYPE],
+		[specify mars platform TYPE (cell | spursengine)])],
+	[],
+	[AC_MSG_ERROR([missing option --with-mars-platform=])])
+AS_CASE([${with_mars_platform}],
+	[cell],[],
+	[spursengine],[],
+	[AC_MSG_ERROR([invalid option --with-mars-platform=${with_mars_platform}])])
+AM_CONDITIONAL([MARS_PLATFORM_CELL],
+	[test "x${with_mars_platform}" = "xcell"])
+AM_CONDITIONAL([MARS_PLATFORM_SPURSENGINE],
+	[test "x${with_mars_platform}" = "xspursengine"])
+AC_MSG_RESULT([using mars-platform ${with_mars_platform}])
+
+AC_ARG_ENABLE(
+	[debug],
+	[AS_HELP_STRING([--enable-debug], [build debug versions of mars])])
+AM_CONDITIONAL([DEBUG], [test "x${enable_debug}" = "xyes"])
+AC_MSG_RESULT([using enable-debug ${enable_debug}])
 
 AC_CONFIG_AUX_DIR([.])
 
-AC_PROG_CC(spu-gcc)
-AC_PROG_CXX(spu-g++)
-AC_PROG_LD(spu-ld)
-AM_PROG_AS(spu-as)
-AC_PATH_TOOL(PPU_EMBEDSPU, ppu-embedspu)
-
 AC_PROG_LIBTOOL
 AM_INIT_AUTOMAKE
-
-AC_CONFIG_HEADERS(config.h)
-AC_CONFIG_FILES([
-	Makefile
-	kernel/Makefile
-	lib/Makefile
-])
+AM_PROG_AS
+AC_SUBST([DESTDIR])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_FILES([Makefile lib/Makefile kernel/Makefile])
 
 AC_OUTPUT
--- a/src/mpu/kernel/Makefile.am
+++ b/src/mpu/kernel/Makefile.am
@@ -36,15 +36,44 @@ 
 #  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
 #
 
+extra_cppflags =
+extra_cflags =
+extra_ldflags =
+
+if DEBUG
+ extra_cppflags += "-DDEBUG"
+ # debug kernel is 64K
+ extra_ldflags += -Wl,--defsym=__stack=0x0fff0
+else
+ extra_cppflags += "-DNDEBUG"
+ # release kernel is 16K
+ # ** todo **
+ extra_ldflags += -Wl,--defsym=__stack=0x0fff0
+endif
+
+if MARS_PLATFORM_CELL
+endif
+
+if MARS_PLATFORM_SPURSENGINE
+endif
+
 MAINTAINERCLEANFILES = Makefile.in
 
-noinst_PROGRAMS = mars_kernel mars_kernel.eo
+EXTRA_DIST = \
+	$(srcdir)/../../../include/mpu/mars/mars_kernel.h \
+	$(srcdir)/../../../include/mpu/mars/mars_syscalls.h
 
-mars_kernel_CPPFLAGS = \
+AM_CPPFLAGS = \
+	$(extra_cppflags) \
 	-I$(srcdir)/../../../include/mpu \
 	-I$(srcdir)/../../../include/common
 
-mars_kernel_CFLAGS = \
+AM_CCASFLAGS = \
+	$(extra_cppflags)
+
+AM_CFLAGS = \
+	$(extra_cflags) \
+	-W \
 	-Wall \
 	-Wunused \
 	-Winline \
@@ -53,12 +82,15 @@  mars_kernel_CFLAGS = \
 	-Wmissing-prototypes \
 	-Wmissing-declarations
 
-mars_kernel_LDFLAGS = \
-	-Wl,--defsym=__stack=0x0fff0 \
+AM_LDFLAGS = \
+	$(extra_ldflags) \
+	-Wl,-Map -Wl,$@.map -Wl,--cref \
 	-Wl,-gc-sections \
 	-Wl,-N \
 	-Wl,-s
 
+noinst_PROGRAMS = mars-kernel
+
 mars_kernel_LDADD = $(builddir)/../lib/libmars.a
 
 mars_kernel_SOURCES = \
@@ -69,6 +101,4 @@  mars_kernel_SOURCES = \
 	mars_kernel_task.c \
 	mars_kernel_workload.c
 
-mars_kernel_eo_SOURCES =
-mars_kernel.eo: mars_kernel
-	$(PPU_EMBEDSPU) $(HOST_FLAGS) mars_kernel_entry mars_kernel mars_kernel.eo
+CLEANFILES = *.map
--- a/src/mpu/lib/Makefile.am
+++ b/src/mpu/lib/Makefile.am
@@ -36,15 +36,52 @@ 
 #  LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
 #
 
+extra_cppflags =
+extra_cflags =
+extra_ldflags =
+
+if DEBUG
+ extra_cppflags += "-DDEBUG"
+else
+ extra_cppflags += "-DNDEBUG"
+endif
+
+if MARS_PLATFORM_CELL
+endif
+
+if MARS_PLATFORM_SPURSENGINE
+endif
+
 MAINTAINERCLEANFILES = Makefile.in
 
-lib_LIBRARIES = libmars.a
+pkginclude_HEADERS = \
+	$(srcdir)/../../../include/common/mars/mars_error.h \
+	$(srcdir)/../../../include/common/mars/mars_mutex_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_barrier_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_event_flag_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_queue_types.h \
+	$(srcdir)/../../../include/common/mars/mars_task_semaphore_types.h \
+	$(srcdir)/../../../include/mpu/mars/mars.h \
+	$(srcdir)/../../../include/mpu/mars/mars_mutex.h \
+	$(srcdir)/../../../include/mpu/mars/mars_task.h \
+	$(srcdir)/../../../include/mpu/mars/mars_task_barrier.h \
+	$(srcdir)/../../../include/mpu/mars/mars_task_event_flag.h \
+	$(srcdir)/../../../include/mpu/mars/mars_task_queue.h \
+	$(srcdir)/../../../include/mpu/mars/mars_task_semaphore.h \
+	$(srcdir)/../../../include/mpu/mars/mars_task_signal.h
+
+EXTRA_DIST = \
+	$(srcdir)/../../../include/mpu/mars/mars_dma.h \
+	$(srcdir)/../../../include/mpu/mars/mars_timer.h
 
-libmars_a_CPPFLAGS = \
+AM_CPPFLAGS = \
+	$(extra_cppflags) \
 	-I$(srcdir)/../../../include/mpu \
 	-I$(srcdir)/../../../include/common
 
-libmars_a_CFLAGS = \
+AM_CFLAGS = \
+	-W \
 	-Wall \
 	-Wunused \
 	-Winline \
@@ -53,6 +90,8 @@  libmars_a_CFLAGS = \
 	-Wmissing-prototypes \
 	-Wmissing-declarations
 
+lib_LIBRARIES = libmars.a
+
 libmars_a_SOURCES = \
 	mars_entry.S \
 	mars_mutex.c \