# **************************************************************************
#    TI-99/4A read and write floppy images
#
#    Copyright (C) 2008 Michael Zapf (Michael.Zapf@mizapf.de)
#    Copyright (C) 2011 Gerhard Wiesinger (gerhard@wiesinger.com)
#
#    This program is free software; you can redistribute it and/or modify it
#    under the terms of the GNU General Public License as published by the Free
#    Software Foundation; either version 3 of the License, or (at your option)
#    any later version.
#
#    This program is distributed in the hope that it will be useful, but WITHOUT
#    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#    FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
#    more details.
#
#    You should have received a copy of the GNU General Public License along with
#    this program; if not, see <http://www.gnu.org/licenses/>.
#
# **************************************************************************

CC=gcc
CCFLAGS=-g -Wall -pedantic -std=c99
LDFLAGS=-g

MAKEFILE=Makefile
TARGET1=readti
OBJS1=readti.o
TARGET2=writeti
OBJS2=writeti.o

ORIGDIR=orig
NEWDIR=new
PATCHFILE=ti99.patch

.c.o: 
	$(CC) -c $(CCFLAGS) $< 

all: $(TARGET1) $(TARGET2) $(PATCHFILE)

$(TARGET1): $(OBJS1)
	$(CC) $(LDFLAGS) -o $(TARGET1) $(OBJS1)
#	strip $(TARGET1)

$(TARGET2): $(OBJS2)
	$(CC) $(LDFLAGS) -o $(TARGET2) $(OBJS2)
#	strip $(TARGET2)

$(PATCHFILE): $(MAKEFILE) $(TARGET1).c $(TARGET2).c
	mkdir -p $(NEWDIR)
	cp $(MAKEFILE) $(TARGET1).c $(TARGET2).c DOC.TXT $(NEWDIR)
	diff -Nur $(ORIGDIR) $(NEWDIR) > $(PATCHFILE); exit 0

clean:
	rm -f $(TARGET1) $(OBJS1) $(TARGET2) $(OBJS2) $(PATCHFILE)
