gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Sorting out the PATH and Makefile mess

#51143 - Quirky - Tue Aug 16, 2005 7:49 pm

I'm getting a bit hacked off with an aspect of GBA coding; namely how to deal with the unique set of tools required and how to correctly build programs so that they Just Work (or at least give meaningful errors) when someone else tries to build them elsewhere. Especially with all their 'stuff' installed in different places.

My original approach to keeping track of multiple projects was to create a file that has all the tools I need, gfx2gba, devkitARM etc, defined by their full path, together with typical flags (FOOBAR=/home/rich/gbadev/Tools/foobar FOOBARFLAGS=-n -q -x) and then include this in each game's Makefile. OK, keeps configuration in one spot across multi-projects and makes my life easy, providing I never release the source code.

I also have my own gba library, as I'm sure a lot of homebrewers have, made up from bits and bobs from all over the place that works as well as it needs and has sensible headers. I have all my gba dev code in ~/gbadev/Projects/ together with this library (*.[ach]) in ~/gbadev/Projects/gbalib/. .

Right. So what is the problem?

Well, I find I'm duplicating a lot of stuff in my Makefiles, I need to hadrcode the path between my gbalib and the current working directory (for -L and so forth), as I add more libraries it gets harder to keep track. Makefiles are tedious to write and not very useful (all and clean and that's it). I'm toying with Lua and Tepples' GBFS, so that's 2 more -Ls that I need to hardcode. I have my own simple XM playing library that I need to hardcode when I use it. Ditto for the include paths to header files. If I use GBFS tools, for example, they live in /some/path/to/gbfs/tools/ which I need to, again, add in to the included tools makefile rules. It's all getting a bit complicated and not very good if I want to sensibly release anything ever.

So, what is the solution? I've recently been trying autoconf and automake with a bit of success. They help with a lot of the problems: I can define required library paths with ./configure --host=arm-elf --with-gbalib=/path/to/lib for a particular project and then make 'remembers' the choice until you need to change something major. The Makefiles are also easier to write, just the bare minimum and the rest is autogenerated, with nicer rules (dist being especially useful). And it should be easier for other people to compile the code as the configure script gives them advice as to what they are missing and where. The downside is that this really requires arm-elf-gcc and friends to be in the PATH, together with any other special programs I need. I do have this now for GBA coding at least - but why is it generally frowned upon? Installing Insight adds arm-elf-insight to /usr/local/bin, for example, which is very similar.

But it does have downsides: the configure.ac input becomes the new Makefile-like monster of copy paste for any new projects - rules to check for gbalib, rules to check for programs required are all identical across projects. The files Makefile.am require special rules for GBA (the elf objcopy at the end) that you must copy-paste each time. Anything a bit non-standard, such as rules for gfx2gba, requires special attention and more copy pasting. Dealing with multiple palette images requires extra scripting. There's no real way to scale it all nicely that i can see.

So what's the best solution to this mess? How is one supposed to go about cross compiling in an organized way? Normal programs automagically know where their libraries live (dlls in windows live in C:\Windows(?) and libXXX.so is found by ldd on GNU/Linux) but cross compiled ones can't use this wizardry. How do other people go about this in a way that is scalable as your number of homebrew projects grow?

#51190 - sgeos - Wed Aug 17, 2005 3:05 am

I'd just hardcode the directories into the makefile using the makefile variable deal. When someone else has to use it, they can "fix" the directory variables and it should work.

-Brendan

#51209 - wintermute - Wed Aug 17, 2005 5:43 am

you might care to look at the recommended way to set up devkitARM found here - http://www.devkitpro.org/setup.shtml

Using the method described there and the standard devkitPro makefiles has made compiling across different environments quite easy. Currently most work has been done with the DS environment but template projects and some more GBA examples will be available soon.

As the toolchains mature I hope to add some more automation to linux installation, probably starting with .deb

#51263 - Quirky - Wed Aug 17, 2005 7:42 pm

I think the /usr/local/devkitpro idea is good, especially if the DEVKITPRO and DEVKITARM variables become homebrew standard,

I assume they are meant to be set as the following?:
Code:

export DEVKITPRO=/usr/local/devkitPro
export DEVKITARM=/usr/local/devkitPro/devkitARM

(or the equivalent  in Windows/Minsys)


I have more or less decided to move over to using autoconf - I've written a gba.m4 that checks for 'GBA things' and it works pretty well, cuts down a lot on copy paste and means no editting is needed for changing file locations. If I change having arm-elf-gcc in the path to using DEVKITARM, or even checking for one then the other, I see it as the way to go (for me at least).

#51290 - wintermute - Thu Aug 18, 2005 12:31 am

Quirky wrote:
I think the /usr/local/devkitpro idea is good, especially if the DEVKITPRO and DEVKITARM variables become homebrew standard,

I assume they are meant to be set as the following?:
Code:

export DEVKITPRO=/usr/local/devkitPro
export DEVKITARM=/usr/local/devkitPro/devkitARM

(or the equivalent  in Windows/Minsys)




yes that's correct

Code:

export DEVKITPRO=/c/devkitPro
export DEVKITARM=/c/devkitPro/devkitARM


Are the current equivalents on windows. It's certainly possible to use /usr/local on msys but this means they'll be inside the msys directory. That's given me an idea though, msys allows for pseudo mount points using an fstab which may allow the /usr/local/devkitPro path to point to the default installation.

Quote:

I have more or less decided to move over to using autoconf - I've written a gba.m4 that checks for 'GBA things' and it works pretty well, cuts down a lot on copy paste and means no editting is needed for changing file locations. If I change having arm-elf-gcc in the path to using DEVKITARM, or even checking for one then the other, I see it as the way to go (for me at least).


msys also allows for automake/autoconf so it's conceivable that your system may work equally well on windows. Personally I think that would be rather cool :)