summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/sdl/sdl.mak
blob: 2f188762da5cae0209ee282c506078a3c1180f17 (plain) (blame)
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
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
###########################################################################
#
#   sdl.mak
#
#   SDL-specific makefile
#
#   Copyright (c) 1996-2013, Nicola Salmoria and the MAME Team.
#   Visit http://mamedev.org for licensing and usage restrictions.
#
#   SDLMAME by Olivier Galibert and R. Belmont
#
###########################################################################

###########################################################################
#################   BEGIN USER-CONFIGURABLE OPTIONS   #####################
###########################################################################


#-------------------------------------------------
# specify build options; see each option below
# for details
#-------------------------------------------------

# uncomment and edit next line to specify a distribution
# supported debian-stable, ubuntu-intrepid

# DISTRO = debian-stable
# DISTRO = ubuntu-intrepid
# DISTRO = gcc44-generic

# uncomment next line to build without OpenGL support

# NO_OPENGL = 1

# uncomment next line to build without X11 support (TARGETOS=unix only)
# this also implies, that no debugger will be builtin.

# NO_X11 = 1

# uncomment next line to disable XInput support for e.g. multiple lightguns and mice on X11 systems
# using Wiimote driver (see http://spritesmods.com/?art=wiimote-mamegun for more info)
# enabling NO_X11 also implies no XInput support, of course.
# (currently defaults disabled due to causing issues with mouse capture, esp. in MESS)

NO_USE_XINPUT = 1

# uncomment and adapt next line to link against specific GL-Library
# this will also add a rpath to the executable
# MESA_INSTALL_ROOT = /usr/local/dfb_GL

# uncomment the next line to build a binary using GL-dispatching.
# This option takes precedence over MESA_INSTALL_ROOT

USE_DISPATCH_GL = 1

# The following settings are currently supported for unix only.
# There is no need to play with this option unless you are doing
# active development on sdlmame or SDL.

# uncomment the next line to use couriersud's multi-keyboard patch for SDL 2.1? (this API was removed prior to the 2.0 release)
# SDL2_MULTIAPI = 1

# uncomment the next line to specify where you have installed
# SDL. Equivalent to the ./configure --prefix=<path>
# SDL_INSTALL_ROOT = /usr/local/sdl20

# uncomment to disable the Qt debugger (on non-OSX this disables all debugging)
# NO_USE_QTDEBUG = 1

# uncomment to disable MIDI
# NO_USE_MIDI = 1

# uncomment to disable implementations based on assembler code
# NOASM = 1

# change for custom OS X installations
SDL_FRAMEWORK_PATH = /Library/Frameworks/

# uncomment to use SDL1.2 (depracated)
# SDL_LIBVER = sdl

# uncomment to use BGFX

# USE_BGFX = 1

###########################################################################
##################   END USER-CONFIGURABLE OPTIONS   ######################
###########################################################################
OSDSRC = $(SRC)/osd
OSDOBJ = $(OBJ)/osd

# add a define identifying the target osd
DEFS += -DOSD_SDL

# default to SDL2 for non-OS/2 builds now
ifndef SDL_LIBVER
ifneq ($(TARGETOS),os2)
SDL_LIBVER = sdl2
else
SDL_LIBVER = sdl
endif
endif

ifndef NO_USE_QTDEBUG
OBJDIRS += $(OSDOBJ)/modules/debugger/qt
endif

ifdef SDL_INSTALL_ROOT
SDL_CONFIG = $(SDL_INSTALL_ROOT)/bin/$(SDL_LIBVER)-config
else
SDL_CONFIG = $(SDL_LIBVER)-config
endif

ifeq ($(SDL_LIBVER),sdl2)
DEFS += -DSDLMAME_SDL2=1
	ifeq ($(SDL2_MULTIAPI),1)
	DEFS += -DSDL2_MULTIAPI
	endif
else
DEFS += -DSDLMAME_SDL2=0
endif

# minimal preliminary ARM support
ifeq ($(findstring arm,$(UNAME)),arm)
	NOASM = 1
	DEFS += -DSDLMAME_ARM
endif

ifdef NOASM
DEFS += -DSDLMAME_NOASM
endif

# patch up problems with new zlib
DEFS += -D_LFS64_LARGEFILE=0

# bring in external flags for RPM build
CCOMFLAGS += $(OPT_FLAGS)

#-------------------------------------------------
# distribution may change things
#-------------------------------------------------

