Developing cross platform program/game from ground up - part 1.

First of all its good to know what the differences are between the operating systems.
Do some resource and see what libs are ported and what are not ported to etch operating systems you like to support.

For AmigaOS4.1 you can check http://OS4Depot.net
For AmigaOS3.1 you can check http://Aminet.
For AROS you can check http://archives.aros-exec.org/.

Often you can to etch library and check how to configure and set it up in your development enviroment.

For example if you go to libpng web page and look you see how to configure it for windows.

Note for windows visual studio uses different build system then AmigaOS/Linux/AROS/MorphsOS or what ever, so I think might be best to create the project there and copy the files to the other computers.

You should have repository to track your changes and other people changes.
You can sign up a repository at code.google.com for free.

Design your application so its easy to update your program with out messing up your code.

Try to keep the OS depended code out of your game AI and general code.

If you need to draw a line make function or macro like:

app_draw_line()

this way draw line is abstracted from the OS, and it becomes easier to keep every thing compatible.

create folder in project root directory called.

linux, os3, os4, windows, osx and so on.

you will also need a folder called inc or include, here you put .h files that declare how functions will look like.

in the inc/display.h file you should have line like:

extern void app_draw_line();

extern means that app_draw_line does not need to be in the .c/.cpp file its included in, but can be in a different .c/.cpp file, this is to make sure the compiler does not get confused, because you can only have one app_draw_line function.

Setting up the makefiles.


For AmigaOS4, you make file named it Makefile.os4
          the following line should be like:

all: obj/display.o obj/filesystem.o obj/joystick.o obj/audio.o
          gcc main.cpp obj/display.o obj/filesystem.o obj/joystick.o obj/audio.o -o game.exe

display.o:
          gcc os4/display.c -o obj/display.o -c

filesystem.o:
          gcc os4/filesystem.c -o obj/filesystem .o -c

joystick.o:
          gcc os4/joystick.c -o obj/joystick .o -c

audio.o:
          gcc os4/audio.c -o obj/audio .o -c

create a make file for AmigaOS3 and name it Makefile.os3.

all: obj/display.o obj/filesystem.o obj/joystick.o obj/audio.o
          gcc main.cpp obj/display.o obj/filesystem.o obj/joystick.o obj/audio.o -o game.exe

obj/display.o:
          gcc os3/display.c -o obj/display.o -c

obj/filesystem.o:
          gcc os3/filesystem.c -o obj/filesystem .o -c

obj/joystick.o:
          gcc os3/joystick.c -o obj/joystick .o -c

obj/audio.o:
          gcc os3/audio.c -o obj/audio .o -c

create a make file for Linux and name it Makefile.linux

all: obj/display.o obj/filesystem.o obj/joystick.o obj/audio.o
          gcc main.cpp obj/display.o obj/filesystem.o obj/joystick.o obj/audio.o -o game.exe

obj/display.o:
          gcc linux/display.c -o obj/display.o -c

obj/filesystem.o:
          gcc linux/filesystem.c -o obj/filesystem .o -c

obj/joystick.o:
          gcc linux/joystick.c -o obj/joystick .o -c

obj/audio.o:
          gcc linux/audio.c -o obj/audio .o -c


So now you see that etch target platform has its own folder, with platform dependent code, while main.cpp is on the project root folder. This is because main.cpp is shared between the different target operating systems, and should not contain any OS dependent code.

Additional support libraries most also be statically linked or dynamically linked. Its up to you how you solve that.

Note I'm not using configure scripts, well this because different operating systems do not share the same shell commands, while there is some thing called ABC shell for AmigaOS that mimics the SH shell, it does not guaranty compatibility, with 1000 of GNU commands in Linux. This simply does not work for AmigaOS.

When compiling you simply do:

make all -f makefile.os4
make all -f makefile.os3
make all -f makefile.linux
make all -f makefile.aros

you can also make soft like to from makefile.os to makefile so you can just type

make all