Dear Roland,
Thank you for your email.
I followed your suggestion, including the modification of
. if empty (${${_var_}}:M__nonexistent__) ->
. if empty(${var}:M__nonexistent)
I also run full bmake run from a local package I created whose Makefile rectites "pre-configure: copy-base-pkgconfig"
I obtained "bmake[1]: "/var/pkgsrc/pkgsrc-2022Q1/local/
copy-base-pkgconfig.mk" line 6: autoreconf autoconf automake gmake pkg-config" in the output seemingly as the result of ".info ${USE_TOOLS:Uundefined}".
However, the code still failed to loop on any items in BUILTIN_FIND_PKGCONFIG_FILES_VAR.
Best regards,
Yosuke
Am 13.06.2022 um 04:27 schrieb Yosuke Kawasaki:
> Hello all,
>
> I am trying to make a makefile fragment like below to manage the copying of
> system-provided pkg-config.pc files into {WRKDIR}/.buildlink/lib/pkgconfig
>
>>> (code)
> BUILTIN_FIND_PKGCONFIG_FILES_VAR+= LIBSELINUX
> BUILTIN_FIND_PKGCONFIG_FILES.LIBSELINUX= libselinux.pc
>
> .include "../../mk/buildlink3/find-pkgconfig-files.mk"
> .PHONY: copy-base-pkgconfig
> copy-base-pkgconfig:
If you want to save a line of code, you can write:
copy-base-pkgconfig: .PHONY
During development, you can test whether USE_TOOLS already contains the
word pkg-config:
.info ${USE_TOOLS:Uundefined}
.if !empty(USE_TOOLS:Mpkg-config)
The point is that the '.if' condition is evaluated when the makefile
fragment is parsed, which may be earlier than the line
'USE_TOOLS+=pkg-config'.
> .if !empty(USE_TOOLS:Mpkg-config)
> # ${RUN} ${ECHO}
> "BUILTIN_FIND_PKGCONFIG_FILES_VAR=${BUILTIN_FIND_PKGCONFIG_FILES_VAR}"
> . for _var_ in ${BUILTIN_FIND_PKGCONFIG_FILES_VAR}
Having underscores in the variable name is the traditional form. Since
2009 they are no longer required. You can simply use 'var' instead.
> ${RUN} ${ECHO} "Copying base pkgconfig ${_var_}. ${${_var_}}"
> . if empty (${${_var_}}:M__nonexistent__)
The function 'empty' is a little tricky. It requires the _name_ of a
variable, plus optional modifiers. Instead, you are passing the _value_
here, testing whether the variable named
'/usr/lib/pkg-config/library.pc' contains the word '__nonexistent__'.
You need to remove one pair of braces, and you can remove the space
after 'empty':
. if empty(${var}:M__nonexistent)
> ${RUN} ${CP} ${${_var_}} ${WRKDIR}/.buildlink/lib/pkgconfig/
The above line should be indented with a tab. I guess this is just a
copy-and-paste mistake since otherwise bmake would have complained.
> . endif
> . endfor
> .endif
>
>>> (end of code)
>
> When I ran bmake copy-base-pkgconfig, the for loop does not run at all (no
Running a helper target directly often does not work, as the pkgsrc
infrastructure has some tricky parts that rely on running nested 'bmake'
instances.
To get realistic results, you should make your test package as small and
fast as possible, so that you can test 'pre-configure:
copy-base-pkgconfig' in the environment where it will later be used.
> echo results), even though I confirmed BUILTIN_FIND_PKGCONFIG_FILES_VAR
> contains LIBSELINUX, by running bmake show-var
> VARNAME=BUILTIN_FIND_PKGCONFIG_FILES_VAR
During debugging, you can edit find-pkgconfig-files.mk and insert the
following directives:
.MAKEFLAGS: -dc -dp -dv # debug conditions, parsing, variables
.MAKEFLAGS: -dFstderr # actually show debug output
.for _var_ in ...
# ...
.endfor
.MAKEFLAGS: -dF/dev/null # suppress further debug output
Roland
--