Auto XT

Stratego -- Strategies for Program Transformation
The autoxt package provides Autoconf and Automake support for packages constructed with the XT toolset. The package provides the autoxt tool which should be run as part of the Autoconf/Automake bootstrapping process, prior to running autoconf. A typical bootstrap script looks like:

#! /bin/sh

autoxt
autoreconf -if

The toplevel Makefile.am should declare:

ACLOCAL_AMFLAGS = -I .

Autoconf

Autoxt installs a set of m4 macros autoxt.m4 with support for package configuration switches. By just including the macro call XT_USE_XT_PACKAGES a configure.ac file can be parameterized with switches for all the StrategoXT packages:

AC_INIT([java-front],[0.6],[stratego-bugs@cs.uu.nl])
AM_INIT_AUTOMAKE

XT_USE_XT_PACKAGES
XT_PKG_ATERM
XT_PKG_SDF
XT_PKG_STRATEGOXT

AC_PROG_CC
AC_PROG_INSTALL
AC_CONFIG_FILES([Makefile syn/Makefile])
AC_OUTPUT

Available Macros

  • XT_USE_XT_PACKAGES
    Adds configuration options to configure the package with the location of the ATerm library, SDF and StrategoXT.

  • XT_PKG_ATERM
    Checks if the ATerm library is installed at the specified prefix of the ATerm library.

  • XT_PKG_SDF
    Checks if the SDF packages are installed at the specified prefix of SDF.

  • XT_PKG_STRATEGOXT
    checks if StrategoXT is installed at the specified prefix of StrategoXT.

  • XT_TERM_DEFINE
    Defines some Stratego strategies that will return the values (as strings) of various Autoconf variables: PACKAGE_NAME_TERM(), PACKAGE_TARNAME_TERM(), PACKAGE_VERSION_TERM(), PACKAGE_BUGREPORT_TERM(), and SVN_REVISION_TERM(). These strategies can be used in any Stratego program in this package.

  • XT_PRE_RELEASE
    Adds the suffix pre${SVN_REVISION} to the PACKAGE_VERSION and VERSION variables. This is a naming convention for unstable packages that we are using in our release management system.

Automake

Furthermore, autoxt installs Makefile.xt, a collection of automake rules for compiling Stratego programs and applying other XT tools, such as signature generation. Using this makefile, a makefile reduces to a declaration of programs to be compiled. The makefile automatically takes care of distributing the generated C code. The specification will only be compiled when it is newer than the C code. This means that packages using autoxt can be built using only the Stratego Run-Time System (srts).

include $(top_srcdir)/Makefile.xt
include $(wildcard *.dep)

bin_PROGRAMS    = xtc
pkgdata_DATA    = xtc-lib.rtree xtc-rep.rtree xtc-proc.rtree
SCFLAGS         = --main $*
STRINCLUDES     = -I $(XTC)/share/xtc
EXTRA_DIST      = $(pkgdata_DATA) $(wildcard *.str) $(wildcard *.meta)
CLEANFILES      = $(wildcard *.dep)
BOOTCLEANFILES  = xtc.c

Explanation of the example

  • include $(top_srcdir)/Makefile.xt
    Instructs the Stratego compiler to compile the Stratego files.

  • include $(wildcard *.dep)
    The Stratego compiler generates .dep files which contain information about file dependencies. When these .dep files are included a rebuild is forced when a dependent file changes.

  • bin_PROGRAMS
    Specifies the resulting binaries from the compilation.

  • SCFLAGS
    Contains compiler flags passed to the Stratego compiler.

  • STRINCLUDES
    Are the additional includes necessary for a succesful compilation.

  • EXTRA_DIST
    Specifies which auxilary files have to be included in the distribution.

  • CLEANFILES
    Deletes these files when the make clean command is issued.

  • BOOTCLEANFILES
    In addition to files specified in CLEANFILES, deletes these files when the make bootclean command is issued.

See also: