#!/bin/sh # # ZLIB compilation script for the OS/400. # # # This is a shell script since make is not a standard component of OS/400. ################################################################################ # # Tunable configuration parameters. # ################################################################################ TARGETLIB='ZLIB' # Target OS/400 program library STATBNDDIR='ZLIB_A' # Static binding directory. DYNBNDDIR='ZLIB' # Dynamic binding directory. SRVPGM="ZLIB" # Service program. IFSDIR='/zlib' # IFS support base directory. TGTCCSID='500' # Target CCSID of objects DEBUG='*NONE' # Debug level OPTIMIZE='40' # Optimisation level OUTPUT='*NONE' # Compilation output option. TGTRLS='V6R1M0' # Target OS release export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM IFSDIR export TGTCCSID DEBUG OPTIMIZE OUTPUT TGTRLS ################################################################################ # # OS/400 specific definitions. # ################################################################################ LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB" ################################################################################ # # Procedures. # ################################################################################ # action_needed dest [src] # # dest is an object to build # if specified, src is an object on which dest depends. # # exit 0 (succeeds) if some action has to be taken, else 1. action_needed() { [ ! -e "${1}" ] && return 0 [ "${2}" ] || return 1 [ "${1}" -ot "${2}" ] && return 0 return 1 } # make_module module_name source_name [additional_definitions] # # Compile source name into module if needed. # As side effect, append the module name to variable MODULES. # Set LINK to "YES" if the module has been compiled. make_module() { MODULES="${MODULES} ${1}" MODIFSNAME="${LIBIFSNAME}/${1}.MODULE" CSRC="`basename \"${2}\"`" if action_needed "${MODIFSNAME}" "${2}" then : elif [ ! "`sed -e \"//,/<\\\\/source>/!d\" \ -e '/ tmphdrfile # Need to translate to target CCSID. CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')" CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)" system "${CMD}" # touch -r "${HFILE}" "${DEST}" rm -f tmphdrfile fi IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`" if action_needed "${IFSFILE}" "${DEST}" then rm -f "${IFSFILE}" ln -s "${DEST}" "${IFSFILE}" fi done # Install the ILE/RPG header file. HFILE="${SCRIPTDIR}/zlib.inc" DEST="${SRCPF}/ZLIB.INC.MBR" if action_needed "${DEST}" "${HFILE}" then CMD="CPY OBJ('${HFILE}') TOOBJ('${DEST}')" CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)" system "${CMD}" # touch -r "${HFILE}" "${DEST}" fi IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`" if action_needed "${IFSFILE}" "${DEST}" then rm -f "${IFSFILE}" ln -s "${DEST}" "${IFSFILE}" fi # Create and compile the identification source file. echo '#pragma comment(user, "ZLIB version '"${VERSION}"'")' > os400.c echo '#pragma comment(user, __DATE__)' >> os400.c echo '#pragma comment(user, __TIME__)' >> os400.c echo '#pragma comment(copyright, "Copyright (C) 1995-2017 Jean-Loup Gailly, Mark Adler. OS/400 version by P. Monnerat.")' >> os400.c make_module OS400 os400.c LINK= # No need to rebuild service program yet. MODULES= # Get source list. CSOURCES=`sed -e '/