0
votes

In the first line of my configure.ac I need to tell autoconf what is the name of my package:

AC_INIT([xjump], [2.8], [])

Should I try to avoid duplicating the "xjump" name inside my code or is it ok to hardcode "xjump" when needed? More specifically:

1. For directories in /var

In my install script I need to create a directory inside "/var". Should I use

install-exec-hook:
    mkdir -p    @localstatedir@/@PACKAGE@
    touch       @localstatedir@/@PACKAGE@/highscores

or should I use

install-exec-hook:
    mkdir -p    @localstatedir@/xjump
    touch       @localstatedir@/xjump/highscores

Also, right now the highscore file stays there when I run make uninstall. Should I add an uninstall hook to remove it or is there a way to handle this automatically?

2. Executable names

Right now the name of my executable is hardcoded

bin_PROGRAMS = xjump
xjump_SOURCES = game.c

Is there a way to make it not be? The following gives an error when I try to run it:

# error: 'bin_PROGRAMS' contains configure substitution
bin_PROGRAMS = @PACKAGE@
@PACKAGE@_SOURCES = game.c 

3. Man pages

Similarly to the question about binaies, is there a way to make the man page name not hardcoded?

dist_man_MANS = xjump.6
1

1 Answers

2
votes

Generally speaking, you should not do this -- not because it is necessarily a bad idea, but because there is already a general facility in autoconf to do something like this, and this facility puts control in the hands of the users, where it belongs.

To see how to use this as a user, search the Autoconf manual for --program-transform-name (and related options). These provide a way to rename programs at install time. Automake automatically applies these transforms to programs and some other installable objects, without any effort on your part. (This is one of the many add-on features that Automake provides for free.)

Now, Automake doesn't apply this transform in all situations. Sometimes you must do it yourself, by hand, in Makefile.am. In your question, this would apply to the /var case. I don't think there is a hard-and-fast rule for when you ought to do this and when not. One reason it is commonly done is if you want your program to be "parallel installable" -- meaning that the user might want to have multiple versions installed and running alongside each other at the same time. However, in this case the "normal" thing to do is not to use the program transform, but instead to put the version number into the directory name (and program names, etc).