Use a variable for `PKG_CONFIG` for distros that cross-compile.

Fixes #450.

Change-Id: If399caf0566f85b1e20e6ea3fedfc524018d2e6c
Reviewed-on: https://code-review.googlesource.com/c/re2/+/61950
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/Makefile b/Makefile
index 60b79c9..52484d4 100644
--- a/Makefile
+++ b/Makefile
@@ -17,16 +17,17 @@
 	absl_strings\
 	absl_synchronization\
 
-CCABSL=$(shell pkg-config $(ABSL_DEPS) --cflags)
+PKG_CONFIG?=pkg-config
+CCABSL=$(shell $(PKG_CONFIG) $(ABSL_DEPS) --cflags)
 # GCC barfs on `-Wl` whereas Clang doesn't mind, but it's unclear what
 # causes it to manifest on Ubuntu 22.04 LTS, so filter it out for now.
 # Similar is needed for `static-testinstall` and `shared-testinstall`.
-LDABSL=$(shell pkg-config $(ABSL_DEPS) --libs | sed -e 's/-Wl / /g')
+LDABSL=$(shell $(PKG_CONFIG) $(ABSL_DEPS) --libs | sed -e 's/-Wl / /g')
 
 # To build against ICU for full Unicode properties support,
 # uncomment the next two lines:
-# CCICU=$(shell pkg-config icu-uc --cflags) -DRE2_USE_ICU
-# LDICU=$(shell pkg-config icu-uc --libs)
+# CCICU=$(shell $(PKG_CONFIG) icu-uc --cflags) -DRE2_USE_ICU
+# LDICU=$(shell $(PKG_CONFIG) icu-uc --libs)
 
 # To build against PCRE for testing and benchmarking,
 # uncomment the next two lines:
@@ -359,8 +360,8 @@
 	@cp testinstall.cc obj/static-testinstall.cc
 	(cd obj && export PKG_CONFIG_PATH=$(DESTDIR)$(libdir)/pkgconfig; \
 	  $(CXX) static-testinstall.cc -o static-testinstall $(CXXFLAGS) $(LDFLAGS) \
-	  $$(pkg-config re2 --cflags) \
-	  $$(pkg-config re2 --libs | sed -e 's/-Wl / /g' | sed -e 's/-lre2/-l:libre2.a/'))
+	  $$($(PKG_CONFIG) re2 --cflags) \
+	  $$($(PKG_CONFIG) re2 --libs | sed -e 's/-Wl / /g' | sed -e 's/-lre2/-l:libre2.a/'))
 	obj/static-testinstall
 endif
 
@@ -370,8 +371,8 @@
 	@cp testinstall.cc obj/shared-testinstall.cc
 	(cd obj && export PKG_CONFIG_PATH=$(DESTDIR)$(libdir)/pkgconfig; \
 	  $(CXX) shared-testinstall.cc -o shared-testinstall $(CXXFLAGS) $(LDFLAGS) \
-	  $$(pkg-config re2 --cflags) \
-	  $$(pkg-config re2 --libs | sed -e 's/-Wl / /g'))
+	  $$($(PKG_CONFIG) re2 --cflags) \
+	  $$($(PKG_CONFIG) re2 --libs | sed -e 's/-Wl / /g'))
 ifeq ($(shell uname),Darwin)
 	DYLD_LIBRARY_PATH="$(DESTDIR)$(libdir):$(DYLD_LIBRARY_PATH)" obj/shared-testinstall
 else