From e894fac200892232cda15e013c5cfbdcf5f90ef5 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 21 Sep 2009 11:24:01 -0300 Subject: [PATCH] Generalize function find_headers (now find_files) Make find_headers function more generic. Rename it to find_files and allow omitting the second argument, defaulting to the third argument. --- Lib.mak | 13 ++++++++----- lib1/Build.mak | 2 +- lib2/Build.mak | 2 +- subproj/Build.mak | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Lib.mak b/Lib.mak index f84d288..1e09736 100644 --- a/Lib.mak +++ b/Lib.mak @@ -94,11 +94,14 @@ eq = $(if $(subst $1,,$2),,$1) find_objects = $(patsubst $T/%.$1,$O/%.o,$(shell \ find $(if $2,$2,$C) -name '*.$1')) -# Find sources files and get the corresponding object names -# The first argument should be the sources extension ("c" or "cpp" typically) -# It expects the variable $T and $O to be defined as commented previously in -# this file. -find_headers = $(patsubst $C/%.$1,$2/%.$1,$(shell find $C -name '*.$1')) +# Find files and get the their file names relative to another directory. The +# first argument should be the files suffix (".h" or ".cpp" for example). The +# second argument is a directory rewrite, the matched files will be rewriten to +# be in the directory specified in this argument (it defaults to the third +# argument if omitted). The third argument is where to search for the files +# ($C if omitted). +find_files = $(patsubst $(if $3,$3,$C)/%$1,$(if $2,$2,$(if $3,$3,$C))/%$1, \ + $(shell find $(if $3,$3,$C) -name '*$1')) # Abbreviate a file name. Cut the leading part of a file if it match to the $T # directory, so it can be displayed as if it were a relative directory. Take diff --git a/lib1/Build.mak b/lib1/Build.mak index 298a88e..356f07b 100644 --- a/lib1/Build.mak +++ b/lib1/Build.mak @@ -13,5 +13,5 @@ install += $I/lib/liblib1.so # Install the library's headers # XXX: we can't use += here, call will be resolved lazily if we do -install := $(install) $(call find_headers,h,$I/include/makeit/lib1) +install := $(install) $(call find_files,.h,$I/include/makeit/lib1) diff --git a/lib2/Build.mak b/lib2/Build.mak index 4f201de..893f8f7 100644 --- a/lib2/Build.mak +++ b/lib2/Build.mak @@ -13,5 +13,5 @@ install += $I/lib/liblib2.so # Install the library's headers # XXX: we can't use += here, call will be resolved lazily if we do -install := $(install) $(call find_headers,h,$I/include/makeit/lib2) +install := $(install) $(call find_files,.h,$I/include/makeit/lib2) diff --git a/subproj/Build.mak b/subproj/Build.mak index 2d3f120..f9de53f 100644 --- a/subproj/Build.mak +++ b/subproj/Build.mak @@ -33,7 +33,7 @@ otherproj: $L/libotherproj.so $I/include/otherproj/%.h: $C/%.h $(call install_file) # XXX: we can't use += here, call will be resolved lazily if we do -install := $(install) $(call find_headers,h,$I/include/otherproj) +install := $(install) $(call find_files,.h,$I/include/otherproj) # Create the include directory symbolic link and pkg-config flags file setup_include_dir__ := $(call symlink_include_dir,otherproj) -- 2.43.0