www.pudn.com > ncdzsrc.rar > makefile.gcc


#--------------------------------------------------------------------- 
# 
#        NEOGEO CDZ Emulator Makefile for GCC 
# 
#--------------------------------------------------------------------- 
 
#--------------------------------------------------------------------- 
# Programs 
#--------------------------------------------------------------------- 
 
AR = @ar 
CC = @gcc 
LD = @gcc 
RC = @windres 
 
ASM = @nasmw 
ASMFLAGS = -f coff 
ASMDEFS = -DSCRBMP_ALIGNED=0 
 
RM = @rm -f 
MD = -mkdir.exe 
PACKER = @upx 
 
#--------------------------------------------------------------------- 
# Executable File Extension 
#--------------------------------------------------------------------- 
 
EXE = .exe 
 
#--------------------------------------------------------------------- 
# Object File Output Directtory 
#--------------------------------------------------------------------- 
 
OBJ = obj 
 
#--------------------------------------------------------------------- 
# Target File Name 
#--------------------------------------------------------------------- 
 
EMULATOR = ncdz$(EXE) 
 
#--------------------------------------------------------------------- 
# If you have upx installed to compress executable. 
#--------------------------------------------------------------------- 
 
# COMPRESS = $(PACKER) -9 $(EMULATOR) 
 
#--------------------------------------------------------------------- 
# Optimize 
#--------------------------------------------------------------------- 
 
ARCH = -march=pentiumpro 
 
ifdef ATHLON 
ARCH = -march=athlon -m3dnow 
endif 
 
ifdef ATHLONXP 
ARCH = -march=athlon-xp -m3dnow -msse 
endif 
 
ifdef P3 
ARCH = -march=pentium3 -sse 
endif 
 
ifdef P4 
ARCH = -march=pentium4 -msse2 
endif 
 
ifdef PM 
ARCH = -march=pentium3 -msse2 
endif 
 
#--------------------------------------------------------------------- 
# Compiler Flags 
#--------------------------------------------------------------------- 
 
CDEFS = \ 
	-DX86_ASM \ 
	-DLSB_FIRST \ 
	-DCRLF=3 \ 
	-DWINVER=0x0400 \ 
	-D_WIN32_WINNT=0x0500 \ 
	-DWIN32 \ 
	-D_WINDOWS \ 
	-DDIRECTSOUND_VERSION=0x0300 \ 
	-DDIRECTDRAW_VERSION=0x0300 \ 
	-DDIRECTINPUT_VERSION=0x0500 \ 
	-DINLINE='static __inline' \ 
	-Dinline=__inline \ 
	-D__inline__=__inline \ 
	-Isrc \ 
	-Isrc/cpu/m68000 \ 
	-I$(OBJ)/cpu/m68000 \ 
	-Isrc/cpu/z80 \ 
	-I$(OBJ)/cpu/z80 \ 
	-DNEOGEOCD 
 
ifdef DEBUG 
CFLAGS += -O0 -Wall -Wno-unused -g 
else 
CFLAGS = $(ARCH) \ 
	-DNODEBUG \ 
	-O3 \ 
	-fno-strict-aliasing \ 
	-Werror \ 
	-Wall \ 
	-Wno-sign-compare \ 
	-Wno-unused-functions \ 
	-Wpointer-arith \ 
	-Wbad-function-cast \ 
	-Wcast-align \ 
	-Wstrict-prototypes \ 
	-Wundef \ 
	-Wformat-security \ 
	-Wwrite-strings \ 
	-Wdeclaration-after-statement 
endif 
 
ifdef MEMORY_DEBUG 
CDEFS += -DMEMORY_DEBUG=1 
ASMDEFS += -DMEMORY_DEBUG=1 
else 
CDEFS += -DMEMORY_DEBUG=0 
ASMDEFS += -DMEMORY_DEBUG=0 
endif 
 
ifdef FAST_SPRITE 
CDEFS += -DFAST_SPRITE_DRAW=1 
else 
CDEFS += -DFAST_SPRITE_DRAW=0 
endif 
 
ifdef SYSTEM_CHECK 
CDEFS += -DENABLE_SYSTEM_CHECK=1 
else 
CDEFS += -DENABLE_SYSTEM_CHECK=0 
endif 
 
ifdef OUTPUT_CDDA_LOG 
CDEFS += -DOUTPUT_CDDA_LOG=1 
else 
CDEFS += -DOUTPUT_CDDA_LOG=0 
endif 
 
ifdef OUTPUT_MEMORY_LOG 
CDEFS += -DOUTPUT_MEMORY_LOG=1 
else 
CDEFS += -DOUTPUT_MEMORY_LOG=0 
endif 
 
ifdef M68K_DEBUG 
CDEFS += -DM68K_DEBUG=1 
ASMDEFS += -DM68K_DEBUG=1 
else 
CDEFS += -DM68K_DEBUG=0 
ASMDEFS += -DM68K_DEBUG=0 
endif 
 
