+ # $def_cppflags_fortify[0] must be -D_FORTIFY_SOURCE=2!
+ my $fortify_source = $def_cppflags_fortify[0];
+
+ # Some build systems enable/disable fortify source multiple times, check
+ # the final result.
+ my $disable_pos = 0;
+ foreach my $flag (@def_cppflags_fortify_bad) {
+ while ($line =~ /$flag/g) {
+ if ($disable_pos < $+[0]) {
+ $disable_pos = $+[0];
+ }
+ }
+ }
+ my $enable_pos = 0;
+ while ($line =~ /$fortify_source/g) {
+ $enable_pos = $+[0];
+ }
+ if ($enable_pos > $disable_pos) {
+ return 0;
+ }
+
+ push @{$missing_flags}, $fortify_source;
+ return 1;