########################################################################### # # makefile.sdl # # Core makefile for building MESS and derivatives # ########################################################################### ########################################################################### ################# BEGIN USER-CONFIGURABLE OPTIONS ##################### ########################################################################### #------------------------------------------------- # specify core target: mame, mess, etc. # specify subtarget: mame, mess, tiny, etc. # build rules will be included from # src/$(TARGET)/$(SUBTARGET).mak #------------------------------------------------- ifndef TARGET TARGET = mess endif ifndef SUBTARGET SUBTARGET = $(TARGET) endif #------------------------------------------------- # specify OSD layer: windows, sdl, etc. # build rules will be included from # src/osd/$(OSD)/$(OSD).mak #------------------------------------------------- ifndef OSD OSD = sdl endif #------------------------------------------------- # specify OS target, which further differentiates # the underlying OS; supported values are: # win32, unix, macosx, os2 #------------------------------------------------- ifndef TARGETOS ifeq ($(OSD),windows) TARGETOS = win32 else TARGETOS = unix endif endif #------------------------------------------------- # specify program options; see each option below # for details #------------------------------------------------- # uncomment next line to include the debugger # DEBUG = 1 ifeq ($(ARCH),i386) # uncomment next line to use DRC MIPS3 engine X86_MIPS3_DRC = 1 # uncomment next line to use DRC PowerPC engine X86_PPC_DRC = 1 endif # uncomment next line to use DRC Voodoo rasterizers # X86_VOODOO_DRC = 1 WINUI = 1 MESS = 1 #------------------------------------------------- # specify build options; see each option below # for details #------------------------------------------------- # uncomment one of the next lines to build a target-optimized build # ATHLON = 1 # I686 = 1 # P4 = 1 # PM = 1 # AMD64 = 1 # G3 = 1 # G4 = 1 # G5 = 1 # CELL = 1 # uncomment next line if you are building for a 64-bit target ifeq ($(ARCH),amd64) PTR64 = 1 endif # 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 BUILD_ZLIB = 1 # uncomment next line to include the symbols # SYMBOLS = 1 # uncomment next line to generate a link map for exception handling in windows # MAP = 1 # uncomment next line to generate a unicode build # UNICODE = 1 # 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 ###################### ########################################################################### #------------------------------------------------- # sanity check the configuration #------------------------------------------------- # disable DRC cores for 64-bit builds ifdef PTR64 X86_MIPS3_DRC = X86_PPC_DRC = endif # specify a default optimization level if none explicitly stated ifndef OPTIMIZE ifndef SYMBOLS OPTIMIZE = 3 else OPTIMIZE = 0 endif endif #------------------------------------------------- # platform-specific definitions #------------------------------------------------- # extension for executables EXE = ifeq ($(TARGETOS),win32) EXE = .exe endif ifeq ($(TARGETOS),os2) EXE = .exe endif # compiler, linker and utilities AR = @ar CC := @$(CC) LD = @$(CC) HHC = @-hhc MD = -mkdir$(EXE) RM = @rm -f #------------------------------------------------- # form the name of the executable #------------------------------------------------- ifeq ($(OSD),msdos) PREFIX = d endif #------------------------------------------------- # based on the architecture, determine suffixes # and endianness #------------------------------------------------- # by default, don't compile for a specific target CPU # and assume little-endian (x86) ARCH = ENDIAN = little # architecture-specific builds get extra options ifdef ATHLON SUFFIX = at ARCH = -march=athlon endif ifdef I686 SUFFIX = pp ARCH = -march=pentiumpro endif ifdef P4 SUFFIX = p4 ARCH = -march=pentium4 endif ifdef AMD64 SUFFIX = 64 ARCH = -march=athlon64 endif ifdef PM SUFFIX = pm ARCH = -march=pentium3 -msse2 endif ifdef G3 SUFFIX = g3 ARCH = -mtune=G3 -isysroot /Developer/SDKs/MacOSX10.3.9.sdk ENDIAN = big endif ifdef G4 SUFFIX = g4 ARCH = -mcpu=G4 ENDIAN = big endif ifdef G5 SUFFIX = g5 ARCH = -mcpu=G5 ENDIAN = big endif ifdef CELL SUFFIX = cbe ARCH = ENDIAN = big endif #------------------------------------------------- # form the name of the executable #------------------------------------------------- ifdef MSVC_BUILD SUFFIX:=$(SUFFIX)vc endif # unicode builds just get the additional 'u' suffix ifdef UNICODE SUFFIX:=$(SUFFIX)u endif # debug builds just get the 'd' suffix and nothing more ifdef DEBUG SUFFIX:=$(SUFFIX)d endif # the name is just 'target' if no subtarget; otherwise it is # the concatenation of the two (e.g., mametiny) ifeq ($(TARGET),$(SUBTARGET)) NAME = $(TARGET) else NAME = $(TARGET)$(SUBTARGET) endif # fullname is prefix+name+suffix FULLNAME = $(NAME) FULLGUINAME = $(NAME)gui # add an EXE suffix to get the final emulator name EMULATORCLI = $(FULLNAME)$(EXE) EMULATORGUI = $(FULLGUINAME)$(EXE) #------------------------------------------------- # 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 OBJ = obj/$(OSD)/$(FULLNAME) #------------------------------------------------- # compile-time definitions #------------------------------------------------- # CR/LF setup: use both on win32/os2, CR only on everything else DEFS = -DCRLF=2 ifeq ($(TARGETOS),win32) DEFS = -DCRLF=3 endif ifeq ($(TARGETOS),os2) DEFS = -DCRLF=3 endif # map the INLINE to something digestible by GCC DEFS += -DINLINE="static __inline__" # define LSB_FIRST if we are a little-endian target ifeq ($(ENDIAN),little) DEFS += -DLSB_FIRST endif # define PTR64 if we are a 64-bit target ifdef PTR64 DEFS += -DPTR64 endif # define MAME_DEBUG if we are a debugging build ifdef DEBUG DEFS += -DMAME_DEBUG else DEFS += -DNDEBUG endif # define VOODOO_DRC if we are building the DRC Voodoo engine ifdef X86_VOODOO_DRC DEFS += -DVOODOO_DRC endif #------------------------------------------------- # compile flags #------------------------------------------------- # we compile to C89 standard with GNU extensions CFLAGS += -std=gnu89 # add -g if we need symbols ifdef SYMBOLS CFLAGS += -g endif # add a basic set of warnings CFLAGS += \ -Wall \ -Wpointer-arith \ -Wbad-function-cast \ -Wcast-align \ -Wstrict-prototypes \ -Wundef \ -Wformat-security \ -Wwrite-strings \ -Wno-unused-function \ # this warning is not supported on the os2 compilers ifneq ($(TARGETOS),os2) CFLAGS += -Wdeclaration-after-statement endif # add the optimization flag CFLAGS += -O$(OPTIMIZE) # if we are optimizing, include optimization options # and make all errors into warnings # but not on 64-bit or debug builds ifneq ($(OPTIMIZE),0) CFLAGS += -fno-strict-aliasing # only -Werror if not PTR64 and not DEBUG ifndef PTR64 ifndef DEBUG #CFLAGS += -Werror endif # !DEBUG endif # !PTR64 endif # neq OPTIMIZE ifeq ($(OSD),windows) DEFS += -DWIN32 -DWINNT EMULATORDLL = $(FULLNAME)lib.dll EMULATORALL = $(EMULATORDLL) $(EMULATORCLI) $(EMULATORGUI) MESSDOCS = messdocs$(EXE) else EMULATORALL = $(EMULATORCLI) endif # extra options needed *only* for the osd files CFLAGSOSDEPEND = $(CFLAGS) #------------------------------------------------- # include paths #------------------------------------------------- # add core include paths CFLAGS += \ -I$(SRC)/$(TARGET) \ -I$(SRC)/$(TARGET)/includes \ -I$(OBJ)/$(TARGET)/layout \ -I$(SRC)/emu \ -I$(OBJ)/emu \ -I$(OBJ)/emu/layout \ -I$(SRC)/lib/util \ -I$(SRC)/osd \ -I$(SRC)/osd/$(OSD) \ -I$(LOCALBASE)/include ifdef MESS CFLAGS += \ -I$(SRC)/mame \ -I$(SRC)/mame/includes \ -I$(SRC)/$(TARGET)/osd/$(OSD) endif #------------------------------------------------- # linking flags #------------------------------------------------- # LDFLAGS are used generally; LDFLAGSEMULATOR are additional # flags only used when linking the core emulator LDFLAGS += -L$(LOCALBASE)/lib LDFLAGSEMULATOR = # strip symbols and other metadata in non-symbols builds ifndef SYMBOLS LDFLAGS += -s endif # output a map file (emulator only) ifdef MAP LDFLAGSEMULATOR += -Wl,-Map,$(FULLNAME).map endif # any reason why this doesn't work for all cases? ifeq ($(TARGETOS),macosx) LDFLAGSEMULATOR += -Xlinker -all_load endif #------------------------------------------------- # define the standard object directory; other # projects can add their object directories to # this variable #------------------------------------------------- OBJDIRS = $(OBJ) #------------------------------------------------- # define standard libarires for CPU and sounds #------------------------------------------------- LIBEMU = $(OBJ)/libemu.a LIBCPU = $(OBJ)/libcpu.a LIBSOUND = $(OBJ)/libsound.a LIBUTIL = $(OBJ)/libutil.a LIBOCORE = $(OBJ)/libocore.a LIBOCORE_NOMAIN = $(OBJ)/libocore_nomain.a LIBOSD = $(OBJ)/libosd.a VERSIONOBJ = $(OBJ)/version.o #------------------------------------------------- # either build or link against the included # libraries #------------------------------------------------- # start with an empty set of libs LIBS = # add expat XML library ifdef BUILD_EXPAT CFLAGS += -I$(SRC)/lib/expat EXPAT = $(OBJ)/libexpat.a else LIBS += -lexpat EXPAT = endif # add ZLIB compression library ifdef BUILD_ZLIB CFLAGS += -I$(SRC)/lib/zlib ZLIB = $(OBJ)/libz.a else LIBS += -lz ZLIB = endif #------------------------------------------------- # 'all' target needs to go here, before the # include files which define additional targets #------------------------------------------------- all: maketree emulator tools #------------------------------------------------- # include the various .mak files #------------------------------------------------- # include OSD-specific rules first include $(SRC)/osd/$(OSD)/$(OSD).mak # then the various core pieces include $(SRC)/$(TARGET)/$(SUBTARGET).mak include $(SRC)/mess/osd/$(OSD)/$(OSD).mak include $(SRC)/emu/emu.mak include $(SRC)/mess/messcore.mak include $(SRC)/lib/lib.mak include $(SRC)/build/build.mak include $(SRC)/tools/tools.mak # combine the various definitions to one CDEFS = $(DEFS) $(COREDEFS) $(CPUDEFS) $(SOUNDDEFS) #------------------------------------------------- # primary targets #------------------------------------------------- emulator: maketree $(BUILD) $(EMULATORALL) tools: maketree $(TOOLS) maketree: $(sort $(OBJDIRS)) clean: @echo Deleting object tree $(OBJ)... $(RM) -r $(OBJ) @echo Deleting $(EMULATORALL)... $(RM) $(EMULATORALL) @echo Deleting $(TOOLS)... $(RM) $(TOOLS) ifdef MAP @echo Deleting $(FULLNAME).map... $(RM) $(FULLNAME).map endif #------------------------------------------------- # directory targets #------------------------------------------------- $(sort $(OBJDIRS)): $(MD) -p $@ #------------------------------------------------- # executable targets and dependencies #------------------------------------------------- ifeq ($(OSD),windows) ifdef MSVC_BUILD DLLLINK=lib else DLLLINK=dll endif $(EMULATORDLL): $(VERSIONOBJ) $(OBJ)/mess/osd/windows/messlib.o $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE) $(LIBWINUI) $(MESS_WINOBJ)/mess.res # always recompile the version string $(CC) $(CDEFS) $(CFLAGS) -c $(SRC)/version.c -o $(VERSIONOBJ) @echo Linking $@... $(LD) -shared $(LDFLAGS) $(LDFLAGSEMULATOR) $^ $(LIBS) -o $@ # gui target $(EMULATORGUI): $(EMULATORDLL) $(OBJ)/mess/osd/windows/ui/guimain.o $(GUIRESFILE) @echo Linking $@... $(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) -mwindows $(FULLNAME)lib.$(DLLLINK) $(OBJ)/mess/osd/windows/ui/guimain.o $(GUIRESFILE) $(LIBS) -o $@ # cli target $(EMULATORCLI): $(EMULATORDLL) $(OBJ)/mess/osd/windows/climain.o @echo Linking $@... $(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) -mconsole $(FULLNAME)lib.$(DLLLINK) $(OBJ)/mess/osd/windows/climain.o $(LIBS) -o $@ else $(EMULATORCLI): $(VERSIONOBJ) $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE) $(CC) $(CDEFS) $(CFLAGS) -c $(SRC)/version.c -o $(VERSIONOBJ) @echo Linking $@... $(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) -mconsole $^ $(LIBS) -o $@ endif #------------------------------------------------- # generic rules #------------------------------------------------- $(OBJ)/%.o: $(SRC)/%.c | $(OSPREBUILD) @echo Compiling $<... $(CC) $(CDEFS) $(CFLAGS) -c $< -o $@ $(OBJ)/%.pp: $(SRC)/%.c | $(OSPREBUILD) @echo Compiling $<... $(CC) $(CDEFS) $(CFLAGS) -E $< -o $@ $(OBJ)/%.s: $(SRC)/%.c | $(OSPREBUILD) @echo Compiling $<... $(CC) $(CDEFS) $(CFLAGS) -S $< -o $@ $(OBJ)/%.lh: $(SRC)/%.lay $(FILE2STR) @echo Converting $<... @$(FILE2STR) $< $@ layout_$(basename $(notdir $<)) $(OBJ)/%.fh: $(SRC)/%.png $(PNG2BDC) $(FILE2STR) @echo Converting $<... @$(PNG2BDC) $< $(OBJ)/temp.bdc @$(FILE2STR) $(OBJ)/temp.bdc $@ font_$(basename $(notdir $<)) UINT8 $(OBJ)/%.a: @echo Archiving $@... $(RM) $@ $(AR) -cr $@ $^ ifeq ($(TARGETOS),macosx) $(OBJ)/%.o: $(SRC)/%.m | $(OSPREBUILD) @echo Objective-C compiling $<... $(CC) $(CDEFS) $(CFLAGS) -c $< -o $@ endif mess.chm: $(MESSDOCS) $(MESSDOCS) docs/wintoc.xml obj/help $(HHC) obj\\help\\mess.hhp @cp obj/help/mess.chm $@