The list of source files compile can now be specified either as a simple list of
files in Make/files e.g.
adjointOutletPressure/adjointOutletPressureFvPatchScalarField.C
adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.C
adjointShapeOptimizationFoam.C
EXE = $(FOAM_APPBIN)/adjointShapeOptimizationFoam
or directly as the SOURCE entry which is used in the Makefile:
SOURCE = \
adjointOutletPressure/adjointOutletPressureFvPatchScalarField.C \
adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.C \
adjointShapeOptimizationFoam.C
EXE = $(FOAM_APPBIN)/adjointShapeOptimizationFoam
In both cases the Make/files is first parsed by cpp to handle #if, #ifdef
etc. directives but in the latter form gmake directives like ifeq can be also be
used to optionally select files to compile, typically using
SOURCE += anotherFile.C
statements.
81 lines
3.2 KiB
Plaintext
81 lines
3.2 KiB
Plaintext
#----------------------------*- makefile-gmake -*------------------------------
|
|
# ========= |
|
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
# \\ / O peration | Website: https://openfoam.org
|
|
# \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
|
# \\/ M anipulation |
|
|
#------------------------------------------------------------------------------
|
|
# License
|
|
# This file is part of OpenFOAM.
|
|
#
|
|
# OpenFOAM is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
# for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# File
|
|
# wmake/makefiles/files
|
|
#
|
|
# Description
|
|
# A Makefile for the 'options' and 'files' files, used by wmake
|
|
#
|
|
#------------------------------------------------------------------------------
|
|
|
|
GENERAL_RULES = $(WM_DIR)/rules/General
|
|
include $(GENERAL_RULES)/general
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
# Declare names of make system control files derived from file 'files'
|
|
#------------------------------------------------------------------------------
|
|
|
|
OBJECTS_DIR = $(MAKE_DIR)/$(WM_OPTIONS)
|
|
OPTIONS = $(OBJECTS_DIR)/options
|
|
FILES = $(OBJECTS_DIR)/files
|
|
|
|
-include $(OPTIONS)
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
# Declare dependency of all make system files on FILES
|
|
# Causes all derived files to be remade if any are changed or missing
|
|
#------------------------------------------------------------------------------
|
|
|
|
all : $(OPTIONS) $(FILES)
|
|
|
|
$(OPTIONS) : $(MAKE_DIR)/options
|
|
@$(CPP) $(GFLAGS) $(MAKE_DIR)/options | sed -e 's@ *@ @g' > $(OPTIONS)
|
|
|
|
ifeq ($(shell grep "SOURCE" $(MAKE_DIR)/files),)
|
|
# List of source files format supporting cpp conditionals
|
|
$(FILES): $(MAKE_DIR)/files
|
|
@$(CPP) $(GFLAGS) $(MAKE_DIR)/files | sed -e 's@ *@ @g' \
|
|
> $(OBJECTS_DIR)/cppdFiles
|
|
# Create a grep pattern from the source file suffix list
|
|
@echo $(SUFFIXES) | sed -e "s/\([a-zA-Z]\) \./\1\\\|./g" -e "s/\./\\\./g" \
|
|
> $(OBJECTS_DIR)/suffixPattern
|
|
# Use the suffix pattern to find all non source file lines in files
|
|
@grep -v -f $(OBJECTS_DIR)/suffixPattern $(OBJECTS_DIR)/cppdFiles > $(FILES)
|
|
# Use the suffix pattern to create the SOURCE entry from the source files
|
|
@echo "SOURCE = \\" >> $(FILES)
|
|
@grep -f $(OBJECTS_DIR)/suffixPattern $(OBJECTS_DIR)/cppdFiles \
|
|
| sed -e 's,$$, \\,' -e '$$s,\\,,' >> $(FILES)
|
|
# Remove the temporary cpp'd files file
|
|
@rm -f $(OBJECTS_DIR)/cppdFiles
|
|
else
|
|
# SOURCE declaration format supporting gmake conditionals
|
|
$(FILES): $(MAKE_DIR)/files
|
|
@$(CPP) $(GFLAGS) $(MAKE_DIR)/files | sed -e 's@ *@ @g' > $(FILES)
|
|
endif
|
|
|
|
|
|
#------------------------------------------------------------------------------
|