Description: Fix up Makefiles
 * Use lib/ instead of run/.
 * Fix build flags passing, build order and hardlinks.
 Patch based on the one imported from .diff.gz of crack 5.0a-9.4

--- crack-5.0a.orig/Makefile
+++ crack-5.0a/Makefile
@@ -39,17 +39,17 @@
 tidy: clean
 	-scripts/plaster
 	-scripts/fbmerge
-	-rm -f run/[DIEGTKM]*
-	-rm -f run/dict/gecos.*
-	-rm -f run/dict/gcperm.*
+	-rm -f lib/[DIEGTKM]*
+	-rm -f lib/dict/gecos.*
+	-rm -f lib/dict/gcperm.*
 
 spotless: tidy
-	-rm -rf run/bin
+	-rm -rf lib/bin
 
 rmdict:
-	-rm -rf run/dict
+	-rm -rf lib/dict
 
 clobber: spotless rmdict
-	-cat run/F-merged >> F-merged.save
-	-rm -rf run
+	-cat lib/F-merged >> F-merged.save
+	-rm -rf lib
 	( cd extra ; make clean )

--- a/src/util/Makefile
+++ b/src/util/Makefile
@@ -1,6 +1,6 @@
 ###
 # This program was written by and is copyright Alec Muffett 1991,
-# 1992, 1993, 1994, 1995, and 1996, and is provided as part of the
+# 1992, 1993, 1994, 1995, 1996 & 1997, and is provided as part of the
 # Crack v5.0 Password Cracking package.
 #
 # The copyright holder disclaims all responsibility or liability with
@@ -9,13 +9,12 @@
 # document which accompanies distributions of Crack v5.0 and upwards.
 ###
 
-CFLAGS= $(XCFLAGS) -I../lib
+CFLAGS+= $(XCFLAGS) -I../lib -D_XOPEN_SOURCE $(CPPFLAGS)
 CC=     $(XCC)
 
 XLIB=$(XDIR)/libc5.a $(XLIBS)
 
 EXE=    $(XDIR)/dawg \
-	$(XDIR)/dictfilt \
 	$(XDIR)/kickdict \
 	$(XDIR)/cracker
 
@@ -41,39 +40,37 @@
 
 $(XDIR)/stdlib-cracker: cracker.c $(XLIB)
 	$(CC) $(CFLAGS) -c elcid.c
-	$(CC) $(CFLAGS) -o $(XDIR)/cracker cracker.c elcid.o $(XLIB)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/cracker cracker.c elcid.o $(XLIB)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/dictfilt dictfilt.c elcid.o $(XLIB)
 	date > $@
 
 $(XDIR)/libdes-cracker: cracker.c $(XLIB)
 	$(CC) $(CFLAGS) -c elcid.c
-	$(CC) $(CFLAGS) -o $(XDIR)/cracker cracker.c elcid.o $(XLIB) ../libdes/libdes.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/cracker cracker.c elcid.o $(XLIB) ../libdes/libdes.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/dictfilt dictfilt.c elcid.o $(XLIB) ../libdes/libdes.a
 	date > $@
 
 $(XDIR)/ufc-cracker: cracker.c $(XLIB)
 	$(CC) $(CFLAGS) -DINITDES -DFCRYPT -c elcid.c
-	$(CC) $(CFLAGS) -o $(XDIR)/cracker cracker.c elcid.o $(XLIB) ../ufc-crypt/libufc.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/cracker cracker.c elcid.o $(XLIB) ../ufc-crypt/libufc.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/dictfilt dictfilt.c elcid.o $(XLIB) ../ufc-crypt/libufc.a
 	date > $@
 
 $(XDIR)/gnu-cracker: cracker.c $(XLIB)
 	$(CC) $(CFLAGS) -c elcid.c
