# CPDIST Makefile for the GNU C/C++ Compiler on the Commodore Amiga
#
# (c)Copyright 1992-93 by Tobias Ferber.
#
# This file is part of CPDIST.
#
# CPDIST 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 1 of the License, or
# (at your option) any later version.
#
# CPDIST 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 CPDIST; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

CC=gccv

# -DNO_GETKEY   use gets() instead of device dependent getkey()
# -DNO_PERROR   don't use perror()

CFLAGS= -O

# CPDIST will compile w/o Amiga dependent material (amiga.lib & includes)
# if   cpdist.c    is compiled w/  -DNO_GETKEY
# and  filecopy.c  is compiled w/o -UAMIGA

# getkey() needs libcurses.a and libtermlib.a on unix machines
LIBS= -L/usr/os-lib -lamiga -L/usr/lib -lcurses


# *** / CPDIST / ***

.PHONY: all

all: cpdist

#add getkey.o to the rhs if compiled w/o -DNO_GETKEY
cpdist: main.o args.o msg.o cpdist.o keys.o filecopy.o getkey.o
	$(CC) $(CFLAGS) -o $@ $(LIBS) $?

main.o: main.c cpdist.h
	$(CC) $(CFLAGS) -c -o $@ $<

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

msg.o: msg.c cpdist.h
	$(CC) $(CFLAGS) -c -o $@ $<

cpdist.o: cpdist.c cpdist.h
	$(CC) $(CFLAGS) -c -o $@ $<

keys.o: keys.c cpdist.h
	$(CC) $(CFLAGS) -c -o $@ $<
#	$(CC) $(CFLAGS) -DNO_GETKEY -c -o $@ $<

#only needed if cpdist.o is _NOT_ compiled w/ -DNO_GETKEY
getkey.o: getkey.c getkey.h
	$(CC) -Iinclude: $(CFLAGS) -c -o $@ $<

#use -UAMIGA to use c.lib's malloc() instead of exec.library's AllocMem()
filecopy.o: filecopy.c filecopy.h
	$(CC) $(CFLAGS) -Iinclude: -c -o $@ $<
#	$(CC) $(CFLAGS) -UAMIGA -c -o $@ $<


# *** / GETKEY / ***

getkey: getkey.c getkey.h
	$(CC) $(CFLAGS) -DTEST -o $@ $< $(LIBS)


# *** / CLEAN / ***

.PHONY: clean

clean:
	rm *.o cpdist


# *** / DEPEND / ***

.PHONY: depend

depend:
	$(CC) -MM $(CFLAGS) *.c > .depend


#include the dependency file (if it exists)

ifeq (.depend,$(wildcard .depend))
include .depend
endif
