I am a rather new C++ programmer. I have made a very simple game using SDL libraries. My game, naturally, uses some images, sounds and fonts. I have wanted to make a distribution of the package, where user's can configure && make . It's not like this simple game is worth distributing, but I want to learn how autoconf and automake works. I searched for the examples around the internet but tutorials I could find shows only installation of a simple helloworld program. They neither talk about installation of data files, nor how to check for if certain libraries exists so that I could link against them in compile time. And also, my program should know where each file get installed so that it can load them. I have delved into automake and autoconf manuals, but they are more like a reference materials than being a resource for new comers. Could anyone briefly explain this concepts, or lead me to some place where I could read about them.
How to package data files with GNU's autoconf and automake
Asked Answered
I've found that the best way to go with autoconf/automake is to find a project similar to your own, see what they do, and work up from there with the documentation. –
Crush
Try the Goat Book for a more readable introduction to autotools. They have a few example projects of varying complexity that show how to do most common things with autotools. –
Milka
Looks promising. I am taking a look at it. –
Muzz
You may want to look at John Calcote's book "Autotools: A Practioner's Guide to GNU Autoconf, Automake, and Libtool" –
Bogart
I have made some research on this, and I have wanted to share what has worked for me. I have created a directory structure like this:
/
|->src/
| |-> Makefile.am
| |-> main.cpp
| |-> functions.cpp
|
|-> data/
| |-> Makefile.am
| |-> somethings.png
| |-> something.mp3
|-> configure.ac
|-> README
|-> NEWS, AUTHORS etc. etc.
I have put all my images, fonts, sounds etc. in data folder. Makefile.am on data folder looks like this:
pkgdata_DATA = esound.wav \
another.wav \
apicture.png
It simply lists all the files that need to be end up in the data directory. The Makefile.am in the src folder look like this:
bin_PROGRAMS = mygame
mygame_SOURCES = main.cpp functions.cpp
AM_CPPFLAGS = -DDATADIR=\"$(pkgdatadir)\"
The important part here is AM_CPPFLAGS, which defines DATADIR macro, according to the options passed to the configure script. So then we can use this macro in our source files like this:
background = load_image( DATADIR "/background.png");
So that your program will get compiled knowing where background file should reside in the filesystem.
Should you use dist_pkgdata_DATA if you want to distribute it? –
Fortuna
© 2022 - 2024 — McMap. All rights reserved.