/*
        bumprev.srx

        Bump revision

        © 1998 HAAGE & PARTNER GmbH

        Create a new empty file and attach this make script to it. After the
        first make this file contains version 1. Touch this file if you want
        a new revision set. Change the version number if you want to increase
        it. In this case you should edit the file "xxx_rev.rev" and set the
        revision number to 0.

        Warning: this make script overwrites its file if the first line does
                 not contain a single number.

        $VER bumprev.srx 2.0 (9.3.98)
*/

/* Don't forget the point '.' at the end      \/        */
PARSE ARG '"' filename '"' '"' projectname '"' .

revname = LEFT(filename,LASTPOS('_ver.txt',filename)-1)

SAY ""
SAY "Bumping revision..."

found = 0
IF OPEN(vfile,filename,"Read") == 1 THEN DO
        version = READLN(vfile)
        IF DATATYPE(version,"Whole") THEN
                found = 1
        CALL CLOSE(vfile)
        END
IF ~found THEN DO
        SAY "Version not found - generating new version file"
        IF OPEN(vfile,filename,"Write") == 1 THEN DO
                CALL WRITELN(vfile,"1")
                CALL WRITELN(vfile,"* The first line contains the version number")
                CALL WRITELN(vfile,"* If you change this you should also edit the file")
                CALL WRITELN(vfile,"* "||revname||"_rev.rev and set the revision")
                CALL WRITELN(vfile,"* number to 0.")
                CALL WRITELN(vfile,"")
                CALL WRITELN(vfile,"* Touch this file if you want to set a new revision number")
                CALL CLOSE(vfile)
                END
        ELSE DO
                SAY "Unable to create version file "||filename||"."
                EXIT 20
                END
        version = 1
        END

ADDRESS COMMAND "bumprev" version revname
OBJECTS filename revname||"_rev.h" revname||"_rev.i"

SAY "Done."
