# Unix makefile for ARAnyM
# Inspired in BasiliskII's Makefile

#makefile := $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST))

## System specific configuration
@SET_MAKE@
SHELL = /bin/sh

prefix = @prefix@
includedir = @includedir@
exec_prefix = @exec_prefix@
bindir = @bindir@
datadir = @datadir@
datarootdir = @datarootdir@
mandir = @mandir@
man1dir = $(mandir)/man1
docdir = $(prefix)/share/doc
builddir = @builddir@
top_srcdir = @top_srcdir@
srcdir = $(top_srcdir)/src

DESTDIR =
ARCH := @CPU_TYPE@
DEPEND := $(builddir)/depend_$(ARCH)
makefile := $(builddir)/Makefile


CC = @CC@
CXX = @CXX@
CFLAGS1 = @CFLAGS@
CFLAGS = @CFLAGS@ $(SDL_CFLAGS) $(ZLIB_CFLAGS)
CXXFLAGS1 = @CXXFLAGS@
CXXFLAGS = @CXXFLAGS@ $(SDL_CFLAGS) $(ZLIB_CFLAGS)
CPPFLAGS = -I$(GEN_DIR) -I$(srcdir)/include -I$(srcdir)/Unix -I$(builddir) -I$(srcdir)/natfeat @CPUINCLUDES@ @CPPFLAGS@ $(DISASM_CFLAGS)
ARCHFLAGS = @ARCHFLAGS@
GENCPU_FLAGS = @GENCPU_FLAGS@
WFLAGS = @WFLAGS@
DEFS = @DEFS@ @DEFINES@
DISASM_CFLAGS=@DISASM_CFLAGS@
DISASM_LIBS=@DISASM_LIBS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ $(SDL_LIBS) $(ZLIB_LIBS) $(DISASM_LIBS)
SDL_LIBS = @SDL_LIBS@
SDL_CONFIG = @SDL_CONFIG@
SDL_CFLAGS = @SDL_CFLAGS@
ZLIB_LIBS = @ZLIB_LIBS@
ZLIB_CFLAGS = @ZLIB_CFLAGS@
SYSSRCS = @SYSSRCS@
CPUSRCS = @CPUSRCS@
GENCPUSRCS = @GENCPUSRCS@
DSPSRCS = @DSPSRCS@
MIDISEQSRCS = @MIDISEQSRCS@
NFCDROMSRCS = @NFCDROMSRCS@
NFPCISRCS = @NFPCISRCS@
NFOSMESASRCS = @NFOSMESASRCS@
NFJPEGSRCS = @NFJPEGSRCS@
NFVDISRCS = @NFVDISRCS@
NFCLIPBOARDSRCS = @NFCLIPBOARDSRCS@
PARALLELX86SRCS = @PARALLELX86SRCS@
PARALLELPARPORTSRCS = @PARALLELPARPORTSRCS@
SERIALSRCS = @SERIALSRCS@
GUISDLSRCS = @GUISDLSRCS@
DYNGLSRCS = @DYNGLSRCS@
DBGSP = @DBGSP@
TAPIF = @TAPIF@
USBHOSTSRCS = @USBHOSTSRCS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
GENCOMP_ARCH = @GENCOMP_ARCH@
GENCOMP_SRC = gencomp$(filter _$(GENCOMP_ARCH),_arm)

ACLOCAL = aclocal
AUTOCONF = autoconf
AUTOHEADER = autoheader
PERL = @PERL@
MKDIR_P = @MKDIR_P@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

host_alias = @host_alias@
host_triplet = @host@

## Files
SRCS = main.cpp \
	Unix/main_unix.cpp \
	Unix/vm_alloc.cpp \
	Unix/host_clock_unix.cpp \
	acia.cpp \
	acsifdc.cpp \
	adler32.c \
	aradata.cpp \
	aranym_exception.cpp \
	ata.cpp \
	audio_conv.cpp \
	audio_dma.cpp \
	audio_crossbar.cpp \
	blitter.cpp \
	bootos.cpp \
	bootos_tos.cpp \
	bootos_emutos.cpp \
	bootos_linux.cpp \
	cdrom.cpp \
	cfgopts.cpp \
	dirty_rects.cpp \
	dsp.cpp \
	disasm-glue.cpp \
	disasm-builtin.cpp \
	emul_op.cpp \
	natfeats.cpp \
	fakeio.cpp \
	hardware.cpp \
	host.cpp \
	host_audio.cpp \
	host_clock.cpp \
	hostscreen.cpp \
	hostscreen_opengl.cpp \
	host_surface.cpp \
	host_surface_opengl.cpp \
	ide.cpp \
	identify.cpp \
	ikbd.cpp \
	input.cpp \
	joypads.cpp \
	logo.cpp \
	md5.cpp \
	mfp.cpp \
	midi.cpp \
	midi_file.cpp \
	mmu.cpp \
	ndebug.cpp \
	ncr5380.cpp \
	parallel.cpp \
	parallel_file.cpp \
	parameters.cpp \
	romdiff.cpp \
	rtc.cpp \
	serial.cpp \
	scc.cpp \
	tools.cpp \
	videl.cpp \
	videl_zoom.cpp \
	yamaha.cpp \
	natfeat/nf_base.cpp \
	natfeat/nf_objs.cpp \
	natfeat/xhdi.cpp \
	natfeat/nfaudio.cpp \
	natfeat/nfbootstrap.cpp \
	natfeat/nf_basicset.cpp \
	natfeat/debugprintf.cpp \
	$(MIDISEQSRCS) \
	$(NFCDROMSRCS) \
	$(NFPCISRCS) \
	$(USBHOSTSRCS) \
	$(NFOSMESASRCS) \
	$(NFJPEGSRCS) \
	$(NFVDISRCS) \
	$(NFCLIPBOARDSRCS) \
	$(PARALLELX86SRCS) \
	$(PARALLELPARPORTSRCS) \
	$(SERIALSRCS) \
	$(SYSSRCS) \
	$(CPUSRCS) \
	$(DSPSRCS) \
	$(LILOSRCS) \
	$(GUISDLSRCS) \
	$(DYNGLSRCS)

