(file) Return to customizedefs.pl CVS log (file) (dir) Up to [Development] / JSOC

  1 arta  1.1 #!/usr/bin/perl -w 
  2           
  3           use constant kSTATUSOK => 0;
  4           use constant kSTATUSCONF => 1;
  5           
  6           use constant kUNKSECTION => 0;
  7           use constant kDEFSSECTION => 1;
  8           use constant kMAKESECTION => 2;
  9           
 10           use constant kCONFIGFILE => "config.local";
 11 arta  1.2 use constant kHEADER => "base/include/customizeddefs.h";
 12 arta  1.1 
 13           my($line);
 14           my($section);
 15           my($status);
 16           my(@defs);
 17           my(%defines);
 18           my($adef);
 19           my($defname);
 20           my($val);
 21           my($tmp);
 22           
 23           $status = kSTATUSOK;
 24           
 25           # create hash table to hold all customizable define names
 26 arta  1.7 @defs = qw(SERVER DRMS_LOCAL_SITE_CODE USER PASSWD DBNAME DRMSPGPORT POSTGRES_ADMIN SUMS_MANAGER SUMS_MANAGER_UID SUMS_GROUP SUMLOG_BASEDIR SUMBIN_BASEDIR SUMSERVER SUMPGPORT SUM_NUMSUM SUM_MAXNUMSUM SUMS_TAPE_AVAILABLE SUMS_MULTIPLE_PARTNSETS AUTOSELCOMP LOC_SUMEXP_METHFMT LOC_SUMEXP_USERFMT LOC_SUMEXP_HOSTFMT LOC_SUMEXP_PORTFMT PRODUSER_DBHOST PRODUSER_DBNAME 
 27               PRODUSER_PRODTAB PRODUSER_COLUSER);
 28 arta  1.1 foreach $adef (@defs)
 29           {
 30              $defines{$adef} = 1;
 31           }
 32           
 33           $section = kUNKSECTION;
 34           $tmp = kCONFIGFILE;
 35           if (open(CONFLOC, "<$tmp"))
 36           {
 37              $tmp = kHEADER;
 38              if (!open(HEADER, ">$tmp"))
 39              {
 40                 print STDERR "Can't open file '$tmp' for writing.\n"
 41              }
 42              else
 43              {
 44                 while (defined($line = <CONFLOC>))
 45                 {
 46                    chomp($line);
 47           
 48                    if ($line =~ /^\#/ || $line =~ /^\s*$/)
 49 arta  1.1          {
 50                       next;
 51                    }
 52           
 53                    if ($line =~ /__DEFS__/)
 54                    {
 55                       $section = kDEFSSECTION;
 56                       next;
 57                    }
 58                    elsif ($line =~ /__MAKE__/)
 59                    {
 60                       $section = kMAKESECTION;
 61                       next;
 62                    }
 63           
 64                    if ($section == kDEFSSECTION)
 65                    {
 66                       $val = "";
 67           
 68                       if ($line =~ /^\s*(\S+)\s+(\S+.*)/)
 69                       {
 70 arta  1.1                $defname = $1;
 71                          $val = $2;
 72                       }
 73                       elsif ($line =~ /^\s*(\S+)\s*/)
 74                       {
 75                          $defname = $1;
 76                       }
 77                       else
 78                       {
 79                          print STDERR "Invalid line '$line' in configuration file.\n";
 80                          $status = kSTATUSCONF;
 81                          last;
 82                       }
 83           
 84                       if (defined($defines{$defname}))
 85                       {
 86                          if (length($val) > 0)
 87                          {
 88 arta  1.5                   print HEADER "#ifdef $defname\n  #undef $defname\n#endif\n#define $defname $val\n";
 89 arta  1.1                }
 90                          else
 91                          {
 92 arta  1.5                   print HEADER "#ifdef $defname\n  #undef $defname\n#endif#define $defname\n";
 93 arta  1.1                }
 94                       }
 95                       else
 96                       {
 97                          print STDERR "Invalid parameter '$defname'.\n";
 98                          $status = kSTATUSCONF;
 99                          last;
100                       }
101                    }
102                    elsif ($section == kMAKESECTION)
103                    {
104                       # Done - use customizemake.pl to create the custom.mk file from config.local
105                       last;
106                    }
107                    else
108                    {
109                       print STDERR "Invalid configuration file format.\n";
110                       $status = kSTATUSCONF;
111                    }
112                 }
113           
114 arta  1.1       close(HEADER);
115              }
116           
117              close(CONFLOC);
118           }
119           
120           exit($status);

Karen Tian
Powered by
ViewCVS 0.9.4