+ # Helper function to deal with inclusion directory specs.
+ # We have to deal with two things:
+ # 1. comma separation and no possibility of trailing comma
+ # 2. no inclusion directories given at all
+ # 3. long compiler command lines
+ # To resolve 1, we need to iterate through the sources of inclusion
+ # directories, and only add a comma when needed.
+ # To resolve 2, we need to have a variable that will hold the whole
+ # inclusion qualifier, or be the empty string if there are no inclusion
+ # directories. That's the symbol 'qual_includes' that's used in CPPFLAGS
+ # To resolve 3, we creata a logical name TMP_INCLUDES: to hold the list
+ # of inclusion directories.
+ #
+ # This function returns a list of two lists, one being the collection of
+ # commands to execute before the compiler is called, and the other being
+ # the collection of commands to execute after. It takes as arguments the
+ # collection of strings to include as directory specs.
+ sub includes {
+ my @stuff = ( @_ );
+ my @before = (
+ 'qual_includes :=',
+ );
+ my @after = (
+ 'DELETE/SYMBOL/LOCAL qual_includes',
+ );
+
+ if (scalar @stuff > 0) {
+ push @before, 'tmp_includes := '.shift(@stuff);
+ while (@stuff) {
+ push @before, 'tmp_add := '.shift(@stuff);
+ push @before, 'IF tmp_includes .NES. "" .AND. tmp_add .NES. "" THEN tmp_includes = tmp_includes + ","';
+ push @before, 'tmp_includes = tmp_includes + tmp_add';
+ }
+ push @before, "IF tmp_includes .NES. \"\" THEN DEFINE tmp_includes 'tmp_includes'";
+ push @before, 'IF tmp_includes .NES. "" THEN qual_includes := /INCLUDE=(tmp_includes:)';
+ push @before, 'DELETE/SYMBOL/LOCAL tmp_includes';
+ push @before, 'DELETE/SYMBOL/LOCAL tmp_add';
+ push @after, 'DEASSIGN tmp_includes:'
+ }
+ return ([ @before ], [ @after ]);
+ }
+