diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index b47971edef..6e34dabf78 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -743,6 +743,11 @@ endif
 # tracking (see below) is used.
 %: %.c
 
+# Provide an explicit link rule since the link command lists are
+# order-sensitive.
+%: %.o
+	$(CC) $(CFLAGS) $< $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+
 ifndef PGXS
 
 # Remake Makefile.global from Makefile.global.in if the latter
diff --git a/src/interfaces/ecpg/test/Makefile.regress b/src/interfaces/ecpg/test/Makefile.regress
index 4da1bb8a03..b0647cd2c5 100644
--- a/src/interfaces/ecpg/test/Makefile.regress
+++ b/src/interfaces/ecpg/test/Makefile.regress
@@ -21,9 +21,6 @@ ECPG_TEST_DEPENDENCIES = ../../preproc/ecpg$(X) \
 	$(srcdir)/../../include/sqltypes.h \
 	$(srcdir)/../../include/sql3types.h
 
-%: %.o
-	$(CC) $(CFLAGS) $< $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
-
 # Caution: this build rule is overridden in some child Makefiles
 # where it's necessary to use nondefault switches to ecpg;
 # make sure those rules match except for the extra switches.
diff --git a/src/makefiles/Makefile.linux b/src/makefiles/Makefile.linux
index f4f091caef..ac58fe45de 100644
--- a/src/makefiles/Makefile.linux
+++ b/src/makefiles/Makefile.linux
@@ -12,4 +12,4 @@ CFLAGS_SL = -fPIC
 
 # Rule for building a shared library from a single .o file
 %.so: %.o
-	$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $<
+	$(CC) $(CFLAGS) $< $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@
