genmake

Synopsis

(require "genmake")

(genmake-version>=? version)
(genmake-stkversion>=? version)
(generate-makefile &key :target-so :target-scm :target
                        :prefix :stkdir :libdir :execdir
                        :confdir :ardir :incdir :mandir
                        :bindir 
                        :dflgs   :eobj  :etkobj
                        :ipath   :lpath :libs)

Description

This module is to ease writing portable makefile for STk extensions. There's a lot of site-specific parameters you must consider, e.g. installation directories or compiler options, when compiling STk extensions. However, if you want to install an STk extension, you already have running STk installed, and that STk itself must know those site specific parameters. This module uses that knowledge to generate suitable Makefile for every site. I borrowed the idea from Perl's ExtUtils::MakeMaker.

Each extention is provided with a file called Makefile.scm, instead of Makefile, which looks like this:

  (require "genmake")
  (genmake-version>=? "0.2")
  (generate-makefile :target-scm "myextension.scm"
                     :target-so '(("myextension" "myextension" "moresource"))
                     :libs  '("-lmylib")
                     :lpath '("-L/usr/home/my/lib")
   )

If you want to install new extension module, all you need to do is

  stk Makefile.scm
  make
  make install

`stk Makefile.scm' creates a Makefile in which site-dependent parameters are set up.

genmake-version>=? VERSION

VERSION is a string representing version in period separated decimals, like "3.2" or "1.0.23". This procedure returns #t when current genmake version is equal to or larger than VERSION, otherwise #f. More valid keyword arguments for generate-makefile will be added in later versions of genmake, so this procedure is used to ensure that the user has recent version of genmake.

genmake-stkversion>=? VERSION

VERSION is a string representing version in period separated decimals, like "3.2" or "1.0.23". This procedure returns #t when current STk version is equal to or larger than VERSION, otherwise #f. This is useful if you want to make sure the user uses recent version of STk.

generate-makefile . ARGS

Write "Makefile" out, depending the system default values and keyword parameters given in ARGS. All valid keyword parameters are described the section below.

Customizing Makefile

Valid keyword argument for generate-makefile. To generate meaningful Makefile, you need to specify at least one of :target-so or :target-scm. The default values of other parameters are taken from config.make file.

:target-so SOFILE-SPEC
Specifies the target compiled shared file(s). Syntax of SOFILE-SPEC is as follows:
  SOFILE-SPEC : soname | (SOFILE-DEP ...)
  SOFILE-DEP  : soname | (soname oname ...)

where `soname' is a string specifying the name of target file, and `oname' is a string specifying the object file to create the target .so file. You shouldn't add suffix to `soname' and `oname'. Here are some examples

:target-so "foo"
genmake assumes "foo.so" is created from "foo.o"
:target-so '("foo" "bar")
genmake assumes "foo.so" is created from "foo.o", and "bar.so" is created from "bar.o".
:target-so '(("foo" "foo1" "foo2" "foo3") "bar")
genmake assumes "foo.so" is created from "foo1.o", "foo2.o" and "foo3.o", while "bar.so" is created from "bar.o".

If :target-so is specified multiple times, SOFILE-SPEC are accumulated.

:target-scm SCMFILE
:target-scm (SCMFILE ...)

Specifies the scheme source(s) to be installed. If :target-scm is specified multiple times, SCMFILEs are accumulated. You need to specify suffix.

:ipath "-Ipath"
:ipath ("-Ipath" ...)
Add "-Ipath" to IPATH variable which is used when .c file is compiled.
:libs "-llib"
:libs ("-llib" ...)
Add "-llib" to LIBS variable which is used to create .so file.
:lpath "-Lpath"
:lpath ("-Lpath" ...)
Add "-Llib" to LPATH variable which is used to create .so file.
:prefix DIR
Override prefix directory.

Examples

See Also


Shiro Kawai
Last modified: Thu Oct 7 21:54:22 HST 1999