1# 2# Makefile for DarcNES 3# 4 5# $Id: Makefile,v 1.83 2001/03/23 17:04:49 nyef Exp $ 6 7#TARGET?=Linux_svgalib 8TARGET?=Linux_X 9#TARGET?=DJGPP 10#TARGET?=Linux_GTK 11 12#C_ONLY=-DC_ONLY 13 14#MACH_TYPES=-DMACH_TYPES=\"types-i386.h\" 15 16#BYTE_ORDER=-DMSB_FIRST 17#BYTE_ORDER=-DLSB_FIRST 18 19#DEBUG=-g 20 21#OPTFLAGS=-O2 -fomit-frame-pointer 22 23BASE_CFLAGS=-Wall $(DEBUG) $(OPTFLAGS) $(C_ONLY) $(MACH_TYPES) 24BASE_SFLAGS=-Wall $(DEBUG) $(OPTFLAGS) 25BASE_LDFLAGS= 26 27ifndef NO_MULTIPLE_COMMON_WARNING 28BASE_LDFLAGS+=-Wl,--warn-common 29endif 30 31# 32# Flags for Linux_svgalib 33# 34ifeq ($(TARGET),Linux_svgalib) 35CONFFLAGS=-DPCE_CD_SUPPORT -DSOUND 36LOCALBASE?=/usr/local 37LDFLAGS+=-L${LOCALBASE}/lib 38CFLAGS+=-I${LOCALBASE}/include 39SFLAGS+=-I${LOCALBASE}/include 40SYSTEMSRCS=video_svga.c ui_svga.c snd_unix.c cd_unix.c 41BINFILE=darcnes 42LIBS=-lvgagl -lvga 43endif 44 45# 46# Flags for Linux_X 47# 48ifeq ($(TARGET),Linux_X) 49CONFFLAGS=-DPCE_CD_SUPPORT -DSOUND 50LDFLAGS+=-L${LOCALBASE}/lib 51CFLAGS+=-I${LOCALBASE}/include 52SFLAGS+=-I${LOCALBASE}/include 53SYSTEMSRCS=video_x.c ui_x.c snd_unix.c keyboard_x.c cd_unix.c 54BINFILE=darcnes 55LIBS=-lXext -lXaw -lXmu -lXt -lX11 56endif 57 58# 59# Flags for Linux_GTK 60# 61ifeq ($(TARGET),Linux_GTK) 62GTK_CONFIG?=gtk-config 63CONFFLAGS=-DPCE_CD_SUPPORT -DSOUND 64CFLAGS+=`$(GTK_CONFIG) --cflags` 65SYSTEMSRCS=ui_gtk.c snd_unix.c cd_unix.c 66BINFILE=darcnes 67LIBS=`$(GTK_CONFIG) --libs` 68endif 69 70# 71# Flags for DJGPP 72# 73ifeq ($(TARGET),DJGPP) 74CONFFLAGS=-DSOUND 75CFLAGS+=-DASM_UNDERBARS 76SFLAGS+=-DASM_UNDERBARS 77SYSTEMSRCS=video_allegro.c ui_allegro.c snd_allegro.c 78BINFILE=darcnes.exe 79LIBS=-lalleg 80endif 81 82# 83# finalize FLAGS 84# 85CFLAGS+=$(BASE_CFLAGS) $(CONFFLAGS) 86SFLAGS+=$(BASE_SFLAGS) 87LDFLAGS+=$(BASE_LDFLAGS) 88 89# 90# fixup command variables 91# 92LOCAL_CC?=gcc 93LOCAL_CXX?=g++ 94LOCAL_AS?=gcc 95LOCAL_LD?=gcc 96 97CC=$(LOCAL_CC) 98CXX=$(LOCAL_CC) 99AS=$(LOCAL_AS) 100LD=$(LOCAL_LD) 101 102ifndef CROSS_COMPILING 103TARGET_CC=$(LOCAL_CC) 104TARGET_CXX=$(LOCAL_CXX) 105TARGET_AS=$(LOCAL_AS) 106TARGET_LD=$(LOCAL_LD) 107endif 108 109# 110# file lists 111# 112NES_SRCS=mappers.c nes_ppu.c nes.c nes_psg.c fds.c 113PCE_SRCS=pce.c pce_vdp.c pce_cd.c 114SMS_SRCS=sms.c sms9918.c sms_psg.c 115CV_SRCS=coleco.c tms9918.c sms_psg.c 116SG1K_SRCS=sg1000.c tms9918.c sms_psg.c 117GEN_SRCS=genesis.c gen_vdp.c 118A2_SRCS=apple2.c apple2_vdp.c apple2_disk.c 119MSX_SRCS=msx.c tms9918.c 120 121GAMESRCS := $(NES_SRCS) $(PCE_SRCS) $(SMS_SRCS) $(CV_SRCS) $(SG1K_SRCS) \ 122 $(A2_SRCS) $(MSX_SRCS) #$(GEN_SRCS) 123GAMESRCS := $(sort $(GAMESRCS)) 124 125ifdef C_ONLY 126ASMSRCS= 127CSRCS=blit_c.c 128else 129ASMSRCS=blitters.S 130CSRCS= 131endif 132 133MZ80_SRCS=mz80.c 134CPU6502_SRCS=cpu6502.c cpu6502opc.c 135CPU6280_SRCS=cpu6280.c cpu6280opc.c 136EMU68K_SRCS=emu68k.c torr_cpu.c 137 138CPUSRCS := $(MZ80_SRCS) $(CPU6502_SRCS) $(CPU6280_SRCS) #$(EMU68K_SRCS) 139CPUSRCS := $(sort $(CPUSRCS)) 140 141COMMONSRCS=tool.c cal.c tiledraw.c event.c palette8.c 142 143SRCFILES=$(COMMONSRCS) $(GAMESRCS) $(ASMSRCS) $(CSRCS) $(SYSTEMSRCS) $(CPUSRCS) 144 145# .c files that should not be auto-depended 146NODEPSRCS=palette8.c 147 148# .c files not in SRCFILES that should be auto-depended 149DEPSRCS= 150 151# extra files to delete while cleaning up 152RMFILES= 153 154# non-*.[chS] files to include in distribution 155#MISC_FILES=Makefile notes ppu_notes readme sound_notes timing.txt 156MISC_FILES=Makefile readme files.txt tests/*[0-9] 157 158# object file list 159OBJFILES := \ 160 $(patsubst %.c,%.o,$(filter %.c,$(SRCFILES))) \ 161 $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRCFILES))) \ 162 $(patsubst %.S,%.o,$(filter %.S,$(SRCFILES))) 163 164# make rules 165 166all: default 167 168default: $(BINFILE) 169 170$(BINFILE): $(OBJFILES) 171 $(TARGET_LD) $(LDFLAGS) -o $(BINFILE) $(OBJFILES) $(LIBS) 172 173# stupid GNU make limitations require specifying .S dependancies explicitly 174blitters.o: blitters.S machdep.h 175 176DEPSRCS += test_68k.c test_6280.c test_6502.c 177 178.PHONY: tests 179tests: run_test_68k run_test_6280 run_test_6502 180 181 182# special handling for generic palette code 183 184# FIXME: how to add MACH_TYPES to dependancies on following line? 185palette8.o: palette.c palette.h types.h 186 $(TARGET_CC) -o $@ $(CFLAGS) -DPALETTE_DEPTH=8 -c $< 187 188palette16.o: palette.c palette.h types.h 189 $(TARGET_CC) -o $@ $(CFLAGS) -DPALETTE_DEPTH=16 -c $< 190 191palette32.o: palette.c palette.h types.h 192 $(TARGET_CC) -o $@ $(CFLAGS) -DPALETTE_DEPTH=32 -c $< 193 194# special handling for 68000 core 195 196.PHONY: run_test_68k 197run_test_68k: test_68k 198 cat tests/68k_test_*[0-9] | ./test_68k 199 200RMFILES += test_68k 201test_68k: test_68k.o emu68k.o 202 $(LD) $(LDFLAGS) -o test_68k test_68k.o emu68k.o 203 204 205# special handling for 6280 core 206 207.PHONY: run_test_6280 208run_test_6280: test_6280 209 cat tests/6280_test_*[0-9] | ./test_6280 210 211RMFILES += test_6280 212test_6280: test_6280.o cpu6280.o cpu6280opc.o 213 $(LD) $(LDFLAGS) -o test_6280 test_6280.o cpu6280.o cpu6280opc.o 214 215NODEPSRCS += cpu6280opc.c 216RMFILES += cpu6280opc.c 217cpu6280opc.o: cpu6280opc.c cpu6280int.h 218 219cpu6280opc.c: build_cpu6280 220 ./build_cpu6280 cpu6280opc.c 221 222DEPSRCS += build_cpu6280.c 223 224build_cpu6280.o: build_cpu6280.c 225 $(CC) -c $(CFLAGS) $< 226 227RMFILES += build_cpu6280 228build_cpu6280: build_cpu6280.o 229 $(CC) $(CFLAGS) -o build_cpu6280 build_cpu6280.o 230 231 232# special handling for 6502 core 233 234.PHONY: run_test_6502 235run_test_6502: test_6502 236 cat tests/6502_test_*[0-9] | ./test_6502 237 238RMFILES += test_6502 239test_6502: test_6502.o cpu6502.o cpu6502opc.o 240 $(LD) $(LDFLAGS) -o test_6502 test_6502.o cpu6502.o cpu6502opc.o 241 242NODEPSRCS += cpu6502opc.c 243RMFILES += cpu6502opc.c 244cpu6502opc.o: cpu6502opc.c cpu6502int.h 245 246cpu6502opc.c: build_cpu6502 247 ./build_cpu6502 cpu6502opc.c 248 249DEPSRCS += build_cpu6502.c 250 251build_cpu6502.o: build_cpu6502.c 252 $(CC) -c $(CFLAGS) $< 253 254RMFILES += build_cpu6502 255build_cpu6502: build_cpu6502.o 256 $(CC) $(CFLAGS) -o build_cpu6502 build_cpu6502.o 257 258 259.PHONY: clean 260clean: 261 rm -f *.o *.d *~ "#"*"#" $(BINFILE) $(RMFILES) 262 263.PHONY: distr 264distr: clean 265 (cd ..; tar cvzf darcnes/darcnes.tgz $(addprefix darcnes/,*.[chS] $(MISC_FILES))) 266 grep -h \$$Id Makefile *.[chS] | grep -v darcnes.ids -> darcnes.ids 267 268.c.o: 269 $(TARGET_CC) -c $(CFLAGS) $< 270 271.c.s: 272 $(TARGET_CC) -S $(CFLAGS) $< 273 274.cpp.o: 275 $(TARGET_CXX) -c $(CFLAGS) $< 276 277.cpp.s: 278 $(TARGET_CXX) -S $(CFLAGS) $< 279 280.S.o: 281 $(TARGET_AS) -c $(SFLAGS) $< 282 283.s.o: 284 $(TARGET_AS) -c $(SFLAGS) $(addsuffix .S,$(basename $<)) 285 286# 287# Dependancy data 288# 289DEPSRCS += $(SRCFILES) 290DEPFILES := $(patsubst %.c,%.d,$(filter %.c,$(filter-out $(NODEPSRCS),$(DEPSRCS)))) 291DEPFILES += $(patsubst %.cpp,%.d,$(filter %.cpp,$(filter-out $(NODEPSRCS),$(DEPSRCS)))) 292 293# include depend files unles we are making clean 294ifneq ($(MAKECMDGOALS),clean) 295ifneq ($(MAKECMDGOALS),distr) 296include $(DEPFILES) 297endif 298endif 299 300RMFILES+=fixdep 301NODEPSRCS+=fixdep.c 302fixdep: fixdep.c 303 $(CC) -o $@ $(CFLAGS) $< 304 305%.d: %.cpp fixdep 306 $(TARGET_CXX) $(CFLAGS) -MM $< | ./fixdep > $@ 307 308%.d: %.c fixdep 309 $(TARGET_CC) $(CFLAGS) -MM $< | ./fixdep > $@ 310 311# 312# $Log: Makefile,v $ 313# Revision 1.83 2001/03/23 17:04:49 nyef 314# fixed to allow an overriding makefile to disable the multiple common warning 315# 316# Revision 1.82 2001/02/27 04:17:37 nyef 317# removed 68k core and genesis driver sources from the compile lists 318# 319# Revision 1.81 2000/11/29 05:44:16 nyef 320# removed M6502_SRCS from CPUSRCS 321# removed the definition of M6502_SRCS 322# 323# Revision 1.80 2000/11/25 15:03:18 nyef 324# added new MSX_SRCS group to the GAMESRCS list 325# 326# Revision 1.79 2000/10/30 22:18:04 nyef 327# enabled warnings for multiple definitions of the same common section 328# 329# Revision 1.78 2000/08/04 23:34:42 nyef 330# added support for the generic palette system 331# added the 8-bit generic palette code to the common compile lists 332# 333# Revision 1.77 2000/08/04 21:26:03 nyef 334# fixed to use $(CC) instead of $(TARGET_CC) for making build_cpu6{502,280} 335# 336# Revision 1.76 2000/07/09 20:49:23 nyef 337# tweaked definition of LDFLAGS for the Linux_X version to allow for overrides 338# 339# Revision 1.75 2000/06/28 01:34:42 nyef 340# added fds.c to the NES compile list 341# 342# Revision 1.74 2000/06/28 00:36:54 nyef 343# fixed to work with GNU make 3.77 on BeOS (hopefully other platforms too) 344# 345# Revision 1.73 2000/06/25 15:23:47 nyef 346# fixed default GTK_CONFIG to be gtk-config 347# 348# Revision 1.72 2000/06/03 23:01:04 nyef 349# tweaked GTK target to allow specifying a different version of gtk_config 350# 351# Revision 1.71 2000/05/07 00:01:02 nyef 352# Cleaned up a lot of things 353# Added support for compiling and auto-depending C++ files 354# Moved sound control out from #define SOUND in {sms,nes}_psg.c 355# Added support for cross compilation 356# 357# Revision 1.70 2000/05/01 00:35:23 nyef 358# added build process for cpu6502 core 359# added cpu6502.c and cpu6502opc.c to the compile lists 360# 361# Revision 1.69 2000/04/15 02:14:06 nyef 362# fixed to not rebuild the depend files when making clean 363# 364# Revision 1.68 2000/04/05 02:23:04 nyef 365# added fixdep to the "files to remove when cleaning up" list 366# 367# Revision 1.67 2000/04/05 02:14:11 nyef 368# fixed to not clobber CFLAGS inherited from the environment 369# 370# Revision 1.66 2000/03/25 18:18:45 nyef 371# fixed a couple mistakes with the "clean" target 372# 373# Revision 1.65 2000/03/25 06:33:01 nyef 374# general cleanup 375# rebuilt auto-depend system (GNU make sucks sometimes) 376# fixed autodep on CPU test and generation code 377# 378# Revision 1.64 2000/03/20 03:37:26 nyef 379# made automatic dependancy generation fail to suck 380# broke automatic dependancy generation for test drivers 381# cleaned up the massive duplication involved in maintaining separate lists 382# of source and object files 383# cleaned up system-dependant file lists 384# 385# Revision 1.63 2000/03/18 17:54:42 nyef 386# fixed automatic dependancy problem with test driver code 387# 388# Revision 1.62 2000/03/11 02:30:17 nyef 389# added apple2_disk.[co] to the compile lists 390# 391# Revision 1.61 2000/03/10 01:49:14 nyef 392# added event.[co] to the compile lists 393# 394# Revision 1.60 2000/03/06 00:38:51 nyef 395# added keyboard support to X version 396# 397# Revision 1.59 2000/02/14 02:36:58 nyef 398# changed to use new unified cd_unix.c interface 399# 400# Revision 1.58 2000/02/12 19:04:24 nyef 401# added PCE CD support 402# 403# Revision 1.57 2000/02/06 22:30:19 nyef 404# re-added -g debug option 405# 406# Revision 1.56 2000/02/01 04:12:01 nyef 407# added test data files to distribution 408# 409# Revision 1.55 2000/01/29 03:09:50 nyef 410# changed dist target to put files in the .tgz file in a darcnes/ directory 411# 412# Revision 1.54 2000/01/24 05:07:24 nyef 413# removed m6280.[co] from the compile lists 414# added cpu6280.[co] and cpu6280opc.o to the compile lists 415# 416# Revision 1.53 2000/01/21 03:21:25 nyef 417# fixed depends for cpu6280opc.o 418# 419# Revision 1.52 2000/01/17 01:24:59 nyef 420# added test code for cpu6280 core 421# added build process for cpu6280 core 422# 423# Revision 1.51 2000/01/09 18:23:46 nyef 424# added a target to run the unit tests automatically 425# 426# Revision 1.50 2000/01/01 04:13:06 nyef 427# added apple2.c and apple2_vdp.c to the compile lists 428# 429# Revision 1.49 1999/12/24 16:53:04 nyef 430# added include directory for XWindows on FreeBSD 431# 432# Revision 1.48 1999/12/12 18:20:31 nyef 433# added a target for test_68k 434# 435# Revision 1.47 1999/12/07 02:01:51 nyef 436# added the MACH_TYPES silliness (too bad it's the best solution I found) 437# 438# Revision 1.46 1999/12/04 04:57:41 nyef 439# removed debug.c, dt6502.c, dt65c02.c and dt6280.c from the compile lists 440# 441# Revision 1.45 1999/12/04 04:05:59 nyef 442# removed all ASM CPU cores from the compile lists 443# 444# Revision 1.44 1999/11/27 20:08:10 nyef 445# added sg1000.[co] to the compile lists 446# 447# Revision 1.43 1999/11/23 01:41:59 nyef 448# added tiledraw.c to the compile lists 449# 450# Revision 1.42 1999/11/14 01:30:25 nyef 451# added a .c.s rule to make it easier to check the compiler's behavior 452# 453# Revision 1.41 1999/10/31 02:38:24 nyef 454# added snd_allegro.c and snd_unix.c to the compile lists 455# 456# Revision 1.40 1999/08/23 01:44:37 nyef 457# removed -g debug option 458# 459# Revision 1.39 1999/08/15 02:27:20 nyef 460# added C_ONLY support 461# added partial support for new "Torrigion" CPU core 462# added BYTE_ORDER support 463# 464# Revision 1.38 1999/08/07 16:20:03 nyef 465# added -DLSB_FIRST to CFLAGS in all system types 466# 467# Revision 1.37 1999/08/02 00:21:36 nyef 468# added m6280.[co] to the compile lists 469# 470# Revision 1.36 1999/06/14 19:16:56 nyef 471# removed (unused) GRAPHICS options 472# added OPTFLAGS (optimization), with -fomit-frame-pointer 473# 474# Revision 1.35 1999/06/08 01:49:56 nyef 475# added coleco.[co] to the compile lists 476# added tms9918.[co] to the compile lists 477# 478# Revision 1.34 1999/04/28 16:49:22 nyef 479# added sms_psg.[co] to the compile lists 480# 481# Revision 1.33 1999/04/17 23:04:29 nyef 482# added genesis.[co], gen_vdp.[co], and emu68k.[co] to compile lists. 483# 484# Revision 1.32 1999/02/21 23:32:52 nyef 485# switched from using blitters.c to blitter.S 486# 487# Revision 1.31 1999/02/15 03:40:50 nyef 488# added patch from Michael Vance for GTK support 489# 490# Revision 1.30 1999/02/14 18:34:35 nyef 491# removed io_nes.[So] from the compile lists 492# 493# Revision 1.29 1999/01/22 03:04:16 nyef 494# added files.txt to the MISC_FILES list. 495# 496# Revision 1.28 1999/01/18 22:16:58 nyef 497# added changes required for SVGALib support 498# 499# Revision 1.27 1999/01/17 02:13:13 nyef 500# added pce_vdp.[co] to the compile lists. 501# 502# Revision 1.26 1999/01/13 04:15:41 nyef 503# removed io_pce.[So] from the compile lists. 504# 505# Revision 1.25 1999/01/11 02:24:02 nyef 506# removed nes_blit.[co] from compile lists. 507# added blitters.[co] to compile lists. 508# 509# Revision 1.24 1999/01/08 02:45:46 nyef 510# removed zarzon code from compile lists. 511# 512# Revision 1.23 1999/01/07 03:16:55 nyef 513# added sms9918.[co] to the compile lists. 514# 515# Revision 1.22 1999/01/03 02:29:51 nyef 516# added maratz80.[co] to the compile lists. 517# 518# Revision 1.21 1999/01/01 07:01:38 nyef 519# added sms.c, emuz80.S and opcz80.S to compile lists. 520# 521# Revision 1.20 1998/12/31 19:30:45 nyef 522# added some admin stuff to make distr. 523# 524# Revision 1.19 1998/12/24 04:33:46 nyef 525# split all of the game-specific files out of the common compile lists. 526# added zarzon.[co] to the game compile lists. 527# 528# Revision 1.18 1998/12/20 04:03:37 nyef 529# changed header comment and all binfiles to say "darcnes". 530# 531# Revision 1.17 1998/12/20 04:01:54 nyef 532# removed a few files from MISC_FILES. 533# 534# Revision 1.16 1998/12/12 21:38:50 nyef 535# added m6502.c to compile lists 536# 537# Revision 1.15 1998/11/29 18:29:20 nyef 538# added cal.c to the compile lists. 539# 540# Revision 1.14 1998/10/21 02:38:58 nyef 541# added targets for 'realclean' and 'distr' 542# 543# Revision 1.13 1998/10/11 21:37:02 nyef 544# added {emu,opc}6502a.[So] the the common compile lists. 545# 546# Revision 1.12 1998/08/22 00:25:46 nyef 547# added nes_psg.[co] to the common compile lists. 548# 549# Revision 1.11 1998/08/02 16:52:59 nyef 550# added ui_allegro.[co] to DJGPP{SRC,OBJ}S. 551# 552# Revision 1.10 1998/08/01 22:31:02 nyef 553# added ui_x.[co] to the LINUX_X{SRC,OBJ}S lines. 554# 555# Revision 1.9 1998/08/01 01:15:10 nyef 556# added a bunch of libs to the Linux_X configuration for GUI support. 557# 558# Revision 1.8 1998/07/31 23:52:47 nyef 559# added .s.o rule for DJGPP support. 560# 561# Revision 1.7 1998/07/29 01:39:42 nyef 562# added ASM_UNDERBARS to [CS]FLAGS for DJGPP. 563# removed commented out commands on [CS]FLAGS for Linux/Svgalib. 564# added -lalleg to LIBS line for DJGPP. 565# 566# Revision 1.6 1998/07/28 23:48:18 nyef 567# changed all references to '.depend' to '_depend' for DOS compatability. 568# 569# Revision 1.5 1998/07/25 16:58:04 nyef 570# added the blit compiler to the common compile lists. 571# 572# Revision 1.4 1998/07/14 02:08:59 nyef 573# added opc6280.S to the compile lists 574# 575# Revision 1.3 1998/07/14 01:50:30 nyef 576# added dt6280.c to the file lists. 577# 578# Revision 1.2 1998/07/12 20:51:17 nyef 579# re-added pce-specific files to compile lists 580# 581# Revision 1.1 1998/07/11 22:16:01 nyef 582# Initial revision 583# 584# 585