Add PKG_CHECK_VAR and AS_VAR_COPY compat macros (Courtesy of ycflash)

(cherry picked from commit d80b6ec8)

Closes #1182 (closed)

Merge request reports