src/osd/sdl/drawogl.c
| r4431 | r4432 | |
| 22 | 22 | #include "render.h" |
| 23 | 23 | #include "options.h" |
| 24 | 24 | #include "driver.h" |
| 25 | #include "rendutil.h" |
| 25 | 26 | |
| 26 | 27 | // standard SDL headers |
| 27 | 28 | #include <SDL/SDL.h> |
| r4431 | r4432 | |
| 128 | 129 | //============================================================ |
| 129 | 130 | |
| 130 | 131 | #define DEBUG_MODE_SCORES 0 |
| 132 | #define USE_WIN32_STYLE_LINES 0 // use the same method baseline does - yields somewhat nicer vectors but a little buggy |
| 131 | 133 | |
| 132 | 134 | //============================================================ |
| 133 | 135 | // CONSTANTS |
| r4431 | r4432 | |
| 258 | 260 | GLfloat texVerticex[8]; |
| 259 | 261 | }; |
| 260 | 262 | |
| 263 | /* line_aa_step is used for drawing antialiased lines */ |
| 264 | typedef struct _line_aa_step line_aa_step; |
| 265 | struct _line_aa_step |
| 266 | { |
| 267 | float xoffs, yoffs; // X/Y deltas |
| 268 | float weight; // weight contribution |
| 269 | }; |
| 261 | 270 | |
| 271 | static const line_aa_step line_aa_1step[] = |
| 272 | { |
| 273 | { 0.00f, 0.00f, 1.00f }, |
| 274 | { 0 } |
| 275 | }; |
| 276 | |
| 277 | static const line_aa_step line_aa_4step[] = |
| 278 | { |
| 279 | { -0.25f, 0.00f, 0.25f }, |
| 280 | { 0.25f, 0.00f, 0.25f }, |
| 281 | { 0.00f, -0.25f, 0.25f }, |
| 282 | { 0.00f, 0.25f, 0.25f }, |
| 283 | { 0 } |
| 284 | }; |
| 285 | |
| 262 | 286 | //============================================================ |
| 263 | 287 | // INLINES |
| 264 | 288 | //============================================================ |
| r4431 | r4432 | |
| 1151 | 1175 | render_primitive *prim; |
| 1152 | 1176 | texture_info *texture=NULL; |
| 1153 | 1177 | float vofs, hofs; |
| 1154 | | int pendingPrimitive=GL_NO_PRIMITIVE, curPrimitive=GL_NO_PRIMITIVE; |
| 1178 | int pendingPrimitive=GL_NO_PRIMITIVE, curPrimitive=GL_NO_PRIMITIVE, scrnum, is_vector; |
| 1179 | const device_config *screen; |
| 1180 | const screen_config *scrconfig; |
| 1155 | 1181 | |
| 1156 | 1182 | if (video_config.novideo) |
| 1157 | 1183 | { |
| r4431 | r4432 | |
| 1171 | 1197 | glDepthFunc(GL_LEQUAL); |
| 1172 | 1198 | glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); |
| 1173 | 1199 | } |
| 1200 | |
| 1201 | // figure out if we're vector |
| 1202 | scrnum = is_vector = 0; |
| 1203 | for (screen = video_screen_first(window->machine->config); screen != NULL; screen = video_screen_next(screen)) |
| 1204 | { |
| 1205 | if (scrnum == window->index) |
| 1206 | { |
| 1207 | scrconfig = screen->inline_config; |
| 1208 | is_vector = (scrconfig->type == SCREEN_TYPE_VECTOR) ? 1 : 0; |
| 1209 | break; |
| 1210 | } |
| 1211 | else |
| 1212 | { |
| 1213 | scrnum++; |
| 1214 | } |
| 1215 | } |
| 1216 | |
| 1174 | 1217 | // only clear if the geometry changes (and for 2 frames afterward to clear double and triple buffers) |
| 1175 | | if ((sdl->blittimer > 0) || (video_config.isvector)) |
| 1218 | if ((sdl->blittimer > 0) || (is_vector)) |
| 1176 | 1219 | { |
| 1177 | 1220 | glClear(GL_COLOR_BUFFER_BIT); |
| 1178 | 1221 | sdl->blittimer--; |
| r4431 | r4432 | |
| 1289 | 1332 | * since entering and leaving one is most expensive.. |
| 1290 | 1333 | */ |
| 1291 | 1334 | case RENDER_PRIMITIVE_LINE: |
| 1335 | #if !USE_WIN32_STYLE_LINES |
| 1292 | 1336 | // check if it's really a point |
| 1293 | 1337 | if (((prim->bounds.x1 - prim->bounds.x0) == 0) && ((prim->bounds.y1 - prim->bounds.y0) == 0)) |
| 1294 | 1338 | { |
| r4431 | r4432 | |
| 1303 | 1347 | pendingPrimitive=GL_NO_PRIMITIVE; |
| 1304 | 1348 | } |
| 1305 | 1349 | |
| 1306 | | if ( pendingPrimitive==GL_NO_PRIMITIVE ) |
| 1307 | | set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags)); |
| 1350 | if ( pendingPrimitive==GL_NO_PRIMITIVE ) |
| 1351 | { |
| 1352 | set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags)); |
| 1353 | } |
| 1308 | 1354 | |
| 1309 | 1355 | glColor4f(prim->color.r, prim->color.g, prim->color.b, prim->color.a); |
| 1310 | 1356 | |
| r4431 | r4432 | |
| 1324 | 1370 | glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs); |
| 1325 | 1371 | glVertex2f(prim->bounds.x1+hofs, prim->bounds.y1+vofs); |
| 1326 | 1372 | } |
| 1373 | #else |
| 1374 | { |
| 1375 | const line_aa_step *step = line_aa_4step; |
| 1376 | render_bounds b0, b1; |
| 1377 | float r, g, b, a; |
| 1378 | float effwidth; |
| 1379 | |
| 1380 | // we're not gonna play fancy here. close anything pending and let's go. |
| 1381 | if (pendingPrimitive!=GL_NO_PRIMITIVE && pendingPrimitive!=curPrimitive) |
| 1382 | { |
| 1383 | glEnd(); |
| 1384 | pendingPrimitive=GL_NO_PRIMITIVE; |
| 1385 | } |
| 1386 | |
| 1387 | set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags)); |
| 1388 | |
| 1389 | // compute the effective width based on the direction of the line |
| 1390 | effwidth = prim->width; |
| 1391 | if (effwidth < 0.5f) |
| 1392 | effwidth = 0.5f; |
| 1393 | |
| 1394 | // determine the bounds of a quad to draw this line |
| 1395 | render_line_to_quad(&prim->bounds, effwidth, &b0, &b1); |
| 1396 | |
| 1397 | // fix window position |
| 1398 | b0.x0 += hofs; |
| 1399 | b0.x1 += hofs; |
| 1400 | b1.x0 += hofs; |
| 1401 | b1.x1 += hofs; |
| 1402 | b0.y0 += vofs; |
| 1403 | b0.y1 += vofs; |
| 1404 | b1.y0 += vofs; |
| 1405 | b1.y1 += vofs; |
| 1406 | |
| 1407 | // iterate over AA steps |
| 1408 | for (step = PRIMFLAG_GET_ANTIALIAS(prim->flags) ? line_aa_4step : line_aa_1step; step->weight != 0; step++) |
| 1409 | { |
| 1410 | glBegin(GL_TRIANGLE_STRIP); |
| 1411 | |
| 1412 | // rotate the unit vector by 135 degrees and add to point 0 |
| 1413 | glVertex2f(b0.x0 + step->xoffs, b0.y0 + step->yoffs); |
| 1414 | |
| 1415 | // rotate the unit vector by -135 degrees and add to point 0 |
| 1416 | glVertex2f(b0.x1 + step->xoffs, b0.y1 + step->yoffs); |
| 1417 | |
| 1418 | // rotate the unit vector by 45 degrees and add to point 1 |
| 1419 | glVertex2f(b1.x0 + step->xoffs, b1.y0 + step->yoffs); |
| 1420 | |
| 1421 | // rotate the unit vector by -45 degrees and add to point 1 |
| 1422 | glVertex2f(b1.x1 + step->xoffs, b1.y1 + step->yoffs); |
| 1423 | |
| 1424 | // determine the color of the line |
| 1425 | r = (prim->color.r * step->weight); |
| 1426 | g = (prim->color.g * step->weight); |
| 1427 | b = (prim->color.b * step->weight); |
| 1428 | a = (prim->color.a * 255.0f); |
| 1429 | if (r > 1.0) r = 1.0; |
| 1430 | if (g > 1.0) g = 1.0; |
| 1431 | if (b > 1.0) b = 1.0; |
| 1432 | if (a > 1.0) a = 1.0; |
| 1433 | glColor4f(r, g, b, a); |
| 1434 | |
| 1435 | // texture = texture_update(window, prim, 0); |
| 1436 | // if (texture) printf("line has texture!\n"); |
| 1437 | |
| 1438 | // if we have a texture to use for the vectors, use it here |
| 1439 | #if 0 |
| 1440 | if (d3d->vector_texture != NULL) |
| 1441 | { |
| 1442 | printf("SDL: textured lines unsupported\n"); |
| 1443 | vertex[0].u0 = d3d->vector_texture->ustart; |
| 1444 | vertex[0].v0 = d3d->vector_texture->vstart; |
| 1445 | |
| 1446 | vertex[2].u0 = d3d->vector_texture->ustop; |
| 1447 | vertex[2].v0 = d3d->vector_texture->vstart; |
| 1448 | |
| 1449 | vertex[1].u0 = d3d->vector_texture->ustart; |
| 1450 | vertex[1].v0 = d3d->vector_texture->vstop; |
| 1451 | |
| 1452 | vertex[3].u0 = d3d->vector_texture->ustop; |
| 1453 | vertex[3].v0 = d3d->vector_texture->vstop; |
| 1454 | } |
| 1455 | #endif |
| 1456 | glEnd(); |
| 1457 | } |
| 1458 | } |
| 1459 | #endif |
| 1327 | 1460 | break; |
| 1328 | 1461 | |
| 1329 | 1462 | case RENDER_PRIMITIVE_QUAD: |
src/osd/sdl/sdldir.c
| r4431 | r4432 | |
| 13 | 13 | #ifdef SDLMAME_LINUX |
| 14 | 14 | #define __USE_LARGEFILE64 |
| 15 | 15 | #endif |
| 16 | | #ifndef SDLMAME_FREEBSD |
| 16 | #ifndef SDLMAME_BSD |
| 17 | 17 | #define _XOPEN_SOURCE 500 |
| 18 | 18 | #endif |
| 19 | 19 | |
| r4431 | r4432 | |
| 43 | 43 | struct _osd_directory |
| 44 | 44 | { |
| 45 | 45 | osd_directory_entry ent; |
| 46 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) |
| 46 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) |
| 47 | 47 | struct dirent *data; |
| 48 | 48 | #else |
| 49 | 49 | struct dirent64 *data; |
| r4431 | r4432 | |
| 52 | 52 | }; |
| 53 | 53 | |
| 54 | 54 | |
| 55 | | #if defined (SDLMAME_LINUX) || defined (SDLMAME_FREEBSD) || defined(SDLMAME_DARWIN) |
| 55 | #if defined (SDLMAME_LINUX) || defined (SDLMAME_BSD) || defined(SDLMAME_DARWIN) |
| 56 | 56 | static osd_dir_entry_type get_attributes_enttype(int attributes) |
| 57 | 57 | { |
| 58 | 58 | if (attributes == DT_DIR) |
| r4431 | r4432 | |
| 85 | 85 | |
| 86 | 86 | static UINT64 osd_get_file_size(const char *file) |
| 87 | 87 | { |
| 88 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) |
| 88 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) |
| 89 | 89 | struct stat st; |
| 90 | 90 | if(stat(file, &st)) |
| 91 | 91 | return 0; |
| r4431 | r4432 | |
| 171 | 171 | |
| 172 | 172 | const osd_directory_entry *osd_readdir(osd_directory *dir) |
| 173 | 173 | { |
| 174 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) |
| 174 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) |
| 175 | 175 | dir->data = readdir(dir->fd); |
| 176 | 176 | #else |
| 177 | 177 | dir->data = readdir64(dir->fd); |
| r4431 | r4432 | |
| 181 | 181 | return NULL; |
| 182 | 182 | |
| 183 | 183 | dir->ent.name = dir->data->d_name; |
| 184 | | #if defined (SDLMAME_LINUX) || defined (SDLMAME_FREEBSD) || defined(SDLMAME_DARWIN) |
| 184 | #if defined (SDLMAME_LINUX) || defined (SDLMAME_BSD) || defined(SDLMAME_DARWIN) |
| 185 | 185 | dir->ent.type = get_attributes_enttype(dir->data->d_type); |
| 186 | 186 | #else |
| 187 | 187 | dir->ent.type = get_attributes_stat(dir->data->d_name); |
src/osd/sdl/sdlfile.c
| r4431 | r4432 | |
| 13 | 13 | #ifdef SDLMAME_LINUX |
| 14 | 14 | #define __USE_LARGEFILE64 |
| 15 | 15 | #endif |
| 16 | | #ifndef SDLMAME_FREEBSD |
| 16 | #ifndef SDLMAME_BSD |
| 17 | 17 | #define _XOPEN_SOURCE 500 |
| 18 | 18 | #endif |
| 19 | 19 | |
| r4431 | r4432 | |
| 96 | 96 | UINT32 access; |
| 97 | 97 | const char *src; |
| 98 | 98 | char *dst; |
| 99 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) |
| 99 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) |
| 100 | 100 | struct stat st; |
| 101 | 101 | #else |
| 102 | 102 | struct stat64 st; |
| r4431 | r4432 | |
| 180 | 180 | #endif |
| 181 | 181 | |
| 182 | 182 | // attempt to open the file |
| 183 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) |
| 183 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) |
| 184 | 184 | (*file)->handle = open(tmpstr, access, 0666); |
| 185 | 185 | #else |
| 186 | 186 | (*file)->handle = open64(tmpstr, access, 0666); |
| r4431 | r4432 | |
| 203 | 203 | // attempt to reopen the file |
| 204 | 204 | if (error == NO_ERROR) |
| 205 | 205 | { |
| 206 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) |
| 206 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) |
| 207 | 207 | (*file)->handle = open(tmpstr, access, 0666); |
| 208 | 208 | #else |
| 209 | 209 | (*file)->handle = open64(tmpstr, access, 0666); |
| r4431 | r4432 | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // get the file size |
| 226 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) |
| 226 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) |
| 227 | 227 | fstat((*file)->handle, &st); |
| 228 | 228 | #else |
| 229 | 229 | fstat64((*file)->handle, &st); |
| r4431 | r4432 | |
| 253 | 253 | { |
| 254 | 254 | ssize_t result; |
| 255 | 255 | |
| 256 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_FREEBSD) |
| 256 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_BSD) |
| 257 | 257 | result = pread(file->handle, buffer, count, offset); |
| 258 | 258 | if (result < 0) |
| 259 | 259 | #elif defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_OS2) |
| r4431 | r4432 | |
| 281 | 281 | { |
| 282 | 282 | UINT32 result; |
| 283 | 283 | |
| 284 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_FREEBSD) |
| 284 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_BSD) |
| 285 | 285 | result = pwrite(file->handle, buffer, count, offset); |
| 286 | 286 | if (!result) |
| 287 | 287 | #elif defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_OS2) |
| r4431 | r4432 | |
| 465 | 465 | { |
| 466 | 466 | int err; |
| 467 | 467 | osd_directory_entry *result = NULL; |
| 468 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) |
| 468 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) |
| 469 | 469 | struct stat st; |
| 470 | 470 | #else |
| 471 | 471 | struct stat64 st; |
| 472 | 472 | #endif |
| 473 | 473 | |
| 474 | | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) |
| 474 | #if defined(SDLMAME_DARWIN) || defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_BSD) || defined(SDLMAME_OS2) |
| 475 | 475 | err = stat(path, &st); |
| 476 | 476 | #else |
| 477 | 477 | err = stat64(path, &st); |
src/osd/sdl/osinline.h
| r4431 | r4432 | |
| 17 | 17 | #if defined(__i386__) || defined(__x86_64__) |
| 18 | 18 | |
| 19 | 19 | |
| 20 | | INLINE void osd_yield_processor(void) |
| 20 | INLINE void ATTR_FORCE_INLINE |
| 21 | osd_yield_processor(void) |
| 21 | 22 | { |
| 22 | 23 | __asm__ __volatile__ ( " rep ; nop ;" ); |
| 23 | 24 | } |
| r4431 | r4432 | |
| 29 | 30 | // osd_exchange64 |
| 30 | 31 | //============================================================ |
| 31 | 32 | |
| 32 | | ATTR_UNUSED |
| 33 | | INLINE INT64 _osd_exchange64(INT64 volatile *ptr, INT64 exchange) |
| 33 | INLINE INT64 ATTR_UNUSED ATTR_NONNULL(1) ATTR_FORCE_INLINE |
| 34 | _osd_exchange64(INT64 volatile *ptr, INT64 exchange) |
| 34 | 35 | { |
| 35 | 36 | register INT64 ret; |
| 36 | 37 | __asm__ __volatile__ ( |
| r4431 | r4432 | |
| 49 | 50 | #elif defined(__ppc__) || defined (__PPC__) || defined(__ppc64__) || defined(__PPC64__) |
| 50 | 51 | |
| 51 | 52 | |
| 52 | | INLINE void osd_yield_processor(void) |
| 53 | INLINE void ATTR_FORCE_INLINE |
| 54 | osd_yield_processor(void) |
| 53 | 55 | { |
| 54 | 56 | __asm__ __volatile__ ( " nop \n nop \n" ); |
| 55 | 57 | } |
| r4431 | r4432 | |
| 62 | 64 | // osd_exchange64 |
| 63 | 65 | //============================================================ |
| 64 | 66 | |
| 65 | | ATTR_UNUSED |
| 66 | | INLINE INT64 _osd_exchange64(INT64 volatile *ptr, INT64 exchange) |
| 67 | INLINE INT64 ATTR_UNUSED ATTR_NONNULL(1) ATTR_FORCE_INLINE |
| 68 | _osd_exchange64(INT64 volatile *ptr, INT64 exchange) |
| 67 | 69 | { |
| 68 | 70 | register INT64 ret; |
| 69 | 71 | __asm__ __volatile__ ( |
| 70 | 72 | "1: ldarx %[ret], 0, %[ptr] \n" |
| 71 | 73 | " stdcx. %[exchange], 0, %[ptr] \n" |
| 72 | | " bne-- 1b \n" |
| 74 | " bne- 1b \n" |
| 73 | 75 | : [ret] "=&r" (ret) |
| 74 | 76 | : [ptr] "r" (ptr) |
| 75 | 77 | , [exchange] "r" (exchange) |
makefile.sdl
| r4431 | r4432 | |
| 1 | 1 | ########################################################################### |
| 2 | 2 | # |
| 3 | | # makefile.sdl |
| 3 | # makefile |
| 4 | 4 | # |
| 5 | 5 | # Core makefile for building SDLMAME and derivatives |
| 6 | 6 | # |
| r4431 | r4432 | |
| 146 | 146 | # (default is OPTIMIZE = 3 normally, or OPTIMIZE = 0 with symbols) |
| 147 | 147 | # OPTIMIZE = 3 |
| 148 | 148 | |
| 149 | # experimental: uncomment to compile everything as C++ for stricter type checking |
| 150 | # CPP_COMPILE = 1 |
| 149 | 151 | |
| 152 | |
| 150 | 153 | ########################################################################### |
| 151 | 154 | ################## END USER-CONFIGURABLE OPTIONS ###################### |
| 152 | 155 | ########################################################################### |
| r4431 | r4432 | |
| 210 | 213 | DEBUGSUFFIX = d |
| 211 | 214 | endif |
| 212 | 215 | |
| 216 | # cpp builds get a 'pp' suffix |
| 217 | ifdef CPP_COMPILE |
| 218 | CPPSUFFIX = pp |
| 219 | endif |
| 220 | |
| 213 | 221 | # the name is just 'target' if no subtarget; otherwise it is |
| 214 | 222 | # the concatenation of the two (e.g., mametiny) |
| 215 | 223 | ifeq ($(TARGET),$(SUBTARGET)) |
| r4431 | r4432 | |
| 219 | 227 | endif |
| 220 | 228 | |
| 221 | 229 | # fullname is prefix+name+suffix+debugsuffix |
| 222 | | FULLNAME = $(PREFIX)$(NAME)$(SUFFIX)$(DEBUGSUFFIX) |
| 230 | FULLNAME = $(PREFIX)$(NAME)$(CPPSUFFIX)$(SUFFIX)$(DEBUGSUFFIX) |
| 223 | 231 | |
| 224 | 232 | # add an EXE suffix to get the final emulator name |
| 225 | 233 | EMULATOR = $(FULLNAME)$(EXE) |
| r4431 | r4432 | |
| 281 | 289 | |
| 282 | 290 | #------------------------------------------------- |
| 283 | 291 | # compile flags |
| 292 | # CCOMFLAGS are common flags |
| 293 | # CONLYFLAGS are flags only used when compiling for C |
| 294 | # CPPONLYFLAGS are flags only used when compiling for C++ |
| 284 | 295 | #------------------------------------------------- |
| 285 | 296 | |
| 286 | | # we compile to C89 standard with GNU extensions |
| 287 | | CFLAGS = -std=gnu89 |
| 297 | # start with empties for everything |
| 298 | CCOMFLAGS = |
| 299 | CONLYFLAGS = |
| 300 | CPPONLYFLAGS = |
| 288 | 301 | |
| 302 | # CFLAGS is defined based on C or C++ targets |
| 303 | # (remember, expansion only happens when used, so doing it here is ok) |
| 304 | ifdef CPP_COMPILE |
| 305 | CFLAGS = $(CCOMFLAGS) $(CPPONLYFLAGS) |
| 306 | else |
| 307 | CFLAGS = $(CCOMFLAGS) $(CONLYFLAGS) |
| 308 | endif |
| 309 | |
| 310 | # we compile C-only to C89 standard with GNU extensions |
| 311 | # we compile C++ code to C++98 standard with GNU extensions |
| 312 | CONLYFLAGS += -std=gnu89 |
| 313 | CPPONLYFLAGS += -x c++ -std=gnu++98 |
| 314 | |
| 289 | 315 | # this speeds it up a bit by piping between the preprocessor/compiler/assembler |
| 290 | | CFLAGS += -pipe |
| 316 | CCOMFLAGS += -pipe |
| 291 | 317 | |
| 292 | | # add -g if we need symbols |
| 318 | # add -g if we need symbols, and ensure we have frame pointers |
| 293 | 319 | ifdef SYMBOLS |
| 294 | | CFLAGS += -g |
| 320 | CCOMFLAGS += -g -fno-omit-frame-pointer |
| 295 | 321 | endif |
| 296 | 322 | |
| 297 | 323 | # add -v if we need verbose build information |
| 298 | 324 | ifdef VERBOSE |
| 299 | | CFLAGS += -v |
| 325 | CCOMFLAGS += -v |
| 300 | 326 | endif |
| 301 | 327 | |
| 302 | | # add a basic set of warnings |
| 303 | | CFLAGS += \ |
| 304 | | -Wall \ |
| 305 | | -Wpointer-arith \ |
| 306 | | -Wbad-function-cast \ |
| 307 | | -Wcast-align \ |
| 308 | | -Wstrict-prototypes \ |
| 309 | | -Wundef \ |
| 310 | | -Wformat-security \ |
| 311 | | -Wwrite-strings \ |
| 312 | | |
| 313 | 328 | # add profiling information for the compiler |
| 314 | 329 | ifdef PROFILE |
| 315 | | CFLAGS += -pg |
| 330 | CCOMFLAGS += -pg |
| 316 | 331 | endif |
| 317 | 332 | |
| 318 | | # this warning is not supported on the os2 compilers |
| 319 | | ifneq ($(TARGETOS),os2) |
| 320 | | CFLAGS += -Wdeclaration-after-statement |
| 321 | | endif |
| 322 | | |
| 323 | 333 | # add the optimization flag |
| 324 | | CFLAGS += -O$(OPTIMIZE) |
| 334 | CCOMFLAGS += -O$(OPTIMIZE) |
| 325 | 335 | |
| 326 | 336 | # if we are optimizing, include optimization options |
| 327 | 337 | # and make all errors into warnings |
| 328 | 338 | ifneq ($(OPTIMIZE),0) |
| 329 | | CFLAGS += $(ARCHOPTS) -fno-strict-aliasing |
| 330 | 339 | ifneq ($(TARGETOS),os2) |
| 331 | | CFLAGS += -Werror |
| 340 | CCOMFLAGS += -Werror -fno-strict-aliasing $(ARCHOPTS) |
| 341 | else |
| 342 | CCOMFLAGS += -fno-strict-aliasing $(ARCHOPTS) |
| 332 | 343 | endif |
| 333 | 344 | endif |
| 334 | 345 | |
| 335 | | # if symbols are on, make sure we have frame pointers |
| 336 | | ifdef SYMBOLS |
| 337 | | CFLAGS += -fno-omit-frame-pointer |
| 346 | # add a basic set of warnings |
| 347 | CCOMFLAGS += \ |
| 348 | -Wall \ |
| 349 | -Wcast-align \ |
| 350 | -Wundef \ |
| 351 | -Wformat-security \ |
| 352 | -Wwrite-strings \ |
| 353 | -Wno-sign-compare |
| 354 | |
| 355 | # warnings only applicable to C compiles |
| 356 | CONLYFLAGS += \ |
| 357 | -Wpointer-arith \ |
| 358 | -Wbad-function-cast \ |
| 359 | -Wstrict-prototypes |
| 360 | |
| 361 | # this warning is not supported on the os2 compilers |
| 362 | ifneq ($(TARGETOS),os2) |
| 363 | CONLYFLAGS += -Wdeclaration-after-statement |
| 338 | 364 | endif |
| 339 | 365 | |
| 340 | 366 | |
| 341 | | |
| 342 | 367 | #------------------------------------------------- |
| 343 | 368 | # include paths |
| 344 | 369 | #------------------------------------------------- |
| 345 | 370 | |
| 346 | 371 | # add core include paths |
| 347 | | CFLAGS += \ |
| 372 | CCOMFLAGS += \ |
| 348 | 373 | -I$(SRC)/$(TARGET) \ |
| 349 | 374 | -I$(SRC)/$(TARGET)/includes \ |
| 350 | 375 | -I$(OBJ)/$(TARGET)/layout \ |
| r4431 | r4432 | |
| 392 | 417 | LDFLAGSEMULATOR += -Wl,-Map,$(FULLNAME).map |
| 393 | 418 | endif |
| 394 | 419 | |
| 395 | | # any reason why this doesn't work for all cases? |
| 396 | | ifeq ($(TARGETOS),macosx) |
| 397 | | LDFLAGSEMULATOR += -Xlinker -all_load |
| 398 | | endif |
| 399 | 420 | |
| 400 | 421 | |
| 401 | | |
| 402 | 422 | #------------------------------------------------- |
| 403 | 423 | # define the standard object directory; other |
| 404 | 424 | # projects can add their object directories to |
| r4431 | r4432 | |
| 434 | 454 | |
| 435 | 455 | # add expat XML library |
| 436 | 456 | ifdef BUILD_EXPAT |
| 437 | | CFLAGS += -I$(SRC)/lib/expat |
| 457 | CCOMFLAGS += -I$(SRC)/lib/expat |
| 438 | 458 | EXPAT = $(OBJ)/libexpat.a |
| 439 | 459 | else |
| 440 | 460 | LIBS += -lexpat |
| r4431 | r4432 | |
| 443 | 463 | |
| 444 | 464 | # add ZLIB compression library |
| 445 | 465 | ifdef BUILD_ZLIB |
| 446 | | CFLAGS += -I$(SRC)/lib/zlib |
| 466 | CCOMFLAGS += -I$(SRC)/lib/zlib |
| 447 | 467 | ZLIB = $(OBJ)/libz.a |
| 448 | 468 | else |
| 449 | 469 | LIBS += -lz |
| r4431 | r4432 | |
| 460 | 480 | all: maketree buildtools emulator tools |
| 461 | 481 | |
| 462 | 482 | |
| 483 | |
| 484 | |
| 463 | 485 | #------------------------------------------------- |
| 464 | 486 | # defines needed by multiple make files |
| 465 | 487 | #------------------------------------------------- |