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
CPPFLAGS     = -DBEM -DVERSION=\"$(VERSION)\" -DINCLUDE_DEBUGGER -DUSE_MEMORY_POINTER -DMODET -DMODE32 -DBEEBEM $(ALLEGRO_INC)
CFLAGS       = -std=gnu99 $(COMMON_FLAGS)
CXXFLAGS     = -std=gnu++11 $(COMMON_FLAGS)
LDFLAGS      = $(ALLEGRO_LIB)

CC           = cc
CXX          = c++
WINDRES      = windres
RM           = del /f

OBJ = \
    6502.o \
    6502debug.o \
    6502tube.o \
    6809tube.o \
    65816.o \
    acia.o \
    adc.o \
    arm.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 \
    mmb.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 \
    textsave.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

DARMOBJ = \
    darm.o \
    darm-tbl.o \
    armv7.o \
    armv7-tbl.o \
    thumb.o \
    thumb-tbl.o \
    thumb2.o \
    thumb2-decoder.o \
    thumb2-tbl.o

LIBS = -lz -lallegro_audio -lallegro_acodec -lallegro_primitives -lallegro_dialog -lallegro_image -lallegro_font -lallegro -lallegro_main -lwinmm -mwindows

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

clean :
	-$(RM) *.o
	-$(RM) *.exe
	-$(RM) *.res

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

%.o : %.cc
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<

%.o : %.cpp
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<

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

b-em.exe : $(OBJ) $(SIDOBJ) $(NS32KOBJ) $(MC6809OBJ) $(PDP11OBJ)  $(M68000OBJ) $(ARMEMUOBJ) $(DARMOBJ) b-em.res
	$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)

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

jstest.exe : jstest.o
	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -lallegro -lallegro_main

gtest.exe : sdf-gtest.o sdf-geo.o
	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@

sdf2imd.exe : sdf2imd.o sdf-geo.o
	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@

bsnapdump.exe : bsnapdump.o
	$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ -lz
