AFNI

Compiling

 

Step 3: Get and setup AFNI
export BASE_DIR=/nfsscratch/PREDICT/hjohnson/20121205_src/
mkdir -p ${BASE_DIR}
 
cd ${BASE_DIR}
curl http://afni.nimh.nih.gov/pub/dist/tgz/afni_src.tgz -o afni_src.tgz
tar xfz afni_src.tgz
# Optional: rm /nfsscratch/PREDICT/hjohnson/20121121_src/afni_src.tgz

## NOTE:  Suma won't build  SUMA because of missing GL library, and wont build parallel because it is stupid


cd afni_src
ls Makefile*
sed 's#/usr/bin/gcc#/usr/bin/gcc44#g' Makefile.linux_gcc33_64 | \
sed 's#/usr/X11R6/include#/usr/include#g' | \
sed 's#/usr/X11R6/lib64#/usr/lib64#g' | \
sed 's#LLIBS *= \(.*\)#LLIBS = \1 -lpng -ljpeg -lXm#g' | \
sed 's%^ *INSTALL_PREREQ%#%g' |
sed 's%INSTALLDIR = ./linux_gcc33_64%INSTALLDIR = ./linux_RHEL5%g' >  Makefile
 
make -j1 totality
 

 

 

NOTE:  EVERYTHING BELOW HERE IS NOT RELEVANT OR NEEDED FOR AFNI BUILD THEY ARE NOTES THAT MAY HELP WITH OTHER BUILDS.

 

 

 

Step 1: Get and install f2c
cd /nfsscratch/PREDICT/hjohnson/20121121_src/
# Install f2c executable
rsync -avz netlib.org::netlib/f2c/src f2c
cd f2c
mkdir -p bin share/man/man1
cd src 
make -f makefile.u
cp f2c ../bin
cp f2c.1t ../share/man/man1
 
# Install f2c library
cd .. # PWD == /nfsscratch/PREDICT/hjohnson/20121121_src/f2c
curl http://www.netlib.org/f2c/libf2c.zip>libf2c.zip
mkdir libf2c lib
cd libf2c
unzip ../libf2c.zip
make -f makefile.u
make -f makefile.u install LIBDIR=../lib
 
# Create the module file for f2c
echo -e "#%Module\n\
proc ModuleHelp { } {\n\
       puts stderr " This module loads the Fortran-to-C" \n\
       puts stderr " compiler f2c into your local environment."\n\
	puts stderr " Creation date: 2012-12-05"\n\
}\n\
set env_base 	/nfsscratch/PREDICT/hjohnson/20121121_src/f2c\n\
module-whatis   "module for Fortran-to-C compiler f2c "\n\
set curMod [module-info name]\n\
prepend-path     PATH                    $env_base/bin\n\
prepend-path     LD_LIBRARY_PATH         $env_base/lib\n\
prepend-path     MANPATH                 $env_base/share/man" > ~/privatemodules/f2c
Step 2: Get and install X11
# Possible solution:
sudo yum --installroot=/nfsscratch/PREDICT/hjohnson/20121121_src/X11 install xorg-x11-drivers.x86_64
####################### IGNORE #################################
cd /nfsscratch/PREDICT/hjohnson/20121121_src/
mkdir X11
cd X11
wget -A tar.gz -r http://www.x.org/releases/X11R7.7/src/
mv www.x.org/releases/X11R7.7 ./
rm -rf www.x.org
cd X11R7.7/proto
for FILE in `ls`; do tar xvf $FILE; done
 
tar xvf libX11-1.5.0.tar.gz
cd libX11-1.5.0
 
 
 
# Create the module file for X11R7.7
mkdir ~/privatemodules/X11
echo -e "#%Module\n\
proc ModuleHelp { } {\n\
       puts stderr " This module loads X11" \n\
       puts stderr " into your local environment."\n\
	puts stderr " Creation date: 2012-12-05"\n\
}\n\
set env_base 	/nfsscratch/PREDICT/hjohnson/20121121_src/X11\n\
module-whatis   "module for full X11 "\n\
set curMod [module-info name]\n\
setenv			 X11_DEFAULT			 R7.7
prepend-path     PATH                    $env_base/bin\n\
prepend-path     LD_LIBRARY_PATH         $env_base/lib\n\
prepend-path     MANPATH                 $env_base/share/man" > ~/privatemodules/X11/R7.7
 
# Specify the module version for X11
echo -e "#%Module\n\
\n\
if [info exists env(X11_DEFAULT)] {\n\
	set 	 	ModulesVersion 				 $env(X11_DEFAULT)\n\
} else {\n\
	set			ModulesVersion				 "R7.7"\n\
}" > ~/privatemodules/X11/.version
####################### IGNORE #################################
# Edit Makefile to use /usr/bin/gcc44 and not X11
 
Makefile (edited)
# This Makefile works on Linux.
# This is for compiling with GCC 4.4, on a 64-bit CPU.
GCC = /usr/bin/gcc44
# CPROF = -pg -g
USE_ZLIB = -DHAVE_ZLIB
LZLIB    = -lz
USE_GIFTI = -DHAVE_GIFTI
LGIFTI    = /usr/lib64/libexpat.a
# default to having these off
# D_USE_ACML = -DUSE_ACML
# I_USE_ACML = -I/opt/acml3.1.0/gnu64/include
# L_USE_ACML = /opt/acml3.1.0/gnu64/lib/libacml.a
CCDEBS = -DAFNI_DEBUG -DIMSEQ_DEBUG -DDISPLAY_DEBUG -DTHD_DEBUG
CEXTRA = -Wcomment -Wformat -DUSE_TRACING -DHAVE_XDBE # $(CPROF)
CC     = $(GCC) -O2 -m64 -fPIC -DREAD_WRITE_64 -DLINUX2 $(CEXTRA)
CCVOL  = $(GCC) -O2 -m64 -fPIC -DREAD_WRITE_64 -DLINUX2 $(CEXTRA)
# CCFAST = $(GCC) -O2 -m64 -fPIC -DREAD_WRITE_64 -DLINUX2 $(CEXTRA)
CCOLD  = $(GCC)

