@ -39,11 +39,11 @@
# SCRIPTS_built -- script files (not binaries) to install into $PREFIX/bin,
# SCRIPTS_built -- script files (not binaries) to install into $PREFIX/bin,
# which need to be built first
# which need to be built first
# HEADERS -- files to install into $(includedir_server)/$MODULEDIR/$MODULE_big
# HEADERS -- files to install into $(includedir_server)/$MODULEDIR/$MODULE_big
# HEADERS_built -- as above but built first
# HEADERS_built -- as above but built first (but NOT cleaned)
# HEADERS_$(MODULE) -- files to install into
# HEADERS_$(MODULE) -- files to install into
# $(includedir_server)/$MODULEDIR/$MODULE; the value of $MODULE must be
# $(includedir_server)/$MODULEDIR/$MODULE; the value of $MODULE must be
# listed in MODULES or MODULE_big
# listed in MODULES or MODULE_big
# HEADERS_built_$(MODULE) -- as above but built first
# HEADERS_built_$(MODULE) -- as above but built first (also NOT cleaned)
# REGRESS -- list of regression test cases (without suffix)
# REGRESS -- list of regression test cases (without suffix)
# REGRESS_OPTS -- additional switches to pass to pg_regress
# REGRESS_OPTS -- additional switches to pass to pg_regress
# NO_INSTALLCHECK -- don't define an installcheck target, useful e.g. if
# NO_INSTALLCHECK -- don't define an installcheck target, useful e.g. if
@ -117,6 +117,8 @@ ifdef PG_CPPFLAGS
override CPPFLAGS : = $( PG_CPPFLAGS ) $( CPPFLAGS )
override CPPFLAGS : = $( PG_CPPFLAGS ) $( CPPFLAGS )
e n d i f
e n d i f
# logic for HEADERS_* stuff
# get list of all names used with or without built_ prefix
# get list of all names used with or without built_ prefix
# note that use of HEADERS_built_foo will get both "foo" and "built_foo",
# note that use of HEADERS_built_foo will get both "foo" and "built_foo",
# we cope with that later when filtering this list against MODULES.
# we cope with that later when filtering this list against MODULES.
@ -128,44 +130,54 @@ HEADER_alldirs := $(patsubst HEADERS_%,%,$(filter HEADERS_%, $(.VARIABLES)))
HEADER_alldirs += $( patsubst HEADERS_built_%,%,$( filter HEADERS_built_%, $( .VARIABLES) ) )
HEADER_alldirs += $( patsubst HEADERS_built_%,%,$( filter HEADERS_built_%, $( .VARIABLES) ) )
# collect all names of built headers to use as a dependency
# collect all names of built headers to use as a dependency
HEADER_allbuilt =
HEADER_allbuilt : =
# HEADERS is an error in the absence of MODULE_big to provide a dir name
i f d e f M O D U L E _ b i g
i f d e f M O D U L E _ b i g
i f d e f H E A D E R S
# we can unconditionally add $(MODULE_big) here, because we will strip it
# back out below if it turns out not to actually define any headers.
HEADER_dirs := $( MODULE_big)
HEADER_dirs := $( MODULE_big)
HEADER_unbuilt_$(MODULE_big) = $( HEADERS)
HEADER_unbuilt_$(MODULE_big) = $( HEADERS)
HEADER_built_$(MODULE_big) = $( HEADERS_built)
HEADER_built_$(MODULE_big) = $( HEADERS_built)
HEADER_allbuilt += $( HEADERS_built)
HEADER_allbuilt += $( HEADERS_built)
e l s e i f d e f H E A D E R S _ b u i l t
# treat "built" as an exclusion below as well as "built_foo"
HEADER_dirs := $( MODULE_big)
HEADER_xdirs := built built_$( MODULE_big)
HEADER_built_$(MODULE_big) = $( HEADERS_built)
HEADER_allbuilt += $( HEADERS_built)
e l s e # not MODULE_big, so check MODULES
e l s e
# file might have used HEADERS_foo or HEADERS_built_foo, so check for those
# HEADERS is an error in the absence of MODULE_big to provide a dir name
HEADER_dirs := $( if $( filter $( MODULE_big) built_$( MODULE_big) ,$( HEADER_alldirs) ) ,$( MODULE_big) )
HEADER_unbuilt_$(MODULE_big) = $( HEADERS_$( MODULE_big) )
HEADER_built_$(MODULE_big) = $( HEADERS_built_$( MODULE_big) )
HEADER_allbuilt += $( HEADERS_built_$( MODULE_big) )
e n d i f
e l s e
i f d e f H E A D E R S
i f d e f H E A D E R S
$( error HEADERS requires MODULE_big to be set )
$( error HEADERS requires MODULE_big to be set )
e n d i f
e n d i f
# make list of modules that have either HEADERS_foo or HEADERS_built_foo
# make list of modules that have either HEADERS_foo or HEADERS_built_foo
HEADER_dirs := $( foreach m,$( MODULES) ,$( if $( filter $( m) built_$( m) ,$( HEADER_alldirs) ) ,$( m) ) )
HEADER_dirs := $( foreach m,$( MODULES) ,$( if $( filter $( m) built_$( m) ,$( HEADER_alldirs) ) ,$( m) ) )
# make list of conflicting names to exclude
HEADER_xdirs := $( addprefix built_,$( HEADER_dirs) )
e n d i f # MODULE_big or MODULES
# HEADERS_foo requires that "foo" is in MODULES as a sanity check
i f n e q ( , $( filter -out $ ( HEADER_dirs ) $ ( HEADER_xdirs ) ,$ ( HEADER_alldirs ) ) )
$( error $ ( patsubst %,HEADERS_ %,$ ( filter -out $ ( HEADER_dirs ) $ ( HEADER_xdirs ) ,$ ( HEADER_alldirs ) ) ) defined with no module )
e n d i f
# assign HEADER_unbuilt_foo and HEADER_built_foo, but make sure
# assign HEADER_unbuilt_foo and HEADER_built_foo, but make sure
# that "built" takes precedence in the case of conflict, by removing
# that "built" takes precedence in the case of conflict, by removing
# conflicting module names when matching the unbuilt name
# conflicting module names when matching the unbuilt name
$( foreach m ,$ ( filter -out $ ( addprefix built_ ,$ ( MODULES ) ) ,$ ( MODULES ) ) ,$ ( eval HEADER_unbuilt_ $ ( m ) = $ $ ( HEADERS_ $ ( m ) ) ) )
$( foreach m ,$ ( filter -out $ ( HEADER_xdirs ) ,$ ( HEADER_dirs ) ) ,$ ( eval HEADER_unbuilt_ $ ( m ) += $ $ ( HEADERS_ $ ( m ) ) ) )
$( foreach m ,$ ( MODULES ) ,$ ( eval HEADER_built_ $ ( m ) = $ $ ( HEADERS_built_ $ ( m ) ) ) )
$( foreach m ,$ ( HEADER_dirs ) ,$ ( eval HEADER_built_ $ ( m ) += $ $ ( HEADERS_built_ $ ( m ) ) ) )
$( foreach m ,$ ( MODULES ) ,$ ( eval HEADER_allbuilt += $ $ ( HEADERS_built_ $ ( m ) ) ) )
$( foreach m ,$ ( HEADER_dirs ) ,$ ( eval HEADER_allbuilt += $ $ ( HEADERS_built_ $ ( m ) ) ) )
e n d i f
# HEADERS_foo requires that "foo" is in MODULES as a sanity check
# expand out the list of headers for each dir, attaching source prefixes
i f n e q ( $( filter -out $ ( HEADER_dirs ) $ ( addprefix built_ ,$ ( HEADER_dirs ) ) ,$ ( HEADER_alldirs ) ) , )
header_file_list = $( HEADER_built_$( 1) ) $( addprefix $( srcdir) /,$( HEADER_unbuilt_$( 1) ) )
$( error $ ( patsubst %,HEADERS_ %,$ ( filter -out $ ( HEADER_dirs ) $ ( addprefix built_ ,$ ( HEADER_dirs ) ) ,$ ( HEADER_alldirs ) ) ) defined with no module )
$(foreach m,$(HEADER_dirs),$(eval HEADER_files_$(m) : = $$( call header_file_list ,$ $ ( m ) ) ))
e n d i f
# note that the caller's HEADERS* vars have all been expanded now, and
# later changes will have no effect.
# remove entries in HEADER_dirs that produced an empty list of files,
# to ensure we don't try and install them
HEADER_dirs := $( foreach m,$( HEADER_dirs) ,$( if $( strip $( HEADER_files_$( m) ) ) ,$( m) ) )
# Functions for generating install/uninstall commands; the blank lines
# Functions for generating install/uninstall commands; the blank lines
# before the "endef" are required, don't lose them
# before the "endef" are required, don't lose them
@ -181,6 +193,8 @@ rm -f $(addprefix '$(DESTDIR)$(includedir_server)/$(incmoduledir)/$(1)'/, $(notd
e n d e f
e n d e f
# end of HEADERS_* stuff
all : $( PROGRAM ) $( DATA_built ) $( HEADER_allbuilt ) $( SCRIPTS_built ) $( addsuffix $ ( DLSUFFIX ) , $ ( MODULES ) ) $( addsuffix .control , $ ( EXTENSION ) )
all : $( PROGRAM ) $( DATA_built ) $( HEADER_allbuilt ) $( SCRIPTS_built ) $( addsuffix $ ( DLSUFFIX ) , $ ( MODULES ) ) $( addsuffix .control , $ ( EXTENSION ) )
@ -228,9 +242,8 @@ endif # SCRIPTS
i f d e f S C R I P T S _ b u i l t
i f d e f S C R I P T S _ b u i l t
$( INSTALL_SCRIPT) $( SCRIPTS_built) '$(DESTDIR)$(bindir)/'
$( INSTALL_SCRIPT) $( SCRIPTS_built) '$(DESTDIR)$(bindir)/'
e n d i f # SCRIPTS_built
e n d i f # SCRIPTS_built
i f n e q ( $( strip $ ( HEADER_dirs ) ) , )
i f n e q ( , $( strip $ ( HEADER_dirs ) ) )
$( foreach dir,$( HEADER_dirs) ,$( if $( HEADER_unbuilt_$( dir) ) ,$( call install_headers,$( dir) ,$( addprefix $( srcdir) /, $( HEADER_unbuilt_$( dir) ) ) ) ) )
$( foreach dir,$( HEADER_dirs) ,$( call install_headers,$( dir) ,$( HEADER_files_$( dir) ) ) )
$( foreach dir,$( HEADER_dirs) ,$( if $( HEADER_built_$( dir) ) ,$( call install_headers,$( dir) ,$( HEADER_built_$( dir) ) ) ) )
e n d i f # HEADERS
e n d i f # HEADERS
i f d e f M O D U L E _ b i g
i f d e f M O D U L E _ b i g
i f e q ( $( with_llvm ) , y e s )
i f e q ( $( with_llvm ) , y e s )
@ -296,8 +309,8 @@ endif
i f d e f S C R I P T S _ b u i l t
i f d e f S C R I P T S _ b u i l t
rm -f $( addprefix '$(DESTDIR)$(bindir)' /, $( SCRIPTS_built) )
rm -f $( addprefix '$(DESTDIR)$(bindir)' /, $( SCRIPTS_built) )
e n d i f
e n d i f
i f n e q ( $( strip $ ( HEADER_dirs ) ) , )
i f n e q ( , $( strip $ ( HEADER_dirs ) ) )
$( foreach dir,$( HEADER_dirs) ,$( call uninstall_headers,$( dir) ,$( HEADER_unbuilt_$( dir) ) $( HEADER_built _$( dir) ) ) )
$( foreach dir,$( HEADER_dirs) ,$( call uninstall_headers,$( dir) ,$( HEADER_files _$( dir) ) ) )
e n d i f # HEADERS
e n d i f # HEADERS
i f d e f M O D U L E _ b i g
i f d e f M O D U L E _ b i g