ifeq ($(DISTRO),)
DISTRO = generic
else
ifeq ($(DISTRO),debian-stable)
DEFS += -DNO_AFFINITY_NP
else
ifeq ($(DISTRO),ubuntu-intrepid)
# Force gcc-4.2 on ubuntu-intrepid
CC = @gcc -V 4.2
LD = @g++-4.2
else
ifeq ($(DISTRO),gcc44-generic)
CC = @gcc-4.4
LD = @g++-4.4
else
ifeq ($(DISTRO),gcc45-generic)
CC = @gcc-4.5
LD = @g++-4.5
else
ifeq ($(DISTRO),gcc46-generic)
CC = @gcc-4.6
LD = @g++-4.6
else
ifeq ($(DISTRO),gcc47-generic)
CC = @gcc-4.7
LD = @g++-4.7
else
$(error DISTRO $(DISTRO) unknown)
endif
endif
endif
endif
endif
endif
endif

DEFS += -DDISTRO=$(DISTRO)

#-------------------------------------------------
# sanity check the configuration
#-------------------------------------------------

ifdef BIGENDIAN
X86_MIPS3_DRC =
X86_PPC_DRC =
FORCE_DRC_C_BACKEND = 1
endif

ifdef NOASM
X86_MIPS3_DRC =
X86_PPC_DRC =
FORCE_DRC_C_BACKEND = 1
endif

#-------------------------------------------------
# compile and linking flags
#-------------------------------------------------

# add SDLMAME BASE_TARGETOS definitions

ifeq ($(TARGETOS),unix)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = tc
endif

ifeq ($(TARGETOS),linux)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = tc
SDL_NETWORK = taptun

ifndef NO_USE_MIDI
ALSACFLAGS := $(shell pkg-config --cflags alsa)
ALSALIBS := $(shell pkg-config --libs alsa)

INCPATH += $(ALSACFLAGS)
LIBS += $(ALSALIBS)
endif

endif

ifeq ($(TARGETOS),freebsd)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = tc
DEFS += -DNO_AFFINITY_NP
LIBS += -lutil
# /usr/local/include is not considered a system include directory
# on FreeBSD. GL.h resides there and throws warnings
CCOMFLAGS += -isystem /usr/local/include
NO_USE_MIDI = 1
endif

ifeq ($(TARGETOS),openbsd)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = ntc
LIBS += -lutil
NO_USE_MIDI = 1
endif

ifeq ($(TARGETOS),netbsd)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = ntc
LIBS += -lutil
NO_USE_MIDI = 1
SDL_NETWORK = pcap
endif

ifeq ($(TARGETOS),solaris)
BASE_TARGETOS = unix
#DEFS += -DNO_AFFINITY_NP -UHAVE_VSNPRINTF -DNO_vsnprintf
DEFS += -DNO_AFFINITY_NP
SYNC_IMPLEMENTATION = tc
NO_USE_MIDI = 1
NO_USE_QTDEBUG = 1
endif

ifeq ($(TARGETOS),haiku)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = ntc
NO_X11 = 1
NO_USE_XINPUT = 1
NO_USE_MIDI = 1
NO_USE_QTDEBUG = 1
LIBS += -lnetwork -lbsd
endif

ifeq ($(TARGETOS),emscripten)
BASE_TARGETOS = unix
SYNC_IMPLEMENTATION = mini
NO_DEBUGGER = 1
NO_X11 = 1
NO_USE_XINPUT = 1
NO_USE_MIDI = 1
NO_USE_QTDEBUG = 1
DONT_USE_NETWORK = 1
endif

ifeq ($(TARGETOS),macosx)
NO_USE_QTDEBUG = 1
BASE_TARGETOS = unix
DEFS += -DSDLMAME_UNIX -DSDLMAME_MACOSX -DSDLMAME_DARWIN

ifndef NO_USE_MIDI
LIBS += -framework CoreAudio -framework CoreMIDI
endif

ifdef NO_USE_QTDEBUG

OBJDIRS += $(OSDOBJ)/modules/debugger/osx

