Index: Makefile
--- Makefile.orig	2006-06-11 17:52:50.000000000 +0200
+++ Makefile	2012-07-25 20:30:37.000000000 +0200
@@ -9,14 +9,17 @@
 
 all: $(TARGET)
 
+.c.o:
+	$(CC) $(CFLAGS) -o $@ -c $<
+
 ttyrec: ttyrec.o io.o
-	$(CC) $(CFLAGS) -o ttyrec ttyrec.o io.o
+	$(CC) $(LDFLAGS) -o ttyrec ttyrec.o io.o $(LIBS)
 
 ttyplay: ttyplay.o io.o
-	$(CC) $(CFLAGS) -o ttyplay ttyplay.o io.o
+	$(CC) $(LDFLAGS) -o ttyplay ttyplay.o io.o $(LIBS)
 
 ttytime: ttytime.o io.o
-	$(CC) $(CFLAGS) -o ttytime ttytime.o io.o
+	$(CC) $(LDFLAGS) -o ttytime ttytime.o io.o $(LIBS)
 
 clean:
 	rm -f *.o $(TARGET) ttyrecord *~
Index: ttyrec.c
--- ttyrec.c.orig	2006-06-11 17:52:50.000000000 +0200
+++ ttyrec.c	2012-07-25 20:31:49.000000000 +0200
@@ -71,6 +71,7 @@
 #define _(FOO) FOO
 
 #ifdef HAVE_openpty
+#include <termios.h>
 #include <libutil.h>
 #endif
 
@@ -203,7 +204,7 @@
 void
 finish()
 {
-#if defined(SVR4)
+#if defined(SVR4) || defined(__FreeBSD__)
 	int status;
 #else /* !SVR4 */
 	union wait status;
