branches/rbelmont/makefile
| r0 | r23965 | |
| 1 | ########################################################################### |
| 2 | # |
| 3 | # makefile |
| 4 | # |
| 5 | # Core makefile for building MAME and derivatives |
| 6 | # |
| 7 | # Copyright (c) Nicola Salmoria and the MAME Team. |
| 8 | # Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | # |
| 10 | ########################################################################### |
| 11 | |
| 12 | |
| 13 | |
| 14 | ########################################################################### |
| 15 | ################# BEGIN USER-CONFIGURABLE OPTIONS ##################### |
| 16 | ########################################################################### |
| 17 | |
| 18 | |
| 19 | #------------------------------------------------- |
| 20 | # specify core target: mame, mess, etc. |
| 21 | # specify subtarget: mame, mess, tiny, etc. |
| 22 | # build rules will be included from |
| 23 | # src/$(TARGET)/$(SUBTARGET).mak |
| 24 | #------------------------------------------------- |
| 25 | |
| 26 | ifndef TARGET |
| 27 | TARGET = mame |
| 28 | endif |
| 29 | |
| 30 | ifndef SUBTARGET |
| 31 | SUBTARGET = $(TARGET) |
| 32 | endif |
| 33 | |
| 34 | |
| 35 | |
| 36 | #------------------------------------------------- |
| 37 | # specify OSD layer: windows, sdl, etc. |
| 38 | # build rules will be included from |
| 39 | # src/osd/$(OSD)/$(OSD).mak |
| 40 | #------------------------------------------------- |
| 41 | |
| 42 | ifndef OSD |
| 43 | ifeq ($(OS),Windows_NT) |
| 44 | OSD = windows |
| 45 | TARGETOS = win32 |
| 46 | else |
| 47 | OSD = sdl |
| 48 | endif |
| 49 | endif |
| 50 | |
| 51 | ifndef CROSS_BUILD_OSD |
| 52 | CROSS_BUILD_OSD = $(OSD) |
| 53 | endif |
| 54 | |
| 55 | |
| 56 | |
| 57 | #------------------------------------------------- |
| 58 | # specify OS target, which further differentiates |
| 59 | # the underlying OS; supported values are: |
| 60 | # win32, unix, macosx, os2 |
| 61 | #------------------------------------------------- |
| 62 | |
| 63 | ifndef TARGETOS |
| 64 | |
| 65 | ifeq ($(OS),Windows_NT) |
| 66 | TARGETOS = win32 |
| 67 | else |
| 68 | |
| 69 | ifneq ($(CROSSBUILD),1) |
| 70 | |
| 71 | ifneq ($(OS2_SHELL),) |
| 72 | TARGETOS = os2 |
| 73 | else |
| 74 | |
| 75 | UNAME = $(shell uname -a) |
| 76 | |
| 77 | ifeq ($(firstword $(filter Linux,$(UNAME))),Linux) |
| 78 | TARGETOS = linux |
| 79 | endif |
| 80 | ifeq ($(firstword $(filter Solaris,$(UNAME))),Solaris) |
| 81 | TARGETOS = solaris |
| 82 | endif |
| 83 | ifeq ($(firstword $(filter FreeBSD,$(UNAME))),FreeBSD) |
| 84 | TARGETOS = freebsd |
| 85 | endif |
| 86 | ifeq ($(firstword $(filter GNU/kFreeBSD,$(UNAME))),GNU/kFreeBSD) |
| 87 | TARGETOS = freebsd |
| 88 | endif |
| 89 | ifeq ($(firstword $(filter NetBSD,$(UNAME))),NetBSD) |
| 90 | TARGETOS = netbsd |
| 91 | endif |
| 92 | ifeq ($(firstword $(filter OpenBSD,$(UNAME))),OpenBSD) |
| 93 | TARGETOS = openbsd |
| 94 | endif |
| 95 | ifeq ($(firstword $(filter Darwin,$(UNAME))),Darwin) |
| 96 | TARGETOS = macosx |
| 97 | endif |
| 98 | ifeq ($(firstword $(filter Haiku,$(UNAME))),Haiku) |
| 99 | TARGETOS = haiku |
| 100 | endif |
| 101 | |
| 102 | ifndef TARGETOS |
| 103 | $(error Unable to detect TARGETOS from uname -a: $(UNAME)) |
| 104 | endif |
| 105 | |
| 106 | # Autodetect PTR64 |
| 107 | ifndef PTR64 |
| 108 | ifeq ($(firstword $(filter x86_64,$(UNAME))),x86_64) |
| 109 | PTR64 = 1 |
| 110 | endif |
| 111 | ifeq ($(firstword $(filter amd64,$(UNAME))),amd64) |
| 112 | PTR64 = 1 |
| 113 | endif |
| 114 | ifeq ($(firstword $(filter ppc64,$(UNAME))),ppc64) |
| 115 | PTR64 = 1 |
| 116 | endif |
| 117 | endif |
| 118 | |
| 119 | # Autodetect BIGENDIAN |
| 120 | # MacOSX |
| 121 | ifndef BIGENDIAN |
| 122 | ifneq (,$(findstring Power,$(UNAME))) |
| 123 | BIGENDIAN=1 |
| 124 | endif |
| 125 | # Linux |
| 126 | ifneq (,$(findstring ppc,$(UNAME))) |
| 127 | BIGENDIAN=1 |
| 128 | endif |
| 129 | endif # BIGENDIAN |
| 130 | |
| 131 | endif # OS/2 |
| 132 | endif # CROSS_BUILD |
| 133 | endif # Windows_NT |
| 134 | |
| 135 | endif # TARGET_OS |
| 136 | |
| 137 | |
| 138 | ifeq ($(TARGETOS),win32) |
| 139 | |
| 140 | # Autodetect PTR64 |
| 141 | ifndef PTR64 |
| 142 | ifneq (,$(findstring mingw64-w64,$(PATH))) |
| 143 | PTR64=1 |
| 144 | endif |
| 145 | endif |
| 146 | |
| 147 | endif |
| 148 | |
| 149 | |
| 150 | |
| 151 | #------------------------------------------------- |
| 152 | # configure name of final executable |
| 153 | #------------------------------------------------- |
| 154 | |
| 155 | # uncomment and specify prefix to be added to the name |
| 156 | # PREFIX = |
| 157 | |
| 158 | # uncomment and specify suffix to be added to the name |
| 159 | # SUFFIX = |
| 160 | |
| 161 | |
| 162 | |
| 163 | #------------------------------------------------- |
| 164 | # specify architecture-specific optimizations |
| 165 | #------------------------------------------------- |
| 166 | |
| 167 | # uncomment and specify architecture-specific optimizations here |
| 168 | # some examples: |
| 169 | # ARCHOPTS = -march=pentiumpro # optimize for I686 |
| 170 | # ARCHOPTS = -march=core2 # optimize for Core 2 |
| 171 | # ARCHOPTS = -march=native # optimize for local machine (auto detect) |
| 172 | # ARCHOPTS = -mcpu=G4 # optimize for G4 |
| 173 | # note that we leave this commented by default so that you can |
| 174 | # configure this in your environment and never have to think about it |
| 175 | # ARCHOPTS = |
| 176 | |
| 177 | |
| 178 | |
| 179 | #------------------------------------------------- |
| 180 | # specify program options; see each option below |
| 181 | # for details |
| 182 | #------------------------------------------------- |
| 183 | |
| 184 | # uncomment next line to build a debug version |
| 185 | # DEBUG = 1 |
| 186 | |
| 187 | # uncomment next line to include the internal profiler |
| 188 | # PROFILER = 1 |
| 189 | |
| 190 | # uncomment the force the universal DRC to always use the C backend |
| 191 | # you may need to do this if your target architecture does not have |
| 192 | # a native backend |
| 193 | # FORCE_DRC_C_BACKEND = 1 |
| 194 | |
| 195 | # uncomment next line to build using unix-style libsdl on Mac OS X |
| 196 | # (vs. the native framework port). Normal users should not enable this. |
| 197 | # MACOSX_USE_LIBSDL = 1 |
| 198 | |
| 199 | # uncomment and specify path to cppcheck executable to perform |
| 200 | # static code analysis during compilation |
| 201 | # CPPCHECK = |
| 202 | |
| 203 | |
| 204 | |
| 205 | #------------------------------------------------- |
| 206 | # specify build options; see each option below |
| 207 | # for details |
| 208 | #------------------------------------------------- |
| 209 | |
| 210 | # uncomment next line if you are building for a 64-bit target |
| 211 | # PTR64 = 1 |
| 212 | |
| 213 | # uncomment next line if you are building for a big-endian target |
| 214 | # BIGENDIAN = 1 |
| 215 | |
| 216 | # uncomment next line to build expat as part of MAME build |
| 217 | BUILD_EXPAT = 1 |
| 218 | |
| 219 | # uncomment next line to build zlib as part of MAME build |
| 220 | BUILD_ZLIB = 1 |
| 221 | |
| 222 | # uncomment next line to build libflac as part of MAME build |
| 223 | BUILD_FLAC = 1 |
| 224 | |
| 225 | # uncomment next line to build jpeglib as part of MAME build |
| 226 | BUILD_JPEGLIB = 1 |
| 227 | |
| 228 | # uncomment next line to build PortMidi as part of MAME/MESS build |
| 229 | BUILD_MIDILIB = 1 |
| 230 | |
| 231 | # uncomment next line to include the symbols |
| 232 | # SYMBOLS = 1 |
| 233 | |
| 234 | # specify symbols level or leave commented to use the default |
| 235 | # (default is SYMLEVEL = 2 normally; use 1 if you only need backtrace) |
| 236 | # SYMLEVEL = 2 |
| 237 | |
| 238 | # uncomment next line to dump the symbols to a .sym file |
| 239 | # DUMPSYM = 1 |
| 240 | |
| 241 | # uncomment next line to include profiling information from the compiler |
| 242 | # PROFILE = 1 |
| 243 | |
| 244 | # uncomment next line to generate a link map for exception handling in windows |
| 245 | # MAP = 1 |
| 246 | |
| 247 | # uncomment next line to generate verbose build information |
| 248 | # VERBOSE = 1 |
| 249 | |
| 250 | # specify the sanitizer to use or leave empty to use none |
| 251 | # SANITIZE = |
| 252 | |
| 253 | # specify optimization level or leave commented to use the default |
| 254 | # (default is OPTIMIZE = 3 normally, or OPTIMIZE = 0 with symbols) |
| 255 | # OPTIMIZE = 3 |
| 256 | |
| 257 | |
| 258 | ########################################################################### |
| 259 | ################## END USER-CONFIGURABLE OPTIONS ###################### |
| 260 | ########################################################################### |
| 261 | |
| 262 | |
| 263 | #------------------------------------------------- |
| 264 | # sanity check the configuration |
| 265 | #------------------------------------------------- |
| 266 | |
| 267 | # specify a default optimization level if none explicitly stated |
| 268 | ifndef OPTIMIZE |
| 269 | ifndef SYMBOLS |
| 270 | OPTIMIZE = 3 |
| 271 | else |
| 272 | OPTIMIZE = 0 |
| 273 | endif |
| 274 | endif |
| 275 | |
| 276 | # profiler defaults to on for DEBUG builds |
| 277 | ifdef DEBUG |
| 278 | ifndef PROFILER |
| 279 | PROFILER = 1 |
| 280 | endif |
| 281 | endif |
| 282 | |
| 283 | # allow gprof profiling as well, which overrides the internal PROFILER |
| 284 | # also enable symbols as it is useless without them |
| 285 | ifdef PROFILE |
| 286 | PROFILER = |
| 287 | SYMBOLS = 1 |
| 288 | ifndef SYMLEVEL |
| 289 | SYMLEVEL = 1 |
| 290 | endif |
| 291 | endif |
| 292 | |
| 293 | # set the symbols level |
| 294 | ifdef SYMBOLS |
| 295 | ifndef SYMLEVEL |
| 296 | SYMLEVEL = 2 |
| 297 | endif |
| 298 | endif |
| 299 | |
| 300 | |
| 301 | #------------------------------------------------- |
| 302 | # platform-specific definitions |
| 303 | #------------------------------------------------- |
| 304 | |
| 305 | # extension for executables |
| 306 | EXE = |
| 307 | |
| 308 | ifeq ($(TARGETOS),win32) |
| 309 | EXE = .exe |
| 310 | endif |
| 311 | ifeq ($(TARGETOS),os2) |
| 312 | EXE = .exe |
| 313 | endif |
| 314 | |
| 315 | ifndef BUILD_EXE |
| 316 | BUILD_EXE = $(EXE) |
| 317 | endif |
| 318 | |
| 319 | # compiler, linker and utilities |
| 320 | AR = @ar |
| 321 | CC = @gcc |
| 322 | LD = @g++ |
| 323 | MD = -mkdir$(EXE) |
| 324 | RM = @rm -f |
| 325 | OBJDUMP = @objdump |
| 326 | PYTHON = @python |
| 327 | |
| 328 | |
| 329 | #------------------------------------------------- |
| 330 | # form the name of the executable |
| 331 | #------------------------------------------------- |
| 332 | |
| 333 | # reset all internal prefixes/suffixes |
| 334 | PREFIXSDL = |
| 335 | SUFFIX64 = |
| 336 | SUFFIXDEBUG = |
| 337 | SUFFIXPROFILE = |
| 338 | |
| 339 | # Windows SDL builds get an SDL prefix |
| 340 | ifeq ($(OSD),sdl) |
| 341 | ifeq ($(TARGETOS),win32) |
| 342 | PREFIXSDL = sdl |
| 343 | endif |
| 344 | endif |
| 345 | |
| 346 | # 64-bit builds get a '64' suffix |
| 347 | ifeq ($(PTR64),1) |
| 348 | SUFFIX64 = 64 |
| 349 | endif |
| 350 | |
| 351 | # debug builds just get the 'd' suffix and nothing more |
| 352 | ifdef DEBUG |
| 353 | SUFFIXDEBUG = d |
| 354 | endif |
| 355 | |
| 356 | # gprof builds get an addition 'p' suffix |
| 357 | ifdef PROFILE |
| 358 | SUFFIXPROFILE = p |
| 359 | endif |
| 360 | |
| 361 | # the name is just 'target' if no subtarget; otherwise it is |
| 362 | # the concatenation of the two (e.g., mametiny) |
| 363 | ifeq ($(TARGET),$(SUBTARGET)) |
| 364 | NAME = $(TARGET) |
| 365 | else |
| 366 | NAME = $(TARGET)$(SUBTARGET) |
| 367 | endif |
| 368 | |
| 369 | # fullname is prefix+name+suffix+suffix64+suffixdebug |
| 370 | FULLNAME ?= $(PREFIX)$(PREFIXSDL)$(NAME)$(SUFFIX)$(SUFFIX64)$(SUFFIXDEBUG)$(SUFFIXPROFILE) |
| 371 | |
| 372 | # add an EXE suffix to get the final emulator name |
| 373 | EMULATOR = $(FULLNAME)$(EXE) |
| 374 | |
| 375 | |
| 376 | |
| 377 | #------------------------------------------------- |
| 378 | # source and object locations |
| 379 | #------------------------------------------------- |
| 380 | |
| 381 | # all sources are under the src/ directory |
| 382 | SRC = src |
| 383 | |
| 384 | # build the targets in different object dirs, so they can co-exist |
| 385 | OBJ = obj/$(PREFIX)$(OSD)$(SUFFIX)$(SUFFIX64)$(SUFFIXDEBUG)$(SUFFIXPROFILE) |
| 386 | |
| 387 | |
| 388 | |
| 389 | #------------------------------------------------- |
| 390 | # compile-time definitions |
| 391 | #------------------------------------------------- |
| 392 | |
| 393 | # CR/LF setup: use both on win32/os2, CR only on everything else |
| 394 | DEFS = -DCRLF=2 |
| 395 | |
| 396 | ifeq ($(TARGETOS),win32) |
| 397 | DEFS = -DCRLF=3 |
| 398 | endif |
| 399 | ifeq ($(TARGETOS),os2) |
| 400 | DEFS = -DCRLF=3 |
| 401 | endif |
| 402 | |
| 403 | # map the INLINE to something digestible by GCC |
| 404 | DEFS += -DINLINE="static inline" |
| 405 | |
| 406 | # define LSB_FIRST if we are a little-endian target |
| 407 | ifndef BIGENDIAN |
| 408 | DEFS += -DLSB_FIRST |
| 409 | endif |
| 410 | |
| 411 | # define PTR64 if we are a 64-bit target |
| 412 | ifeq ($(PTR64),1) |
| 413 | DEFS += -DPTR64 |
| 414 | endif |
| 415 | |
| 416 | # define MAME_DEBUG if we are a debugging build |
| 417 | ifdef DEBUG |
| 418 | DEFS += -DMAME_DEBUG |
| 419 | else |
| 420 | DEFS += -DNDEBUG |
| 421 | endif |
| 422 | |
| 423 | # define MAME_PROFILER if we are a profiling build |
| 424 | ifdef PROFILER |
| 425 | DEFS += -DMAME_PROFILER |
| 426 | endif |
| 427 | |
| 428 | # define USE_NETWORK if we are a making network enabled build |
| 429 | ifdef USE_NETWORK |
| 430 | DEFS += -DUSE_NETWORK |
| 431 | endif |
| 432 | |
| 433 | # need to ensure FLAC functions are statically linked |
| 434 | ifeq ($(BUILD_FLAC),1) |
| 435 | DEFS += -DFLAC__NO_DLL |
| 436 | endif |
| 437 | |
| 438 | # define USE_SYSTEM_JPEGLIB if library shipped with MAME is not used |
| 439 | ifneq ($(BUILD_JPEGLIB),1) |
| 440 | DEFS += -DUSE_SYSTEM_JPEGLIB |
| 441 | endif |
| 442 | |
| 443 | |
| 444 | |
| 445 | #------------------------------------------------- |
| 446 | # compile flags |
| 447 | # CCOMFLAGS are common flags |
| 448 | # CONLYFLAGS are flags only used when compiling for C |
| 449 | # CPPONLYFLAGS are flags only used when compiling for C++ |
| 450 | # COBJFLAGS are flags only used when compiling for Objective-C(++) |
| 451 | #------------------------------------------------- |
| 452 | |
| 453 | # start with empties for everything |
| 454 | CCOMFLAGS = |
| 455 | CONLYFLAGS = |
| 456 | COBJFLAGS = |
| 457 | CPPONLYFLAGS = |
| 458 | |
| 459 | # CFLAGS is defined based on C or C++ targets |
| 460 | # (remember, expansion only happens when used, so doing it here is ok) |
| 461 | CFLAGS = $(CCOMFLAGS) $(CPPONLYFLAGS) |
| 462 | |
| 463 | # we compile C-only to C89 standard with GNU extensions |
| 464 | # we compile C++ code to C++98 standard with GNU extensions |
| 465 | CONLYFLAGS += -std=gnu89 |
| 466 | CPPONLYFLAGS += -x c++ -std=gnu++98 |
| 467 | COBJFLAGS += -x objective-c++ |
| 468 | |
| 469 | # this speeds it up a bit by piping between the preprocessor/compiler/assembler |
| 470 | CCOMFLAGS += -pipe |
| 471 | |
| 472 | # add -g if we need symbols, and ensure we have frame pointers |
| 473 | ifdef SYMBOLS |
| 474 | CCOMFLAGS += -g$(SYMLEVEL) -fno-omit-frame-pointer |
| 475 | endif |
| 476 | |
| 477 | # add -v if we need verbose build information |
| 478 | ifdef VERBOSE |
| 479 | CCOMFLAGS += -v |
| 480 | endif |
| 481 | |
| 482 | # add profiling information for the compiler |
| 483 | ifdef PROFILE |
| 484 | CCOMFLAGS += -pg |
| 485 | endif |
| 486 | |
| 487 | # add the optimization flag |
| 488 | CCOMFLAGS += -O$(OPTIMIZE) |
| 489 | |
| 490 | # add the error warning flag |
| 491 | ifndef NOWERROR |
| 492 | CCOMFLAGS += -Werror |
| 493 | endif |
| 494 | |
| 495 | # if we are optimizing, include optimization options |
| 496 | ifneq ($(OPTIMIZE),0) |
| 497 | CCOMFLAGS += -fno-strict-aliasing $(ARCHOPTS) |
| 498 | endif |
| 499 | |
| 500 | # add a basic set of warnings |
| 501 | CCOMFLAGS += \ |
| 502 | -Wall \ |
| 503 | -Wcast-align \ |
| 504 | -Wundef \ |
| 505 | -Wformat-security \ |
| 506 | -Wwrite-strings \ |
| 507 | -Wno-sign-compare \ |
| 508 | -Wno-conversion |
| 509 | |
| 510 | # warnings only applicable to C compiles |
| 511 | CONLYFLAGS += \ |
| 512 | -Wpointer-arith \ |
| 513 | -Wbad-function-cast \ |
| 514 | -Wstrict-prototypes |
| 515 | |
| 516 | # warnings only applicable to OBJ-C compiles |
| 517 | COBJFLAGS += \ |
| 518 | -Wpointer-arith |
| 519 | |
| 520 | # warnings only applicable to C++ compiles |
| 521 | CPPONLYFLAGS += \ |
| 522 | -Woverloaded-virtual |
| 523 | |
| 524 | ifneq (,$(findstring clang,$(CC))) |
| 525 | CCOMFLAGS += \ |
| 526 | -Wno-cast-align \ |
| 527 | -Wno-tautological-compare \ |
| 528 | -Wno-constant-logical-operand \ |
| 529 | -Wno-format-security \ |
| 530 | -Wno-shift-count-overflow \ |
| 531 | -Wno-self-assign-field |
| 532 | endif |
| 533 | |
| 534 | ifdef SANITIZE |
| 535 | CCOMFLAGS += -fsanitize=$(SANITIZE) |
| 536 | ifneq (,$(findstring thread,$(SANITIZE))) |
| 537 | CCOMFLAGS += -fPIE |
| 538 | endif |
| 539 | ifneq (,$(findstring memory,$(SANITIZE))) |
| 540 | ifneq (,$(findstring clang,$(CC))) |
| 541 | CCOMFLAGS += -fsanitize-memory-track-origins -fPIE |
| 542 | endif |
| 543 | endif |
| 544 | endif |
| 545 | |
| 546 | #------------------------------------------------- |
| 547 | # include paths |
| 548 | #------------------------------------------------- |
| 549 | |
| 550 | # add core include paths |
| 551 | INCPATH += \ |
| 552 | -I$(SRC)/$(TARGET) \ |
| 553 | -I$(OBJ)/$(TARGET)/layout \ |
| 554 | -I$(SRC)/emu \ |
| 555 | -I$(OBJ)/emu \ |
| 556 | -I$(OBJ)/emu/layout \ |
| 557 | -I$(SRC)/lib/util \ |
| 558 | -I$(SRC)/lib \ |
| 559 | -I$(SRC)/osd \ |
| 560 | -I$(SRC)/osd/$(OSD) \ |
| 561 | |
| 562 | |
| 563 | |
| 564 | #------------------------------------------------- |
| 565 | # archiving flags |
| 566 | #------------------------------------------------- |
| 567 | # Default to something reasonable for all platforms |
| 568 | ARFLAGS = -cr |
| 569 | # Deal with macosx brain damage if COMMAND_MODE is in |
| 570 | # the luser's environment: |
| 571 | ifeq ($(TARGETOS),macosx) |
| 572 | ifeq ($(COMMAND_MODE),"legacy") |
| 573 | ARFLAGS = -crs |
| 574 | endif |
| 575 | endif |
| 576 | |
| 577 | |
| 578 | #------------------------------------------------- |
| 579 | # linking flags |
| 580 | #------------------------------------------------- |
| 581 | |
| 582 | # LDFLAGS are used generally; LDFLAGSEMULATOR are additional |
| 583 | # flags only used when linking the core emulator |
| 584 | LDFLAGS = |
| 585 | ifneq ($(TARGETOS),macosx) |
| 586 | ifneq ($(TARGETOS),os2) |
| 587 | ifneq ($(TARGETOS),solaris) |
| 588 | LDFLAGS = -Wl,--warn-common |
| 589 | endif |
| 590 | endif |
| 591 | endif |
| 592 | LDFLAGSEMULATOR = |
| 593 | |
| 594 | # add profiling information for the linker |
| 595 | ifdef PROFILE |
| 596 | LDFLAGS += -pg |
| 597 | endif |
| 598 | |
| 599 | # strip symbols and other metadata in non-symbols and non profiling builds |
| 600 | ifndef SYMBOLS |
| 601 | ifneq ($(TARGETOS),macosx) |
| 602 | LDFLAGS += -s |
| 603 | endif |
| 604 | endif |
| 605 | |
| 606 | # output a map file (emulator only) |
| 607 | ifdef MAP |
| 608 | LDFLAGSEMULATOR += -Wl,-Map,$(FULLNAME).map |
| 609 | endif |
| 610 | |
| 611 | ifdef SANITIZE |
| 612 | LDFLAGS += -fsanitize=$(SANITIZE) |
| 613 | ifneq (,$(findstring thread,$(SANITIZE))) |
| 614 | LDFLAGS += -pie |
| 615 | endif |
| 616 | ifneq (,$(findstring memory,$(SANITIZE))) |
| 617 | LDFLAGS += -pie |
| 618 | endif |
| 619 | endif |
| 620 | |
| 621 | |
| 622 | #------------------------------------------------- |
| 623 | # define the standard object directory; other |
| 624 | # projects can add their object directories to |
| 625 | # this variable |
| 626 | #------------------------------------------------- |
| 627 | |
| 628 | OBJDIRS = $(OBJ) $(OBJ)/$(TARGET)/$(SUBTARGET) |
| 629 | |
| 630 | |
| 631 | #------------------------------------------------- |
| 632 | # define standard libarires for CPU and sounds |
| 633 | #------------------------------------------------- |
| 634 | |
| 635 | LIBEMU = $(OBJ)/libemu.a |
| 636 | LIBOPTIONAL = $(OBJ)/$(TARGET)/$(SUBTARGET)/liboptional.a |
| 637 | LIBDASM = $(OBJ)/$(TARGET)/$(SUBTARGET)/libdasm.a |
| 638 | LIBUTIL = $(OBJ)/libutil.a |
| 639 | LIBOCORE = $(OBJ)/libocore.a |
| 640 | LIBOSD = $(OBJ)/libosd.a |
| 641 | |
| 642 | VERSIONOBJ = $(OBJ)/version.o |
| 643 | EMUINFOOBJ = $(OBJ)/$(TARGET)/$(TARGET).o |
| 644 | DRIVLISTSRC = $(OBJ)/$(TARGET)/$(SUBTARGET)/drivlist.c |
| 645 | DRIVLISTOBJ = $(OBJ)/$(TARGET)/$(SUBTARGET)/drivlist.o |
| 646 | |
| 647 | |
| 648 | |
| 649 | #------------------------------------------------- |
| 650 | # either build or link against the included |
| 651 | # libraries |
| 652 | #------------------------------------------------- |
| 653 | |
| 654 | # start with an empty set of libs |
| 655 | LIBS = |
| 656 | |
| 657 | # add expat XML library |
| 658 | ifeq ($(BUILD_EXPAT),1) |
| 659 | INCPATH += -I$(SRC)/lib/expat |
| 660 | EXPAT = $(OBJ)/libexpat.a |
| 661 | else |
| 662 | LIBS += -lexpat |
| 663 | EXPAT = |
| 664 | endif |
| 665 | |
| 666 | # add ZLIB compression library |
| 667 | ifeq ($(BUILD_ZLIB),1) |
| 668 | INCPATH += -I$(SRC)/lib/zlib |
| 669 | ZLIB = $(OBJ)/libz.a |
| 670 | else |
| 671 | LIBS += -lz |
| 672 | ZLIB = |
| 673 | endif |
| 674 | |
| 675 | # add flac library |
| 676 | ifeq ($(BUILD_FLAC),1) |
| 677 | INCPATH += -I$(SRC)/lib/util |
| 678 | FLAC_LIB = $(OBJ)/libflac.a |
| 679 | # $(OBJ)/libflac++.a |
| 680 | else |
| 681 | LIBS += -lFLAC |
| 682 | FLAC_LIB = |
| 683 | endif |
| 684 | |
| 685 | # add jpeglib image library |
| 686 | ifeq ($(BUILD_JPEGLIB),1) |
| 687 | INCPATH += -I$(SRC)/lib/libjpeg |
| 688 | JPEG_LIB = $(OBJ)/libjpeg.a |
| 689 | else |
| 690 | LIBS += -ljpeg |
| 691 | JPEG_LIB = |
| 692 | endif |
| 693 | |
| 694 | # add SoftFloat floating point emulation library |
| 695 | SOFTFLOAT = $(OBJ)/libsoftfloat.a |
| 696 | |
| 697 | # add formats emulation library |
| 698 | FORMATS_LIB = $(OBJ)/libformats.a |
| 699 | |
| 700 | # add LUA library |
| 701 | LUA_LIB = $(OBJ)/liblua.a |
| 702 | |
| 703 | # add PortMidi MIDI library |
| 704 | ifeq ($(BUILD_MIDILIB),1) |
| 705 | INCPATH += -I$(SRC)/lib/portmidi |
| 706 | MIDI_LIB = $(OBJ)/libportmidi.a |
| 707 | else |
| 708 | LIBS += -lportmidi |
| 709 | MIDI_LIB = |
| 710 | endif |
| 711 | |
| 712 | ifneq (,$(findstring clang,$(CC))) |
| 713 | LIBS += -lstdc++ -lpthread |
| 714 | endif |
| 715 | |
| 716 | #------------------------------------------------- |
| 717 | # 'default' target needs to go here, before the |
| 718 | # include files which define additional targets |
| 719 | #------------------------------------------------- |
| 720 | |
| 721 | default: maketree buildtools emulator |
| 722 | |
| 723 | all: default tools |
| 724 | |
| 725 | 7Z_LIB = $(OBJ)/lib7z.a |
| 726 | |
| 727 | #------------------------------------------------- |
| 728 | # defines needed by multiple make files |
| 729 | #------------------------------------------------- |
| 730 | |
| 731 | BUILDSRC = $(SRC)/build |
| 732 | BUILDOBJ = $(OBJ)/build |
| 733 | BUILDOUT = $(BUILDOBJ) |
| 734 | |
| 735 | |
| 736 | |
| 737 | #------------------------------------------------- |
| 738 | # include the various .mak files |
| 739 | #------------------------------------------------- |
| 740 | |
| 741 | # include OSD-specific rules first |
| 742 | include $(SRC)/osd/$(OSD)/$(OSD).mak |
| 743 | |
| 744 | # then the various core pieces |
| 745 | include $(SRC)/build/build.mak |
| 746 | include $(SRC)/$(TARGET)/$(SUBTARGET).mak |
| 747 | -include $(SRC)/$(TARGET)/osd/$(OSD)/$(OSD).mak |
| 748 | include $(SRC)/emu/emu.mak |
| 749 | include $(SRC)/lib/lib.mak |
| 750 | -include $(SRC)/osd/$(CROSS_BUILD_OSD)/build.mak |
| 751 | include $(SRC)/tools/tools.mak |
| 752 | include $(SRC)/regtests/regtests.mak |
| 753 | |
| 754 | # combine the various definitions to one |
| 755 | CCOMFLAGS += $(INCPATH) |
| 756 | CDEFS = $(DEFS) |
| 757 | |
| 758 | # TODO: -x c++ should not be hard-coded |
| 759 | CPPCHECKFLAGS = $(CDEFS) $(INCPATH) -x c++ --enable=style |
| 760 | |
| 761 | |
| 762 | #------------------------------------------------- |
| 763 | # primary targets |
| 764 | #------------------------------------------------- |
| 765 | |
| 766 | emulator: maketree $(BUILD) $(EMULATOR) |
| 767 | |
| 768 | buildtools: maketree $(BUILD) |
| 769 | |
| 770 | tools: maketree $(TOOLS) |
| 771 | |
| 772 | maketree: $(sort $(OBJDIRS)) |
| 773 | |
| 774 | clean: $(OSDCLEAN) |
| 775 | @echo Deleting object tree $(OBJ)... |
| 776 | $(RM) -r $(OBJ) |
| 777 | @echo Deleting $(EMULATOR)... |
| 778 | $(RM) $(EMULATOR) |
| 779 | @echo Deleting $(TOOLS)... |
| 780 | $(RM) $(TOOLS) |
| 781 | @echo Deleting dependencies... |
| 782 | $(RM) depend_emu.mak |
| 783 | $(RM) depend_mame.mak |
| 784 | $(RM) depend_mess.mak |
| 785 | $(RM) depend_ume.mak |
| 786 | ifdef MAP |
| 787 | @echo Deleting $(FULLNAME).map... |
| 788 | $(RM) $(FULLNAME).map |
| 789 | endif |
| 790 | ifdef SYMBOLS |
| 791 | @echo Deleting $(FULLNAME).sym... |
| 792 | $(RM) $(FULLNAME).sym |
| 793 | endif |
| 794 | |
| 795 | checkautodetect: |
| 796 | @echo TARGETOS=$(TARGETOS) |
| 797 | @echo PTR64=$(PTR64) |
| 798 | @echo BIGENDIAN=$(BIGENDIAN) |
| 799 | @echo UNAME="$(UNAME)" |
| 800 | |
| 801 | tests: $(REGTESTS) |
| 802 | |
| 803 | mak: maketree $(MAKEMAK_TARGET) |
| 804 | @echo Rebuilding $(SUBTARGET).mak... |
| 805 | $(MAKEMAK) $(SRC)/targets/$(SUBTARGET).lst -I$(SRC)/emu -I$(SRC)/mame -I$(SRC)/mame/layout -I$(SRC)/mess -I$(SRC)/mess/layout $(SRC) > $(SUBTARGET).mak |
| 806 | $(MAKEMAK) $(SRC)/targets/$(SUBTARGET).lst > $(SUBTARGET).lst |
| 807 | |
| 808 | #------------------------------------------------- |
| 809 | # directory targets |
| 810 | #------------------------------------------------- |
| 811 | |
| 812 | $(sort $(OBJDIRS)): |
| 813 | $(MD) -p $@ |
| 814 | |
| 815 | |
| 816 | |
| 817 | #------------------------------------------------- |
| 818 | # executable targets and dependencies |
| 819 | #------------------------------------------------- |
| 820 | |
| 821 | ifndef EXECUTABLE_DEFINED |
| 822 | |
| 823 | $(EMULATOR): $(EMUINFOOBJ) $(DRIVLISTOBJ) $(DRVLIBS) $(LIBOSD) $(LIBOPTIONAL) $(LIBEMU) $(LIBDASM) $(LIBUTIL) $(EXPAT) $(SOFTFLOAT) $(JPEG_LIB) $(FLAC_LIB) $(7Z_LIB) $(FORMATS_LIB) $(LUA_LIB) $(ZLIB) $(LIBOCORE) $(MIDI_LIB) $(RESFILE) |
| 824 | $(CC) $(CDEFS) $(CFLAGS) -c $(SRC)/version.c -o $(VERSIONOBJ) |
| 825 | @echo Linking $@... |
| 826 | $(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) $(VERSIONOBJ) $^ $(LIBS) -o $@ |
| 827 | ifeq ($(TARGETOS),win32) |
| 828 | ifdef SYMBOLS |
| 829 | ifndef MSVC_BUILD |
| 830 | $(OBJDUMP) --section=.text --line-numbers --syms --demangle $@ >$(FULLNAME).sym |
| 831 | endif |
| 832 | endif |
| 833 | endif |
| 834 | |
| 835 | endif |
| 836 | |
| 837 | |
| 838 | |
| 839 | #------------------------------------------------- |
| 840 | # generic rules |
| 841 | #------------------------------------------------- |
| 842 | |
| 843 | $(OBJ)/%.o: $(SRC)/%.c | $(OSPREBUILD) |
| 844 | @echo Compiling $<... |
| 845 | $(CC) $(CDEFS) $(CFLAGS) -c $< -o $@ |
| 846 | ifdef CPPCHECK |
| 847 | @$(CPPCHECK) $(CPPCHECKFLAGS) $< |
| 848 | endif |
| 849 | |
| 850 | $(OBJ)/%.o: $(OBJ)/%.c | $(OSPREBUILD) |
| 851 | @echo Compiling $<... |
| 852 | $(CC) $(CDEFS) $(CFLAGS) -c $< -o $@ |
| 853 | ifdef CPPCHECK |
| 854 | @$(CPPCHECK) $(CPPCHECKFLAGS) $< |
| 855 | endif |
| 856 | |
| 857 | $(OBJ)/%.pp: $(SRC)/%.c | $(OSPREBUILD) |
| 858 | @echo Compiling $<... |
| 859 | $(CC) $(CDEFS) $(CFLAGS) -E $< -o $@ |
| 860 | ifdef CPPCHECK |
| 861 | @$(CPPCHECK) $(CPPCHECKFLAGS) $< |
| 862 | endif |
| 863 | |
| 864 | $(OBJ)/%.s: $(SRC)/%.c | $(OSPREBUILD) |
| 865 | @echo Compiling $<... |
| 866 | $(CC) $(CDEFS) $(CFLAGS) -S $< -o $@ |
| 867 | ifdef CPPCHECK |
| 868 | @$(CPPCHECK) $(CPPCHECKFLAGS) $< |
| 869 | endif |
| 870 | |
| 871 | $(OBJ)/%.lh: $(SRC)/%.lay $(FILE2STR_TARGET) |
| 872 | @echo Converting $<... |
| 873 | @$(FILE2STR) $< $@ layout_$(basename $(notdir $<)) |
| 874 | |
| 875 | $(OBJ)/%.fh: $(SRC)/%.png $(PNG2BDC_TARGET) $(FILE2STR_TARGET) |
| 876 | @echo Converting $<... |
| 877 | @$(PNG2BDC) $< $(OBJ)/temp.bdc |
| 878 | @$(FILE2STR) $(OBJ)/temp.bdc $@ font_$(basename $(notdir $<)) UINT8 |
| 879 | |
| 880 | $(DRIVLISTOBJ): $(DRIVLISTSRC) |
| 881 | @echo Compiling $<... |
| 882 | $(CC) $(CDEFS) $(CFLAGS) -c $< -o $@ |
| 883 | ifdef CPPCHECK |
| 884 | @$(CPPCHECK) $(CPPCHECKFLAGS) $< |
| 885 | endif |
| 886 | |
| 887 | $(DRIVLISTSRC): $(SRC)/$(TARGET)/$(SUBTARGET).lst $(MAKELIST_TARGET) |
| 888 | @echo Building driver list $<... |
| 889 | @$(MAKELIST) $< >$@ |
| 890 | |
| 891 | $(OBJ)/%.a: |
| 892 | @echo Archiving $@... |
| 893 | $(RM) $@ |
| 894 | $(AR) $(ARFLAGS) $@ $^ |
| 895 | |
| 896 | ifeq ($(TARGETOS),macosx) |
| 897 | $(OBJ)/%.o: $(SRC)/%.m | $(OSPREBUILD) |
| 898 | @echo Objective-C compiling $<... |
| 899 | $(CC) $(CDEFS) $(COBJFLAGS) $(CCOMFLAGS) -c $< -o $@ |
| 900 | endif |
| 901 | |
| 902 | |
| 903 | |
| 904 | #------------------------------------------------- |
| 905 | # optional dependencies file |
| 906 | #------------------------------------------------- |
| 907 | |
| 908 | -include depend_emu.mak |
| 909 | -include depend_$(TARGET).mak |