@ KDEV 2007 Some Rights Reserved
Porting Applications - Compile with cross-compiler
In this how-to we explain how to port a application or a library to foXServe using the ACME Sytems SDK Patched by Phrozen.

Before start:
foXServe software is compiled using CRIS. This means that binaries (executables) files are compiled for a particular architecture. You cannot run a binary compiled for X86 but you need to compile the sources and get it compiled for ETRAX processor, this process is called "porting". In the next steps we will see how to perform a a porting.

-Prepare the SDK installed following guidelines on ACME systems website:
Installing the SDK on Linux
Installing the SDK on windows XP

The SDK is the system provides you all is needed to CROSS COMPILE your software

After you have succesfully installed the SDK you need to set the environment variables so that the compiler will match "DEVBOARD" libraries and includes.
To do this simply go to the devboard-R2_01 directory and type:

/home/fox/devboard-R_01# . ./init_env
Prepending "/..../devboard-R2_01/tools/build/bin" to PATH.
Prepending "/usr/local/cris/bin" to PATH.
Now the SDK is succesfully initialized, rember that environment is related to the terminal window where you execute it, so is mandatory to re-launch the command each time you switch to another terminal window.

If you need to compile only a single C file, create the makefile for it following this article http://www.acmesystems.it/?id=711 or use the webcompiler

Move to apps folder under SDK root:

/home/fox/devboard-R_01# cd apps

Now we need to take the software source from the website of the owner:
In these example we are going to port mailsend a simple SMTP client.

Download sources for All platform or LINUX/UNIX platform of the software in this case:

curl -O http://www.muquit.com/muquit/software/mailsend/mailsend1.15b5.tar.gz

Unpack it using tar:
tar xzvf mailsend1.15b5.tar.gz

enter in the new created folder:
cd mailsend1.15b5

Now we need to launch the configure script provided in the package specifiyng a few options, to get the list of option launch
./configure --help
This is probably the most complicated step, because we need to specify where are header files and libraries located and we need to specify libraries of the SDK not the system library of your machine!

In this example we want to configure the client with SSL so that a Secure communication (OpenSSL if STARTTLS and CRAM-MD5 ) with the mailserver can be esatablished, not all portings need that you specify options, and is enough taht you launch ./configure, in this way base configuration is assumed

./configure --with-openssl=/home/fox/devboard-R2_01/apps/crypto/openssl-IR0_9_7f-1/openssl

You can use locate command to search for libraries: locate <pattern>

Now we need to modify the Makefile so that gcc-cris will be used instead of sydtem gcc

The file we need to modify are ALL Makefile of the software:

from the root folder of mailsend:

for this software you can skip Makefile under example directory but normally ALL makefile need to be adapted as Follows:

For each Makefile do: - Prepend to each Makefile (on top as first 2 lines)
include $(AXIS_TOP_DIR)/tools/build/Rules.axis
- Now search for CC or GCC entries and CFLAGS entry, if a entry CFLAGS exist replace only gcc with with gcc-cris and put -isystem -mlinux -Wall -Wshadow -O2 -g in CFLAGS
CFLAGS= -isystem -mlinux -Wall -Wshadow -O2 -g

In this case there is no CFLAGS entry so you need to change CC=gcc in
CC = gcc-cris -isystem -mlinux -Wall -Wshadow -O2 -g

Keep in mind that also the linker LD=ld need to be changed to ld-cris if specified in the Makefile (not in this example)
-when you changed all Makefile you need to launch:
make cris-axis-linux-gnu

This will create the target system specifications for you.
/home/fox/devboard-R_01# make cris-axis-linux-gnu
make[1]: Entering directory `/devboard-R2_01/apps/mailsend1.15b5'
(cd libs/libmsock && make clean)
rm -f msock.o libmsock.a core
(cd libs/libmutils && make clean)
rm -f string.o mutils.o mime.o libmutils.a core
(cd libs/libsll && make clean)
rm -f sll.o libsll.a core a.out
rm -f *.o *~ core mailsend
cp "/devboard-R2_01/apps/mailsend1.15b5/.tmp.target-makefrag" .target-makefrag
make[1]: Leaving directory `/devboard-R2_01/apps/mailsend1.15b5'
[root@localhost mailsend1.15b5]# make
(cd libs/libmsock && make)
an output like this should appear.

Now simply launch make
gcc-cris  -isystem -mlinux -Wall -Wshadow -O2 -g -O -I.  -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" 
As you can see during compile you will see the gcc-cris using the specified flags
When you finished compile you have to launch cris-strip to strip symbols and reduce the size of you ported binary
cris-strip mailsend

Now your software has been ported! Copy it in the READ/WRITE area of your foXServe /mnt/flash/ using ftp or scp

ensure execution prvileges to the file with

chmod +X mailsend
Now you are ready to execute it launch ./mailsend and try it!

The compiled (binary) for foXServe of Mailsend is available here.

Obviously this is an example of porting, if you adapt the Makefile of the sources following this guide probably you can port every software. Keep in mind that in some cases you need to fit dependencies or include libraries changing the Makefile. You can add libraries to the linker using LDLIBS+= <path to the library> in the Makefile, and include headers specifiyng the path in the -I option of <SOME>INCLUDE in your Makefile.

Some package after the ./configure generates libtool script. Libtool script need to be changed as the Makefile but YOU HAVE NOT to prepend the 2 lines of Rules.axis at the begin of the file. The other changes are the some.

If you have ported a application and you would like share your experience with others or include it in the main tree do not hesistate to contact us.




Special thanks to ACME Systems and JOHN CRISPIN for the SDK.

SMS MMS FoxBox the appliance based on foxserve for messaging management

foXServe is Developed by KDEV a Davide Cantaluppi company and running on ACME SYSTEMS srl Hardware.

@ KDEV 2007 Some Rights Reserved
foXServe firmware is free
foXServe firmware
Download it now!


Apache/1.3.37 Server

Copyright 2007 Kdev of Davide Cantaluppi Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

PHP 5.0.5
"This product includes PHP software, freely available from <http://www.php.net/software/>"

This product includes software developed by Greg Stein <gstein@lyra.org> for use in the mod_dav module for Apache (http://www.webdav.org/mod_dav/).