Related projects

Sep 12, 2019

Setting up a 64bit Linux development env for AROS

One of the scariest part about coding or compiling applications for AROS (in particular for the x64 version, where the following procedures are mandatory) seems to be setting up the AROS build system which is, on the contrary, quite straightforward. So here I will explain how I did it, which is the simpliest, barest, dumbest way to do this thing. Better implementations would include using different directories for building, in order to separate different targets (for instance, ARM, M68K and i386) on the same computer, but I'm leaving this to your will. At the end you should be able to compile your 'HelloWorld.c' program for 64bit AROS.

UPDATE!

We now provide a pre-configured Ubuntu 64 based Linux virtual machine for this! Follow this link to download it and save time. However, if you still wish to set up everything by yourself, just ignore it and go on reading.

> Icaros' Linux Development Environment virtual machine for VMware Player

SETTING UP THE UBUNTU VIRTUAL MACHINE

Let's be clear. Linux gives great freedom to users, and you might have practical and ethical motivations to dislike this distribution and prefer another one, but please get real and let's be practical guys: if you choose Ubuntu, you're SURE this procedure will work as expected, with no customizations, no personal modifications, no unavailable packages, no avoidable issues. You will use the upcoming machine to compile AROS and AROS programs only. Nothing else. You can live with this distro, with its GUI, with its habits. So head to Ubuntu's download page and grab Ubuntu 18.04.x LTS (long time support), which is exactly the one I'm using as well.

> Download Ubuntu

(you can follow the 'alternative downloads' link on the right of the page, if this guide got old and another version of the distro has superseded the suggested one).

Then, you need a virtualization platform. There are several ones out there, with QEMU/KVM, VMware Player and VirtualBox being the most popular. Again, I suggest to choose the one that works better, both with Linux and AROS, which is VMware Player. Grab the latest version here:

> VMware.com download page for VMware Workstation Player

It's FREE and available for both Linux and Windows, so you won't have any issues running a Ubuntu virtual machine on your computer. If you have a Mac, there is VMware Fusion but you will have to pay for it. The alternative is VirtualBox, but I generally suggest it as a 'last option' because 1) sometimes newer releases introduce regressions with guest OSes which worked good before, and 2) this is often the case with AROS (where we received dozens of reports about sound and mouse pointer not properly working). I am also sick of discussions with VirtualBox users, when I tell them their virtualisation platform has issues.

Once you have these two components, you can install VMware Workstation Player. You need a 64bit host operating system (either Linux or Windows) with a stable Internet connection you will share with your virtual machines. Create a VM with the following specs:

Operating system --> Ubuntu 64bit
Processors --> 2 - 4  (if you have a new Ryzen processor... why not?)
Memory --> 2 - 4 GB
Hard drive space --> 40 - 60 GB thin provision¹
Network
USB controller 2.0
Sound

(¹) Thin provisioning is the default behavior for VMware Player, when setting up a virtual machine: it allows dynamically increasing .vmdk file space when you actually save data to it. So, if you create a 60 GB hard drive file, it will not take 60 GB of your real hard drive at once, but its size will grow as much as you use it. In a nutshell, it will grow up to the size you choose, with time.

Boot your new virtual computer and let Ubuntu update itself. After a little while, you will be able to add components needed by AROS. When you're ready, open a Linux shell and enter the following commands:

sudo apt-get install -y libpng-dev zlib1g-dev libxcursor-dev libgl1-mesa-dev libasound2-dev
sudo apt-get install -y gawk bison flex netpbm automake cmake genisoimage sshpass
sudo apt-get install -y python-mako libswitch-perl gperf gcc-multilib g++ ccache
sudo apt-get install -y jlha-utils wget

Now start Mozilla (or any browser you installed on your VM) and download AROS sources from the following link:

https://github.com/aros-development-team/AROS.git

Create a directory in your home, for instance 'sources' and extract all contents. In this guide, I will use this path: ~/sources, you will need to adapt it if you choose a different one.

Now be sure your internet connection is working and keep it alive, because the next steps require a Internet connection. Give the following commands:

cd  ~/sources
./configure --target=pc-x86_64 --enable-ccache --with-gcc-version=9.1.0 --with-binutils-version=2.32 --with-portssources=~/sources

make -j 2 && make -j 2 distfiles


this will create your first AROS ISO. If you need to redo it quickly after modifying some file, the following command will be enough:

make -j 2 bootiso-quick

TARGETING TO DIFFERENT ARCHITECTURES  (new!)


If you follow the instrctions on AROS Site's Page About Compiling, you will find two very useful hints about using a different directory for portsources and another, related one for compiling to different targets. Let's say you wish to compile both linux-hosted AROS for x64 and the native one. In this case, you should take a better approach:


1. instead of using a single directory for everything, create several ones:
- one for sources in general, ~/sources
- one for portsources, to preserve them, ~/portsrc
- one for your main target, for instance ~/native64


2. now, instead of configuring and making from the /sources directory, enter your target one:
cd ~/native64


3. now configure from here, specifying that you should also use the ~/portsrc directory for port sources:
../sources/configure --target=pc-x86_64 --enable-ccache --with-gcc-version=9.1.0 --with-binutils-version=2.32 --with-portssources=~/portsrc
4. compile with make commands from ~/native64.

If you wish to compile AROS to a second architecture, just create a different directory than ~/native64, and change the configure command accordingly.

COMPILING YOUR SOFTWARE


Now that we have a working AROS build system, it's time to use it to compile your software. You will do this providing both source files and a metamake script called 'mmakefile.src'. One for each project you need. Metamake scripts are a sort of recipe that tells the crosscompiler what to do. Unluckily, I am not able to tell you how to correctly write one, but I can give you at least a vague idea. Inside of ~/sources, create a 'personal' drawer for your programs.

md personal

and, inside of ~/sources/personal, create a different 'projectname' subdirectory for each program, for instance ~/sources/personal/myproject

Now, let's imagine you have a myproject.c and myproject.h files for your program: you should place them into ~/sources/personal/myproject and create a mmakefile.src script in the same directory, for instance:


include $(SRCDIR)/config/aros.cfg

#MM local-personal-myproject : includes linklibs

FILES := myproject    ← myproject.c without .c
EXEDIR := $(AROS_CONTRIB)/$(AROS_DIR_DEVELOPER)/Build    ← destination path for binary file
NOWARN_FLAGS := $(NOWARN_FORMAT)
USER_CFLAGS := $(NOWARN_FLAGS)

%build_prog mmake=local-personal-myproject \
progname=myproject targetdir=$(EXEDIR) \   ← executable name
files=$(FILES)

%common

Pay attention to the first line (#MM local-personal-myproject : includes linklibs), the bold part is the one you will call with the make command, from the root of the sources directory

cd ~/sources

make local-personal-myproject


If you need a better explanation to this, please also read the following documents:

> The AROS build system, and how MetaMake works on aros.org

Aros/Developer/BuildSystem on Wikibooks.org

> "How I compiled deark for 64bit AROS" on this site.