#!/usr/bin/perl -w package XXXXbuildenv; { # XXXXbuild-env.pl wjs Jun 04 # XXXX = "opt-" for option server setup; presumably empty else # (from opt-build-env November 13, 1998 C.Hammond # "For use in setting a compilation environment when building # an OTHER OPTIONS server" as modified by rcg 29 Dec 99 # Base csh source file was in use 1 Jun 04) # General comment: this routine is a string generator. It does NOT # check for the validity of strings, existence of files when string # points to a file, etc. I think this is a good architectural idea # because I don't think all strings can be validated, and doing some # but not others would be confusing # # Accepts -sh or -csh switch. If present, outputs a set of export or # setenv commands, respectively, to stdout. Values for env vars are # output between a single set of "s, so complicated ones might produce # bad setenv/export statements. # Accepts -defnlist to control XXXXBUILD-ENV-DEFNS (see below) # Accepts an absolute directory spec as an argument. If present, that # directory becomes the jgofs root instead of the directory in which # opt-build-env is found. # If -defnlist specified, outputs XXXXBUILD-ENV-DEFNS, an # environment variable = to a comma separated list of environment # variables set by XXXXbuild-env.pl. # Defines perl hash old_ENV for every env var that XXXXbuild-env.pl # replaced. Key is the replaced env var; value is the replaced value. # old-ENV{key} is undefined if there was no old value for key. # Sample of environment variables output - documentation is in code where # user modifies the site-specific value. (Note: sample not # necessarily complete nor does it necessarily reflect the defaults # nor does it necessarily reflect the values in the body of the code. # It is a sample showing the kinds of things that can be done) # Some variables (eg, TARPROG) are output only for option servers # Some variables (eg, SHELL) are output on an OS-specific basis. # AR /usr/ccs/bin/ar srv # BACKGROUND_COLOR 00FF00 # BUTTONIMAGESDIR http://optserv1.whoi.edu:8200/images # CC cc -DSOL -DSVR4 -lnsl -lsocket # CONFIG_FILE /export/home/wsass/opt-build-env.pl # CPPROG /usr/bin/cp # DIRSERVER optserv1.whoi.edu:8200/jg/dir # DISPLAY_DATA_URL FALSE # DMONAME Option Server # FC f77 -lnsl -lsocket # GNUCOMPRESS /usr/local/bin/gzip # HELPADDR http://optserv1.whoi.edu:8200 # HELPDIR htdocs # INFOSERVER optserv1.whoi.edu:8200/jg/info # INFO_SOURCES BCO-DMO,TRADITIONAL # JGOFSDIR /export/home/wsass # JGSCRIPTDIR /jg # MAIL_SENDER /usr/bin/rmail # MYADDR optserv1.whoi.edu:8200 # NAWK nawk # OBJDIR / # OPT opt # OPTIONSERVER optserv1.whoi.edu/jg/otheropt3 # PERL /usr/bin/perl # PORT 8200 # RANLIB echo # SYS Solaris # TARPROG /usr/bin/tar # TEMPADDR http://optserv1.whoi.edu:8200/jgofsopt/8200 # TEMPDIR /export/home/wsass/htdocs/jgofsopt/8200 # UNIXCOMPRESS /usr/bin/compress # ZIPPROG /usr/local/bin/zip $build_env_pl_version = "build-env.pl version 1.3a 9 Aug 2010"; # 9 Aug 10. wjs # More info controls (info 4.1) # [begin v 1.3a] # # 11 Mar 10. wjs # Forgot to accept dmoname from .conf file # Need to accept temp_dir from .conf file # 5 Mar 10. wjs # Forgot to accept button_images_server from .conf file # 27 Feb 10. wjs # More info controls # 20 Feb 10. wjs # Accept values from a .conf file. If present there, # overrides value (if any) here # Bug fix: no FC env var defined for irix systems. Typo. # Add a version. DON'T call it $version until/unless ready # to deal w/scoping issues # 5 Feb 10. wjs # By default, don't define DMONAME # Output INFO_USEDATABASE w/same value as USEDATABASE # info 4.0 control variables. Supersedes but accepts USEDATABASE # and INFO_USEDATABASE. # Comment to advise against changing jg defn # [begin v 1.3] # # 11 Jun 09. wjs # Change otheropt2 to otheropt3 # 16 Apr 09. wjs # Add USEDATABASE per rcg request # 14 Mar 09. wjs # Add compile-time LINUX defn # 14 Feb 09. wjs # Change otheropt to otheropt2 # Get rid of "not setting up standard system OOserver" warning # [Earlier comments moved to build-env.revision Feb 10] foreach (@ARGV) { if ($_ eq "-sh") { ((defined $sh_out) || (defined $csh_out)) && die ("Duplicate or conflicting -sh, -csh switches\n"); $sh_out = 1; } elsif ($_ eq "-csh") { ((defined $sh_out) || (defined $csh_out)) && die ("Duplicate or conflicting -sh, -csh switches\n"); $csh_out = 1; } elsif ($_ eq "-defnlist") { $defnlist = ""; } else { (defined $jgofs_root) && die "Too many switches/arguments\n"; $jgofs_root = $_; } } (defined $sh_out) || ($sh_out = 0); (defined $csh_out) || ($csh_out = 0); if (defined $jgofs_root) { ($jgofs_root =~ /^\//) || die "jgofs root (specified as $jgofs_root) must be an absolute file spec\n"; (-e $jgofs_root) || die "jgofs root $jgofs_root does not exist\n"; (-r $jgofs_root) || die "jgofs root $jgofs_root is not readable\n"; (-d $jgofs_root) || die "jgofs root $jgofs_root is not a directory file\n"; } $this_file = ($main::build_env_file_name) ? $main::build_env_file_name : $0; # Use cd command to get directory. Don't know how to do it easily otherwise # (there is a shell env var PWD, but this can be set != to actual pwd) ($dir,$file) = ($this_file =~ /^(.*)\/(.+)$/); if ($file) { # Presumably $dir must be defined if $file is, so testing $dir is # asking whether or not it's empty $this_dir = ($dir) ? `(cd $dir; pwd)` : ""; } else { # Presumably $dir is not defined, or we'd have a non-empty dir spec w/an # empty file name. Don't think this is worth a diagnostic $this_dir = `pwd`; $file = $this_file; } chomp $this_dir; &out("CONFIG_FILE","$this_dir/$file"); (defined $jgofs_root) || ($jgofs_root = $this_dir); # Some day we may want to get next routine from a standard "library # place". Issue is that if/when we do that, we make the build package # depend on something else. At the moment it's stand alone (and we # distribute the next file w/the build package) # get_hash_from_file is now a perl module, so we are one step closer # to standard. Regarding the location issue, above, we could find # things w/whatever perl search list mechanism is defined # Well, turns out we actually NEED that "standard library place" # use get_hash_from_file; the intended syntax, looks in the @INC # array for the directory. The @INC array has . in it, but we might # not be running in . Attempts to alter @INC have so far resulted in # humiliating failure. So, for now, something that works ######## push @INC,$jgofs_root; require "$jgofs_root/get_hash_from_file.pm"; ### # vvvvvvvv most only need to edit between long comment lines vvvvvvvvvv ####################################################################### # Site-specific configuration configuration. See build-env_conf.doc # Set next value to "" or remove line if capability not desired $build_env_conf_file = "$jgofs_root/build-env.conf"; # Destination file(s) for diagnostics regarding the configuration file $build_env_conf_diagnostic_sink = "STDERR"; # Operating system. If not "Solaris", "Irix", or "linux" # editing "outside the lines" will be required $opsys = "Solaris"; # Location of perl. It is recommended that this NOT be used # Some perl scripts are released as "template" files which are input # to make files which substitute values for placeholders in the template. # Except for the location of perl itself, these placeholders all come # from this file. Therefore, we can get rid of both the templates and # their make files by # 1) hardcoding the perl location (we recommend /usr/bin/perl and, # if perl is NOT in /usr/bin, setting up a soft link defining # /usr/bin/perl; eg, ln -s wherever_perl_is /usr/bin/perl) # 2) "require"ing this file # 3) using $ENV{"whatever"} instead of the placeholder $perl_location = "/usr/bin/perl"; ######## # Next group must be defined and non-empty # $jgofs_cgi_root is relative to the directory build-env.pl is in, # and must be defined in httpd server config for $server_name:$port # Note: much of the system does NOT honor $jgofs_cgi_root, so change # at own peril $server_name = "optserv1.whoi.edu"; $port = 8200; $jgofs_cgi_root = "jg"; # Pieces of URL pointing to directory where images for outer's # display buttons are located. Empty $button_images_server means # $server_name. Empty $button_images_dir means default doc root for # $button_images_server. (Note that empty $button_images_port means # default port for $button_images_server, not $port) # If no images, comment out next 3 lines $button_images_server = "globec.whoi.edu"; $button_images_port = ""; $button_images_dir = "images"; # Next 2 values control appearance of web pages displayed by # outer. If your methods do not use outer, these values have # no effect. # Controls whether outer displays the object spec as a title line # in html display. May be omitted. Default value is TRUE $display_data_url = TRUE; # Controls background color of pages displayed by outer. May be # omitted. Default value depends on browser displaying page. # If specified, specify as a string constant exactly 6 characters in # length, each character being a valid hex digit. Case insensitive. $background_color = "ffffff"; # # Name of server (appears on web pages someplace...) # If commented out or otherwise undefined, defaults to $server_name # A defined, empty name is honored. Will override the default server # name, if any, implied by the value of program (below) # $dmoname = "Option Server"; # The next variable controls the sources of metadata. It assumes # that version 4.0 of the info utility is installed. The variable's value # is a comma-separated list of sources. The sources are searched # in the order specified. # If TRADITIONAL is in the list, # the metadata information comes from a plain text, with HTML tags # allowed, file called .info located in the same # subdirectory in the JGOFS/GLOBEC objects subdirectory where the # data object is specified as an entry in the .objects file. # If BCO-DMO is in the list then the metadata information is read # from the BCO-DMO metadata database via a web CGI script. # If REMOTE_TRADITIONAL is in the list, the metadata comes from a # remote host's info server. That server is expected to be configured # as TRADITIONAL (above). Specification of the remote server is controlled # by the REMOTE_TRADITIONAL_SERVERS configuration parameter (below) # If the list is empty or not specified, TRADITIONAL is assumed. # # $info_sources = "BCO-DMO,TRADITIONAL"; # # Some earlier versions of the info utility were controlled by # the build-env.pl $usedatabase variable. # This variable is still accepted. If defined as true, it is a synonym for # $info_sources = "BCO-DMO,TRADITIONAL"; # If false, it is a synonym for # $info_sources = "TRADITIONAL"; # The next set of variables can be used to control the operation of # the metadata display facility. For information about these variables # please see the info.doc file included with info version 4.0 # $info_log_misses = "/tmp/info40-misses.log"; # $info_log_all_sources = "/tmp/info40-logall.log"; # $info_action_on_data_source_error = "ABORT"; # $info_action_on_logging_failure = "ABORT"; # The next variable can be used to specify the host and port # for the BCO-DMO metadata web CGI script # $info_BCODMO_host_port # The next variable can be used to specify how the BCO-DMO metadata web # web CGI script is called. The choices are # DATASET_URL, MANUFACTURED_DATASET_URL, and DDIR_OBJ. # The default is # $info_BCODMO_access_techniques = # "DATASET_URL,MANUFACTURED_DATASET_URL,DDIR_OBJ"; # The next variable can be used to force all the named techniques to be # attempted even if use of a technique results in returned data. The # default is # $info_BCODMO_attempt_all_techniques = "FALSE"; # The next variable can be used to specify where to look if # INFO_SOURCES includes the keyword REMOTE_TRADITIONAL # The choices are DATASERVER, INFOSERVER and GLOBEC. The default is # $info_remote_traditional_servers = "INFOSERVER"; # The next variable can be used to force all the named remote traditional # servers to be contacted even if one of them already returned data. The # default is # $info_attempt_all_remote_traditional_servers = "FALSE"; # NEXT VARIABLE ONLY NEEDED FOR DATA SERVER SETUP # If you are a node in the JGOFS or GLOBEC programs, setting # program to JGOFS or GLOBEC, respectively, will set your documentation # and directory servers to the programs' master servers, and will # set the default name for your data server. If blank or undefined, # servers will come from your node. # $program = ""; # REST OF VARIABLES ONLY NEEDED FOR OPTION SERVER SETUP # Directory of DocumentRoot defined for $server_name in # server setup, specified as a relative directory (no initial /) # This directory must be an offset from the JGOFS software installation # directory (where this file lives). Use links, if necessary, to # coordinate JGOFS installation tree and web server tree $doc_root = "htdocs"; # directory relative to $doc_root where help is located $help_dir = ""; # directory relative to $doc_root under which temp files are stored # Some level of uniqueness is nice, but we certainly don't do # a thorough job of it with $port. (We don't even do a # thorough job of it when we add the browser's ip addr as # another subdirectory level) # (NB: this is NOT /jgofsopt just because we sometimes alias # things there - alias is logically irrelevant to configuration # The OOserver code uses jgofsopt in 2 different ways. One way # is as a spec for temp files (set up here). When used this way, the file # spec is arbitrary (except for accessibility issues). The other way is # as a web-server-accessibile "entity". When used this way, jgofsopt # is "the thing we define in the web server setup". We happened to # choose the same name for both uses (and, on optserv1, threw a file # system symbolic link into the stew for good measure) # Among other things, the web "entity" must be a subdir of the # doc root (enforced here, creating an understood association between # what's done here and what's done in the web server config)) # NB: $port, below does NOT reflect the value, if any, in build-env.conf # If you change the port in build-env.conf, and you want temp_dir to # have that changed port, you must specify temp_dir in build-env.conf as well $temp_dir = "jgofsopt/$port"; # Locations below are almost just "suggestions" to remind us that # this info, if changed, will goof things up. These root locations # are just the start. The actual directories, files, etc that are # needed are set in the make files. We make the unjustified # assumption that what's needed in the make files will be a function # of these roots plus other, "observed" names, offsets, etc. # If option server being set up does not offer these services, # define symbol as empty string. Alternate matlabs in case 1) OOserver # has them 2) it turns out there is a difference between them. # Define at least 1 if OOserver is to offer matlab download capability # At the moment (May 08), which gets the default name "matlab" is # hardcoded into various scripts $matlabroot = "/usr/local/matlab61"; $matlab5root = "/usr/local/matlab531"; $matlab65root = "/usr/local/matlab65"; $matlab71root = "/usr/local/matlabR2007a"; $netcdfroot = "/usr/local/netcdf"; # auxiliary programs required for download functionality $mail_sender = "/usr/bin/rmail"; $zip = "/usr/bin/zip"; $tar = "/usr/bin/tar"; $compress = "/usr/bin/compress"; $gzip = "/usr/bin/gzip"; # life is much easier if we have cp ... $cp = "/usr/bin/cp"; ####################################################################### # ^^^^^^^^ most only need to edit between long comment lines ^^^^^^^^^^^ ### if ($build_env_conf_file) { ($status,$msg,%build_env_conf) = &get_hash_from_file::get_hash_from_file ($build_env_conf_file,$build_env_conf_diagnostic_sink); ($status eq "OK") || (die ("Bad status $status from get_hash_from_file. Err text = $msg")); } ### # OPERATING SYSTEM STUFF ### &use_build_env_conf_val("opsys"); $opsys || die "Undefined or blank \$opsys (operating system) variable"; if ( $opsys eq 'linux' ) { $c_compile = "cc -DLINUX"; $fortran_compile = "g77 -O"; $archive_command = "/usr/bin/ar rv"; $ranlib = "ranlib"; $nawk = "awk"; # Next line needed only for option servers that support matlab # Value determined by inspection of fleetlink.whoi.edu Jun 2005 $matlab_extern_arch_dir = "glnx86"; # Stop supporting SunOS. Leave this here to explain # code conditional on SYS=SunOS (for example) # } elsif ( $ENV{'SYS'} eq 'SunOS' ) { # $ENV{'CC'} = "cc -DSUN"; # $ENV{'FC'} = "f77"; # $ENV{'AR'} = "ar rv"; # $ENV{'RANLIB'} = "ranlib"; # $ENV{'NAWK'} = "nawk"; } elsif ( $opsys eq 'Solaris' ) { $c_compile = "cc -DSOL -DSVR4 -lnsl -lsocket"; $fortran_compile = "f77 -lnsl -lsocket"; $archive_command = "/usr/ccs/bin/ar srv"; $ranlib = "echo"; $nawk = "nawk"; # Next line needed only for option servers that support matlab # Value determined by inspection of gb6.whoi.edu Jun 2005 $matlab_extern_arch_dir = "sol2"; } elsif ( $opsys eq 'Irix' ) { $c_compile = "cc -cckr -DIRIX"; $fortran_compile = "f77 -woff 2290"; $archive_command = "/usr/bin/ar -srv"; $ranlib = "echo"; $nawk = "nawk"; $sh = "/sbin/sh"; # Next line needed only for option servers that support matlab # Value from E Cunningham Jun 2005 $matlab_extern_arch_dir = "sgi"; } else { die "Unrecognized value for \$opsys (operating system) variable: $opsys"; } &use_build_env_conf_val("c_compile"); &use_build_env_conf_val("fortran_compile"); &use_build_env_conf_val("archive_command"); &use_build_env_conf_val("ranlib"); &use_build_env_conf_val("nawk"); &use_build_env_conf_val("sh"); &out("SYS",$opsys); &out("CC",$c_compile); &out("FC",$fortran_compile); &out("AR",$archive_command); &out("RANLIB",$ranlib); &out("NAWK",$nawk); $sh && &out("SHELL",$sh); &out("PERL",$perl_location); ### # JGOFS SYSTEM/WEB SERVER STUFF ### &use_build_env_conf_val("program"); (defined $program) || ($program = ""); $opt_prefix = ($file =~ /^opt-/) ? "opt" : ""; if ($defnlist) { $defnlist_env_var = $opt_prefix; $defnlist_env_var && ($defnlist_env_var .= "-"); $defnlist_env_var .= "BUILD-ENV-DEFNS"; } # Could do more checks on next group. port should be numeric. # _root's should neither lead nor end w/slashes &use_build_env_conf_val("server_name"); &use_build_env_conf_val("port"); &use_build_env_conf_val("doc_root"); &use_build_env_conf_val("jgofs_cgi_root"); $server_name || die ("\$server_name variable empty or undefined"); $port || die ("\$port variable empty or undefined"); $doc_root || die ("\$doc_root variable empty or undefined"); $jgofs_cgi_root || die ("\$jgofs_cgi_root variable empty or undefined"); # Presence/absence of slashes, "http:"s, etc is historical. # So are most comments below. # Unfortunately not much consistency... $myaddr = "$server_name:$port"; # I suspect trouble if $jgofs_root is /. Since things that use this # assume that $jgofs_root does not end in /, we'll put out the empty # string and hope for the best &out("JGOFSDIR",$jgofs_root); &out("OPT","$opt_prefix"); &out("PORT",$port); &out("MYADDR",$myaddr); # # location to be added to MYADDR to find Optionserver scripts # (and other stuff, like serv. Probably not in use in data servers # at the moment. wjs Jun 04) # &out("JGSCRIPTDIR","/$jgofs_cgi_root"); # Deliberately allowing user to specify empty $button_images_dir # which means that images are in default doc root of server &use_build_env_conf_val("button_images_dir"); &use_build_env_conf_val("button_images_port"); &use_build_env_conf_val("button_images_server"); if (defined $button_images_dir) { $button_images_server || ($button_images_server = $server_name); $button_images_port && ($button_images_port = ":$button_images_port"); $temp = "http://$button_images_server$button_images_port"; $button_images_dir && ($temp .= "/$button_images_dir"); &out("BUTTONIMAGESDIR",$temp); } # option_server_program definition below assumes that the OOserver being # pointed to actually HAS a jg/otheropt3. This file was added # to the default optserv1.whoi.edu OOserver 1 Jun 09. # If option_server_host in fact points to the default optserv1.whoi.edu # OOserver, then the defn assumes that the JGOFS server # being build with this file is running at least outer 3.2. If # this second assumption is NOT correct, then the defn should # be changed to point to jg/otheropt2, if the data server is # running at least outer 3.0, or jg/otheropt otherwise &use_build_env_conf_val("option_server_host"); &use_build_env_conf_val("option_server_port"); &use_build_env_conf_val("option_server_program"); $option_server_host = "optserv1.whoi.edu"; $option_server_port = ""; $option_server_program = "jg/otheropt3"; $option_server = $option_server_host; $option_server_port && ($option_server .= ":" . $option_server_port); $option_server .= "/" . $option_server_program; &out("OPTIONSERVER",$option_server); # Deliberately allowing user to specify empty $dmoname &use_build_env_conf_val("dmoname"); if ($program eq "JGOFS") { $info_server = "usjgofs.whoi.edu/jg/info"; $dir_server = "usjgofs.whoi.edu/jg/dir"; (defined $dmoname) || ($dmoname = "US JGOFS"); $top_object_subdir = "/jgofs"; } elsif ($program eq "GLOBEC") { $info_server = "globec.whoi.edu/jg/info"; $dir_server = "globec.whoi.edu/jg/dir"; (defined $dmoname) || ($dmoname = "U.S. GLOBEC"); $top_object_subdir = "/globec"; } else { $info_server = "$myaddr/$jgofs_cgi_root/info"; $dir_server = "$myaddr/$jgofs_cgi_root/dir"; (defined $dmoname) || ($dmoname = "$server_name -- "); $top_object_subdir = "/"; } &use_build_env_conf_val("info_server"); &use_build_env_conf_val("dir_server"); &use_build_env_conf_val("top_object_subdir"); $objdir = $top_object_subdir; &use_build_env_conf_val("background_color"); &use_build_env_conf_val("display_data_url"); (defined $background_color) && &out("BACKGROUND_COLOR",$background_color); (defined $display_data_url) && &out("DISPLAY_DATA_URL",$display_data_url); &use_build_env_conf_val("usedatabase"); &use_build_env_conf_val("info_sources"); &use_build_env_conf_val("info_log_all_sources"); &use_build_env_conf_val("info_log_misses"); &use_build_env_conf_val("info_action_on_data_source_error"); &use_build_env_conf_val("info_action_on_logging_failure"); &use_build_env_conf_val("info_BCODMO_host_port"); &use_build_env_conf_val("info_BCODMO_access_techniques"); &use_build_env_conf_val("info_BCODMO_attempt_all_techniques"); &use_build_env_conf_val("info_remote_traditional_servers"); &use_build_env_conf_val("info_attempt_all_remote_traditional_servers"); (defined $usedatabase) && &out("USEDATABASE",$usedatabase); (defined $usedatabase) && &out("INFO_USEDATABASE",$usedatabase); (defined $info_sources) && &out("INFO_SOURCES",$info_sources); (defined $info_log_all_sources) && &out("INFO_LOG_ALL_SOURCES",$info_log_all_sources); (defined $info_log_misses) && &out("INFO_LOG_MISSES",$info_log_misses); (defined $info_action_on_data_source_error) && &out("INFO_ACTION_ON_DATA_SOURCE_ERROR",$info_action_on_data_source_error); (defined $info_action_on_logging_failure) && &out("INFO_ACTION_ON_LOGGING_FAILURE",$info_action_on_logging_failure); (defined $info_BCODMO_host_port) && &out("INFO_BCO-DMO_HOST_PORT",$info_BCODMO_host_port); (defined $info_BCODMO_access_techniques) && &out("INFO_BCO-DMO_ACCESS_TECHNIQUES",$info_BCODMO_access_techniques); (defined $info_BCODMO_attempt_all_techniques) && &out("INFO_BCO-DMO_ATTEMPT_ALL_TECHNIQUES", $info_BCODMO_attempt_all_techniques); (defined $info_remote_traditional_servers) && &out("INFO_REMOTE_TRADITIONAL_SERVERS",$info_remote_traditional_servers); (defined $info_attempt_all_remote_traditional_servers) && &out("INFO_ATTEMPT_ALL_REMOTE_TRADITIONAL_SERVERS", $info_attempt_all_remote_traditional_servers); &out("INFOSERVER",$info_server); &out("DIRSERVER",$dir_server); &out("OBJDIR",$objdir); &out("DMONAME",$dmoname); if ($opt_prefix) { # # HELPDIR is subdirectory from JGOFSDIR for help documents # HELPADDR is full URL to the location for help documents # $temp = $doc_root; $help_dir && ($temp .= "/$help_dir"); &out("HELPDIR",$temp); $temp = "http://$myaddr"; $help_dir && ($temp .= "/$help_dir"); &out("HELPADDR",$temp); # # TEMPDIR/TEMPADDR are similar but, alas, not same as # HELPDIR/HELPADDR. # TEMPDIR is absolute dir spec to # a temporary directory unique to OOserver on this port # (HELPDIR is a relative directory) # TEMPADDR is URL of that directory, which depends # on TEMPDIR being a subdir of $jgofs_root/$doc_root # (HELPADDR works on same concept) # Note that the soft link from $doc_root/jgofsopt # to top-level /jgofsopt is NOT necessary (but I think # some code accidentally works because of it) # &use_build_env_conf_val("temp_dir"); $temp = "$jgofs_root/$doc_root"; $temp_dir && ($temp .= "/$temp_dir"); &out("TEMPDIR",$temp); $temp = "http://$myaddr"; $temp_dir && ($temp .= "/$temp_dir"); &out("TEMPADDR",$temp); &use_build_env_conf_val("matlabroot"); &use_build_env_conf_val("matlab5root"); &use_build_env_conf_val("matlab65root"); &use_build_env_conf_val("matlab71root"); &use_build_env_conf_val("netcdfroot"); if ($matlabroot) { ($incdir,$libdir) = &do_matlab($matlabroot,$matlab_extern_arch_dir); &out("MATLABINCDIR",$incdir); &out("MATLABLIBDIR",$libdir); } if ($matlab5root) { ($incdir,$libdir) = &do_matlab($matlab5root,$matlab_extern_arch_dir); &out("MATLAB5INCDIR",$incdir); &out("MATLAB5LIBDIR",$libdir); } if ($matlab65root) { ($incdir,$libdir) = &do_matlab($matlab65root,$matlab_extern_arch_dir); &out("MATLAB65INCDIR",$incdir); &out("MATLAB65LIBDIR",$libdir); } if ($matlab71root) { ($incdir,$libdir) = &do_matlab($matlab71root,$matlab_extern_arch_dir); &out("MATLAB71INCDIR",$incdir); &out("MATLAB71LIBDIR",$libdir); } if ($netcdfroot) { ($incdir,$libdir) = &do_netcdf($netcdfroot); &out("NETCDFINCDIR",$incdir); &out("NETCDFLIBDIR",$libdir); } &use_build_env_conf_val("mail_sender"); &use_build_env_conf_val("zip"); &use_build_env_conf_val("cp"); &use_build_env_conf_val("tar"); &use_build_env_conf_val("compress"); &use_build_env_conf_val("gzip"); &out("MAIL_SENDER",$mail_sender); &out("ZIPPROG",$zip); &out("CPPROG",$cp); &out("TARPROG",$tar); &out("UNIXCOMPRESS",$compress); &out("GNUCOMPRESS",$gzip); } # Check that all conf file data were used # The hash is probably always defined, but too lazy to # be exact about this if (defined %build_env_conf) { $nkeys = 0; $msg = "*** Error\n" . "*** Following data defined in $build_env_conf_file " . "but not used by $this_file\n"; foreach (keys(%build_env_conf)) { $nkeys++; # If the string is ACTUALLY defined as "[empty string]", I still # think that the problem can be figured out from the message # Don't see how hash value can be undefined, but the test is really # cheap compared to the mystery if it actually DOES happen (defined ($value = $build_env_conf{$_})) || ($value = "[not defined]"); $value || ($value = "[empty string]"); $msg .= "***\t$_ defined as $value\n"; } ($nkeys == 0) || die $msg; } # Refer to $old_ENV to avoid "only one use" diagnostic (exists $old_ENV{"JGOFSDIR"}) && 1; # Next line sets "status" of file to 1. This game an attempt # to allow this program to be run both standalone and as a # "require"d file. Not sure if it is really necessary 1; } # Next line is so file can be "require"d successfully 1; sub do_matlab # "extern" strings empirically observed and assumed to be constant # for all matlab releases # Fooling with leading and trailing slashes may not be necessary. # In any case, objective is 1) make the cc options -L & -I happy # & 2) make LD_LIBRARY_PATH happy. At minimum, objective should # be to put out a consistent string whether or not user plays with # slashes { my ($root,$suffix) = @_; my ($save_chomp_char); $save_chomp_char = $/; $/ = '/'; chomp $root; chomp $suffix; ($suffix) = ($suffix =~ m"^/?(.*)"); $/ = $save_chomp_char; return "$root/extern/include" , "$root/extern/lib/$suffix"; } sub do_netcdf # See do_matlab comments above # This routine not really needed, but makes a parallel w/matlab... { my ($root) = @_; my ($save_chomp_char); $save_chomp_char = $/; $/ = '/'; chomp $root; $/ = $save_chomp_char; return "$root/include" , "$root/lib"; } sub out { my ($env_var,@env_var_val) = @_; my ($env_var_val); (scalar @env_var_val > 0) || die "No value for env var $env_var\n"; $env_var_val = join (' ',@env_var_val); $sh_out && (print "export $env_var=\"$env_var_val\"\n"); $csh_out && (print "setenv $env_var \"$env_var_val\"\n"); if (defined $defnlist) { $defnlist && ($defnlist .= ","); $defnlist .= $env_var; $ENV{$defnlist_env_var} = $defnlist; } # If we are about to change an env var, save it... but only save # the first one (protects in case this routine for some reason # changes something more than once - we want the "original") if (exists $ENV{$env_var}) { (exists $old_ENV{$env_var}) || ($old_ENV{$env_var} = $ENV{$env_var}); } $ENV{$env_var} = $env_var_val; return; } sub use_build_env_conf_val # Given a string as an argument, check if build_env_conf{string} is defined # Assumes that build_env_conf and $string are global, so only works if # build_env_conf is the name of the hash. Routine will never do anything # if "wrong" hash is in use # If so, set $string to build_env_conf{string} and remove # the build_env_conf entry # If not, do nothing # Return whether build_env_conf{string} existed # Requires a version of perl sufficiently new that $$x works { my ($arg,$dummy) = @_; my $temp; ($arg && ( ! $dummy)) || (die "Internal error. use_build_env_conf_val called w/incorrect args"); if ( $status = (exists $build_env_conf{$arg}) ) { $$arg = $build_env_conf{$arg}; delete $build_env_conf{$arg}; } return $status; }