###########################################################################
#        Copyright 1986-1992 FTP Software, Inc.
#
# Filename: \WINDOWS\SAMPLES\MAKEFILE
#
# Makefile for sample windows accessing the PC/TCP PCTCPAPI.DLL
#  note: this makefile assumes the DLL source and makefile are in
#  the DLL subdirectory directory below this one.
#
# Environment variables this makefile expects to be set:
#	INCLUDE		header file directory(s) (for CL)
#	LIB		library directory(s) (for LINK) -- note:
#			  you must be using the segmented linker
#
# Edit History:
#  07-20-92  rcq  took out references to lib.lib, now using OBJS, made
#		   other modifications for nmake compatibility.
#  29-Sep-92 rcq  got rid of some unneeded macros in compile lines and
#                  changed "CFLAGS" to "WCFLAGS"
#
###########################################################################

LIBS = pctcpapi libw slibcew

# Path to root of the PC/TCP development kit tree:
PCTCP	=..\..
INCDIR  = $(PCTCP)\include

# The next lines for debugging in CodeView (or CodeView/Windows)
#WCFLAGS = -DASSERT -DDEBUG -Od -Gsw -Zi -Zl -Zp
#LFLAGS = /NOE/NOD/MAP/CO/STACK:30000
# --or-- the next lines for general release
WCFLAGS = -DASSERT -Od -Gsw -Zp -Zl -W3
LFLAGS = /NOE/NOD/MAP/STACK:30000

LIBOBJS = cgarf.wo fmters.wo oplaint.wo pplaint.wo

all: techos.exe uecho.exe uechos.exe uechosd.exe


###############################  techos  #################################

techos.exe:  techos.wo techos.def techos.res $(LIBOBJS)
	link $(LFLAGS) techos.wo $(LIBOBJS),,,$(LIBS),techos.def
	rc techos.res techos.exe

# Update the resource if necessary
techos.res: techos.rc
    rc -r techos.rc

# Make a symbol file, for debugging
techos.sym:  techos.map
	mapsym techos.map

techos.wo:  techos.c fmters.h plaints.h techos.h \
  $(INCDIR)\pctcp\winapp.h


###################### uecho : UDP Echo Client #############################
uecho.exe:  uecho.wo uecho.def uecho.res $(LIBOBJS) 
	link $(LFLAGS) uecho.wo $(LIBOBJS),,,$(LIBS),uecho.def
	rc uecho.res uecho.exe

# Update the resource if necessary
uecho.res: uecho.rc uecho.h
    rc -r uecho.rc

# Make a symbol file, for debugging
uecho.sym:  uecho.map
	mapsym uecho.map

uecho.wo:  uecho.c cgarf.h fmters.h plaints.h uecho.h \
  $(INCDIR)\pctcp\dns_lib.h $(INCDIR)\pctcp\winapp.h


#################### uechos : UDP Echo Server #############################
uechos.exe:  uechos.wo uechos.def uechos.res $(LIBOBJS) 
	link $(LFLAGS) uechos.wo $(LIBOBJS),,,$(LIBS),uechos.def
	rc uechos.res uechos.exe

# Update the resource if necessary
uechos.res: uechos.rc uechos.h
    rc -r uechos.rc

# Make a symbol file, for debugging
uechos.sym:  uechos.map
	mapsym uechos.map

uechos.wo:  uechos.c cgarf.h fmters.h plaints.h uechos.h \
  $(INCDIR)\pctcp\winapp.h
	cl  $(WCFLAGS) -c -Fo$@ uechos.c
 


###############################  uechosd  ################################
# To avoid creating a command line too long for make to handle, we create
#  a temporary "link reference file" with commands on seperate lines, then
#  feed this file to the linker.

uechosd.exe:  uechosd.wo uechosd.def uechosd.res $(LIBOBJS) dll\uechosdl.lib
	echo uechosd.wo $(LIBOBJS)			> link_ref.tmp
	echo $@ $(LFLAGS)				>>link_ref.tmp
	echo uechosd					>>link_ref.tmp
	echo $(LIBS) dll\uechosdl			>>link_ref.tmp
	echo uechosd.def				>>link_ref.tmp
	link @link_ref.tmp
	del link_ref.tmp
	rc uechosd.res uechosd.exe

# Update the resource if necessary
uechosd.res: uechosd.rc uechosd.h
    rc -r uechosd.rc

# Make a symbol file, for debugging
uechosd.sym:  uechosd.map
	mapsym uechosd.map

uechosd.wo:  uechosd.c cgarf.h fmters.h plaints.h uechosd.h \
  $(INCDIR)\pctcp\winapp.h


########################### uechosdl.dll #################################

# Build the DLL -- in a separate directory because of conflicts in
#  C compilation flags for DLL objects.
dll\uechosdl.lib:
	cd dll
	@echo --------------------------------------------------------
	@echo -- Now in DLL\ subdirectory building the uechosdl.dll -- 
	@echo --------------------------------------------------------
	@echo -  If this make command fails, type "make all"       -
	@echo -  (after that is done, cd .. and 'make all' again)  -
	@echo --------------------------------------------------------
#the following usually fails due to lack of memory
#this line needs manual modification to replace 'make' with 'nmake'
	make all
	@cd ..


###############################  library  ################################

cgarf.wo:  cgarf.c cgarf.h
	cl  $(WCFLAGS) -c -Fo$@ cgarf.c
	
fmters.wo:  fmters.c fmters.h $(INCDIR)\pctcp\winapp.h
	cl  $(WCFLAGS) -c -Fo$@ fmters.c
	
oplaint.wo: oplaint.c plaints.h $(INCDIR)\pctcp\winapp.h
	cl  $(WCFLAGS) -c -Fo$@ oplaint.c
	
pplaint.wo:  pplaint.c plaints.h fmters.h $(INCDIR)\pctcp\winapp.h
	cl  $(WCFLAGS) -c -Fo$@ pplaint.c

##############################  housekeeping  #############################

clean:	
	del *.?o
	del *.obj
	del *.map
cleanall: clean
	del *.res
	del *.exe
	del *.dll
	del *.lib

# eof