DEBUGOBJS = \
	$(OSDOBJ)/modules/debugger/debugosx.o \
	$(OSDOBJ)/modules/debugger/osx/breakpointsview.o \
	$(OSDOBJ)/modules/debugger/osx/consoleview.o \
	$(OSDOBJ)/modules/debugger/osx/debugcommandhistory.o \
	$(OSDOBJ)/modules/debugger/osx/debugconsole.o \
	$(OSDOBJ)/modules/debugger/osx/debugview.o \
	$(OSDOBJ)/modules/debugger/osx/debugwindowhandler.o \
	$(OSDOBJ)/modules/debugger/osx/deviceinfoviewer.o \
	$(OSDOBJ)/modules/debugger/osx/devicesviewer.o \
	$(OSDOBJ)/modules/debugger/osx/disassemblyview.o \
	$(OSDOBJ)/modules/debugger/osx/disassemblyviewer.o \
	$(OSDOBJ)/modules/debugger/osx/errorlogview.o \
	$(OSDOBJ)/modules/debugger/osx/errorlogviewer.o \
	$(OSDOBJ)/modules/debugger/osx/memoryview.o \
	$(OSDOBJ)/modules/debugger/osx/memoryviewer.o \
	$(OSDOBJ)/modules/debugger/osx/pointsviewer.o \
	$(OSDOBJ)/modules/debugger/osx/registersview.o \
	$(OSDOBJ)/modules/debugger/osx/watchpointsview.o

endif

SYNC_IMPLEMENTATION = ntc

# SDLMain_tmpl isn't necessary for SDL2
ifneq ($(SDL_LIBVER),sdl2)
SDLMAIN = $(SDLOBJ)/SDLMain_tmpl.o
SDLUTILMAIN = $(SDLOBJ)/SDLMain_tmpl.o
endif

SDL_NETWORK = pcap
MAINLDFLAGS = -Xlinker -all_load
NO_X11 = 1
NO_USE_XINPUT = 1

ifdef BIGENDIAN
DEFS += -DOSX_PPC=1
CCOMFLAGS += -Wno-unused-label
ifdef SYMBOLS
CCOMFLAGS += -mlong-branch
endif   # SYMBOLS
ifeq ($(PTR64),1)
CCOMFLAGS += -arch ppc64
LDFLAGS += -arch ppc64
else
CCOMFLAGS += -arch ppc
LDFLAGS += -arch ppc
endif
$(OBJ)/emu/cpu/tms57002/tms57002.o : CCOMFLAGS += -O0
else    # BIGENDIAN
ifeq ($(PTR64),1)
CCOMFLAGS += -arch x86_64
LDFLAGS += -arch x86_64
else
CCOMFLAGS += -m32 -arch i386
LDFLAGS += -m32 -arch i386
endif
endif   # BIGENDIAN

endif

ifeq ($(TARGETOS),win32)
BASE_TARGETOS = win32
SYNC_IMPLEMENTATION = windows
NO_X11 = 1
NO_USE_XINPUT = 1
DEFS += -DSDLMAME_WIN32 -DX64_WINDOWS_ABI
LIBGL = -lopengl32
SDLMAIN = $(SDLOBJ)/main.o
# needed for unidasm
LDFLAGS += -Wl,--allow-multiple-definition
SDL_NETWORK = pcap
INCPATH += -I$(3RDPARTY)/winpcap/Include

# enable UNICODE
DEFS += -Dmain=utf8_main -DUNICODE -D_UNICODE
LDFLAGS += -municode

# Qt
ifndef NO_USE_QTDEBUG
QT_INSTALL_HEADERS = $(shell qmake -query QT_INSTALL_HEADERS)
INCPATH += -I$(QT_INSTALL_HEADERS)/QtCore -I$(QT_INSTALL_HEADERS)/QtGui -I$(QT_INSTALL_HEADERS)
BASELIBS += -lcomdlg32 -loleaut32 -limm32 -lwinspool -lmsimg32 -lole32 -luuid -lws2_32 -lshell32 -lkernel32
LIBS += -L$(shell qmake -query QT_INSTALL_LIBS) -lqtmain -lQtGui4 -lQtCore4 -lcomdlg32 -loleaut32 -limm32 -lwinspool -lmsimg32 -lole32 -luuid -lws2_32 -lshell32 -lkernel32
endif
endif

ifeq ($(TARGETOS),macosx)
ifndef NO_USE_QTDEBUG
MOC = @moc

QT_INSTALL_LIBS = $(shell qmake -query QT_INSTALL_LIBS)
INCPATH += -I$(QT_INSTALL_LIBS)/QtGui.framework/Versions/4/Headers -I$(QT_INSTALL_LIBS)/QtCore.framework/Versions/4/Headers -F$(QT_INSTALL_LIBS)
LIBS += -L$(QT_INSTALL_LIBS) -F$(QT_INSTALL_LIBS) -framework QtCore -framework QtGui
endif
endif

ifeq ($(TARGETOS),os2)
BASE_TARGETOS = os2
DEFS += -DSDLMAME_OS2
SYNC_IMPLEMENTATION = os2
NO_DEBUGGER = 1
NO_X11 = 1
NO_USE_XINPUT = 1
NO_USE_MIDI = 1
NO_USE_QTDEBUG = 1
# OS/2 can't have OpenGL (aww)
NO_OPENGL = 1
endif

