1
2# This Makefile is for Mac OS 11 for 64 bit AFNI, with local linking
3# the default gcc with
4# Xcode (Apple clang v.12 )
5# The required libraries for use should come with Xcode, XQuartz
6# and homebrew
7
8# ******* IMPORTANT - Please READ ********
9# ***** SET PATH to point to /opt/homebrew/bin before /usr/local/bin
10#
11#  1. to get right version of brew for ARM (see below)
12#  2. to get right version of autoconf for ARM to build libgts.a
13#     in SUMA Makefile
14#
15# two versions of homebrew are provided with an installation on an M1 ARM
16# system. The ARM version is installed in /opt/homebrew/bin/brew
17# and the Intel version is installed in /usr/local/bin/brew
18# Either call the path to these explicitly or change the path to get
19# the one you want.
20# the Intel version must be run from a Rosetta terminal
21# tested with clang is 12.0.0
22# use homebrew to install the following:
23#
24#  brew install
25#    libpng jpeg expat freetype fontconfig openmotif libomp
26#    libxt gsl glib pkg-config gcc (version 10 used here by default)
27#    autoconf
28
29# also brew install netpbm libiconv
30
31
32# brew install gsl
33# put this symbolic link for needed library
34#ln -s /usr/local/Cellar/gsl/2.6/lib/libgsl.25.dylib /usr/local/lib/libgsl.dylib
35#ln -s /usr/local/Cellar/openmotif/2.3.8_1/lib/libXm.4.dylib /usr/local/lib/libXm.4.dylib
36# if XQuartz doesn't include libXm (as it used to), then use this
37#ln -s /usr/local/Cellar/openmotif/2.3.8_1/lib/libXm.a /usr/local/lib/libXm.a
38#ln -s /usr/local/Cellar/jpeg/9d/lib/libjpeg.a /usr/local/lib/libjpeg.a
39#ln -s /usr/local/Cellar/jpeg/9d/lib/libjpeg.a /usr/local/lib/libjpeg.9.a
40#ln -s /usr/local/Cellar/netpbm/10.86.18/include/netpbm/pgm.h /usr/local/include/pgm.h
41# ***** for MAC ARM-M1 and 10.15 clang x86_64 builds    09 Mar 2021 [drg]
42#   once again have confusing problem with pgm.h missing from standard
43#   kinds of places, so libgts has errors
44#   solve with symbolic link to Cellar versions in homebrew
45#   ARM_M1 version
46#   sudo ln -s /opt/homebrew/Cellar/netpbm/10.86.18/include/netpbm/pgm.h  \
47#     /opt/homebrew/include/pgm.h
48#   x86_64 version as above
49#   sudo ln -s /usr/local/Cellar/netpbm/10.86.18/include/netpbm/pgm.h     \
50#     /usr/local/homebrew/include/pgm.h
51
52# I've removed libbz2.dylib from the installed dylib list because it doesn't
53# seem to be used below, but on 10.15 with brew install
54# there is /usr/lib/libbz2.1.0.dylib
55
56# DRG: M1 homebrew location
57usr_ROOT   = /opt/homebrew
58USE_ZLIB  = -DHAVE_ZLIB
59LZLIB     = -lz
60USE_GIFTI = -DHAVE_GIFTI
61LGIFTI    = -lexpat
62
63# ------------------------------
64# python from C
65#IPYTHON     = -I/Users/molfesepj/anaconda3/include/python3.8 -DSELENIUM_READY
66#LPYTHON     = -L/Users/molfesepj/anaconda3/lib/python3.8/config
67#LDPYTHON    = -lpython3.8
68
69# ----------------------------------------------------------------------
70# X configuration
71#
72
73XROOT   = /opt/X11
74XROOT_I = -I$(XROOT)/include
75XROOT_L = -L$(XROOT)/lib
76
77XLIBS = -lXm -ljpeg.9 -lXt
78
79# ----------------------------------------------------------------------
80
81
82CCDEBS = -DAFNI_DEBUG -DIMSEQ_DEBUG -DDISPLAY_DEBUG -DTHD_DEBUG
83CEXTRA = -m64 -Wall -Wno-deprecated-declarations -Wcomment -Wformat -DUSE_TRACING -DHAVE_XDBE \
84	 -DDONT_USE_MCW_MALLOC $(LESSTIF_DEFS)
85# choose gcc version below from homebrew directory in
86# either /opt/homebrew/bin
87# or Apple clang from /usr/bin with
88# architecture set for x86_64 or arm64
89# set CC and CCMIN to appropriate directory
90#CC     = /opt/homebrew/bin/gcc-10 -O2  -DDARWIN $(CEXTRA)
91# MacOS default is clang
92CC     = /usr/bin/gcc -O2 -arch arm64 -DDARWIN -DARM_M1 $(CEXTRA)
93CCVOL  = $(CC)
94CCFAST = $(CC)
95#CCMIN  = /opt/homebrew/bin/gcc-10 -arch arm64
96CCMIN  = /usr/bin/gcc -arch arm64 -DDARWIN -DARM_M1
97CCD    = $(CC) $(CCDEBS)
98CCOLD  = $(CC)
99
100# set CPU_TYPE for libgts.a building and anything else that might need it
101CPU_TYPE = ARM_M1
102
103# previous mac versions for brew put omp in a separate directory
104# here it's just homebrew's standard install directories for the ARM
105BREWI =  /opt/homebrew/include
106BREWL =  /opt/homebrew/lib
107
108OMPFLAG = -Xpreprocessor -fopenmp -lomp -I$(BREWI) -L$(BREWL) -DUSE_OMP
109
110SYSTEM_NAME = macos_11.3_ARM_M1_clang
111
112INSTALLDIR = $(SYSTEM_NAME)
113
114# these are homebrew's install library and include files
115# repeats definitions BREWI and BREWL above but
116# separating for now in case OMP goes back to a separate directory
117BREWLIBDIR = /opt/homebrew/lib
118BREWINCDIR = /opt/homebrew/include
119
120EXTRA_INSTALL_FILES = $(BREWLIBDIR)/libXm.4.dylib			  \
121		      $(BREWLIBDIR)/libjpeg.9.dylib			          \
122		      $(BREWLIBDIR)/libgsl.dylib                      \
123		      $(BREWLIBDIR)/libglib-2.0.0.dylib		          \
124		      $(BREWLIBDIR)/libgslcblas.0.dylib		          \
125		      $(BREWLIBDIR)/libpng16.16.dylib			      \
126		      $(BREWLIBDIR)/libintl.8.dylib                   \
127              /opt/homebrew/opt/libiconv/lib/libiconv.2.dylib
128
129# this is called a hack - command to convert dyname -lXm to static for R_io.so
130#RLIB_CONVERT = | sed 's/-lXm/\/usr\/lib\/libXm.a/'
131#RLIB_CONVERT = | sed 's/-lXm/\/usr\/local\/lib\/libXm.a/'
132RLIB_CONVERT = | sed 's/-lXm/\/opt\/Homebrew\/lib\/libXm.a/'
133
134# these were the PJM's library files to copy to binary distribution directory
135# The list above includes different versions to copy
136#
137#              /usr/local/lib/libfreetype.6.dylib       \
138#		      /usr/local/lib/gcc/8/lib/libgomp.1.dylib		  \
139#		      /usr/local/lib/gcc/8/lib/libgcc_s.1.dylib		  \
140#		      /usr/local/lib/libgsl.0.dylib			  \
141#		      /usr/local/lib/libiconv.2.dylib			  \
142#		      /usr/local/lib/freetype219/lib/libfreetype.6.dylib \
143#  	      /Users/molfesepj/anaconda3/lib/python3.8/config-3.8-darwin/libpython3.8.a \
144#		      /usr/local/lib/libbz2.1.dylib			  \
145#
146
147EXTRA_INSTALL_COMMANDS = ( cd $(INSTALLDIR) ;                                 \
148                           chmod u+w *.dylib ;                                \
149                           if [ -d $(HOME)/EXTRAPROGS ]; then $(CP) $(HOME)/EXTRAPROGS/* . ; fi ; )
150
151IFLAGS = -I. $(XROOT_I) -I$(BREWINCDIR) -I/usr/include
152
153LFLAGS = -L. -L$(BREWLIBDIR) $(XROOT_L) -L/usr/lib -Wl,-x -Wl,-multiply_defined -Wl,warning -Wl,-bind_at_load $(LPYTHON)
154
155CCSVD  = $(CCMIN) -m64 -O0
156
157PLUGIN_SUFFIX = so
158PLUGIN_LFLAGS = -m64 -bundle -flat_namespace -undefined suppress -Wl,-x
159PLUGIN_CC     = $(CC) -dynamic -fno-common
160PLFLAGS       = -m64 -dynamic $(LFLAGS)
161
162# include the line below if you want to include vector arith in 3dDeconvolve_f
163# SPECIAL = -framework Accelerate -DUSE_ACCELERATE
164
165AR     = /usr/bin/ar
166RANLIB = /usr/bin/ranlib
167TAR    = /usr/bin/tar
168MKDIR  = /bin/mkdir
169GZIP   = /usr/bin/gzip
170LD     = $(CCMIN)
171
172RM = /bin/rm -f
173MV = /bin/mv -f
174CP = /bin/cp -f
175
176LINT = /usr/bin/lint -a -b -u -v -x $(IFLAGS) $(CCDEFS)
177
178LIBDIR = $(INSTALLDIR)
179SHOWOFF = -DSHOWOFF=$(SYSTEM_NAME)
180
181INSTALL_PREREQ = suma_gts
182# uncomment if the Gnu Scientific Library is installed (libgsl, libgslcblas)
183# GSLPROGS = balloon
184EXPROGS = $(GSLPROGS)
185
186# for dynamic linking
187
188LLIBS  = -lmri -lf2c $(XLIBS) -lXft -lfontconfig \
189         -lpng16 -liconv -lXmu -lXp -lXpm -lXext -lX11      \
190         $(LZLIB) $(LGIFTI) $(LDPYTHON) -lm -lc
191
192
193# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
194# For suma
195# ZSS Aug. 08. LibGLw.a now made locally and called libGLws.a
196
197SUMA_GL_DYLIB_CMD = -lGL
198
199GLw_IPATH  =
200GLw_LIB = -lGLw
201# uncomment next two lines if you want to use libGLws.a, SUMA's copy of GLw
202GLw_IPATH  = -IGLw_local
203GLw_LIB = libGLws.a
204
205
206SUMA_GLIB_VER = -2.0
207SUMA_INCLUDE_PATH = $(GLw_IPATH) -I.. -I../niml $(IFLAGS) -Igts/src  -I${usr_ROOT}/include/glib-2.0  -I${usr_ROOT}/lib/glib-2.0/include
208#SUMA_LINK_PATH = $(XROOT_L) $(LFLAGS) -L..
209SUMA_LINK_PATH = $(XROOT_L) $(LFLAGS) -L..
210
211SUMA_LINK_LIB = $(XLIBS) $(GLw_LIB) $(LLIBS) -lGLU -lGL -lmri -lf2c -lmx -L${usr_ROOT}/lib/ -lglib-2.0 $(SUMA_GL_DYLIB_CMD)
212SUMA_MAKEFILE_NAME = SUMA_Makefile
213SUMA_BIN_ARCHIVE = SUMA_MacOSX.tar
214SUMA_MDEFS = -DSUMA_GL_NO_CHECK_FRAME_BUFFER
215# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
216
217
218###############################################################
219
220MAKE = make
221include Makefile.INCLUDE
222