(file) Return to configure CVS log (file) (dir) Up to [Development] / JSOC

File: [Development] / JSOC / configure (download)
Revision: 1.85, Thu Aug 18 22:28:29 2016 UTC (2 years, 1 month ago) by arta
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-12, NetDRMS_Ver_LATEST, NetDRMS_Ver_9-2, NetDRMS_Ver_9-1, NetDRMS_Ver_9-0, NetDRMS_Ver_8-12, HEAD
Changes since 1.84: +37 -2 lines
If an error occurs, return 1.

#! /bin/csh -f

# The system configuration for configure script
set PERLBIN = ""
set PYBIN = ""

if ($PERLBIN == "") then
    if (-x /home/jsoc/bin/linux_x86_64/activeperl) then
        set PERLBIN = "/home/jsoc/bin/linux_x86_64/activeperl"
    else
        set PERLBIN = "perl"
    endif
endif

if ($PYBIN == "") then
    if (-x /home/jsoc/bin/linux_x86_64/activepython) then
        set PYBIN = "/home/jsoc/bin/linux_x86_64/activepython"
    else
        set PYBIN = "python"
    endif
endif

# set up $JSOC_MACHINE
set JSOC_MACHINE = `build/jsoc_machine.csh`
if ($? != 0) then
    echo "Unable to determine machine type."
    exit 1
endif

echo "Machine type is $JSOC_MACHINE"
echo ""

# Clean by default.
set CLEAN = "yes"
set PROJCONFIG = ""
set CLEANCMD = "d"
set CFGSERVER = "no"
set CFGSERVERARG = "s"
set CUSTOMDEFSFILE = ""

foreach THEARG ($argv)
    set LITERALSTR = '{ my($argin) = "'${THEARG}'"; my($flagout); $flagout = ($argin =~ /^-(.+)/)[0]; print $flagout; }'
    set FLAG = `$PERLBIN -e "$LITERALSTR"`
    if ($? != 0) then
        echo "Unable to parse command-line arguments."
        exit 1
    endif
    
    if ($FLAG == $CLEANCMD) then
        set CLEAN = "no"
    else if ($FLAG == $CFGSERVERARG) then
        set CFGSERVER = "yes"
    else if (-e $THEARG) then
        set PROJCONFIG = $THEARG
    endif
end

# Usage:
#   configure [ -d ] [ -s ] [ <project config file> ]

# Backward compatibility - remove the links to the old make files in projconf
if (-d proj) then	 
    cd proj	 
    if (-e configure) then	 
        rm configure	 
    endif	 
    if (-e make_basic.mk) then	 
        rm make_basic.mk	 
    endif	 
    if (-e Rules.mk) then	 
        rm Rules.mk	 
    endif	 
    if (-e target.mk) then	 
        rm target.mk	 
    endif	 
    cd ..	 