#-------------------------------------------------
# Sanity checks
#-------------------------------------------------

ifeq ($(BASE_TARGETOS),)
$(error $(TARGETOS) not supported !)
endif

# if no Qt and not OS X, no debugger
ifneq ($(TARGETOS),macosx)
ifdef NO_USE_QTDEBUG
NO_DEBUGGER = 1
endif
endif

#-------------------------------------------------
# object and source roots
#-------------------------------------------------

SDLSRC = $(SRC)/osd/$(OSD)
SDLOBJ = $(OBJ)/osd/$(OSD)

OBJDIRS += $(SDLOBJ) \
	$(OSDOBJ)/modules/sync \
	$(OSDOBJ)/modules/lib \
	$(OSDOBJ)/modules/midi \
	$(OSDOBJ)/modules/font \
	$(OSDOBJ)/modules/netdev \
	$(OSDOBJ)/modules/opengl \
	$(OSDOBJ)/modules/render
	
#-------------------------------------------------
# OSD core library
#-------------------------------------------------

OSDCOREOBJS = \
	$(SDLOBJ)/strconv.o \
	$(SDLOBJ)/sdldir.o  \
	$(SDLOBJ)/sdlfile.o     \
	$(SDLOBJ)/sdlptty_$(BASE_TARGETOS).o    \
	$(SDLOBJ)/sdlsocket.o   \
	$(SDLOBJ)/sdlos_$(SDLOS_TARGETOS).o \
	$(OSDOBJ)/modules/lib/osdlib_$(SDLOS_TARGETOS).o \
	$(OSDOBJ)/modules/sync/sync_$(SYNC_IMPLEMENTATION).o \
	$(OSDOBJ)/modules/osdmodule.o \

ifdef NOASM
OSDCOREOBJS += $(OSDOBJ)/modules/sync/work_mini.o
else
OSDCOREOBJS += $(OSDOBJ)/modules/sync/work_osd.o
endif

# any "main" must be in LIBOSD or else the build will fail!
# for the windows build, we just add it to libocore as well.
OSDOBJS = \
	$(SDLMAIN) \
	$(SDLOBJ)/sdlmain.o \
	$(SDLOBJ)/input.o \
	$(OSDOBJ)/modules/sound/js_sound.o  \
	$(OSDOBJ)/modules/sound/direct_sound.o  \
	$(OSDOBJ)/modules/sound/sdl_sound.o  \
	$(OSDOBJ)/modules/sound/none.o  \
	$(SDLOBJ)/video.o \
	$(SDLOBJ)/window.o \
	$(SDLOBJ)/output.o \
	$(SDLOBJ)/watchdog.o \
	$(OSDOBJ)/modules/lib/osdobj_common.o  \
	$(OSDOBJ)/modules/font/font_sdl.o \
	$(OSDOBJ)/modules/font/font_windows.o \
	$(OSDOBJ)/modules/font/font_osx.o \
	$(OSDOBJ)/modules/font/font_none.o \
	$(OSDOBJ)/modules/netdev/taptun.o \
	$(OSDOBJ)/modules/netdev/pcap.o \
	$(OSDOBJ)/modules/netdev/none.o \
	$(OSDOBJ)/modules/midi/portmidi.o \
	$(OSDOBJ)/modules/midi/none.o \
	$(OSDOBJ)/modules/render/drawsdl.o \

ifdef NO_USE_MIDI
	DEFS += -DNO_USE_MIDI
else
endif

# Add SDL2.0 support

ifeq ($(SDL_LIBVER),sdl2)
OSDOBJS += $(OSDOBJ)/modules/render/draw13.o
endif

# add an ARCH define
DEFS += -DSDLMAME_ARCH="$(ARCHOPTS)" -DSYNC_IMPLEMENTATION=$(SYNC_IMPLEMENTATION)

#-------------------------------------------------
# Generic defines and additions
#-------------------------------------------------

OSDCLEAN = sdlclean

# copy off the include paths before the sdlprefix & sdl-config stuff shows up
MOCINCPATH := $(INCPATH)

# add the prefix file
INCPATH += -include $(SDLSRC)/sdlprefix.h


#-------------------------------------------------
# BASE_TARGETOS specific configurations
#-------------------------------------------------

SDLOS_TARGETOS = $(BASE_TARGETOS)

#-------------------------------------------------
# TEST_GCC for GCC version-specific stuff
#-------------------------------------------------

ifneq ($(TARGETOS),emscripten)
TEST_GCC = $(shell gcc --version)

