Makefile: Limit `pkgconf --static` workaround to OpenBSD

The flag was added in commit facfadb4b771 (Makefile: use pkg-config
--libs --static for LDFLAGS) to work around missing shared `libpci`
on OpenBSD. Usually it doesn't hurt to add the flag even when link-
ing against shared libraries, but it turns out that this can create
issues in corner cases.  For instance, Fedora doesn't ship symbolic
links to shared libraries without version number by default, i.e. a
plain `.so` without further suffix.  These links are shipped in the
`-devel` packages which normally aren't required in case of transi-
tive dependencies (like libusb1 depending on libudev in our case).

Our `meson.build` already limits the quirk to OpenBSD.

Change-Id: Ie0dcbb8b70ade5c98736138591eb9fac31e1e00c
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/554
diff --git a/Makefile b/Makefile
index 7d6e668..8ea9b85 100644
--- a/Makefile
+++ b/Makefile
@@ -211,6 +211,15 @@
 
 CC_WORKING := $(call c_compile_test, Makefile.d/cc_test.c)
 
+# Determine the destination OS, architecture and endian
+# IMPORTANT: The following lines must be placed before TARGET_OS, ARCH or ENDIAN
+# is ever used (of course), but should come after any lines setting CC because
+# the lines below use CC itself.
+override TARGET_OS  := $(call c_macro_test, Makefile.d/os_test.h)
+override ARCH       := $(call c_macro_test, Makefile.d/arch_test.h)
+override ENDIAN     := $(call c_macro_test, Makefile.d/endian_test.h)
+
+
 # Configs for dependencies. Can be overwritten by commandline
 CONFIG_LIBFTDI1_VERSION    := $(call dependency_version, libftdi1)
 CONFIG_LIBFTDI1_CFLAGS     := $(call dependency_cflags, libftdi1)
@@ -246,15 +255,6 @@
 CONFIG_LIBGPIOD_CFLAGS       := $(call dependency_cflags, libgpiod)
 CONFIG_LIBGPIOD_LDFLAGS      := $(call dependency_ldflags, libgpiod)
 
-# Determine the destination OS, architecture and endian
-# IMPORTANT: The following lines must be placed before TARGET_OS, ARCH or ENDIAN
-# is ever used (of course), but should come after any lines setting CC because
-# the lines below use CC itself.
-override TARGET_OS  := $(call c_macro_test, Makefile.d/os_test.h)
-override ARCH       := $(call c_macro_test, Makefile.d/arch_test.h)
-override ENDIAN     := $(call c_macro_test, Makefile.d/endian_test.h)
-
-
 HAS_LIBFTDI1        := $(call find_dependency, libftdi1)
 HAS_LIB_NI845X      := no
 HAS_LIBJAYLINK      := $(call find_dependency, libjaylink)
diff --git a/Makefile.include b/Makefile.include
index 1bca4f3..a0b5fa9 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -66,5 +66,5 @@
 endef
 
 define dependency_ldflags
-$(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --libs --static $1 2>/dev/null)
+$(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --libs $(if $(filter OpenBSD,$(TARGET_OS)),--static) $1 2>/dev/null)
 endef