Cross Compile for PPC

Dec 16, 2013
1 min read
May 27, 2023 11:35 EEST

First install eldk described here .

Automake and Autoconf

We use automake and autoconf, because cmake cannot cross compile yet. At first we need some files for automake:

touch NEWS
touch README
touch AUTHORS
touch ChangeLog

Create a autogen.sh:

#!/bin/sh
rm -f config.cache
rm -f acconfig.h

autoreconf --force --install -I config -I m4
#autoconf
#autoheader
#automake --add-missing

./configure "$@"

echo
echo "Now type 'make' to compile."

We have the following directory structure:

/
 -> i2c

Now create a file called configure.ac:

AC_INIT(icecube, 0.1)
AC_PREREQ(2.5)
AC_CONFIG_SRCDIR([i2c/readMax6633.c])
AC_CONFIG_AUX_DIR(config)

AM_INIT_AUTOMAKE(1.8)

AC_PROG_CC

dnl Checks for header files.
AC_CONFIG_HEADER(config.h)
AC_HEADER_STDC
AC_CONFIG_FILES([Makefile i2c/Makefile])
AC_OUTPUT

And a file Makefile.am:

EXTRA_DIST = autogen.sh configure
SUBDIRS = i2c

In the directory i2c create a file Makefile.am:

INCLUDES = -I/usr/local/eldk/ppc_6xx/usr/include

bin_PROGRAMS = readMax6633
readMax6633_SOURCES = readMax6633.c

Now execute the script autogen.sh with:

./autogen.sh --host=ppc-6xx --prefix=/usr/local/eldk/ppc_6xx/usr/local

To cross-compile now do the following:

export CROSS_COMPILE=ppc_6xx-
make

cmake

Create a file CMakeLists.txt:

project (ICECUBE)

SET(CMAKE_C_FLAGS "-O")
add_subdirectory(i2c)

And a file i2c/CMakeLists.txt:

add_executable (readMax6633 readMax6633.c)

Now execute:

CC=ppc_6xx-gcc cmake .

Related Posts