#!/bin/sh
+PROJ="eet"
+
+SKIFF="/skiff/local"
+HOSTARCH="i686-pc-linux-gnu"
+TARGETCPU="arm"
+TARGETARCH=$TARGETCPU"-pc-linux-gnu"
+
make clean distclean
-./configure
+export CC=$SKIFF"/bin/"$TARGETCPU"-linux-gcc"
+export CFLAGS=-O9
+./configure \
+--host=$HOSTARCH \
+--build=$TARGETARCH \
+--target=$TARGETARCH
+
+INST="/tmp/"$PROJ"-instroot"
+sudo rm -rf $INST
+
+make
-cp config.h config.h.bak
-grep -v HAVE_FMEMOPEN config.h.bak > config.h
-#cp config.h config.h.bak
-#grep -v HAVE_OPEN_MEMSTREAM config.h.bak > config.h
-rm config.h.bak
+for I in find . -name "*.la" -print; do
+ sed s:"/usr/local":$INST:g < $I > "/tmp/.sed.tmp"
+ sudo cp "/tmp/.sed.tmp" $I
+ rm -f "/tmp/.sed.tmp"
+done
-CC="/skiff/local/bin/arm-linux-gcc"
-ST="/skiff/local/bin/arm-linux-strip"
-CFLAGS="-O2"
+sudo \
+make \
+prefix=$INST \
+exec_prefix=$INST \
+bindir=$INST"/bin" \
+sbindir=$INST"/sbin" \
+sysconfdir=$INST"/etc" \
+datadir=$INST"/share" \
+includedir=$INST"/include" \
+libdir=$INST"/lib" \
+libexecdir=$INST"/libexec" \
+localstatedir=$INST"/var/run" \
+mandir=$INST"/share/man" \
+infodir=$INST"/share/info" \
+install
-rm -rf "build"
-mkdir "build"
-DST=`pwd`"/build";
+## FIXUPS
+for I in $INST"/bin/"* $INST"/sbin/"* $INST"/libexec/"*; do
+ J=`echo $I | sed s:$TARGETARCH"-"::g`
+ sudo mv $I $J
+done
-mkdir $DST"/lib";
-mkdir $DST"/bin";
-mkdir $DST"/include";
-#mkdir $DST"/share";
-#mkdir $DST"/share/eet";
+CF=$INST"/bin/"$PROJ"-config"
+sed s:"/usr/local":$SKIFF"/"$TARGETCPU"-linux":g < $CF > "/tmp/.sed.tmp"
+sudo cp "/tmp/.sed.tmp" $CF
+rm -f "/tmp/.sed.tmp"
-pushd src
+for I in $INST"/lib/"*.la; do
+ sed s:"/usr/local":$SKIFF"/"$TARGETCPU"-linux":g < $I > "/tmp/.sed.tmp"
+ sudo cp "/tmp/.sed.tmp" $I
+ rm -f "/tmp/.sed.tmp"
+done
- pushd lib
- LIB="eet"
- $CC \
- *.c \
- $CFLAGS \
- -I. \
- -I../.. \
- -I/skiff/local/include \
- -shared -fPIC -DPIC \
- -Wl,-soname -Wl,"lib"$LIB".so.0.0.1" \
- -o "lib"$LIB".so.0.0.1"
- $ST -g "lib"$LIB".so.0.0.1"
- rm -f "lib"$LIB".so"
- ln -s "lib"$LIB".so.0.0.1" "lib"$LIB".so"
- rm -f "lib"$LIB".so.0"
- ln -s "lib"$LIB".so.0.0.1" "lib"$LIB".so.0"
- rm -f "lib"$LIB".so.0.0"
- ln -s "lib"$LIB".so.0.0.1" "lib"$LIB".so.0.0"
- cp -a "lib"$LIB".so"* $DST"/lib";
- cp -a "Eet.h" $DST"/include";
- popd
+## package it all up
+PACK=$PROJ"-"$TARGETCPU"-inst.tar.gz"
- pushd bin
- BIN="eet"
- $CC "eet_main.c" \
- -I../.. -I../lib \
- -I. \
- -I/skiff/local/include \
- -L. -L../lib \
- -L/skiff/local/lib \
- -leet -ljpeg -lz -lm \
- -o $BIN
- $ST $BIN
- cp -a $BIN $DST"/bin";
- popd
-popd
+DIR=$PWD
+cd $INST
+sudo tar zcvf $DIR"/"$PACK *
+sudo chown $USER $DIR"/"$PACK
+cd $DIR
+sudo rm -rf $INST
-#cp -ar data $DST"/share/eet"
+## install it in our skiff tree
+cd $SKIFF"/"$TARGETCPU"-linux"
+sudo tar zxvf $DIR"/"$PACK
-PD=`pwd`
-pushd "build"
- tar zcvf $PD"/data.tar.gz" *
- pushd /skiff/local
- sudo tar zxvf $PD"/data.tar.gz"
- popd
-popd