/*
* {automake|configure} => {nmake|iffe} conversion support
*
* The first command line target overrides the default original source
* directory name $(MAKEFILE:D). The hard work is in the makefile using
* these assertions, since it must (manually) provide the nmake makefiles
* and config equivalent iffe scripts. The conversion makefile is typically
* named lib/package/PACKAGE.cvt in an ast package $PACKAGEROOT directory,
* and the conversion is run from the $PACKAGEROOT directory, e.g.:
*
* nmake -I lib/package -f PACKAGE-VERSION/PACKAGE.cvt
*
* The conversion requires the ast nmake, pax and tw commands.
*
* After the conversion you will be liberated from ./configure, *.in,
* *.am, automake, autom4te, libtool, make depend, and makefile
* recursion ordering. You can build from $PACKAGEROOT using the ast
* package(1) (which sets up the { HOSTTYPE PATH VPATH } environment):
*
* package make
*
* of the hierarchy with the ast nmake(1) (after setting PATH and VPATH):
*
* nmake
*
* The conversion assertions are:
*
* package :CONVERT: file ...
*
* files in the original source directory are copied
* and converted into the ./src and ./lib subdirectories
* the default original source directory is ./original
*
* package package name
* file original source file that must exist
*
* :OMIT: pattern
*
* files matching pattern are not copied into the converted
* directory
*
* pattern ksh pattern of files to omit
*
* :COPY: from to [ file ... ]
*
* files in the from directory are copied to the to directory
* the action may contain :MOVE: exceptions to the copy
*
* from original directory subdirectory
* . names the original directory
* .. names the
* to converted subdirectory
* file files or files in subdirectories to be copied;
* explicit files are copied to the to directory;
* if no files are specified then the from hierarchy
* is recursively copied to the converted directory
*
* :MOVE: to file ...
*
* :COPY: assertion exceptions placed in the assertion's action
*
* to files or subdirectory files are copied to this directory
* file file or files in subdirectories to be copied
*
* :FILE: to file <<!
* contents
* !
*
* the :FILE: action is copied to the named file in the to directory
* the :FILE: action is usually specified using the here syntax to
* avoid make comment, quote and variable expansion
*
* :EDIT: to file ... | - pattern <<!
* edit script
* !
*
* the :EDIT: action is an ed(1) script applied to each file in the
* to directory after it has been copied from the original source
* directory; if to is - then the :EDIT: action is a sed(1) script
* that is applied to all files matching the file pattern during the
* copy from the original source directory; a file may be subject to
* both a sed(1) and ed(1) :EDIT:; the :EDIT: action is usually
* specified using the here syntax to avoid make comment, quote and
* variable expansion
*/
package = $(PWD:B)
here = !-=-=-=-=-!
CPFLAGS = -u
PAXFLAGS = -u -v
STDEDFLAGS = -
local D
if D = "$(~.ARGS:O=1)"
if "$(D:T>FD)"
original := $(D)
.cvt.package =
local N V
V := $(%:O=1)
return -s',^\(\(?K)?(*/)($(omit))?(/*))$,,$(showedit)'
if "$(%)" == "."
return src
if "$(%)" == "*/*"
return src/$(%)
if "$(%)" == "lib*"
local I
package := $(<)
$(I) : .ACCEPT
local I
if I = "$(.cvt.package:T!=F)"
local F T I A
F := $(>:O=1)
copy : $(A)
$(A) : .VIRTUAL
if F == "."
$(A) : $(T)
$(T) :
for I $(>:O>2)
$$(A) : $(I:D=$(T):B:S)
$(I:D=$(T):B:S) : $$(original)/$(I)
$$(A) : $$(F)
cd $(T)
else
F := $$(original)/$(F)
if ! "$(@:V)"
$$(A) : .FORCE
cd $(F:V)
else
: $(@:V:@R)
$$(A) : .FORCE
cd $(F:V)
local A D F
D := $(>:O=1)
if D == "-"
else
F := $(>:O>1:C,^,$(D)/,)
edit : $(F)
$$(F) :
$(@:V)
w
q
$(here)
local ( D F ) $(>)
local A
$(A) := $(@:V)
file : $(D)/$(F)
$$(D)/$$(F) :
cat > $$(<) <<'$(here)'
$$($(A):V)
$(here)
local T I
for I $(>:O>1)
if I == "*/"
else
local P
for P $(>)