--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,45 +1,49 @@
-CFLAGS = 
+CFLAGS +=
 CWEAVE = cweavex +d
 CTANGLE = ctanglex
-.SUFFIXES: .tex .dvi .w
+
+all: treeprint treeprint.pdf wc wc.pdf wmerge wmerge.pdf
+
+.SUFFIXES: .tex .dvi .w .pdf
 
 .w.tex:
 	$(CWEAVE) $*
 
-.tex.dvi:	
+.tex.dvi:
 	tex $*
 
-
-.w.dvi:
-	$(CWEAVE) $*
-	tex $*
+.tex.pdf:
+	pdftex $*
 
 .w.c:
 	$(CTANGLE) $*
 
-.w.o:
-	$(CTANGLE) $*
-	$(CC) $(CFLAGS) -c $*.c
-
 .w.dvi:
-	make $*.tex
-	make $*.dvi
+	$(MAKE) $*.tex
+	$(MAKE) $*.dvi
+
+.w.pdf:
+	$(MAKE) $*.tex
+	$(MAKE) $*.pdf
 
 .w.o:
-	make $*.c
-	make $*.o
+	$(MAKE) $*.c
+	$(MAKE) $*.o
 
 treeprint: treeprint.w
-	make treeprint.c
-	make treeprint	
+	$(MAKE) treeprint.o
+	$(CC) $(CFLAGS) -o treeprint treeprint.o
 
 wc: wc.w
-	make wc.c
-	make wc
-
-wmerge: wmerge.w
-	make wmerge.o
-	$(CC) $(CFLAGS) -o wmerge wmerge.o ../common.o
-
+	$(MAKE) wc.o
+	$(CC) $(CFLAGS) -o wc wc.o
 
-	
+wmerge: wmerge.w common.o
+	$(MAKE) wmerge.o
+	$(CC) $(CFLAGS) -o wmerge wmerge.o common.o
+
+.PHONY: clean
+
+clean:
+	rm -f *.o *.c *.tex *.dvi *.pdf *.log *.toc
+	rm -f treeprint wc wmerge common.h
--- a/examples/wmerge.w
+++ b/examples/wmerge.w
@@ -10,11 +10,11 @@
 banner is produced anyway.
 
 @h <stdio.h>
-@h "../common.h" /* the header file for \.{CWEB}'s \.{common.w} */
+@h "common.h" /* the header file for \.{CWEB}'s \.{common.w} */
 @c
 @< Prototype @>@;
 main (int argc,char** argv)
-{ common_init(argc,argv);
+{ common_init(argc,argv,"x3.52");
   flags['h']=flags['p']=0;
   reset_input();
   while (get_line())
