This page will guide you through the compilation process of MicroLua.
This page concerns both Windows and Linux users. In each part, there will be explanations for the two OS.
This is currently working with devkitPro 1.5.3 (libnds 1.5.7, devkitARM 41) and MicroLua 4.7.1. There is no clue that it won't work with any later version but in the same time I cannot guarantee it will work without modification.
The first thing to do is to download everything you need. Some are archives so a good archive manager such as 7zip is recommended.
Now you have everything needed, we can start with installing the devkitPro toolchain. This is the "compilation machine" which brings all the tools needed to build a .nds
.
The automated installer 'devkitProUpdater-X.exe' will guide you through the download and installation of the complete toolchain.
The only part needed is msys and devkitARM so you can uncheck everything else for a minimal setup. These parts concern PSP, NGC and Wii, besides some tools that may or may not be useful.
There should be no issue with this but you may check that some environment variables have been created. They will lead the compilation process to devkitPro's binaries (otherwise the compilation fail as it will not find the make
commands.
Run a command interpreter (Windows+R then type in cmd
) and type:
echo %DEVKITPRO% echo %DEVKITARM%
If set properly, you should see the paths leading to your devkitPro installation, and to a folder called 'devkitARM' in the same path than above. If you haven't changed anything, they should be respectively 'c:\devkitpro' and 'c:\devkitpro\devkitARM'.
The variable PATH
also should have been changed by adding 'c:\devkitpro\msys\bin' (default path) to it. You check it out likewise with echo %PATH%
.
If there any problem with these, check the following chapter; otherwise, you may jump to 'Install the µLibrary'.
Let's say the variables weren't set properly; we have to make them anyway. Here is how to do this:
DEVKITXXX
variables in the lower listPATH
variable by adding the path followed by a semi-column ";" (without any space)I invite you to check what you did by following the step in the chapter hereabove.
Running 'devkitARMupdate.pl' will install devkitPro in your 'home' folder, however this can be customized by editing the first line of real instructions in the script.
Then you need to add the environment variables similarly to Windows, as the script cannot do this.
You should probably edit the file called either '.profile' or '.bash_profile' following the one already existing. This way they will be available in every shell you open.
Put somewhere in (at the end of) the file:
DEVKITPRO=/home/YOUR_NAME/devkitpro DEVKITARM=$DEVKITPRO/devkitARM
Restarting the shell (or doing source .profile
or source .bash_profile
if you are lazy) is mandatory for this to have an effect. You can check it worked by typing:
echo $DEVKITPRO echo $DEVKITARM
At this point you may be able to compile a generic source code for the NDS, however MicroLua needs two more things before the compilation can be made.
The next step is to install the µLibrary. This is a lib which (mainly) ease drawings so you do not have to mess with the low-level libnds for this.
Helpfully the precompiled files in 'libnds' may work, so you only have to merge this folder into the one in the devkitPro root. However there are not updated (and this may cause them not to work) so I advised to follow the compilation steps hereby in order to properly setup the µLibrary.
Some Batch scripts are present to ease the process, but you have to set the paths within the scripts.
ROOTPATH
to the devkitpro's folder (usually 'c:\devkitpro')ROOTPATH
to the libnds's folder inside the devkitPro's one (usually 'c:\devkitpro\libnds')Now you are done, go back to the µLibrary folder and run 'Install.bat'. It is advised to run it from a CMD. Then, cd
to 'Source' and run its 'Install.bat'.
You're done! You can test that the compilation process is working fine by running a 'Build.bat' in any example from the µLibrary folder. If you manage to get a working .nds in the end, it means you are almost done.
Running make
and / or make install
in the 'Source' will do the job: building the lib, and copying the includes and the '.a' in the devkitPro folder according to the set environment variables.
One of the archives you downloaded earlier is a custom libnds lib which enables support for Nifi from MicroLua.
The only thing you need to do is to merge the 'libnds' folder into the one already present inside 'devkitpro' by replacing the asked files.
Whether you got the sources from the static package or the repository, you get a folder containing among others 'lua' (the Lua sources modified for MicroLua), 'sources' (the 'main.c' for µLua), etc.
If you need to include some files in the EFS, make a directory called 'efsroot' and put them in.
Finally we can compile MicroLua!
You have two batch scripts, 'Compile_All.bat' and 'Compile_DS.bat':
The first time, you obviously need to compile the lualib so run 'Compile_All.bat'. If an error occurs, run it a second time and it should be okay. Thus you also get your executable, meaning... You made it!
The next time, 'Compile_DS.bat' will be sufficient unless you change something inside the 'lua' folder.
It is very close to what you did with the µLib and in the end you need to do the same things than the Windows users:
cd lua
make
and then make install
make clean
if you wish (important if you want to commit something to our Git repository afterwards)cd ..
Now you have built the lualib. So just do a make
in the µLua's folder and you get your .nds binary! make clean
may be done here too.
The other times, a make
in the µLua's folder is enough unless you modify something inside 'lua'.
Since 4.7, the Makefile provides two more targets:
make all
will always compile both lualib and 'MicroLua.nds'make cleanall
will clean both the 'lua' folder and the current folderYou can get more informations about this feature here.
Since [1c5823] there is no need to make the folder if you do not wish to use the EFS; the compilation process will include the folder and patch the binary to enable the EFS only if the folder is found.
By putting the 'lua' folder inside it, MicroLua will use this one if none is present on the linker. Replace the file 'shell.lua' inside 'lua/libs' by your 'index.lua' (the main file of your script) and you get your standalone MicroLua homebrew!
Many thanks to thomh@ck for his tutorial (French).
Commit: [1c5823]
Wiki: EFS
Wiki: GetSources
Wiki: Home
Wiki: Tutorials