ifdef DEBUG 
CDEFS += -DDEBUG=1 -DBUILD_CONSOLE=1 
ASMDEFS += -DDEBUG=1 
BUILD_CONSOLE = 1 
endif 
 
ifdef BUILD_CONSOLE 
CDEFS += -DBUILD_CONSOLE=1 
endif 
 
ifdef BUILD_CONSOLE 
PROGRAM_TYPE = -mconsole 
else 
PROGRAM_TYPE = -mwindows 
endif 
 
CDEFS += $(PROGRAM_TYPE) 
 
#--------------------------------------------------------------------- 
# Linker Flags 
#--------------------------------------------------------------------- 
 
ifdef DEBUG 
LDFLAGS = -Wl,-Map,ncdz.map  $(PROGRAM_TYPE) 
else 
LDFLAGS = -s $(PROGRAM_TYPE) 
endif 
 
 
#--------------------------------------------------------------------- 
# Resource Compiler Flags 
#--------------------------------------------------------------------- 
 
RCDEFS += -DNDEBUG -D_WIN32_IE=0x0400 
RCFLAGS += -O coff --include-dir=src 
 
#--------------------------------------------------------------------- 
# Object files 
#--------------------------------------------------------------------- 
 
OBJDIRS = \ 
	$(OBJ) \ 
	$(OBJ)/cpu \ 
	$(OBJ)/cpu/m68000 \ 
	$(OBJ)/cpu/z80 \ 
	$(OBJ)/drivers \ 
	$(OBJ)/machine \ 
	$(OBJ)/sound \ 
	$(OBJ)/vidhrdw \ 
	$(OBJ)/win32 \ 
	$(OBJ)/zlib \ 
 
OBJS = \ 
	$(OBJ)/neogeocd.o \ 
	$(OBJ)/cpuintrf.o \ 
	$(OBJ)/config.o \ 
	$(OBJ)/input.o \ 
	$(OBJ)/memintrf.o \ 
	$(OBJ)/sndintrf.o \ 
	$(OBJ)/usrintrf.o \ 
	$(OBJ)/png.o \ 
	$(OBJ)/timer.o \ 
	$(OBJ)/video.o \ 
	$(OBJ)/drivers/driver.o \ 
	$(OBJ)/machine/machine.o \ 
	$(OBJ)/machine/cdda.o \ 
	$(OBJ)/machine/cdrom.o \ 
	$(OBJ)/machine/loadscr.o \ 
	$(OBJ)/machine/simbios.o \ 
	$(OBJ)/machine/i68k.o \ 
	$(OBJ)/machine/pd4990a.o \ 
	$(OBJ)/vidhrdw/vidhrdw.o \ 
	$(OBJ)/cpu/m68000/d68k.o \ 
	$(OBJ)/cpu/z80/z80.o \ 
	$(OBJ)/cpu/z80/z80intf.o \ 
	$(OBJ)/sound/2610intf.o \ 
	$(OBJ)/sound/ym2610.o \ 
	$(OBJ)/sound/streams.o \ 
 
 
OSOBJS = \ 
	$(OBJ)/win32/asmblt16.oa \ 
	$(OBJ)/win32/asmblt24.oa \ 
	$(OBJ)/win32/asmblt32.oa \ 
	$(OBJ)/win32/blit.o \ 
	$(OBJ)/win32/dbgcdrom.o \ 
	$(OBJ)/win32/DirectDraw.o \ 
	$(OBJ)/win32/DirectInput.o \ 
	$(OBJ)/win32/DirectSound.o \ 
	$(OBJ)/win32/fileio.o \ 
	$(OBJ)/win32/misc.oa \ 
	$(OBJ)/win32/osd_cdda.o \ 
	$(OBJ)/win32/osd_joy.o \ 
	$(OBJ)/win32/osd_key.o \ 
	$(OBJ)/win32/osd_sound.o \ 
	$(OBJ)/win32/osd_video.o \ 
	$(OBJ)/win32/ticker.o \ 
	$(OBJ)/win32/win32.o \ 
	$(OBJ)/win32/resource.res 
 
 
#ifdef A68K0 
#OBJS += $(OBJ)/cpu/m68000/68000.oa $(OBJ)/cpu/m68000/asmintf.o 
#CDEFS += -DA68K0 
#else 
M68000_GENERATED_OBJS = \ 
	$(OBJ)/cpu/m68000/m68kops.o $(OBJ)/cpu/m68000/m68kopac.o \ 
	$(OBJ)/cpu/m68000/m68kopdm.o $(OBJ)/cpu/m68000/m68kopnz.o 
 
OBJS += $(M68000_GENERATED_OBJS) $(OBJ)/cpu/m68000/m68kcpu.o $(OBJ)/cpu/m68000/m68kncdz.o 
#endif 
 
#--------------------------------------------------------------------- 
# Library files 
#--------------------------------------------------------------------- 
 
