diff -Nurd -x'*~' Xfoil.orig/bin/Makefile_gfortran Xfoil/bin/Makefile_gfortran
--- Xfoil.orig/bin/Makefile_gfortran	2012-03-07 00:33:23.000000000 -0500
+++ Xfoil/bin/Makefile_gfortran	2015-09-26 23:46:49.000000000 -0400
@@ -6,10 +6,10 @@
 
 
 SHELL = sh
-BINDIR = /home/codes/bin/
+BINDIR = @FINKDEST@/bin/
 #BINDIR = .
 
-PROGS = xfoil pplot pxplot
+PROGS = xfoil pplot pxplot blu
 
 SRC = ../src
 OSRC = ../osrc
@@ -116,11 +116,11 @@
 ##--------------------------
 ### Gfortran
 FC = gfortran
-CHK = 
+CHK = -fbounds-check -finit-real=inf -ffpe-trap=invalid,zero -fstack-protector --param=ssp-buffer-size=4 -fallow-argument-mismatch
 #CHK = -fbounds-check -finit-real=inf -ffpe-trap=invalid,zero,denormal
 DBL = -fdefault-real-8
-FFLAGS = -O $(CHK) $(DBL)
-FFLOPT = -O $(CHK) $(DBL)
+FFLAGS = -O2 -g $(CHK) $(DBL)
+FFLOPT = -O2 -g $(CHK) $(DBL)
 FTNLIB =
 
 PLTOBJ = ../plotlib/libPlt_gDP.a 
@@ -141,19 +141,15 @@
 
 xfoil: $(XFOILOBJ) $(XUTILOBJ) $(OSOBJ)
 	$(FC) -o xfoil $(XFOILOBJ) $(XUTILOBJ) $(OSOBJ) $(PLTOBJ) $(PLTLIB) $(FTNLIB)
-	$(INSTALLCMD) xfoil $(BINDIR)
 
 pxplot:	$(PXPLOTOBJ) $(XUTILOBJ)
 	$(FC) -o pxplot $(PXPLOTOBJ) $(XUTILOBJ) $(PLTOBJ) $(PLTLIB) $(FTNLIB)
-	$(INSTALLCMD) pxplot $(BINDIR)
 
 pplot:	$(PPLOTOBJ) $(XUTILOBJ)
 	$(FC) -o pplot $(PPLOTOBJ) $(XUTILOBJ)  $(PLTOBJ) $(PLTLIB) $(FTNLIB)
-	$(INSTALLCMD) pplot $(BINDIR)
 
 blu: blu.o profil.o
 	$(FC) -o blu blu.o profil.o
-	$(INSTALLCMD) blu $(BINDIR)
 
 
 blu.o: $(SRC)/blu.f
diff -Nurd -x'*~' Xfoil.orig/orrs/bin/Makefile_DP Xfoil/orrs/bin/Makefile_DP
--- Xfoil.orig/orrs/bin/Makefile_DP	2007-04-05 17:29:35.000000000 -0400
+++ Xfoil/orrs/bin/Makefile_DP	2015-09-26 23:46:49.000000000 -0400
@@ -1,6 +1,6 @@
 
 SRC = ../src
-PLTOBJ = /var/local/codes/Xplot/libPltDP.a
+PLTOBJ =  ../../plotlib/libPltDP.a
 
 #========================================
 #  Default compiler flags
@@ -12,8 +12,8 @@
 #========================================
 #  Uncomment for Intel Fortran Compiler
 FC = ifort
-FLG = -O -r8
 PLTLIB = -L/usr/X11R6/lib -lX11
+FLG = -O2 -fbounds-check -finit-real=inf -ffpe-trap=invalid,zero -fdefault-real-8 -fstack-protector --param=ssp-buffer-size=4
 FTNLIB =
 
 #========================================
diff -Nurd -x'*~' Xfoil.orig/orrs/src/osmap.f Xfoil/orrs/src/osmap.f
--- Xfoil.orig/orrs/src/osmap.f	2011-05-04 22:49:00.000000000 -0400
+++ Xfoil/orrs/src/osmap.f	2015-09-26 23:46:49.000000000 -0400
@@ -98,7 +98,7 @@
 C
 C---- set OSFILE to match the absolute OS database filename
       CHARACTER*128 OSFILE
-      DATA OSFILE / '/home/codes/orrs/osmapDP.dat' /
+      DATA OSFILE / '@BUILDPREFIX@/orrs/osmapDP.dat' /
 ccc      DATA OSFILE / '/home/codes/orrs/osmap.dat' /
 c
 c      DATA OSFILE
diff -Nurd -x'*~' Xfoil.orig/orrs/src/osmap_DP.f Xfoil/orrs/src/osmap_DP.f
--- Xfoil.orig/orrs/src/osmap_DP.f	2003-08-17 22:22:54.000000000 -0400
+++ Xfoil/orrs/src/osmap_DP.f	2015-09-26 23:46:49.000000000 -0400
@@ -94,7 +94,7 @@
 C
 C---- set OSFILE to match the absolute location of the OS database file
       CHARACTER*48 OSFILE
-      DATA OSFILE / '/var/local/codes/orrs/osmap_DP.dat' /
+      DATA OSFILE / '@BUILDPREFIX@/orrs/osmap_DP.dat' /
 C
       DATA LOADED / .FALSE. /
 C
