#	$Id: Makefile,v 2.9 1999/08/01 23:24:26 crosser Exp $
#
#	Copyright (c) 1997,1998 Eugene G. Crosser
#	Copyright (c) 1998 Bruce D. Lightner (DOS/Windows support)
#
#	You may distribute and/or use for any purpose modified or unmodified
#	copies of this software if you preserve the copyright notice above.
#
#	THIS SOFTWARE IS PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY
#	KIND, EITHER EXPRESSED OR IMPLIED.  IN NO EVENT WILL THE
#	COPYRIGHT HOLDER BE LIABLE FOR ANY DAMAGES RESULTING FROM THE
#	USE OF THIS SOFTWARE.
#
#	$Log: Makefile,v $
#	Revision 2.9  1999/08/01 23:24:26  crosser
#	DOS make in subdirectory
#	
#	Revision 2.8  1999/03/22 06:08:44  lightner
#	Fix logic to put ALL binaries into msdos/
#	Add extra library to keep DOS link command line short
#
#	Revision 2.7  1999/03/12 10:37:13  crosser
#	try workaround a problem with tmake
#
#	Revision 2.6  1999/03/12 10:19:17  crosser
#	add ctrl-Z in the end
#
#	Revision 2.5  1999/03/12 10:06:23  crosser
#	make usable with tc1.0
#
#	Revision 2.4  1999/03/10 22:34:43  crosser
#	sync with structure changes
#
#	Revision 2.3  1999/01/17 13:27:59  bruce
#	make win/dos versions in separate subdirs
#
#	Revision 2.2  1998/10/18 13:18:27  crosser
#	Put RCS logs and I.D. into the source
#
#	Revision 2.1  1998/02/16 06:13:29  lightner
#	Add $(MODEL) and change to "small"; improve cleanup logic
#	
#	Revision 2.0  1998/02/13 23:01:50  crosser
#	remove $@ for work with make from TC1.0
#	
#	Revision 1.2  1998/02/08 19:58:38  crosser
#	Support low memory: chunked saving etc.
#	
#	Revision 1.1  1998/01/18 02:16:45  crosser
#	Initial revision
#
# Modified by Bruce D. Lightner (lightner@lightner.net) on 1/8/98 to
# support builds under Borland International Turbo C++ Version 3.0.
#
# To "make" using Borland International's Turbo C++ toolset, ensure that
# your PATH points to the proper Turbo C++ binary directory, then enter
# the following commands:
#
#      make gclean
#      make

srcdir = ..

OPTS	= -DHAVE_CONFIG_H

CC	= tcc

#MODEL	= -ml
MODEL	= -ms

CFLAGS	= $(MODEL) -O2 -G -wsus -wpar

LD	= tlink
LDFLAGS	= $(MODEL) -M

AR	= tlib

# "-I." go first to include right config.h !
INC = -I. -I$(srcdir)

##### No need to touch anything below this line #####

LIBOBJS	= eph_read.obj eph_iob.obj eph_err.obj eph_cmd.obj \
	eph_io.obj eph_open.obj getopt.obj usleep.obj \
	strcscmp.obj comio.obj
LIBLIST1=+eph_read.obj+eph_iob.obj+eph_err.obj+eph_cmd.obj
LIBLIST2=+eph_io.obj+eph_open.obj+getopt.obj+usleep.obj
LIBLIST3=+strcscmp.obj+comio.obj


LIB2OBJS=a12scan.obj fnames.obj ctimez.obj filetime.obj \
	exifscan.obj
LIB2LIST1=+a12scan.obj+fnames.obj+ctimez.obj+filetime.obj
LIB2LIST2=+exifscan.obj

.c.obj:
	$(CC) $(CFLAGS) $(OPTS) $(INC) -c $<

all:	eph_io.lib photopc.exe epinfo.exe

eph_io.lib:	$(LIBOBJS)
	del eph_io.lib
	$(AR) eph_io.lib $(LIBLIST1)
	$(AR) eph_io.lib $(LIBLIST2)
	$(AR) eph_io.lib $(LIBLIST3)
	del eph_io.bak

ephextra.lib:      $(LIB2OBJS)
	del ephextra.lib
	$(AR) ephextra.lib $(LIB2LIST1)
	$(AR) ephextra.lib $(LIB2LIST2)
	del ephextra.bak