# Ubuntu 12.10 GCC 4.7.2 autodetect
ifeq ($(findstring 4.7.2-2ubuntu1,$(TEST_GCC)),4.7.2-2ubuntu1)
GCC46TST = $(shell which g++-4.6 2>/dev/null)
ifeq '$(GCC46TST)' ''
$(error Ubuntu 12.10 detected.  Please install the gcc-4.6 and g++-4.6 packages)
endif
CC = @gcc-4.6
LD = @g++-4.6
endif
endif

include $(SRC)/build/cc_detection.mak

#-------------------------------------------------
# Unix
#-------------------------------------------------
ifeq ($(BASE_TARGETOS),unix)

#-------------------------------------------------
# Mac OS X
#-------------------------------------------------

ifeq ($(TARGETOS),macosx)
OSDCOREOBJS += $(SDLOBJ)/osxutils.o
SDLOS_TARGETOS = macosx

ifeq ($(TARGET),mame)
MACOSX_EMBED_INFO_PLIST = 1
endif
ifeq ($(TARGET),mess)
MACOSX_EMBED_INFO_PLIST = 1
endif
ifeq ($(TARGET),ume)
MACOSX_EMBED_INFO_PLIST = 1
endif
ifdef MACOSX_EMBED_INFO_PLIST
INFOPLIST = $(SDLOBJ)/$(TARGET)-Info.plist
LDFLAGSEMULATOR += -sectcreate __TEXT __info_plist $(INFOPLIST)
$(EMULATOR): $(INFOPLIST)
$(INFOPLIST): $(SRC)/build/verinfo.py $(SRC)/version.c
	@echo Emitting $@...
	$(PYTHON) $(SRC)/build/verinfo.py -b $(TARGET) -p -o $@ $(SRC)/version.c
endif

ifndef MACOSX_USE_LIBSDL
# Compile using framework (compile using libSDL is the exception)
ifeq ($(SDL_LIBVER),sdl2)
LIBS += -F$(SDL_FRAMEWORK_PATH) -framework SDL2 -framework Cocoa -framework OpenGL -lpthread
BASELIBS += -F$(SDL_FRAMEWORK_PATH) -framework SDL2 -framework Cocoa -framework OpenGL -lpthread
else
LIBS += -F$(SDL_FRAMEWORK_PATH) -framework SDL -framework Cocoa -framework OpenGL -lpthread
BASELIBS += -F$(SDL_FRAMEWORK_PATH) -framework SDL -framework Cocoa -framework OpenGL -lpthread
endif
INCPATH += -F$(SDL_FRAMEWORK_PATH)
else
# Compile using installed libSDL (Fink or MacPorts):
#
# Remove the "/SDL" component from the include path so that we can compile

# files (header files are #include "SDL/something.h", so the extra "/SDL"
# causes a significant problem)
SDLCFLAGS := $(shell $(SDL_CONFIG) --cflags | sed 's:/SDL::')
# Remove libSDLmain, as its symbols conflict with SDLMain_tmpl.m
SDLLIBS := $(shell $(SDL_CONFIG) --libs | sed 's/-lSDLmain//')

INCPATH += $(SDLCFLAGS)
CCOMFLAGS += -DNO_SDL_GLEXT
LIBS += $(SDLLIBS) -lpthread -framework Cocoa -framework OpenGL
BASELIBS += $(SDLLIBS) -lpthread -framework Cocoa -framework OpenGL
DEFS += -DMACOSX_USE_LIBSDL
endif   # MACOSX_USE_LIBSDL

else   # ifeq ($(TARGETOS),macosx)

DEFS += -DSDLMAME_UNIX

