-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile.libretro
862 lines (723 loc) · 22.4 KB
/
Makefile.libretro
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
###########################################################################
#
# makefile
#
# Core makefile for building MAME and derivatives
#
# Copyright (c) Nicola Salmoria and the MAME Team.
# Visit http://mamedev.org for licensing and usage restrictions.
#
###########################################################################
NATIVE :=0
UNAME=$(shell uname -a)
ifeq ($(platform),)
platform = unix
ifeq ($(UNAME),)
platform = win
else ifneq ($(findstring MINGW,$(UNAME)),)
platform = win
else ifneq ($(findstring Darwin,$(UNAME)),)
platform = osx
else ifneq ($(findstring win,$(UNAME)),)
platform = win
endif
endif
# system platform
system_platform = unix
ifeq ($(UNAME),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(UNAME)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(UNAME)),)
system_platform = win
endif
# CR/LF setup: use both on win32/os2, CR only on everything else
DEFS = -DCRLF=2 -DDISABLE_MIDI=1
# Default to something reasonable for all platforms
ARFLAGS = -cr
ifeq ($(TARGET),)
TARGET = mame
endif
TARGET_NAME := $(TARGET)
EXE =
LIBS =
ifeq ($(TARGET), mess)
CORE_DEFINE := -DWANT_MESS
else ifeq ($(TARGET), mame)
CORE_DEFINE := -DWANT_MAME
else
CORE_DEFINE := -DWANT_UME
endif
$(info COREDEF = $(CORE_DEFINE))
#-------------------------------------------------
# compile flags
# CCOMFLAGS are common flags
# CONLYFLAGS are flags only used when compiling for C
# CPPONLYFLAGS are flags only used when compiling for C++
# COBJFLAGS are flags only used when compiling for Objective-C(++)
#-------------------------------------------------
# start with empties for everything
CCOMFLAGS = -DDISABLE_MIDI
CONLYFLAGS = -fpermissive
CONLYFLAGS += $(CORE_DEFINE)
COBJFLAGS =
CPPONLYFLAGS = -fpermissive
CPPONLYFLAGS += $(CORE_DEFINE)
# LDFLAGS are used generally; LDFLAGSEMULATOR are additional
# flags only used when linking the core emulator
LDFLAGS =
LDFLAGSEMULATOR =
$(info CFLAGS = $(CONLYFLAGS))
$(info CPPFLAGS = $(CPPONLYFLAGS))
# uncomment next line to build expat as part of MAME build
BUILD_EXPAT = 1
# uncomment next line to build zlib as part of MAME build
ifneq ($(platform), android)
BUILD_ZLIB = 1
endif
# uncomment next line to build libflac as part of MAME build
BUILD_FLAC = 1
# uncomment next line to build jpeglib as part of MAME build
BUILD_JPEGLIB = 1
# uncomment next line to build PortMidi as part of MAME/MESS build
#BUILD_MIDILIB = 1
ifeq ($(platform), unix)
TARGETLIB := $(TARGET_NAME)_libretro.so
TARGETOS=linux
fpic := -fPIC
SHARED := -shared -Wl,--version-script=src/osd/retro/link.T -Wl,--no-undefined
CCOMFLAGS += $(fpic) -fsigned-char -finline -fno-common -fno-builtin -fweb -frename-registers -falign-functions=16 -fsingle-precision-constant
PLATCFLAGS += -DRETRO -DALIGN_INTS -DALIGN_SHORTS -fstrict-aliasing -fno-merge-constants $(fpic)
LDFLAGS += $(fpic) $(SHARED)
NATIVELD = g++
NATIVELDFLAGS = -Wl,--warn-common -lstdc++ -Wl,--no-undefined
NATIVECC = g++
NATIVECFLAGS = -std=gnu99
CC_AS = gcc
CC = g++
AR = @ar
LD = g++
CCOMFLAGS += $(PLATCFLAGS) -ffast-math
LIBS += -lstdc++ -lpthread
ifeq ($(firstword $(filter x86_64,$(UNAME))),x86_64)
PTR64 = 1
endif
ifeq ($(firstword $(filter amd64,$(UNAME))),amd64)
PTR64 = 1
endif
ifeq ($(firstword $(filter ppc64,$(UNAME))),ppc64)
PTR64 = 1
endif
ifneq (,$(findstring ppc,$(UNAME)))
BIGENDIAN=1
else
PLATCFLAGS += -DLSB_FIRST
endif
else ifeq ($(platform), android)
armplatform := 1
TARGETLIB := $(TARGET_NAME)_libretro.so
TARGETOS=linux
fpic := -fPIC
SHARED := -shared -Wl,--version-script=src/osd/retro/link.T
CC_AS = @arm-linux-androideabi-gcc
CC = @arm-linux-androideabi-g++
AR = @arm-linux-androideabi-ar
LD = @arm-linux-androideabi-g++
FORCE_DRC_C_BACKEND = 1
CCOMFLAGS += -fPIC -mstructure-size-boundary=32 -mthumb-interwork -falign-functions=16 -fsigned-char -finline -fno-common -fno-builtin -fweb -frename-registers -falign-functions=16 -fsingle-precision-constant
PLATCFLAGS += -march=armv7-a -mfloat-abi=softfp -DRETRO -DRETRO_AND -DALIGN_INTS -DALIGN_SHORTS -DLSB_FIRST -fstrict-aliasing -fno-merge-constants -DSDLMAME_NO64BITIO -DANDTIME -DRANDPATH -DANDROID_BUILD -DUSE_ARM_HACK
LDFLAGS += -Wl,--fix-cortex-a8 -llog $(fpic) $(SHARED)
NATIVELD = g++
NATIVELDFLAGS = -Wl,--warn-common -lstdc++
NATIVECC = g++
NATIVECFLAGS = -std=gnu99
CCOMFLAGS += $(PLATCFLAGS) -ffast-math
LIBS += -lstdc++
#-lpthread
else ifeq ($(platform), osx)
TARGETLIB := $(TARGET_NAME)_libretro.dylib
TARGETOS = macosx
fpic := -fPIC -mmacosx-version-min=10.7
LDFLAGSEMULATOR += -stdlib=libc++
PLATCFLAGS += $(fpic)
SHARED := -dynamiclib
CC = c++ -stdlib=libc++
LD = c++ -stdlib=libc++
NATIVELD = c++ -stdlib=libc++
NATIVECC = c++
LDFLAGS += $(fpic) $(SHARED)
CC_AS = clang
AR = @ar
PYTHON ?= @python
ifeq ($(COMMAND_MODE),"legacy")
ARFLAGS = -crs
endif
ifeq ($(firstword $(filter x86_64,$(UNAME))),x86_64)
PTR64 = 1
endif
ifeq ($(firstword $(filter amd64,$(UNAME))),amd64)
PTR64 = 1
endif
ifeq ($(firstword $(filter ppc64,$(UNAME))),ppc64)
PTR64 = 1
endif
ifneq (,$(findstring Power,$(UNAME)))
BIGENDIAN=1
else
PLATCFLAGS += -DLSB_FIRST
endif
else ifeq ($(platform), ios)
armplatform := 1
FORCE_DRC_C_BACKEND = 1
TARGETLIB := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
TARGETOS = macosx
CC_AS = clang -arch armv7 -isysroot $(IOSSDK)
CC = clang++ -arch armv7 -isysroot $(IOSSDK)
LD = $(CC) -stdlib=libc++
NATIVELD = c++ -stdlib=libc++
NATIVECC = c++
PYTHON ?= @python
CFLAGS += -DIOS
PLATCFLAGS += -DSDLMAME_NO64BITIO -DIOS -DUSE_ARM_HACK -DHAVE_POSIX_MEMALIGN
CCOMFLAGS += $(PLATCFLAGS) -ffast-math
else ifeq ($(platform), qnx)
armplatform := 1
TARGETLIB := $(TARGET_NAME)_libretro_qnx.so
TARGETOS=linux
fpic := -fPIC
SHARED := -shared -Wl,--version-script=src/osd/retro/link.T
CC = qcc -Vgcc_ntoarmv7le
AR = qcc -Vgcc_ntoarmv7le
CFLAGS += -D__BLACKBERRY_QNX__
LIBS += -lstdc++ -lpthread
else ifeq ($(platform), ps3)
TARGETLIB := $(TARGET_NAME)_libretro_ps3.a
CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
STATIC_LINKING = 1
BIGENDIAN=1
LIBS += -lstdc++ -lpthread
else ifeq ($(platform), sncps3)
TARGETLIB := $(TARGET_NAME)_libretro_ps3.a
CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
STATIC_LINKING = 1
BIGENDIAN=1
LIBS += -lstdc++ -lpthread
else ifeq ($(platform), psl1ght)
TARGETLIB := $(TARGET_NAME)_libretro_psl1ght.a
CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
STATIC_LINKING = 1
BIGENDIAN=1
LIBS += -lstdc++ -lpthread
else ifeq ($(platform), psp1)
TARGETLIB := $(TARGET_NAME)_libretro_psp1.a
CC = psp-g++$(EXE_EXT)
AR = psp-ar$(EXE_EXT)
CFLAGS += -DPSP -G0
STATIC_LINKING = 1
LIBS += -lstdc++ -lpthread
else ifeq ($(platform), xenon)
TARGETLIB := $(TARGET_NAME)_libretro_xenon360.a
CC = xenon-g++$(EXE_EXT)
AR = xenon-ar$(EXE_EXT)
CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
STATIC_LINKING = 1
BIGENDIAN=1
LIBS += -lstdc++ -lpthread
else ifeq ($(platform), ngc)
TARGETLIB := $(TARGET_NAME)_libretro_ngc.a
CC = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
STATIC_LINKING = 1
BIGENDIAN=1
LIBS += -lstdc++ -lpthread
else ifeq ($(platform), wii)
TARGETLIB := $(TARGET_NAME)_libretro_wii.a
CC = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
STATIC_LINKING = 1
BIGENDIAN=1
LIBS += -lstdc++ -lpthread
else ifneq (,$(findstring armv,$(platform)))
armplatform := 1
TARGETLIB := $(TARGET_NAME)_libretro.so
SHARED := -shared -Wl,--no-undefined
fpic := -fPIC
CC = g++
ifneq (,$(findstring cortexa8,$(platform)))
CFLAGS += -marm -mcpu=cortex-a8
ASFLAGS += -mcpu=cortex-a8
else ifneq (,$(findstring cortexa9,$(platform)))
CFLAGS += -marm -mcpu=cortex-a9
ASFLAGS += -mcpu=cortex-a9
endif
CFLAGS += -marm
ifneq (,$(findstring neon,$(platform)))
CFLAGS += -mfpu=neon
ASFLAGS += -mfpu=neon
HAVE_NEON = 1
endif
ifneq (,$(findstring softfloat,$(platform)))
CFLAGS += -mfloat-abi=softfp
ASFLAGS += -mfloat-abi=softfp
else ifneq (,$(findstring hardfloat,$(platform)))
CFLAGS += -mfloat-abi=hard
ASFLAGS += -mfloat-abi=hard
endif
CFLAGS += -DARM
LIBS += -lstdc++ -lpthread
else ifeq ($(platform), wincross)
TARGETLIB := $(TARGET_NAME)_libretro.dll
TARGETOS = win32
CC ?= g++
LD ?= g++
NATIVELD = $(LD)
CC_AS ?= gcc
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=src/osd/retro/link.T
CCOMFLAGS += -DRETRO -D__WIN32__ -D__WIN32_LIBRETRO__
LDFLAGS += $(SHARED)
EXE = .exe
#LIBS += -lpthread
DEFS = -DCRLF=3
ifneq (,$(findstring mingw64-w64,$(PATH)))
PTR64=1
endif
else
TARGETLIB := $(TARGET_NAME)_libretro.dll
TARGETOS = win32
CC = g++
LD = g++
NATIVELD = $(LD)
CC_AS = gcc
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=src/osd/retro/link.T
#CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
CCOMFLAGS += -DRETRO -D__WIN32__ -D__WIN32_LIBRETRO__
LDFLAGS += $(SHARED)
EXE = .exe
LIBS += -lws2_32
DEFS = -DCRLF=3
DEFS += -DX64_WINDOWS_ABI
ifneq (,$(findstring mingw64-w64,$(PATH)))
PTR64=1
endif
endif
###########################################################################
################# BEGIN USER-CONFIGURABLE OPTIONS #####################
###########################################################################
ifndef TARGET
TARGET = mame
endif
ifndef SUBTARGET
SUBTARGET = $(TARGET)
endif
#TARGET=mame
#SUBTARGET=mame
OSD=retro
NOWERROR = 1
ifndef PARTIAL
PARTIAL = 0
endif
#-------------------------------------------------
# specify core target: mame, mess, etc.
# specify subtarget: mame, mess, tiny, etc.
# build rules will be included from
# src/$(TARGET)/$(SUBTARGET).mak
#-------------------------------------------------
#-------------------------------------------------
# specify OSD layer: windows, sdl, etc.
# build rules will be included from
# src/osd/$(OSD)/$(OSD).mak
#-------------------------------------------------
CROSS_BUILD_OSD = $(OSD)
#-------------------------------------------------
# configure name of final executable
#-------------------------------------------------
# uncomment and specify prefix to be added to the name
# PREFIX =
# uncomment and specify suffix to be added to the name
# SUFFIX =
#-------------------------------------------------
# specify architecture-specific optimizations
#-------------------------------------------------
# uncomment and specify architecture-specific optimizations here
# some examples:
# ARCHOPTS = -march=pentiumpro # optimize for I686
# ARCHOPTS = -march=core2 # optimize for Core 2
# ARCHOPTS = -march=native # optimize for local machine (auto detect)
# ARCHOPTS = -mcpu=G4 # optimize for G4
# note that we leave this commented by default so that you can
# configure this in your environment and never have to think about it
# ARCHOPTS =
#-------------------------------------------------
# specify program options; see each option below
# for details
#-------------------------------------------------
# uncomment the force the universal DRC to always use the C backend
# you may need to do this if your target architecture does not have
# a native backend
# FORCE_DRC_C_BACKEND = 1
#-------------------------------------------------
# specify build options; see each option below
# for details
#-------------------------------------------------
# specify optimization level or leave commented to use the default
# (default is OPTIMIZE = 3 normally, or OPTIMIZE = 0 with symbols)
OPTIMIZE = 3
###########################################################################
################## END USER-CONFIGURABLE OPTIONS ######################
###########################################################################
#-------------------------------------------------
# platform-specific definitions
#-------------------------------------------------
# utilities
MD = -mkdir$(EXE_EXT)
RM = @rm -f
OBJDUMP = @objdump
PYTHON ?= @python2
#-------------------------------------------------
# form the name of the executable
#-------------------------------------------------
# reset all internal prefixes/suffixes
SUFFIX64 =
SUFFIXDEBUG =
SUFFIXPROFILE =
# 64-bit builds get a '64' suffix
ifeq ($(PTR64),1)
SUFFIX64 = 64
endif
# add an EXE suffix to get the final emulator name
EMULATOR = $(TARGET)
#-------------------------------------------------
# source and object locations
#-------------------------------------------------
# all sources are under the src/ directory
SRC = src
# build the targets in different object dirs, so they can co-exist
ifeq ($(NATIVE),1)
OBJ = obj/$(PREFIX)$(OSD)$(SUFFIX)$(SUFFIX64)$(SUFFIXDEBUG)$(SUFFIXPROFILE)
else
OBJ = obj/$(PREFIX)$(SUFFIXDEBUG)$(SUFFIXPROFILE)
endif
#-------------------------------------------------
# compile-time definitions
#-------------------------------------------------
# map the INLINE to something digestible by GCC
DEFS += -DINLINE="static inline"
# define LSB_FIRST if we are a little-endian target
ifndef BIGENDIAN
DEFS += -DLSB_FIRST
endif
# define PTR64 if we are a 64-bit target
ifeq ($(PTR64),1)
DEFS += -DPTR64
endif
DEFS += -DNDEBUG
# need to ensure FLAC functions are statically linked
ifeq ($(BUILD_FLAC),1)
DEFS += -DFLAC__NO_DLL
endif
# define USE_SYSTEM_JPEGLIB if library shipped with MAME is not used
ifneq ($(BUILD_JPEGLIB),1)
DEFS += -DUSE_SYSTEM_JPEGLIB
endif
# CFLAGS is defined based on C or C++ targets
# (remember, expansion only happens when used, so doing it here is ok)
CFLAGS = $(CCOMFLAGS) $(CPPONLYFLAGS)
# we compile C-only to C89 standard with GNU extensions
# we compile C++ code to C++98 standard with GNU extensions
#CONLYFLAGS += -std=gnu89
ifeq ($(platform), osx)
CONLYFLAGS += -ansi
else
CONLYFLAGS += -std=gnu89
endif
CPPONLYFLAGS += -x c++ -std=gnu++98
COBJFLAGS += -x objective-c++
# this speeds it up a bit by piping between the preprocessor/compiler/assembler
CCOMFLAGS += -pipe
# add the optimization flag
CCOMFLAGS += -O$(OPTIMIZE)
# add the error warning flag
ifndef NOWERROR
CCOMFLAGS += -Werror
endif
# if we are optimizing, include optimization options
ifneq ($(OPTIMIZE),0)
CCOMFLAGS += -fno-strict-aliasing $(ARCHOPTS)
endif
# add a basic set of warnings
CCOMFLAGS += \
-Wall \
-Wcast-align \
-Wundef \
-Wformat-security \
-Wwrite-strings \
-Wno-sign-compare \
-Wno-conversion
# warnings only applicable to C compiles
CONLYFLAGS += \
-Wpointer-arith \
-Wbad-function-cast \
-Wstrict-prototypes
# warnings only applicable to OBJ-C compiles
COBJFLAGS += \
-Wpointer-arith
# warnings only applicable to C++ compiles
CPPONLYFLAGS += \
-Woverloaded-virtual
ifneq (,$(findstring clang,$(CC)))
CCOMFLAGS += \
-Wno-cast-align \
-Wno-tautological-compare \
-Wno-constant-logical-operand \
-Wno-format-security \
-Wno-shift-count-overflow \
-Wno-self-assign-field
endif
#-------------------------------------------------
# include paths
#-------------------------------------------------
# add core include paths
INCPATH += \
-I$(SRC)/$(TARGET) \
-I$(OBJ)/$(TARGET)/layout \
-I$(SRC)/emu \
-I$(OBJ)/emu \
-I$(OBJ)/emu/layout \
-I$(SRC)/lib/util \
-I$(SRC)/lib \
-I$(SRC)/osd \
-I$(SRC)/osd/$(OSD) \
#-------------------------------------------------
# archiving flags
#-------------------------------------------------
#-------------------------------------------------
# linking flags
#-------------------------------------------------
#-------------------------------------------------
# define the standard object directory; other
# projects can add their object directories to
# this variable
#-------------------------------------------------
OBJDIRS = $(OBJ) $(OBJ)/$(TARGET)/$(SUBTARGET)
#-------------------------------------------------
# define standard libarires for CPU and sounds
#-------------------------------------------------
LIBEMU = $(OBJ)/libemu.a
LIBOPTIONAL = $(OBJ)/$(TARGET)/$(SUBTARGET)/liboptional.a
LIBDASM = $(OBJ)/$(TARGET)/$(SUBTARGET)/libdasm.a
LIBBUS = $(OBJ)/$(TARGET)/$(SUBTARGET)/libbus.a
LIBUTIL = $(OBJ)/libutil.a
LIBOCORE = $(OBJ)/libocore.a
LIBOSD = $(OBJ)/osd/retro/retromain.o $(OSDOBJS)
VERSIONOBJ = $(OBJ)/version.o
EMUINFOOBJ = $(OBJ)/$(TARGET)/$(TARGET).o
DRIVLISTSRC = $(OBJ)/$(TARGET)/$(SUBTARGET)/drivlist.c
DRIVLISTOBJ = $(OBJ)/$(TARGET)/$(SUBTARGET)/drivlist.o
#-------------------------------------------------
# either build or link against the included
# libraries
#-------------------------------------------------
# add expat XML library
ifeq ($(BUILD_EXPAT),1)
INCPATH += -I$(SRC)/lib/expat
EXPAT = $(OBJ)/libexpat.a
else
LIBS += -lexpat
EXPAT =
endif
# add ZLIB compression library
ifeq ($(BUILD_ZLIB),1)
INCPATH += -I$(SRC)/lib/zlib
ZLIB = $(OBJ)/libz.a
else
LIBS += -lz
ZLIB =
endif
# add flac library
ifeq ($(BUILD_FLAC),1)
INCPATH += -I$(SRC)/lib/util
FLAC_LIB = $(OBJ)/libflac.a
# $(OBJ)/libflac++.a
else
LIBS += -lFLAC
FLAC_LIB =
endif
# add jpeglib image library
ifeq ($(BUILD_JPEGLIB),1)
INCPATH += -I$(SRC)/lib/libjpeg
JPEG_LIB = $(OBJ)/libjpeg.a
else
LIBS += -ljpeg
JPEG_LIB =
endif
# add SoftFloat floating point emulation library
SOFTFLOAT = $(OBJ)/libsoftfloat.a
# add formats emulation library
FORMATS_LIB = $(OBJ)/libformats.a
# add LUA library
LUA_LIB = $(OBJ)/liblua.a
# add PortMidi MIDI library
ifeq ($(BUILD_MIDILIB),1)
INCPATH += -I$(SRC)/lib/portmidi
MIDI_LIB = $(OBJ)/libportmidi.a
else
#LIBS += -lportmidi
MIDI_LIB =
endif
#-------------------------------------------------
# 'default' target needs to go here, before the
# include files which define additional targets
#-------------------------------------------------
default: maketree buildtools emulator
all: default tools
tests: maketree jedutil$(EXE_EXT) chdman$(EXE_EXT)
7Z_LIB = $(OBJ)/lib7z.a
#-------------------------------------------------
# defines needed by multiple make files
#-------------------------------------------------
BUILDSRC = $(SRC)/build
BUILDOBJ = $(OBJ)/build
BUILDOUT = $(BUILDOBJ)
#-------------------------------------------------
# include the various .mak files
#-------------------------------------------------
# include OSD-specific rules first
include $(SRC)/osd/$(OSD)/$(OSD).mak
# then the various core pieces
include $(SRC)/build/build.mak
include $(SRC)/$(TARGET)/$(SUBTARGET).mak
-include $(SRC)/$(TARGET)/osd/$(OSD)/$(OSD).mak
include $(SRC)/emu/emu.mak
include $(SRC)/lib/lib.mak
-include $(SRC)/osd/$(CROSS_BUILD_OSD)/build.mak
include $(SRC)/tools/tools.mak
include $(SRC)/regtests/regtests.mak
# combine the various definitions to one
CCOMFLAGS += $(INCPATH)
CDEFS = $(DEFS)
#-------------------------------------------------
# primary targets
#-------------------------------------------------
emulator: maketree $(BUILD) $(EMULATOR)
buildtools: maketree $(BUILD)
ifeq ($(NATIVE),1)
mkdir prec-build
cp -R $(OBJ)/build/* prec-build/
$(RM) -r $(OBJ)/osd
$(RM) -r $(OBJ)/lib/util
$(RM) -r $(OBJ)/libutil.a
$(RM) -r $(OBJ)/libocore.a
endif
tools: maketree $(TOOLS)
maketree: $(sort $(OBJDIRS))
clean: $(OSDCLEAN)
ifeq ($(PARTIAL),1)
@echo Deleting object tree $(OBJ)...
$(RM) -r obj/osd/*
@echo Deleting $(EMULATOR)...
$(RM) $(EMULATOR)
@echo Deleting $(TOOLS)...
$(RM) $(TOOLS)
@echo Deleting dependencies...
$(RM) depend_mame.mak
$(RM) depend_mess.mak
$(RM) depend_ume.mak
else
@echo Deleting object tree $(OBJ)...
$(RM) -r obj/*
@echo Deleting $(EMULATOR)...
$(RM) $(EMULATOR)
@echo Deleting $(TOOLS)...
$(RM) $(TOOLS)
@echo Deleting dependencies...
$(RM) depend_mame.mak
$(RM) depend_mess.mak
$(RM) depend_ume.mak
endif
checkautodetect:
@echo TARGETOS=$(TARGETOS)
@echo PTR64=$(PTR64)
@echo BIGENDIAN=$(BIGENDIAN)
@echo UNAME="$(UNAME)"
tests: $(REGTESTS)
#-------------------------------------------------
# directory targets
#-------------------------------------------------
$(sort $(OBJDIRS)):
$(MD) -p $@
BUILDTOOLS_CUSTOM = 0
ifeq ($(platform), android)
BUILDTOOLS_CUSTOM = 1
else ifeq ($(platform), ios)
BUILDTOOLS_CUSTOM = 1
endif
ifeq ($(NATIVE),0)
ifeq ($(BUILDTOOLS_CUSTOM),1)
$(OBJ)/build/file2str:
mkdir -p $(OBJ)/build
cp -R prec-build/file2str $(OBJ)/build
$(OBJ)/build/m68kmake:
cp -R prec-build/m68kmake $(OBJ)/build
$(OBJ)/build/png2bdc:
cp -R prec-build/png2bdc $(OBJ)/build
$(OBJ)/build/makedep:
cp -R prec-build/makedep $(OBJ)/build
$(OBJ)/build/makelist:
cp -R prec-build/makelist $(OBJ)/build
$(OBJ)/build/verinfo:
cp -R prec-build/verinfo $(OBJ)/build
$(OBJ)/build/makemak:
cp -R prec-build/makemak $(OBJ)/build
endif
endif
#-------------------------------------------------
# executable targets and dependencies
#-------------------------------------------------
$(EMULATOR): $(EMUINFOOBJ) $(DRIVLISTOBJ) $(DRVLIBS) $(LIBOSD) $(LIBBUS) $(LIBOPTIONAL) $(LIBEMU) $(LIBDASM) $(LIBUTIL) $(EXPAT) $(SOFTFLOAT) $(JPEG_LIB) $(FLAC_LIB) $(7Z_LIB) $(FORMATS_LIB) $(LUA_LIB) $(ZLIB) $(LIBOCORE) $(MIDI_LIB) $(RESFILE)
$(CC) $(CDEFS) $(CFLAGS) -c $(SRC)/version.c -o $(VERSIONOBJ)
@echo Linking $(TARGETLIB)
$(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) $(VERSIONOBJ) $^ $(LIBS) -o $(TARGETLIB)
#-------------------------------------------------
# generic rules
#-------------------------------------------------
ifeq ($(armplatform), 1)
$(LIBCOOBJ)/armeabi_asm.o:
$(CC_AS) -c $(SRC)/osd/$(OSD)/libco/armeabi_asm.S -o $(LIBCOOBJ)/armeabi_asm.o
endif
$(OBJ)/%.o: $(SRC)/%.c | $(OSPREBUILD)
$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
$(OBJ)/%.o: $(OBJ)/%.c | $(OSPREBUILD)
$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
$(OBJ)/%.pp: $(SRC)/%.c | $(OSPREBUILD)
$(CC) $(CDEFS) $(CFLAGS) -E $< -o $@
$(OBJ)/%.s: $(SRC)/%.c | $(OSPREBUILD)
$(CC) $(CDEFS) $(CFLAGS) -S $< -o $@
$(OBJ)/%.lh: $(SRC)/%.lay $(FILE2STR_TARGET)
@echo Converting $<...
@$(FILE2STR) $< $@ layout_$(basename $(notdir $<))
$(OBJ)/%.fh: $(SRC)/%.png $(PNG2BDC_TARGET) $(FILE2STR_TARGET)
@echo Converting $<...
@$(PNG2BDC) $< $(OBJ)/temp.bdc
@$(FILE2STR) $(OBJ)/temp.bdc $@ font_$(basename $(notdir $<)) UINT8
$(DRIVLISTOBJ): $(DRIVLISTSRC)
$(CC) $(CDEFS) $(CFLAGS) -c $< -o $@
$(DRIVLISTSRC): $(SRC)/$(TARGET)/$(SUBTARGET).lst $(MAKELIST_TARGET)
@echo Building driver list $<...
@$(MAKELIST) $< >$@
$(OBJ)/%.a:
@echo Archiving $@...
$(RM) $@
$(AR) $(ARFLAGS) $@ $^
-include depend_emu.mak
-include depend_$(TARGET).mak