$!=======================================================================================
$! title    : mysql_demo.com (build script for my "mysql" demo programs)
$! author   : Neil Rieck ( http://neilrieck.net MAILTO:n.rieck@sympatico.ca )
$!	    : Waterloo, Ontario, Canada.
$! platform : OpenVMS 8.4 for Itanium or Alpha
$! notes    : 1) MariaDB is an alternate fork of MySQL
$!	      2) your OpenVMS system will have one of three TCPIP stacks: MultiNet,
$!		 TCPIP Services, and TCPware which place different include files in
$!		 sys$library. The cleanest compile comes from MultiNet
$!	      3) Mark's object libraries require that you link against ssl and crypto
$!		 with mixed-case names (libraries from HP/HPE have upcased names)
$!	      4) always reference zlib (or libz) before the ssl and crypto libraries
$!	      5) my c-only demo programs are numbered 01-09
$!	      6) my BASIC-c hybrids      are numbered 11-19
$!	      7) see 'mysql_demo_alt.com' for alternate ways to link to libraries
$! when     who what
$! 20140120 NSR a build script for my MariaDB-5.5-25 demo programs (Alpha only)
$! 20170419 NSR added additional support for Itanium
$! 20171031 NSR added support for MariaDB-5.5-57 and MariaDB-5.5-58
$! 20171123 NSR this script can now build all my demos
$! 20180412 NSR this script is now much smaller
$! 20180425 NSR cleanup (moved see 'mysql_demo_alt.com' for alternate ways to link to libraries)
$!================================================================================================
$	say	:== write sys$output						!
$	ask	:== inquire/nopunct						!
$	on error then goto fini							!
$	set on									!
$	say	"=========================================================="
$	say	"-i-script:",f$environment("procedure")
$	say	"   (a build script for MySQL/MariaDB client demos on OpenVMS)"
$	if P1 .eqs. ""
$	then
$		say "-w-oops, no version number was detected"
$		say "-i-usage: @mysql_demo xx (where xx = version)"
$		say "-i-generating a directory listing""
$		say "=========================================================="
$		dir/col=1/width=file=52/nohead/notrail/date mysql_demo*.c;,mysql_demo*.bas;
$		savedstatus = $STATUS
$		if ((f$integer(savedstatus).and.7).ne.1)
$		then
$			say "-w-oops, none found"
$			exit
$		endif
$		say ""
$		ask junk "build which project number? (eg. 01) "
$		if (junk .eqs. "") then goto fini
$		p1 = junk
$	endif
$	if f$length(p1).eq.1 then p1 = "0"+p1					!
$	if (p1 .ges. "01") .and. (p1 .les. "09")				!
$	then									!
$		hybrid = 0							! not a hybrid
$		pgm_c = "mysql_demo"+p1						! c-program
$		app   = "mysql_demo"+p1						!
$		goto got_name							!
$	endif									!
$	if (p1 .ge. "10") .and. (p1 .le. "19")					!
$	then									!
$		hybrid = 1							! hybrid program
$		pgm_b = "mysql_demo"+p1						! BASIC program
$		app   = "mysql_demo"+p1						!
$		pgm_c = "mysql_api_demo"+p1					! c-based API
$		goto got_name							!
$	endif									!
$	say "-e-processing cannot continue with p1 = (",p1,")"			!
$	exit									!
$!
$got_name:
$	arch	= f$getsyi("ARCH_NAME")			!
$	path	= f$trnlnm("mysql055_root")		! eg. KAWC90$DKB1:[MYSQL055.]
$	path	= path - "]"				!
$	path	= path + "lib."'arch'"]"		! eg. KAWC09$DKB1:[MYSQL055.lib.ia64]
$!
$	if (hybrid.eq.1)
$	then
$		say "-i-BASIC compiling: ",pgm_b,".bas"
$		wait 0:0:01
$		basic	'pgm_b'.bas
$		wait 0:0:01
$	endif
$	say "-i-C compiling: ",pgm_c,".c"
$	wait 0:0:01
$	cc	'pgm_c'.c				-
		/pointer=32				-
		/float=ieee				-
		/ieee=denorm				-
		/name=(as_is,shorten)			-
		/prefix_library_entries=all_entries	-
		/include=mysql055_root:[include.mysql]
$	set noon
$!===============================================================
$!	now generate a build script to cobble everything together
$!===============================================================
$	build_script = app +".bld_scratch"
$	if f$search(build_script.nes."") then	delete/nolog 'build_script';*
$	open/write  my_bld  'build_script'
$	write my_bld	"$link -"
$	if (hybrid.eq.1)
$	then
$		write my_bld    pgm_b,	".obj, ",	pgm_c,".obj	-"
$	else
$		write my_bld	pgm_c,".obj	-"
$	endif
$	write my_bld	" /MAP		-"
$	write my_bld	" /NOinformationals	-"
$	write my_bld	" , sys$input/opt"
$	write my_bld	" ",path,"libclientlib.olb/library"
$!~	write my_bld	" ",path,"libdbug.olb/library"		! debug
$	write my_bld	" ",path,"libmysys.olb/library"
$!~	write my_bld	" ",path,"libsql.olb/library"		! not required
$	write my_bld	" ",path,"libstrings.olb/library"
$	write my_bld	" ",path,"libvio.olb/library"
$	write my_bld	" ",path,"libz.olb/library"
$	write my_bld	" ",path,"ssl_libssl32.olb/library"
$	write my_bld	" ",path,"ssl_libcrypto32.olb/library"
$finish_build:
$	close my_bld
$	say "-i-linking"
$	@'build_script'
$	savedstatus = $status
$	say "-i-linking summary:"
$	say "-i-exit status: ",savedstatus
$	if ((savedstatus .and. 1).eq.0) then say "-i-there were LINKER warnings"
$	if ((savedstatus .and. 2).eq.2) then say "-i-there were LINKER errors"
$	if ((savedstatus .and. 4).eq.4) then say "-i-there were LINKER fatals"
$	if ((savedstatus .and. 6).eq.0)
$	then
$		say "-i-there were NO LINKER errors"
$		say "-i-you can ignore LINKER warnings pertaining to SSL (if you are not using SSL)"
$		say "-i-look what I just built:"
$		say "==============================================================="
$		dir/col=1/date/width=file=50/nohead/notrail/since="-0 0:0:10" 'app'*.exe;/siz
$		say "==============================================================="
$	endif
$fini:
$	set noon
$	say "-i-exiting script"
$	exit