all: progs libs
#
# Makefile to build bmeps using Visual C++ 5.0 or above
#

#
# START OF FIRST CONFIGURATION SECTION.
#
# You may need to customize this section.
#

# FLAGS FOR XCOPY TO OVERWRITE EXISTING FILES
# Does xcopy need a special option to overwrite
# files without prompting?
XCOPYFL= /Y



# INSTALLATION TARGET DIRECTORY
# Where do you want to install the software?
PROGRAMS=C:\Programs
VENDOR=Krause
PREFIX=$(PROGRAMS)\$(VENDOR)



# LIBRARY LOCATION
# Where do the libraries reside?
# We need:
# - zlib (required)
# - libpng (required)
# - jpeg-6b (optional)
# - NetPBM (optional)
# Toggle setting to build DLLs
# LIBSRC=C:\P\DLL-LIB
LIBSRC=C:\P\LIB-STT



# COMPILER, LINKER AND LIBRARIAN PROGRAMS
# Which programs to use for compiling and linking?
CC=CL
LD=LINK
LIB=LIB



# VISUAL C DIRECTORY
# Where is Visual C?
# Directories lib, include and bin must be beyound this.
#
VC=$(PROGRAMS)\Microsoft Visual Studio\Vc98
# VC=D:\Programme\DevStudio\Vc



# SYSTEM CONFIGURATION DIRECTORY
SCD=	-DSYSCONFDIR=\"C:\\ETC\"



# ZLIB SUPPORT
# As zlib is required you need to change this section
# only for DLL-linking.
# Leave it as is for static linking.
ZL_DEF=-DHAVE_ZLIB_H=1
ZL_DIR=-I$(LIBSRC)\Include
# Use next lines to use static zlib
ZL_LIB=zlib.lib
ZL_CP_CMD=echo No need to copy a DLL for zlib.
# # Use next two lines to use zlib DLL
# ZL_LIB=zdll.lib
# ZL_CP_CMD=xcopy $(LIBSRC)\bin\zlib1.dll $(PREFIX)\bin\ /S $(XCOPYFL)




# PNGLIB requires ZLIB!
# libpng is required too, this section should not need
# changes.
PNG_DEF=-DHAVE_LIBPNG=1
PNG_DIR=-I$(LIBSRC)\Include
PNG_LIB=libpng.lib
PNGEPSOBJ=pngeps.obj
# Toggle the next two lines when building DLL-linked.
PNG_CP_CMD=echo No need to copy a DLL for libpng
# PNG_CP_CMD=xcopy $(LIBSRC)\bin\libpng.dll $(PREFIX)\bin\ /S $(XCOPYFL)


# JPEGLIB
# Toggle this section if you have the JPEG library.
JPG_DEF=-DHAVE_JPEGLIB_H=0
JPEG_CP_CMD=echo No need to copy a DLL for libjpeg
# JPG_DEF=-DHAVE_JPEGLIB_H=1
# JPG_DIR=-I$(LIBSRC)\Include
# JPG_LIB=libjpeg.lib
# JPGEPSOBJ=jpgeps.obj
# # Toggle the next two lines when building DLL-linked.
# JPEG_CP_CMD=echo No need to copy a DLL for libjpeg
# # JPEG_CP_CMD=xcopy $(LIBSRC)\bin\libjpeg.dll $(PREFIX)\bin\ /S $(XCOPYFL)



# NETPBM
# Toggle this section if you have the NetPBM library.
PNM_DEF=-DHAVE_PNM_H=0
PNM_CP_CMD=echo No need to copy a DLL for NetPBM.
# PNM_DEF=-DHAVE_PNM_H=1
# PNM_DIR=-I$(LIBSRC)\Include
# PNM_LIB=netpbm.lib
# PNMEPSOBJ=pnmeps.obj
# # Toggle the next two lines when building DLL-linked
# PNM_CP_CMD=echo No need to copy a DLL for NetPBM.
# # PNM_CP_CMD=xcopy $(LIBSRC)\bin\netpbm.dll $(PREFIX)\bin\ /S $(XCOPYFL)





#
# END OF FIRST CONFIGURATION SECTION.
#
# NOTE: There is a second configuration section at
# the end of this file. You may need to customize
# this section too.
#



#
# START OF FIXED OPTIONS SECTION
#
LIBS= $(BZL_LIB) $(ZL_LIB) 

