$COMMON=md5_dgst.c md5_one.c md5_sha1.c $MD5ASM
SOURCE[../../libcrypto]=$COMMON
SOURCE[../../providers/libimplementations.a]=$COMMON
-SOURCE[../../providers/liblegacy.a]=$COMMON
+
+# A no-deprecated no-shared build ends up with double function definitions
+# without conditioning this on dso. The issue is MD5 which is needed in the
+# legacy provider for one of the spliced algorithms, however it resides in the
+# default provider. A no-deprecated build removes the external definition from
+# libcrypto and this means that the code needs to be in liblegacy. However,
+# when building without 'dso', liblegacy is included in libcrypto.
+IF[{- !$disabled{dso} -}]
+ SOURCE[../../providers/liblegacy.a]=$COMMON
+ENDIF
# Implementations are now spread across several libraries, so the defines
# need to be applied to all affected libraries and modules.