GENSRCS = \
	uae_cpu/build68k.c \
	uae_cpu/cpuopti.c \
	uae_cpu/gencpu.c \
	uae_cpu/readcpu.cpp \
	uae_cpu/compiler/$(GENCOMP_SRC).c

BUNDLE_RESOURCES = \
	$(srcdir)/Unix/darwin/busybee.icns \
	$(top_srcdir)/data/logo.png
	
BUNDLE_LOCALIZATON_FOLDERS = \
	$(srcdir)/Unix/darwin/*.lproj
	
BUNDLE_CONTENTS = \
	$(srcdir)/Unix/darwin/Info.plist \
	$(srcdir)/Unix/darwin/PkgInfo 	

BUNDLE_FRAMEWORKS =  /Library/Frameworks/SDL.framework /Library/Frameworks/SDL_image.framework

BEOS_RESOURCES = \
	$(top_srcdir)/aranym.rdef

BEOS_XRES = @BEOS_XRES@
BEOS_RC = @BEOS_RC@
BEOS_SETVERSION = @BEOS_SETVERSION@

APP = aranym
APP_ARCH = aranym_$(ARCH)
APP_STATIC = aranym_static
APP_LIB = libaranym.a
APP_BUNDLE = ARAnyM.app
APP_IFC = aratapif
TARGET = @TARGET@
PACKAGE_VERSION = @PACKAGE_VERSION@

## Rules
AM_V_CC = $(am__v_CC_$(V))
am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
am__v_CC_0 = @echo "  CC    " $@;
AM_V_CXX = $(am__v_CXX_$(V))
am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
am__v_CXX_0 = @echo "  CXX   " $@;
AM_V_CXXLD = $(am__v_CXXLD_$(V))
am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
am__v_CXXLD_0 = @echo "  CXXLD " $@;
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo "  GEN   " $@;

.PHONY: install installdirs uninstall mostlyclean clean distclean depend $(APP_BUNDLE)
.SUFFIXES:
.SUFFIXES: .c .cpp .s .o .h .m .M

all: $(builddir)/version_date.h $(TARGET) $(TAPIF)

BUILD_SOURCES = \
	$(top_srcdir)/atari/nfosmesa/glfuncs.h \
	$(top_srcdir)/src/natfeat/nfosmesa/call-gl.c \
	$(top_srcdir)/src/natfeat/nfosmesa/dispatch-gl.c \
	$(top_srcdir)/atari/nfosmesa/ldg/osmesa.h \
	$(top_srcdir)/atari/nfosmesa/ldg/tiny_gl.h \
	$(top_srcdir)/atari/nfosmesa/osmesa_load.c \
	$(top_srcdir)/atari/nfosmesa/tinygl_load.c \
	$(top_srcdir)/atari/nfosmesa/link-tinygl.h \
	$(top_srcdir)/atari/nfosmesa/slb/tiny_gl.h \
	$(top_srcdir)/atari/nfosmesa/tinygl_loadslb.c \
	$(empty)

OBJ_DIR = obj_$(ARCH)
$(OBJ_DIR)::
	@[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1
GEN_DIR = gen_$(ARCH)
$(GEN_DIR)::
	@[ -d $(GEN_DIR) ] || mkdir $(GEN_DIR) > /dev/null 2>&1

define SRCS_LIST_TO_OBJS
	$(patsubst %,$(OBJ_DIR)/%.o, $(basename $(notdir $(GENCPUSRCS) $(SRCS))))
endef

$(builddir)/version_date.h: $(top_srcdir)/ChangeLog
	echo '/* generated from ChangeLog */' > $@
	sed -n '/^20[0-9][0-9]\/[0-9]*\/[0-9]/p' < $(top_srcdir)/ChangeLog | sed 's/^\(20[0-9][0-9]\/[0-9]*\/[0-9]*\).*/#define VERSION_DATE "\1"/;q' >> $@

OBJS = $(SRCS_LIST_TO_OBJS)

SRC_PATHS += $(sort $(GEN_DIR)/ $(dir $(SRCS)))
empty:=
space:= $(empty) $(empty)
VPATH += $(subst $(space),:,$(strip $(addprefix $(filter-out ./,$(srcdir)/), $(SRC_PATHS))))

$(APP): $(OBJ_DIR) $(GEN_DIR) $(BUILD_SOURCES) $(OBJS)
	$(AM_V_CXXLD)$(CXX) -o $@ $(LDFLAGS) $(ARCHFLAGS) $(OBJS) $(LIBS)
ifneq ($(BEOS_XRES),)
	$(BEOS_RC) -o $(APP).rsrc $(BEOS_RESOURCES)
endif
ifneq ($(BEOS_XRES),)
	$(BEOS_XRES) -o $(APP) $(APP).rsrc
endif
ifneq ($(BEOS_SETVERSION),)
	$(BEOS_SETVERSION) $(APP) \
		-app 0 9 0 d 0 \
		-short "$(APP) $(PACKAGE_VERSION)" \
		-long "$(APP) $(PACKAGE_VERSION)"
endif

