--- wmtictactoe-1.1.orig/wmtictactoe/Makefile
+++ wmtictactoe-1.1/wmtictactoe/Makefile
@@ -1,14 +1,22 @@
+CC     = gcc
 LIBDIR = -L/usr/X11R6/lib
 LIBS   = -lXpm -lXext -lX11
-OBJS =  wmtictactoe.o ../wmgeneral/wmgeneral.o
+CFLAGS = -g -O2 -W -Wall
+OBJS   = wmtictactoe.o ../wmgeneral/wmgeneral.o
+PREFIX=/usr/local
+BINDIR=${PREFIX}/bin
+MANDIR=${PREFIX}/share/man
+INSTALL = /usr/bin/install
+INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
+INSTALL_FILE    = $(INSTALL) -p -o root -g root -m 644
 
 .c.o:
-	cc -c -g -O2 -Wall $< -o $*.o
+	$(CC) -c $(CFLAGS) $< -o $*.o
 
 all: wmtictactoe
 
 wmtictactoe: $(OBJS)
-	cc -o wmtictactoe $^ $(LIBDIR) $(LIBS)
+	$(CC) -o wmtictactoe $^ $(CFLAGS) $(LIBDIR) $(LIBS)
 
 clean:
 	for i in $(OBJS) ; do \
@@ -17,5 +25,6 @@
 	rm -rf wmtictactoe core *~
 
 install:
-	/usr/bin/install -c -o 0 -g 0 -s -m 755 wmtictactoe /usr/local/bin/wmtictactoe
+	${INSTALL_PROGRAM} wmtictactoe ${DESTDIR}${BINDIR}
+
 
--- wmtictactoe-1.1.orig/wmtictactoe/wmtictactoe.c
+++ wmtictactoe-1.1/wmtictactoe/wmtictactoe.c
@@ -123,7 +123,7 @@
 // ----------------------------------------------------------
 // declaracao das funcoes do sistema
 
-void    main (int argc, char *argv[]);
+int     main (int argc, char *argv[]);
 void    usage (void);
 void    printversion (void);
 void    readfile (void);
@@ -168,7 +168,7 @@
 //        in: argc - numero de argumentos passados por linha d comando
 //            argv - vetor com os argumentos
 //       out: nada
-void main (int argc, char *argv[])
+int main (int argc, char *argv[])
 {
 	int     i;
      
@@ -221,6 +221,7 @@
 	}
 	
 	principal (argc, argv);
+	return 0;
 }
 
 // -------------------------------------------------------------------------------------------
@@ -1021,8 +1022,8 @@
 	fprintf (stderr, "\t-deadmatch\n");
 	fprintf (stderr, "\t-h\tthis screen\n");
 	fprintf (stderr, "\t-v\tprint the version number\n");
-	fprintf (stderr, "\t-o\tofensive mode\n");
-	fprintf (stderr, "\t-q\tquiet mode(for Debian's user)\n");
+	fprintf (stderr, "\t-o\toffensive mode\n");
+	fprintf (stderr, "\t-q\tquiet mode (for Debian users)\n");
 	fprintf (stderr, "\t\tdefault: defensive mode\n");
 	fprintf (stderr, "\n");
 }
@@ -1052,7 +1053,10 @@
 	char buf[256];
 	int done;
 
-	sprintf(rcfilen, "%s/.wmtictactoe", getenv("HOME"));
+	memset(rcfilen,'\0',sizeof(rcfilen));
+	if (getenv("HOME") != NULL ) {
+	       snprintf(rcfilen,sizeof(rcfilen)-1, "%s/.wmtictactoe", getenv("HOME"));
+	}
 
 	if ((rcfile=fopen(rcfilen, "r")) != NULL){
 	        do {
@@ -1089,7 +1093,10 @@
         FILE *rcfile;
 	char rcfilen[256];
 
-	sprintf(rcfilen, "%s/.wmtictactoe", getenv("HOME"));
+	memset(rcfilen,'\0',sizeof(rcfilen));
+	if (getenv("HOME") != NULL ) {
+	       snprintf(rcfilen,sizeof(rcfilen)-1, "%s/.wmtictactoe", getenv("HOME"));
+	}
 
 	if ((rcfile=fopen(rcfilen, "w")) != NULL){
                 fprintf(rcfile, "score_user_offensive %d\nscore_deuce_offensive %d\nscore_X_offensive %d\n", score_user_offensive, score_deuce_offensive, score_X_offensive);
