VPATH = . resid-fp NS32016 darm mc6809nc pdp11 musahi ARMulator

# The following flags are used by PiTubeDirect Co Pros:
#                BEM - fixes for compilation in B-Em envorinment
#   INCLUDE_DEBUGGER - include the cpu_debug implementation
# USE_MEMORY_POINTER - do not assume Co Pro memory starts at address 0

COMMON_FLAGS = -O3 -Wall -DBEM -DVERSION=\"$(VERSION)\" -DINCLUDE_DEBUGGER -DUSE_MEMORY_POINTER -DMODET -DMODE32 -DBEEBEM -I ../src -I /usr/i686-w64-mingw32/include $(ALLEGRO_INC)
CFLAGS       = -std=gnu99 $(COMMON_FLAGS)
CXXFLAGS     = $(COMMON_FLAGS)
LDFLAGS	     = $(ALLEGRO_LIB)

OBJ = \
    6502.o \
    6502debug.o \
    6502tube.o \
    6809tube.o \
    65816.o \
    acia.o \
    adc.o \
    arm.o \
    darm.o \
    darm-tbl.o \
    armv7.o \
    armv7-tbl.o \
    thumb.o \
    thumb-tbl.o \
    thumb2.o \
    thumb2-decoder.o \
    thumb2-tbl.o \
    cmos.o \
    compact_joystick.o \
    compactcmos.o \
    compat_wrappers.o \
    config.o \
    csw.o \
    ddnoise.o \
    debugger.o \
    debugger_symbols.o \
    disc.o \
    fdi2raw.o \
    fdi.o \
    fullscreen.o\
    gui-allegro.o \
    hfe.o \
    i8271.o \
    ide.o \
    imd.o \
    joystick.o\
    keyboard.o \
    keydef-allegro.o \
    led.o \
    logging.o \
    map.o \
    main.o \
    mem.o \
    midi-windows.o \
    mmccard.o \
    model.o \
    mouse.o \
    music2000.o \
    music4000.o \
    music5000.o \
    pal.o \
    paula.o \
    savestate.o \
    scsi.o \
    sdf-acc.o \
    sdf-geo.o \
    serial.o \
    sn76489.o \
    sound.o \
    sprow.o \
    sysacia.o \
    sysvia.o \
    tape.o \
    tapecat-allegro.o \
    tapenoise.o \
    tsearch.o \
    tube.o \
    uef.o \
    uservia.o \
    vdfs.o \
    via.o \
    vidalleg.o \
    video.o \
    wd1770.o \
    win.o \
    x86.o \
    x86dasm.o \
    z80.o \
    z80dis.o \
    resid.o

NS32KOBJ = \
    32016.o \
    32016_debug.o \
    Decode.o \
    mem32016.o \
    Trap.o \
    Profile.o \
    NSDis.o

SIDOBJ = \
    convolve.o \
    convolve-sse.o \
    envelope.o \
    extfilt.o \
    filter.o \
    pot.o \
    sid.o \
    voice.o \
    wave6581__ST.o \
    wave6581_P_T.o \
    wave6581_PS_.o \
    wave6581_PST.o \
    wave8580__ST.o \
    wave8580_P_T.o \
    wave8580_PS_.o \
    wave8580_PST.o \
    wave.o

MC6809OBJ = mc6809_debug.o mc6809_dis.o mc6809nc.o

PDP11OBJ = \
    pdp11.o \
    pdp11_debug.o \
    copro-pdp11.o

M68000OBJ = \
    mc68000tube.o \
    m68kops.o \
    m68kcpu.o \
    m68kdasm.o

ARMEMUOBJ = armdis.o \
    armemu.o \
    arminit.o \
    armmem.o \
    armsupp.o \
    bag.o \
    thumbemu.o

LIBS = -lz -lallegro_audio -lallegro_acodec -lallegro_primitives -lallegro_dialog -lallegro_image -lallegro_font -lallegro -mwindows -lgdi32 -lwinmm -lstdc++

all : b-em.exe hdfmt.exe jstest.exe gtest.exe

b-em.exe: $(OBJ) $(SIDOBJ) $(NS32KOBJ) $(MC6809OBJ) $(PDP11OBJ)  $(M68000OBJ) $(ARMEMUOBJ)
	$(CC) $(LDFLAGS) $(OBJ) $(SIDOBJ) $(NS32KOBJ) $(MC6809OBJ) $(PDP11OBJ) $(M68000OBJ) $(ARMEMUOBJ) -o "b-em.exe" $(LIBS)

clean :
	del *.o *.exe *.res

%.o : %.c
	$(CC) $(CFLAGS) -c $<

%.o : %.cc
	$(CPP) $(CXXFLAGS) -c $<

b-em.res: b-em.rc
	$(WINDRES) -i $< --input-format=rc -o b-em.res -O coff

hdfmt.exe: hdfmt.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o hdfmt.exe hdfmt.c

jstest.exe: jstest.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o jstest $(LIBS) -lallegro_main

GTEST_OBJ = gtest.o sdf-geo.o sdf-acc.o

gtest.exe: $(GTEST_OBJ)
	$(CC) $(CFLAGS) $(LDFLAGS) -o gtest $(GTEST_OBJ)
