Description: debianization
 Meant to maintain a minimal debian/rules, to fix warnings,
 to address Debian specific stuff in general.

--- a/makefile
+++ b/makefile
@@ -1,11 +1,34 @@
 MINGW=mingw
-GCC=gcc -O
+GCC=gcc -std=gnu17
 TARS= tars/tthgoldC.tgz tars/tthgoldL.tar.gz  tars/ttmC.tar.gz\
  tars/ttmL.tar.gz  tars/tthgoldW.exe tars/ttmW.exe
 WARN=-Wall -Wno-unused-but-set-variable -Wno-stringop-truncation -Wno-stringop-overflow -Wno-format-overflow
 
+##CFLAGS += -O0
+
+dh_auto_build_default: tth ttm dh_auto_build_tthsplit dh_auto_build_tthrfcat dh_auto_build_manual dh_auto_build_gold_manual
+
+dh_auto_build_tthsplit:
+	make -C tools tthsplit
+
+dh_auto_build_tthrfcat: tthgold/tthrfcat.c
+	$(GCC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -Wall -o tthrfcat $<
+
+dh_auto_build_manual: tth dh_auto_build_tthsplit
+	make -C manual
+
+dh_auto_build_gold_manual: tthgold_manual.tex tth
+	latex -no-shell-escape -interaction=batchmode $<
+	./tth -a $<
+
+tthgold_manual.tex: tthgold/gold_man.tex
+	sed \
+		-e 's#usr\/local\/tth#usr\/share\/tth#g' \
+		-e 's#tth\/swedish.bab#tth\/babel\/swedish.bab#g' \
+		< $< > $@
+
 unopt : tth.c
-	gcc -o tth $(WARN) tth.c
+	$(GCC) -o tth $(WARN) tth.c
 	sleep 1s
 	date > unopt
 
@@ -34,13 +57,13 @@
 	flex -ottm.c ttm.lex
 
 ttm : ttm.c
-	gcc -o ttm $(WARN) ttm.c
+	$(GCC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -Wall -o ttm ttm.c
 
 tth.c : tth.lex
 	flex -otth.c tth.lex
 
 tth : tth.c
-	$(GCC) -o tth $(WARN) tth.c
+	$(GCC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -Wall -o tth tth.c
 
 # The tars are individual packages. Win32, Linux, C.
 
@@ -91,10 +114,10 @@
 ttmL/ttm_manual.html : manual/ttm_manual.html
 
 ttmstatic : ttm.c
-	gcc -static -o ttmstatic ttm.c
+	$(GCC) -static -o ttmstatic ttm.c
 
 tthstatic : tth.c
-	gcc -static -o tthstatic tth.c
+	$(GCC) -static -o tthstatic tth.c
 
 ttm.exe : ttm ttm.c ttm.res makefile
 	$(MINGW) -o ttm.exe ttm.res ttm.c
--- a/tools/makefile
+++ b/tools/makefile
@@ -7,7 +7,7 @@
 	mingw -o choice.exe choice.c
 
 tthsplit : tthsplit.c
-	gcc -o tthsplit tthsplit.c
+	gcc $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -Wall -o tthsplit tthsplit.c
 
 tthsplit.exe : tthsplit.c
 	mingw -o tthsplit.exe tthsplit.c
--- a/tthgold/README.txt
+++ b/tthgold/README.txt
@@ -1,4 +1,4 @@
-Unzip or untar the distribution. It should make its own directory.
-For Wind@ws run the install.bat file by the command "install".
-Read the file gold_man.html or gold_man.tex for further instructions.
+Unzip or untar the distribution. It should make its own directory.
+For Wind@ws run the install.bat file by the command "install".
+Read the file tthgold_manual.html or tthgold_manual.tex for further instructions.
 