-	$(CC) $(CFLAGS) -o $(XDIR)/cracker cracker.c elcid.o $(XLIB) ../crypt/libufc.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/cracker cracker.c elcid.o $(XLIB) ../crypt/libufc.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/dictfilt dictfilt.c elcid.o $(XLIB) ../crypt/libufc.a
 	date > $@
 
 #------------------------------------------------------------------
 
 $(XDIR)/dawg: dawg.c $(XLIB)
-	$(CC) $(CFLAGS) -o $(XDIR)/dawg dawg.c $(XLIB)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/dawg dawg.c $(XLIB)
 	rm -f $(XDIR)/xdawg
-	ln $(XDIR)/dawg $(XDIR)/xdawg
-
-#------------------------------------------------------------------
-
-# don't you just love dependency graphs?
-$(XDIR)/dictfilt: dictfilt.c $(XLIB) $(XDIR)/cracker
-	$(CC) $(CFLAGS) -o $(XDIR)/dictfilt dictfilt.c elcid.o $(XLIB)
+	ln -s dawg $(XDIR)/xdawg
 
 #------------------------------------------------------------------
 
 $(XDIR)/kickdict: kickdict.c $(XLIB)
-	$(CC) $(CFLAGS) -o $(XDIR)/kickdict kickdict.c $(XLIB)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $(XDIR)/kickdict kickdict.c $(XLIB)
 
--- a/extra/Makefile
+++ b/extra/Makefile
@@ -10,20 +10,20 @@
 ###
 
 CC= gcc
-CFLAGS= -O2 -g
+#CFLAGS= -O2 -g
 LIB= ../src/libdes/libdes.a
 #LIB= -lcrypt
 
 all: brute brute-gen
 
 brute: brute.c
-	$(CC) -O2 -o $@ brute.c $(LIB)
+	$(CC) $(CLFAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ brute.c $(LIB)
 
 brute-gen: brute.c
-	$(CC) -DBRUTEGEN=1 -O2 -o $@ brute.c
+	$(CC) -DBRUTEGEN=1 $(CLFAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ brute.c
 
 fips: fips.o
-	$(CC) -O2 -o $@ fips.o
+	$(CC) $(CLFAGS) $(CPPFLAGS) $(LDFLAGS) -O2 -o $@ fips.o
 
 clean:
 	rm -f *.o *~ brute brute-gen core
--- a/src/lib/Makefile
+++ b/src/lib/Makefile
@@ -10,7 +10,7 @@
 ###
 
 XLIB=	$(XDIR)/libc5.a
-CFLAGS= $(XCFLAGS)
+CFLAGS+= $(XCFLAGS) $(CPPFLAGS)
 CC=	$(XCC)
 
 SRC=	dawglib.c debug.c rules.c stringlib.c
--- a/src/libdes/Makefile
+++ b/src/libdes/Makefile
@@ -36,7 +36,7 @@
 OPTS= $(OPTS0) $(OPTS1) $(OPTS2)
 
 CC=cc
-CFLAGS= -O $(OPTS) $(CFLAG)
+CFLAGS= -O $(OPTS) $(CFLAGS) $(CPPFLAGS)
 
 #CC=gcc
 #CFLAGS= -O4 -fomit-frame-pointer -funroll-loops $(OPTS) $(CFLAG)
@@ -85,16 +85,16 @@
 	else exit 0; fi; fi
 
 destest: destest.o libdes.a
-	$(CC) $(CFLAGS) -o destest destest.o libdes.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o destest destest.o libdes.a
 
 rpw: rpw.o libdes.a
-	$(CC) $(CFLAGS) -o rpw rpw.o libdes.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o rpw rpw.o libdes.a
 
 speed: speed.o libdes.a
-	$(CC) $(CFLAGS) -o speed speed.o libdes.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o speed speed.o libdes.a
 
 des: des.o libdes.a
-	$(CC) $(CFLAGS) -o des des.o libdes.a
+	$(CC) $(CFLAGS) $(LDFLAGS) -o des des.o libdes.a
 
 tags:
 	ctags $(DES) $(TESTING) $(LIBDES)