DLLF1= /DLL /nologo /RELEASE /INCREMENTAL:NO /PDB:NONE
DLLF2= /SUBSYSTEM:CONSOLE /MACHINE:I386
DLLF3= /LIBPATH:. /LIBPATH:"$(VC)\LIB" /LIBPATH:"$(LIBSRC)\LIB" /LIBPATH:"$(PREFIX)\lib"
DLLF4= kernel32.lib user32.lib advapi32.lib 
DLLFLAGS= $(DLLF1) $(DLLF2) $(DLLF3) $(DLLF4)

EXEF1= /nologo /RELEASE /INCREMENTAL:NO
EXEF1= /SUBSYSTEM:CONSOLE /MACHINE:I386
EXEF3= /LIBPATH:. /LIBPATH:"$(VC)\LIB" /LIBPATH:"$(LIBSRC)\LIB" /LIBPATH:"$(PREFIX)\lib"
EXEF4= kernel32.lib user32.lib advapi32.lib 
EXEFLAGS= $(EXEF1) $(EXEF2) $(EXEF3) $(EXEF4)

CDLLRT= /MD /GD
CSTTRT= /MT
CDEF1=  /O2 /W3 /D "WIN32" /D "_WIN32" /D "NDEBUG" /D "_CONSOLE" /QI0f /QIfdiv
CDEF2=  -I. -I.. -I"$(PREFIX)\include"
CDEF3=  $(ZL_DEF) $(ZL_DIR) $(PNG_DEF) $(PNG_DIR)
CDEF4=  $(JPG_DEF) $(JPG_DIR) $(PNM_DEF) $(PNM_DIR)

CDLLFLAGS= /nologo $(CDLLRT) $(CDEF1) $(CDEF2) $(CDEF3) $(CDEF4)
CSTTFLAGS= /nologo $(CSTTRT) $(CDEF1) $(CDEF2) $(CDEF3) $(CDEF4)

clean:
	-ERASE *.obj
	-ERASE *.lib
	-ERASE *.dll
	-ERASE *.exe

#
# END OF FIXED OPTIONS SECTION
#



#
# START OF PROJECT SECTION
#


libs:	bmeps.lib
progs:	bmeps.exe

LIBOBJ= bmeps.obj pngeps.obj jpgeps.obj pnmeps.obj bmepsoe.obj

bmeps.exe:	bmepsm.obj bmeps.lib
	$(LD) $(EXEFLAGS) /out:bmeps.exe bmepsm.obj bmeps.lib $(LIBS)

install:	all
	-mkdir $(PREFIX)
	-mkdir $(PREFIX)\include
	-mkdir $(PREFIX)\bin
	-mkdir $(PREFIX)\lib
	-mkdir $(PREFIX)\man
	-mkdir $(PREFIX)\man\man1
	-mkdir $(PREFIX)\docu
	-mkdir $(PREFIX)\docu\bmeps
	xcopy *.exe $(PREFIX)\bin\ $(XCOPYFL)
	xcopy *.lib $(PREFIX)\lib\ $(XCOPYFL)
	-xcopy *.dll $(PREFIX)\bin\ $(XCOPYFL)
	xcopy *.h $(PREFIX)\include\ $(XCOPYFL)
	-xcopy man\man1\bmeps.1 $(PREFIX)\man\man1\ /S $(XCOPYFL)
	-xcopy DOCU\*.pdf $(PREFIX)\docu\bmeps\ /S $(XCOPYFL)
	-$(ZL_CP_CMD)
	-$(PNG_CP_CMD)
	-$(JPEG_CP_CMD)
	-$(PNM_CP_CMD)

#
# END OF PROJECT SECTION
#



#
# START OF SECOND CONFIGURATION SECTION
#



# COMPILING C MODULES
# Toggle this section to build DLL
.c.obj:
	$(CC) $(CSTTFLAGS) /c $*.c
# .c.obj:
#	$(CC) $(CDLLFLAGS) /c $*.c



#
# BUILDING THE BMEPS LIBRARY
# Toggle thissection to build a DLL.
#
bmeps.lib:	$(LIBOBJ)
	$(LIB) /OUT:bmeps.lib $(LIBOBJ)
# bmeps.lib:	$(LIBOBJ)
#	LINK $(DLLFLAGS) /out:bmeps.dll /IMPLIB:bmeps.lib /DEF:bmeps.def $(LIBOBJ) $(LIBS) $(PNG_LIB) $(JPEG_LIB) $(PNM_LIB) $(ZL_LIB)

#
# END OF SECOND CONFIGURATION SECTION
#