LIBS = \ 
	-lkernel32 \ 
	-luser32 \ 
	-lgdi32 \ 
	-lshell32 \ 
	-ldxguid \ 
	-lddraw \ 
	-ldinput \ 
	-ldsound \ 
	-lwinmm 
 
#--------------------------------------------------------------------- 
# Make rules 
#--------------------------------------------------------------------- 
 
all: maketree $(EMULATOR) 
 
include src/zlib/zlib.mak 
 
$(EMULATOR): $(OBJS) $(OSOBJS) 
	@echo Linking $@... 
	$(LD) $(LDFLAGS) $(OBJS) $(OSOBJS) $(LIBS) -o $@ 
	$(COMPRESS) 
 
#--------------------------------------------------------------------- 
# A68K - ASM MC68000 core 
#--------------------------------------------------------------------- 
 
# generate ASM source files for the 68000 emulator 
$(OBJ)/cpu/m68000/68000.asm: src/cpu/m68000/make68k.c 
	@echo make68k make $<... 
	$(CC) $(CDEFS) $(CFLAGS) -o $(OBJ)/cpu/m68000/make68k$(EXE) $< 
	@echo Generating M68K source files... 
	$(OBJ)/cpu/m68000/make68k$(EXE) $@ $(OBJ)/cpu/m68000/68000tab.asm 00 ppro 
 
# compile generated ASM files for the 68000 emulator 
$(OBJ)/cpu/m68000/68000.oa: $(OBJ)/cpu/m68000/68000.asm 
	@echo Compiling A68K0... 
	$(ASM) -o $@ $(ASMFLAGS) $(subst -D,-d,$(ASMDEFS)) $< 
 
#--------------------------------------------------------------------- 
# MUSASHI - C MC68000 core 
#--------------------------------------------------------------------- 
 
# compile generated C files for the 68000 emulator 
$(M68000_GENERATED_OBJS): $(OBJ)/cpu/m68000/m68kmake$(EXE) 
	@echo Compiling $(subst .o,.c,$@)... 
	$(CC) $(CDEFS) $(CFLAGS) -c $*.c -o $@ 
 
# additional rule, because m68kcpu.c includes the generated m68kops.h :-/ 
$(OBJ)/cpu/m68000/m68kcpu.o: $(OBJ)/cpu/m68000/m68kmake$(EXE) 
 
# generate C source files for the 68000 emulator 
$(OBJ)/cpu/m68000/m68kmake$(EXE): src/cpu/m68000/m68kmake.o 
	@echo M68K make $<... 
	$(CC) $(CDEFS) $(CFLAGS) $^ -o $@ 
	$(RM) src/cpu/m68000/m68kmake.o 
	@echo Generating M68K source files... 
	$(OBJ)/cpu/m68000/m68kmake$(EXE) $(OBJ)/cpu/m68000 src/cpu/m68000/m68k_in.c 
 
#--------------------------------------------------------------------- 
# RAZE - Z80 core 
#--------------------------------------------------------------------- 
 
NASMFLAGS = -w+orphan-labels 
 
# This pre-processes the .ASM file 
$(OBJ)/cpu/z80/z80.asm: src/cpu/z80/raze.asm src/cpu/z80/raze.inc src/cpu/z80/raze.reg 
	$(ASM) $(NASMFLAGS) -e $< -o $@ 
 
# This assembles the file, once it's been pre-processed 
$(OBJ)/cpu/z80/z80.o: $(OBJ)/cpu/z80/z80.asm 
	$(ASM) $(NASMFLAGS) -f coff $< -o $@ -psrc/cpu/z80/raze.reg 
 
#--------------------------------------------------------------------- 
# C file 
#--------------------------------------------------------------------- 
 
$(OBJ)/%.o: src/%.c 
	@echo Compiling $<... 
	$(CC) $(CDEFS) $(INCLUDES) $(DEBUGDEF) $(CFLAGS) -c $< -o $@ 
 
$(OBJ)/%.oa: src/%.asm 
	@echo Assembling $@... 
	$(ASM) -o $@ $(ASMFLAGS) $(subst -D,-d,$(ASMDEFS)) $< 
 
$(OBJ)/%.a: 
	@echo Archiving $@... 
	$(RM) $@ 
	$(AR) cr $@ $^ 
 
$(OBJ)/%.res: src/%.rc 
	@echo Compiling Resource $@... 
	$(RC) $(RCDEFS) $(RCFLAGS) -o $@ -i $< 
 
#--------------------------------------------------------------------- 
# Rules to manage files 
#--------------------------------------------------------------------- 
 
mkdir: 
	@echo make mkdir is no longer necessary, just type make 
 
$(sort $(OBJDIRS)): 
	$(MD) $(subst /,\,$@) 
 
maketree2: 
	@echo Making object tree... 
 
maketree: maketree2 $(sort $(OBJDIRS))