$(APP_ARCH): $(OBJ_DIR) $(GEN_DIR) $(OBJS)
	$(AM_V_CXXLD)$(CXX) -o $@ $(LDFLAGS) $(ARCHFLAGS) $(OBJS) $(LIBS)

$(APP_STATIC): $(OBJ_DIR) $(GEN_DIR) $(OBJS)
	$(AM_V_CXXLD)$(CXX) -o $@ -static $(LDFLAGS) $(ARCHFLAGS) $(OBJS) $(LIBS)

$(APP_LIB): $(OBJ_DIR) $(GEN_DIR) $(OBJS)
	$(AM_V_CXXLD)$(LD) -r -o $@ $(LDFLAGS) $(ARCHFLAGS) $(OBJS) $(LIBS)

$(APP_BUNDLE): $(APP)
	rm -rf $(APP_BUNDLE)
	mkdir -p $(APP_BUNDLE)/Contents
	cp -r $(BUNDLE_CONTENTS) $(APP_BUNDLE)/Contents
	mkdir -p $(APP_BUNDLE)/Contents/MacOS
	cp $(APP) $(APP_BUNDLE)/Contents/MacOS
	#mkdir -p $(APP_BUNDLE)/Contents/ARAnyM
	mkdir -p $(APP_BUNDLE)/Contents/Resources
	mkdir -p $(APP_BUNDLE)/Contents/Frameworks
	for fwFolder in $(BUNDLE_FRAMEWORKS); do \
	    if test -d $$fwFolder; then \
		cp -rp $$fwFolder $(APP_BUNDLE)/Contents/Frameworks/; \
	    fi; \
	done
	cp -r $(BUNDLE_RESOURCES) $(APP_BUNDLE)/Contents/Resources
	for locFolder in $(BUNDLE_LOCALIZATON_FOLDERS); do \
		cp -R $$locFolder $(APP_BUNDLE)/Contents/Resources/; \
	done
	find $(APP_BUNDLE)/Contents/Resources -type d -and \( -name CVS -or -name \*~.nib \) -or -name \*~ -or -name \*.bak | xargs rm -rf

install: $(APP) $(TAPIF) doc/$(APP).1 doc/$(APP)-jit.1 doc/$(APP)-mmu.1 doc/$(APP_IFC).1 installdirs
	$(INSTALL_PROGRAM) $(APP) $(DESTDIR)$(bindir)/$(APP)
	if [ "x$(APP_IFC)" = "x$(TAPIF)" ]; then \
	$(INSTALL_PROGRAM) $(APP_IFC) $(DESTDIR)$(bindir)/$(APP_IFC);\
	$(INSTALL_DATA) doc/$(APP_IFC).1 $(DESTDIR)$(man1dir)/$(APP_IFC).1 ;\
	fi
	$(INSTALL_DATA) doc/$(APP).1 $(DESTDIR)$(man1dir)/$(APP).1
	$(INSTALL_DATA) doc/$(APP)-jit.1 $(DESTDIR)$(man1dir)/$(APP)-jit.1
	$(INSTALL_DATA) doc/$(APP)-mmu.1 $(DESTDIR)$(man1dir)/$(APP)-mmu.1
	$(INSTALL_DATA) $(srcdir)/../ChangeLog $(DESTDIR)$(docdir)/$(APP)/changelog
	$(INSTALL_DATA) $(srcdir)/../TODO $(DESTDIR)$(docdir)/$(APP)/TODO
	$(INSTALL_DATA) $(srcdir)/../AUTHORS $(DESTDIR)$(docdir)/$(APP)/AUTHORS
	$(INSTALL_DATA) $(srcdir)/../NEWS $(DESTDIR)$(docdir)/$(APP)/NEWS
	$(INSTALL_DATA) $(srcdir)/../README $(DESTDIR)$(docdir)/$(APP)/README
	$(INSTALL_DATA) $(srcdir)/../FAQ $(DESTDIR)$(docdir)/$(APP)/FAQ
	$(INSTALL_DATA) $(srcdir)/../COPYING $(DESTDIR)$(docdir)/$(APP)/COPYING
	$(INSTALL_DATA) $(srcdir)/../BUGS $(DESTDIR)$(docdir)/$(APP)/BUGS
	$(INSTALL_DATA) $(srcdir)/../INSTALL $(DESTDIR)$(docdir)/$(APP)/INSTALL
	$(INSTALL_DATA) $(srcdir)/../doc/config $(DESTDIR)$(docdir)/$(APP)/config
	$(INSTALL_DATA) $(srcdir)/../atari/newdesk.inf $(DESTDIR)$(datadir)/$(APP)/atari/newdesk.inf
	$(INSTALL_DATA) $(srcdir)/../atari/mmusetup.cnf $(DESTDIR)$(datadir)/$(APP)/atari/mmusetup.cnf
	$(INSTALL_DATA) $(srcdir)/../atari/hostfs/bdconfig.sys $(DESTDIR)$(datadir)/$(APP)/atari/hostfs/bdconfig.sys
	$(INSTALL_DATA) $(srcdir)/../atari/hostfs/README $(DESTDIR)$(datadir)/$(APP)/atari/hostfs/README
	$(INSTALL_DATA) $(srcdir)/../atari/nfosmesa/README $(DESTDIR)$(datadir)/$(APP)/atari/nfosmesa/README
	$(INSTALL_DATA) $(srcdir)/../atari/network/ethernet/nfeth-config/eth0-config.sh $(DESTDIR)$(datadir)/$(APP)/atari/network/eth0-config.sh
	$(INSTALL_DATA) $(srcdir)/../atari/network/ethernet/README $(DESTDIR)$(datadir)/$(APP)/atari/network/README
	$(INSTALL) $(srcdir)/../tools/arabridge $(DESTDIR)$(datadir)/$(APP)/arabridge
	$(INSTALL) $(srcdir)/../tools/floppy.sh $(DESTDIR)$(datadir)/$(APP)/floppy.sh
	$(INSTALL_DATA) $(srcdir)/../atari/tools/README $(DESTDIR)$(datadir)/$(APP)/atari/tools/README
	$(INSTALL_DATA) $(srcdir)/../atari/tools/pc101us.kbd.bz2 $(DESTDIR)$(datadir)/$(APP)/atari/tools/pc101us.kbd.bz2
	$(INSTALL_DATA) $(srcdir)/../atari/sound/README $(DESTDIR)$(datadir)/$(APP)/atari/sound/README
	$(INSTALL_DATA) $(srcdir)/../data/wm_icon.bmp $(DESTDIR)$(datadir)/$(APP)/wm_icon.bmp
	$(INSTALL_DATA) $(srcdir)/../data/logo.png $(DESTDIR)$(datadir)/$(APP)/logo.png
	
