Transforming Program Names When Installing

Autoconf supports changing the names of programs when installing them. In order to use these transformations, configure.ac must call the macro AC_ARG_PROGRAM.

function>AC_ARG_PROGRAM/function> Place in output variable program_transform_name a sequence of sed commands for changing the names of installed programs.

If any of the options described below are given to configure, program names are transformed accordingly. Otherwise, if AC_CANONICAL_TARGET has been called and a -target value is given, the target type followed by a dash is used as a prefix. Otherwise, no program name transformation is done.

Transformation Options

You can specify name transformations by giving configure these command line options:

-program-prefix=prefix

prepend prefix to the names;

-program-suffix=suffix

append suffix to the names;

-program-transform-name=expression

perform sed substitution expression on the names.

Transformation Examples

These transformations are useful with programs that can be part of a cross-compilation development environment. For example, a cross-assembler running on a Sun 4 configured with -target=i960-vxworks is normally installed as i960-vxworks-as, rather than as, which could be confused with a native Sun 4 assembler.

You can force a program name to begin with g, if you don't want gnu programs installed on your system to shadow other programs with the same name. For example, if you configure gnu diff with -program-prefix=g, then when you run make install it is installed as /usr/local/bin/gdiff.

As a more sophisticated example, you could use

--program-transform-name='s/^/g/; s/^gg/g/; s/^gless/less/'

to prepend g to most of the program names in a source tree, excepting those like gdb that already have one and those like less and lesskey that aren't gnu programs. (That is assuming that you have a source tree containing those programs that is set up to use this feature.)

One way to install multiple versions of some programs simultaneously is to append a version number to the name of one or both. For example, if you want to keep Autoconf version 1 around for awhile, you can configure Autoconf version 2 using -program-suffix=2 to install the programs as /usr/local/bin/autoconf2, /usr/local/bin/autoheader2, etc. Nevertheless, pay attention that only the binaries are renamed, therefore you'd have problems with the library files which might overlap.

Transformation Rules

Here is how to use the variable program_transform_name in a Makefile.in:

PROGRAMS = cp ls rm
transform = @program_transform_name@
install:
        for p in $(PROGRAMS); do \
          $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p | \
                                              sed '$(transform)'`; \
        done

uninstall:
        for p in $(PROGRAMS); do \
          rm -f $(DESTDIR)$(bindir)/`echo $$p | sed '$(transform)'`; \
        done

It is guaranteed that program_transform_name is never empty, and that there are no useless separators. Therefore you may safely embed program_transform_name within a sed program using ;:

transform = @program_transform_name@
transform_exe = s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/

Whether to do the transformations on documentation files (Texinfo or man) is a tricky question; there seems to be no perfect answer, due to the several reasons for name transforming. Documentation is not usually particular to a specific architecture, and Texinfo files do not conflict with system documentation. But they might conflict with earlier versions of the same files, and man pages sometimes do conflict with system documentation. As a compromise, it is probably best to do name transformations on man pages but not on Texinfo manuals.