***************************************************************************** * * GCI.NTMAKF.B - generate GCI makefile, Windows NT version * * Module %M% Version %I% Date %H% * * (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved * This is unpublished proprietary source code of Ardent Software Inc. * The copyright notice above does not evidence any actual or intended * publication of such source code. * ******************************************************************************* * * Maintenance log - insert most recent change descriptions at top * * Date.... GTAR# WHO Description......................................... * 10/14/98 23801 SAP Change copyrights. * 29/03/96 18026 PGW Module created by adapting GCI.MAKEFILE. * ******************************************************************************* * * This program creates a makefile for the GCI Library corresponding to a * given GCI Definition file. The makefile is called 'xxx.mak', where 'xxx' * is the GCI definition file name converted to lower case. * * To run this program, use the following command in the uvhome account: * * RUN APP.PROGS GCI.NTMAKF.B file.name * * where 'file.name' is the name of a GCI Definition file. * * The new makefile is created by modifying the model makefile 'Make.gci'. * This program reads in the model, searches for certain lines, and replaces * them. Each line is a macro defintion for a particular symbol. The symbols * required are: * * GCIFILE the name of the GCI definition file. * * GCILIB a list of the libraries needed to link the DLL. This * information comes from GCI definition file itself. Unlike * the Unix version, we do not need to check the DATA.TYPES * file, since all the conversion routines are available from * universe.lib. * * GCIDLL the root filename used for the new GCI library, that is the * GCI definition file name converted to lower case. * * If any of these lines is missing from Make.gci, or if Make.gci itself * cannot be opened, the program displays error messages and gives up. * @SYSTEM.RETURN.CODE is set to 0 if OK, -1 if an error occurs. * ******************************************************************************* * $OPTIONS DEFAULT PROGRAM GCI.NTMAKF.B ID = "@(#)%M% %I%" $INCLUDE UNIVERSE.INCLUDE FILENAMES.H $INCLUDE UNIVERSE.INCLUDE MACHINE.NAME * EQUATE bell TO CHAR(7) EQUATE sym.gcilib TO 1 EQUATE sym.gcifile TO 2 EQUATE sym.gcidll TO 3 EQUATE num.symbols TO 3 DIM symbol.name(num.symbols) DIM symbol.value(num.symbols) DIM symbol.found(num.symbols) * Set up the initial variables symbol.name(sym.gcilib) = "GCILIB" symbol.name(sym.gcifile) = "GCIFILE" symbol.name(sym.gcidll) = "GCIDLL" MAT symbol.value = "" MAT symbol.found = 0 PROMPT "" cl = @(-4) cl.err = @(0,23):cl err = cl.err:bell msg10 = err:PROD.NAMEU:' General Calling Interface is not installed.' failure.message = "The Makefile generation process has failed." OPENPATH UV.ROOT:'\DATA.TYPES' TO fvdata.types ELSE PRINT msg10: INPUT q: ; PRINT cl.err: @SYSTEM.SET = -1 STOP END * You can specify the definition file by putting its name on the * command line, otherwise it defaults to "GCI" cmd = CONVERT(" ", @FM, TRIM(@SENTENCE)) def.file.name = cmd<4> IF def.file.name = "" THEN def.file.name = "GCI" sccsid = DOWNCASE(def.file.name) model.path = UV.GCI : "\Make.gci" output.path = UV.GCI : "\" : sccsid : ".mak" PRINT @( -1 ) PRINT @( 0, 0 ):"General Calling Interface Administration" : @( 67, 0 ) : "GCI.NTMAKF.B": PRINT @( 17, 1): 'Generate a Makefile for GCI Definition File "':def.file.name:'"': PRINT @( 0, 2 ): STR( "-", 79 ): PRINT @( 0, 4 ): PRINTER RESET GOSUB open.files GOSUB set.symbol.values end.of.input = 0 LOOP READSEQ line FROM gci.model ELSE end.of.input = 1 UNTIL end.of.input DO GOSUB check.line.for.symbols IF line.type > 0 THEN GOSUB output.symbol END ELSE WRITESEQ line ON gcimake ELSE GOTO writeseq.error END REPEAT * Reached end of file - make sure that the necessary lines were present failed = 0 FOR symbol.no = 1 TO num.symbols IF NOT(symbol.found(symbol.no)) THEN PRINT "The ":symbol.name(symbol.no):" definition is missing from ": PRINT model.path:"." failed = 1 END NEXT IF failed THEN PRINT failure.message @SYSTEM.SET = -1 STOP END PRINT "Makefile generation complete." @SYSTEM.SET = 0 STOP ******************************************************************************* * * open.files: Opens the input and output files needed by the program. * * Arguments: * model.path (Input) Name of template for GCI makefile * gci.model (Output) Open file variable for template * output.path (Input) Name of output file * gcimake (Output) Sequential file variable for output * * Description: * ******************************************************************************* open.files: OPENSEQ model.path TO gci.model ELSE PRINT "Failed to open the file '":model.path:"'." PRINT "This file must exist and be 'readable' to complete the Makefile generation." PRINT "If the file does not exist, it may be necessary to re-install it." @SYSTEM.SET = -1 STOP END OPENSEQ output.path TO gcimake THEN WEOFSEQ gcimake END ELSE WRITESEQ '' ON gcimake ELSE GOTO writeseq.error END RETURN ******************************************************************************* * * set.symbol.values: set up the values to be substituted for each symbol. * * Arguments: * def.file.name (Input) Name of GCI Definition file being processed * sccsid (Input) Base name of GCI library * symbol.value (Output) Array giving the value to be substituted * for each symbol. * * Description: * The only complicated part is setting up the list of moduldes used * in the GCI definition file. * ******************************************************************************* set.symbol.values: symbol.value(sym.gcilib) = "" symbol.value(sym.gcifile) = def.file.name symbol.value(sym.gcidll) = sccsid xcmd = "SELECT " : def.file.name : " SAVING UNIQUE S.MODULE" EXECUTE xcmd CAPTURING xout IF @SELECTED < 0 THEN PRINT "Error selecting records from " : def.file.name : " file." PRINT xcmd PRINT xout PRINT failure.message @SYSTEM.SET = -1 STOP END end.of.modules = 0 LOOP READNEXT mod.name ELSE end.of.modules = 1 UNTIL end.of.modules DO IF mod.name # "" AND mod.name # "Win32" THEN symbol.value(sym.gcilib)<-1> = mod.name : ".lib" END REPEAT RETURN ******************************************************************************* * * check.line.for.symbols: examine the current line for a substitution symbol. * * Arguments: * line (Input) Line read from the template file * line.type (Output) Either 0, if the line does not start with one of * the substitution symbols, or an index into the symbol.xxx * arrays. * * Description: * ******************************************************************************* check.line.for.symbols: line2 = trimf(CONVERT(CHAR(9), " ", line)) tok = field(line2, " ", 1) line.type = 0 FOR symbol.no = 1 TO num.symbols IF tok = symbol.name(symbol.no) THEN line.type = symbol.no END NEXT RETURN ******************************************************************************* * * output.symbol: write out the definition line for one symbol. * * Arguments: * line.type (Input) Index of the symbol to be output * symbol.name (Input) Array giving the symbol itself * symbol.value (Input) Array giving the value to be substituted * for each symbol. * symbol.found (Output) Array indicating symbols found so far. * * Description: * ******************************************************************************* output.symbol: line = symbol.name(line.type) : " = " line.count = DCOUNT(symbol.value(line.type), @FM) FOR line.no = 1 TO line.count line := symbol.value(line.type) IF line.no < line.count THEN line := " \" WRITESEQ line ON gcimake ELSE GOTO writeseq.error line = SPACE(9) NEXT symbol.found(line.type) = 1 return ******************************************************************************* * * writeseq.error: abort the program if we can't write output for any reason. * * Arguments: none * * Description: * ******************************************************************************* writeseq.error: * unable to write to the new makefile PRINT "Unable to write to ":output.path:"." PRINT "This file and directory must be writable to complete the Makefile generation." PRINT failure.message @SYSTEM.SET = -1 STOP END