installdirs:
	$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) $(DESTDIR)$(datadir)/$(APP) $(DESTDIR)$(datadir)/$(APP)/atari $(DESTDIR)$(datadir)/$(APP)/atari/hostfs $(DESTDIR)$(datadir)/$(APP)/atari/nfcdrom $(DESTDIR)$(datadir)/$(APP)/atari/nfjpeg $(DESTDIR)$(datadir)/$(APP)/atari/nfosmesa $(DESTDIR)$(datadir)/$(APP)/atari/network $(DESTDIR)$(datadir)/$(APP)/atari/tools $(DESTDIR)$(datadir)/$(APP)/atari/sound $(DESTDIR)$(docdir)/$(APP)

uninstall:
	rm -f $(DESTDIR)$(bindir)/$(APP)
	if [ "x$(APP_IFC)" = "x$(TAPIF)" ]; then \
	rm -f $(DESTDIR)$(bindir)/$(APP_IFC);\
	rm -f $(DESTDIR)$(man1dir)/$(APP_IFC).1 ;\
	fi
	rm -f $(DESTDIR)$(man1dir)/$(APP).1
	rm -f $(DESTDIR)$(man1dir)/$(APP)-jit.1
	rm -f $(DESTDIR)$(man1dir)/$(APP)-mmu.1
	rm -f $(DESTDIR)$(docdir)/$(APP)/changelog
	rm -f $(DESTDIR)$(docdir)/$(APP)/TODO
	rm -f $(DESTDIR)$(docdir)/$(APP)/AUTHORS
	rm -f $(DESTDIR)$(docdir)/$(APP)/NEWS
	rm -f $(DESTDIR)$(docdir)/$(APP)/README
	rm -f $(DESTDIR)$(docdir)/$(APP)/FAQ
	rm -f $(DESTDIR)$(docdir)/$(APP)/COPYING
	rm -f $(DESTDIR)$(docdir)/$(APP)/BUGS
	rm -f $(DESTDIR)$(docdir)/$(APP)/INSTALL
	rm -f $(DESTDIR)$(docdir)/$(APP)/config
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/newdesk.inf
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/mmusetup.cnf
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/hostfs/bdconfig.sys
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/hostfs/README
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/nfosmesa/README
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/network/eth0-config.sh
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/network/README
	rm -f $(DESTDIR)$(datadir)/$(APP)/arabridge
	rm -f $(DESTDIR)$(datadir)/$(APP)/floppy.sh
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/tools/README
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/tools/pc101us.kbd.bz2
	rm -f $(DESTDIR)$(datadir)/$(APP)/atari/sound/README
	rm -f $(DESTDIR)$(datadir)/$(APP)/wm_icon.bmp
	rm -f $(DESTDIR)$(datadir)/$(APP)/logo.png
	rmdir $(DESTDIR)$(datadir)/$(APP)/atari/hostfs
	rmdir $(DESTDIR)$(datadir)/$(APP)/atari/nfcdrom
	rmdir $(DESTDIR)$(datadir)/$(APP)/atari/nfjpeg
	rmdir $(DESTDIR)$(datadir)/$(APP)/atari/nfosmesa
	rmdir $(DESTDIR)$(datadir)/$(APP)/atari/network
	rmdir $(DESTDIR)$(datadir)/$(APP)/atari/tools
	rmdir $(DESTDIR)$(datadir)/$(APP)/atari/sound
	rmdir $(DESTDIR)$(datadir)/$(APP)/atari
	rmdir $(DESTDIR)$(datadir)/$(APP)
	rmdir $(DESTDIR)$(docdir)/$(APP)

