# $Id: Makefile.in,v 1.10 2003/06/03 12:27:12 nigel Exp $
# MacOS X makefile for Basilisk II. Slightly based on the Unix one

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


CC = @CC@
CXX = @CXX@
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
CPPFLAGS = @CPPFLAGS@ -I../include -I. @CPUINCLUDES@
DEFS = @DEFS@ @DEFINES@ -D_REENTRANT
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@

## Files
OBJ_DIR = build
GENSRCS = cpudefs.cpp cpuemu.cpp cpustbl.cpp cputbl.h

# Wrappers which split the very large cpuemu.cpp into smaller compile units
GENEMUS = cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp \
	  cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp

# Symlinks to files in other directories
GENLINK = README.txt install-sh \
	  config.guess config.sub \
	  sys_unix.cpp timer_unix.cpp user_strings_unix.h

GEN  = $(GENEMUS) $(GENSRCS)

SRCS =  BasiliskII.icns Controller.h Controller.mm Credits.html \
	Emulator.h Emulator.mm EmulatorView.h EmulatorView.mm English.lproj \
	NNThread.h NNThread.m PrefsEditor.h PrefsEditor.mm \
	ToDo.html Versions.html \
	audio_macosx.mm extfs_macosx.mm macos_util_macosx.h main_macosx.h \
	main_macosx.mm misc_macosx.h misc_macosx.mm prefs_macosx.cpp \
	sysdeps.h video_macosx.mm video_macosx.h
APP = $(OBJ_DIR)/BasiliskII.app

## Rules

.PHONY: mostlyclean clean distclean depend dep
.SUFFIXES:
.SUFFIXES: .c .cpp .s .o .h

all: $(APP)

ide: $(OBJ_DIR) $(GEN) $(SRCS)
	open BasiliskII.pbproj

test: $(APP)
	open $(APP)

$(OBJ_DIR)::
	@[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1


$(APP): $(OBJ_DIR) $(GEN) $(SRCS)
	pbxbuild -buildstyle Deployment	|| rm -fr $(APP)
#	pbxbuild			|| rm -fr $(APP)

BasiliskII.icns :
	touch $@

mostlyclean:
	rm -fr English.lproj/*~* $(OBJ_DIR)/* core* *.core *~ *.bak

clean: mostlyclean
	rm -f $(GEN)
	rm -f cpudefs.cpp cputmp*.s cpufast*.s cpustbl.cpp

distclean: clean
	rm -fr $(OBJ_DIR)
	rm -fr $(GENLINK)
	rm -f config.cache config.log config.status config.h config.h.in
	rm -f configure
	rm -f Makefile




$(OBJ_DIR)/build68k: ../uae_cpu/build68k.c
	$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(LDFLAGS) $< -o $@

$(OBJ_DIR)/cpuopti: ../uae_cpu/cpuopti.c
	$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(LDFLAGS) $< -o $@

$(OBJ_DIR)/gencpu: cpudefs.cpp ../uae_cpu/gencpu.c ../uae_cpu/readcpu.cpp
	$(CXX) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(CXXFLAGS) $(LDFLAGS) $^ -o $@



cpudefs.cpp: $(OBJ_DIR)/build68k ../uae_cpu/table68k
	$(OBJ_DIR)/build68k < ../uae_cpu/table68k > $@

cpuemu.cpp cpustbl.cpp cputbl.h: $(OBJ_DIR)/gencpu
	$<


$(GENEMUS) : cpuemu.cpp
	for i in 1 2 3 4 5 6 7 8; \
	do \
	printf "#define  PART_%d\n#include \"%s\"\n" $$i $<  >cpuemu$$i.cpp; \
	done


cpufast.s: cpuemu.s $(OBJ_DIR)/cpuopti
	$(OBJ_DIR)/cpuopti <cpuemu.s >$@ || mv cputmp.s $@

cpuemu.s: cpuemu.cpp
	$(CXX) $(CPPFLAGS) $(DEFS) -S $(CXXFLAGS) $< -o $@

#-------------------------------------------------------------------------
# DO NOT DELETE THIS LINE -- make depend depends on it.
