Author: Reiner Herrmann <reiner@reiner-h.de>
Description: Sort lists of libraries/source/object files
 for deterministic linking order

--- a/Make.rules
+++ b/Make.rules
@@ -136,8 +136,8 @@
 _libs = $(strip $(foreach _lib,$(LIBDIRS),\
 		    $(if $(filter lib%,$(_lib)),\
 			$(patsubst lib%,-l%,$(_lib)),\
-			$(wildcard $(srcdir)/$(_lib)/$(_lib).so \
-					$(srcdir)/$(_lib)/$(_lib).a))))
+			$(sort $(wildcard $(srcdir)/$(_lib)/$(_lib).so \
+					$(srcdir)/$(_lib)/$(_lib).a)))))
 
 override LIBS := $(_libs) -lm $(LIBS)
 
@@ -166,7 +166,7 @@
 endif
 endif
 
-sources = $(wildcard *.c)
+sources = $(sort $(wildcard *.c))
 OBJS = $(sources:.c=.$(obj))
 
 
--- a/default.rules
+++ b/default.rules
@@ -143,7 +143,7 @@
 ifeq ($(filter $(TARGET),$(EXEDIRS)),$(TARGET))
 
 ifeq ($(filter $(TARGET),$(MODUSERS)),$(TARGET))
-MOD_OBJS = $(wildcard $(foreach dir,$(MODDIRS),$(srcdir)/$(dir)/*.o))
+MOD_OBJS = $(sort $(wildcard $(foreach dir,$(MODDIRS),$(srcdir)/$(dir)/*.o)))
 ifeq ($(shared),yes)
 override LDFLAGS := -rdynamic $(LDFLAGS)
 endif