mostlyclean:
	rm -r -f $(APP) $(APP_BUNDLE) $(APP_ARCH) $(APP_LIB) $(APP_STATIC) $(TAPIF) cdromtest m68kdisasm $(OBJ_DIR)/* core* *.core *~ *.bak

clean: mostlyclean
	rm -rf $(GEN_DIR)

distclean: clean
	rm -rf $(OBJ_DIR)
	rm -f $(makefile)
	rm -f $(builddir)/config.cache $(builddir)/config.log $(builddir)/config.status $(builddir)/config.h
	rm -f $(DEPEND)
	rm -rf $(top_srcdir)/autom4te.cache

mrproper: distclean
	rm -f $(top_srcdir)/aclocal.m4 $(builddir)/configure $(top_srcdir)/config.h.in

bindistdirs:
	$(SHELL) $(top_srcdir)/mkinstalldirs tmpdist tmpdist$(bindir) tmpdist$(man1dir) tmpdist$(datadir)/$(APP) tmpdist$(datadir)/$(APP)/atari tmpdist$(datadir)/$(APP)/atari/hostfs tmpdist$(datadir)/$(APP)/atari/nfcdrom tmpdist$(datadir)/$(APP)/atari/nfjpeg tmpdist$(datadir)/$(APP)/atari/nfosmesa tmpdist$(datadir)/$(APP)/atari/network tmpdist$(datadir)/$(APP)/atari/tools tmpdist$(datadir)/$(APP)/atari/sound tmpdist$(docdir)/$(APP)

bindist: $(APP) $(TAPIF) $(top_srcdir)/doc/$(APP).1 $(top_srcdir)/doc/$(APP)-jit.1 $(top_srcdir)/doc/$(APP)-mmu.1 $(top_srcdir)/doc/$(APP_IFC).1 bindistdirs
	$(INSTALL_PROGRAM) $(APP) tmpdist$(bindir)/$(APP)
	if [ "x$(APP_IFC)" = "x$(TAPIF)" ]; then \
	$(INSTALL_PROGRAM) $(APP_IFC) tmpdist$(bindir)/$(APP_IFC);\
	$(INSTALL_DATA) $(top_srcdir)/doc/$(APP_IFC).1 tmpdist$(man1dir)/$(APP_IFC).1 ;\
	fi
	$(INSTALL_DATA) $(top_srcdir)/doc/$(APP).1 tmpdist$(man1dir)/$(APP).1
	$(INSTALL_DATA) $(top_srcdir)/doc/$(APP)-jit.1 tmpdist$(man1dir)/$(APP)-jit.1
	$(INSTALL_DATA) $(top_srcdir)/doc/$(APP)-mmu.1 tmpdist$(man1dir)/$(APP)-mmu.1
	$(INSTALL_DATA) $(top_srcdir)/ChangeLog tmpdist$(docdir)/$(APP)/changelog
	$(INSTALL_DATA) $(top_srcdir)/TODO tmpdist$(docdir)/$(APP)/TODO
	$(INSTALL_DATA) $(top_srcdir)/AUTHORS tmpdist$(docdir)/$(APP)/AUTHORS
	$(INSTALL_DATA) $(top_srcdir)/NEWS tmpdist$(docdir)/$(APP)/NEWS
	$(INSTALL_DATA) $(top_srcdir)/README tmpdist$(docdir)/$(APP)/README
	$(INSTALL_DATA) $(top_srcdir)/FAQ tmpdist$(docdir)/$(APP)/FAQ
	$(INSTALL_DATA) $(top_srcdir)/COPYING tmpdist$(docdir)/$(APP)/COPYING
	$(INSTALL_DATA) $(top_srcdir)/BUGS tmpdist$(docdir)/$(APP)/BUGS
	$(INSTALL_DATA) $(top_srcdir)/INSTALL tmpdist$(docdir)/$(APP)/INSTALL	
	$(INSTALL_DATA) $(top_srcdir)/doc/config tmpdist$(docdir)/$(APP)/config
	$(INSTALL_DATA) $(top_srcdir)/atari/newdesk.inf tmpdist$(datadir)/$(APP)/atari/newdesk.inf
	$(INSTALL_DATA) $(top_srcdir)/atari/mmusetup.cnf tmpdist$(datadir)/$(APP)/atari/mmusetup.cnf
	$(INSTALL_DATA) $(top_srcdir)/atari/hostfs/bdconfig.sys tmpdist$(datadir)/$(APP)/atari/hostfs/bdconfig.sys
	$(INSTALL_DATA) $(top_srcdir)/atari/hostfs/README tmpdist$(datadir)/$(APP)/atari/hostfs/README
	$(INSTALL_DATA) $(top_srcdir)/atari/nfosmesa/README tmpdist$(datadir)/$(APP)/atari/nfosmesa/README
	$(INSTALL_DATA) $(top_srcdir)/atari/network/ethernet/nfeth-config/eth0-config.sh tmpdist$(datadir)/$(APP)/atari/network/eth0-config.sh
	$(INSTALL_DATA) $(top_srcdir)/atari/network/ethernet/README tmpdist$(datadir)/$(APP)/atari/network/README
	$(INSTALL) $(top_srcdir)/tools/arabridge tmpdist$(datadir)/$(APP)/arabridge
	$(INSTALL) $(top_srcdir)/tools/floppy.sh tmpdist$(datadir)/$(APP)/floppy.sh
	$(INSTALL_DATA) $(top_srcdir)/atari/tools/README tmpdist$(datadir)/$(APP)/atari/tools/README
	$(INSTALL_DATA) $(top_srcdir)/atari/tools/pc101us.kbd.bz2 tmpdist$(datadir)/$(APP)/atari/tools/pc101us.kbd.bz2
	$(INSTALL_DATA) $(top_srcdir)/atari/sound/README tmpdist$(datadir)/$(APP)/atari/sound/README
	$(INSTALL_DATA) $(top_srcdir)/data/wm_icon.bmp tmpdist$(datadir)/$(APP)/wm_icon.bmp
	$(INSTALL_DATA) $(top_srcdir)/data/logo.png tmpdist$(datadir)/$(APP)/logo.png
	chmod -R a+r tmpdist
	cd tmpdist && GZIP=--best tar chozf ../$(APP).tar.gz *
	rm -rf tmpdist

devdist: mrproper 
	cd $(srcdir)/../../ && GZIP=--best tar chozf $(APP).tar.gz aranym

dist: distclean
	cd $(srcdir)/../../ && GZIP=--best tar chozf $(APP).tar.gz --exclude=autogen.sh --exclude=CVS --exclude=.cvsignore aranym

depend: $(builddir)/version_date.h
	$(AM_V_CC)$(CC) -MM $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CFLAGS) $(ARCHFLAGS) $(addprefix $(srcdir)/,$(filter %.c,$(SRCS))) | sed 's,^[^ ],$$(OBJ_DIR)/&,' > $(DEPEND)
	$(AM_V_CXX)$(CXX) -MM $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS) $(ARCHFLAGS) $(addprefix $(srcdir)/,$(filter %.cpp,$(SRCS))) | sed 's,^[^ ],$$(OBJ_DIR)/&,' >> $(DEPEND)
	$(AM_V_CC)$(CC) -MM $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CFLAGS1) $(addprefix $(srcdir)/,$(filter %.c,$(GENSRCS))) | sed 's,^[^ ],$$(GEN_DIR)/&,' >> $(DEPEND)
	$(AM_V_CXX)$(CXX) -MM $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS1) $(addprefix $(srcdir)/,$(filter %.cpp,$(GENSRCS))) | sed 's,^[^ ],$$(GEN_DIR)/&,' >> $(DEPEND)

$(OBJ_DIR)/%.o : %.c
	$(AM_V_CC)$(CC) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o : %.m
	$(AM_V_CC)$(CC) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o : %.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o : %.M
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/%.o : %.s
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@

$(GEN_DIR)/%.o : %.c
	$(AM_V_CC)$(CC) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CFLAGS1) -c $< -o $@
$(GEN_DIR)/%.o : %.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS1) -c $< -o $@
$(GEN_DIR)/%.o : %.s
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(CFLAGS) -c $< -o $@

$(GEN_DIR)/cpuopti: $(GEN_DIR)/cpuopti.o
	$(AM_V_CC)$(CC) $(LDFLAGS) -o $(GEN_DIR)/cpuopti $(GEN_DIR)/cpuopti.o
$(GEN_DIR)/build68k: $(GEN_DIR)/build68k.o
	$(AM_V_CC)$(CC) $(LDFLAGS) -o $(GEN_DIR)/build68k $(GEN_DIR)/build68k.o
$(GEN_DIR)/gencpu: $(GEN_DIR)/gencpu.o $(GEN_DIR)/readcpu.o $(GEN_DIR)/cpudefs.o
	$(AM_V_CXX)$(CXX) $(LDFLAGS) -o $(GEN_DIR)/gencpu $(GEN_DIR)/gencpu.o $(GEN_DIR)/readcpu.o $(GEN_DIR)/cpudefs.o
$(GEN_DIR)/gencomp: $(GEN_DIR)/$(GENCOMP_SRC).o $(GEN_DIR)/readcpu.o $(GEN_DIR)/cpudefs.o
	$(AM_V_CXX)$(CXX) $(LDFLAGS) -o $(GEN_DIR)/gencomp $(GEN_DIR)/$(GENCOMP_SRC).o $(GEN_DIR)/readcpu.o $(GEN_DIR)/cpudefs.o

$(GEN_DIR)/cpudefs.cpp: $(GEN_DIR)/build68k uae_cpu/table68k
	$(GEN_DIR)/build68k <$(srcdir)/uae_cpu/table68k > $(GEN_DIR)/cpudefs.cpp
$(GEN_DIR)/cpuemu.cpp: $(GEN_DIR)/gencpu
	cd $(GEN_DIR); ./gencpu
$(GEN_DIR)/compemu.cpp: $(GEN_DIR)/gencomp
	cd $(GEN_DIR); ./gencomp

$(GEN_DIR)/cpustbl_nf.cpp: $(GEN_DIR)/cpuemu.cpp 
$(GEN_DIR)/cpustbl.cpp: $(GEN_DIR)/cpuemu.cpp 
$(GEN_DIR)/cputbl.h: $(GEN_DIR)/cpuemu.cpp
$(GEN_DIR)/compstbl.cpp: $(GEN_DIR)/compemu.cpp
$(GEN_DIR)/comptbl.h: $(GEN_DIR)/compemu.cpp

$(OBJ_DIR)/cpustbl_nf.o: $(GEN_DIR)/cpustbl.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS) $(ARCHFLAGS) -DNOFLAGS -c $< -o $@
$(OBJ_DIR)/cpustbl.o: $(GEN_DIR)/cpustbl.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpudefs.o: $(GEN_DIR)/cpudefs.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/compstbl.o: $(GEN_DIR)/compstbl.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@

$(GEN_DIR)/cpustbl.o: $(GEN_DIR)/cpustbl.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS) -c $< -o $@
$(GEN_DIR)/cpudefs.o: $(GEN_DIR)/cpudefs.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(WFLAGS) $(CXXFLAGS) -c $< -o $@

ifdef GENCOMP_ARCH
$(OBJ_DIR)/compemu_support.o: compemu_support.cpp codegen_$(GENCOMP_ARCH).cpp compemu_midfunc_$(GENCOMP_ARCH).cpp $(GEN_DIR)/comptbl.h
endif

$(OBJ_DIR)/cpuemu1.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(GENCPU_FLAGS) -DPART_1 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu2.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(GENCPU_FLAGS) -DPART_2 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu3.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(GENCPU_FLAGS) -DPART_3 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu4.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(GENCPU_FLAGS) -DPART_4 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu5.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(GENCPU_FLAGS) -DPART_5 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu6.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(GENCPU_FLAGS) -DPART_6 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu7.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(GENCPU_FLAGS) -DPART_7 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu8.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) $(GENCPU_FLAGS) -DPART_8 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@

$(OBJ_DIR)/cpuemu1_nf.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_1 -DNOFLAGS $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu2_nf.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_2 -DNOFLAGS $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu3_nf.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_3 -DNOFLAGS $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu4_nf.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_4 -DNOFLAGS $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu5_nf.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_5 -DNOFLAGS $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu6_nf.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_6 -DNOFLAGS $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu7_nf.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_7 -DNOFLAGS $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/cpuemu8_nf.o: $(GEN_DIR)/cpuemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_8 -DNOFLAGS $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@

$(OBJ_DIR)/compemu1.o: $(GEN_DIR)/compemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_1 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/compemu2.o: $(GEN_DIR)/compemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_2 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/compemu3.o: $(GEN_DIR)/compemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_3 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/compemu4.o: $(GEN_DIR)/compemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_4 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/compemu5.o: $(GEN_DIR)/compemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_5 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/compemu6.o: $(GEN_DIR)/compemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_6 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/compemu7.o: $(GEN_DIR)/compemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_7 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@
$(OBJ_DIR)/compemu8.o: $(GEN_DIR)/compemu.cpp
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) $(DBGSP) -DPART_8 $(CXXFLAGS) $(ARCHFLAGS) -c $< -o $@

$(GEN_DIR)/cpufast.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp.s >$@ || mv $(GEN_DIR)/cputmp.s $@
	rm -f $(GEN_DIR)/cputmp.s
$(GEN_DIR)/cpufast1.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_1 -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp1.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp1.s >$@ || mv $(GEN_DIR)/cputmp1.s $@
	rm -f $(GEN_DIR)/cputmp1.s
$(GEN_DIR)/cpufast2.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_2 -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp2.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp2.s >$@ || mv $(GEN_DIR)/cputmp2.s $@
	rm -f $(GEN_DIR)/cputmp2.s
$(GEN_DIR)/cpufast3.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_3 -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp3.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp3.s >$@ || mv $(GEN_DIR)/cputmp3.s $@
	rm -f $(GEN_DIR)/cputmp3.s
$(GEN_DIR)/cpufast4.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_4 -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp4.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp4.s >$@ || mv $(GEN_DIR)/cputmp4.s $@
	rm -f $(GEN_DIR)/cputmp4.s
$(GEN_DIR)/cpufast5.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_5 -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp5.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp5.s >$@ || mv $(GEN_DIR)/cputmp5.s $@
	rm -f $(GEN_DIR)/cputmp5.s
$(GEN_DIR)/cpufast6.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_6 -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp6.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp6.s >$@ || mv $(GEN_DIR)/cputmp6.s $@
	rm -f $(GEN_DIR)/cputmp6.s
$(GEN_DIR)/cpufast7.s: $(GEN_DIR)/cpuemu.cpp $(OBJ_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_7 -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp7.s
	$(OBJ_DIR)/cpuopti <$(GEN_DIR)/cputmp7.s >$@ || mv $(GEN_DIR)/cputmp7.s $@
	rm -f $(GEN_DIR)/cputmp7.s
$(GEN_DIR)/cpufast8.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_8 -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp8.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp8.s >$@ || mv $(GEN_DIR)/cputmp8.s $@
	rm -f $(GEN_DIR)/cputmp8.s

$(GEN_DIR)/cpufast_nf.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DNOFLAGS -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp.s >$@ || mv $(GEN_DIR)/cputmp.s $@
	rm -f $(GEN_DIR)/cputmp.s
$(GEN_DIR)/cpufast1_nf.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_1 -DNOFLAGS -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp1.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp1.s >$@ || mv $(GEN_DIR)/cputmp1.s $@
	rm -f $(GEN_DIR)/cputmp1.s
$(GEN_DIR)/cpufast2_nf.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_2 -DNOFLAGS -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp2.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp2.s >$@ || mv $(GEN_DIR)/cputmp2.s $@
	rm -f $(GEN_DIR)/cputmp2.s
$(GEN_DIR)/cpufast3_nf.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_3 -DNOFLAGS -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp3.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp3.s >$@ || mv $(GEN_DIR)/cputmp3.s $@
	rm -f $(GEN_DIR)/cputmp3.s
$(GEN_DIR)/cpufast4_nf.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_4 -DNOFLAGS -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp4.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp4.s >$@ || mv $(GEN_DIR)/cputmp4.s $@
	rm -f $(GEN_DIR)/cputmp4.s
$(GEN_DIR)/cpufast5_nf.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_5 -DNOFLAGS -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp5.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp5.s >$@ || mv $(GEN_DIR)/cputmp5.s $@
	rm -f $(GEN_DIR)/cputmp5.s
$(GEN_DIR)/cpufast6_nf.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_6 -DNOFLAGS -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp6.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp6.s >$@ || mv $(GEN_DIR)/cputmp6.s $@
	rm -f $(GEN_DIR)/cputmp6.s
$(GEN_DIR)/cpufast7_nf.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_7 -DNOFLAGS -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp7.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp7.s >$@ || mv $(GEN_DIR)/cputmp7.s $@
	rm -f $(GEN_DIR)/cputmp7.s
$(GEN_DIR)/cpufast8_nf.s: $(GEN_DIR)/cpuemu.cpp $(GEN_DIR)/cpuopti
	$(AM_V_CXX)$(CXX) $(CPPFLAGS) $(DEFS) -DPART_8 -DNOFLAGS -S $(CXXFLAGS) $(ARCHFLAGS) $< -o $(GEN_DIR)/cputmp8.s
	$(GEN_DIR)/cpuopti <$(GEN_DIR)/cputmp8.s >$@ || mv $(GEN_DIR)/cputmp8.s $@
	rm -f $(GEN_DIR)/cputmp8.s

DYNGL_PL = $(top_srcdir)/tools/dyngl.pl

$(top_srcdir)/atari/nfosmesa/glfuncs.h: $(top_srcdir)/tools/glfuncs.h $(DYNGL_PL)
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -macros $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

$(top_srcdir)/src/natfeat/nfosmesa/call-gl.c: $(top_srcdir)/atari/nfosmesa/glfuncs.h $(DYNGL_PL)
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -calls $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

$(top_srcdir)/src/natfeat/nfosmesa/dispatch-gl.c: $(top_srcdir)/atari/nfosmesa/glfuncs.h $(DYNGL_PL)
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -dispatch $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

$(top_srcdir)/atari/nfosmesa/ldg/osmesa.h: $(top_srcdir)/tools/glfuncs.h $(DYNGL_PL) $(top_srcdir)/atari/nfosmesa/gltypes.h
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -ldgheader $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

$(top_srcdir)/atari/nfosmesa/osmesa_load.c: $(top_srcdir)/tools/glfuncs.h $(DYNGL_PL)
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -ldgsource $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

$(top_srcdir)/atari/nfosmesa/ldg/tiny_gl.h: $(top_srcdir)/tools/glfuncs.h $(DYNGL_PL) $(top_srcdir)/atari/nfosmesa/gltypes.h
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -tinyldgheader $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

$(top_srcdir)/atari/nfosmesa/tinygl_load.c: $(top_srcdir)/tools/glfuncs.h $(DYNGL_PL)
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -tinyldgsource $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

$(top_srcdir)/atari/nfosmesa/link-tinygl.h: $(top_srcdir)/tools/glfuncs.h $(DYNGL_PL)
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -tinyldglink $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

$(top_srcdir)/atari/nfosmesa/slb/tiny_gl.h: $(top_srcdir)/tools/glfuncs.h $(DYNGL_PL) $(top_srcdir)/atari/nfosmesa/gltypes.h
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -tinyslbheader $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

$(top_srcdir)/atari/nfosmesa/tinygl_loadslb.c: $(top_srcdir)/tools/glfuncs.h $(DYNGL_PL)
	$(AM_V_GEN)if test -z "$(PERL)"; then \
		echo "$@ is out of date, but PERL not available" >&2; \
	else \
		$(PERL) $(DYNGL_PL) -tinyslbsource $(top_srcdir)/tools/glfuncs.h > $$$$.tmp && mv $$$$.tmp $@ || { $(RM) $$$$.tmp; false; } \
	fi

# For tests
$(GEN_DIR)/newcpu.s: newcpu.cpp
	$(CXX) -fverbose-asm $(CPPFLAGS) $(DEFS) -S $(CXXFLAGS) $< -o $@

$(GEN_DIR)/memory.s: memory.cpp
	$(CXX) -fverbose-asm $(CPPFLAGS) $(DEFS) -S $(CXXFLAGS) $< -o $@

$(APP_IFC): aratapif.c
	$(AM_V_CC)$(CC) $(LDFLAGS) $(CPPFLAGS) $(DEFS) $(WFLAGS) $(CFLAGS) $(ARCHFLAGS) -o $(APP_IFC) -DHAVE_AFINET $(srcdir)/Unix/aratapif.c

m68kdisasm: disasm-main.cpp disasm-glue.cpp disasm-builtin.cpp
	$(AM_V_CXXLD)$(CXX) $(LDFLAGS) $(CPPFLAGS) $(DEFS) $(WFLAGS) $(CFLAGS) $(ARCHFLAGS) -o $@ $(srcdir)/disasm-main.cpp $(DISASM_LIBS)

cdromtest: $(srcdir)/cdromtest.cpp $(srcdir)/natfeat/nfcdrom.cpp $(srcdir)/natfeat/nfcdrom_sdl.cpp $(srcdir)/natfeat/nfcdrom_linux.cpp $(srcdir)/natfeat/nfcdrom_win32.cpp
	$(AM_V_CC)$(CXX) $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(DEFS) $(WFLAGS) $(CFLAGS) $(ARCHFLAGS) -o $@ $(srcdir)/cdromtest.cpp $(LIBS)

gldiff:
	$(PERL) $(DYNGL_PL) -protos /usr/include/GL/gl.h /usr/include/GL/glext.h /usr/include/GL/osmesa.h | diff $(top_srcdir)/tools/glfuncs.h - || true
	$(PERL) $(DYNGL_PL) -macros $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/atari/nfosmesa/glfuncs.h - || true
	$(PERL) $(DYNGL_PL) -calls $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/src/natfeat/nfosmesa/call-gl.c - || true
	$(PERL) $(DYNGL_PL) -dispatch $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/src/natfeat/nfosmesa/dispatch-gl.c - || true
	$(PERL) $(DYNGL_PL) -ldgheader $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/atari/nfosmesa/ldg/osmesa.h - || true
	$(PERL) $(DYNGL_PL) -ldgsource $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/atari/nfosmesa/osmesa_load.c - || true
	$(PERL) $(DYNGL_PL) -tinyldgheader $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/atari/nfosmesa/ldg/tiny_gl.h - || true
	$(PERL) $(DYNGL_PL) -tinyldgsource $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/atari/nfosmesa/tinygl_load.c - || true
	$(PERL) $(DYNGL_PL) -tinyldglink $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/atari/nfosmesa/link-tinygl.h - || true
	$(PERL) $(DYNGL_PL) -tinyslbheader $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/atari/nfosmesa/slb/tiny_gl.h - || true
	$(PERL) $(DYNGL_PL) -tinyslbsource $(top_srcdir)/tools/glfuncs.h | diff $(top_srcdir)/atari/nfosmesa/tinygl_loadslb.c - || true

# Include dependencies
ifneq ($(wildcard $(DEPEND)),)
include $(DEPEND)
endif
