summaryrefslogtreecommitdiff
path: root/lib/sbin/BuildHeaders.pl
diff options
context:
space:
mode:
authorallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-09-14 11:28:07 +0000
committerallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-09-14 11:28:07 +0000
commitb795cd7ea7f76e91f5b3af302db9b1fb9fe75948 (patch)
tree895e3136b8b05948df072370dc68135cfc09447f /lib/sbin/BuildHeaders.pl
parenta14d954ee3284df8b7566cfbc957ecf8d22daf07 (diff)
The routine to build the dynamic include files
git-svn-id: http://svn.cactuscode.org/flesh/trunk@913 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/BuildHeaders.pl')
-rw-r--r--lib/sbin/BuildHeaders.pl123
1 files changed, 123 insertions, 0 deletions
diff --git a/lib/sbin/BuildHeaders.pl b/lib/sbin/BuildHeaders.pl
new file mode 100644
index 00000000..f1fda254
--- /dev/null
+++ b/lib/sbin/BuildHeaders.pl
@@ -0,0 +1,123 @@
+#! /usr/bin/perl -s
+
+#/*@@
+# @routine BuildHeaders
+# @date Sun 13 Sep 1999
+# @author Gabrielle Allen
+# @desc
+# Creates the dynamic header files requested in interface.ccl files
+# and writes them into the Bindings include directory
+# @enddesc
+# @calls
+# @calledby
+# @history
+# @endhistory
+#@@*/
+
+
+sub BuildHeaders
+{
+ local($cctk_home,$bindings_dir,%database) = @_;
+ local($start_dir,$thorn,$inc_file,$inc_file1,$inc_file2);
+
+ $start_dir = `pwd`;
+ chdir $bindings_dir;
+ chdir include;
+
+# First delete all global include files since we will be appending
+ foreach $thorn (split(" ",$interface_database{"THORNS"}))
+ {
+ foreach $inc_file (split(" ",$interface_database{"\U$thorn USES HEADER"}))
+ {
+ if (-e $inc_file)
+ {
+ system("rm $inc_file");
+ }
+ }
+ }
+
+# Create all the global include files used by thorns
+ foreach $thorn (split(" ",$interface_database{"THORNS"}))
+ {
+ foreach $inc_file (split(" ",$interface_database{"\U$thorn USES HEADER"}))
+ {
+ if (!-e $inc_file)
+ {
+ open(OUT,">$inc_file") || die "Cannot open $inc_dir";
+ print OUT "/* Include file $inc_file used by $thorn */\n";
+ close OUT;
+ }
+ else
+ {
+ open(OUT,">>$inc_file") || die "Cannot open $inc_dir";
+ print OUT "/* Include file $inc_file used by $thorn */\n";
+ close OUT;
+ }
+ }
+ }
+
+# Add the local headers from thorns
+ foreach $thorn (split(" ",$interface_database{"THORNS"}))
+ {
+
+ $arrangement = $interface_database{"\U$thorn ARRANGEMENT"};
+
+ foreach $inc_file1 (split(" ",$interface_database{"\U$thorn ADD HEADER"}))
+ {
+ if ($inc_file1 !~ /^\s*$/)
+ {
+ $inc_file1 =~ s/ //g;
+ $inc_file2 = $interface_database{"\U$thorn ADD HEADER $inc_file1 TO"};
+
+ # Check the global include file is already there
+ if (! -e $inc_file2)
+ {
+ $message = "No thorn requires $inc_file2 written to by $thorn\n";
+ &CST_error(2,$message,__LINE__,__FILE__);
+ }
+ else
+ {
+ # Write information to the global include file
+ open(OUT,">>$inc_file2") || die "Cannot open $inc_dir2";
+ print OUT "/* Including file $inc_file1 from $thorn */\n";
+
+ # Now have to find the include file and copy it
+ if (-e "$cctk_home/arrangements/$arrangement/$thorn/src/$inc_file1")
+ {
+ open(HEADER,"<$cctk_home/arrangements/$arrangement/$thorn/src/$inc_file1");
+ while (<HEADER>)
+ {
+ print OUT;
+ }
+ print OUT "\n\n\n";
+ close HEADER;
+ }
+ elsif (-e "$cctk_home/arrangements/$arrangement/$thorn/src/include/$inc_file1")
+ {
+ open(HEADER,"<$cctk_home/arrangements/$arrangement/$thorn/src/$inc_file1");
+ while (<HEADER>)
+ {
+ print OUT;
+ }
+ print OUT "\n\n\n";
+ close HEADER;
+ }
+ else
+ {
+ $message = "Include file $inc_file1 not found in $arrangement/$thorn\n";
+ &CST_error(0,$message,__LINE__,__FILE__);
+ }
+ print OUT "/* End of include file $inc_file1 from $thorn */\n";
+ close OUT;
+ }
+ }
+ }
+ }
+
+ chdir $start_dir;
+ return;
+
+}
+
+1;
+