Skip to content
Snippets Groups Projects
Commit 4730c381 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

COMP: avoid cpp replacement of linux,unix,... in Make/options (fixes #2548)

- the cpp command is used to process Make/{files,options}, but builtin
  defines such as `linux` will cause problems (macro replacement) if
  these is present in the Make/{files,options}.

  Solve by undefining -Ulinux, -Uunix macros, which will leave directory
  names such as "/usr/lib/x86_64-linux-gnu/..." intact.

  Directories with _linux, __linux__ content (for example), could
  still pose future issues.
parent 7ea185b0
Branches
Tags
No related merge requests found
......@@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2018-2020 OpenCFD Ltd.
# Copyright (C) 2018-2022 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
......@@ -47,16 +47,31 @@ WM_SCRIPTS = $(WM_DIR)/scripts
# Causes all derived files to be remade if any are changed or missing
#------------------------------------------------------------------------------
# Process 'Make/{files,options}' via cpp, but undefine linux,unix,... to avoid
# inadvertent replacements (Eg, leave /usr/lib/x86_64-linux-gnu/... intact)
define PREFILTER_MAKE_OPTIONS
@$(CPP) -Ulinux -Uunix $(GFLAGS) $1 | sed -e 's@ *@ @g' > $2
endef
all : $(OPTIONS) $(SFILES) $(VARS)
# Make/options
# ~~~~~~~~~~~~
$(OPTIONS) : $(MAKE_DIR)/options
@$(CPP) $(GFLAGS) $(MAKE_DIR)/options | sed -e 's@ *@ @g' > $(OPTIONS)
$(call PREFILTER_MAKE_OPTIONS,$<,${OPTIONS})
ifneq (,$(findstring windows,$(WM_OSTYPE)))
@$(WM_SCRIPTS)/wmakeWindowsDlOpenLibs $(OPTIONS) >> $(OPTIONS)
endif
# Ensure final line is followed by newline. Extra comment for safety.
@echo >> $(OPTIONS)
@echo "# options" >> $(OPTIONS)
# Make/files
# ~~~~~~~~~~
$(SFILES): $(MAKE_DIR)/files
@$(CPP) $(GFLAGS) $(MAKE_DIR)/files | sed -e 's@ *@ @g' > $(FILES)
$(call PREFILTER_MAKE_OPTIONS,$<,${FILES})
# Extracted macro definitions.
@sed -n -e '/=/p' $(FILES) > $(VARS)
@echo "SOURCE = \\" > $(SFILES)
......@@ -64,7 +79,7 @@ $(SFILES): $(MAKE_DIR)/files
@sed -e '/=/d; /^#/d; /^[ \t]*$$/d' -e 's@[ \t]*$$@ \\@' $(FILES) >> $(SFILES)
@rm -f $(FILES)
# Ensure final line is followed by newline. Extra comment for safety.
@echo "" >> $(SFILES)
@echo >> $(SFILES)
@echo "# sources" >> $(SFILES)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment