aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flprefix.h
blob: 390f51ab2ef1e3600ef84759a14357ca7a288de9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/* 

flext - C++ layer for Max/MSP and pd (pure data) externals

Copyright (c) 2001-2003 Thomas Grill (xovo@gmx.net)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.  

*/

/*! \file flprefix.h
    \brief Try to find out the platform.
*/
 
#ifndef __FLEXT_PREFIX_H
#define __FLEXT_PREFIX_H

// --- definitions for FLEXT_SYS ---------------------
#define FLEXT_SYS_UNKNOWN	0

#ifndef FLEXT_SYS_MAX
	#define FLEXT_SYS_MAX	1
#else
	// already defined
	#undef FLEXT_SYS_MAX
	#define FLEXT_SYS_MAX	1
	#define FLEXT_SYS FLEXT_SYS_MAX
#endif

#ifndef FLEXT_SYS_PD
	#define FLEXT_SYS_PD	2
#else
	// already defined
	#undef FLEXT_SYS_PD
	#define FLEXT_SYS_PD	2
	#define FLEXT_SYS FLEXT_SYS_PD
#endif

#ifndef FLEXT_SYS_JMAX
	#define FLEXT_SYS_JMAX	3
#else
	// already defined
	#undef FLEXT_SYS_JMAX
	#define FLEXT_SYS_JMAX	3
	#define FLEXT_SYS FLEXT_SYS_JMAX
#endif

// --- definitions for FLEXT_OS ----------------------
#define FLEXT_OS_UNKNOWN	0
#define FLEXT_OS_WIN	1
#define FLEXT_OS_MAC	2  
#define FLEXT_OS_LINUX	3
#define FLEXT_OS_IRIX	4

// --- definitions for FLEXT_OS_API ---------------------
#define FLEXT_OSAPI_UNKNOWN	0
#define FLEXT_OSAPI_MAC_CLASSIC 1
#define FLEXT_OSAPI_MAC_CARBON 2
#define FLEXT_OSAPI_MAC_OSX 3

// --- definitions for FLEXT_CPU ---------------------
#define FLEXT_CPU_UNKNOWN	0
#define FLEXT_CPU_INTEL 1
#define FLEXT_CPU_PPC 	2
#define FLEXT_CPU_MIPS	3
#define FLEXT_CPU_ALPHA	4

// --- definitions for FLEXT_THREADS -----------------
#define FLEXT_THR_POSIX 1 // pthreads
#define FLEXT_THR_WIN32	2 // Win32 native
#define FLEXT_THR_MP	3 // MacOS MPThreads

// ---------------------------------------------------
// support old definitions

#ifndef FLEXT_SYS
	#if defined(MAXMSP)
		#define FLEXT_SYS FLEXT_SYS_MAX
	//	#undef MAXMSP
	#elif defined(PD)
		#define FLEXT_SYS FLEXT_SYS_PD
	//	#undef PD
	//	#undef NT
	#endif
#endif

#if defined(_DEBUG) && !defined(FLEXT_DEBUG)
	#define FLEXT_DEBUG
#endif

// ---------------------------------------------------

// Definition of supported real-time systems
#if FLEXT_SYS == FLEXT_SYS_MAX
#elif FLEXT_SYS == FLEXT_SYS_PD
#elif FLEXT_SYS == FLEXT_SYS_JMAX
#else
	#error "System must be defined by either FLEXT_SYS_MAX, FLEXT_SYS_PD or FLEXT_SYS_JMAX"
#endif

// Definition of OS/CPU
#if defined(_MSC_VER) || (defined(__ICC) && (FLEXT_OS == FLEXT_OS_WIN || defined(_WIN32)))
	// Microsoft C++
    // and Intel C++ (as guessed)
	
	#ifndef FLEXT_CPU
		#if defined(_M_IX86)
			#define FLEXT_CPU FLEXT_CPU_INTEL
		#elif defined(_M_PPC)
			#define FLEXT_CPU FLEXT_CPU_PPC
		#elif defined(_M_MRX000)
			#define FLEXT_CPU FLEXT_CPU_MIPS
		#elif defined(_M_ALPHA)
			#define FLEXT_CPU FLEXT_CPU_ALPHA
		#else
			#define FLEXT_CPU FLEXT_CPU_UNKNOWN
		#endif
	#endif

	#ifndef FLEXT_OS
		#if defined(_WIN32)
			#define FLEXT_OS FLEXT_OS_WIN
		#else
			#define FLEXT_OS FLEXT_OS_UNKNOWN
		#endif
	#endif

	#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN

#elif defined(__BORLANDC__) 
	// Borland C++

	#ifndef FLEXT_CPU
		#define FLEXT_CPU FLEXT_CPU_INTEL
	#endif
	#ifndef FLEXT_OS
		#define FLEXT_OS FLEXT_OS_WIN
	#endif

	#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN

#elif defined(__MWERKS__)
	// Metrowerks CodeWarrior

	#ifdef __MACH__
		// quick fix for OSX Mach-O
		#define TARGET_CPU_PPC 1
		#define TARGET_OS_MAC 1
		#define TARGET_API_MAC_OSX 1
	#else
		#ifndef __CONDITIONALMACROS__
		#include <ConditionalMacros.h>
		#endif
	#endif

	#ifndef FLEXT_CPU
		#if TARGET_CPU_X86
			#define FLEXT_CPU FLEXT_CPU_INTEL
		#elif TARGET_CPU_PPC
			#define FLEXT_CPU FLEXT_CPU_PPC
		#elif TARGET_CPU_MIPS
			#define FLEXT_CPU FLEXT_CPU_MIPS
		#elif TARGET_CPU_ALPHA
			#define FLEXT_CPU FLEXT_CPU_ALPHA
		#else
			#define FLEXT_CPU FLEXT_CPU_UNKNOWN
		#endif
	#endif

	#ifndef FLEXT_OS
		#if TARGET_OS_MAC
			#define FLEXT_OS FLEXT_OS_MAC
		#elif TARGET_OS_WIN32
			// assume Windows
			#define FLEXT_OS FLEXT_OS_WIN
		#else
			#define FLEXT_OS FLEXT_OS_UNKNOWN
		#endif
	#endif
	
	#ifndef FLEXT_OSAPI
		#if TARGET_API_MAC_OSX
			// this has the precedence (OSX can also be Carbon, of course)
			#define FLEXT_OSAPI FLEXT_OSAPI_MAC_OSX
		#elif TARGET_API_MAC_CARBON
			#define FLEXT_OSAPI FLEXT_OSAPI_MAC_CARBON
		#else
			#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
		#endif
	#endif
	
	// This is important for method and attribute callbacks
	#pragma enumsalwaysint on
	// This is important for everything
	#pragma bool on

#elif defined(__GNUG__) || (defined(__ICC) && (FLEXT_OS == FLEXT_OS_LINUX || defined(linux) || defined(__linux__)))

	// GNU C++
    // and Intel (as suggested by Tim Blechmann)

	#ifndef FLEXT_CPU
		#if defined(_X86_) || defined(__i386__) || defined(__i586__) || defined(__i686__)
			#define FLEXT_CPU FLEXT_CPU_INTEL
		#elif defined(__POWERPC__)
			#define FLEXT_CPU FLEXT_CPU_PPC
		#elif defined(__MIPS__)
			#define FLEXT_CPU FLEXT_CPU_MIPS
		#else
			#define FLEXT_CPU FLEXT_CPU_UNKNOWN
		#endif
	#endif

	#ifndef FLEXT_OS
		#if defined(linux) || defined(__linux__)
			#define FLEXT_OS FLEXT_OS_LINUX
		#elif defined(__CYGWIN__) || defined(__CYGWIN32__)
			#define FLEXT_OS FLEXT_OS_WIN
		#elif defined(__APPLE__) && defined(__MACH__)
			#define FLEXT_OS FLEXT_OS_MAC
		// how about IRIX??
		#else
			#define FLEXT_OS FLEXT_OS_UNKNOWN
		#endif
	#endif

	#if FLEXT_OS == FLEXT_OS_MAC
		#define FLEXT_OSAPI FLEXT_OSAPI_MAC_OSX
	#else
		#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
	#endif

#elif defined(__MRC__) && defined(MPW_CPLUS)
	// Apple MPW MrCpp
	#if __MRC__ < 0x500
		#error Apple MPW MrCpp v.5.0.0 or better compiler required
	#endif

	#ifndef FLEXT_CPU
		#if defined(__POWERPC__)
			#define FLEXT_CPU FLEXT_CPU_PPC
		#else
			#define FLEXT_CPU FLEXT_CPU_UNKNOWN
		#endif
	#endif

	#ifndef FLEXT_OS
		#if defined(macintosh)
			#define FLEXT_OS FLEXT_OS_MAC
		#else
			#define FLEXT_OS FLEXT_OS_UNKNOWN
		#endif
	#endif

	#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN

#endif

#if FLEXT_OS == FLEXT_OS_WIN
//	#pragma message("Compiling for Windows")

	#if FLEXT_SYS == FLEXT_SYS_MAX
//		#define WIN_VERSION 1
	#elif FLEXT_SYS == FLEXT_SYS_PD
//		#define PD
//		#define NT
	#endif
#elif FLEXT_OS == FLEXT_OS_LINUX
//	#pragma message("Compiling for Linux")

	#if FLEXT_SYS == FLEXT_SYS_PD
//		#define PD
	#else
		#error "Flext SYS/OS combination unknown"
	#endif
#elif FLEXT_OS == FLEXT_OS_IRIX
//	#pragma message("Compiling for Irix")

	#if FLEXT_SYS == FLEXT_SYS_PD
//		#define PD
	#else
		#error "Flext SYS/OS combination unknown"
	#endif
#elif FLEXT_OS == FLEXT_OS_MAC
//	#pragma message("Compiling for MacOS")

	#if FLEXT_SYS == FLEXT_SYS_PD
//		#define PD
	#endif
#else
	#error "Operating system could not be determined"
#endif

#if FLEXT_SYS == FLEXT_SYS_MAX
//	#pragma message("Compiling for Max/MSP")
#elif FLEXT_SYS == FLEXT_SYS_PD
//	#pragma message("Compiling for PD")
#endif

// ----- set threading model -----
// shared builds are always threaded (although this not be so....)
#ifdef FLEXT_SHARED
	#undef FLEXT_THREADS
	#define	FLEXT_THREADS
#endif

#ifdef FLEXT_THREADS
	#undef FLEXT_THREADS
	#if FLEXT_OS == FLEXT_OS_MAC && FLEXT_SYS == FLEXT_SYS_MAX
		// Max crashes with posix threads (but don't know why...)
		#define FLEXT_THREADS FLEXT_THR_MP		
	#else
		#define FLEXT_THREADS FLEXT_THR_POSIX
	#endif
#endif

// ----- set message queue mode -----
#undef FLEXT_QTHR

#ifdef FLEXT_PDLOCK
	// new PD thread locking functionality shall be used
	#if FLEXT_SYS == FLEXT_SYS_PD
		#ifdef FLEXT_THREADS
			// can only be used with PD and threaded build
			#define FLEXT_QTHR
		#endif
	#else
		#error FLEXT_PDLOCK can only be defined with PD
	#endif
#endif

#endif // __FLEXT_PREFIX_H