# The following line includes compiling for the SSE operations.
# However, I found that it actually makes things worse in some test code.
# Your mileage may vary.
CCFAST = $(GCC) -O3 -mtune=generic -ffast-math -mmmx -msse -mfpmath=sse -DLINUX2 $(CEXTRA)
CCMIN  = $(GCC) -m64 -fPIC $(CPROF)
CCD    = $(GCC) $(CCDEBS)
IFLAGS = -I. # -I/usr/X11R6/include $(I_USE_ACML)
LFLAGS = -L. # -L/usr/X11R6/lib64 $(L_USE_ACML)
# maybe 
CCSVD  = $(GCC) -O0 -m64 -fPIC
PLUGIN_SUFFIX = so
PLUGIN_LFLAGS = -shared -fPIC
PLUGIN_CC     = $(GCC)
# PLFLAGS       = -rdynamic -L. -L/usr/X11R6/lib
PLFLAGS       = -rdynamic -L. # -L/usr/X11R6/lib64
SHOWOFF = -DSHOWOFF=linux_gcc4_64
AR     = /usr/bin/ar
RANLIB = /usr/bin/ranlib
TAR    = /bin/tar
MKDIR  = /bin/mkdir
GZIP   = /bin/gzip
LD     = $(GCC) $(CPROF)
RM = /bin/rm -f
MV = /bin/mv -f
CP = /bin/cp -f
# LINT = /usr/bin/lint -a -b -u -v -x $(IFLAGS) $(CCDEFS)
INSTALLDIR = ../afni/linux_gcc44_64
LIBDIR = $(INSTALLDIR)
#INSTALL_PREREQ = suma
INSTALL_PREREQ = suma_gts
# uncomment if the Gnu Scientific Library is installed (libgsl, libgslcblas)
# GSLPROGS = balloon
EXPROGS = gifti_tool $(GSLPROGS)
# for dynamic linking
LLIBS  = -lmri -lf2c -lXp -lXpm -lXext -lXmu -lXt $(LZLIB) $(LGIFTI) -lm  -ldl -lc
# for static linking to Motif, dynamic to all else
# LLIBS  = -lmri -lf2c /usr/X11R6/lib64/libXm.a -lXp -lXpm -lXext -lXmu -lXt -lSM -lICE -lX11 $(LZLIB) $(LGIFTI) -lm  -ldl -lc
# for static linking, as far as possible
# LLIBS = -lmri -lf2c -ldl               \
#         /usr/X11R6/lib/libXm.a   \
#        /usr/X11R6/lib/libXpm.a  \
#        /usr/X11R6/lib/libXext.a \
#        /usr/X11R6/lib/libXmu.a  \
#        /usr/X11R6/lib/libXt.a   \
#        /usr/X11R6/lib/libSM.a   \
#        /usr/X11R6/lib/libICE.a  \
#        /usr/X11R6/lib/libX11.a  \
#        /usr/lib/libm.a          \
#        /usr/lib/libc.a
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# For suma (NO STATIC LINKING OF GL libs)
SUMA_GLIB_VER = -2.0
SUMA_INCLUDE_PATH = -I./ -I../ -I../niml/ -Igts/src -I/usr/include/glib-1.2 -I/usr/include/glib-2.0 -I/usr/lib64/glib/include -I/usr/lib64/glib-2.0/include
SUMA_LINK_PATH = -L/usr/lib64 -L/usr/X11R6/lib64 -L../
#use -lGLw if you have libGLw.a or libGLw.so* or 
#  -lMesaGLw if you have Mesa's version (libMesaGLw*) of libGLw
SUMA_LINK_LIB = -lGLw -lGLU -lGL -lXmu -lXp -lXt -lXext $(LZLIB) $(LGIFTI) -lm 
SUMA_MAKEFILE_NAME = SUMA_Makefile
SUMA_BIN_ARCHIVE = SUMA_Linux.tar
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
###############################################################
MAKE = make
include Makefile.INCLUDE
Makefile.INCLUDE
##
## Include for MCW AFNI make
##   -- goes at end of each platform specific Makefile.
##
# for compiling with OpenMP, if available
CCOMP   = $(CCFAST) $(OMPFLAG)
EXINCOM = echo '..... Extra install commands (if any) .....' ; $(EXTRA_INSTALL_COMMANDS)
F2C = f2c -A
## 07 Dec 2005: modify the include flags here
INFLAGS  = $(IFLAGS) -Inifti/niftilib -Inifti/nifticdf -Inifti/znzlib -I3DEdge/src -Irickr $(USE_ZLIB) $(USE_GIFTI)
ISFLAGS  = $(IFLAGS) -I../nifti/niftilib -I../nifti/nifticdf -I../nifti/znzlib -I../3DEdge/src -I../rickr $(USE_ZLIB)
DOCS     = ../doc/ps/*.ps ../doc/README/README*                    \
           rickr/AFNI.changes.rickr rhammett/AFNI.changes.rhammett \
           AFNI.changes.dglen
MINDOCS  = rickr/AFNI.changes.rickr AFNI.changes.dglen
IMOBJS  = display.o imseq.o bbox.o xim.o xutil.o LiteClue.o thd_xwebber.o
AFOBJS  = afni.o afni_func.o afni_widg.o afni_warp.o afni_fimmer.o \
            afni_slice_short.o afni_slice_float.o afni_filer.o     \
            afni_slice_byte.o  afni_slice_complex.o                \
            afni_pcor.o afni_pcor_float.o afni_transforms.o        \
            pbar.o afni_graph.o afni_plugin.o afni_cluster.o       \
            parser.o parser_int.o afni_plugout.o afni_fimfunc.o    \
            afni_setup.o afni_receive.o mcw_graf.o afni_splash.o   \
            afni_pplug_env.o afni_pplug_2dfunc.o afni_friends.o    \
            afni_ttren.o afni_pplug_1dfunc.o afni_driver.o         \
            afni_niml.o afni_sumafunc.o afni_slice_rgbyte.o        \
            afni_version.o afni_lock.o afni_vol2surf.o             \
            afni_pplug_instacorr.o afni_pplug_instacalc.o
SOMEAFOBJS = parser_int.o afni_warp.o afni_slice_byte.o afni_slice_short.o \
             afni_slice_float.o afni_slice_complex.o afni_slice_rgbyte.o   \
             parser.o pbar_color_defs.o afni_ports.o
T3OBJS  = to3d.o
MISC    = AFNI_atlas_spaces.niml AFNI.Xdefaults AFNI.afnirc AFNI.sumarc \
          3d*.lib gmovie*
## The following programs are "extras" not really part of the
## AFNI package, but included because they are useful.  Some of
## them are Open Source programs, not from the AFNI group at all.
EXTRAS   = cjpeg djpeg whirlgif mpeg_encode myget Xphace rmz aiv mycat $(EXPROGS)
# mpegtoppm in above list
## This list is the core AFNI package:
## other programs are experimental and/or outsiders.
PROGRAMS = afni to3d from3d abut 3dclust nsize 3dinfo 3dproject 3dmerge count   \
           sfim tfim ftosh 3dttest 3ddup imrotate imreg imstat 3dnvals          \
           fim2 imand FD2 sqwave immask imdump imaver 3dhistog 3dfim 3daxialize \
               cdf 2swap 4swap mritopgm 3dANOVA 3dANOVA2 3dANOVA3 plugout_tta   \
           waver 3dnewid 3dcalc ccalc imcalc 1dmatcalc 3drefit 3dbucket         \
           3dNLfim 3dTSgen AlphaSim 3dFWHM plugout_tt 3dnoise plugout_ijk       \
           3dMannWhitney 3dWilcoxon 3dKruskalWallis 3dFriedman 3dRegAna         \
           2dImReg 3dmaskave 3dbuc2fim byteorder imstack 3dDeconvolve 3dTcat    \
           3drotate 3dvolreg 3dpc 3dfractionize 1dplot adwarp imupsam           \
           3dIntracranial 24swap 3dTsmooth RSFgen float_scan 1dtranspose        \
           3dFourier 3dNotes 3dROIstats 1deval 3dStatClust 3dTstat 3dmaskdump   \
           3dTshift 3dDetrend 1dfft 1dcat 3drename 1dnorm afni_vcheck 3ddot     \
           3dWavelets 3dfim+ imcutup imcat 3dWinsor 3dZeropad 3dTagalign        \
           3dMean 3dAttribute cat_matvec 3dOverlap 3dClipLevel 3dZregrid        \
           3dEntropy 3ddelay ent16 3dRowFillin 1dgrayplot 3dToutcount 1dsum     \
           3dExtrema qhull strblast 3dConvolve 3dZcutup 3dZcat 3dTqual 3dGetrow \
           3dTcorrelate 3dAnatNudge 3dcopy Vecwarp 3dMINCtoAFNI 3dCM fdrval     \
           3dAFNItoANALYZE siemens_vision ge_header mayo_analyze 3dAFNItoNIFTI  \
           3dAutoTcorrelate 3dFDR rtfeedme 3dAutomask 3dAFNItoMINC 3dBrickStat  \
           3dThreetoRGB Ifile 3dresample 3dAutobox 3dLRflip 3dANALYZEtoAFNI     \
           dicom_hdr 3dDespike dicom_to_raw file_tool rotcom 1ddot 1dsvd        \
           3dDeconvolve_f 3dAnhist 3dAFNIto3D 3dUniformize 3dWarp nicat         \
           3dSpatNorm fftest serial_helper 3dDTeig 3dDWItoDT 3dWarpDrive        \
           nifti_tool 3dAllineate nifti1_test whereami plugout_drive 3dLSS      \
           3dMedianFilter 3dretroicor 3dAFNItoNIML 3dAFNItoRaw im2niml 3dedge3  \
           DTIStudioFibertoSegments Dimon 3dLocalstat 3danisosmooth 3dmaxima    \
           3dTwotoComplex 3dInvFMRI 3dmatcalc 3dAcost 3dLocalBistat 3dFWHMx     \
           3dBlurToFWHM 1dSEM 3dDFT 3dSynthesize 1dMarry 3dEmpty 3dsvm          \
           1dFlagMotion 3dTsort 1dTsort 3dTfitter afni_history 1dUpsample       \
           3dLocalSVD  niml_feedme  3dErrtsCormat 3dUndump 3dREMLfit 3dTnorm    \
           3dUpsample 3dTcorrMap 3dmatmult 3dABoverlap 3dmaskSVD 1dBandpass     \
           3dBlurInMask 3dRank 3dFFT 1dgenARMA11 3dPeriodogram 1dAstrip         \
           3dLocalPV 3dBandpass 3dSetupGroupInCorr 3dGroupInCorr 3dTcorr1D      \
           3dClustSim 3dRetinoPhase 3dMaskToASCII 3dttest++ 3dDTtoDWI           \
           niccc rbox qdelaunay 3dkmeans 3dXYZcat 3dPolyfit 3dNwarpApply        \
           1dCorrelate 3dCountSpikes 3dNwarpCalc dicom_hinfo apsearch 1dBport   \
           3dNormalityTest 3dmask_tool FIRdesign help_format 2perm 3dClustCount \
           column_cat $(EXTRAS)
PROGRAMS_NOPLUG = afni to3d from3d abut 3dclust nsize 3dinfo 3dproject 3dmerge      \
                  sfim tfim ftosh 3dttest 3ddup imrotate imreg imstat 3dnoise count \
                  fim2 imand FD2 sqwave immask imdump imaver 3dhistog 3dfim imupsam \
                      cdf 2swap 4swap mritopgm 3dANOVA 3dANOVA2 3dANOVA3 3drefit    \
                  waver 3dnewid 3dcalc ccalc imcalc 2dImReg 3dmaskave adwarp fdrval \
                  3dMannWhitney 3dWilcoxon 3dKruskalWallis 3dFriedman 3dRegAna      \
                  imstack byteorder 3dDeconvolve 3dTcat 3drotate 3dvolreg 1dplot    \
                  24swap 3dTsmooth RSFgen float_scan 3dDeconvolve_f 1ddot 1dsvd     \
                  3dFourier 3dNotes 3dROIstats 1deval 3dStatClust 3dTstat 3ddelay   \
                  3dDTeig 3dDWItoDT 1dtranspose whereami 3dAFNItoNIML 3dcopy imcat  \
                  3dDetrend 1dfft 3drename 1dnorm afni_vcheck 3ddot 3dBrickStat     \
                  imcutup 3dMean 3dAttribute 3dZeropad 3dWinsor 3dmaskdump 3dfim+   \
                  3dUndump cat_matvec 3dOverlap 3dClipLevel 3dZregrid 3dEntropy     \
                  ent16 3dRowFillin 1dgrayplot 3dToutcount 1dsum 3dExtrema strblast \
                  3dConvolve 3dZcutup 3dZcat 3dTqual 3dTcorrelate 3dAnatNudge       \
                  Vecwarp 3dMINCtoAFNI 3dAFNItoANALYZE 3dAFNItoNIFTI siemens_vision \
                  mayo_analyze 3dAutoTcorrelate 3dFDR 3dAutomask 3dAFNItoMINC       \
                  3dThreetoRGB Ifile 3dresample 3dAutobox 3dLRflip 3dANALYZEtoAFNI  \
                  dicom_hdr 3dDespike dicom_to_raw file_tool rotcom 3dUniformize    \
                  3dWarp nicat 3dSpatNorm 3dWarpDrive 3dretroicor ge_header 3dTnorm \
                  3dAFNItoRaw DTIStudioFibertoSegments im2niml 3dLocalstat 3dGetrow \
                  nifti_tool 3dAllineate nifti1_test Dimon 3danisosmooth            \
                  3dmaxima 3dTwotoComplex 3dInvFMRI 1dmatcalc 3dmatcalc 3dAcost     \
                  3dLocalBistat 3dFWHMx 3dBlurToFWHM 1dSEM 3dDFT 3dSynthesize       \
                  1dMarry 3dEmpty 3dTsort 1dTsort 1dFlagMotion 3dTfitter 1dBport    \
                  3dLocalSVD 3dFFT  1dcat  3dErrtsCormat 3dREMLfit 3dTcorrMap       \
                  afni_history 3dUpsample 1dUpsample 3dmatmult 3dABoverlap          \
                  3dmaskSVD 3dRank 3dLocalPV 3dTcorr1D 3dClustSim 3dRetinoPhase     \
                  3dMaskToASCII 3dttest++ 3dDTtoDWI niccc 3dXYZcat 3dPolyfit        \
                  3dNwarpApply 1dCorrelate 3dCountSpikes 3dNwarpCalc dicom_hinfo    \
                  apsearch 3dNormalityTest 3dmask_tool 2perm 3dClustCount           \
                  $(EXTRAS)
# For CYGWIN (look for "exe" to find various places below)
#  Note that 3dNLfim and 3dTSgen are missing for now
PROGRAMS_EXE = afni.exe to3d from3d abut 3dclust nsize 3dinfo 3dproject 3dmerge   \
               sfim tfim ftosh 3dttest 3ddup imrotate imreg imstat 3dnvals count  \
               fim2 imand FD2 sqwave immask imdump imaver 3dhistog 3dfim 3dGetrow \
                   cdf 2swap 4swap mritopgm 3dANOVA 3dANOVA2 3dANOVA3 plugout_tta \
               waver 3dnewid 3dcalc ccalc imcalc 1dmatcalc 3drefit 3dbucket       \
               3dAFNItoNIML    AlphaSim 3dFWHM plugout_tt 3dnoise plugout_ijk     \
               3dMannWhitney 3dWilcoxon 3dKruskalWallis 3dFriedman 3dRegAna       \
               2dImReg 3dmaskave 3dbuc2fim byteorder imstack 3dDeconvolve 3dTcat  \
               3drotate 3dvolreg 3dpc 3dfractionize 1dplot adwarp imupsam 1dBport \
               3dIntracranial 24swap 3dTsmooth RSFgen float_scan 1dtranspose      \
               3dFourier 3dNotes 3dROIstats 1deval 3dStatClust 1ddot 3dBrickStat  \
               3dDWItoDT 3dTstat 3dDTeig 3dmaskdump 3dretroicor 3daxialize imcat  \
               3dTshift 3dDetrend 1dfft 1dcat 3drename 1dnorm afni_vcheck 3ddot   \
               3dWavelets 3dfim+ imcutup 3dWinsor 3dZeropad 3dTagalign 3dUndump   \
               3dMean 3dAttribute cat_matvec 3dOverlap 3dClipLevel 3dZregrid      \
               3dEntropy 3ddelay ent16 3dRowFillin 1dgrayplot 3dToutcount 1dsum   \
               3dExtrema qhull.exe strblast 3dConvolve 3dZcutup 3dZcat 3dTqual    \
               3dTcorrelate 3dAnatNudge 3dcopy Vecwarp 3dMINCtoAFNI 3dAFNItoNIFTI \
               3dAFNItoANALYZE siemens_vision ge_header mayo_analyze 1dsvd        \
               3dAutoTcorrelate 3dFDR 3dAutomask 3dAFNItoMINC 3dThreetoRGB Ifile  \
               3dAutobox 3dLRflip 3dANALYZEtoAFNI dicom_hdr 3dDespike nicat       \
               dicom_to_raw rotcom 3dDeconvolve_f 3dUniformize 3dWarp 3dWarpDrive \
               file_tool 3dresample serial_helper im2niml 3dUpsample         \
               nifti_tool 3dAFNItoRaw DTIStudioFibertoSegments Dimon 3dREMLfit    \
               3danisosmooth 3dTwotoComplex 3dInvFMRI 3dmatcalc 3dAllineate       \
               3dFWHMx 3dBlurToFWHM 1dSEM 3dDFT 3dSynthesize 1dMarry 3dEmpty      \
               1dFlagMotion 3dTsort 1dTsort 3dTfitter afni_history 1dUpsample     \
               3dTcorrMap 3dABoverlap 3dRank 3dFFT 3dTcorr1D 3dClustSim           \
               3dRetinoPhase 3dMaskToASCII 3dttest++ 3dDTtoDWI niccc 3dXYZcat \
               column_cat
SCRIPTS = @4Daverage @CommandGlobb @GetAfniOrient @DTI_studio_reposition          \
          @GetAfniPrefix @NoExt @UpdateAfni @RenamePanga @2dwarper                \
          @GetAfniView @SUMA_AlignToExperiment @SUMA_Make_Spec_FS @Purify_1D      \
          @SUMA_Make_Spec_SF @make_stim_file @Align_Centers suma_change_spec      \
          @CheckForAfniDset @clip_volume @AfniOrient2RAImap @parse_afni_name      \
          @auto_align @auto_tlrc @FromRAI @ToRAI @AfniOrientSign @VolCenter       \
          @Center_Distance @fix_FSsphere @parse_name @align_partial_oblique       \
          @np 3dMax @IsoMasks @SUMA_Make_Spec_Caret @FindAfniDsetPath @GetAfniID  \
          @float_fix @escape- 3dPAR2AFNI.pl @DriveAfni @DriveSuma @AddEdge        \
          @SurfSmooth.HEAT_07.examples @SUMA_FSvolToBRIK @isOblique afni_run_R    \
          @GetAfniDims @GetAfniRes @NoisySkullStrip @statauxcode @ScaleVolume     \
          @ShowDynamicRange AFNI_Batch_R @DO.examples demo.fixed.niml.do          \
          demo.mobile.niml.do @Spharm.examples @GetAfniBin @fast_roi              \
          @make_plug_diff @build_afni_Xlib @update.afni.binaries @ROI_Corr_Mat    \
          @FS_roi_label @demo_prompt @ScriptCheck @NoPound @Reorder 3dSignatures  \
          3dMEMA @DiceMetric @R_funclist @TimeDiff @FullPath @RetinoProc          \
          @ANATICOR @MakeLabelTable @ElectroGrid ExamineXmat 1dRplot              \
          @2dwarper.Allin @Shift_Volume  @help.AFNI @1dDiffMag @FSlabel2dset      \
          @Install_InstaCorr_Demo @Quiet_Talkers @radial_correlate                \
          @DeblankFileNames @clean_help_dir @global_parse @AfniEnv @Atlasize      \
          @Install_TSrestMovieDemo @Install_AfniRetinoDemo                        \
          @Install_PTaylor_TractDemo @Install_RSFMRI_Motion_Group_Demo            \
          @Install_MEICA_Demo @T1scale 3dMVM  
PY_DIR = python_scripts
PY_SCRIPTS = afni_base.py @DoPerRoi.py
R_DIR = R_scripts
LIBHEADERS = mrilib.h mcw_glob.h 3ddata.h thd_maker.h thd_iochan.h            \
             editvol.h cs.h eispack.h killer.h vecmat.h machdep.h tagset.h    \
             thd_compress.h afni_warp.h coxplot.h f2c.h volpack.h mcw_malloc.h\
             multivector.h afni_environ.h niml.h cs_sort_template.h vol2surf.h\
             AFNI_label.h Amalloc.h afni_suma.h debugtrace.h list_struct.h    \
             mri_dicom_stuff.h mri_warpfield.h nifti/niftilib/nifti1.h        \
             nifti/niftilib/nifti1_io.h nifti/nifticdf/nifticdf.h             \
             nifti/znzlib/znzlib.h                                            \
             rickr/r_new_resam_dset.h rickr/r_idisp.h rickr/r_misc.h
### Make everything, install it too, and cleanup
totality:clean all plugins install install_plugins install_lib cleann
### Make everything, install it too, but don't cleanup
vastness:all plugins install install_plugins install_lib
### Make many things
all:$(LIBDL) libmri.a libmrix.a libcoxplot.a libvolpack.a libtracktools.a \
             R_io.so programs ptaylor_all
### Make afni binaries
afobj:$(AFOBJS) libf2c.a libcoxplot.a libvolpack.a libmrix.a libjpeg.a libXmHTML.a
afobjs: afobj
### Make a few more things
itall:all plugins install install_plugins
$(INSTALLDIR):
	if [ ! -d $(INSTALLDIR) ]; then $(MKDIR) -p $(INSTALLDIR); echo Made directory $(INSTALLDIR); fi
### for those on crippled systems
all_noplug:libmri.a libmrix.a libcoxplot.a programs_noplug
totality_noplug:libmri.a libmrix.a libcoxplot.a programs_noplug install_noplug clean
# CYGWIN: variations on totality and vastness above
totality_exe:libmri.a libmrix.a libcoxplot.a programs_exe install_exe clean_exe
vastness_exe:libmri.a libmrix.a libcoxplot.a programs_exe install_exe
programs:$(PROGRAMS)
programs_noplug:$(PROGRAMS_NOPLUG)
programs_exe:$(PROGRAMS_EXE)
libraries:libmri.a libmrix.a libcoxplot.a libvolpack.a libf2c.a
### rules for individual programs
quotize:quotize.o
	$(CC) -o quotize quotize.o $(LFLAGS) $(LLIBS)
license.h:../doc/README/README.copyright
	quotize license < ../doc/README/README.copyright > license.h
readmes:readme_env.h readme_afnigui.h
readme_env.h:../doc/README/README.environment
	quotize readme_env < ../doc/README/README.environment > readme_env.h
readme_afnigui.h:../doc/README/README.afnigui
	quotize readme_afnigui < ../doc/README/README.afnigui > readme_afnigui.h
Ifile:Ifile.o
	$(CC) -o Ifile Ifile.o $(LFLAGS) $(LLIBS)
3dHmetric:3dHmetric.o
	$(CC) -o 3dHmetric 3dHmetric.o $(LFLAGS) $(LLIBS)
3dJointHist:3dJointHist.o
	$(CC) -o 3dJointHist 3dJointHist.o $(LFLAGS) $(LLIBS)
3dUndump:3dUndump.o
	$(CC) -o 3dUndump 3dUndump.o $(LFLAGS) $(LLIBS)
3dGetrow:3dGetrow.o
	$(CC) -o 3dGetrow 3dGetrow.o $(LFLAGS) $(LLIBS)
3dnoise:3dnoise.o
	$(CC) -o 3dnoise 3dnoise.o $(LFLAGS) $(LLIBS)
3dstrip:3dstrip.o
	$(CC) -o 3dstrip 3dstrip.o $(LFLAGS) $(LLIBS)
byteorder:byteorder.o
	$(CC) -o byteorder byteorder.o $(LFLAGS) $(LLIBS)
3dbuc2fim:3dbuc2fim.o
	$(CC) -o 3dbuc2fim 3dbuc2fim.o $(LFLAGS) $(LLIBS)
mritopgm:mritopgm.c
	$(CC) -o mritopgm mritopgm.c $(INFLAGS) $(LFLAGS) $(LLIBS)
ppmtocmap:ppmtocmap.c
	$(CC) -o ppmtocmap ppmtocmap.c $(INFLAGS) $(LFLAGS) $(LLIBS)
impdif:impdif.c
	$(CC) -o impdif impdif.c $(INFLAGS) $(LFLAGS) $(LLIBS)
imcutup:imcutup.c
	$(CC) -o imcutup imcutup.c $(INFLAGS) $(LFLAGS) $(LLIBS)
imcat:imcat.c
	$(CC) -o imcat imcat.c $(INFLAGS) $(LFLAGS) $(LLIBS)
Vecwarp:Vecwarp.c
	$(CC) -o Vecwarp Vecwarp.c $(INFLAGS) $(LFLAGS) $(LLIBS)
float_scan:float_scan.c
	$(CC) -o float_scan float_scan.c $(INFLAGS) $(LFLAGS) $(LLIBS)
to26:to26.c
	$(CC) -o to26 to26.c $(INFLAGS) $(LFLAGS) $(LLIBS)
toxx:toxx.c
	$(CC) -o toxx toxx.c $(INFLAGS) $(LFLAGS) $(LLIBS)
imupsam:imupsam.c
	$(CC) -o imupsam imupsam.c $(INFLAGS) $(LFLAGS) $(LLIBS)
2swap:2swap.c
	$(CC) -o 2swap 2swap.c $(INFLAGS) $(LFLAGS) $(LLIBS)
4swap:4swap.c
	$(CC) -o 4swap 4swap.c $(INFLAGS) $(LFLAGS) $(LLIBS)
24swap:24swap.c
	$(CC) -o 24swap 24swap.c $(INFLAGS) $(LFLAGS) $(LLIBS)
crao:crao.o
	$(CC) -o crao crao.o $(LFLAGS) $(LLIBS)
crao2:crao2.o
	$(CC) -o crao2 crao2.o $(LFLAGS) $(LLIBS)
imaver:imaver.o
	$(CC) -o imaver imaver.o $(LFLAGS) $(LLIBS)
impsd:impsd.o
	$(CC) -o impsd impsd.o $(LFLAGS) $(LLIBS)
zfuntest:zfuntest.o
	$(CC) -o zfuntest zfuntest.o $(LFLAGS) $(LLIBS)
imdump:imdump.o
	$(CC) -o imdump imdump.o $(LFLAGS) $(LLIBS)
im2niml:im2niml.o
	$(CC) -o im2niml im2niml.o $(LFLAGS) $(LLIBS)
imswap:imswap.o
	$(CC) -o imswap imswap.o $(LFLAGS) $(LLIBS)
immask:immask.o
	$(CC) -o immask immask.o $(LFLAGS) $(LLIBS)
sqwave:sqwave.o
	$(CC) -o sqwave sqwave.o
pcor.o:pcor.c pcor.h
	$(RM) $@
	$(CC) -c pcor.c $(INFLAGS) -DREF_FLOAT_SINGLE -UVOX_SHORT
pcorsh.o:pcor.c pcor.h
	$(RM) $@
	$(CP) pcor.c pcorsh.c
	$(CC) -c pcorsh.c $(INFLAGS) -DREF_FLOAT_SINGLE -DVOX_SHORT
	$(RM) pcorsh.c
# FD2:FD2.o ts.o mcw.o overfim.o pcorsh.o csfft_AJ.o
# 	$(RM) $@
# 	$(CC) -o FD2 FD2.o mcw.o overfim.o ts.o pcorsh.o csfft_AJ.o $(LFLAGS) $(LLIBS)
FD2.o:FD2.c FD2_inc.c
FD2:FD2.o ts.o mcw.o overfim.o pcorsh.o csfft_AJ.o FD2_inc.c
	$(RM) $@
	$(CC) -o FD2 FD2.o mcw.o overfim.o ts.o pcorsh.o csfft_AJ.o $(LFLAGS) -lX11 -lm -lc
dFD2:dFD2.o ts.o mcw.o overfim.o pcorsh.o
	$(RM) $@
	$(CC) -o dFD2 dFD2.o mcw.o overfim.o ts.o pcorsh.o $(LFLAGS) $(LLIBS)
fim:fim.c
	$(RM) $@
	$(CC) -o fim fim.c -DSYSV $(LFLAGS) $(LLIBS)
bzip2:bzip2.o
	$(CC) -o bzip2 bzip2.o
fim2:fim2.o ts.o pcor.o
	$(RM) $@
	$(CC) -o fim2 fim2.o ts.o pcor.o $(LFLAGS) $(LLIBS)
imstat:imstat.o
	$(RM) $@
	$(CC) -o imstat imstat.o $(LFLAGS) $(LLIBS)
imstack:imstack.o
	$(RM) $@
	$(CC) -o imstack imstack.o $(LFLAGS) $(LLIBS)
imreg:imreg.o pcor.o
	$(RM) $@
	$(CC) -o imreg imreg.o pcor.o $(LFLAGS) $(LLIBS)
FIRdesign.o:FIRdesign.c remez.c remez.h
FIRdesign:FIRdesign.o
	$(RM) $@
	$(CC) -o FIRdesign FIRdesign.o $(LFLAGS) $(LLIBS)
imfit:imfit.o
	$(RM) $@
	$(CC) -o imfit imfit.o $(LFLAGS) $(LLIBS)
imand:imand.o
	$(RM) $@
	$(CC) -o imand imand.o $(LFLAGS) $(LLIBS)
imrotate:imrotate.o
	$(RM) $@
	$(CC) -o imrotate imrotate.o $(LFLAGS) $(LLIBS)
dsetdup:dsetdup.o
	$(RM) $@
	$(CC) -o dsetdup dsetdup.o $(LFLAGS) $(LLIBS)
3ddup:3ddup.o
	$(RM) $@
	$(CC) -o 3ddup 3ddup.o $(LFLAGS) $(LLIBS)
3dZeropad:3dZeropad.o
	$(RM) $@
	$(CC) -o 3dZeropad 3dZeropad.o $(LFLAGS) $(LLIBS)
3dnvals:3dnvals.o
	$(RM) $@
	$(CC) -o 3dnvals 3dnvals.o $(LFLAGS) $(LLIBS)
3dAttribute:3dAttribute.o
	$(RM) $@
	$(CC) -o 3dAttribute 3dAttribute.o $(LFLAGS) $(LLIBS)
3dproject:3dproject.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dproject 3dproject.o parser.o parser_int.o \
                 $(LFLAGS) $(LLIBS)
3dinfo:3dinfo.o
	$(RM) $@
	$(CC) -o 3dinfo 3dinfo.o $(LFLAGS) $(LLIBS)
3dmaskave:3dmaskave.o
	$(RM) $@
	$(CC) -o 3dmaskave 3dmaskave.o $(LFLAGS) $(LLIBS)
3dmaskdump:3dmaskdump.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dmaskdump 3dmaskdump.o parser.o parser_int.o \
                 $(LFLAGS) $(LLIBS)
3drefit:3drefit.o
	$(RM) $@
	$(CC) -o 3drefit 3drefit.o $(LFLAGS) $(LLIBS)
3drename:3drename.o
	$(RM) $@
	$(CC) -o 3drename 3drename.o $(LFLAGS) $(LLIBS)
3dcopy:3dcopy.o
	$(RM) $@
	$(CC) -o 3dcopy 3dcopy.o $(LFLAGS) $(LLIBS)
3daxialize:3daxialize.o
	$(RM) $@
	$(CC) -o 3daxialize 3daxialize.o $(LFLAGS) $(LLIBS)
3dfractionize:3dfractionize.o
	$(RM) $@
	$(CC) -o 3dfractionize 3dfractionize.o $(LFLAGS) $(LLIBS)
3dbucket:3dbucket.o
	$(RM) $@
	$(CC) -o 3dbucket 3dbucket.o $(LFLAGS) $(LLIBS)
3dZcutup:3dZcutup.o
	$(RM) $@
	$(CC) -o 3dZcutup 3dZcutup.o $(LFLAGS) $(LLIBS)
3dZcat:3dZcat.o
	$(RM) $@
	$(CC) -o 3dZcat 3dZcat.o $(LFLAGS) $(LLIBS)
3dXYZcat:3dXYZcat.o
	$(RM) $@
	$(CC) -o 3dXYZcat 3dXYZcat.o $(LFLAGS) $(LLIBS)
3dTqual:3dTqual.o
	$(RM) $@
	$(CC) -o 3dTqual 3dTqual.o $(LFLAGS) $(LLIBS)
3dTcat:3dTcat.o
	$(RM) $@
	$(CC) -o 3dTcat 3dTcat.o $(LFLAGS) $(LLIBS)
3dSynthesize:3dSynthesize.o
	$(RM) $@
	$(CC) -o 3dSynthesize 3dSynthesize.o $(LFLAGS) $(LLIBS)
3dTcorrelate:3dTcorrelate.o
	$(RM) $@
	$(CC) -o 3dTcorrelate 3dTcorrelate.o $(LFLAGS) $(LLIBS)
3dTagalign:3dTagalign.o
	$(RM) $@
	$(CC) -o 3dTagalign 3dTagalign.o $(LFLAGS) $(LLIBS)
3dTshift:3dTshift.o
	$(RM) $@
	$(CC) -o 3dTshift 3dTshift.o $(LFLAGS) $(LLIBS)
3dTnorm:3dTnorm.o
	$(RM) $@
	$(CC) -o 3dTnorm 3dTnorm.o $(LFLAGS) $(LLIBS)
3dTstat:3dTstat.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dTstat 3dTstat.o parser.o parser_int.o $(LFLAGS) \
          $(LLIBS)
3dTfitter:3dTfitter.o thd_fitter.o thd_lasso.o
	$(RM) $@
	$(CC) -o 3dTfitter 3dTfitter.o $(LFLAGS) $(LLIBS)
3dTsort:3dTsort.o
	$(RM) $@
	$(CC) -o 3dTsort 3dTsort.o $(LFLAGS) $(LLIBS)
3dPeriodogram:3dPeriodogram.o
	$(RM) $@
	$(CC) -o 3dPeriodogram 3dPeriodogram.o $(LFLAGS) $(LLIBS)
1dAstrip:1dAstrip.o
	$(RM) $@
	$(CC) -o 1dAstrip 1dAstrip.o
1dBport.o:1dBport.c mri_bport.c
1dBport:1dBport.o
	$(RM) $@
	$(CC) -o 1dBport 1dBport.o $(LFLAGS) $(LLIBS)
3dLocalBistat:3dLocalBistat.o
	$(RM) $@
	$(CC) -o 3dLocalBistat 3dLocalBistat.o $(LFLAGS) $(LLIBS)
3dmaskSVD:3dmaskSVD.o
	$(RM) $@
	$(CC) -o 3dmaskSVD 3dmaskSVD.o $(LFLAGS) $(LLIBS)
3dBlurToFWHM:3dBlurToFWHM.o
	$(RM) $@
	$(CCFAST) -o 3dBlurToFWHM 3dBlurToFWHM.o $(LFLAGS) $(LLIBS)
3dDFT:3dDFT.o
	$(RM) $@
	$(CC) -o 3dDFT 3dDFT.o $(LFLAGS) $(LLIBS)
3dRetinoPhase:3dRetinoPhase.o
	$(RM) $@
	$(CC) -o 3dRetinoPhase 3dRetinoPhase.o $(LFLAGS) $(LLIBS)
3dDTeig:3dDTeig.o libmri.a
	$(RM) $@
	$(CC) -o 3dDTeig 3dDTeig.o $(LFLAGS) $(LLIBS)
3dDWItoDT:3dDWItoDT.o libmri.a
	$(RM) $@
	$(CC) -o 3dDWItoDT 3dDWItoDT.o $(LFLAGS) $(LLIBS)
1dSEM:1dSEM.o libmri.a sqrmat.o matrix.c matrix.h
	$(RM) $@
	$(CC) -o 1dSEM 1dSEM.o sqrmat.o $(LFLAGS) $(LLIBS)
3dDTtoDWI:3dDTtoDWI.o libmri.a
	$(RM) $@
	$(CC) -o 3dDTtoDWI 3dDTtoDWI.o $(LFLAGS) $(LLIBS)
3danisosmooth:3danisosmooth.o DWIstructtensor.o libmri.a
	$(RM) $@
	$(CCFAST) -o 3danisosmooth 3danisosmooth.o DWIstructtensor.o \
          $(LFLAGS) $(LLIBS)
	
3dToutcount:3dToutcount.o
	$(RM) $@
	$(CC) -o 3dToutcount 3dToutcount.o $(LFLAGS) $(LLIBS)
	
3dCountSpikes:3dCountSpikes.o
	$(RM) $@
	$(CC) -o 3dCountSpikes 3dCountSpikes.o $(LFLAGS) $(LLIBS)
3dTsmooth:3dTsmooth.o
	$(RM) $@
	$(CC) -o 3dTsmooth 3dTsmooth.o $(LFLAGS) $(LLIBS)
3dMean:3dMean.o
	$(RM) $@
	$(CC) -o 3dMean 3dMean.o $(LFLAGS) $(LLIBS)
3dBrickStat:3dBrickStat.o
	$(RM) $@
	$(CC) -o 3dBrickStat 3dBrickStat.o $(LFLAGS) $(LLIBS)
3dMINCtoAFNI:3dMINCtoAFNI.o
	$(RM) $@
	$(CC) -o 3dMINCtoAFNI 3dMINCtoAFNI.o $(LFLAGS) $(LLIBS)
3dAFNItoMINC:3dAFNItoMINC.o
	$(RM) $@
	$(CC) -o 3dAFNItoMINC 3dAFNItoMINC.o $(LFLAGS) $(LLIBS)
3dAFNItoRaw:3dAFNItoRaw.o
	$(RM) $@
	$(CC) -o 3dAFNItoRaw 3dAFNItoRaw.o $(LFLAGS) $(LLIBS)
3dAFNItoNIML:3dAFNItoNIML.o
	$(RM) $@
	$(CC) -o 3dAFNItoNIML 3dAFNItoNIML.o $(LFLAGS) $(LLIBS)
3dAFNIto3D:3dAFNIto3D.o
	$(RM) $@
	$(CC) -o 3dAFNIto3D 3dAFNIto3D.o $(LFLAGS) $(LLIBS)
3dAFNItoANALYZE:3dAFNItoANALYZE.o
	$(RM) $@
	$(CC) -o 3dAFNItoANALYZE 3dAFNItoANALYZE.o $(LFLAGS) $(LLIBS)
3dANALYZEtoAFNI:3dANALYZEtoAFNI.o
	$(RM) $@
	$(CC) -o 3dANALYZEtoAFNI 3dANALYZEtoAFNI.o $(LFLAGS) $(LLIBS)
3dThreetoRGB:3dThreetoRGB.o
	$(RM) $@
	$(CC) -o 3dThreetoRGB 3dThreetoRGB.o $(LFLAGS) $(LLIBS)
3dTwotoComplex:3dTwotoComplex.o
	$(RM) $@
	$(CC) -o 3dTwotoComplex 3dTwotoComplex.o $(LFLAGS) $(LLIBS)
3dInvFMRI:3dInvFMRI.o
	$(RM) $@
	$(CC) -o 3dInvFMRI 3dInvFMRI.o $(LFLAGS) $(LLIBS)
3dvolreg:3dvolreg.o
	$(RM) $@
	$(CC) -o 3dvolreg 3dvolreg.o $(LFLAGS) $(LLIBS)
3dedge:3dedge.o
	$(RM) $@
	$(CC) -o 3dedge 3dedge.o $(LFLAGS) $(LLIBS)
from3d:from3d.o
	$(RM) $@
	$(CC) -o from3d from3d.o $(LFLAGS) $(LLIBS)
3dfim:3dfim.o afni_pcor_float.o ts.o
	$(RM) $@
	$(CC) -o 3dfim 3dfim.o ts.o afni_pcor_float.o $(LFLAGS) $(LLIBS)
3T_toafni:3T_toafni.o
	$(RM) $@
	$(CC) -o 3T_toafni 3T_toafni.o $(LFLAGS) $(LLIBS)
3dRank:3dRank.o
	$(RM) $@
	$(CC) -o 3dRank 3dRank.o $(LFLAGS) $(LLIBS)
3dRankizer:3dRankizer.o
	$(RM) $@
	$(CC) -o 3dRankizer 3dRankizer.o $(LFLAGS) $(LLIBS)
p2t:p2t.o
	$(RM) $@
	$(CC) -o p2t p2t.o $(LFLAGS) $(LLIBS)
cdf:cdf.o
	$(RM) $@
	$(CC) -o cdf cdf.o $(LFLAGS) $(LLIBS)
fdrval:fdrval.o
	$(RM) $@
	$(CC) -o fdrval fdrval.o $(LFLAGS) $(LLIBS)
hide:hide.o
	$(RM) $@
	$(CC) -o hide hide.o $(LFLAGS)
count:count.o
	$(RM) $@
	$(CC) -o count count.o $(LFLAGS) $(LLIBS)
nsize:nsize.o
	$(RM) $@
	$(CC) -o nsize nsize.o $(LFLAGS) $(LLIBS)
3dclust:3dclust.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dclust 3dclust.o parser.o parser_int.o \
              $(LFLAGS) $(LLIBS)
3dhistog:3dhistog.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dhistog 3dhistog.o  parser.o parser_int.o \
              $(LFLAGS) $(LLIBS)
3dAnhist:3dAnhist.o
	$(RM) $@
	$(CC) -o 3dAnhist 3dAnhist.o $(LFLAGS) $(LLIBS)
3dhclip:3dhclip.o
	$(RM) $@
	$(CC) -o 3dhclip 3dhclip.o $(LFLAGS) $(LLIBS)
3dErrtsCormat:3dErrtsCormat.o
	$(RM) $@
	$(CC) -o 3dErrtsCormat 3dErrtsCormat.o $(LFLAGS) $(LLIBS)
3dLocalCormat:3dLocalCormat.o
	$(RM) $@
	$(CC) -o 3dLocalCormat 3dLocalCormat.o $(LFLAGS) $(LLIBS)
3dmerge:3dmerge.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dmerge 3dmerge.o parser.o parser_int.o \
                 $(LFLAGS) $(LLIBS)
3dcalc:3dcalc.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dcalc 3dcalc.o parser.o parser_int.o \
              $(LFLAGS) $(LLIBS)
3dDetrend:3dDetrend.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dDetrend 3dDetrend.o parser.o parser_int.o \
              $(LFLAGS) $(LLIBS)
d3dmerge:3dmerge.c
	$(RM) $@
	$(CCD) -o d3dmerge 3dmerge.c $(LFLAGS) $(LLIBS)
3dttest:3dttest.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dttest 3dttest.o parser.o parser_int.o $(LFLAGS) $(LLIBS)
3dttest++:3dttest++.o
	$(RM) $@
	$(CC) -o 3dttest++ 3dttest++.o $(LFLAGS) $(LLIBS)
3dedge3:lib3DEdge.a 3dedge3.o
	$(RM) $@
	$(CC) -o 3dedge3 3dedge3.o -I3DEdge/src            \
              $(LFLAGS) -l3DEdge $(LLIBS)
### From Stephen LaConte
3dsvm:
	( cd svm/   ;  							\
          $(CC) -o 3dsvm 3dsvm_common.c svm_common.c svm_learn.c	\
		svm_hideo.c 3dsvm.c 					\
                -I.. $(ISFLAGS) -L.. $(LFLAGS) $(LLIBS) -lf2c -lmri ;   \
	  $(MV) 3dsvm ../. ; 						\
          cd .. ;)
whereami:whereami.c
	$(RM) $@
	$(CC) -o whereami whereami.c parser.o parser_int.o $(INFLAGS) $(LFLAGS) $(LLIBS)
apsearch:apsearch.c
	$(RM) $@
	$(CC) -o apsearch apsearch.c $(INFLAGS) $(LFLAGS) $(LLIBS)
3dSegment:3dSegment.c
	$(RM) $@
	$(CC) -o 3dSegment 3dSegment.c parser.o parser_int.o $(INFLAGS) $(LFLAGS) $(LLIBS)
3dUniformize:3dUniformize.o
	$(RM) $@
	$(CC) -o 3dUniformize 3dUniformize.o $(PLFLAGS) $(LLIBS)
3dpc:3dpc.o
	$(RM) $@
	$(CC) -o 3dpc 3dpc.o $(LFLAGS) $(LLIBS)
3duca:3duca.o
	$(RM) $@
	$(CC) -o 3duca 3duca.o $(LFLAGS) $(LLIBS)
3duuu:3duuu.o uuu.c
	$(RM) $@
	$(CC) -o 3duuu 3duuu.o $(LFLAGS) $(LLIBS)
3duuu2:3duuu2.o uuu2.c
	$(RM) $@
	$(CC) -o 3duuu2 3duuu2.o $(LFLAGS) $(LLIBS)
3ddot:3ddot.o
	$(RM) $@
	$(CC) -o 3ddot 3ddot.o $(LFLAGS) $(LLIBS)
3dPaxes:3dPaxes.o
	$(RM) $@
	$(CC) -o 3dPaxes 3dPaxes.o $(LFLAGS) $(LLIBS)
3dRowFillin:3dRowFillin.o
	$(RM) $@
	$(CC) -o 3dRowFillin 3dRowFillin.o $(LFLAGS) $(LLIBS)
3dZFillin:3dZFillin.o
	$(RM) $@
	$(CC) -o 3dZFillin 3dZFillin.o $(LFLAGS) $(LLIBS)
3ddelay:3ddelay.o
	$(RM) $@
	$(CC) -o 3ddelay 3ddelay.o $(LFLAGS) $(LLIBS)
ent16:ent16.o
	$(RM) $@
	$(CC) -o ent16 ent16.o $(LFLAGS) $(LLIBS)
strblast:strblast.o
	$(RM) $@
	$(CC) -o strblast strblast.o $(LFLAGS) $(LLIBS)
3dEntropy:3dEntropy.o
	$(RM) $@
	$(CC) -o 3dEntropy 3dEntropy.o $(LFLAGS) $(LLIBS)
3dZregrid:3dZregrid.o
	$(RM) $@
	$(CC) -o 3dZregrid 3dZregrid.o $(LFLAGS) $(LLIBS)
3dOverlap:3dOverlap.o
	$(RM) $@
	$(CC) -o 3dOverlap 3dOverlap.o $(LFLAGS) $(LLIBS)
3dABoverlap:3dABoverlap.o
	$(RM) $@
	$(CC) -o 3dABoverlap 3dABoverlap.o $(LFLAGS) $(LLIBS)
3dNormalityTest.o:3dNormalityTest.c
	$(RM) $@
	$(CCFAST) -c 3dNormalityTest.c $(INFLAGS)
3dNormalityTest:3dNormalityTest.o
	$(RM) $@
	$(CCFAST) -o 3dNormalityTest 3dNormalityTest.o $(LFLAGS) $(LLIBS)
3dClipLevel:3dClipLevel.o
	$(RM) $@
	$(CC) -o 3dClipLevel 3dClipLevel.o $(LFLAGS) $(LLIBS)
3dAutomask:3dAutomask.o
	$(RM) $@
	$(CC) -o 3dAutomask 3dAutomask.o $(LFLAGS) $(LLIBS)
3dLRflip:3dLRflip.o
	$(RM) $@
	$(CC) -o 3dLRflip 3dLRflip.o $(LFLAGS) $(LLIBS)
3dAutobox:3dAutobox.o
	$(RM) $@
	$(CC) -o 3dAutobox 3dAutobox.o $(LFLAGS) $(LLIBS)
3dWinsor:3dWinsor.o
	$(RM) $@
	$(CC) -o 3dWinsor 3dWinsor.o $(LFLAGS) $(LLIBS)
3dMedianFilter:3dMedianFilter.o
	$(RM) $@
	$(CC) -o 3dMedianFilter 3dMedianFilter.o $(LFLAGS) $(LLIBS)
3dPolyfit:3dPolyfit.o
	$(RM) $@
	$(CC) -o 3dPolyfit 3dPolyfit.o $(LFLAGS) $(LLIBS)
3drotate:3drotate.o
	$(RM) $@
	$(CC) -o 3drotate 3drotate.o $(LFLAGS) $(LLIBS)
3dWarp:3dWarp.o
	$(RM) $@
	$(CC) -o 3dWarp 3dWarp.o $(LFLAGS) $(LLIBS)
3dWarpDrive:3dWarpDrive.o
	$(RM) $@
	$(CC) -o 3dWarpDrive 3dWarpDrive.o $(LFLAGS) $(LLIBS)
qm:qm.o
	$(RM) $@
	$(CC) -o qm qm.o $(LFLAGS) $(LLIBS)
3dAcost:3dAcost.o
	$(RM) $@
	$(CCFAST) -o 3dAcost 3dAcost.o $(LFLAGS) $(LLIBS)
3dSetupGroupInCorr.o:3dSetupGroupInCorr.c
	$(RM) $@
	$(CCFAST) -c 3dSetupGroupInCorr.c $(INFLAGS)
3dSetupGroupInCorr:3dSetupGroupInCorr.o
	$(RM) $@
	$(CCFAST) -o 3dSetupGroupInCorr 3dSetupGroupInCorr.o $(LFLAGS) $(LLIBS)
3dTransformGroupInCorr:3dTransformGroupInCorr.o
	$(RM) $@
	$(CCFAST) -o 3dTransformGroupInCorr 3dTransformGroupInCorr.o $(LFLAGS) $(LLIBS)
3dExtractGroupInCorr:3dExtractGroupInCorr.o
	$(RM) $@
	$(CCFAST) -o 3dExtractGroupInCorr 3dExtractGroupInCorr.o $(LFLAGS) $(LLIBS)
rotcom:rotcom.o
	$(RM) $@
	$(CC) -o rotcom rotcom.o $(LFLAGS) $(LLIBS)
3dDistize:3dDistize.o
	$(RM) $@
	$(CC) -o 3dDistize 3dDistize.o $(LFLAGS) $(LLIBS)
3dDimize:3dDimize.o
	$(RM) $@
	$(CC) -o 3dDimize 3dDimize.o $(LFLAGS) $(LLIBS)
3dAnatNudge:3dAnatNudge.o
	$(RM) $@
	$(CC) -o 3dAnatNudge 3dAnatNudge.o $(LFLAGS) $(LLIBS)
rtfeedme:rtfeedme.o
	$(RM) $@
	$(CC) -o rtfeedme rtfeedme.o $(LFLAGS) $(LLIBS)
niml_feedme:niml_feedme.o
	$(RM) $@
	$(CC) -o niml_feedme niml_feedme.o $(LFLAGS) $(LLIBS)
3dFDR:3dFDR.o
	$(RM) $@
	$(CC) -o 3dFDR 3dFDR.o $(LFLAGS) $(LLIBS)
3dANOVA.o: 3dANOVA.lib
3dANOVA2.o:3dANOVA.lib
3dANOVA3.o:3dANOVA.lib
3dANOVA:3dANOVA.o
	$(RM) $@
	$(CC) -o 3dANOVA 3dANOVA.o $(LFLAGS) $(LLIBS)
3dANOVA2:3dANOVA2.o
	$(RM) $@
	$(CC) -o 3dANOVA2 3dANOVA2.o $(LFLAGS) $(LLIBS)
3dANOVA3:3dANOVA3.o
	$(RM) $@
	$(CC) -o 3dANOVA3 3dANOVA3.o $(LFLAGS) $(LLIBS)
3dNLfim:3dNLfim.o NLfit.c NLfit.h NLfit_model.c NLfit_model.h simplex.c  parser.o parser_int.o
	$(RM) $@
	$(CCFAST) -o 3dNLfim 3dNLfim.o $(PLFLAGS) $(LFLAGS)  parser.o parser_int.o $(LLIBS)
3dNLfim_n:3dNLfim_n.o NLfit.c NLfit.h NLfit_model.c NLfit_model.h simplex.c
	$(RM) $@
	$(CC) -o 3dNLfim_n 3dNLfim_n.o $(PLFLAGS) $(LFLAGS) $(LLIBS)
3dNeocon:3dNeocon.o
	$(RM) $@
	$(CCFAST) -o 3dNeocon 3dNeocon.o $(PLFLAGS) $(LFLAGS) $(LLIBS)
3dStatClust:3dStatClust.o
	$(RM) $@
	$(CC) -o 3dStatClust 3dStatClust.o $(PLFLAGS) $(LLIBS)
RSFgen:RSFgen.o
	$(RM) $@
	$(CC) -o RSFgen RSFgen.o $(LFLAGS) $(LLIBS)
3dTSgen:3dTSgen.o NLfit.c NLfit.h NLfit_model.c NLfit_model.h
	$(RM) $@
	$(CC) -o 3dTSgen 3dTSgen.o $(PLFLAGS) $(LLIBS)
3dFWHM:3dFWHM.o
	$(RM) $@
	$(CC) -o 3dFWHM 3dFWHM.o $(LFLAGS) $(LLIBS)
3dFWHMx:3dFWHMx.o
	$(RM) $@
	$(CC) -o 3dFWHMx 3dFWHMx.o $(LFLAGS) $(LLIBS)
3dMannWhitney:3dMannWhitney.o
	$(RM) $@
	$(CC) -o 3dMannWhitney 3dMannWhitney.o $(LFLAGS) $(LLIBS)
3dWilcoxon:3dWilcoxon.o
	$(RM) $@
	$(CC) -o 3dWilcoxon 3dWilcoxon.o $(LFLAGS) $(LLIBS)
3dWavelets:3dWavelets.o
	$(RM) $@
	$(CC) -o 3dWavelets 3dWavelets.o $(LFLAGS) $(LLIBS)
3dfim+:3dfim+.o
	$(RM) $@
	$(CC) -o 3dfim+ 3dfim+.o $(LFLAGS) $(LLIBS)
3dKruskalWallis:3dKruskalWallis.o
	$(RM) $@
	$(CC) -o 3dKruskalWallis 3dKruskalWallis.o $(LFLAGS) $(LLIBS)
3dFriedman:3dFriedman.o
	$(RM) $@
	$(CC) -o 3dFriedman 3dFriedman.o $(LFLAGS) $(LLIBS)
3dRegAna:3dRegAna.o
	$(RM) $@
	$(CC) -o 3dRegAna 3dRegAna.o $(LFLAGS) $(LLIBS)
# double precision version of 3dDeconvolve
3dDeconvolve:3dDeconvolve.c Deconvolve.c RegAna.c matrix.c matrix.h parser.o parser_int.o
	$(RM) $@
	$(CCFAST) -o 3dDeconvolve 3dDeconvolve.c parser.o parser_int.o $(INFLAGS) $(LFLAGS) -lcoxplot $(LLIBS)
# float version of 3dDeconvolve
3dDeconvolve_f:3dDeconvolve.c Deconvolve.c RegAna.c matrix_f.c matrix_f.h parser.o parser_int.o
	$(RM) $@
	$(CCFAST) $(SPECIAL) -DFLOATIZE -o 3dDeconvolve_f 3dDeconvolve.c matrix_f.c parser.o parser_int.o $(INFLAGS) $(LFLAGS) -lcoxplot $(LLIBS)
# double precision version of 3dDeconvolve
3dDeconvolve_n:3dDeconvolve.c Deconvolve.c RegAna.c matrix.c matrix.h parser.o parser_int.o
	$(RM) $@
	$(CC) -o 3dDeconvolve_n 3dDeconvolve.c parser.o parser_int.o $(INFLAGS) $(LFLAGS) -lcoxplot $(LLIBS)
3dConvolve:3dConvolve.o
	$(RM) $@
	$(CC) -o 3dConvolve 3dConvolve.o $(LFLAGS) $(LLIBS)
3dIntracranial:3dIntracranial.o
	$(RM) $@
	$(CC) -o 3dIntracranial 3dIntracranial.o $(LFLAGS) $(LLIBS)
3dExtrema:3dExtrema.o
	$(RM) $@
	$(CC) -o 3dExtrema 3dExtrema.o $(LFLAGS) $(LLIBS)
adwarp:adwarp.o
	$(RM) $@
	$(CC) -o adwarp adwarp.o $(LFLAGS) $(LLIBS)
2dImReg:2dImReg.o
	$(RM) $@
	$(CC) -o 2dImReg 2dImReg.o $(LFLAGS) $(LLIBS)
waver:waver.o parser.o parser_int.o
	$(RM) $@
	$(CC) -o waver waver.o parser.o parser_int.o $(LFLAGS) $(LLIBS)
3dSimARMA11:3dSimARMA11.o
	$(RM) $@
	$(CC) -o 3dSimARMA11 3dSimARMA11.o $(LFLAGS) $(LLIBS)
3dnewid:3dnewid.o
	$(RM) $@
	$(CC) -o 3dnewid 3dnewid.o $(LFLAGS) $(LLIBS)
DTIStudioFibertoSegments:DTIStudioFibertoSegments.o
	$(RM) $@
	$(CC) -o DTIStudioFibertoSegments DTIStudioFibertoSegments.o $(LFLAGS) $(LLIBS)
mri_nstats.o:mri_nstats.c
	$(RM) $@
	$(CCFAST) -c mri_nstats.c $(INFLAGS)
3dLocalSVD.o:3dLocalSVD.c
	$(RM) $@
	$(CC) -c 3dLocalSVD.c $(INFLAGS)
3dLocalSVD:3dLocalSVD.o
	$(RM) $@
	$(CC) -o 3dLocalSVD 3dLocalSVD.o $(LFLAGS) $(LLIBS)
## ------- Things to be compiled or linked with OpenMP -------
3dDimRed.o: 3dDimRed.c
	$(RM) $@
	$(CCOMP) -c 3dDimRed.c $(INFLAGS)
3dDimRed:3dDimRed.o
	$(RM) $@
	$(CCOMP) -o 3dDimRed 3dDimRed.o $(LFLAGS) $(LLIBS)
3dSatCheck.o: 3dSatCheck.c thd_satcheck.c
	$(RM) $@
	$(CCOMP) -c 3dSatCheck.c $(INFLAGS)
3dSatCheck:3dSatCheck.o
	$(RM) $@
	$(CCOMP) -o 3dSatCheck 3dSatCheck.o $(LFLAGS) $(LLIBS)
3dREMLfit.o: 3dREMLfit.c remla.c matrix.c rcmat.c
	$(RM) $@
	$(CCOMP) -c 3dREMLfit.c $(INFLAGS)
3dREMLfit:3dREMLfit.o
	$(RM) $@
	$(CCOMP) -o 3dREMLfit 3dREMLfit.o $(LFLAGS) $(LLIBS)
3dBandpass.o: 3dBandpass.c mri_blur3d_variable.c
	$(RM) $@
	$(CCOMP) -c 3dBandpass.c $(INFLAGS)
3dBandpass:3dBandpass.o
	$(RM) $@
	$(CCOMP) -o 3dBandpass 3dBandpass.o $(LFLAGS) $(LLIBS)
3dGroupInCorr.o:3dGroupInCorr.c
	$(RM) $@
	$(CCOMP) -c 3dGroupInCorr.c $(INFLAGS)
3dGroupInCorr:3dGroupInCorr.o
	$(RM) $@
	$(CCOMP) -o 3dGroupInCorr 3dGroupInCorr.o $(LFLAGS) $(LLIBS)
3dLocalPV.o:3dLocalPV.c cs_pv.c
	$(RM) $@
	$(CCOMP) -c 3dLocalPV.c $(INFLAGS)
3dLocalPV:3dLocalPV.o
	$(RM) $@
	$(CCOMP) -o 3dLocalPV 3dLocalPV.o $(LFLAGS) $(LLIBS)
3dLocalstat.o:3dLocalstat.c mri_nstats.c
	$(RM) $@
	$(CCOMP) -c 3dLocalstat.c $(INFLAGS)
3dLocalstat:3dLocalstat.o
	$(RM) $@
	$(CCOMP) -o 3dLocalstat 3dLocalstat.o $(LFLAGS) $(LLIBS)
AlphaSim.o:AlphaSim.c zgaussian.c
	$(RM) $@
	$(CCOMP) -c AlphaSim.c $(INFLAGS)
AlphaSim:AlphaSim.o
	$(RM) $@
	$(CCOMP) -o AlphaSim AlphaSim.o $(LFLAGS) $(LLIBS)
3dClustSim.o:3dClustSim.c zgaussian.c
	$(RM) $@
	$(CCOMP) -c 3dClustSim.c $(INFLAGS)
3dClustSim:3dClustSim.o
	$(RM) $@
	$(CCOMP) -o 3dClustSim 3dClustSim.o $(LFLAGS) $(LLIBS)
3dBlurInMask.o:3dBlurInMask.c
	$(RM) $@
	$(CCOMP) -c 3dBlurInMask.c $(INFLAGS)
3dTcorrMap:3dTcorrMap.o
	$(RM) $@
	$(CCOMP) -o 3dTcorrMap 3dTcorrMap.o $(LFLAGS) $(LLIBS)
3dTmatch:3dTmatch.o
	$(RM) $@
	$(CCOMP) -o 3dTmatch 3dTmatch.o $(LFLAGS) $(LLIBS)
3dTcorr1D:3dTcorr1D.o
	$(RM) $@
	$(CCOMP) -o 3dTcorr1D 3dTcorr1D.o $(LFLAGS) $(LLIBS)
3dBlurInMask:3dBlurInMask.o
	$(RM) $@
	$(CCOMP) -o 3dBlurInMask 3dBlurInMask.o $(LFLAGS) $(LLIBS)
3dDespike.o:3dDespike.c
	$(RM) $@
	$(CCOMP) -c 3dDespike.c $(INFLAGS)
3dDespike:3dDespike.o
	$(RM) $@
	$(CCOMP) -o 3dDespike 3dDespike.o $(LFLAGS) $(LLIBS)
3dAllineate:3dAllineate.o mri_genalign.c mri_genalign_util.c thd_correlate.c
	$(RM) $@
	$(CCOMP) -o 3dAllineate 3dAllineate.o $(LFLAGS) $(LLIBS)
3dQwarp:3dQwarp.o mri_genalign.c mri_genalign_util.c mri_nwarp.c thd_incorrelate.c
	$(RM) $@
	$(CCOMP) -o 3dQwarp 3dQwarp.o $(LFLAGS) $(LLIBS)
3dQwarp.o:3dQwarp.c mri_genalign.c mri_genalign_util.c thd_incorrelate.c mri_nwarp.c
	$(RM) $@
	$(CCOMP) -c 3dQwarp.c $(INFLAGS)
3dNwarpApply:3dNwarpApply.o
	$(RM) $@
	$(CCOMP) -o 3dNwarpApply 3dNwarpApply.o $(LFLAGS) $(LLIBS)
3dNwarpCalc:3dNwarpCalc.o
	$(RM) $@
	$(CCOMP) -o 3dNwarpCalc 3dNwarpCalc.o $(LFLAGS) $(LLIBS)
3dRBFdset:3dRBFdset.o mri_rbfinterp.o
	$(RM) $@
	$(CCOMP) -o 3dRBFdset 3dRBFdset.o $(LFLAGS) $(LLIBS)
3dAutoTcorrelate.o:3dAutoTcorrelate.c
	$(RM) $@
	$(CCOMP) -c 3dAutoTcorrelate.c $(INFLAGS)
3dAutoTcorrelate:3dAutoTcorrelate.o
	$(RM) $@
	$(CCOMP) -o 3dAutoTcorrelate 3dAutoTcorrelate.o $(LFLAGS) $(LLIBS)
mri_rbfinterp.o:mri_rbfinterp.c
	$(RM) $@
	$(CCOMP) -c mri_rbfinterp.c $(INFLAGS)
3dAllineate.o:3dAllineate.c mri_genalign.c mri_genalign_util.c thd_correlate.c
	$(RM) $@
	$(CCOMP) -c 3dAllineate.c $(INFLAGS)
3dNwarpApply.o:3dNwarpApply.c mri_nwarp.c
	$(RM) $@
	$(CCOMP) -c 3dNwarpApply.c $(INFLAGS)
3dNwarpCalc.o:3dNwarpCalc.c mri_nwarp.c
	$(RM) $@
	$(CCOMP) -c 3dNwarpCalc.c $(INFLAGS)
3dTcorrMap.o:3dTcorrMap.c
	$(RM) $@
	$(CCOMP) -c 3dTcorrMap.c $(INFLAGS)
3dTmatch.o:3dTmatch.c
	$(RM) $@
	$(CCOMP) -c 3dTmatch.c $(INFLAGS)
3dTcorr1D.o:3dTcorr1D.c
	$(RM) $@
	$(CCOMP) -c 3dTcorr1D.c $(INFLAGS)
## ------- end of OpenMP compilations -------
# in case I want to CCOMP this someday
mcw_malloc.o:mcw_malloc.c
	$(RM) $@
	$(CC) -c mcw_malloc.c $(INFLAGS)
###  generic compile a C file
.c.o:
	$(RM) $@
	$(CC) -c $*.c $(INFLAGS)
### Special compilations for the reslicing routines, which
### are templates that require definition of the data type
### upon which they operate.
afni_slice_short.o:3ddata.h afni_slice.c afni_warp.h
	$(RM) $@
	$(CC) -c -DDTYPE=short afni_slice.c $(INFLAGS)
	$(MV) afni_slice.o afni_slice_short.o
afni_slice_float.o:3ddata.h afni_slice.c afni_warp.h
	$(RM) $@
	$(CC) -c -DDTYPE=float afni_slice.c $(INFLAGS)
	$(MV) afni_slice.o afni_slice_float.o
afni_slice_byte.o:3ddata.h afni_slice.c afni_warp.h
	$(RM) $@
	$(CC) -c -DDTYPE=byte afni_slice.c $(INFLAGS)
	$(MV) afni_slice.o afni_slice_byte.o
afni_slice_int.o:3ddata.h afni_slice.c afni_warp.h
	$(RM) $@
	$(CC) -c -DDTYPE=int afni_slice.c $(INFLAGS)
	$(MV) afni_slice.o afni_slice_int.o
afni_slice_complex.o:3ddata.h afni_slice.c afni_warp.h
	$(RM) $@
	$(CC) -c -DDTYPE=complex afni_slice.c $(INFLAGS)
	$(MV) afni_slice.o afni_slice_complex.o
afni_slice_rgbyte.o:3ddata.h afni_slice.c afni_warp.h
	$(RM) $@
	$(CC) -c -DDTYPE=rgbyte afni_slice.c $(INFLAGS)
	$(MV) afni_slice.o afni_slice_rgbyte.o
afni_slice_rgba.o:3ddata.h afni_slice.c afni_warp.h
	$(RM) $@
	$(CC) -c -DDTYPE=rgba afni_slice.c $(INFLAGS)
	$(MV) afni_slice.o afni_slice_rgba.o
afni_pcor_byte.o:afni_pcor.h afni_pcor_update.c
	$(RM) $@
	$(CC) -c -DDTYPE=byte afni_pcor_update.c $(INFLAGS)
	$(MV) afni_pcor_update.o afni_pcor_byte.o
afni_pcor_float.o:afni_pcor.h afni_pcor_update.c
	$(RM) $@
	$(CC) -c -DDTYPE=float afni_pcor_update.c $(INFLAGS)
	$(MV) afni_pcor_update.o afni_pcor_float.o
afni_pcor_short.o:afni_pcor.h afni_pcor_update.c
	$(RM) $@
	$(CC) -c -DDTYPE=short afni_pcor_update.c $(INFLAGS)
	$(MV) afni_pcor_update.o afni_pcor_short.o
### End of reslicing routines
# SHOWOFF = -DSHOWOFF=NO
### The star of the show
afni.o:afni.c niml.h
	$(RM) $@
	$(CC) -c afni.c $(INFLAGS) $(SHOWOFF)
afni_version.o:afni_version.c
	$(RM) $@
	$(CC) -c afni_version.c $(INFLAGS) $(SHOWOFF)
afni:$(AFOBJS) libcoxplot.a libmri.a libmrix.a libvolpack.a libjpeg.a libXmHTML.a volpack.h coxplot.h niml.h
	$(RM) $@
	$(CC) -o afni $(AFOBJS) $(PLFLAGS) -lmrix -lcoxplot -lmri -lvolpack libXmHTML.a libjpeg.a $(LLIBS) -lm -lc
afni+:$(AFOBJS) libcoxplot.a libmri.a libmrix.a coxplot.h niml.h
	$(RM) $@
	$(CC) -o afni+ $(AFOBJS) $(PLFLAGS) -lmrix -lcoxplot $(LLIBS) -lm -lc
motiftoy: afni motiftoy.c
	$(RM) $@
	$(CC) -o motiftoy motiftoy.c $(INFLAGS) $(SHOWOFF) $(PLFLAGS) -lmrix -lcoxplot -lmri -lvolpack $(LLIBS) -lm -lc
# CYGWIN: must compile afni.exe with fixed plugins (see PLUGIN_FIXED, far below)
afni.exe:$(AFOBJS) plugin_fixed libcoxplot.a libvolpack.a libmri.a libmrix.a volpack.h coxplot.h niml.h
	$(RM) $@
	$(CC) -o afni $(AFOBJS) $(PLUGIN_FIXED) $(LFLAGS) -lmrix -lcoxplot -lmri -lvolpack $(LLIBS)
### If you have Purify
# pafni:$(AFOBJS) libcoxplot.a
# 	$(RM) $@
# 	purify $(CC) -o pafni $(AFOBJS) $(PLFLAGS) -lcoxplot $(LLIBS)
### This program is only used with XFree86 4.0 and above
xiner:xiner.o
	$(RM) $@
	$(CC) -o xiner xiner.o $(LFLAGS) -lXinerama $(LLIBS)
cat_matvec:cat_matvec.o
	$(RM) $@
	$(CC) -o cat_matvec cat_matvec.o $(LFLAGS) $(LLIBS)
to3d:to3d.h $(T3OBJS) libcoxplot.a
	$(RM) $@
	$(CC) -o to3d $(T3OBJS) $(LFLAGS) -lmrix -lcoxplot $(LLIBS)
1dplot:libcoxplot.a 1dplot.o display.o
	$(RM) $@
	$(CC) -o 1dplot 1dplot.o display.o $(LFLAGS) -lcoxplot -lmrix $(LLIBS)
1dgrayplot:libcoxplot.a 1dgrayplot.o display.o
	$(RM) $@
	$(CC) -o 1dgrayplot 1dgrayplot.o display.o $(LFLAGS) -lcoxplot $(LLIBS)
1dsigplot:libcoxplot.a 1dsigplot.o display.o
	$(RM) $@
	$(CC) -o 1dsigplot 1dsigplot.o display.o $(LFLAGS) -lcoxplot $(LLIBS)
1dtranspose:1dtranspose.o
	$(RM) $@
	$(CC) -o 1dtranspose 1dtranspose.o $(LFLAGS) $(LLIBS)
1dREMLfit.o: 1dREMLfit.c remla.c
1dREMLfit:1dREMLfit.o
	$(RM) $@
	$(CC) -o 1dREMLfit 1dREMLfit.o $(LFLAGS) $(LLIBS)
mri_blur3d_variable.o:mri_blur3d_variable.c
	$(RM) $@
	$(CCFAST) -c mri_blur3d_variable.c $(INFLAGS)
1dUpsample:1dUpsample.o
	$(RM) $@
	$(CC) -o 1dUpsample 1dUpsample.o $(LFLAGS) $(LLIBS)
3dUpsample:3dUpsample.o
	$(RM) $@
	$(CC) -o 3dUpsample 3dUpsample.o $(LFLAGS) $(LLIBS)
1dTsort:1dTsort.o
	$(RM) $@
	$(CC) -o 1dTsort 1dTsort.o $(LFLAGS) $(LLIBS)
1dGentimes:1dGentimes.o
	$(RM) $@
	$(CC) -o 1dGentimes 1dGentimes.o $(LFLAGS) $(LLIBS)
1dRansplit:1dRansplit.o
	$(RM) $@
	$(CC) -o 1dRansplit 1dRansplit.o $(LFLAGS) $(LLIBS)
afni_vcheck:afni_vcheck.o
	$(RM) $@
	$(CC) -o afni_vcheck afni_vcheck.o $(LFLAGS) $(LLIBS)
1dfft:1dfft.o
	$(RM) $@
	$(CC) -o 1dfft 1dfft.o $(LFLAGS) $(LLIBS)
1dgenARMA11:1dgenARMA11.o
	$(RM) $@
	$(CC) -o 1dgenARMA11 1dgenARMA11.o $(LFLAGS) $(LLIBS)
1dBandpass:1dBandpass.o
	$(RM) $@
	$(CC) -o 1dBandpass 1dBandpass.o $(LFLAGS) $(LLIBS)
1dcat:1dcat.o
	$(RM) $@
	$(CC) -o 1dcat 1dcat.o $(LFLAGS) $(LLIBS)
2perm:2perm.o
	$(CC) -o 2perm 2perm.o $(INFLAGS) $(LFLAGS) $(LLIBS)
3dClustCount:3dClustCount.o
	$(RM) $@
	$(CC) -o 3dClustCount 3dClustCount.o $(LFLAGS) $(LLIBS)
1dMarry:1dMarry.o
	$(RM) $@
	$(CC) -o 1dMarry 1dMarry.o $(LFLAGS) $(LLIBS)
3dEmpty:3dEmpty.o
	$(RM) $@
	$(CC) -o 3dEmpty 3dEmpty.o $(LFLAGS) $(LLIBS)
1ddot:1ddot.o
	$(RM) $@
	$(CC) -o 1ddot 1ddot.o $(LFLAGS) $(LLIBS)
qtest:thd_bstrap_corr.o
	$(RM) $@
	$(CC) -o qtest thd_bstrap_corr.o $(LFLAGS) $(LLIBS)
1dcorr:1dcorr.o
	$(RM) $@
	$(CC) -o 1dcorr 1dcorr.o $(LFLAGS) $(LLIBS)
1dCorrelate:1dCorrelate.o
	$(RM) $@
	$(CC) -o 1dCorrelate 1dCorrelate.o $(LFLAGS) $(LLIBS)
1dsvd:1dsvd.o
	$(RM) $@
	$(CC) -o 1dsvd 1dsvd.o $(LFLAGS) $(LLIBS)
1dsum:1dsum.o
	$(RM) $@
	$(CC) -o 1dsum 1dsum.o $(LFLAGS) $(LLIBS)
1dnorm:1dnorm.o
	$(RM) $@
	$(CC) -o 1dnorm 1dnorm.o $(LFLAGS) $(LLIBS)
1dFlagMotion:1dFlagMotion.o
	$(RM) $@
	$(CC) -o 1dFlagMotion 1dFlagMotion.o $(LFLAGS) $(LLIBS)
abut:abut.o
	$(RM) $@
	$(CC) -o abut abut.o $(LFLAGS) $(LLIBS)
siemens_vision:siemens_vision.o
	$(RM) $@
	$(CC) -o siemens_vision siemens_vision.o $(LFLAGS) $(LLIBS)
ge_header:ge_header.o
	$(RM) $@
	$(CC) -o ge_header ge_header.o $(LFLAGS) $(LLIBS)
mayo_analyze:mayo_analyze.o
	$(RM) $@
	$(CC) -o mayo_analyze mayo_analyze.o $(LFLAGS) $(LLIBS)
dicom_hdr:dicom_hdr.o
	$(RM) $@
	$(CC) -o dicom_hdr dicom_hdr.o $(LFLAGS) $(LLIBS)
dicom_hinfo:dicom_hinfo.o
	$(RM) $@
	$(CC) -o dicom_hinfo dicom_hinfo.o $(LFLAGS) $(LLIBS)
dicom_to_raw:dicom_to_raw.o
	$(RM) $@
	$(CC) -o dicom_to_raw dicom_to_raw.o $(LFLAGS) $(LLIBS)
sfim:sfim.o
	$(RM) $@
	$(CC) -o sfim sfim.o $(LFLAGS) $(LLIBS)
tfim:tfim.o
	$(RM) $@
	$(CC) -o tfim tfim.o $(LFLAGS) $(LLIBS)
ftosh:ftosh.o
	$(RM) $@
	$(CC) -o ftosh ftosh.o $(LFLAGS) $(LLIBS)
ppmtoargb:ppmtoargb.o
	$(RM) $@
	$(CC) -o ppmtoargb ppmtoargb.o $(LFLAGS) $(LLIBS)
colari:colari.o
	$(RM) $@
	$(CC) -o colari colari.o $(LFLAGS) $(LLIBS)
iotest:iotest.o
	$(RM) $@
	$(CC) -o iotest iotest.o $(LFLAGS) $(LLIBS)
iochan_relay:iochan_relay.o
	$(RM) $@
	$(CC) -o iochan_relay iochan_relay.o $(LFLAGS) $(LLIBS)
3dFFT:3dFFT.o
	$(RM) $@
	$(CCFAST) -o 3dFFT 3dFFT.o $(LFLAGS) $(LLIBS)
3dLSS.o:3dLSS.c
	$(RM) $@
	$(CCFAST) -c 3dLSS.c $(INFLAGS)
3dLSS:3dLSS.o
	$(RM) $@
	$(CCFAST) -o 3dLSS 3dLSS.o $(LFLAGS) $(LLIBS)
### These programs are from Tom Ross
3dFourier:3dFourier.o
	$(RM) $@
	$(CC) -o 3dFourier 3dFourier.o $(LFLAGS) $(LLIBS)
3dNotes:3dNotes.o
	$(RM) $@
	$(CC) -o 3dNotes 3dNotes.o $(LFLAGS) $(LLIBS)
3dROIstats:3dROIstats.o
	$(RM) $@
	$(CC) -o 3dROIstats 3dROIstats.o $(LFLAGS) $(LLIBS)
3dCM:3dCM.o
	$(RM) $@
	$(CC) -o 3dCM 3dCM.o $(LFLAGS) $(LLIBS)
3dSpatNorm:3dSpatNorm.o
	$(RM) $@
	$(CC) -o 3dSpatNorm 3dSpatNorm.o $(LFLAGS) $(LLIBS)
### These programs are from Fred Tam
3dretroicor:3dretroicor.o retroicor.o
	$(RM) $@
	$(CC) -o 3dretroicor 3dretroicor.o retroicor.o $(LFLAGS) $(LLIBS)
### These programs are from Matthew Belmonte
balloon:balloon.o
	$(RM) $@
	$(CC) -o balloon balloon.o $(LFLAGS) -lgsl -lgslcblas -lm
### Test area for  surface datasets Placed here by ZSS for RickR
suma_datasets.o: suma_datasets.c
	$(RM) $@
	$(CC) -c suma_datasets.c -o $@ -ISUMA/ $(INFLAGS)
suma_algorithms.o: suma_algorithms.c
	$(RM) $@
	$(CC) -c suma_algorithms.c -o $@ -ISUMA/ $(INFLAGS)
testdsetio: SUMA/SUMA_TestDsetIO.c suma_datasets.o suma_algorithms.o
	$(RM) $@
	$(CC) -o testdsetio SUMA/SUMA_TestDsetIO.c suma_datasets.o suma_algorithms.o \
            -ISUMA/ $(INFLAGS) $(LFLAGS) $(LLIBS)
### Sort of clean
clean:
	$(RM) `find . -name \*.o -print`
cleann:
	$(RM) `find . -name \*.o -print`
cleaner:clean
	$(RM) *.a $(PROGRAMS)
cleanest:
	$(RM) `find . -name \*.o -print`
	$(RM) `find . -name \*.so -print`
	$(RM) `find . -name \*.a -print`
	$(RM) $(PROGRAMS)
	$(RM) SUMA/SUMA_*.tar
clean_progs:
	$(RM) $(PROGRAMS)
# CYGWIN: remove the fixed plugins as well
clean_exe:
	$(RM) *.o *.fixed
#backup:
#	ssh afni chmod -R u+w /home/rwcox/AFNI_BACKUP
#	scp -prq * afni:/home/rwcox/AFNI_BACKUP
backup:
	chmod -R u+w /net/afni/home2/AFNI/BACKUP/
	cp -pr * /net/afni/home2/AFNI/BACKUP
### Make the source distribution
afni_src.tgz:
	$(MKDIR) afni_src
	$(CP) -p *.c *.f *.inc *.h *.hhh Makefile.* *.xbm $(MINDOCS) $(MISC)     ./afni_src
	$(CP) -pr coxplot volpack moveup moveAFNI* eispack avovk ptaylor pkundu        ./afni_src
	$(CP) -pr $(SCRIPTS) $(PY_DIR) $(R_DIR)                                  ./afni_src
	$(CP) -pr gifsicledir qhulldir f2cdir mpeg_encodedir                     ./afni_src
	$(CP) -pr 3DEdge netcdf-3.5.0 jpeg-6b niml Makefile_* nifti dlcompat     ./afni_src
	$(CP) -pr SUMA svm matlab rickr faces poems gifti ni_test_? README.*     ./afni_src
	$(CP) -pr XmHTML html                                                    ./afni_src
	chmod -R ugo+rw                                                          ./afni_src
	$(TAR) cf - afni_src | $(GZIP) -9v > afni_src.tgz
	$(RM) -r ./afni_src
# in above list
# mpegtoppm_dir                 ./afni_src
### Make the source of the Matlab code
afni_matlab.tgz:
	$(MKDIR) afni_matlab
	$(CP) -pr matlab ./afni_matlab
	chmod ugo+rwx ./afni_matlab/*
	$(TAR) cf - afni_matlab | $(GZIP) -9v > afni_matlab.tgz
	$(RM) -r afni_matlab
### Make the documentation distribution: only for use by RWCox
afni_doc.tgz:
	$(RM) $@
	$(MKDIR) ./afni_doc
	$(CP) $(DOCS) ./afni_doc
	$(TAR) cf - ./afni_doc | $(GZIP) -9v > afni_doc.tgz
	$(RM) -r ./afni_doc
### Put things in their places
install: $(INSTALLDIR) $(INSTALL_PREREQ) ptaylor_install pkundu_install 
	$(MV) $(PROGRAMS) $(INSTALLDIR)
	$(CP) $(SCRIPTS)  $(INSTALLDIR)
	$(CP) $(PY_DIR)/*.py  $(R_DIR)/*.R $(INSTALLDIR)
	$(CP) html/??*.* $(EXTRA_INSTALL_FILES) $(INSTALLDIR)
	if [ -f README.environment ]; then $(CP) README.*    $(INSTALLDIR); fi;
	if [ -f AFNI.afnirc        ]; then $(CP) AFNI.afnirc $(INSTALLDIR); fi;
	if [ -f AFNI.sumarc        ]; then $(CP) AFNI.sumarc $(INSTALLDIR); fi;
	if [ -f R_io.so            ]; then $(CP) R_io.so     $(INSTALLDIR); fi;
	if [ -f AFNI_atlas_spaces.niml ]; then $(CP) AFNI_atlas_spaces.niml $(INSTALLDIR); fi;
	$(EXINCOM)
	echo "===== AFNI install finished (fondly do we hope, fervently we do pray) ====="
install_noplug: $(INSTALLDIR)
	$(MV) $(PROGRAMS_NOPLUG) $(INSTALLDIR)
	$(CP) $(SCRIPTS) $(INSTALLDIR)
	$(CP) $(PY_DIR)/*.py $(R_DIR)/*.R $(INSTALLDIR)
install_lib: $(LIBDIR)
	$(CP) libmri.a libmrix.a libf2c.a libcoxplot.a libvolpack.a $(LIBHEADERS) $(LIBDIR)
# CYGWIN: must put the .exe suffix on the "mv" command for some reason
install_exe: $(INSTALLDIR)
	( for pp in $(PROGRAMS_EXE) ; do                               \
             qq=`basename $$pp .exe`; $(MV) $${qq}.exe $(INSTALLDIR) ; \
          done )
	$(CP) $(SCRIPTS) $(INSTALLDIR)
	$(CP) $(PY_DIR)/*.py $(R_DIR)/*.R $(INSTALLDIR)
###################################################################
# some dependencies (not complete)
afni.o:imseq.h 3ddata.h xutil.h pbar.h afni.h bbox.h afni_warp.h \
       afni_graph.h afni_setup.h machdep.h
debugtrace.o:debugtrace.h debugtrace.c
	$(RM) $@
	$(CC) -c debugtrace.c $(INFLAGS) $(SHOWOFF)
afni_vcheck.o:afni.h
afni_splash.o:afni_splash.h imseq.h afni_splash.c
afni_func.o:imseq.h 3ddata.h xutil.h pbar.h afni.h machdep.h
afni_widg.o:imseq.h 3ddata.h xutil.h pbar.h afni.h logo.h machdep.h
afni_warp.o:afni_warp.h 3ddata.h machdep.h
afni_graph.o:afni_graph.h 3ddata.h xutil.h bbox.h afni.h machdep.h
afni_fimmer.o:afni_graph.h afni.h machdep.h
afni_plugin.o:afni_plugin.h 3ddata.h xutil.h afni.h bbox.h afni_warp.h \
              machdep.h display.h imseq.h
afni_plugout.o:afni_plugin.h afni_plugout.h machdep.h
afni_setup.o:afni.h afni_setup.h pbar.h
3dclust.o:3ddata.h
3dmerge.o:3ddata.h
pbar.o:pbar.h machdep.h
bbox.o:bbox.h xutil.h coxplot.h
xutil.o:xutil.h
imseq.o:imseq.h display.h bbox.h xutil.h mrilib.h
display.o:display.h mrilib.h
xim.o:xim.h display.h mrilib.h
ts.o:ts.h
to3d.o:to3d.h
3dbucket.o:3ddata.h
3dTSgen.o:NLfit.c NLfit.h NLfit_model.c NLfit_model.h
mcw_graf.o:mcw_graf.h
###################################################################
# make the mri library
afni_suma.o:afni_suma.c afni_suma.h cs_sort_template.h
	$(RM) $@
	$(CCFAST) -c afni_suma.c $(INFLAGS)
csfft.o:csfft.c
	$(RM) $@
	$(CCFAST) -c csfft.c $(INFLAGS)
mri_percents.o:mri_percents.c
	$(RM) $@
	$(CCFAST) -c mri_percents.c $(INFLAGS)
mri_warpfield.o:mri_warpfield.c
	$(RM) $@
	$(CCFAST) -c mri_warpfield.c $(INFLAGS)
edt_clustalpha.o:AlphaTab64.h edt_clustalpha.c
	$(RM) $@
	$(CCFAST) -c edt_clustalpha.c $(INFLAGS)
afni_pplug_instacorr.o:afni_pplug_instacorr.c
	$(RM) $@
	$(CCFAST) -c afni_pplug_instacorr.c $(INFLAGS)
afni_pplug_instacalc.o:afni_pplug_instacalc.c
	$(RM) $@
	$(CCFAST) -c afni_pplug_instacalc.c $(INFLAGS)
mri_nbistats.o:mri_nbistats.c
	$(RM) $@
	$(CCFAST) -c mri_nbistats.c $(INFLAGS)
mri_to_float.o:mri_to_float.c
	$(RM) $@
	$(CCFAST) -c mri_to_float.c $(INFLAGS)
mri_to_short.o:mri_to_short.c
	$(RM) $@
	$(CCFAST) -c mri_to_short.c $(INFLAGS)
mri_to_byte.o:mri_to_byte.c
	$(RM) $@
	$(CCFAST) -c mri_to_byte.c $(INFLAGS)
cs_symeig.o:cs_symeig.c
	$(RM) $@
	$(CCFAST) -c cs_symeig.c $(INFLAGS)
cs_pv.o:cs_pv.c
	$(RM) $@
	$(CCFAST) -c cs_pv.c $(INFLAGS)
cs_qmed.o:cs_qmed.c
	$(RM) $@
	$(CCFAST) -c cs_qmed.c $(INFLAGS)
cs_sort_ff.o:cs_sort_ff.c
	$(RM) $@
	$(CCFAST) -c cs_sort_ff.c $(INFLAGS)
cs_sort_fi.o:cs_sort_fi.c
	$(RM) $@
	$(CCFAST) -c cs_sort_fi.c $(INFLAGS)
cs_sort_fv.o:cs_sort_fv.c
	$(RM) $@
	$(CCFAST) -c cs_sort_fv.c $(INFLAGS)
cs_sort_iv.o:cs_sort_iv.c
	$(RM) $@
	$(CCFAST) -c cs_sort_iv.c $(INFLAGS)
cs_sort_dv.o:cs_sort_dv.c
	$(RM) $@
	$(CCFAST) -c cs_sort_dv.c $(INFLAGS)
cs_sort_d.o:cs_sort_d.c
	$(RM) $@
	$(CCFAST) -c cs_sort_d.c $(INFLAGS)
3dNLfim.o:3dNLfim.c NLfit.c NLfit.h NLfit_model.c NLfit_model.h
	$(RM) $@
	$(CCFAST) -c 3dNLfim.c $(INFLAGS)
3dNLfim_n.o:3dNLfim.c NLfit.c NLfit.h NLfit_model.c NLfit_model.h
	$(RM) 3dNLfim.o 3dNLfim_n.o
	$(CC) -c 3dNLfim.c $(INFLAGS)
	$(MV) 3dNLfim.o 3dNLfim_n.o
powell_newuoa.o:powell_newuoa.c
	$(RM) $@
	$(CCFAST) -c powell_newuoa.c $(INFLAGS)
mri_genalign_util.o:mri_genalign_util.c
	$(RM) $@
	$(CCFAST) -c mri_genalign_util.c $(INFLAGS)
mri_genalign.o:mri_genalign.c
	$(RM) $@
	$(CCFAST) -c mri_genalign.c $(INFLAGS)
thd_correlate.o:thd_correlate.c
	$(RM) $@
	$(CCFAST) -c thd_correlate.c $(INFLAGS)
thd_incorrelate.o:thd_incorrelate.c
	$(RM) $@
	$(CCFAST) -c thd_incorrelate.c $(INFLAGS)
cl1.o:cl1.c
	$(RM) $@
	$(CCFAST) -c cl1.c $(INFLAGS)
cl2.o:cl2.c
	$(RM) $@
	$(CCFAST) -c cl2.c $(INFLAGS)
mri_drawing.o:mri_drawing.c
	$(RM) $@
	$(CCFAST) -c mri_drawing.c $(INFLAGS)
mri_dup.o:mri_dup.c
	$(RM) $@
	$(CCFAST) -c mri_dup.c $(INFLAGS)
mri_warp.o:mri_warp.c
	$(RM) $@
	$(CCFAST) -c mri_warp.c $(INFLAGS)
mri_warp3D.o:mri_warp3D.c
	$(RM) $@
	$(CCFAST) -c mri_warp3D.c $(INFLAGS)
mri_warp3D_align.o:mri_warp3D_align.c
	$(RM) $@
	$(CCFAST) -c mri_warp3D_align.c $(INFLAGS)
thd_rot3d.o:thd_rot3d.c
	$(RM) $@
	$(CCFAST) -c thd_rot3d.c $(INFLAGS)
thd_automask.o:thd_automask.c
	$(RM) $@
	$(CCFAST) -c thd_automask.c $(INFLAGS)
# can't use CCFAST on thd_shift2 because GCC optimizer fails
thd_shift2.o:thd_shift2.c
	$(RM) $@
	$(CC) -c thd_shift2.c $(INFLAGS)
thd_rot3d_byte.o:thd_rot3d_byte.c
	$(RM) $@
	$(CCFAST) -c thd_rot3d_byte.c $(INFLAGS)
thd_svdblur.o:thd_svdblur.c
	$(RM) $@
	$(CCFAST) -c thd_svdblur.c $(INFLAGS)
cox_render.o:cox_render.h cox_render.c
	$(RM) $@
	$(CCFAST) -c cox_render.c $(INFLAGS)
mri_matrix.o:mri_matrix.c
	$(RM) $@
	$(CCFAST) -c mri_matrix.c $(INFLAGS)
rcmat.o:rcmat.c
	$(RM) $@
	$(CCFAST) -c rcmat.c $(INFLAGS)
thd_fitter.o:thd_fitter.c
	$(RM) $@
	$(CCFAST) -c thd_fitter.c $(INFLAGS)
thd_lasso.o:thd_lasso.c
	$(RM) $@
	$(CCFAST) -c thd_lasso.c $(INFLAGS)
MRI_OBJS = mri_cfft.o mri_complex_arith.o mri_fft_complex.o mri_free.o    \
           mri_max.o mri_new.o mri_read.o mri_swapbytes.o mri_dup.o        \
           mri_to_byte.o mri_to_complex.o mri_to_float.o mri_to_short.o     \
           mri_warp.o mri_write.o mri_float_func.o mri_edit.o mri_stat_seq.o \
           mri_add_name.o mri_histog.o mri_nsize.o mri_lsqfit.o mri_sobel.o  \
           csfft.o mri_filt_fft.o mri_align.o mri_rota.o mri_thresh.o        \
           mri_to_mri.o mri_flippo.o mri_percents.o mri_stats.o mri_cat2D.o  \
           mri_transpose.o mri_shifter.o mcw_glob.o mri_2dalign.o mri_order.o \
           mri_3dalign.o mri_render.o mri_to_rgb.o mcw_malloc.o mri_cut.o      \
           mri_overlay.o mri_copy.o mri_uncat2D.o cox_render.o mri_histobyte.o \
           mri_aff2d.o debugtrace.o mri_zeropad.o mri_write_angif.o            \
           mri_histoshort.o mri_shift2D.o mri_drawing.o mri_coxplot.o          \
           mri_get_cmass.o mri_scale.o mri_write_analyze.o mri_to_rgba.o       \
           mri_rgba_compose.o mri_blur3d.o mri_dicom_hdr.o mri_read_dicom.o    \
           mri_read_stuff.o mri_flip3D.o mri_warp3D.o mri_fromstring.o         \
           ge4_header.o mri_equal.o mri_scalize.o mri_isgray.o mri_read_mpeg.o \
           mri_entropy16.o mri_symbolize.o mri_colorsetup.o mri_warp3D_align.o \
           mri_medianfilter.o mri_nstats.o mri_scaled_diff.o mri_matrix.o      \
           mri_genalign.o mri_clusterize.o mri_nbistats.o mri_fwhm.o           \
           mri_blur3d_variable.o mri_purger.o mri_counter.o mri_to_imarr.o     \
           mri_pcvector.o mri_fdrize.o mri_floatvec.o mri_sort.o               \
           mri_warpfield.o mri_dicom_stuff.o mri_check.o mri_allzero.o         \
           mri_subset.o mri_to_fvect.o mri_genalign_util.o rcmat.o dmat44.o    \
           mri_rbfinterp.o mri_genARMA11.o mri_catvol.o mri_polyfit.o          \
           mri_nwarp.o mri_extract.o
THD_OBJS = thd_atr.o thd_dsetto1D.o thd_initalldir.o thd_reconpar.o \
           thd_auxdata.o thd_editdaxes.o thd_initdblk.o thd_sarr.o  \
           thd_bstats.o thd_fdbrick.o thd_initdkptr.o thd_statpval.o \
           thd_compress.o thd_fdto1D.o thd_initprefix.o thd_timeof.o  \
           thd_coords.o thd_fdto2D.o thd_initsess.o thd_warps.o        \
           thd_countb.o thd_filestuff.o thd_linecount.o thd_writeatr.o  \
           thd_delete.o thd_forcemalloc.o thd_loaddblk.o thd_writedblk.o \
           thd_dsetdblk.o thd_get1D.o thd_manydset.o thd_writedset.o    \
           thd_dsetinsess.o  thd_idcode.o thd_opendset.o thd_zblock.o  \
           thd_dsetinslist.o thd_info.o thd_purgedblk.o thd_http.o    \
           thd_iochan.o thd_makefbuc.o thd_makefim.o thd_makefith.o  \
           thd_trusthost.o thd_rot3d.o thd_mastery.o thd_intlist.o  \
           thd_checkidc.o thd_floatscan.o thd_notes.o thd_makemask.o \
           thd_shift2.o thd_1Dtodset.o thd_detrend.o thd_fitter.o     \
           thd_winsor.o thd_zeropad.o thd_rot3d_byte.o thd_shear3d.o   \
           thd_tmask.o thd_rotangles.o thd_ttest.o thd_center.o         \
           thd_mismatch.o thd_read_vecmat.o thd_tshift.o thd_newprefix.o \
           thd_entropy16.o thd_dsetrow.o thd_rowfillin.o thd_fetchdset.o  \
           thd_getpathprogs.o thd_zfillin.o thd_ttatlas_query.o           \
           thd_dsetto3D.o thd_median.o thd_cliplevel.o thd_automask.o     \
           thd_outlier_count.o thd_correlate.o thd_autonudge.o thd_avts.o \
           thd_mincwrite.o thd_mnicoords.o thd_strfunc.o thd_niftiwrite.o \
           thd_analyzeread.o thd_ctfread.o thd_1Ddset.o thd_getorient.o   \
           thd_3Ddset.o thd_mattor.o thd_niftiread.o thd_mpegread.o       \
           thd_brainormalize.o thd_opentcat.o thd_nimlatr.o thd_dsetatr.o \
           thd_logafni.o thd_dset_nbhd.o thd_vcheck.o thd_matdaxes.o      \
           thd_niml.o afni_vedit.o thd_fdrcurve.o thd_dset_to_vectim.o    \
           thd_bandpass.o thd_instacorr.o thd_svdblur.o thd_satcheck.o    \
           thd_dumdset.o ktaub.o bilinear_warp3D.o thd_table.o            \
           thd_atlas.o thd_warp_tables.o thd_lasso.o
# these are now included in NIML
UNUSED_OBSJ = thd_md5.o thd_base64.o
NIML_OBJS = niml_b64.o     niml_element.o   niml_elemio.o niml_registry.o \
            niml_util.o    niml_byteorder.o niml_header.o niml_malloc.o   \
            niml_rowtype.o niml_uuid.o      niml_do.o     niml_htable.o   \
            niml_md5.o     niml_url.o       niml_stream.o niml_struct.o   \
            niml_dataset.o niml_vector.o    niml_stat.o   niml_dtable.o   \
            niml_sucker.o
EDT_OBJS = edt_addbrick.o edt_blur.o edt_buildmask.o edt_checkargv.o \
           edt_clust.o edt_clustarr.o edt_coerce.o edt_dsetitems.o   \
           edt_emptycopy.o edt_filtervol.o edt_help.o edt_onedset.o  \
           edt_scl2max.o edt_substbrick.o edt_volamax.o edt_zscore.o \
           edt_fullcopy.o edt_calcmask.o edt_volpad.o edt_sortmask.o \
           edt_clust2.o edt_wodcopy.o edt_clustalpha.o edt_geomcon.o \
           edt_floatize.o
CS_OBJS  = cs_sort_fi.o cs_sort_di.o cs_symeig.o cs_sort_ii.o cs_sort_ff.o \
           cs_addto_args.o multivector.o afni_environ.o cs_qmed.o cl2.o    \
           cs_sort_fv.o cs_laguerre.o machdep.o cs_qhull.o afni_logger.o   \
           cl1.o cs_misc.o powell_int.o powell_newuoa.o cs_sort_dv.o       \
           rhdd.o zfun.o cs_pv.o cs_sort_iv.o cs_sort_d.o cs_fgets.o
EIS_OBJS = eis_bakvec.o eis_balanc.o eis_balbak.o eis_bandr.o              \
           eis_bandv.o eis_bisect.o eis_bqr.o eis_cbabk2.o eis_cbal.o      \
           eis_cdiv.o eis_cg.o eis_ch.o eis_cinvit.o eis_combak.o          \
           eis_comhes.o eis_comlr.o eis_comlr2.o eis_comqr.o eis_comqr2.o  \
           eis_cortb.o eis_corth.o eis_csroot.o eis_elmbak.o eis_elmhes.o  \
           eis_eltran.o eis_epslon.o eis_figi.o eis_figi2.o eis_hqr.o      \
           eis_hqr2.o eis_htrib3.o eis_htribk.o eis_htrid3.o eis_htridi.o  \
           eis_imtql1.o eis_imtql2.o eis_imtqlv.o eis_invit.o eis_minfit.o \
           eis_ortbak.o eis_orthes.o eis_ortran.o eis_pythag.o eis_qzhes.o \
           eis_qzit.o eis_qzval.o eis_qzvec.o eis_ratqr.o eis_rebak.o      \
           eis_rebakb.o eis_reduc.o eis_reduc2.o eis_rg.o eis_rgg.o        \
           eis_rs.o eis_rsb.o eis_rsg.o eis_rsgab.o eis_rsgba.o            \
           eis_rsm.o eis_rsp.o eis_rst.o eis_rt.o eis_svd_slow.o eis_svd.o \
           eis_tinvit.o eis_tql1.o eis_tql2.o eis_tqlrat.o eis_trbak1.o    \
           eis_trbak3.o eis_tred1.o eis_tred2.o eis_tred3.o                \
           eis_tridib.o eis_tsturm.o
NETCDF_OBJS =  netcdf_attr.o   netcdf_dim.o   netcdf_error.o netcdf_libvers.o \
               netcdf_nc.o     netcdf_ncio.o  netcdf_ncx.o   netcdf_putget.o  \
               netcdf_string.o netcdf_v1hpg.o netcdf_v2i.o   netcdf_var.o     \
               thd_mincread.o
SUMA_OBJS = suma_afni_surface.o suma_datasets.o suma_algorithms.o
MISC_OBJS  = afni_suma.o vol2surf.o nifti1_io.o znzlib.o list_struct.o  \
	     nifti_statlib.o nifticdf.o r_new_resam_dset.o r_idisp.o    \
	     r_misc.o matrix.o gifti_choice.o misc_math.o
libmri.a:$(NIML_OBJS) $(MRI_OBJS) $(THD_OBJS)                \
         $(EDT_OBJS)  $(CS_OBJS)  $(EIS_OBJS) $(NETCDF_OBJS) \
         $(SUMA_OBJS) $(MISC_OBJS) niml.h mrilib.h 3ddata.h $(SOMEAFOBJS)
	$(RM) $@
	$(AR) q libmri.a $(MRI_OBJS) $(THD_OBJS) $(EDT_OBJS)        \
		$(NIML_OBJS) $(CS_OBJS) $(EIS_OBJS) $(NETCDF_OBJS)  \
		$(SUMA_OBJS) $(MISC_OBJS) $(SOMEAFOBJS)
	$(RANLIB) libmri.a
libmrix.so:$(IMOBJS) imseq.h display.h xim.h bbox.h xutil.h
	$(RM) $@
	$(CC) -shared -fPIC -o libmrix.so $(IMOBJS)
### Dependencies for above
thd_compress.o:thd_compress.h
mcw_glob.o:mcw_glob.h
thd_iochan.o:thd_iochan.h
mcw_malloc.o:mcw_malloc.h
afni_environ.o:afni_environ.h
vol2surf.o:vol2surf.h
###################################################################
# shared objects (go into the shared_lib directory)
# same as .a, but build as a shared object
libmri.so:$(NIML_OBJS) $(MRI_OBJS) $(THD_OBJS)                               \
          $(EDT_OBJS)  $(CS_OBJS)  $(EIS_OBJS) $(NETCDF_OBJS)                \
          $(SUMA_OBJS) $(MISC_OBJS) $(SOMEAFOBJS) niml.h mrilib.h 3ddata.h   \
          shared_netcdf_attr
	$(RM) $@
	$(CC) -shared -fPIC -o libmri.so $(MRI_OBJS) $(THD_OBJS) $(EDT_OBJS) \
		$(NIML_OBJS) $(CS_OBJS) $(EIS_OBJS) $(NETCDF_OBJS)           \
		$(SUMA_OBJS) $(MISC_OBJS) $(SOMEAFOBJS)
	$(RM) netcdf_attr.o
# remake netcdf objects with PIC
shared_netcdf_attr:
	$(RM) netcdf_attr.o
	$(MAKE) netcdf_attr.o CCMIN="${CCMIN} -fPIC"
# same as .a, but build as a shared object
libmrix.a:$(IMOBJS) imseq.h display.h xim.h bbox.h xutil.h
	$(RM) libmrix.a
	$(AR) q libmrix.a $(IMOBJS)
	$(RANLIB) libmrix.a
shared_objs: $(INSTALLDIR) libmri.so libmrix.so
	$(MV) libmri.so libmrix.so $(INSTALLDIR)
###################################################################
# Plugin stuff
.SUFFIXES:.$(PLUGIN_SUFFIX)
SO = $(PLUGIN_SUFFIX)
plugins:plug_clust.$(SO)    plug_copy.$(SO)     plug_rename.$(SO)      \
        plug_tag.$(SO)      plug_power.$(SO)    plug_stats.$(SO)       \
        plug_lsqfit.$(SO)   plug_imreg.$(SO)    plug_edit.$(SO)        \
        plug_nlfit.$(SO)    plug_realtime.$(SO) plug_3ddot.$(SO)       \
        plug_coorder.$(SO)  plug_compress.$(SO) plug_volreg.$(SO)      \
        plug_drawdset.$(SO) plug_maskave.$(SO)  plug_deconvolve.$(SO)  \
        plug_render.$(SO)   plug_notes.$(SO)    plug_histog.$(SO)      \
        plug_scatplot.$(SO) plug_nudge.$(SO)    plug_wavelets.$(SO)    \
        plug_second_dataset.$(SO)               plug_betafit.$(SO)     \
        plug_zeropad.$(SO)  plug_nth_dataset.$(SO)                     \
        plug_roiplot.$(SO)  plug_ttget.$(SO)    plug_L1fit.$(SO)       \
        plug_3ddup.$(SO)    plug_histog_multi.$(SO)                    \
        plug_afnihistory.$(SO)                                         \
        models contrib_plugins
models: model_constant.$(SO) model_linear.$(SO) model_quadratic.$(SO)  \
        model_null.$(SO) model_diffusion.$(SO) model_beta.$(SO)        \
        model_sinewave_ap.$(SO) model_sinewave_apf.$(SO)               \
        model_squarewave_ap.$(SO) model_squarewave_apf.$(SO)           \
        model_trnglwave_ap.$(SO) model_trnglwave_apf.$(SO)             \
        model_exp.$(SO) model_diffexp.$(SO) model_gammavar.$(SO)       \
        model_convgamma.$(SO) model_convgamma2a.$(SO)                  \
        model_michaelis_menton.$(SO) model_linplusort.$(SO)            \
        model_zero.$(SO) model_demri_3.$(SO) model_expr2.$(SO)         \
        model_conv_diffgamma.$(SO) model_expMEMRI.$(SO)                \
        model_expMEMRI3.$(SO)
# Contributed plugins go last, since they might not compile well
contrib_plugins: ziad_plugins birn_plugins kummer_plugins laconte_plugins \
                 rickr_plugins tross_plugins belmonte_plugins fredtam_plugins \
                 davidshin_plugins
ziad_plugins: plug_3Ddump_V2.$(SO) plug_4Ddump.$(SO) \
              plug_delay_V2.$(SO)  plug_extract.$(SO)
fredtam_plugins: plug_retroicor.$(SO)
davidshin_plugins: plug_aslA3D3.$(SO)
birn_plugins: plug_stavg.$(SO)
kummer_plugins: plug_reorder.$(SO)
rickr_plugins: plug_roiedit.$(SO) plug_hemisub.$(SO) \
               plug_maskcalc.$(SO) plug_maxima.$(SO) \
               plug_crender.$(SO) plug_vol2surf.$(SO)
tross_plugins: plug_fourier.$(SO)
belmonte_plugins: plug_threshold.$(SO) plug_permtest.$(SO)
laconte_plugins: plug_3dsvm.$(SO)
install_plugins: $(INSTALLDIR)
	$(MV) *.$(PLUGIN_SUFFIX) $(INSTALLDIR)
	mkdir -p $(INSTALLDIR)/funstuff
	$(CP) faces/face_*.jpg faces/splash_*.jpg poems/poem_*.txt $(INSTALLDIR)/funstuff
	echo Plugins put in directory $(INSTALLDIR):
	echo Do not forget to setenv AFNI_PLUGINPATH appropriately
.c.$(SO):afni_plugin.h afni.h 3ddata.h
	$(RM) $@
	$(PLUGIN_CC) -c $*.c $(INFLAGS)
	$(LD) $(PLUGIN_LFLAGS) -o $*.$(SO) $*.o
plug_realtime.$(SO):plug_realtime.c
	$(RM) $@
	$(PLUGIN_CC) -c plug_realtime.c $(INFLAGS)
	$(LD) $(PLUGIN_LFLAGS) -o plug_realtime.$(SO) plug_realtime.o
plug_drealtime.$(SO):plug_realtime.c
	$(RM) $@
	$(PLUGIN_CCD) -c plug_realtime.c $(INFLAGS)
	$(LD) $(PLUGIN_LFLAGS) -o plug_drealtime.$(SO) plug_realtime.o
plug_crender.$(SO):plug_crender.c
	$(RM) $@
	$(PLUGIN_CC) -c plug_crender.c $(INFLAGS)
	$(LD) $(PLUGIN_LFLAGS) -o plug_crender.$(SO) plug_crender.o -L.
plug_maxima.$(SO):plug_maxima.c maxima.o
	$(RM) $@
	$(PLUGIN_CC) -c plug_maxima.c $(INFLAGS)
	$(LD) $(PLUGIN_LFLAGS) -o plug_maxima.$(SO) plug_maxima.o maxima.o -L.
### From Fred Tam
plug_retroicor.$(SO):plug_retroicor.c retroicor.o
	$(RM) $@
	$(PLUGIN_CC) -c plug_retroicor.c $(INFLAGS)
	$(LD) $(PLUGIN_LFLAGS) -o plug_retroicor.$(SO) plug_retroicor.o \
      retroicor.o
# nuke any existing renderer plugin
plug_render.$(SO):plug_null.o
	$(LD) $(PLUGIN_LFLAGS) -o plug_render.$(SO) plug_null.o
### From Stephen LaConte
plug_3dsvm.$(SO):
	( cd svm;   							\
          $(RM) ../$@ ; 						\
          $(PLUGIN_CC) -c plug_3dsvm.c 3dsvm_common.c svm_common.c 	\
            svm_learn.c svm_hideo.c $(ISFLAGS)  -I.. ; 			\
	  $(LD) $(PLUGIN_LFLAGS) -o plug_3dsvm.$(SO) 			\
            plug_3dsvm.o 3dsvm_common.o svm_common.o svm_learn.o	\
	    svm_hideo.o -L. -L.. ; 					\
	  $(MV) plug_3dsvm.so ../. ; 					\
	  cd .. ;  )
# Stuff for plugins on CYGWIN:
# Each plugin must be listed here and have 2 corresponding lines in fixed_plugins.h
#
# plug_nlfit.fixed and plug_wavelets.fixed have been removed due to difficulties
PLUGIN_FIXED = plug_clust.fixed    plug_copy.fixed     plug_rename.fixed     \
               plug_tag.fixed      plug_power.fixed    plug_stats.fixed      \
               plug_lsqfit.fixed   plug_imreg.fixed    plug_edit.fixed       \
                                   plug_realtime.fixed plug_3ddot.fixed      \
               plug_coorder.fixed  plug_compress.fixed plug_volreg.fixed     \
               plug_drawdset.fixed plug_maskave.fixed  plug_deconvolve.fixed \
               plug_render.fixed   plug_notes.fixed    plug_histog.fixed     \
               plug_scatplot.fixed plug_nudge.fixed                          \
               plug_zeropad.fixed  plug_3Ddump_V2.fixed                      \
               plug_4Ddump.fixed   plug_delay_V2.fixed plug_extract.fixed    \
               plug_betafit.fixed  plug_roiplot.fixed                        \
               plug_second_dataset.fixed                                     \
               plug_stavg.fixed    plug_reorder.fixed                        \
               plug_roiedit.fixed  plug_hemisub.fixed  plug_maskcalc.fixed   \
               plug_fourier.fixed  plug_threshold.fixed                      \
               plug_permtest.fixed
plugin_fixed:$(PLUGIN_FIXED)
.SUFFIXES:.fixed
.c.fixed:afni_plugin.h afni.h 3ddata.h
	$(RM) $@
	$(PLUGIN_CC) -c $*.c $(INFLAGS) -DPLUGIN_init=PLUGIN_init_$*
	$(MV) $*.o $*.fixed
# Miscellaneous stuff (plugouts)
plugout_tt:plugout_tt.o
	$(RM) $@
	$(CC) -o plugout_tt plugout_tt.o $(LFLAGS) $(LLIBS)
plugout_ijk:plugout_ijk.o
	$(RM) $@
	$(CC) -o plugout_ijk plugout_ijk.o $(LFLAGS) $(LLIBS)
plugout_tta:plugout_tta.o
	$(RM) $@
	$(CC) -o plugout_tta plugout_tta.o $(LFLAGS) $(LLIBS)
plugout_surf:plugout_surf.o
	$(RM) $@
	$(CC) -o plugout_surf plugout_surf.o $(LFLAGS) -lcurses $(LLIBS)
plugout_drive:plugout_drive.o
	$(RM) $@
	$(CC) -o plugout_drive plugout_drive.o $(LFLAGS) $(LLIBS)
plugout_graph:plugout_graph.o
	$(RM) $@
	$(CC) -o plugout_graph plugout_graph.o $(LFLAGS) $(LLIBS)
######################################################################
# Stuff that was originally in Fortran
f2c:
	( cd f2cdir ;                                                         \
	  $(MAKE) f2c clean 'RM=$(RM)' 'CC=$(CC)' 'AR=$(AR)' 'CCMIN=$(CCMIN)' \
	        'RANLIB=$(RANLIB)' 'LDFLAGS=$(LDFLAGS)' 'IFLAGS=$(ISFLAGS)' ;  \
	  $(MV) f2c .. ; )
libf2c.a:
	( cd f2cdir ;                                                        \
	  $(MAKE) libf2c.a clean 'RM=$(RM)' 'CC=$(CC)' 'AR=$(AR)'            \
	        'RANLIB=$(RANLIB)' 'LDFLAGS=$(LDFLAGS)' 'IFLAGS=$(ISFLAGS)' ; \
	  $(MV) libf2c.a .. ; )
f2c.h:
	$(CP) f2cdir/f2c.h ./
f2c.tgz:
	$(TAR) cf - ./f2cdir | $(GZIP) -9v > f2c.tgz
#######
# dlcompat
libdl.a:dlcompat/dlfcn.h dlcompat/dlopen.c
	( cd dlcompat ;              \
	  $(MAKE) libdl.a ;          \
	  $(CP) libdl.a dlfcn.h .. ; \
          cd .. ;                    \
	  $(RANLIB) libdl.a ;     )
#######
# plotting library
libcoxplot.a:coxplot.h
	( cd coxplot ;                                                       \
	  $(MAKE) libcoxplot.a clean 'RM=$(RM)' 'CC=$(CC)' 'AR=$(AR)'        \
	        'RANLIB=$(RANLIB)' 'LDFLAGS=$(LDFLAGS)' 'IFLAGS=$(ISFLAGS)' ; \
	  $(MV) libcoxplot.a .. ; )
coxplot.h:coxplot/coxplot.h
	$(CP) coxplot/coxplot.h ./
coxplot.tgz:
	$(TAR) cf - ./coxplot | $(GZIP) -9v > coxplot.tgz
#######
# rickr objects
3dresample.o: rickr/3dresample.c
	$(RM) $@
	$(CC) -c rickr/3dresample.c $(INFLAGS)
r_new_resam_dset.o: rickr/r_new_resam_dset.c rickr/r_new_resam_dset.h
	$(RM) $@
	$(CC) -c rickr/r_new_resam_dset.c $(INFLAGS)
r_idisp.o: rickr/r_idisp.c rickr/r_idisp.h
	$(RM) $@
	$(CC) -c rickr/r_idisp.c $(INFLAGS)
r_misc.o: rickr/r_misc.c rickr/r_misc.h
	$(RM) $@
	$(CC) -c rickr/r_misc.c $(INFLAGS)
#######
# rickr programs
3dmaxima: 3dmaxima.o maxima.o libmri.a
	$(RM) $@
	$(CC) -o 3dmaxima 3dmaxima.o maxima.o $(LFLAGS) $(LLIBS)
3dresample: 3dresample.o libmri.a
	$(RM) $@
	$(CC) -o 3dresample 3dresample.o $(LFLAGS) $(LLIBS)
file_tool: ge4_header.o
	( cd rickr ;                                                    \
	$(MAKE) file_tool 'RM=$(RM)' 'CC=$(CC)' 'IFLAGS=$(ISFLAGS)'      \
			'LFLAGS=$(LFLAGS)' 'LLIBS=$(LLIBS)' ;           \
	$(MV) file_tool .. ; )
Dimon: rickr/Dimon.c rickr/Imon.h rickr/realtime.c rickr/realtime.h
	( cd rickr ; 							\
	$(MAKE) Dimon 'RM=$(RM)' 'CC=$(CC)' 'IFLAGS=$(ISFLAGS)'        	\
		  'LFLAGS=$(LFLAGS)' 'EXTRA_LIBS_2=$(EXTRA_LIBS_2)'	\
		  'LGIFTI=$(LGIFTI)' ;					\
	$(MV) Dimon .. ; )
Imon: rickr/Imon.c rickr/Imon.h rickr/realtime.c rickr/realtime.h thd_iochan.o
	( cd rickr ; 							\
	$(MAKE) Imon 'RM=$(RM)' 'CC=$(CC)' 'IFLAGS=$(ISFLAGS)'        	\
		  'LFLAGS=$(LFLAGS)' 'EXTRA_LIBS_2=$(EXTRA_LIBS_2)' ;	\
	$(MV) Imon .. ; )
serial_helper: rickr/serial_helper.c
	( cd rickr ;                                                    \
	$(MAKE) serial_helper 'RM=$(RM)' 'CC=$(CC)' 'IFLAGS=$(ISFLAGS)'  \
		  'LFLAGS=$(LFLAGS)' 'EXTRA_LIBS_2=$(EXTRA_LIBS_2)' ;	\
	$(MV) serial_helper .. ; )
serial_writer: rickr/serial_writer.c
	$(RM) $@
	$(CCMIN) -o serial_writer rickr/serial_writer.c
gtest:
	( cd gifti ; 							\
	$(MAKE) gtest 'RM=$(RM)' 'CC=$(CC)' 'IFLAGS=$(ISFLAGS)'         \
	                'LFLAGS=$(LFLAGS)' ;                            \
	$(MV) gtest .. ; )
3dmatmult: 3dmatmult.o libmri.a
	$(RM) $@
	$(CC) -o 3dmatmult 3dmatmult.o $(LFLAGS) $(LLIBS)
3dmask_tool: 3dmask_tool.o libmri.a
	$(RM) $@
	$(CC) -o 3dmask_tool 3dmask_tool.o $(LFLAGS) $(LLIBS)
column_cat: rickr/column_cat.c
	$(RM) $@
	$(CC) -o column_cat rickr/column_cat.c

#######
# rendering library
libvolpack.a:
	( cd volpack ;                                                       \
	  $(MAKE) libvolpack.a clean 'RM=$(RM)' 'CC=$(CCVOL)' 'AR=$(AR)'     \
	        'RANLIB=$(RANLIB)' 'LDFLAGS=$(LDFLAGS)' 'IFLAGS=$(ISFLAGS)' ; \
	  $(MV) libvolpack.a .. ; )
volpack.h:
	$(CP) volpack/volpack.h ./
volpack.tgz:
	$(TAR) cf - ./volpack | $(GZIP) -9v > volpack.tgz
#######
# for Larry Frank
qhull:
	( cd qhulldir ;                                                  \
	  $(MAKE) qhull rbox qdelaunay clean \
	        'RM=$(RM)' 'CC=$(CC)' 'LFLAGS=$(LFLAGS)' ; \
	  $(MV) qhull rbox qdelaunay .. ; )
# CYGWIN: we "mv" the result, so must name it correctly as qhull.exe
qhull.exe:
	( cd qhulldir ;                                                  \
	  $(MAKE) qhull clean 'RM=$(RM)' 'CC=$(CC)' 'LFLAGS=$(LFLAGS)' ; \
	  $(MV) qhull.exe .. ; )
#######
# 3DEdge library files - make them and move them up here
lib3DEdge.a:
	( cd 3DEdge/src ; $(MAKE) clean lib3DEdge.a 'RM=$(RM)' 'AR=$(AR)' 'RANLIB=$(RANLIB)' 'CC=$(CCFAST)' 'IFLAGS=$(ISFLAGS)' 'LFLAGS=$(LFLAGS)' ; $(MV) *.a ../.. ; )
#######
# Eispack and CDF library files - make them and move them up here
eis_bakvec.o:
	( cd eispack/ ; $(MAKE) all 'CC=$(CCFAST)' 'CCSVD=$(CCSVD)' ; $(MV) *.o .. ; )
#######
# Ditto for NIML objects
$(NIML_OBJS):niml.h
	( cd niml/ ; $(MAKE) all 'CC=$(CC)' ; $(MV) *.o .. ; )
niml.h:niml/niml.h
	$(CP) niml/niml.h .
#######
# netcdf library files - make them and move them up here
netcdf_attr.o:
	( cd netcdf-3.5.0/src ;                           \
          FC=""  ; export FC  ; F90=""   ; export F90 ;   \
          CXX="" ; export CXX ; CC="${CCMIN}";export CC;  \
          $(RM) config.cache config.log config.status ;   \
          chmod ugo+x ./configure ;                       \
          ./configure ; $(MAKE) libsrc/all ;              \
          $(CP) libsrc/netcdf.h  ../.. ;                  \
          $(MV) libsrc/attr.o    ../../netcdf_attr.o    ; \
          $(MV) libsrc/dim.o     ../../netcdf_dim.o     ; \
          $(MV) libsrc/error.o   ../../netcdf_error.o   ; \
          $(MV) libsrc/libvers.o ../../netcdf_libvers.o ; \
          $(MV) libsrc/nc.o      ../../netcdf_nc.o      ; \
          $(MV) libsrc/ncio.o    ../../netcdf_ncio.o    ; \
          $(MV) libsrc/ncx.o     ../../netcdf_ncx.o     ; \
          $(MV) libsrc/putget.o  ../../netcdf_putget.o  ; \
          $(MV) libsrc/string.o  ../../netcdf_string.o  ; \
          $(MV) libsrc/v1hpg.o   ../../netcdf_v1hpg.o   ; \
          $(MV) libsrc/v2i.o     ../../netcdf_v2i.o     ; \
          $(MV) libsrc/var.o     ../../netcdf_var.o     ; \
          $(RM) config.cache config.log config.status ;   \
          $(MAKE) clean ; )
#######
# 27 Jul 2001 - for fun
gifsicle:
	( cd gifsicledir ;                                                  \
	  $(MAKE) gifsicle clean 'RM=$(RM)' 'CC=$(CC)' 'LFLAGS=$(LFLAGS)' ; \
	  $(MV) gifsicle .. ; )
#######
# 02 Aug 2001 - for fun
mpeg_encode:
	( cd mpeg_encodedir ;                                                                   \
	  $(MAKE) mpeg_encode clean 'RM=$(RM)' 'CC=$(CC)' 'LFLAGS=$(LFLAGS)' 'LLIBS=$(LLIBS)' ; \
	  $(MV) mpeg_encode .. ; )
#######
# 03 Dec 2003 - for even more fun
mpegtoppm:
	( cd mpegtoppm_dir ; chmod ugo+x ./configure ;                                         \
	  ./configure --disable-sdl --disable-mlib --without-x --disable-dependency-tracking --disable-accel-detect ; \
	  $(MAKE) ; mv doc/sample2 ../mpegtoppm ; $(MAKE) clean ; )
#######
# 11 Sep 2002 - for fun
djpeg:cjpeg
libjpeg.a:cjpeg
cjpeg:
	( cd jpeg-6b ; $(RM) Makefile jconfig.h ;                    \
          chmod ugo+x ./configure ; ./configure 'CC=$(CCMIN)' ; \
          $(MAKE) ; $(MV) cjpeg djpeg libjpeg.a .. ;            \
          $(MAKE) clean ; $(RM) Makefile )
libXmHTML.a:
	( cd XmHTML ; make lib 'CC=$(CC)' 'II=$(IFLAGS)' ; \
		$(MV) lib/libXmHTML.a .. ; make clean   )
thd_xwebber.o:thd_xwebber.c
	$(CC) -c thd_xwebber.c -I./XmHTML/include $(INFLAGS)
#######
# FFTW - not used
libfftw.a:
	( cd fftw ;                                                    \
	  $(MAKE) libfftw.a clean 'RM=$(RM)' 'CC=$(CCFAST)' 'AR=$(AR)' \
	        'RANLIB=$(RANLIB)' 'LDFLAGS=$(LDFLAGS)' 'IFLAGS=$(ISFLAGS)' ; \
	  $(MV) libfftw.a .. ; )
fftw.h:
	$(CP) fftw/fftw.h ./
fftw_setup:fftw_setup.o
	$(CC) -o fftw_setup fftw_setup.o $(LFLAGS) -lfftw $(LLIBS)
#######
# CLAMS - not used
libclam.a:
	( cd clamdir ;                                             \
	  $(MAKE) libclam.a clean 'RM=$(RM)' 'CC=$(CC)' 'AR=$(AR)' \
	        'RANLIB=$(RANLIB)' 'IFLAGS=-I..' ;                 \
	  $(MV) libclam.a .. ; )
libclam.h:
	$(CP) clamdir/libclam.h ./
clamsrc.tgz:
	$(TAR) cf - ./clamsrc | $(GZIP) -9v > clamsrc.tgz
clamdir.tgz:
	$(TAR) cf - ./clamdir | $(GZIP) -9v > clamdir.tgz
#######
## The following line only needs to be used if parser.f
## is edited, since AFNI ships with parser.c already made.
parser.c:
	$(F2C) parser.f
## expression parsing and evaluation functions
parser.o:parser.c f2c.h libf2c.a
	$(CCFAST) -c parser.c $(INFLAGS)
## programs that user parser.c functions
ccalc:parser.o parser_int.o ccalc.o
	$(RM) $@
	$(CC) -o ccalc ccalc.o parser.o parser_int.o $(LFLAGS) $(LLIBS)
1deval:parser.o parser_int.o 1deval.o
	$(RM) $@
	$(CC) -o 1deval 1deval.o parser.o parser_int.o $(LFLAGS) $(LLIBS)
1dmatcalc:parser.o parser_int.o 1dmatcalc.o mri_matrix.o
	$(RM) $@
	$(CC) -o 1dmatcalc 1dmatcalc.o parser.o parser_int.o $(LFLAGS) $(LLIBS)
3dmatcalc:parser.o parser_int.o 3dmatcalc.o
	$(RM) $@
	$(CC) -o 3dmatcalc 3dmatcalc.o parser.o parser_int.o $(LFLAGS) $(LLIBS)
colfit.c:
	$(F2C) colfit.f
colcalc.c:
	$(F2C) colcalc.f
colfit:parser.o colfit.o
	$(CC) -o colfit colfit.o parser.o $(LFLAGS) -lclam $(LLIBS)
colcalc:parser.o colcalc.o
	$(CC) -o colcalc colcalc.o parser.o $(LFLAGS) -lclam $(LLIBS)
imcalc:imcalc.o parser.o parser_int.o
	$(CC) -o imcalc imcalc.o parser.o parser_int.o $(LFLAGS) $(LLIBS)

AFNI_HIST_FILES  = afni_history.c					     \
	afni_history_bpittman.c afni_history_christip.c afni_history_dglen.c \
	afni_history_gangc.c afni_history_rickr.c afni_history_rwcox.c	     \
	afni_history_ziad.c
afni_history: $(AFNI_HIST_FILES)
	$(RM) $@
	$(CCMIN) -o afni_history $(AFNI_HIST_FILES)
###########################################################################
# Miscellaneous programs, mostly for testing purposes
fftest:fftest.o
	$(CC) -o fftest fftest.o $(LFLAGS) $(LLIBS)
fftwest:fftest.c
	$(CC) -o fftwest fftest.c -DUSE_FFTW $(LFLAGS) -lfftw $(LLIBS)
fftnext:fftnext.o
	$(CC) -o fftnext fftnext.o $(LFLAGS) $(LLIBS)
fftcheck:fftcheck.o
	$(CC) -o fftcheck fftcheck.o $(LFLAGS) $(LLIBS)
fftest_dj:fftest_dj.o csfft_dj.o fft_dj.o
	$(CC) -o fftest_dj fftest_dj.o csfft_dj.o fft_dj.o $(LFLAGS) $(LLIBS)
fftprint:fftprint.o
	$(CC) -o fftprint fftprint.o $(LFLAGS) $(LLIBS)
## get a Web page using the command line
myget:myget.o
	$(CC) -o myget myget.o $(LFLAGS) $(LLIBS)
## zero out before removing
rmz:rmz.o
	$(CC) -o rmz rmz.o $(LFLAGS) $(LLIBS)
uncomment:uncomment.o
	$(CC) -o uncomment uncomment.o $(LFLAGS) $(LLIBS)
help_format:help_format.o
	$(CC) -o help_format help_format.o
ibinom:ibinom.o
	$(CC) -o ibinom ibinom.o $(LFLAGS) $(LLIBS)
## GIF animation
whirlgif:whirlgif.h whirlgif.c
	$(CC) -o whirlgif whirlgif.c $(INFLAGS) $(LFLAGS) $(LLIBS)
extor.o:extor.c
	$(CCFAST) -c extor.c $(INFLAGS)
ktaub.o:ktaub.c
	$(CCFAST) -c ktaub.c $(INFLAGS)
bilinear_warp3D.o:bilinear_warp3D.c
	$(CCFAST) -c bilinear_warp3D.c $(INFLAGS)
thd_detrend.o:thd_detrend.c
	$(CCFAST) -c thd_detrend.c $(INFLAGS)
thd_bandpass.o:thd_bandpass.c
	$(CCFAST) -c thd_bandpass.c $(INFLAGS)
thd_dset_to_vectim.o:thd_dset_to_vectim.c
	$(CCFAST) -c thd_dset_to_vectim.c $(INFLAGS)
thd_ttest.o:thd_ttest.c
	$(CCFAST) -c thd_ttest.c $(INFLAGS)
extor:extor.o
	$(CC) -o extor extor.o $(INFLAGS) $(LFLAGS) $(LLIBS)
exx.o:exx.c
	$(CCFAST) -c exx.c $(INFLAGS)
exx:exx.o
	$(CC) -o exx exx.o $(INFLAGS) $(LFLAGS) $(LLIBS)
mycat:mycat.o
	$(CC) -o mycat mycat.o $(LFLAGS)
qqq.o:qqq.c
	$(CCFAST) -c qqq.c $(INFLAGS)
qqq:qqq.o
	$(CC) -o qqq qqq.o $(INFLAGS) $(LFLAGS) -lmrix -lcoxplot  $(LLIBS)
warping.o:warping.c
	$(CCFAST) -c warping.c $(INFLAGS)
warping:warping.o
	$(CC) -o warping warping.o $(INFLAGS) $(LFLAGS) $(LLIBS)
mri_gwarp.o:mri_gwarp.c
	$(CCFAST) -c mri_gwarp.c $(INFLAGS)
gwarp:mri_gwarp.o
	$(CC) -o gwarp mri_gwarp.o $(INFLAGS) $(LFLAGS) $(LLIBS)
3dMaskToASCII.o:3dMaskToASCII.c
	$(CC) -c 3dMaskToASCII.c $(INFLAGS)
3dMaskToASCII:3dMaskToASCII.o
	$(CC) -o 3dMaskToASCII 3dMaskToASCII.o $(INFLAGS) $(LFLAGS) $(LLIBS)
bitvec.o:bitvec.c
	$(CCFAST) -c bitvec.c $(INFLAGS)
bitvec:bitvec.o
	$(CC) -o bitvec bitvec.o $(INFLAGS) $(LFLAGS) $(LLIBS)
unu.o:unu.c
	$(CCFAST) -c unu.c $(INFLAGS)
unu:unu.o
	$(CC) -o unu unu.o $(INFLAGS) $(LFLAGS) $(LLIBS)
Xphace:Xphace.o
	$(CC) -o Xphace Xphace.o $(INFLAGS) $(LFLAGS) -lmrix -lcoxplot  $(LLIBS)
3dbetafit:3dbetafit.o betafit.c
	$(CC) -o 3dbetafit 3dbetafit.o $(INFLAGS) $(LFLAGS) $(LLIBS)
3dbetafit2.o:3dbetafit2.c
	$(CCFAST) -c 3dbetafit2.c $(INFLAGS)
pv.o:pv.c
	$(CCFAST) -c pv.c $(INFLAGS)
3dbetafit2:3dbetafit2.o betafit.c
	$(CC) -o 3dbetafit2 3dbetafit2.o $(INFLAGS) $(LFLAGS) $(LLIBS)
3dbetafit3:3dbetafit3.o betafit.c
	$(CC) -o 3dbetafit3 3dbetafit3.o $(INFLAGS) $(LFLAGS) $(LLIBS)
testcox:testcox.o
	$(CC) -o testcox testcox.o $(INFLAGS) $(LFLAGS) $(LLIBS)
agni_to_afni:agni_to_afni.o agni.o
	$(CC) -o agni_to_afni agni_to_afni.o $(INFLAGS) $(LFLAGS) $(LLIBS)
epsim:epsim.o
	$(RM) $@
	$(CC) -o epsim epsim.o $(LFLAGS) $(LLIBS)
nimltest:nimltest.o niml.h
	$(RM) $@
	$(CC) -o nimltest nimltest.o $(LFLAGS) $(LLIBS)
nimel:nimel.o niml.h
	$(RM) $@
	$(CC) -o nimel nimel.o $(LFLAGS) $(LLIBS)
nidset:nidset.o niml.h
	$(RM) $@
	$(CC) -o nidset nidset.o $(LFLAGS) $(LLIBS)
nicat:nicat.o
	$(RM) $@
	$(CC) -o nicat nicat.o $(LFLAGS) $(LLIBS)
malp:mri_alphasim.o
	$(RM) $@
	$(CC) -o malp mri_alphasim.o $(LFLAGS) $(LLIBS)
test_rowtype:test_rowtype.o
	$(RM) $@
	$(CC) -o test_rowtype test_rowtype.o $(LFLAGS) $(LLIBS)
niccc:niccc.o
	$(RM) $@
	$(CC) -o niccc niccc.o $(LFLAGS) $(LLIBS)
aiv:aiv.o
	$(RM) $@
	$(CC) -o aiv aiv.o $(LFLAGS) -lmrix -lcoxplot $(LLIBS)
test_powell:test_powell.o
	$(RM) $@
	$(CC) -o test_powell test_powell.o $(LFLAGS) $(LLIBS)
asnap:asnap.o
	$(RM) $@
	$(CC) -o asnap asnap.o $(LFLAGS) -lmrix -lcoxplot $(LLIBS)
galler:galler.o
	$(RM) $@
	$(CC) -o galler galler.o $(LFLAGS) $(LLIBS)
# specifics for the nifti library files
3dAFNItoNIFTI.o:3dAFNItoNIFTI.c
	$(RM) $@
	$(CC) -c 3dAFNItoNIFTI.c $(INFLAGS)
3dAFNItoNIFTI:3dAFNItoNIFTI.o nifti1_io.o znzlib.o
	$(RM) $@
	$(CC) -o 3dAFNItoNIFTI 3dAFNItoNIFTI.o nifti1_io.o znzlib.o $(LFLAGS) $(LLIBS)
nifti1_io.o:nifti/niftilib/nifti1_io.c nifti/niftilib/nifti1_io.h
	$(RM) $@
	$(CC) -c nifti/niftilib/nifti1_io.c $(INFLAGS)
znzlib.o:nifti/znzlib/znzlib.c nifti/znzlib/znzlib.h
	$(RM) $@
	$(CC) -c nifti/znzlib/znzlib.c $(INFLAGS)
nifti_stats.o:nifti/utils/nifti_stats.c
	$(RM) $@
	$(CC) -c nifti/utils/nifti_stats.c $(INFLAGS)
# 64-bit gcc 4.0+ has optimization problem with this file
# -> use 3.4 if necessary		19 May 2010 [rickr]
nifticdf.o:nifti/nifticdf/nifticdf.c
	$(RM) $@
	$(CCOLD) -D__COMPILE_UNUSED_FUNCTIONS__ -c nifti/nifticdf/nifticdf.c $(INFLAGS)
nifti_statlib.o:nifti/utils/nifti_stats.c nifti_statlib.c
	$(RM) $@
	$(CC) -c nifti_statlib.c -Inifti/utils $(INFLAGS)
nifti_stats:nifti_stats.o nifticdf.o
	$(RM) $@
	$(CC) -o nifti_stats nifti_stats.o nifticdf.o -lm
nifti1_test.o:nifti/utils/nifti1_test.c
	$(RM) $@
	$(CC) -c nifti/utils/nifti1_test.c $(INFLAGS)
nifti1_test:nifti1_test.o nifti1_io.o znzlib.o
	$(RM) $@
	$(CC) -o nifti1_test nifti1_test.o nifti1_io.o znzlib.o $(LZLIB) -lm
nifti_tool.o:nifti/utils/nifti_tool.c
	$(RM) $@
	$(CC) -c nifti/utils/nifti_tool.c $(INFLAGS)
nifti_tool:nifti_tool.o nifti1_io.o znzlib.o
	$(RM) $@
	$(CC) -o nifti_tool nifti_tool.o nifti1_io.o znzlib.o $(LZLIB) -lm
nifti_tool.exe:nifti_tool.o nifti1_io.o znzlib.o
	$(RM) $@
	$(CC) -o nifti_tool.exe nifti_tool.o nifti1_io.o znzlib.o $(LZLIB) -lm
# just compile completely, removing issue of libraries
gifti_tool:nifti1_io.o znzlib.o
	$(RM) $@
	$(CC) -o gifti_tool $(INFLAGS) $(LFLAGS) 			\
		gifti/gifti_tool.c gifti/gifti_io.c gifti/gifti_xml.c 	\
		nifti1_io.o znzlib.o $(LGIFTI) $(LZLIB) -lm
gifti_choice.o:gifti_choice.c thd_gifti.c suma_gifti.c
	$(RM) $@
	$(CC) -c gifti_choice.c -Igifti $(INFLAGS)
tsdsim:tsdsim.o
	$(RM) $@
	$(CC) -o tsdsim tsdsim.o $(LFLAGS) $(LLIBS) -lmx
tsdsolve:tsdsolve.c
	$(CC) -c tsdsolve.c -I.
	$(CC) -o tsdsolve tsdsolve.o $(LFLAGS)            \
	      -llapack_panther -lblas_panther -lF77 -lI77 \
	      $(LLIBS)

#-------------------------------------------------------------------------------
#############
#AVOVK directory
3dkmeans: avovk/3dkmeans.c avovk/cluster_floatNOMASK.c avovk/thd_segtools_fNM.c
	( cd avovk ;	\
	./@MakeLocalMake	;\
	$(MAKE) afni_all  ;	\
	cd ../	;		)
libsegtools.a: avovk/cluster_floatNOMASK.c avovk/thd_segtools_fNM.c
	( cd avovk ;	\
	./@MakeLocalMake	;\
	$(MAKE) libsegtools.a  ;	\
	$(CP) libsegtools.a ../;	\
	cd ../	;		)

#############
#PTAYLOR directory
ptaylor_all: 
	( cd ptaylor ;	\
	./@MakeLocalMake	;\
	$(MAKE) afni_all  ;	\
	cd ../	;		)
ptaylor_install:
	( cd ptaylor ;	\
	./@MakeLocalMake	;\
	$(MAKE) afni_install  ;	\
	cd ../	;		)
libtracktools.a:
	( cd ptaylor ;	\
	./@MakeLocalMake	;\
	$(MAKE) clean libtracktools.a  ;	\
	$(CP) libtracktools.a ../;	\
	cd ../	;		)
#############
#PKUNDU directory
pkundu_install:
	( cd pkundu ;	\
	./@install_pkundu $(INSTALLDIR)	;\
	cd ../	;		)
#############
#SUMA
libSUMA.a: libmri.a libmrix.a libcoxplot.a libf2c.a libtracktools.a
	( cd SUMA ;	\
	rm -f libSUMA.a	;\
	$(MAKE) -f $(SUMA_MAKEFILE_NAME) clean MarchingCubes.o libSUMA.a 'INSTALLDIR=$(INSTALLDIR)' \
	'SUMA_INCLUDE_PATH=$(SUMA_INCLUDE_PATH)' \
	'SUMA_BIN_ARCHIVE=$(SUMA_BIN_ARCHIVE)' \
	'RANLIB=$(RANLIB)' \
        'MAKE=$(MAKE)'     \
	'CC=$(CC)' 'RM=$(RM)' 'CEXTRA=$(CEXTRA)' 'MV=$(MV)' 'CP=$(CP)'	\
	'TAR=$(TAR)' 'MKDIR=$(MKDIR)';	\
	cd ../	;	\
	if [ ! -d $(INSTALLDIR) ]; then $(MKDIR) -p $(INSTALLDIR); echo WARNING: directory $(INSTALLDIR) has been created. ; fi	;\
	$(CP) SUMA/libSUMA.a ${INSTALLDIR}; \
	$(CP) SUMA/libSUMA.a ./;	)
libgts.a:
	( cd SUMA ;	\
	rm -f libgts.a	;\
	$(MAKE) -f $(SUMA_MAKEFILE_NAME) libgts.a ;	\
	cd ../	;	\
	if [ ! -d $(INSTALLDIR) ]; then $(MKDIR) -p $(INSTALLDIR); echo WARNING: directory $(INSTALLDIR) has been created. ; fi	;\
	$(CP) SUMA/libgts.a ${INSTALLDIR}; \
	$(CP) SUMA/libgts.a ./;	)
libSUMAseg.a:
	( cd SUMA ;	\
	rm -f libSUMAseg.a	;\
	$(MAKE) -f $(SUMA_MAKEFILE_NAME) libSUMAseg.a ;	\
	cd ../	;	\
	if [ ! -d $(INSTALLDIR) ]; then $(MKDIR) -p $(INSTALLDIR); echo WARNING: directory $(INSTALLDIR) has been created. ; fi	;\
	$(CP) SUMA/libSUMAseg.a ${INSTALLDIR}; \
	$(CP) SUMA/libSUMAseg.a ./;	)
libGLws.a:
	( cd SUMA ;	\
	rm -f libGLws.a	;\
	$(MAKE) -f $(SUMA_MAKEFILE_NAME) libGLws.a 'INSTALLDIR=$(INSTALLDIR)' \
	'SUMA_INCLUDE_PATH=$(SUMA_INCLUDE_PATH)' \
	'SUMA_BIN_ARCHIVE=$(SUMA_BIN_ARCHIVE)' \
	'RANLIB=$(RANLIB)' \
        'MAKE=$(MAKE)'     \
	'CC=$(CC)' 'RM=$(RM)' 'CEXTRA=$(CEXTRA)' 'MV=$(MV)' 'CP=$(CP)'	\
	'TAR=$(TAR)' 'MKDIR=$(MKDIR)';	\
	cd ../	;	\
	if [ ! -d $(INSTALLDIR) ]; then $(MKDIR) -p $(INSTALLDIR); echo WARNING: directory $(INSTALLDIR) has been created. ; fi	;\
	$(CP) SUMA/libGLws.a ${INSTALLDIR}; \
	$(CP) SUMA/libGLws.a ./;	)
###
#link executables but check for libraries first and create them if needed	
suma_exec:libGLws.a libSUMA.a libtracktools.a libmri.a xutil.o LiteClue.o parser.o parser_int.o libmrix.a libcoxplot.a libf2c.a
	( cd SUMA ;	\
	$(MAKE) -f $(SUMA_MAKEFILE_NAME) testGL suma ScaleToMap CompareSurfaces \
	MakeColorMap ROI2dataset 3dVol2Surf \
	3dSurf2Vol SurfMeasures SurfFWHM \
	ConvertSurface ConvertDset SurfClust IsoSurface \
   ConvexHull MapIcosahedron CreateIcosahedron SurfaceMetrics \
   SurfSmooth inspec quickspec FSread_annot SurfPatch SurfQual SampBias \
   3dSkullStrip 3dCRUISEtoAFNI 3dBRAIN_VOYAGERtoAFNI 3dSurfMask\
   SurfToSurf Surf2VolCoord ROIgrow SurfDsetInfo SurfInfo AnalyzeTrace \
   DriveSuma SurfDist SpharmReco SpharmDeco prompt_user SurfRetinoMap \
   ParseName 3dGenPriors 3dSeg SurfExtrema 3dinfill 3dHist \
   'INSTALLDIR=$(INSTALLDIR)' \
	'SUMA_INCLUDE_PATH=$(SUMA_INCLUDE_PATH)' \
	'SUMA_LINK_PATH=$(SUMA_LINK_PATH)' \
	'SUMA_LINK_LIB=$(SUMA_LINK_LIB)' \
	'SUMA_BIN_ARCHIVE=$(SUMA_BIN_ARCHIVE)' \
	'SUMA_GLIB_VER=$(SUMA_GLIB_VER)' \
	'RANLIB=$(RANLIB)' \
        'MAKE=$(MAKE)'     \
	'CC=$(CC)' 'RM=$(RM)' 'CEXTRA=$(CEXTRA)' 'MV=$(MV)' 'CP=$(CP)'		\
	'TAR=$(TAR)' 'MKDIR=$(MKDIR)';	\
	cd ../	;)
###
#Do the GTS related stuff 	
suma_gts_progs: libgts.a
	( cd SUMA ;	\
	$(MAKE) -f $(SUMA_MAKEFILE_NAME) SurfMesh 'INSTALLDIR=$(INSTALLDIR)' \
	'SUMA_INCLUDE_PATH=$(SUMA_INCLUDE_PATH)' \
	'SUMA_LINK_PATH=$(SUMA_LINK_PATH)' \
	'SUMA_LINK_LIB=$(SUMA_LINK_LIB)' \
	'SUMA_BIN_ARCHIVE=$(SUMA_BIN_ARCHIVE)' \
	'SUMA_GLIB_VER=$(SUMA_GLIB_VER)' \
	'RANLIB=$(RANLIB)' \
        'MAKE=$(MAKE)'     \
	'CC=$(CC)' 'RM=$(RM)' 'CEXTRA=$(CEXTRA)' 'MV=$(MV)' 'CP=$(CP)'		\
	'TAR=$(TAR)' 'MKDIR=$(MKDIR)';	\
	cd ../	;)
###
#run make all in SUMA directory, USE FOR DEVELOPMENT ONLY	
suma_all:libmri.a libtracktools.a xutil.o LiteClue.o parser.o parser_int.o libmrix.a libcoxplot.a libf2c.a
	( cd SUMA ;	\
	$(MAKE) -f $(SUMA_MAKEFILE_NAME) all 'INSTALLDIR=$(INSTALLDIR)' 'INSTALLDIR_SUMA=$(INSTALLDIR)' \
	'SUMA_INCLUDE_PATH=$(SUMA_INCLUDE_PATH)' \
	'SUMA_LINK_PATH=$(SUMA_LINK_PATH)' \
	'SUMA_LINK_LIB=$(SUMA_LINK_LIB)' \
	'SUMA_BIN_ARCHIVE=$(SUMA_BIN_ARCHIVE)' \
	'SUMA_GLIB_VER=$(SUMA_GLIB_VER)' \
	'RANLIB=$(RANLIB)' \
        'MAKE=$(MAKE)'     \
	'CC=$(CC)' 'RM=$(RM)' 'CEXTRA=$(CEXTRA)' 'MV=$(MV)' 'CP=$(CP)'		\
	'TAR=$(TAR)' 'MKDIR=$(MKDIR)';	\
	cd ../	;)
###
#run make anew in SUMA directory, USE FOR DEVELOPMENT ONLY	
suma_anew:libmri.a xutil.o LiteClue.o parser.o parser_int.o libmrix.a libcoxplot.a libf2c.a libtracktools.a
	( cd SUMA ;	\
	$(MAKE) -f $(SUMA_MAKEFILE_NAME) anew 'INSTALLDIR=$(INSTALLDIR)' 'INSTALLDIR_SUMA=$(INSTALLDIR)' \
	'SUMA_INCLUDE_PATH=$(SUMA_INCLUDE_PATH)' \
	'SUMA_LINK_PATH=$(SUMA_LINK_PATH)' \
	'SUMA_LINK_LIB=$(SUMA_LINK_LIB)' \
	'SUMA_BIN_ARCHIVE=$(SUMA_BIN_ARCHIVE)' \
	'SUMA_GLIB_VER=$(SUMA_GLIB_VER)' \
	'RANLIB=$(RANLIB)' \
        'MAKE=$(MAKE)'     \
	'CC=$(CC)' 'RM=$(RM)' 'CEXTRA=$(CEXTRA)' 'MV=$(MV)' 'CP=$(CP)'		\
	'TAR=$(TAR)' 'MKDIR=$(MKDIR)';	\
	cd ../	;)
suma_clean:
	$(RM) SUMA/libSUMA.a libSUMA.a SUMA/libGLws.a libGLws.a	
	if [ -f SUMA/suma ]; then $(RM) SUMA/suma; fi;
	if [ -f suma ]; then $(RM) suma; fi;
	if [ -f SUMA/MakeColorMap ]; then $(RM) SUMA/MakeColorMap; fi;
	if [ -f MakeColorMap ]; then $(RM) MakeColorMap; fi;
	if [ -f SUMA/ROI2dataset ]; then $(RM) SUMA/ROI2dataset; fi;
	if [ -f ROI2dataset ]; then $(RM) ROI2dataset; fi;
	if [ -f SUMA/3dVol2Surf ]; then $(RM) SUMA/3dVol2Surf; fi;
	if [ -f 3dVol2Surf ]; then $(RM) 3dVol2Surf; fi;
	if [ -f SUMA/3dSurf2Vol ]; then $(RM) SUMA/3dSurf2Vol; fi;
	if [ -f 3dSurf2Vol ]; then $(RM) 3dSurf2Vol; fi;
	if [ -f SUMA/SurfMeasures ]; then $(RM) SUMA/SurfMeasures; fi;
	if [ -f SurfMeasures ]; then $(RM) SurfMeasures; fi;
	if [ -f SUMA/SurfFWHM  ]; then $(RM) SUMA/SurfFWHM ; fi;
	if [ -f SurfFWHM  ]; then $(RM) SurfFWHM ; fi;
	if [ -f ScaleToMap ]; then $(RM) ScaleToMap; fi;
	if [ -f SUMA/ScaleToMap ]; then $(RM) SUMA/ScaleToMap; fi;
	if [ -f CompareSurfaces  ]; then $(RM) CompareSurfaces ; fi;
	if [ -f SUMA/CompareSurfaces  ]; then $(RM) SUMA/CompareSurfaces ; fi;
	if [ -f ConvertSurface ]; then $(RM) ConvertSurface; fi;
	if [ -f SUMA/ConvertSurface ]; then $(RM) SUMA/ConvertSurface; fi;
	if [ -f ConvertDset ]; then $(RM) ConvertDset; fi;
	if [ -f SUMA/ConvertDset ]; then $(RM) SUMA/ConvertDset; fi;
	if [ -f SurfClust ]; then $(RM) SurfClust; fi;
	if [ -f SUMA/SurfClust ]; then $(RM) SUMA/SurfClust; fi;
	if [ -f IsoSurface ]; then $(RM) IsoSurface; fi;
	if [ -f SUMA/IsoSurface ]; then $(RM) SUMA/IsoSurface; fi;
	if [ -f ConvexHull ]; then $(RM) ConvexHull; fi;
	if [ -f SUMA/ConvexHull ]; then $(RM) SUMA/ConvexHull; fi;
	if [ -f SUMA_glxdino ]; then $(RM) SUMA_glxdino; fi;
	if [ -f SUMA_paperplane ]; then $(RM) SUMA_paperplane; fi;
	if [ -f SUMA/SUMA_glxdino ]; then $(RM) SUMA/SUMA_glxdino; fi;
	if [ -f SUMA/SUMA_paperplane ]; then $(RM) SUMA/SUMA_paperplane; fi;
	if [ -f SUMA_pixmap2eps ]; then $(RM) SUMA_pixmap2eps; fi;
	if [ -f SUMA/SUMA_pixmap2eps ]; then $(RM) SUMA/SUMA_pixmap2eps; fi;
	if [ -f SurfaceMetrics ]; then $(RM) SurfaceMetrics; fi;
	if [ -f SUMA/SurfaceMetrics ]; then $(RM) SUMA/SurfaceMetrics; fi;
	if [ -f inspec ]; then $(RM) inspec; fi;
	if [ -f SUMA/inspec ]; then $(RM) SUMA/inspec; fi;
	if [ -f quickspec ]; then $(RM) quickspec; fi;
	if [ -f SUMA/quickspec ]; then $(RM) SUMA/quickspec; fi;
	if [ -f FSread_annot ]; then $(RM) FSread_annot; fi;
	if [ -f SUMA/FSread_annot ]; then $(RM) SUMA/FSread_annot; fi;
	if [ -f SurfPatch ]; then $(RM) SurfPatch; fi;
	if [ -f SUMA/SurfPatch ]; then $(RM) SUMA/SurfPatch; fi;
	if [ -f SurfQual ]; then $(RM) SurfQual; fi;
	if [ -f SUMA/SurfQual ]; then $(RM) SUMA/SurfQual; fi;
	if [ -f SurfSmooth ]; then $(RM) SurfSmooth; fi;
	if [ -f SUMA/SurfSmooth ]; then $(RM) SUMA/SurfSmooth; fi;
	if [ -f MapIcosahedron ]; then $(RM) MapIcosahedron; fi;
	if [ -f SUMA/MapIcosahedron ]; then $(RM) SUMA/MapIcosahedron; fi;
	if [ -f CreateIcosahedron ]; then $(RM) CreateIcosahedron; fi;
	if [ -f SUMA/CreateIcosahedron ]; then $(RM) SUMA/CreateIcosahedron; fi;
	if [ -f SurfMesh ]; then $(RM) SurfMesh; fi;
	if [ -f SUMA/SurfMesh ]; then $(RM) SUMA/SurfMesh; fi;
	if [ -f SampBias ]; then $(RM) SampBias; fi;
	if [ -f SUMA/SampBias ]; then $(RM) SUMA/SampBias; fi;
	if [ -f 3dSkullStrip  ]; then $(RM) 3dSkullStrip ; fi;
	if [ -f SUMA/3dSkullStrip  ]; then $(RM) SUMA/3dSkullStrip ; fi;
	if [ -f 3dCRUISEtoAFNI  ]; then $(RM) 3dCRUISEtoAFNI ; fi;
	if [ -f SUMA/3dCRUISEtoAFNI  ]; then $(RM) SUMA/3dCRUISEtoAFNI ; fi;
	if [ -f 3dBRAIN_VOYAGERtoAFNI  ]; then $(RM) 3dBRAIN_VOYAGERtoAFNI ; fi;
	if [ -f SUMA/3dBRAIN_VOYAGERtoAFNI  ]; then $(RM) SUMA/3dBRAIN_VOYAGERtoAFNI ; fi;
	if [ -f 3dSurfMask  ]; then $(RM) 3dSurfMask ; fi;
	if [ -f SUMA/3dSurfMask  ]; then $(RM) SUMA/3dSurfMask ; fi;
	if [ -f SurfToSurf   ]; then $(RM) SurfToSurf  ; fi;
	if [ -f SUMA/SurfToSurf   ]; then $(RM) SUMA/SurfToSurf  ; fi;
	if [ -f Surf2VolCoord    ]; then $(RM) Surf2VolCoord   ; fi;
	if [ -f SUMA/Surf2VolCoord    ]; then $(RM) SUMA/Surf2VolCoord   ; fi;
	if [ -f ROIgrow   ]; then $(RM) ROIgrow  ; fi;
	if [ -f SUMA/ROIgrow   ]; then $(RM) SUMA/ROIgrow  ; fi;
	if [ -f SurfDsetInfo    ]; then $(RM) SurfDsetInfo   ; fi;
	if [ -f SUMA/SurfDsetInfo    ]; then $(RM) SUMA/SurfDsetInfo   ; fi;
	if [ -f SurfInfo    ]; then $(RM) SurfInfo   ; fi;
	if [ -f SUMA/SurfInfo    ]; then $(RM) SUMA/SurfInfo   ; fi;
	if [ -f AnalyzeTrace     ]; then $(RM) AnalyzeTrace    ; fi;
	if [ -f SUMA/AnalyzeTrace     ]; then $(RM) SUMA/AnalyzeTrace    ; fi;
	if [ -f DriveSuma     ]; then $(RM) DriveSuma    ; fi;
	if [ -f SUMA/DriveSuma     ]; then $(RM) SUMA/DriveSuma    ; fi;
	if [ -f SurfDist ]; then $(RM) SurfDist; fi;
	if [ -f SUMA/SurfDist ]; then $(RM) SUMA/SurfDist; fi;
	if [ -f SpharmReco ]; then $(RM) SpharmReco; fi;
	if [ -f SUMA/SpharmReco ]; then $(RM) SUMA/SpharmReco; fi;
	if [ -f SpharmDeco ]; then $(RM) SpharmDeco; fi;
	if [ -f SUMA/SpharmDeco ]; then $(RM) SUMA/SpharmDeco; fi;
	if [ -f prompt_user ]; then $(RM) prompt_user; fi;
	if [ -f SUMA/prompt_user ]; then $(RM) SUMA/prompt_user; fi;
	if [ -f SurfRetinoMap ]; then $(RM) SurfRetinoMap; fi;
	if [ -f SUMA/SurfRetinoMap ]; then $(RM) SUMA/SurfRetinoMap; fi;
	if [ -f ParseName ]; then $(RM) ParseName; fi;
	if [ -f SUMA/ParseName ]; then $(RM) SUMA/ParseName; fi;
	if [ -f 3dGenPriors ]; then $(RM) 3dGenPriors; fi;
	if [ -f SUMA/3dGenPriors ]; then $(RM) SUMA/3dGenPriors; fi;
	if [ -f 3dSeg ]; then $(RM) 3dSeg; fi;
	if [ -f SUMA/3dSeg ]; then $(RM) SUMA/3dSeg; fi;
	if [ -f SurfExtrema ]; then $(RM) SurfExtrema; fi;
	if [ -f SUMA/SurfExtrema ]; then $(RM) SUMA/SurfExtrema; fi;
	if [ -f 3dinfill ]; then $(RM) 3dinfill; fi;
	if [ -f SUMA/3dinfill ]; then $(RM) SUMA/3dinfill; fi;
	if [ -f 3dHist ]; then $(RM) 3dHist; fi;
	if [ -f SUMA/3dHist ]; then $(RM) SUMA/3dHist; fi;
###
#Use precompiled libraries present in SUMA/$(SUMA_BIN_ARCHIVE) and just link SUMA
suma_link:
	( cd SUMA ;	\
	tar -xf $(SUMA_BIN_ARCHIVE)	;\
	touch *.a	;\
	$(CP) libmri.a libtractools.a libmrix.a libcoxplot.a libf2c.a ../	;\
	$(RM) suma MakeColorMap ROI2dataset 3dVol2Surf 3dSurf2Vol \
   SurfMeasures  SurfFWHM \
   ScaleToMap MapIcosahedron \
   CreateIcosahedron CompareSurfaces ConvertSurface ConvertDset SurfClust \
   IsoSurface ConvexHull SurfaceMetrics SurfSmooth inspec \
   quickspec FSread_annot SurfPatch SurfQual SampBias 3dSkullStrip \
   3dCRUISEtoAFNI 3dBRAIN_VOYAGERtoAFNI 3dSurfMask\
   SurfToSurf Surf2VolCoord ROIgrow SurfDsetInfo SurfInfo AnalyzeTrace \
   DriveSuma SurfDist SpharmReco SpharmDeco prompt_user SurfRetinoMap \
   ParseName 3dGenPriors 3dSeg SurfExtrema 3dinfill 3dHist; \
	$(MAKE) -f $(SUMA_MAKEFILE_NAME) testGL suma MakeColorMap ROI2dataset \
   3dVol2Surf 3dSurf2Vol ScaleToMap SurfMeasures SurfFWHM \
	MapIcosahedron CreateIcosahedron CompareSurfaces ConvertSurface ConvertDset \
	SurfClust IsoSurface ConvexHull SurfaceMetrics SurfSmooth inspec \
   quickspec FSread_annot SurfPatch SurfQual SampBias 3dSkullStrip \
   3dCRUISEtoAFNI 3dBRAIN_VOYAGERtoAFNI 3dSurfMask \
	SurfToSurf Surf2VolCoord ROIgrow SurfDsetInfo SurfInfo AnalyzeTrace \
   DriveSuma SurfDist SpharmReco SpharmDeco prompt_user SurfRetinoMap \
   ParseName 3dGenPriors 3dSeg SurfExtrema 3dinfill 3dHist \
	'INSTALLDIR=$(INSTALLDIR)' \
	'SUMA_INCLUDE_PATH=$(SUMA_INCLUDE_PATH)' \
	'SUMA_LINK_PATH=$(SUMA_LINK_PATH)' \
	'SUMA_LINK_LIB=$(SUMA_LINK_LIB)' \
	'SUMA_BIN_ARCHIVE=$(SUMA_BIN_ARCHIVE)' \
	'SUMA_GLIB_VER=$(SUMA_GLIB_VER)' \
	'RANLIB=$(RANLIB)' \
        'MAKE=$(MAKE)'     \
	'CC=$(CC)' 'RM=$(RM)' 'CEXTRA=$(CEXTRA)' 'MV=$(MV)' 'CP=$(CP)'\
	'TAR=$(TAR)' 'MKDIR=$(MKDIR)';	\
	cd ../	;)
###
#install suma
suma_install:
	( if [ ! -d $(INSTALLDIR) ]; then $(MKDIR) -p $(INSTALLDIR); echo WARNING: directory $(INSTALLDIR) has been created. ; fi	;\
	$(CP) SUMA/suma SUMA/MakeColorMap SUMA/ROI2dataset SUMA/3dVol2Surf \
	SUMA/3dSurf2Vol SUMA/SurfMeasures SUMA/SurfFWHM \
	SUMA/ScaleToMap SUMA/MapIcosahedron SUMA/CreateIcosahedron \
	SUMA/CompareSurfaces \
	SUMA/ConvertSurface SUMA/ConvertDset SUMA/SurfClust SUMA/IsoSurface \
	SUMA/ConvexHull SUMA/SUMA_glxdino SUMA/SUMA_pixmap2eps SUMA/SurfaceMetrics \
   SUMA/inspec SUMA/quickspec SUMA/FSread_annot SUMA/SurfPatch SUMA/SurfQual \
	SUMA/SurfSmooth SUMA/SUMA_paperplane \
   SUMA/SampBias SUMA/3dSkullStrip SUMA/3dCRUISEtoAFNI \
   SUMA/3dBRAIN_VOYAGERtoAFNI SUMA/3dSurfMask \
   SUMA/SurfToSurf  SUMA/Surf2VolCoord  SUMA/ROIgrow SUMA/SurfDsetInfo \
   SUMA/SurfInfo SUMA/AnalyzeTrace SUMA/DriveSuma SUMA/SurfDist \
   SUMA/SpharmReco SUMA/SpharmDeco SUMA/prompt_user SUMA/SurfRetinoMap \
   SUMA/ParseName SUMA/3dGenPriors SUMA/3dSeg SUMA/SurfExtrema SUMA/3dinfill \
   SUMA/3dHist \
   ${INSTALLDIR} ; \
	if [ -f SUMA/SurfMesh ]; then $(CP) SUMA/SurfMesh ${INSTALLDIR} ; fi; \
	$(CP) @SUMA_* ${INSTALLDIR} ;)
	
suma: suma_clean suma_exec suma_install
suma_gts: suma_clean suma_exec suma_gts_progs suma_install
suma_fromobjs: suma_link suma_install

###
#R toys
#For compiling R programs, you'll need to do the following:
# run tcsh ./@RmakeOpts and see that it creates Makefile.R.INCLUDE
# add to the end of your Makefile line:
#     include Makefile.R.INCLUDE
# and then:            make 3dTsmoothR && mv 3dTsmoothR YOUR_ABIN/
#
AFNI_embeddedRCall.o: AFNI_embeddedRCall.c
	$(RM)  AFNI_embeddedRCall.o
	$(CC) $(RccCOMopt) -c AFNI_embeddedRCall.c $(INFLAGS)
3dTsmoothR: 3dTsmoothR.c AFNI_embeddedRCall.o
	$(RM) 3dTsmoothR.o 3dTsmoothR
	$(CC) $(RccCOMopt) -c 3dTsmoothR.c $(INFLAGS)
	$(CC) -o 3dTsmoothR 3dTsmoothR.o $(LFLAGS) \
         $(LLIBS) $(RccCOMlfl) AFNI_embeddedRCall.o
toyR: toyR.c AFNI_embeddedRCall.o
	$(RM) toyR.o toyR
	$(CC) $(RccCOMopt) -c toyR.c $(INFLAGS)
	$(CC) -o toyR toyR.o $(LFLAGS) \
         $(LLIBS) $(RccCOMlfl) AFNI_embeddedRCall.o
####
R_io.so:R_io.c libmri.a
	( if which R >/dev/null ; then \
	echo PKG_CPPFLAGS = $(INFLAGS)  > Makevars ;\
	echo PKG_LIBS =  $(LFLAGS) $(LLIBS) >> Makevars ;\
	R CMD SHLIB R_io.c ; \
	else echo WARNING: Cannot build R_io.so because R is not installed;\
	fi ; )
Step 4: Compiling AFNI
cd /nfsscratch/PREDICT/hjohnson/20121121_src/afni_src
make totality suma

mv -f ../afni/linux_gcc44_64/afni/* ../afni/linux_gcc44_64/abin  # TODO: verify paths once build succedes

 

Running