-$! Set the def dir to proper place for use in batch. Works for interactive too.
-$flnm = f$enviroment("PROCEDURE") ! get current procedure name
-$set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
+$v='f$verify(0) !make-cccp.com
$!
-$! Build the GNU "C" pre-processor on VMS
+$! Build the GNU C preprocessor on VMS.
$!
-$! Note: to build with DEC's VAX C compiler, uncomment the 2nd CC, CFLAGS,
-$! and LIBS alternatives, and also execute the following command:
-$! DEFINE SYS SYS$LIBRARY:
-$
-$!
-$! C compiler
-$!
-$ CC := gcc
-$! CC := cc !uncomment for VAXC
-$ BISON := bison
-$ RENAME := rename
-$ LINK := link
+$! Usage:
+$! $ @make-cccp.com [compiler] [link-only]
$!
-$! Compiler options
+$! where [compiler] is one of "GNUC", "VAXC", "DECC";
+$! default when none specified is "GNUC",
+$! and where [link-only] is "LINK" or omitted.
+$! If both options are specified, the compiler must come first.
$!
-$ CFLAGS = "/debug/incl=([],[.config.])"
-$! CFLAGS = "/noopt/incl=([],[.config])" !uncomment for VAXC
+$ if f$type(gcc_debug).eqs."INTEGER" then if gcc_debug.and.1 then set verify
+$
+$ p1 = f$edit(p1,"UPCASE,TRIM")
+$ if p1.eqs."" then p1 = "GNUC"
$!
-$! Link options
+$! Compiler-specific setup (assume GNU C, then override as necessary):
$!
-$ LDFLAGS := /nomap
+$ CC = "gcc"
+$ CFLAGS = "/Debug/noVerbos"
+$ LIBS = "gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr"
+$ if p1.nes."GNUC"
+$ then
+$ CC = "cc"
+$ CFLAGS = "/noOpt" !disable optimizer when bootstrapping with native cc
+$ if p1.eqs."VAXC"
+$ then
+$ if f$trnlnm("DECC$CC_DEFAULT").nes."" then CC = "cc/VAXC"
+$ LIBS = "alloca.obj,sys$library:vaxcrtl.olb/Libr"
+$ define/noLog SYS SYS$LIBRARY:
+$ else
+$ if p1.eqs."DECC"
+$ then
+$ if f$trnlnm("DECC$CC_DEFAULT").nes."" then CC = "cc/DECC"
+$ LIBS = "alloca.obj" !DECC$SHR will be found implicitly by linker
+$ define/noLog SYS DECC$LIBRARY_INCLUDE:
+$ else
+$ if p1.nes."LINK"
+$ then
+$ type sys$input: /Output=sys$error:
+$DECK
+[compiler] argument should be one of "GNUC", "VAXC", or "DECC".
+
+Usage:
+$ @make-cccp.com [compiler] [link-only]
+
+$EOD
+$ exit %x1000002C + 0*f$verify(v) !%SYSTEM-F-ABORT
+$ endif !!LINK
+$ endif !DECC
+$ endif !VAXC
+$ endif !!GNUC
+$
$!
-$! Link libraries
+$! Other setup:
$!
-$ LIBS := gnu_cc:[000000]gcclib.olb/libr,sys$library:vaxcrtl.olb/libr
-$! LIBS := alloca.obj,sys$library:vaxcrtl.olb/libr !uncomment for VAXC
+$ LDFLAGS = "/noMap"
+$ PARSER = "bison"
+$ RENAME = "rename/New_Version"
+$ LINK = "link"
+$ echo = "write sys$output"
$
-$ if "''p1'" .eqs. "LINK" then goto Link
-$ 'CC 'CFLAGS cccp.c
-$ t1:='f$search("CEXP.C")'
-$ if "''t1'" .eqs. "" then goto 10$
-$ t1:='f$file_attributes("CEXP.Y","RDT")'
-$ t1:='f$cvtime(t1)'
-$ t2:='f$file_attributes("CEXP.C","RDT")'
-$ t2:='f$cvtime(t2)'
-$ if t1 .les. t2 then goto 20$
-$ 10$:
-$ bison cexp.y
-$ rename cexp_tab.c cexp.c
-$ 20$:
-$!
-$ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).lt.f$length(LIBS) then -
- 'CC 'CFLAGS /define="STACK_DIRECTION=(-1)" alloca.c
+$!!!!!!!
+$! Nothing beyond this point should need any local configuration changes.
+$!!!!!!!
+$
+$! Set the default directory to the same place as this command procedure.
+$ flnm = f$enviroment("PROCEDURE") !get current procedure name
+$ set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")'
+$
+$ if p1.eqs."LINK" .or. p2.eqs."LINK" then goto Link
+$ echo " Building the preprocessor."
+$
+$! Compile the simplest file first, to catch problem with compiler setup early.
+$ set verify
+$ 'CC''CFLAGS' version.c
+$!'f$verify(0)
+$
+$ set verify
+$ 'CC''CFLAGS' cccp.c
+$!'f$verify(0)
+$
+$! Compile preprocessor's parser, possibly making it with yacc first.
+$ if f$search("CEXP.C").nes."" then -
+ if f$cvtime(f$file_attributes("CEXP.C","RDT")).ges.-
+ f$cvtime(f$file_attributes("CEXP.Y","RDT")) then goto skip_yacc
+$ set verify
+$ 'PARSER' cexp.y
+$ 'RENAME' cexp_tab.c cexp.c
+$!'f$verify(0)
+$skip_yacc:
+$ echo " (Ignore any warning about not finding file ""bison.simple"".)"
+$ set verify
+$ 'CC''CFLAGS' cexp.c
+$!'f$verify(0)
+$
+$! In case there's no builtin alloca support, use the C simulation.
+$ if f$locate("alloca.obj",f$edit(LIBS,"lowercase")).lt.f$length(LIBS)
+$ then
+$ set verify
+$ 'CC''CFLAGS'/Incl=[]/Defi=("HAVE_CONFIG_H","STACK_DIRECTION=(-1)") alloca.c
+$!'f$verify(0)
+$ endif
$!
-$ 'CC 'CFLAGS cexp.c
-$ 'CC 'CFLAGS version.c
-$ Link:
-$ link 'LDFLAGS /exe=gcc-cpp cccp,cexp,version,version.opt/opt,'LIBS'
+$
+$Link:
+$ echo " Linking the preprocessor."
+$ set verify
+$ 'LINK''LDFLAGS'/Exe=gcc-cpp.exe -
+ cccp.obj,cexp.obj,version.obj,version.opt/Opt,-
+ 'LIBS'
+$!'f$verify(0)
$!
$! Done
$!
-$ exit
+$ exit 1+0*f$verify(v)