lib: halfmd4: Make halfmd4.c optional

Add a new config option HALFMD4 to compile out half-MD4 hash function.
This config is selected by config EXT3_FS and config EXT4_FS as
these file systems use half-MD4 hash function for directory indexing.

bloat-o-meter output:
move: 0/1 grow/shrink: 0/0 up/down: 0/-657 (-657)
function                                     old     new   delta
half_md4_transform                           657       -    -657

Signed-off-by: Catalina Mocanu <catalina.mocanu@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
diff --git a/fs/ext3/Kconfig b/fs/ext3/Kconfig
index e8c6ba0..345277b 100644
--- a/fs/ext3/Kconfig
+++ b/fs/ext3/Kconfig
@@ -1,6 +1,7 @@
 config EXT3_FS
 	tristate "Ext3 journalling file system support"
 	select JBD
+	select HALFMD4
 	help
 	  This is the journalling version of the Second extended file system
 	  (often called ext3), the de facto standard Linux file system
diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig
index efea5d5..617f362 100644
--- a/fs/ext4/Kconfig
+++ b/fs/ext4/Kconfig
@@ -4,6 +4,7 @@
 	select CRC16
 	select CRYPTO
 	select CRYPTO_CRC32C
+	select HALFMD4
 	help
 	  This is the next generation of the ext3 filesystem.
 
diff --git a/include/linux/cryptohash.h b/include/linux/cryptohash.h
index 2cd9f1c..ebf2043 100644
--- a/include/linux/cryptohash.h
+++ b/include/linux/cryptohash.h
@@ -13,6 +13,8 @@
 
 void md5_transform(__u32 *hash, __u32 const *in);
 
+#ifdef CONFIG_HALFMD4
 __u32 half_md4_transform(__u32 buf[4], __u32 const in[8]);
+#endif
 
 #endif
diff --git a/lib/Kconfig b/lib/Kconfig
index 54cf309..78e8035 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -180,6 +180,9 @@
 	  when they need to do cyclic redundancy check according CRC8
 	  algorithm. Module will be called crc8.
 
+config HALFMD4
+	bool
+
 config AUDIT_GENERIC
 	bool
 	depends on AUDIT && !AUDIT_ARCH
diff --git a/lib/Makefile b/lib/Makefile
index 7512dc9..26f7c25 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -22,11 +22,12 @@
 lib-y	+= kobject.o klist.o
 obj-y	+= lockref.o
 
-obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
+obj-y += bcd.o div64.o sort.o parser.o debug_locks.o random32.o \
 	 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
 	 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \
 	 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \
 	 percpu-refcount.o percpu_ida.o hash.o rhashtable.o
+obj-$(CONFIG_HALFMD4) += halfmd4.o
 obj-y += string_helpers.o
 obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
 obj-y += kstrtox.o