ifndef NO_USE_QTDEBUG
MOCTST = $(shell which moc-qt4 2>/dev/null)
ifeq '$(MOCTST)' ''
MOCTST = $(shell which moc 2>/dev/null)
ifeq '$(MOCTST)' ''
$(error Qt's Meta Object Compiler (moc) wasn't found!)
else
MOC = @$(MOCTST)
endif
else
MOC = @$(MOCTST)
endif
# Qt on Linux/UNIX
QMAKE = $(shell which qmake-qt4 2>/dev/null)
ifeq '$(QMAKE)' ''
QMAKE = $(shell which qmake 2>/dev/null)
ifeq '$(QMAKE)' ''
$(error qmake wasn't found!)
endif
endif
QT_INSTALL_HEADERS = $(shell $(QMAKE) -query QT_INSTALL_HEADERS)
INCPATH += -I$(QT_INSTALL_HEADERS)/QtCore -I$(QT_INSTALL_HEADERS)/QtGui -I$(QT_INSTALL_HEADERS)
LIBS += -L$(shell $(QMAKE) -query QT_INSTALL_LIBS) -lQtGui -lQtCore
endif

LIBGL = -lGL

ifeq ($(NO_X11),1)
NO_DEBUGGER = 1
endif

SDLINCLUDES := $(shell $(SDL_CONFIG) --cflags  | sed -e 's:/SDL[2]*::' -e 's:\(-D[^ ]*\)::g')
SDLDEFINES := $(shell $(SDL_CONFIG) --cflags  | sed -e 's:/SDL[2]*::' -e 's:\(-I[^ ]*\)::g')
SDLLIBS := $(shell $(SDL_CONFIG) --libs)

INCPATH += $(SDLINCLUDES)
CCOMFLAGS += $(SDLDEFINES)
BASELIBS += $(SDLLIBS)
LIBS += $(SDLLIBS)

ifeq ($(SDL_LIBVER),sdl2)
ifdef SDL_INSTALL_ROOT
# FIXME: remove the directfb ref. later. This is just there for now to work around an issue with SDL1.3 and SDL2.0
INCPATH += -I$(SDL_INSTALL_ROOT)/include/directfb
endif
endif

FONTCONFIGCFLAGS := $(shell pkg-config --cflags fontconfig)
FONTCONFIGLIBS := $(shell pkg-config --libs fontconfig)

ifneq ($(TARGETOS),emscripten)
INCPATH += $(FONTCONFIGCFLAGS)
endif
LIBS += $(FONTCONFIGLIBS)

ifeq ($(SDL_LIBVER),sdl2)
LIBS += -lSDL2_ttf
else
LIBS += -lSDL_ttf
endif

# FIXME: should be dealt with elsewhere
# libs that Haiku doesn't want but are mandatory on *IX
ifneq ($(TARGETOS),haiku)
BASELIBS += -lm -lpthread
LIBS += -lm -lpthread
ifneq ($(TARGETOS),solaris)
BASELIBS += -lutil
LIBS += -lutil
else
SUPPORTSM32M64 = 1
BASELIBS += -lsocket -lnsl
LIBS += -lsocket -lnsl
endif
endif


endif # not Mac OS X

ifneq (,$(findstring ppc,$(UNAME)))
# override for preprocessor weirdness on PPC Linux
CFLAGS += -Upowerpc
SUPPORTSM32M64 = 1
endif

ifneq (,$(findstring amd64,$(UNAME)))
SUPPORTSM32M64 = 1
endif
ifneq (,$(findstring x86_64,$(UNAME)))
SUPPORTSM32M64 = 1
endif
ifneq (,$(findstring i386,$(UNAME)))
SUPPORTSM32M64 = 1
endif

ifeq ($(SUPPORTSM32M64),1)
ifeq ($(PTR64),1)
CCOMFLAGS += -m64
LDFLAGS += -m64
else
CCOMFLAGS += -m32
LDFLAGS += -m32
endif
endif

endif # Unix

#-------------------------------------------------
# Windows
#-------------------------------------------------

# Win32: add the necessary libraries
ifeq ($(BASE_TARGETOS),win32)

# Add to osdcoreobjs so tools will build
OSDCOREOBJS += $(SDLMAIN)

ifdef SDL_INSTALL_ROOT
INCPATH += -I$(SDL_INSTALL_ROOT)/include
LIBS += -L$(SDL_INSTALL_ROOT)/lib
#-Wl,-rpath,$(SDL_INSTALL_ROOT)/lib
endif

# LIBS += -lmingw32 -lSDL
# Static linking

LDFLAGS += -static-libgcc
ifeq (,$(findstring clang,$(CC)))
ifeq ($(findstring 4.4,$(TEST_GCC)),)
	#if we use new tools
	LDFLAGS += -static-libstdc++
endif
endif

ifndef NO_USE_QTDEBUG
MOC = @moc
endif

ifeq ($(SDL_LIBVER),sdl2)
LIBS += -lSDL2 -limm32 -lversion -lole32 -loleaut32 -lws2_32 -static
BASELIBS += -lSDL2 -limm32 -lversion -lole32 -loleaut32 -lws2_32 -static
else
LIBS += -lSDL -lws2_32 -static
BASELIBS += -lSDL -lws2_32 -static
endif
LIBS += -luser32 -lgdi32 -lddraw -ldsound -ldxguid -lwinmm -ladvapi32 -lcomctl32 -lshlwapi
BASELIBS += -luser32 -lgdi32 -lddraw -ldsound -ldxguid -lwinmm -ladvapi32 -lcomctl32 -lshlwapi
endif   # Win32

#-------------------------------------------------
# OS/2
#-------------------------------------------------

ifeq ($(BASE_TARGETOS),os2)

SDLCFLAGS := $(shell sdl-config --cflags)
SDLLIBS := $(shell sdl-config --libs)

INCPATH += $(SDLCFLAGS)
LIBS += $(SDLLIBS) -lpthread
BASELIBS += $(SDLLIBS) -lpthread

endif # OS2

#-------------------------------------------------
# Debugging
#-------------------------------------------------

ifndef NO_USE_QTDEBUG
$(OSDOBJ)/%.moc.c: $(OSDSRC)/%.h
	$(MOC) $(MOCINCPATH) $< -o $@

DEBUGOBJS = \
	$(OSDOBJ)/modules/debugger/qt/debuggerview.o \
	$(OSDOBJ)/modules/debugger/qt/windowqt.o \
	$(OSDOBJ)/modules/debugger/qt/logwindow.o \
	$(OSDOBJ)/modules/debugger/qt/dasmwindow.o \
	$(OSDOBJ)/modules/debugger/qt/mainwindow.o \
	$(OSDOBJ)/modules/debugger/qt/memorywindow.o \
	$(OSDOBJ)/modules/debugger/qt/breakpointswindow.o \
	$(OSDOBJ)/modules/debugger/qt/deviceswindow.o \
	$(OSDOBJ)/modules/debugger/qt/deviceinformationwindow.o \
	$(OSDOBJ)/modules/debugger/qt/debuggerview.moc.o \
	$(OSDOBJ)/modules/debugger/qt/windowqt.moc.o \
	$(OSDOBJ)/modules/debugger/qt/logwindow.moc.o \
	$(OSDOBJ)/modules/debugger/qt/dasmwindow.moc.o \
	$(OSDOBJ)/modules/debugger/qt/mainwindow.moc.o \
	$(OSDOBJ)/modules/debugger/qt/memorywindow.moc.o \
	$(OSDOBJ)/modules/debugger/qt/breakpointswindow.moc.o \
	$(OSDOBJ)/modules/debugger/qt/deviceswindow.moc.o \
	$(OSDOBJ)/modules/debugger/qt/deviceinformationwindow.moc.o

DEFS += -DUSE_QTDEBUG=1

else
DEFS += -DUSE_QTDEBUG=0
endif

ifeq ($(NO_DEBUGGER),1)
DEFS += -DNO_DEBUGGER
else
OSDOBJS += $(DEBUGOBJS)
endif # NO_DEBUGGER

# Always add these
OSDOBJS += \
	$(OSDOBJ)/modules/debugger/none.o \
	$(OSDOBJ)/modules/debugger/debugint.o \
	$(OSDOBJ)/modules/debugger/debugwin.o \
	$(OSDOBJ)/modules/debugger/debugqt.o

#-------------------------------------------------
# BGFX
#-------------------------------------------------

ifdef USE_BGFX
DEFS += -DUSE_BGFX
OSDOBJS += $(OSDOBJ)/modules/render/drawbgfx.o
INCPATH += -I$(3RDPARTY)/bgfx/include -I$(3RDPARTY)/bx/include
USE_DISPATCH_GL = 0
BGFX_LIB = $(OBJ)/libbgfx.a
endif

#-------------------------------------------------
# OPENGL
#-------------------------------------------------

ifeq ($(NO_OPENGL),1)
DEFS += -DUSE_OPENGL=0
else
OSDOBJS += \
	$(OSDOBJ)/modules/render/drawogl.o \
	$(OSDOBJ)/modules/opengl/gl_shader_tool.o \
	$(OSDOBJ)/modules/opengl/gl_shader_mgr.o
	
DEFS += -DUSE_OPENGL=1
ifeq ($(USE_DISPATCH_GL),1)
DEFS += -DUSE_DISPATCH_GL=1
else
LIBS += $(LIBGL)
endif
endif

ifneq ($(USE_DISPATCH_GL),1)
ifdef MESA_INSTALL_ROOT
LIBS += -L$(MESA_INSTALL_ROOT)/lib
LDFLAGS += -Wl,-rpath=$(MESA_INSTALL_ROOT)/lib
INCPATH += -I$(MESA_INSTALL_ROOT)/include
endif
endif

#-------------------------------------------------
# X11
#-------------------------------------------------

ifeq ($(NO_X11),1)
DEFS += -DSDLMAME_NO_X11
else
# Default libs
DEFS += -DSDLMAME_X11
LIBS += -lX11 -lXinerama
ifneq ($(SDL_LIBVER),sdl2)
BASELIBS += -lX11
endif

# The newer debugger uses QT
ifndef NO_USE_QTDEBUG
QTCFLAGS := $(shell pkg-config --cflags QtGui)
QTLIBS := $(shell pkg-config --libs QtGui)

INCPATH += $(QTCFLAGS)
LIBS += $(QTLIBS)
endif

# some systems still put important things in a different prefix
LIBS += -L/usr/X11/lib -L/usr/X11R6/lib -L/usr/openwin/lib
# make sure we can find X headers
INCPATH += -I/usr/X11/include -I/usr/X11R6/include -I/usr/openwin/include
endif # NO_X11

# can't use native libs with emscripten
ifeq ($(TARGETOS),emscripten)
LIBS =
endif

#-------------------------------------------------
# XInput
#-------------------------------------------------

ifeq ($(NO_USE_XINPUT),1)
DEFS += -DUSE_XINPUT=0
else
DEFS += -DUSE_XINPUT=1 -DUSE_XINPUT_DEBUG=0
LIBS += -lXext -lXi
endif # USE_XINPUT

#-------------------------------------------------
# Network (TAP/TUN)
#-------------------------------------------------

ifndef DONT_USE_NETWORK

ifeq ($(SDL_NETWORK),taptun)

DEFS += -DSDLMAME_NET_TAPTUN
endif

ifeq ($(SDL_NETWORK),pcap)

DEFS += -DSDLMAME_NET_PCAP

# dynamically linked ...
#ifneq ($(TARGETOS),win32)
#LIBS += -lpcap
#endif

endif # ifeq ($(SDL_NETWORK),pcap)

endif # ifndef DONT_USE_NETWORK

#-------------------------------------------------
# Dependencies
#-------------------------------------------------

# due to quirks of using /bin/sh, we need to explicitly specify the current path
CURPATH = ./

ifeq ($(BASE_TARGETOS),os2)
# to avoid name clash of '_brk'
$(OBJ)/emu/cpu/h6280/6280dasm.o : CDEFS += -D__STRICT_ANSI__
endif # OS2

ifeq ($(TARGETOS),solaris)
# solaris only has gcc-4.3 by default and is reporting a false positive
$(OBJ)/emu/video/tms9927.o : CCOMFLAGS += -Wno-error
endif # solaris

# drawSDL depends on the core software renderer, so make sure it exists
$(OSDOBJ)/modules/render/drawsdl.o : $(SRC)/emu/rendersw.inc $(OSDSRC)/modules/render/drawogl.c

# draw13 depends on blit13.h
$(OSDOBJ)/modules/render/draw13.o : $(OSDSRC)/modules/render/blit13.h

#$(OSDCOREOBJS): $(SDLSRC)/sdl.mak

#$(OSDOBJS): $(SDLSRC)/sdl.mak


$(LIBOCORE): $(OSDCOREOBJS)

$(LIBOSD): $(OSDOBJS)


#-------------------------------------------------
# Tools
#-------------------------------------------------

TOOLS += \
	$(BIN)testkeys$(EXE)

$(SDLOBJ)/testkeys.o: $(SDLSRC)/testkeys.c
	@echo Compiling $<...
	$(CC)  $(CFLAGS) $(DEFS) -c $< -o $@

TESTKEYSOBJS = \
	$(SDLOBJ)/testkeys.o \

$(BIN)testkeys$(EXE): $(TESTKEYSOBJS) $(LIBUTIL) $(LIBOCORE) $(SDLUTILMAIN)
	@echo Linking $@...
	$(LD) $(LDFLAGS) $^ $(BASELIBS) -o $@

#-------------------------------------------------
# clean up
#-------------------------------------------------

$(OSDCLEAN):
	@rm -f .depend_*

#-------------------------------------------------
# various support targets
#-------------------------------------------------

testlib:
	@echo LIBS: $(LIBS)
	@echo INCPATH: $(INCPATH)
	@echo DEFS: $(DEFS)
	@echo CORE: $(OSDCOREOBJS)

ifneq ($(TARGETOS),win32)
BUILD_VERSION = $(shell grep 'build_version\[\] =' src/version.c | sed -e "s/.*= \"//g" -e "s/ .*//g")
DISTFILES = test_dist.sh whatsnew.txt whatsnew_$(BUILD_VERSION).txt makefile  docs/ src/
EXCLUDES = -x "*/.svn/*"

zip:
	zip -rq ../mame_$(BUILD_VERSION).zip $(DISTFILES) $(EXCLUDES)

endif