# TI-99/sim Makefile for Linux

GAMES_DIR = /usr/local/games
DATA_DIR  = /usr/local/share/games
INSTALL   = /usr/bin/install

all: ti99sim

install:
	$(INSTALL) -d $(DATA_DIR)/ti99sim
	$(INSTALL) -d $(DATA_DIR)/ti99sim/roms
	$(INSTALL) -d $(DATA_DIR)/ti99sim/cartridges
	$(INSTALL) -d $(GAMES_DIR)/ti99sim
	@if [ -x src ]; then \
	  $(INSTALL) -s src/sdl/ti99sim-sdl $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) -s src/util/convert-ctg $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) -s src/util/decode $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) -s src/util/disk $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) -s src/util/dumpcpu $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) -s src/util/dumpgrom $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) -s src/util/mkspch $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) -s src/console/ti99sim-console $(GAMES_DIR)/ti99sim; \
	else \
	  $(INSTALL) ti99sim-sdl $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) convert-ctg $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) decode $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) disk $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) dumpcpu $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) dumpgrom $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) mkspch $(GAMES_DIR)/ti99sim; \
	  $(INSTALL) ti99sim-console $(GAMES_DIR)/ti99sim; \
	fi

clean:
	@if [ -x src ]; then \
	  rm -f *~ include/*~ doc/*~; \
	  $(MAKE) -C src/core clean; \
	  $(MAKE) -C src/console clean; \
	  $(MAKE) -C src/sdl clean; \
	  $(MAKE) -C src/util clean; \
	fi

ti99sim:
	@if [ -x src ]; then \
	  $(MAKE) -C src/core; \
	  $(MAKE) -C src/console; \
	  $(MAKE) -C src/sdl; \
	  $(MAKE) -C src/util; \
	fi