photopc.exe:     photopc.obj eph_io.lib ephextra.lib
	$(CC) $(LDFLAGS) photopc.obj eph_io.lib ephextra.lib

epinfo.exe:      epinfo.obj eph_io.lib ephextra.lib
	$(CC) $(LDFLAGS) epinfo.obj eph_io.lib ephextra.lib

tidyup:
	del ephextra.lib
	del ephextra.bak
	del eph_io.bak
	del *.map
	del *.obj

clean:	tidyup
	del eph_io.lib
	del photopc.exe
	del epinfo.exe
	rmdir $(T)

MKOBJ = $(CC) $(CFLAGS) $(OPTS) $(INC) -c


photopc.obj: $(srcdir)/photopc.c $(srcdir)/eph_io.h $(srcdir)/a12scan.h $(srcdir)/fnames.h $(srcdir)/ctimez.h $(srcdir)/filetime.h $(srcdir)/getopt.h $(srcdir)/strcscmp.h
	$(MKOBJ) -ophotopc.obj $(srcdir)/photopc.c

epinfo.obj: $(srcdir)/epinfo.c $(srcdir)/a12scan.h $(srcdir)/exifscan.h $(srcdir)/fnames.h $(srcdir)/ctimez.h $(srcdir)/filetime.h $(srcdir)/getopt.h $(srcdir)/strcscmp.h
	$(MKOBJ) -oepinfo.obj $(srcdir)/epinfo.c

a12scan.obj: $(srcdir)/a12scan.c $(srcdir)/a12scan.h
	$(MKOBJ) -oa12scan.obj $(srcdir)/a12scan.c

exifscan.obj: $(srcdir)/exifscan.c $(srcdir)/exifscan.h
	$(MKOBJ) -oexifscan.obj $(srcdir)/exifscan.c

fnames.obj: $(srcdir)/fnames.c $(srcdir)/fnames.h $(srcdir)/ctimez.h
	$(MKOBJ) -ofnames.obj $(srcdir)/fnames.c

ctimez.obj: $(srcdir)/ctimez.c $(srcdir)/ctimez.h
	$(MKOBJ) -octimez.obj $(srcdir)/ctimez.c

filetime.obj: $(srcdir)/filetime.c $(srcdir)/filetime.h $(srcdir)/ctimez.h
	$(MKOBJ) -ofiletime.obj $(srcdir)/filetime.c

eph_read.obj: $(srcdir)/eph_read.c $(srcdir)/eph_io.h $(srcdir)/comio.h $(srcdir)/usleep.h
	$(MKOBJ) -oeph_read.obj $(srcdir)/eph_read.c

eph_iob.obj: $(srcdir)/eph_iob.c $(srcdir)/eph_io.h
	$(MKOBJ) -oeph_iob.obj $(srcdir)/eph_iob.c

eph_err.obj: $(srcdir)/eph_err.c $(srcdir)/eph_io.h $(srcdir)/eph_priv.h
	$(MKOBJ) -oeph_err.obj $(srcdir)/eph_err.c

eph_cmd.obj: $(srcdir)/eph_cmd.c $(srcdir)/eph_io.h $(srcdir)/eph_priv.h
	$(MKOBJ) -oeph_cmd.obj $(srcdir)/eph_cmd.c

eph_io.obj: $(srcdir)/eph_io.c $(srcdir)/eph_io.h $(srcdir)/eph_priv.h $(srcdir)/usleep.h $(srcdir)/comio.h
	$(MKOBJ) -oeph_io.obj $(srcdir)/eph_io.c

eph_open.obj: $(srcdir)/eph_open.c $(srcdir)/eph_io.h $(srcdir)/eph_priv.h $(srcdir)/usleep.h $(srcdir)/comio.h $(srcdir)/usleep.h
	$(MKOBJ) -oeph_open.obj $(srcdir)/eph_open.c

getopt.obj: $(srcdir)/getopt.c $(srcdir)/getopt.h
	$(MKOBJ) -ogetopt.obj $(srcdir)/getopt.c

usleep.obj: $(srcdir)/usleep.c
	$(MKOBJ) -ousleep.obj $(srcdir)/usleep.c

strcscmp.obj: $(srcdir)/strcscmp.c
	$(MKOBJ) -ostrcscmp.obj $(srcdir)/strcscmp.c

comio.obj: $(srcdir)/comio.c
	$(MKOBJ) -ocomio.obj $(srcdir)/comio.c

