1#*************************************************************************
2# Global flags
3#*************************************************************************
4gdb         = yes
5debug       = no
6memdbg      = no
7openmp      = no
8x86compiler = gcc
9
10VERNUM = 0.1.0
11
12
13
14#*************************************************************************
15# System-specific compilation flags
16#*************************************************************************
17# Get some basic information about the system that you are working on
18cputype = $(shell uname -m | sed "s/\\ /_/g")
19systype = $(shell uname)
20ifeq ($(findstring CYGWIN, $(systype)),CYGWIN)
21#  systype = CYGWIN
22  systype = MSWIN
23  cputype = x86
24endif
25
26
27GKLIBINCDIR   = $(HOME)/work/algorithms/GKlib/trunk/
28GKLIBBUILDDIR = $(HOME)/work/algorithms/GKlib/builds/$(systype)-$(cputype)
29
30
31ifeq ($(systype),MSWIN)
32  #-------------------------------------------------------------------
33  # These defs are very much Visual Studio Specific
34  #-------------------------------------------------------------------
35  #Compiler information
36  CC = cl
37  OPTFLAGS = /Ox
38  COPTIONS = -DWIN32 -DMSC -D_CRT_SECURE_NO_DEPRECATE
39
40  #Compile input/output file specification
41  SOURCEFILE = /c $<
42  OUTPUTFILE = /Fo$@
43
44  #Output specification for executables
45  EXEOUTPUTFILE = /Fe$@   # This option is when cl is used for linking
46  #EXEOUTPUTFILE = /OUT:$@  # This option is used when link is used for linking
47
48  #Linker information
49  LDOPTIONS = /MT
50  #LD = /cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ 8/VC/BIN/link
51  LD = cl
52  MERGEMANIFEST =
53
54  #Library creation information
55  AR = lib /OUT:$@
56  RANLIB =
57
58  ifeq ($(openmp),yes)
59    COPTIONS  += -D__OPENMP__ /openmp
60    LDOPTIONS += /openmp
61    MERGEMANIFEST = vc_mt -manifest $@.manifest -outputresource:$@\;1
62  endif
63
64  #Library information
65  ifeq ($(cputype),i386)
66    LIBPLOTDIR = ../Libplot/Win32
67  else
68    LIBPLOTDIR = ../Libplot/Win64
69  endif
70  LIBS = $(LIBPLOTDIR)/libplot.lib  $(BUILDDIR)/libcluto.lib $(GKLIBBUILDDIR)/libGKlib.lib
71
72  # Standard file extensions
73  OBJEXT = .obj
74  LIBEXT = .lib
75  EXEEXT = .exe
76else
77  ifeq ($(systype),Linux)
78    ifeq ($(x86compiler),gcc)
79      #Compiler information
80      CC = gcc
81      OPTFLAGS = -O6
82      COPTIONS = -DLINUX -D_FILE_OFFSET_BITS=64 -pedantic -std=c99  -pthread
83
84      #Linker information
85      LDOPTIONS =
86      LD = gcc
87
88      MERGEMANIFEST =
89
90      #Library creation information
91      AR = ar rv
92      RANLIB = ar -ts
93    else
94      #Compiler information
95      CC = icc
96      OPTFLAGS = -O3
97      COPTIONS = -DLINUX -D_FILE_OFFSET_BITS=64 -std=c99
98
99      #Linker information
100      LDOPTIONS =
101      LD = icc
102
103      #Library creation information
104      AR = ar rv
105      RANLIB = ar -ts
106
107      ifeq ($(openmp),yes)
108        COPTIONS  += -D__OPENMP__ -openmp -openmp-report2
109        LDOPTIONS += -openmp
110      endif
111    endif
112
113    #Library information
114    ifeq ($(cputype),x86_64)
115      LIBPLOTDIR = ../Libplot/Linux64
116    else
117      LIBPLOTDIR = ../Libplot/Linux32
118    endif
119  endif
120
121
122  ifeq ($(systype),SunOS)
123    #Compiler information
124    CC = /opt/SUNWspro/bin/cc
125    OPTFLAGS = -xO4
126    COPTIONS =-DSUNOS
127
128    #Linker information
129    LDOPTIONS =
130    LD = /opt/SUNWspro/bin/cc
131
132
133    #Library creation information
134    AR = ar rv
135    RANLIB = ar -ts
136
137    #Library information
138    LIBPLOTDIR = ../Libplot/SunOS
139  endif
140
141
142  ifeq ($(systype),Darwin)
143    #Compiler information
144    CC = gcc
145    OPTFLAGS = -O6
146    COPTIONS = -DDARWIN -D_FILE_OFFSET_BITS=64 -pedantic -std=c99
147
148    #Linker information
149    LDOPTIONS = -fvisibility=default
150    LD = gcc
151
152    #Library creation information
153    AR = ar rv
154    RANLIB = ar -ts
155
156    #Library information
157    ifeq ($(cputype),i386)
158      LIBPLOTDIR = ../Libplot/Darwini386
159    else
160      LIBPLOTDIR = ../Libplot/DarwinPPC
161    endif
162  endif
163
164  ifeq ($(systype),CYGWIN)
165    #Compiler information
166    CC = gcc
167    OPTFLAGS = -O6
168    COPTIONS = -DCYGWIN -DWIN32 -D_FILE_OFFSET_BITS=64 -Wall -std=c99 -pedantic -mno-cygwin
169
170    #Linker information
171    LDOPTIONS = -mno-cygwin
172    LD = gcc
173
174    #Library creation information
175    AR = ar crv
176    RANLIB = ar -ts
177
178    #Library information
179    LIBPLOTDIR = ../Libplot/CYGWIN
180  endif
181
182
183  #-------------------------------------------------------------------
184  # These defs are common among the GNU/GCC based systems
185  #-------------------------------------------------------------------
186  #Compile input/output file specification
187  SOURCEFILE = -c $<
188  OUTPUTFILE = -o $@
189
190  #Output specification for executables
191  EXEOUTPUTFILE = -o $@
192
193  #Library creation information
194  AR = ar crv $@
195  RANLIB = ar -ts $@
196
197  #Libraries needed for linking
198  LIBSDIR  = -L$(BUILDDIR) -L$(GKLIBBUILDDIR) -L$(HOME)/local/lib
199  LIBS     = -lGKlib -lpcreposix -lpcre -lz -lm
200
201  # Standard file extensions
202  OBJEXT = .o
203  LIBEXT = .a
204  EXEEXT =
205endif
206
207
208#**************************************************************************
209DMALLOCINC =
210DMALLOCFLAGS =
211DEBUGFLAGS =
212
213ifeq ($(dmalloc),yes)
214  DMALLOCINC = -I$(HOME)/local/include
215  DMALLOCFLAGS = -DDMALLOC
216  OPTFLAGS = -g
217endif
218
219ifeq ($(debug),yes)
220  DEBUGFLAGS = -DDEBUG
221  OPTFLAGS = -g
222endif
223
224ifeq ($(gdb),yes)
225  OPTFLAGS += -g
226endif
227#**************************************************************************
228
229
230#**************************************************************************
231# Create the build directory if it does not exist
232#**************************************************************************
233ifeq ($(systype),Darwin)
234  BINDIR    = $(HOME)
235else
236  BINDIR    = $(HOME)/work/bin/$(systype)-$(cputype)
237  $(shell mkdir -p $(BINDIR))
238endif
239
240ifeq ($(openmp),no)
241  BUILDDIR    = ./builds/$(systype)-$(cputype)
242else
243  BUILDDIR    = ./builds/$(systype)-$(cputype)-openmp
244endif
245
246LIBBUILDDIR = $(BUILDDIR)/lib
247PRGBUILDDIR = $(BUILDDIR)/prg
248$(shell mkdir -p $(BUILDDIR))
249$(shell mkdir -p $(LIBBUILDDIR))
250$(shell mkdir -p $(PRGBUILDDIR))
251
252
253
254
255INCLUDES = -I./ -I$(GKLIBINCDIR) -I$(LIBPLOTDIR) -I$(HOME)/local/include
256CFLAGS   = $(COPTIONS) $(OPTFLAGS) $(DEBUGFLAGS) $(INCLUDES)
257
258
259