Terminus autotools setup

From Bitpost wiki

I am going to set up to build with gcc using GNU autotools. It seems to be a pretty common way of doing things, it's not too hard to set up, and once an autotools-built project is set up, maintaining it is a breeze.

Here's my script to create a new project for existing source files:

[m@thedigitalmachine terminus]$ cat ~m/scripts/setup_new_project.sh
#!/bin/bash

# MDM This sets up some default files, to prevent warnings.
touch NEWS README AUTHORS ChangeLog

# MDM We want to redo everything, kill anything that might screw us up.
rm -rf config_backup 2>&1
rm -rf autom4te.cache_backup 2>&1
mv config config_backup 2>&1
mv autom4te.cache autom4te.cache_backup 2>&1

# MDM Set up default dirs, too.
mkdir src >/dev/null 2>&1
mkdir test >/dev/null 2>&1
mkdir config >/dev/null 2>&1
mkdir doc >/dev/null 2>&1

# MDM This creates configure.scan, an initial template for configure.ac,
# based on the code it finds in the current directory.
autoscan

# MDM From http://lists.nongnu.org/archive/html/automake/2003-04/msg00226.html
# libtoolize is the tool that will install (config.sub, ltmain.sh) in your package.
# Consider also autoreconf, which will run
# libtoolize/autopoint/aclocal/autoconf/automake in the right
# order for you.
libtoolize --force

# MDM This runs all the automake tools.
bootstrap

# MDM Go ahead and configure and make, to see if it works.
./configure && make clean && make

And my boostrap script:

[m@thedigitalmachine terminus]$ cat ~m/scripts/bootstrap
#!/bin/bash

aclocal \
    && automake --add-missing --copy \
    && autoconf

Before I can run those successfully we need to create a configure.in file.

But first, where should I put the autotools files? My ShareTheDJ project has all the autotools files in the project root, and the source code under project/src. It would be nice if I could set up the autotools files under a subdirectory, since the root already has source files in it. I'll see if I can pull that off...

[m@thedigitalmachine terminus]$ ls
config.cpp       craftselect.hpp  gamedef.hpp  gamesys.hpp   mainmenu.hpp  profiles   startup.cpp  system.hpp    Terminus_private.h    util
config.hpp       data             game.hpp     main.cpp      profile.cpp   scene.cpp  startup.hpp  Terminus.ico  Terminus_private.rc   world
craftselect.cpp  game.cpp         gamesys.cpp  mainmenu.cpp  profile.hpp   scene.hpp  system.cpp   Terminus.png  Terminus_private.res  xml

Heh, you are way beyond me here. I have never used the autotools stuff. Dev-Cpp builds a makefile for me from the project settings that I set up in the IDE.

There is a bunch of stuff in the root dir that I did not put into the SC (such as the Dev-Cpp project config file) because it did not apply to the Linux build. Should that kind of stuff end up in the SC? Should it be put into a seperate repository?

I am thinking maybe stuff like that I will put into a zip and check it into the root as "windows_build.zip" with each release. NBD.

I think we should add all building configuration right into the terminus repository. Then comes the question of directory structure. Maybe something like this?

terminus/
  (source code)
  (source code subdirs)
  linux
  windows

autotools expects the source to be UNDER the autotools build directory, but I can get around that with a symlink:

terminus/
  (source code)
  (source code subdirs)
  linux
     src (just a symlink to ../)
  windows

I'm pretty sure that will work for me. Can you set up Dev-Cpp configuration under the windows subdir? If not, I say just dump the files right in with the source code, should be fine. What do you think?

I'm slowly making progress on the autotools config. SDL requires a little trickery, you have to include an autotools "M4" macro. I will wait until I get autotools working, then check in the linux directory, if that sounds OK. The only thing outside the linux directory will be one or two autotools config files in the root - I don't see a way around that - does that sound OK?

---

Back. I have screwed around with setting up autotools under the linux directory until I couldn't stand it any more. As of now I am able to compile and get code-related errors, but the autotools config files are located at the parent of the terminus source directory. Here are the files required to build:

 terminus/
   configure.in
   Makefile.am
   terminus/
     code from svn repository
     Makefile.am