endif

    # Always clean up links to man pages and re-create them.
    echo -n "Removing links to man pages..."
    if (-e man) then
	rm -rf man
    endif
    echo "done"

    if ($CLEAN == "yes") then
        echo -n "Removing links in base/include to headers..."
        # Links in base/include
        if (-d base/include) then
            cd base/include
            find . -name "*.h" -exec rm {} \;
            cd ../..
        endif
        echo "done"

        # Special link from base/drms/apps/serverdefs.h to localization/drmsparams.h
        echo -n "Removing link to serverdefs.h..."
        if (-e base/drms/apps) then
            cd base/drms/apps
            rm serverdefs.h
            cd ../../..
        endif
        echo "done"

        # Links in include
        echo -n "Removing links in include to headers..."
        if (-d include) then
            cd include
            find . -name "*.h" -exec rm {} \;
            find . -name "drmsparams*" -exec rm {} \;
            cd ..
        endif
        echo "done"

        echo -n "Removing links to scripts..."
        # Links in scripts
        if (-d scripts) then
            cd scripts
            if ($? == 0) then
                find . -type l -exec rm {} \;
            endif
            cd ..
        endif
        echo "done"
    # End clean flag
    endif

    # Always clean-up links to jsds and re-create them.
    echo -n "Removing links to jsds..."
    if (-d jsds) then
	cd jsds
        if ($? == 0) then
            find . -type l -exec rm {} \;
        endif
	cd ..
    endif
    echo "done"
    echo

    if ($CLEAN == "yes") then
        if (-x base/local/libs/dsds/scripts/rmlinks.csh) then
            base/local/libs/dsds/scripts/rmlinks.csh
        endif

        if (-x base/local/libs/soi/scripts/rmlinks.csh) then
            base/local/libs/soi/scripts/rmlinks.csh
        endif
    endif

    # Make include directories here, since they are used by multiple script blocks below
    if (!(-d base/include)) then
        mkdir -p base/include
        if ($? != 0) then
            echo "Unable to make base/include directory."            
            exit 1        
        endif
    endif

    if (!(-d include)) then
        mkdir -p include
        if ($? != 0) then
            echo "Unable to make include directory."            
            exit 1        
        endif

        
    endif

    echo "Setting links to man pages..."
    if (-d /home/jsoc/man) then
       if (!(-e man)) then
	    ln -s /home/jsoc/man man
	endif
    endif
    echo "done"
    echo
	
    echo "Setting links to jsds..."
    if (!(-d jsds)) then
        mkdir jsds
    endif
    cd jsds
    find ../base \( -name \*.jsd -exec ln -s {} . \; -a -exec echo "  " {} " OK" \; \) -o \( -name \*.jsd -exec echo "  " {} " ERROR - couldn't create link" \; \)
    cd ..
    echo "done"
    echo

    # generate links for DSDS/SOI dynamic libraries - only do this if 
    # user's environment has access to /home/soi/CM
    if (-d /home/soi/CM/include && -d /home/soi/CM/src) then
        if (-x base/local/libs/dsds/scripts/genlinks.csh) then
            base/local/libs/dsds/scripts/genlinks.csh
        endif

	if (-x base/local/libs/soi/scripts/genlinks.csh) then
     	    base/local/libs/soi/scripts/genlinks.csh
	endif
    endif

    echo "done"
    echo

    #######################
    ## Site Localization ##
    #######################
    
    # Path to the configuration file - at some point, make this an argument to the configure script
    set LOCALIZATIONDIR = ""
    set RELLOCALIZATIONDIR = ""
    set conflocal = "config.local"

    if (-e $conflocal) then
        set RELLOCALIZATIONDIR = `perl -n -e 'if ($_ =~ /^LOCALIZATIONDIR\s+(.+)/) { print $1; }' $conflocal`
    endif

    if ($LOCALIZATIONDIR == "") then
        set RELLOCALIZATIONDIR = localization
    endif

    # Make the path absoluate
    set LOCALIZATIONDIR = ${PWD}/${RELLOCALIZATIONDIR}

    # Reset localization.
    if ($CLEAN == "yes") then
        # This script will need to read the config.local file to get the 
        # localization directory. Otherwise, just use JSOC/localization as the default.
        if (!(-d ${LOCALIZATIONDIR})) then
            mkdir ${LOCALIZATIONDIR}
            if ($? != 0) then
                echo "Error creating localization directory."
                exit 1
            endif
        endif

        if (-e ${LOCALIZATIONDIR}/drmsparams.h) then
            rm ${LOCALIZATIONDIR}/drmsparams.h
        endif

        if (-e ${LOCALIZATIONDIR}/drmsparams.mk) then
            rm ${LOCALIZATIONDIR}/drmsparams.mk
        endif

        if (-e ${LOCALIZATIONDIR}/drmsparams.pm) then
            rm ${LOCALIZATIONDIR}/drmsparams.pm
        endif

        if (-e ${LOCALIZATIONDIR}/drmsparams.py) then
            rm ${LOCALIZATIONDIR}/drmsparams.py
        endif

        if (!(-e configsdp.txt)) then
            # This is NetDRMS.
            if (!(-e config.local)) then
                echo "Error: config.local not found. If you have a saved version of this"
                echo "       file from a previous installation, you should copy that into"
                echo "       this directory and rerun configure. Otherwise, copy the file"
                echo "       config.local.template to config.local and edit the config.local"
                echo "       file to contain site-appropriate values."
                echo 
                echo "*** IMPORTANT *** The edited config.local will contain site-specific"
                echo "    values that should not be modified during subsequent updates to"
                echo "    NetDRMS. Keep a safe copy of it somewhere outside of the DRMS"
                echo "    directory tree, for example in /usr/local. After each NetDRMS"
                echo "    update, ensure this file is in place."
                exit 1;
            endif
        endif
        
        # We now call localize.py for both Stanford and NetDRMS builds.
        if ($CFGSERVER == "yes") then
            set cmd = "$PYBIN ./localize.py -d ${LOCALIZATIONDIR} -b drmsparams -s"
        else
            set cmd = "$PYBIN ./localize.py -d ${LOCALIZATIONDIR} -b drmsparams"
        endif
        
        $cmd
        if ($? != 0) then
            echo "Failure running localize.py."            
            exit 1        
        endif

    endif # End reset localization

    echo "Setting links to scripts..."
    if (!(-d scripts)) then
        mkdir scripts
        if ($? != 0) then
            echo "Unable to create scripts directory."
            exit 1        
        endif
    endif
    
    if ($CLEAN == "yes") then 
        cd scripts

        # Sums scripts
        find ../base/sums/scripts -mindepth 1 -path \*CVS -prune -o -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print "   " . $path . " OK\n"; } else { print "   " . $path . " ERROR - could not create link\n"; } }'

        # Util scripts
        find ../base/util/scripts -mindepth 1 -path \*CVS -prune -o -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print "   " . $path . " OK\n"; } else { print "   " . $path . " ERROR - could not create link\n"; } }'

        # Export scripts
        find ../base/export/scripts -mindepth 1 -path \*CVS -prune -o -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print "   " . $path . " OK\n"; } else { print "   " . $path . " ERROR - could not create link\n"; } }'

        # DRMS / IDL-interface scripts
        find ../base/drms/scripts -mindepth 1 -path \*CVS -prune -o -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print "   " . $path . " OK\n"; } else { print "   " . $path . " ERROR - could not create link\n"; } }'

        # Project-specific scripts - these won't show up if you don't have the project source.
        if (-x ${LOCALIZATIONDIR}/configure) then
            ${LOCALIZATIONDIR}/configure
        endif
        cd ..
    endif

    echo "done"
    echo

    echo "Setting links to headers..."

    # When localize.py was added, we removed the repository version of serverdefs.h, and we stopped generating JSOC/base/include/localization.h.
    # To support legacy code, we need to make a link from serverdefs.h to ${LOCALIZATIONDIR}/drmsparams.h (the replacement for serverdefs.h
    # at Stanford) and from JSOC/base/include/localization.h to ${LOCALIZATIONDIR}/drmsparams.h (the replacement for localization.h
    # for NetDRMs builds). However, some files are looking for JSOC/base/drms/apps/serverdefs.h (instead of JSOC/base/include, the correct path).
    # If we make a link from JSOC/base/drms/apps/serverdefs.h to ${LOCALIZATIONDIR}/drmsparams.h, then the script below will make links from 
    # JSOC/base/include/serverdefs.h and JSOC/include/serverdefs.h to JSOC/base/drms/apps/serverdefs.h, which then links to ${LOCALIZATIONDIR}/drmsparams.h.
    if (!(-l base/drms/apps/serverdefs.h)) then
        cd base/drms/apps
        ln -s ../../../${RELLOCALIZATIONDIR}/drmsparams.h serverdefs.h
        if ($? != 0) then
            echo "Failure creating link to "
            exit 1
        endif
        cd ../../..
    endif

    if (!(-l base/include/localization.h)) then
        cd base/include
        ln -s ../../${RELLOCALIZATIONDIR}/drmsparams.h localization.h
        cd ../..
    endif

    if ($CLEAN == "yes") then 
        cd base/include
        find .. -path '../include' -prune -o -name \*.h -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print "   " . $path . " OK\n"; } else { print "   " . $path . " ERROR - could not create link\n"; } }'
        cd ../..

        cd include
        if (-d ../base/include) then
            find ../base/include -name \*.h -print | ${PERLBIN} -MFile::Basename -n -e 'my($bn) = basename($_); chomp($bn); my($path) = $_; chomp($path); if (!(-e $bn)) { `ln -s $_`; if ($? >> 8 == 0) { print "   " . $path . " OK\n"; } else { print "   " . $path . " ERROR - could not create link\n"; } }'
        endif
        cd ..
    endif

    cd include
    # ${LOCALIZATIONDIR} is an absolute path
    if (!(-l drmsparams.h)) then
        ln -s ../${RELLOCALIZATIONDIR}/drmsparams.h
    endif
    if (!(-l drmsparams.pm)) then
        ln -s ../${RELLOCALIZATIONDIR}/drmsparams.pm
    endif
    if (!(-l drmsparams.py)) then
        ln -s ../${RELLOCALIZATIONDIR}/drmsparams.py
    endif

    cd ..
    echo "done"
    echo

Karen Tian
Powered by
ViewCVS 0.9.4