OpenVMS Source Code Demos

LIB_MYSQLUDF_SYS_BUILD_VMS

$!===============================================================================================
$! title  : lib_mysqludf_build_vms.com
$! author : Neil Rieck		(n.rieck@bell.net)
$! created: 2015-10-01
$! notes  :
$! 1) lib_mysqludf_sys ( https://github.com/mysqludf/lib_mysqludf_sys ) is a "UDF" (User Designed
$!    Function) which will allow MySQL/MariaDB server to execute OS commands via UDF function
$!    'exec_sys'
$! 2) This script is a build command for OpenVMS-8.4 on Alpha or Itanium
$! 3) the initial compile will not work without the usual fiddling (about a dozen quick edits)
$!    with files located under MYSQL055_ROOT:[000000.include]
$!    CAVEAT: careful hackers will first copy all these files to a third directory where all the
$!    modifications will occur; it doesn't matter where they are located so long as you end up
$!    with a good compile and link
$! 4) Each UDF function requires three entries be present in the symbol table of the sharable
$!    image (called a 'shared object' in UNIX). So if you wanted to declare a new function called
$!    'yada' then you would also need 'yada_init' as well as 'yada_deinit'
$! 5) CAVEAT: be sure to check file protections; for some operations MySQL/MariaDB may need to
$!    run with additional privs
$!===============================================================================================
$ set noon
$ say :== write sys$output
$ on error then stop
$ set on
$ my_arch = f$getsyi("arch_name")
$ say "-i-compiling"
$ cc lib_mysqludf_sys.c		-
 ! 	/list			-
	/names=(as_is)		-
 !	/pointer=64		-
 	/prefix=all		-
	/nowarn			-
 	/STANDARD=C99		-
	/share			-
	/include=(							-
		MYSQL055_ROOT:[000000.include.mysql]		,	-
		MYSQL055_ROOT:[000000.include.mysql.psi]		)
$!
$ say "-i-linking on architecture: ",my_arch
$ if (my_arch.eqs."Alpha")
$ then
$	link/shareable=lib_mysqludf_sys.exe				-
	!	/map							-
		lib_mysqludf_sys.obj				,	-
		sys$input/opt
			mysql055_root:[lib.alpha]libmysys.olb/library
		GSMATCH=LEQUAL,1,0
		case_sensitive=YES
		SYMBOL_VECTOR=(									-
			LIB_MYSQLUDF_SYS_INFO_INIT/lib_mysqludf_sys_info_init=PROCEDURE,	-
			LIB_MYSQLUDF_SYS_INFO_DEINIT/lib_mysqludf_sys_info_deinit=PROCEDURE,	-
			LIB_MYSQLUDF_SYS_INFO/lib_mysqludf_sys_info=PROCEDURE,			-
			SYS_GET_INIT/sys_get_init=PROCEDURE,					-
			SYS_GET_DEINIT/sys_get_deinit=PROCEDURE,				-
			SYS_GET/sys_get=PROCEDURE,						-
			SYS_SET_INIT/sys_set_init=PROCEDURE,					-
			SYS_SET_DEINIT/sys_set_deinit=PROCEDURE,				-
			SYS_SET/sys_set=PROCEDURE,						-
			SYS_EXEC_INIT/sys_exec_init=PROCEDURE,					-
			SYS_EXEC_DEINIT/sys_exec_deinit=PROCEDURE,				-
			SYS_EXEC/sys_exec=PROCEDURE,						-
			SYS_EVAL_INIT/sys_eval_init=PROCEDURE,					-
			SYS_EVAL_DEINIT/sys_eval_deinit=PROCEDURE,				-
			SYS_EVAL/sys_eval=PROCEDURE)
		case_sensitive=NO
$ else
$	link/shareable=lib_mysqludf_sys.exe				-
	/map								-
		lib_mysqludf_sys.obj				,	-
		sys$input/opt
			mysql055_root:[lib.ia64]libmysys.olb/library
		GSMATCH=LEQUAL,1,0
		case_sensitive=YES
		SYMBOL_VECTOR=(									-
			LIB_MYSQLUDF_SYS_INFO_INIT/lib_mysqludf_sys_info_init=PROCEDURE,	-
			LIB_MYSQLUDF_SYS_INFO_DEINIT/lib_mysqludf_sys_info_deinit=PROCEDURE,	-
			LIB_MYSQLUDF_SYS_INFO/lib_mysqludf_sys_info=PROCEDURE,			-
			SYS_GET_INIT/sys_get_init=PROCEDURE,					-
			SYS_GET_DEINIT/sys_get_deinit=PROCEDURE,				-
			SYS_GET/sys_get=PROCEDURE,						-
			SYS_SET_INIT/sys_set_init=PROCEDURE,					-
			SYS_SET_DEINIT/sys_set_deinit=PROCEDURE,				-
			SYS_SET/sys_set=PROCEDURE,						-
			SYS_EXEC_INIT/sys_exec_init=PROCEDURE,					-
			SYS_EXEC_DEINIT/sys_exec_deinit=PROCEDURE,				-
			SYS_EXEC/sys_exec=PROCEDURE,						-
			SYS_EVAL_INIT/sys_eval_init=PROCEDURE,					-
			SYS_EVAL_DEINIT/sys_eval_deinit=PROCEDURE,				-
			SYS_EVAL/sys_eval=PROCEDURE)
		case_sensitive=NO
$ endif
$ say "-i-build has finished"
$ if (my_arch.eqs."Alpha")
$ then
$	copy lib_mysqludf_sys.EXE	MYSQL055_ROOT:[plugin.alpha]
$	dir/width=file=55/size/date	MYSQL055_ROOT:[plugin.alpha]
$ else
$	copy lib_mysqludf_sys.EXE	MYSQL055_ROOT:[plugin.ia64]
$	dir/width=file=55/size/date	MYSQL055_ROOT:[plugin.ia64]
$ endif