#!/bin/sh ##============================================================================== ## ## Product, Version, and Bilddate information: ## ##============================================================================== product="OMI" fullproduct="Open Management Infrastructure" major=1 minor=0 revision=2 date=`date` version="$major.$minor.$revision" ##============================================================================== ## ## CIM Schema version ## ##============================================================================== cimschema="CIM-2.32.0" ##============================================================================== ## ## Get command line options that start with slash. ## ##============================================================================== for opt do arg=`expr "x$opt" : 'x[^=]*=\(.*\)'` case $opt in -h | --help) help=1 ;; --enable-debug) enable_debug=1 ;; --disable-rtti) disable_rtti=1 ;; --disable-templates) disable_templates=1 ;; --target=*) target=$arg ;; --toolchain=*) toolchain=$arg ;; --prefix=*) prefix=$arg ;; --bindir=*) bindir=$arg ;; --libdir=*) libdir=$arg ;; --includedir=*) includedir=$arg ;; --datadir=*) datadir=$arg ;; --localstatedir=*) localstatedir=$arg ;; --sysconfdir=*) sysconfdir=$arg ;; --providerdir=*) providerdir=$arg ;; --providerdir=*) providerdir=$arg ;; --certsdir=*) certsdir=$arg ;; --authdir=*) authdir=$arg ;; --builddir=*) builddir=$arg ;; --enable-werror) enable_werror=1 ;; --enable-wchar) enable_wchar=1 ;; --enable-gcov) enable_gcov=1 ;; --namespace=*) namespace=$arg ;; --httpport=*) httpport=$arg ;; --httpsport=*) httpsport=$arg ;; --disable-libpath) disable_libpath=1 ;; --favorsize) favorsize=1 ;; *) echo "$0: unknown option: $opt" exit 1 ;; esac done ##============================================================================== ## ## Print the help message ## ##============================================================================== if [ "$help" = "1" ]; then cat<=" 1 ")" "&" "(" "$httpport" "<=" 65535 ")"` if [ "$rc" = "0" ]; then echo "$0: invalid --httpport option: $httpport" exit 1 fi fi if [ -z "$httpsport" ]; then httpsport=7779 else rc=`expr "(" "$httpsport" ">=" 1 ")" "&" "(" "$httpsport" "<=" 65535 ")"` if [ "$rc" = "0" ]; then echo "$0: invalid --httpsport option: $httpsport" exit 1 fi fi ##============================================================================== ## ## Create output directories. ## ##============================================================================== if [ -z "$builddir" ]; then mkdir -p $outputdir else mkdir -p $builddir ln -s $builddir $outputdir fi mkdir -p $outputdir/bin mkdir -p $outputdir/lib mkdir -p $outputdir/obj mkdir -p $outputdir/tmp mkdir -p $outputdir/var mkdir -p $outputdir/var/log mkdir -p $outputdir/var/run mkdir -p $outputdir/var/omiauth mkdir -p $outputdir/include mkdir -p $tmpdir ##============================================================================== ## ## Set macros for suppressing the linefeed produced by 'echo' command. ## ##============================================================================== case `echo -n xyz` in -n*) echon= case `echo 'xyz\c'` in *c*) echoc= ;; *) echoc='\c' ;; esac ;; *) echon='-n' echoc= ;; esac ##============================================================================== ## ## Attempt to find C compiler. ## ##============================================================================== echo $echon "checking whether C compiler is on the path... $echoc" cc=`./buildtool cc` if [ "$cc" = "" ]; then echo "$0: failed" exit 1 fi tmp1=`echo $cc | awk '{ print $1; }'` tmp2=`which $tmp1` if [ -x "$tmp2" ]; then echo "yes" else echo "no" exit 1 fi ##============================================================================== ## ## Attempt to compile and execute a simple C program ## ##============================================================================== echo $echon "checking whether C compiler compiles... $echoc" rm -f $tmpdir/cprogram cat > $tmpdir/cprogram.c < /dev/null 2> /dev/null ) if [ "$?" = "0" ]; then echo "yes" else echo "no" exit 1 fi if [ -z "$CONFIG_TARGET" ]; then echo $echon "checking whether C program executes... $echoc" $tmpdir/cprogram if [ "$?" = "123" ]; then echo "yes" else echo "no" exit 1 fi fi rm $tmpdir/cprogram.c rm $tmpdir/cprogram ##============================================================================== ## ## Check whether __FUNCTION__ macro is supported. ## ##============================================================================== echo $echon "checking for __FUNCTION__ macro... $echoc" rm -f $tmpdir/function cat > $tmpdir/function.c < int main() { printf("%s\n", __FUNCTION__); return 0; } EOF ( cd $tmpdir ; $cc -o function function.c > /dev/null 2> /dev/null ) if [ "$?" = "0" ]; then have_function_macro=1 echo "yes" else have_function_macro=0 echo "no" fi rm -f $tmpdir/function.c rm -f $tmpdir/function ##============================================================================== ## ## Check for 'openssl' command. ## ##============================================================================== echo $echon "checking whether openssl command is on the path... $echoc" openssl=`which openssl` if [ -x "$openssl" ]; then echo "yes" else echo "no" exit 1 fi ##============================================================================== ## ## Check for 'pkg-config' command. ## ##============================================================================== echo $echon "checking whether pkg-config command is on the path... $echoc" pkgconfig=`which pkg-config` if [ -x "$pkgconfig" ]; then echo "yes" else echo "no" exit 1 fi ##============================================================================== ## ## Create config.mak file ## ##============================================================================== fn=$outputdir/config.mak cat > $fn < $fn <> $fn else echo "/* #define CONFIG_ENABLE_DEBUG */" >> $fn fi if [ "$enable_gcov" = "1" ]; then echo "#define CONFIG_ENABLE_GCOV" >> $fn else echo "/* #define CONFIG_ENABLE_GCOV */" >> $fn fi if [ "$enable_werror" = "1" ]; then echo "#define CONFIG_ENABLE_WERROR" >> $fn else echo "/* #define CONFIG_ENABLE_WERROR */" >> $fn fi if [ "$enable_wchar" = "1" ]; then echo "#define CONFIG_ENABLE_WCHAR" >> $fn else echo "/* #define CONFIG_ENABLE_WCHAR */" >> $fn fi if [ "$disable_rtti" = "1" ]; then echo "#define CONFIG_DISABLE_RTTI" >> $fn else echo "/* #define CONFIG_DISABLE_RTTI */" >> $fn fi if [ "$disable_libpath" = "1" ]; then echo "#define CONFIG_DISABLE_LIBPATH" >> $fn else echo "/* #define CONFIG_DISABLE_LIBPATH */" >> $fn fi if [ "$disable_templates" = "1" ]; then echo "#define CONFIG_DISABLE_TEMPLATES" >> $fn else echo "/* #define CONFIG_DISABLE_TEMPLATES */" >> $fn fi if [ "$favorsize" = "1" ]; then echo "#define CONFIG_FAVORSIZE" >> $fn else echo "/* #define CONFIG_FAVORSIZE */" >> $fn fi if [ "$have_function_macro" = "1" ]; then echo "#define CONFIG_HAVE_FUNCTION_MACRO" >> $fn else echo "/* #define CONFIG_HAVE_FUNCTION_MACRO */" >> $fn fi echo "#define CONFIG_SHLIBEXT \"`./buildtool shlibext`\"" >> $fn echo "" >> $fn echo "#endif /* _config_h */" >> $fn echo "created $fn" fn="" ##============================================================================== ## ## Setup symbolic links for 'include' directory. ## ##============================================================================== rm -rf $outputdir/include/MI.h ln -f -s $root/common/MI.h $outputdir/include/MI.h rm -rf $outputdir/include/micxx ln -f -s $root/micxx $outputdir/include/micxx rm -rf $outputdir/include/omiclient ln -f -s $root/omiclient $outputdir/include/omiclient ##============================================================================== ## ## Generate omi.mak (end-user makefile). ## ##============================================================================== fn=$outputdir/omi.mak cat > $fn < $fn < $fn < /dev/null 2> /dev/null if [ "\$?" != "0" ]; then echo "\$0: openssl program is not executable." exit 1 fi ## ## Create directories. ## mkdir -p \$destdir/$prefix mkdir -p \$destdir/$bindir mkdir -p \$destdir/$libdir mkdir -p \$destdir/$localstatedir mkdir -p \$destdir/$localstatedir/log mkdir -p \$destdir/$localstatedir/run mkdir -p \$destdir/$sysconfdir mkdir -p \$destdir/$providerdir mkdir -p \$destdir/$certsdir mkdir -p \$destdir/$authdir mkdir -p \$destdir/$includedir mkdir -p \$destdir/$includedir/micxx mkdir -p \$destdir/$includedir/omiclient mkdir -p \$destdir/$datadir mkdir -p \$destdir/$datadir/omischema mkdir -p \$destdir/$sysconfdir/omiregister mkdir -p \$destdir/$sysconfdir/omiregister/interop mkdir -p "\$destdir/$sysconfdir/omiregister/root#cimv2" mkdir -p "\$destdir/$sysconfdir/omiregister/root#omi" mkdir -p "\$destdir/$sysconfdir/omiregister/root#check" mkdir -p \$destdir/$sysconfdir/omiregister/$namespacedir ## ## Install executables. ## cp -f $outputdirbase/bin/omiserver \$destdir/$bindir/omiserver.bin cp -f $outputdirbase/bin/omicli \$destdir/$bindir/omicli.bin cp -f $outputdirbase/bin/omigen \$destdir/$bindir/omigen.bin cp -f $outputdirbase/bin/omireg \$destdir/$bindir/omireg.bin cp -f $outputdirbase/bin/omicheck \$destdir/$bindir/omicheck.bin cp -f $outputdirbase/bin/omiagent \$destdir/$bindir/omiagent rm -f \$destdir/$bindir/omicli rm -f \$destdir/$bindir/omigen rm -f \$destdir/$bindir/omireg rm -f \$destdir/$bindir/omiserver rm -f \$destdir/$bindir/omicheck cat > \$destdir/$bindir/omiserver < \$destdir/$datadir/omi.mak cat $outputdirbase/omi.mak >> \$destdir/$datadir/omi.mak ## ## Install certificates. ## hostname=`./buildtool hostname` cnffile=./output/$hostname/ssl.cnf keyfile=\$destdir/$certsdir/omikey.pem certfile=\$destdir/$certsdir/omi.pem if [ -f "\$keyfile" -a -f "\$certfile" ]; then echo echo "************************************************************" echo "* Warning: The certificate and keyfile were not generated *" echo "* since they already exist. *" echo "************************************************************" else openssl req -x509 -sha1 -newkey rsa:2048 -days 3650 -nodes -config \$cnffile -keyout \$keyfile -out \$certfile chmod 600 \$keyfile chmod 644 \$certfile fi ## ## Configure PAM. ## $outputdirbase/installpam ## ## Install 'uninstall' script. ## cp $outputdirbase/uninstall \$destdir/$bindir/omiuninstall chmod 755 \$destdir/$bindir/omiuninstall ## ## Print success message! ## echo "Successfully installed under under: \$destdir/$prefix" EOF chmod +x $fn echo "created $fn" ##============================================================================== ## ## Create 'uninstall' script. ## ##============================================================================== shlibext=`./buildtool shlibext` fn=$outputdir/uninstall cat > $fn <