OpenVMS Source Code Demos

mysql_demo.com

$!=======================================================================================
$! title    : mysql_demo.com (a common build script for my mysql_demo programs)
$! author   : Neil Rieck
$!          : Waterloo, Ontario, Canada.
$!            http://neilrieck.net  MAILTO:n.rieck@bell.net
$! 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.
$! 3) Object libraries from Mark Berryman 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 hybrid demos 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 single script can now build all my demos
$! 20180412 NSR this script is now much smaller
$! 20180425 NSR cleanup (see 'mysql_demo_alt.com' for alternate ways to link)
$! 20240415 NSR changes for use with "LibMariaDB for VSI OpenVMS" 
$!=======================================================================================
$       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/siz 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. "00") .and. (p1 .les. "09")                                !
$       then                                                                    !
$               hybrid = 0                                                      ! not a hybrid
$               pgm_c = "mysql_demo"+p1                                         ! stand alone 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:
$       say "1) compile-link to MariaDB        from Mark Berryman"
$       say "2) compile-link to LibMariaDB v2  from VSI"
$       say "3) compile-link to LibMariaDB v3  from VSI"
$       say "4) compile-link to MariaDB-5.5-63 from VSI"
$       ask build_method "build method? (1-4, default=1) "
$       if (build_method .eqs. "" ) then build_method = "1"
$       if (build_method .nes. "1") .and.                        -
           (build_method .nes. "2") .and.                        -
           (build_method .nes. "3") .and.                        -
           (build_method .nes. "4")
$       then
$           say "-e-bad choice. Exiting"
$           exit
$       endif
$!-------------------------------------------------------------------- MariaDB from VSI
$    if build_method .eqs. "4"
$    then
$        test = f$trnlnm("mariadb$root")                              ! installed?
$        if test .eqs. ""                                             ! oops
$        then
$            say "-e-MariaDB for VSI OpenVMS is not installed"
$            say "-i-exiting script"
$            exit
$        endif
$        LIBpath = "mariadb$root:[lib]"
$        INCpath = "mariadb$root:[include.mysql]"
$    endif
$!-------------------------------------------------------------------- Libmariadb from VSI
$    if ((build_method .eqs. "2").or.(build_method .eqs. "3"))
$    then
$        test = f$trnlnm("libmariadb$root")                           ! installed?
$        if test .eqs. ""                                             ! oops
$        then
$            say "-e-LibMariaDB for VSI OpenVMS is not installed"
$            say "-i-exiting script"
$            exit
$        else
$            LIBpath = "libmariadb$root:[lib]"
$            INCpath = "libmariadb$root:[include]"
$        endif
$    endif
$!-------------------------------------------------------------------- MariaDB from Mark Berryman
$    if build_method .eqs. "1"
$    then
$        test    = f$trnlnm("mysql051_root")                          ! test location 51
$        if test .eqs. ""                                             ! oops
$        then
$            test = f$trnlnm("mysql055_root")                         ! test location 55
$        endif
$        if test .nes. ""                                             ! if found...
$        then
$            arch        = f$getsyi("ARCH_NAME")                      !
$            LIBpath        = f$trnlnm("mysql055_root")               ! eg. KAWC90$DKB1:[MYSQL055.]
$            LIBpath        = LIBpath - "]"                           !
$            LIBpath        = LIBpath + "lib."'arch'"]"               ! eg. KAWC09$DKB1:[MYSQL055.lib.ia64]
$            INCpath        = f$trnlnm("mysql055_root")               !
$            INCpath        = INCpath - "]"                           !
$            INCpath        = INCpath + "include.mysql]"              ! eg. KAWC09$DKB1:[MYSQL055.include.mysql]
$        else
$            say "-e-MariaDB from Mark Berryman is not installed"
$            say "-i-exiting script"
$            exit
$        endif
$    endif
$!-------------------------------------------------------
$    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                        -
                /nolist                             -
                /name=(as_is,shorten)               -
                /prefix_library_entries=all_entries -
                /include='INCpath'
$        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        " /noMAP                   -"
$        write my_bld        " /NOinformationals        -"
$        write my_bld        " , sys$input/opt"
$if (build_method .eqs."4")
$then
$       write my_bld    " ",LIBpath,"libclientlib.olb/lib"
        write my_bld    " ",LIBpath,"libz32.olb/lib"
        write my_bld    " ",LIBpath,"mariadb$client_shr.exe/share"
$endif
$if ((build_method .eqs."2").or.(build_method .eqs."3"))
$then
$       write my_bld    " ",LIBpath,"libmariadb.olb/lib"
        write my_bld    " ",LIBpath,"libz.olb/lib"
        write my_bld    " ",LIBpath,"libmariadb$shr.exe/share"
$endif
$if (build_method .eqs."1")
$then
$        write my_bld        " ",LIBpath,"libclientlib.olb/library"
$        write my_bld        " ",LIBpath,"libmysys.olb/library"
$   !~   write my_bld        " ",LIBpath,"libsql.olb/library"         ! not required
$        write my_bld        " ",LIBpath,"libstrings.olb/library"
$        write my_bld        " ",LIBpath,"libvio.olb/library"
$        write my_bld        " ",LIBpath,"libz.olb/library"
$        write my_bld        " ",LIBpath,"ssl_libssl32.olb/library"
$        write my_bld        " ",LIBpath,"ssl_libcrypto32.olb/library"
$endif
$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
$!=============================================================================
$! this is the last line
$!=============================================================================