Do this to set up to build:

 cd terminus
 setup_new_project.sh

From that point on I can build by typing "make". Here are the first errors I get:

In file included from world/weapon.hpp:8,
                 from world/craft.hpp:11,
                 from craftselect.hpp:9,
                 from craftselect.cpp:5:
world/bullet.hpp:23: error: type specifier omitted for parameter `szBullet'
world/bullet.hpp: In member function `TeRect TeBullet::getBoundRect()':
world/bullet.hpp:236: error: request for member `CenteredAt' in `rclBullet',
   which is of non-aggregate type `const TeRect ()(TePoint (*)())'
In file included from craftselect.hpp:9,
                 from craftselect.cpp:5:
world/craft.hpp: At global scope:
world/craft.hpp:22: error: type specifier omitted for parameter `szCraft'
world/craft.hpp: In member function `TeRect TeCraft::getBoundRect()':
world/craft.hpp:192: error: request for member `CenteredAt' in `rclCraft',
   which is of non-aggregate type `const TeRect ()(TePoint (*)())'
make[1]: *** [craftselect.o] Error 1
make[1]: Leaving directory `/home/m/development/terminus/terminus'
make: *** [all-recursive] Error 1

Bedtime...

Sorry I did not response to this last night - I was thinking about it, but did not come up with a conclusion until this morning:

terminus (the only thing that goes here is the stuff that HAS to go here, like your autotools stuff)
  src (plus subdirs)
  data (plus subdirs)
  linux (build scripts, dlls, libs, diaries, project files, etc.)
     output (obj files)
     release
        current
        1.0.0
        1.1.0
  windows (build scripts, dlls, libs, diaries, project files, etc.)
     output (obj files)
     release
        current
        1.0.0
        1.1.0

However, if you are up and running (and happy with it) let's not change things. I would have to refactor my project files, my old VSS, and the new SVN to match the changes :-(

Sounds like a plan, man! It will take a little more autotools tweaking. I would agree with you and hold off on the reorganization in the short term, though, since we both have everything working as it is. I can just tar up what's needed and put it in the root, like you had planned to do with the windoze stuff. Here's what I plan on adding, if it sounds OK:

terminus 
  (existing source code and data)
  setup_linux_build.sh
  linux/
    autotools.tar.gz

autotools.tar.gz consists of the following autotools configuration files:

configure.in                the primary autotools configuration file
Makefile.am                 makefile details for the root dir
acinclude.m4                macros needed for SDL - this is a copy of /usr/share/aclocal/sdl.m4
terminus/Makefile.am        makefile details for the source code in the terminus dir
terminus/util/Makefile.am   makefile details for util
terminus/world/Makefile.am  makefile details for world
terminus/xml/Makefile.am    makefile details for xml

After you run the setup script, you will have the following mess (which unfortunately seems to be the linux "standard"). Note that the script WILL dump files one directory above the terminus subversion repository directory.

(tons of autotools files)
config/(autotools config files)
autom4te.cache/(autotools junk)
terminus/
  (source code)
  (source code.o)
  Makefile.am
  Makefile.in
  Makefile
  (source code subdirs)
    (source code)
    (source code.o)
    Makefile.am
    Makefile.in
    Makefile

What do you think? It's not terrible I guess. And we can revisit and reorganize later. So... upwards and onwards?  :>

Yes, that is all cool. You da man!

You need any help with those errors?

Sure! For now, here is what I am adding:

terminus 
  (existing source code and data)
  setup_linux_build.sh
  linux/
    root/
      acinclude.md4
      configure.in
      Makefile.am
    Makefile.am
    ToDo.txt (just some notes)

I still need to check this stuff out fresh and test it. rollin rollin rollin...

I was unable to get the autotools stuff working. I think I have all the correct SW installed but am missing a step. Help!

How far did you get and what is the error/status? One thing that's very confusing - I have a terminus root directory, then the terminus subversion directory under that.