Skip to content

Commit

Permalink
Use Perl for filtering MAKEFLAGS properly
Browse files Browse the repository at this point in the history
Requires moving the checkflags code into CONFIG_BASE
as that's where FIND_TOOL gets defined.

Fixes epics-base#545
  • Loading branch information
anjohnson committed Sep 3, 2024
1 parent 052a0c7 commit 579906a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
19 changes: 19 additions & 0 deletions configure/CONFIG_BASE
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ PODTOHTML_pl = $(TOOLS)/podToHtml.pl
PODTOHTML_dep = $(PODTOHTML_pl) $(call FIND_PM,EPICS/PodHtml.pm)
PODTOHTML = $(PERL) $(PODTOHTML_pl)
CONVERTRELEASE = $(PERL) $(call FIND_TOOL,convertRelease.pl)
FILTERMAKEFLAGS = $(PERL) $(call FIND_TOOL,filterMakeflags.pl)
FULLPATHNAME = $(PERL) $(TOOLS)/fullPathName.pl
GENVERSIONHEADER = $(PERL) $(TOOLS)/genVersionHeader.pl $(QUIET_FLAG) $(QUESTION_FLAG)

Expand All @@ -65,6 +66,24 @@ INSTALL_LIBRARY = $(INSTALL)
MKMF = $(PERL) $(TOOLS)/mkmf.pl
REPLACEVAR = $(PERL) $(TOOLS)/replaceVAR.pl

#---------------------------------------------------------------
# How to portably check the flags to make
# GNUmake versions before 4.0 gave different values
makeflags := $(shell $(FILTERMAKEFLAGS) $(MAKEFLAGS))
define checkflags
make-$1 := $(findstring $1,$(makeflags))
endef
# This is extensible to most single letter flags:
$(foreach flag,s q, $(eval $(call checkflags,$(flag))))

# Silent builds - suppress messages during 'make -s'
NOP = :
ECHO = @$(if $(make-s),$(NOP),echo)
QUIET_FLAG := $(if $(make-s),-q,)

# Convert 'make -q' flag into '-i' for genVersionHeader.pl
QUESTION_FLAG := $(if $(make-q),-i,)

#---------------------------------------------------------------
# tools for cleaning out unwanted files
CVSCLEAN = $(call FIND_TOOL,cvsclean.pl)
Expand Down
17 changes: 0 additions & 17 deletions configure/CONFIG_COMMON
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,6 @@ FINAL_LOCATION = $(INSTALL_ABSOLUTE)
# IOC's view of install path
IOCS_APPL_TOP = $(INSTALL_ABSOLUTE)

#-------------------------------------------------------
# How to portably check the flags to make
makeflags := $(firstword $(filter-out -,$(filter-out --%,$(MAKEFLAGS))))
define checkflags
make-$1 := $(findstring $1,$(makeflags))
endef
# This is extensible to most single letter flags:
$(foreach flag,s q, $(eval $(call checkflags,$(flag))))

# Silent builds - suppress messages during 'make -s'
NOP = :
ECHO = @$(if $(make-s),$(NOP),echo)
QUIET_FLAG := $(if $(make-s),-q,)

# Convert 'make -q' flag into '-i' for genVersionHeader.pl
QUESTION_FLAG := $(if $(make-q),-i,)

#-------------------------------------------------------
ifdef T_A

Expand Down
1 change: 1 addition & 0 deletions src/tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ PERL_SCRIPTS += depclean.pl
PERL_SCRIPTS += dos2unix.pl
PERL_SCRIPTS += epicsProve.pl
PERL_SCRIPTS += expandVars.pl
PERL_SCRIPTS += filterMakeflags.pl
PERL_SCRIPTS += fullPathName.pl
PERL_SCRIPTS += installEpics.pl
PERL_SCRIPTS += makeAPIheader.pl
Expand Down
15 changes: 15 additions & 0 deletions src/tools/filterMakeflags.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/env perl
#
# Filter all versions of GNU Make's MAKEFLAGS variable to return
# only the single-letter flags. The content differed slightly
# between 3.81, 3.82 and 4.0; Apple still ship 3.81.

use strict;

my @flags;
foreach (@ARGV) {
last if m/^--$/ or m/\w+=/;
next if m/^--/ or m/^-$/;
push @flags, $_;
};
print join(' ', @flags);

0 comments on commit 579906a

Please sign in to comment.