--- ddi/compddi.orig	2013-03-05 12:39:40.000000000 +0900
+++ ddi/compddi	2013-03-05 12:40:52.000000000 +0900
@@ -630,7 +630,79 @@
      set FORT_FLAGS = '-O2 -qarch=440  -qflag=W:W -qhalt=W -qnosave '
      set FORT_LIBS  = ''
   endif
+# --------------------------------------- #
+# FreeBSD for x86 PCs                     #
+# --------------------------------------- #
 
+  if($TARGET == freebsd32) then
+
+     set FORTRAN=%%GMS_FORTRAN%%      # choose from g77, gfortran, ifort, pgf77, f2c
+
+     set CC = %%CC%%
+     set CFLAGS = "-DLINUX -O3 -fstrict-aliasing -I./include"
+
+     switch ($FORTRAN)
+        case g77:
+        case pgf77:
+        case f2c:
+           set NumUS=2
+           breaksw
+        case gfortran:
+           set CFLAGS = "$CFLAGS -Dgetarg_=_gfortran_getarg_i4"
+           set CFLAGS = "$CFLAGS -Diargc_=_gfortran_iargc"
+           set NumUS=1
+           breaksw
+        case ifort:
+           set NumUS=1
+           breaksw
+        default:
+           echo Please spell your ia32 compiler correctly.
+           exit 4
+     endsw
+
+     set CLIBS  = "%%PTHREAD_LIBS%%"
+     set F77_OPTS = "-DINT_SIZE=int -D_UNDERSCORES=$NumUS"
+     set FORT_FLAGS = '-O2'
+     set AR_FLAGS     = 'cr'
+     set RANLIB_FLAGS = ' '
+     set FORT_LIBS = ' '
+  endif
+
+# ------------- #
+# FreeBSD amd64 #
+# ------------- #
+  if($TARGET == freebsd64) then
+
+     set CC = %%CC%%
+     set CFLAGS = "-DLINUX -m64 -O3 -fstrict-aliasing -I./include"
+
+     set FORTRAN=%%GMS_FORTRAN%%
+     switch ($FORTRAN)
+        case g77:
+        case pgf77:
+        case f2c:
+           set NumUS=2
+           breaksw
+        case gfortran:
+           set CFLAGS = "$CFLAGS -Dgetarg_=_gfortran_getarg_i4"
+           set CFLAGS = "$CFLAGS -Diargc_=_gfortran_iargc"
+           set FORT_FLAGS = "-O2 $ARCH -fdefault-integer-8 -std=legacy"
+           set NumUS=1
+           breaksw
+        case ifort:
+           set NumUS=1
+           breaksw
+        default:
+           echo Please spell your x86_64 compiler correctly.
+           exit 4
+     endsw
+
+     set CLIBS  = "%%PTHREAD_LIBS%%"
+     set F77_OPTS = "-DINT_SIZE=long -D_UNDERSCORES=$NumUS"
+     set AR_FLAGS     = 'cr'
+     set RANLIB_FLAGS = ' '
+     set FORT_LIBS = ' '
+  endif
 
 # ---------------------------------------- #
 # Linux for 32 bit systems (Red Hat, etc.) #