diff -Nurd -x'*~' Xfoil.orig/osrc/getosfile.c Xfoil/osrc/getosfile.c
--- Xfoil.orig/osrc/getosfile.c	2005-03-22 13:41:47.000000000 -0500
+++ Xfoil/osrc/getosfile.c	2015-09-26 23:46:49.000000000 -0400
@@ -13,6 +13,8 @@
 
 #endif
 
+#define DEFAULT_OSFILE "@FINKPREFIX@/share/xfoil/osmap.dat"
+
 void
 GETOSFILE(osfile,len)
      char *osfile;
@@ -28,11 +30,12 @@
       printf("osfile: %s\n",osfile); */
 
    if(bufp){ 
-      strcpy(osfile,bufp);
+      strncpy(osfile,bufp, 128);
       l = strlen(bufp);
       }
     else {
-      l = 0;
+      strncpy(osfile,DEFAULT_OSFILE, 128);
+      l = strlen(DEFAULT_OSFILE);
       }
 
    *len = l;
diff -Nurd -x'*~' Xfoil.orig/osrc/osmap.f Xfoil/osrc/osmap.f
--- Xfoil.orig/osrc/osmap.f	2006-08-01 15:46:18.000000000 -0400
+++ Xfoil/osrc/osmap.f	2015-09-27 00:02:45.000000000 -0400
@@ -100,7 +100,7 @@
       CHARACTER*128 OSFILE
       INTEGER LOSF
 
-      DATA OSFILE / '/var/local/codes/orrs/osmap.dat' /
+      DATA OSFILE / '@FINKPREFIX@/share/xfoil/osmap.dat' /
 c      DATA OSFILE
 c     &/'/afs/athena.mit.edu/course/16/16_d0006/Codes/orrs/osmap_lx.dat'/
 C
diff -Nurd -x'*~' Xfoil.orig/plotlib/config.make.gfortranDP Xfoil/plotlib/config.make.gfortranDP
--- Xfoil.orig/plotlib/config.make.gfortranDP	2013-07-02 11:19:37.000000000 -0400
+++ Xfoil/plotlib/config.make.gfortranDP	2015-09-26 23:46:49.000000000 -0400
@@ -17,7 +17,7 @@
 CC  = gcc
 DP = -fdefault-real-8
 
-FFLAGS  = -m64 -O2 $(DP)
+FFLAGS  = -O2 -fbounds-check -finit-real=inf -ffpe-trap=invalid,zero -fstack-protector --param=ssp-buffer-size=4 -g $(DP) -I/usr/X11R6/include
 CFLAGS  = -m64 -O2 $(DEFINE) -I/usr/X11/include
 AR = ar r
 RANLIB = ranlib 
diff -Nurd -x'*~' Xfoil.orig/src/pxplot.f Xfoil/src/pxplot.f
--- Xfoil.orig/src/pxplot.f	2009-12-07 20:37:08.000000000 -0500
+++ Xfoil/src/pxplot.f	2015-09-26 23:46:49.000000000 -0400
@@ -44,7 +44,7 @@
 C
 C
 C---- Check for dump file on command line
-      CALL GETARG0(NARG,FNAME)
+      CALL GETARG0(1,FNAME)
       IF(FNAME.NE.' ') GO TO 40
 C
 C=======================================================
diff -Nurd -x'*~' Xfoil.orig/src/xoper.f Xfoil/src/xoper.f
--- Xfoil.orig/src/xoper.f	2013-12-08 13:21:22.000000000 -0500
+++ Xfoil/src/xoper.f	2015-09-26 23:46:49.000000000 -0400
@@ -114,7 +114,7 @@
 C---- don't try to read integers, since might get integer overflow
       DO I=1, NINPUT
         IF(ABS(RINPUT(I)) .GT. 2.1E9) THEN
-         IINPUT(I) = 2**30
+         IINPUT(I) = HUGE(IINPUT) !2**30
         ELSE
          IINPUT(I) = INT(RINPUT(I))
         ENDIF
diff -Nurd -x'*~' Xfoil.orig/src/xpol.f Xfoil/src/xpol.f
--- Xfoil.orig/src/xpol.f	2010-11-08 17:26:54.000000000 -0500
+++ Xfoil/src/xpol.f	2015-09-26 23:46:49.000000000 -0400
@@ -516,6 +516,7 @@
 C
 C---- the polar dump file doesn't exist, so write new header
    60 CONTINUE
+      BACKSPACE(LU)
       WRITE(LU) NAME, 'XFOIL   ', VERSION
       WRITE(LU) MINF1, REINF1/1.0E6, ACRIT(1), ACRIT(2)
       WRITE(LU) MATYP, RETYP
@@ -948,7 +949,8 @@
  1000 FORMAT(A)
       GO TO 10
 C
- 90   RETURN
+ 90   BACKSPACE(LU)
+      RETURN
       END
 
 
@@ -958,7 +960,8 @@
  10   READ(LU,END=90,ERR=90) DUMMY
       GO TO 10
 C
- 90   RETURN
+ 90   BACKSPACE(LU)
+      RETURN
       END
 
 
