1/* configure_os2.cmd -- Christian Bartels, 1996
2
3   A REXX script to create an OS/2 specific makefile for FTNCHEK using
4   the file 'Makefile.in' as input.
5
6   This script is based on ideas of:
7     Jan Ftacnik, 1993
8     Stefan A. Deutscher, 1996 (sad@utk.edu)
9
10   The building of the makefile is a five phase process:
11   1) Parsing the command line arguments
12   2) Checking of the system configuration
13   3) Building of the actual substitutes for some variables
14   4) Processing of Makefile.in
15   5) Processing of config-generic.h to write config.h
16
17   Extended by Stefan A. Deutscher to also generate stuff in test/
18   directory automagically.  10/1996 until 05/2003
19
20   6) Processing of test/Makefile.in
21   7) Processing of test/Compare.sh.in
22
23   Updated by R. Moniot for changes in 2.11.  (Not tested.) 10/99
24   Updated by Stefan A. Deutscher for changes in 3.0.0, tested. 11/2000
25   Updated by Stefan A. Deutscher for changes in 3.1.0, tested. 06/2001
26   Updated by Stefan A. Deutscher for changes in 3.2.2, tested. 05/2003
27*/
28
29/* load library REXXUTIL */
30  call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
31  call SysLoadFuncs
32
33
34/* get the command line arguments */
35  parse arg argv
36  argc = words(argv)
37
38/* set some constants */
39  InputFile   = 'Makefile.in'
40  TmpFile     = SysTempFileName('Makefile.???')
41  OutputFile  = 'Makefile'
42
43  ConfigGenericFile = 'config-generic.h'
44  ConfigOS2File     = 'config-os2.h'
45
46  TestDir         = 'test'
47  TestInputFile   = 'Makefile.in'
48  TestOutputFile  = 'Makefile'
49
50  CompInputFile   = 'Compare.sh.in'
51  CompOutputFile  = 'Compare.sh'
52
53  ObjectStyle = 'aout'
54  Linking     = 'dynamic'
55  PrefixDir   = 'c:\usr\local'
56
57  UseRegex = 'no'
58  RegexDef = '0'
59
60
61/*******************************************/
62/*     parse command line arguments        */
63/*******************************************/
64
65  i = 1
66  do while (i <= argc)
67     argum = word(argv,i)
68     i = i + 1
69
70/*   check whether program options start correctly with '-'  */
71     c = substr(argum,1,1)
72     if (c \= '-') then
73        call Usage
74
75/*   select the appropriate action for commandline options */
76     c = substr(argum,2,1)
77     select
78        when (c = 'f') then do
79           ObjectStyle = ToLower( word(argv,i) )
80           if (ObjectStyle \= 'omf') & (ObjectStyle \= 'aout') then do
81              say " Error: Only supported object formats are omf and aout."
82              say
83              exit 1
84           end
85           i = i + 1
86        end
87        when (c = 'h') then do
88           call Usage
89        end
90        when (c = 'l') then do
91           Linking = ToLower( word(argv,i) )
92           if (Linking \= 'static') & (Linking \= 'dynamic') then do
93              say " Error: Only static or dynamic linking is supported."
94              say
95              exit 1
96           end
97           i = i + 1
98        end
99        when (c = 'o') then do
100           OutputFile = word(argv,i)
101           i = i + 1
102        end
103        when (c = 'p') then do
104           PrefixDir = word(argv,i)
105           i = i + 1
106        end
107        when (c = 'r') then do
108           UseRegex = 'yes'
109           i = i + 1
110	end
111        otherwise do
112           say ' Error: Argument -'c' is unknown.'
113           say
114           call Usage
115        end
116     end
117  end
118
119
120/*******************************************/
121/*     check the system configuration      */
122/*******************************************/
123
124  say ' Checking system configuration ....'
125
126/* Check if sed is installed */
127  SedProg     = IsProgramInPath( 'sed.exe' )
128  if (SedProg = '') then do
129     say " Error: In order to run this procedure, 'sed.exe' has",
130         "to be installed."
131     say
132     exit 1
133  end
134
135/* Check if make is installed */
136  MakeProg     = IsProgramInPath( 'make.exe' )
137  if (MakeProg = '') then do
138     say " Error: In order to build this code, 'make.exe' has",
139         "to be installed."
140     say " Your best option is to get and install a port of",
141         " GNU make."
142     say
143     exit 1
144  end
145
146/* Man  is not too critical: used only in install */
147  ManProg     = IsProgramInPath( 'man.exe' )
148
149/* Grep is not too critical: used only in make precheck */
150  GrepProg     = IsProgramInPath( 'grep.exe' )
151
152/* Check if pwd is installed: */
153  PwdProg     = IsProgramInPath( 'pwd.exe' )
154
155/* Zip is not too critical: used only to make distribution zipfile for
156   MS-DOS/Windows/OS2 */
157  ZipProg     = IsProgramInPath( 'zip.exe' )
158
159/* Check if printenv is installed */
160  PrintenvProg   = IsProgramInPath( 'printenv.exe' )
161
162/* Check if emx+gcc is installed */
163  CCompiler   = IsProgramInPath( 'gcc.exe' )
164  if (CCompiler = '') then do
165     say ' Error: To build FTNCHEK you will have to install the',
166         'EMX program'
167     say '        development package including the GNU C compiler.'
168  end
169
170/* Check which port of a new awk is installed */
171  AwkProg     = SearchProgramFromList( "gawk.exe mawk.exe" )
172
173/* No port of strip to OS/2 allows stripping of debug information or
174   local symbols from an executable (neither EMX-bound nor LX). Therefore
175   under OS/2 the stripping is done while producing the object files and
176   during the link stage. Fill in a dummy for strip  */
177  StripProg   = 'echo Requested: strip'
178
179/* Check which yacc is installed */
180  YaccProg    = SearchProgramFromList( "bison.exe yacc.exe")
181  if ( YaccProg = 'yacc.exe' ) then do
182     say ' Warning: If the installed yacc is not bison, then if fortran.c',
183         ' is remade make check will report (minor) differences.'
184     end
185  else do
186     if ( YaccProg = 'bison.exe' ) then
187        YaccProg = YaccProg '-y'
188  end
189
190/* Check if tar.exe is installed */
191  TarProg     = IsProgramInPath( 'tar.exe' )
192
193/* To my knowledge no port of col to OS/2 exists, but check anyway */
194  ColProg     = IsProgramInPath( 'col.exe' )
195
196/* Check if the groff port to OS/2 is fully installed */
197  NroffProg   = IsProgramInPath( 'groff.exe' )
198  SoelimProg  = IsProgramInPath( 'soelim.exe' )
199  EqnProg     = IsProgramInPath( 'eqn.exe' )
200  TblProg     = IsProgramInPath( 'tbl.exe' )
201
202/* Check if a unix sh-like shell is installed */
203CmdShell    = SearchProgramFromList( "sh.exe ksh.exe bash.exe cmd.exe" )
204
205/* Check which basic file utilities are installed */
206/*  --- chmod */
207  ChmodCmd    = IsProgramInPath( 'chmod.exe' )
208  if (ChmodCmd = '') then
209     ChmodCmd    = 'echo Requested: chmod'
210/*  --- cmp */
211  CmpCmd      = SearchProgramFromList( "diff.exe cmp.exe comp.com" )
212  if (CmpCmd \= 'diff.exe') then do
213     say ' Warning: 'CmpCmd' claims that files are different even if only'
214     say '          the OS/2 EOL sequence CRLF is used instead of LF.'
215  end
216/*  --- cp */
217  CpCmd       = IsProgramInPath( 'cp.exe' )
218  if (CpCmd = '') & (CmdShell = 'cmd.exe') then
219     CpCmd = 'copy'     /* use built-in command of cmd.exe */
220/*  --- diff */
221  DiffCmd     = SearchProgramFromList( "diff.exe cmp.exe comp.com" )
222  if (DiffCmd \= 'diff.exe') then do
223     say ' Warning: 'DiffCmd' claims that files are different even if only'
224     say '          the OS/2 EOL sequence CRLF is used instead of LF.'
225  end
226/*  --- mkdir */
227  MkdirCmd    = IsProgramInPath( 'mkdir.exe' )
228  if (MkdirCmd = '') & (CmdShell = 'cmd.exe') then
229     MkdirCmd = 'mkdir' /* use built-in command of cmd.exe */
230/*  --- mv */
231  MvCmd       = IsProgramInPath( 'mv.exe' )
232  if (MvCmd = '') & (CmdShell = 'cmd.exe') then do
233     MvCmd = 'move'     /* use built-in command of cmd.exe */
234     say ' Warning: The OS/2 command MOVE cannot move files across drives.'
235  end
236/*  --- rm */
237  RmCmd       = IsProgramInPath( 'rm.exe' )
238  if (RmCmd = '') & (CmdShell = 'cmd.exe') then do
239     RmCmd = 'del'      /* use built-in command of cmd.exe */
240     say ' Warning: The OS/2 command DEL cannot remove read-only files.'
241  end
242  if (RmCmd = 'rm.exe') then RmCmd = RmCmd '-f'
243/*  --- rmdir */
244  RmdirCmd    = IsProgramInPath( 'rmdir.exe' )
245  if (RmdirCmd = '') & (CmdShell = 'cmd.exe') then
246     RmdirCmd = 'rmdir' /* use built-in command of cmd.exe */
247
248
249/*  --- sh */
250  ShPath = Translate(SysSearchPath('PATH', 'sh.exe'), '/', '\')
251  if (ShPath = '') then do
252     say ' Warning: sh.exe was not found. make check will not work.'
253     say '          Setting path to UNIX default: /bin/sh'
254     ShPath = '/bin/sh'
255  end
256
257/* Check if omf type libraries are installed */
258  if ObjectStyle = 'omf' then do
259     CLibraryPath = value( 'library_path',, 'OS2ENVIRONMENT' )
260     CLibraryPath = translate( CLibraryPath, ' \', ';/' )
261     emx2lib = ''
262     gcclib  = ''
263     do i = 1 to words( CLibraryPath )
264        CurSearchDir = word( CLibraryPath, i )
265        if ( right( CurSearchDir, 1) \= '\' ) then
266           CurSearchDir = CurSearchDir'\'
267        test = stream( CurSearchDir'emx2.lib', 'C', 'QUERY EXIST' )
268        if ( test \= '' ) then
269           emx2lib = test
270        test = stream( CurSearchDir'gcc.lib', 'C', 'QUERY EXIST' )
271        if ( test \= '' ) then
272           gcclib = test
273     end
274     if (emx2lib = '') | (gcclib = '') then do
275        say ' Warning: The libraries necessary for linking with object',
276            'files in'
277        say '          OMF format do not exist. Object format reset to AOUT.'
278        ObjectStyle = 'aout'
279     end
280  end
281
282
283/****************************************************/
284/*     build the substitutes for some strings       */
285/****************************************************/
286
287/* Cflags */
288  Cflags  = '-DUNIX -O2 -m486'
289
290/* PrefixDir */
291  if CmdShell = 'cmd.exe' then do
292     PrefixDir = translate( PrefixDir, '\', '/')
293     if ( right( PrefixDir, 1 ) = '\' ) then
294        PrefixDir = left( PrefixDir, length(PrefixDir)-1 )
295     j = LastPos('\', PrefixDir)
296     do while (j \= 0)
297        j = j - 1
298        PrefixDir = insert('\\\', PrefixDir , j)
299        j = LastPos('\', SubStr( PrefixDir, 1, j ))
300     end
301     end
302  else do
303     PrefixDir = translate( PrefixDir, '/', '\')
304     if ( right( PrefixDir, 1 ) = '/' ) then
305        PrefixDir = left( PrefixDir, length(PrefixDir)- 1 )
306     j = LastPos('/', PrefixDir)
307     do while (j \= 0)
308        j = j - 1
309        PrefixDir = insert('\', PrefixDir , j)
310        j = LastPos('/', SubStr( PrefixDir, 1, j ))
311     end
312  end
313
314/* Ldflags */
315  if ObjectStyle = 'omf' then do
316     if Linking = 'dynamic' then
317        Ldflags = '-s -Zomf -Zcrtdll -Zstack 8192 -Zlinker \/pm:vio'
318     else
319        Ldflags = '-s -Zomf -Zsys -Zstack 8192 -Zlinker \/pm:vio'
320     end
321  else do
322     if Linking = 'dynamic' then do
323        Ldflags = '-s'
324        if UseRegex = 'yes' then do
325          Ldflags = '-s'
326          Ldlibs = '-lregex'
327          RegexDef = '1'
328	end
329        else
330          Ldlibs = ''
331	end
332     else
333        say ' Error: Static linking is not possible for ',
334            'aout object file format.'
335  end
336
337/* ObjectsListName, ObjectsToDelete */
338  if ObjectStyle = 'omf' then do
339     ObjectsListName = '$(OBJS:.o=.obj)'
340     ObjectsToDelete = '*.o *.obj'
341     end
342  else do
343     ObjectsListName = '$(OBJS)'
344     ObjectsToDelete = '*.o'
345  end
346
347
348  say ' Generating Makefiles : '
349
350/****************************************/
351/*     process Makefile.in              */
352/****************************************/
353
354  say '  Processing Makefile.in ...'
355
356  '@echo off'
357  'sed -e "s/\/usr\/local/'PrefixDir'/" ',
358      '-e "s/@EXE@/.exe/" ',
359      '-e "s/@CMD@/.cmd/" ',
360      '-e "s/@CC@/'CCompiler'/" ',
361      '-e "s/@MANtoPS@//" ',
362      '-e "s/@AWK@/'AwkProg'/" ',
363      '-e "s/@NROFF@/'NroffProg'/" ',
364      '-e "s/@SED@/'SedProg'/" ',
365      '-e "s/@STRIP@/'StripProg'/" ',
366      '-e "s/@YACC@/'YaccProg'/" ',
367      '-e "s/@COL@/'ColProg'/" ',
368      '-e "s/@CHMOD@/'ChmodCmd'/" ',
369      '-e "s/@CMP@/'CmpCmd'/" ',
370      '-e "s/@CP@/'CpCmd'/" ',
371      '-e "s/@DIFF@/'DiffCmd'/" ',
372      '-e "s/@EQN@/'EqnProg'/" ',
373      '-e "s/@GREP@/'GrepProg'/" ',
374      '-e "s/@PWD_PROG@/'PwdProg'/" ',
375      '-e "s/@ZIP@/'ZipProg'/" ',
376      '-e "s/@PRINTENV@/'PrintenvProg'/" ',
377      '-e "s/@MKDIR@/'MkdirCmd'/" ',
378      '-e "s/@MV@/'MvCmd'/" ',
379      '-e "s/@RM@/'RmCmd'/" ',
380      '-e "s/@RMDIR@/'RmdirCmd'/" ',
381      '-e "s/@SH@/'CmdShell'/" ',
382      '-e "s/@SOELIM@/'SoelimProg'/" ',
383      '-e "s/@TBL@/'TblProg'/" ',
384      '-e "s/@TAR@/'TarProg'/" ',
385      '-e "s/@CFLAGS@/'Cflags'/" ',
386      '-e "s/@LDFLAGS@/'Ldflags'/" ',
387      '-e "s/@LDLIBS@/'Ldlibs'/" ',
388      '-e "s/@INSTALL_MAN@//" ',
389      '-e "s/@FTNPP@//" ',
390      '-e "s/@CPPFLAGS@//" ',
391      '<'InputFile ' >'TmpFile
392
393  'sed -e "s/$(OBJS)/'ObjectsListName'/" ',
394      '-e "s/(RM) \*\.o/(RM) 'ObjectsToDelete'/" ',
395      '<'TmpFile ' >'OutputFile
396
397  if ObjectStyle = 'omf' then do
398     call lineout OutputFile, ""
399     call lineout OutputFile, "# Target to convert object files from",
400                              "a.out format to OMF format"
401     call lineout OutputFile, "%.obj: %.o"
402     call lineout OutputFile,"	emxomf -s $?"
403     call lineout OutputFile
404  end
405
406  if CmdShell = 'cmd.exe' then do
407     'copy 'OutputFile TmpFile '>nul:'
408     'sed -e "s/X)\/bin/X)\\bin/" ',
409         '-e "s/X)\/man/X)\\man/" ',
410         '-e "s/X)\/lib\/ftnchek/X)\\\\lib\\\\ftnchek/" ',
411         '-e "s/DIR)\//DIR)\\/" ',
412         '-e "s/cat1\//cat1\\/" ',
413         '-e "s/man1\//man1\\/" ',
414         '-e "s/= \.\//= \.\\/" ',
415         '-e "s/^fortran.c:/fortran.c.unx:/" ',
416         ' <'TmpFile ' > ' OutputFile
417
418     call lineout OutputFile, ''
419     call lineout OutputFile, '# Build dcl2inc.cmd using the local',
420                              'values for NAWK and LIBDIR.'
421     call lineout OutputFile, 'dcl2inc.cmd: dcl2inc.in' OutputFile
422     call lineout OutputFile, '	sed -e "s%#!/bin/sh%@echo off%"  \'
423     call lineout OutputFile, '	    -e "s%#%rem %"               \'
424     call lineout OutputFile, '	     dcl2inc.in > dcl2inc.cmd'
425     call lineout OutputFile, '	echo $(NAWK) -f $(LIBDIR)\\dcl2inc.awk',
426                              '%1 >> dcl2inc.cmd'
427     call lineout OutputFile, ''
428     call lineout OutputFile, '# N.B. tokdefs.h is copy of y.tab.h used',
429                              'to avoid remaking stuff when'
430     call lineout OutputFile, '# grammar changes but not tokens.'
431     call lineout OutputFile, '# The following copies y.tab.h to',
432                              'tokdefs.h if changed, then aborts make,'
433     call lineout OutputFile, '# since dependencies may have changed.'
434     call lineout OutputFile, 'fortran.c: fortran.y'
435     call lineout OutputFile, '	$(YACC) $(YFLAGS) fortran.y'
436     call lineout OutputFile, '	$(MV) y.tab.c fortran.c'
437     call lineout OutputFile, '	$(CMP) y.tab.h tokdefs.h ||  \'
438     call lineout OutputFile, '	(echo tokdefs.h changed -- repeat make  &  \'
439     call lineout OutputFile, '		$(CP) y.tab.h tokdefs.h)'
440     call lineout OutputFile
441  end
442  'del ' TmpFile
443  say '  Makefile written.'
444
445/****************************************/
446/*     process config-generic.h         */
447/****************************************/
448
449/*
450 emx09d on OS/2 has unistd.h, stdlib.h.
451 regex.h. is available from GNU libregex-0_12 port, which must be
452 installed. To do so, one needs to fetch both
453 http://ftp-os2.nmsu.edu/pub/os2/dev/unix/libregex-0_12-bin.zip
454 http://ftp-os2.nmsu.edu/pub/os2/dev/unix/libregex-0_12.zip
455 as bin contains the actual library but the header file is in the
456 source archive
457 emx09d also has both memset and bzero, and stricmp instead of
458	 strcasecmp
459*/
460
461  say '  Processing ' ConfigGenericFile ' ...'
462
463  '@echo off'
464  'sed -e "s/#define HAVE_UNISTD_H.*0$/#define HAVE_UNISTD_H 1/" ',
465      '-e "s/#define HAVE_STRCASECMP.*1/#define HAVE_STRCASECMP 0/" ',
466      '-e "s/#define HAVE_STRICMP.*0/#define HAVE_STRICMP 1/" ',
467      '-e "s/#define HAVE_REGEX_H.*[01]/#define HAVE_REGEX_H 'RegexDef'/" ',
468      ConfigGenericFile ' > ' ConfigOS2File
469  say '  ' ConfigOS2File ' written.'
470
471/** weiter hier ***/
472
473/****************************************/
474/*     process files in test directory: */
475/****************************************/
476
477  'cd 'TestDir
478
479/****************************************/
480/*     process test/Makefile.in         */
481/****************************************/
482
483  say '  Processing test/Makefile.in ...'
484
485  '@echo off'
486  'sed -e "s/\/usr\/local/'PrefixDir'/" ',
487      '-e "s/@EXE@/.exe/" ',
488      '-e "s/@CMD@/.cmd/" ',
489      '-e "s/@CC@/'CCompiler'/" ',
490      '-e "s/@MAKE@/'MakeProg'/" ',
491      '-e "s/@AWK@/'AwkProg'/" ',
492      '-e "s/@NROFF@/'NroffProg'/" ',
493      '-e "s/@SED@/'SedProg'/" ',
494      '-e "s/@STRIP@/'StripProg'/" ',
495      '-e "s/@YACC@/'YaccProg'/" ',
496      '-e "s/@COL@/'ColProg'/" ',
497      '-e "s/@CHMOD@/'ChmodCmd'/" ',
498      '-e "s/@CMP@/'CmpCmd'/" ',
499      '-e "s/@CP@/'CpCmd'/" ',
500      '-e "s/@DIFF@/'DiffCmd'/" ',
501      '-e "s/@EQN@/'EqnProg'/" ',
502      '-e "s/@GREP@/'GrepProg'/" ',
503      '-e "s/@PWD_PROG@/'PwdProg'/" ',
504      '-e "s/@ZIP@/'ZipProg'/" ',
505      '-e "s/@PRINTENV@/'PrintenvProg'/" ',
506      '-e "s/@MKDIR@/'MkdirCmd'/" ',
507      '-e "s/@MV@/'MvCmd'/" ',
508      '-e "s/@RM@/'RmCmd'/" ',
509      '-e "s/@RMDIR@/'RmdirCmd'/" ',
510      '-e "s/@SH@/'CmdShell'/" ',
511      '-e "s/@SOELIM@/'SoelimProg'/" ',
512      '-e "s/@TBL@/'TblProg'/" ',
513      '-e "s/@TAR@/'TarProg'/" ',
514      '-e "s/@CFLAGS@/'Cflags'/" ',
515      '-e "s/@LDFLAGS@/'Ldflags'/" ',
516      '-e "s/@CPPFLAGS@//" ',
517      '<'TestInputFile ' >'TestOutputFile
518
519  say '  test/Makefile written.'
520
521/****************************************/
522/*     process test/Compare.sh.in          */
523/****************************************/
524
525  say '  Processing test/Compare.sh.in ...'
526
527  '@echo off'
528  'sed -e "s/\/usr\/local/'PrefixDir'/" ',
529      '-e "s/@EXE@/.exe/" ',
530      '-e "s/@CMD@/.cmd/" ',
531      '-e "s/@CC@/'CCompiler'/" ',
532      '-e "s/@MANtoPS@//" ',
533      '-e "s/@AWK@/'AwkProg'/" ',
534      '-e "s/@NROFF@/'NroffProg'/" ',
535      '-e "s/@SED@/'SedProg'/" ',
536      '-e "s/@STRIP@/'StripProg'/" ',
537      '-e "s/@YACC@/'YaccProg'/" ',
538      '-e "s/@COL@/'ColProg'/" ',
539      '-e "s/@CHMOD@/'ChmodCmd'/" ',
540      '-e "s/@CMP@/'CmpCmd'/" ',
541      '-e "s/@CP@/'CpCmd'/" ',
542      '-e "s/@DIFF@/'DiffCmd'/" ',
543      '-e "s/@EQN@/'EqnProg'/" ',
544      '-e "s/@GREP@/'GrepProg'/" ',
545      '-e "s/@PWD_PROG@/'PwdProg'/" ',
546      '-e "s/@ZIP@/'ZipProg'/" ',
547      '-e "s/@MKDIR@/'MkdirCmd'/" ',
548      '-e "s/@MV@/'MvCmd'/" ',
549      '-e "s/@RM@/'RmCmd'/" ',
550      '-e "s/@RMDIR@/'RmdirCmd'/" ',
551      '-e "s/@SH@/'CmdShell'/" ',
552      '-e "s/@SOELIM@/'SoelimProg'/" ',
553      '-e "s/@TBL@/'TblProg'/" ',
554      '-e "s/@TAR@/'TarProg'/" ',
555      '-e "s/@CFLAGS@/'Cflags'/" ',
556      '-e "s/@LDFLAGS@/'Ldflags'/" ',
557      '-e "s;/bin/sh;'ShPath';" ',
558      '<'CompInputFile ' >'CompOutputFile
559
560  say '  test/Compare.sh written. '
561
562/* -------------------------------------------------------------- */
563/* Note: This can be done by REXX:                                */
564/* -------------------------------------------------------------- */
565
566  if (ShPath = '/bin/sh') then do
567    say '  Note: Edit first line by hand to point to sh.exe!'
568  end
569
570  'cd ..'
571
572  say ' Done. Now copy ' ConfigOS2File ' onto config.h and run make'
573  say ' '
574  say '   copy ' ConfigOS2File ' config.h'
575  say '   make        to make ftnchek.exe and the manual page ftnchek.1'
576  say '   make check  to run the tests (that takes time)'
577  say
578  say ' In case you have the GNU regex library (*.h, *.a) installed, you'
579  say ' may wish to enable also the -makehtml option of ftnchek. To do so,'
580  say ' rerun configure_os2.cmd -r before the above four steps.'
581  say ' To save about 80kB, you can compress the executable with LxLite,'
582  say ' if you have it installed:'
583  say '               lxlite ftnchek.exe'
584
585  exit 0
586
587/* PROCEDURE Usage */
588  Usage: PROCEDURE
589     say ' Usage: configure_os2 [options]'
590     say
591     say '    Options:'
592     say '       -f <string>  format of object files: omf, aout'
593     say '       -l <string>  linking: static, dynamic'
594     say '       -o <string>  name of newly created Makefile'
595     say '       -p <string>  prefix directory'
596     say '       -r           build using GNU regex library'
597     say '       -h           show this help'
598     exit 1
599
600/* PROCEDURE ToLower */
601  ToLower: PROCEDURE
602     parse arg OldString
603
604     NewString = translate(OldString, xrange('a','z'), xrange('A','Z'))
605     return NewString
606
607/* PROCEDURE IsProgramInPath */
608  IsProgramInPath: PROCEDURE
609     parse arg ProgramName
610
611     Answer = FileSpec('name', SysSearchPath('PATH', ProgramName))
612     return Answer
613
614/* PROCEDURE SearchProgramFromList */
615  SearchProgramFromList: PROCEDURE
616     parse arg ProgramList
617
618     NumberInList = words( ProgramList )
619
620     FirstFound = ''
621     i = 1
622     do while (i <= NumberInList) & (FirstFound = '')
623        Program = word( ProgramList, i )
624        i = i + 1
625
626        FirstFound = IsProgramInPath( Program )
627     end
628     return FirstFound
629
630