# CPDIST Makefile for Turbo C Version 1.0, MS-DOS
# This one is needed to run CPDIST under versions of MS-DOS <= V2.3
#
# (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.

TC_PATH= c:\devel\tc
TC_BIN_PATH= $(TC_PATH)\bin
TC_LIB_PATH= $(TC_PATH)\libs
TC_INCLUDE_PATH= $(TC_PATH)\include

CC= $(TC_BIN_PATH)\tcc.exe
LN= $(TC_BIN_PATH)\tlink.exe

# The memory model can be (s)mall, (m)edium, (c)ompact, (l)arge or (h)uge

MODEL= c

# CFLAGS should be taken from those:
#
# Turbo C  Version 1.0  Copyright (c) 1987 Borland International
# Syntax is: TCC [ options ] file[s]     * = default; -x- = turn switch x off
#   -1      80186/286 Instructions    -A      Disable non-ANSI extensions
#   -B      Compile via assembly      -C      Allow nested comments
#   -Dxxx   Define macro              -G      Generate for speed
#   -Ixxx   Include files directory   -K      Default char is unsigned
#   -Lxxx   Libraries directory       -M      Generate link map
#   -N      Check stack overflow      -O      Optimize jumps
#   -S      Produce assembly output   -Uxxx   Undefine macro
#   -Z      Optimize register usage   -a      Generate word alignment
#   -c      Compile only              -d      Merge duplicate strings
#   -exxx   Executable file name      -f    * Floating point emulator
#   -f87    8087 floating point       -f-     No floating point
#   -gnnn   Stop after N warnings     -innn   Maximum identifier length N
#   -jnnn   Stop after N errors       -k      Standard stack frame
#   -mc     Compact model             -mh     Huge Model
#   -ml     Large Model               -mm     Medium Model
#   -ms   * Small Model               -mt     Tiny Model
#   -nxxx   Output file directory     -oxxx   Object file name
#   -p      Pascal calls              -r    * Register variables
#   -u    * Underscores on externs    -w      Enable all warnings
#   -wxxx   Enable warning xxx        -w-xxx  Disable warning xxx
#   -y      Produce line number info  -zxxx   Set segment names

CFLAGS=\
	-I$(TC_INCLUDE_PATH)\
	-L$(TC_LIB_PATH)\
	$(DEFINES)\
	-N -O -G -Z -f- -d -A -m$(MODEL) -a -y -k -w-pia

# LFLAGS should be taken from those:
#
# /m = map file with publics
# /x = no map file at all
# /i = initialize all segments
# /l = include source line numbers
# /s = detailed map of segments
# /n = no default libraries
# /d = warn if duplicate symbols in libraries
# /c = lower case significant in symbols

LFLAGS= /x/l/d/c

OBJS= $(TC_LIB_PATH)\c0$(MODEL).obj
LIBS= $(TC_LIB_PATH)\c$(MODEL).lib

# Linking CPDIST in the usual way didn't work because the command line
# became too long for turbo make...
# However a so called 'response file' can be specified in the command
# line for TLINK.EXE via an @xxxx option with 'xxxx' being the response
# file. Since command line redirectioning was not supported by MAKE.EXE
# either I wrote 'MKLNK.EXE' which appends it's arguments to a file
# called 'TURBOC.$LN'. (This name is also used by TCC.EXE).
# MKLNK.C should be part of this distribution.

MKLNK= $(TC_BIN_PATH)\mklnk.exe
LINKFILE= turboc.$ln

# *** / LET's ROLL / ***

all: cpdist

cpdist: cpdist.exe

CPDIST_OBJS=\
	main.obj args.obj msg.obj cpdist.obj keys.obj getkey.obj filecopy.obj

cpdist.exe: $(CPDIST_OBJS) $(LINKFILE)
	$(LN) @$(LINKFILE)

# The response file has to be remade if we (makefile.TC) have been modified

$(LINKFILE): makefile.TC
	$(MKLNK)
	$(MKLNK) $(OBJS) +
	$(MKLNK) $(CPDIST_OBJS)
	$(MKLNK) cpdist.exe
	$(MKLNK) $(LFLAGS)
	$(MKLNK) $(LIBS)

main.obj: main.c cpdist.h
	$(CC) $(CFLAGS) -c -omain.obj main.c

args.obj: args.c
	$(CC) $(CFLAGS) -c -oargs.obj args.c

msg.obj: msg.c cpdist.h
	$(CC) $(CFLAGS) -c -omsg.obj msg.c

cpdist.obj: cpdist.c cpdist.h
	$(CC) $(CFLAGS) -c -ocpdist.obj cpdist.c

keys.obj: keys.c cpdist.h
	$(CC) $(CFLAGS) -c -okeys.obj keys.c

getkey.obj: getkey.c getkey.h
	$(CC) $(CFLAGS) -c -ogetkey.obj getkey.c

filecopy.obj: filecopy.c filecopy.h
	$(CC) $(CFLAGS) -c -ofilecopy.obj filecopy.c
