![]() |
|||
PORTING GUIDEIntroductionThis guide is about porting of software which comes with configure or make scripts to AROS. This is true for the most open source software from the Linux world. It is based on a document which was written by Johan Samuellson for AmigaOS4. What to port?
Getting the SDK up to dateThe most easy way to port to AROS is from a Linux box, because it usually has all the needed development tools. Look in the Development Guide for some information on how about to install the SDK. The basicsThe first thing you do is to check how to build your project. If there is a file called configure in the root directory of the archive, it means you'll have to configure it for your platform. See the next chapter for a description on how to do that. After the project is properly configured it's time to roll out the compiler. Start building your project by typing make. However, if there was no file called configure, look for a file called Makefile. Edit it to suit AROS and build the project with make. If everything compiled and linked you are ready to test your port. A very common problem is that it won't find its datafiles, and crash. Fix the paths as described in the path-fixing chapter, and try to run it again. Strip the binaries in order to remove debugging information and making them smaller. OK, you're done now, upload it to http://archives.aros-exec.org and http://www.aminet.net! How to configureOn Linux, packages with a configure script are usually installed in 3 steps: ./configure make sudo make install What makes configuring for AROS more difficult than e.g. for AmigaOS4 is the fact that we are using a cross compiler. Type ./configure --help to see what options are available. If configuring fails we can try to disable some features. Simple example./configure CC=i386-aros-gcc \ --build=local --host=i686-aros --disable-nls --without-x --without-pic --disable-shared Indication It makes sense to write the configure statement to a text file. This way we can easily re-run it like sh build.sh. But before we re-run the script we have to do rm -f config.cache in order to reset the configuration process. Here is an explanation of the options we have used above:
Avis Don't do sudo make install because this would install your application in Linux paths like /usr/local. SDL example (manual installation)The following example is for Ltris, but it should be similar for other SDL applications: ./configure CC=i386-aros-gcc LDFLAGS="-nix" \ --prefix=/PROGDIR \ --build=local --host=i686-aros \ --disable-nls --without-x --without-pic --disable-shared \ --with-sdl-prefix=/usr/local/aros-sdk/i386-aros
After a successful run of the configure script and make we have to copy the ltris binary and the data files in such a way that the binary finds the data files:
ltris
ltris (binary)
share
ltris
gfx
sounds
SDL example (half automatic installation)We can use nearly the same options as above: ./configure CC=i386-aros-gcc LDFLAGS="-nix" \ --prefix=/PROGDIR --bindir=/PROGDIR \ --build=local --host=i686-aros \ --disable-nls --without-x --without-pic --disable-shared \ --with-sdl-prefix=/usr/local/aros-sdk/i386-aros
Don't forget the --prefix option or it will install AROS files in some Linux paths. Now you can rebuild your project (make distclean, run the configure script, make). We could now call sudo make install. But it is better to do first the following steps:
This has the advantage that we can access /PROGDIR without root rights. Now we can finally do make install which should install the game in /PROGDIR. As this isn't a good place we have to copy it to a place were AROS can reach it (e.g. cp -r /PROGDIR ~/AROS/games/ltris). Remember to do rm -rf /PROGDIR/* before you build another project. Common errors that can occur when configuringI get errors like target or host i686-aros isn't available.
The same thing also often happens when configure is searching for SDL_ttf, and you know why by now. We need to specify some more libs that SDL_ttf depends on. It needs -lfreetype and -lz. I will leave the rest to you as an exercise. If you have added the needed dependencies to the configure script, and it still doesn't work it can be due missing files in the SDK. E.g. the SDL libs aren't included. If it still doesn't work, and you are sure that you have the library installed, try to remove the whole section where it checks for the failing library in the configure file. This is not recommended, but if there is no other way... Now you should be ready to build your project. When porting unix apps always type make. Creating a makefile by handThis makefile could be used if the build system is a mess and you want to simplify it a bit, alter it to fit your needs. Usually you only need to modify an existing makefile, change the name of the C compiler (otherwise it would create binaries for Linux) and add some linklibraries. Here's an explanation of what the flags do.
CC = i386-aros-gcc
RM = rm
STRIP = i386-aros-strip --strip-unneeded --remove-section .comment
CFLAGS = -Wall -O2
LDFLAGS = -nix -lsmpeg -lSDL_gfx -lSDL_net -lSDL_image -lpng -ljpeg -lz -lSDL_mixer \
-lvorbisfile -lvorbis -logg -lSDL_ttf -lfreetype -lz -lsdl -lauto -lpthread -lm
OBJS = a.o b.o c.o
OUTPUT = test.exe
all: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(OUTPUT)
main.o: main.cpp main.h
$(CC) $(CFLAGS) -c main.cpp
strip:
$(STRIP) $(OUTPUT)
clean:
$(RM) -f $(OBJS) $(OUTPUT)
Remember that you have to use tabulator chars before the command. Using the build systemThe build system contains some scripts for configuring of packages. The big advantage when using the build system is that you can easily port to different AROS flavours.
Look in the file $(TOP)/config/make.tmpl for an explanation of the arguments. In $(TOP)/contrib/gnu you can already find a lot of GNU packages. MiscConverting unix paths to AROS pathsHow do I convert UNIX paths into AROS paths? Exchange getenv("HOME") by "/PROGDIR/" Examples:
old: strcpy(path, getenv("HOME"));
new: strcpy(path, "/PROGDIR/");
old: strcpy(home,getenv("HOME"));
new: strcpy(home,"/PROGDIR/");
old: sprintf(rc_dir, "%s/.gngeo/romrc.d", getenv("HOME"));
new: sprintf(rc_dir, "%sgngeo/romrc.d", "/PROGDIR/");
Notice that I removed "/." in the last example. Paths to datadirs are often set during the configure process by issuing -DDATADIR=. If this is the case set it to -DDATADIR=/PROGDIR/ It's also common that the datadir are set in the makefiles. Locate DATADIR= and change it to DATADIR=/PROGDIR/ DefinesDefines are often set in config.h, if something is configured wrongly, you can often change it here by using #define and #undef. A define example that considers all AmigaOS flavours:
#ifdef __AMIGA__
blah blah blah
#else
blah blah blah
#endif
A define example that only considers AROS:
#ifdef __AROS__
blah blah blah
#else
blah blah blah
#endif
A define example, that considers BeOS and AROS: #if !defined(__BEOS__) && !defined(__AROS__) An example of a more complex #ifdef:
#ifdef GP2X
char *gngeo_dir="save/";
#elif defined __AROS__
char *gngeo_dir="/PROGDIR/save/";
#else
char *gngeo_dir=get_gngeo_dir();
#endif
Some open source packages are already adopted to Amiga-like operating systems. If you find something like #ifdef __AMIGA__ in the source you can try to add the define to the config options (e.g. CFLAGS="-nix -D__AMIGA__"). Understanding error messages
Common errorswarning: incompatible implicit declaration of built-in function 'exit'; warning: incompatible implicit declaration of built-in function 'abort': solution: #include <stdlib.h> warning: implicit declaration of function 'strlen'; warning: incompatible implicit declaration of built-in function 'strlen': solution: #include <string.h> warning: implicit declaration of function 'memcpy'; warning: incompatible implicit declaration of built-in function 'memcpy': solution: #include <string.h> error: memory.h: No such file or directory: solution: #include <string.h> error: malloc.h: No such file or directory: solution: #include <stdlib.h> warning: incompatible implicit declaration of built-in function 'printf': solution: #include <stdio.h> warning: implicit declaration of function 'MyRemove': solution: #define MyRemove Remove Tips and tricksHow do I search for text strings using GREP? grep -R "I am looking for this" * How do I make a DIFF file with my changes? diff originalfile.c mychangedfile.c >./originalfile.patch
How do I redirect GCC warnings and errors to a text file? make 2>warnings.txt |
Copyright © 1995-2009, L'équipe de développement AROS. Tous droits réservés. Amiga®, AmigaOS®, Workbench et Intuition sont des marques de Amiga Inc. Les autres marques appartiennent à leur propritaires respectifs. |