fukasawa e60969
# Sample makefile for rpng-win / rpng2-win / wpng using MSVC and NMAKE.
fukasawa e60969
# Greg Roelofs
fukasawa e60969
# Last modified:  2 June 2007
fukasawa e60969
#
fukasawa e60969
#	The programs built by this makefile are described in the book,
fukasawa e60969
#	"PNG:  The Definitive Guide," by Greg Roelofs (O'Reilly and
fukasawa e60969
#	Associates, 1999).  Go buy a copy, eh?  Well, OK, it's not
fukasawa e60969
#	generally for sale anymore, but it's the thought that counts,
fukasawa e60969
#	right?  (Hint:  http://www.libpng.org/pub/png/book/ )
fukasawa e60969
#
fukasawa e60969
# Invoke this makefile from a DOS prompt window via:
fukasawa e60969
#
fukasawa e60969
#	%devstudio%\vc\bin\vcvars32.bat
fukasawa e60969
#	nmake -nologo -f Makefile.w32
fukasawa e60969
#
fukasawa e60969
# where %devstudio% is the installation directory for MSVC / DevStudio.  If
fukasawa e60969
# you get "environment out of space" errors, create a desktop shortcut with
fukasawa e60969
# "c:\windows\command.com /e:4096" as the program command line and set the
fukasawa e60969
# working directory to this directory.  Then double-click to open the new
fukasawa e60969
# DOS-prompt window with a bigger environment and retry the commands above.
fukasawa e60969
#
fukasawa e60969
# This makefile assumes libpng and zlib have already been built or downloaded
fukasawa e60969
# and are in subdirectories at the same level as the current subdirectory
fukasawa e60969
# (as indicated by the PNGPATH and ZPATH macros below).  Edit as appropriate.
fukasawa e60969
#
fukasawa e60969
# Note that the names of the dynamic and static libpng and zlib libraries
fukasawa e60969
# used below may change in later releases of the libraries.  This makefile
fukasawa e60969
# builds statically linked executables, but that can be changed by uncom-
fukasawa e60969
# menting the appropriate PNGLIB and ZLIB lines.
fukasawa e60969
fukasawa e60969
!include <ntwin32.mak></ntwin32.mak>
fukasawa e60969
fukasawa e60969
fukasawa e60969
# macros --------------------------------------------------------------------
fukasawa e60969
fukasawa e60969
PNGPATH = ../libpng
fukasawa e60969
PNGINC = -I$(PNGPATH)
fukasawa e60969
#PNGLIB = $(PNGPATH)/pngdll.lib
fukasawa e60969
PNGLIB = $(PNGPATH)/libpng.lib
fukasawa e60969
fukasawa e60969
ZPATH = ../zlib
fukasawa e60969
ZINC = -I$(ZPATH)
fukasawa e60969
#ZLIB = $(ZPATH)/zlibdll.lib
fukasawa e60969
ZLIB = $(ZPATH)/zlibstat.lib
fukasawa e60969
fukasawa e60969
WINLIBS = -defaultlib:user32.lib gdi32.lib
fukasawa e60969
# ["real" apps may also need comctl32.lib, comdlg32.lib, winmm.lib, etc.]
fukasawa e60969
fukasawa e60969
INCS = $(PNGINC) $(ZINC)
fukasawa e60969
RLIBS = $(PNGLIB) $(ZLIB) $(WINLIBS)
fukasawa e60969
WLIBS = $(PNGLIB) $(ZLIB)
fukasawa e60969
fukasawa e60969
CC = cl
fukasawa e60969
LD = link
fukasawa e60969
RM = del
fukasawa e60969
CPPFLAGS = $(INCS)
fukasawa e60969
CFLAGS = -nologo -O -W3 $(cvars)
fukasawa e60969
# [note that -W3 is an MSVC-specific compilation flag ("all warnings on")]
fukasawa e60969
# [see %devstudio%\vc\include\win32.mak for cvars macro definition]
fukasawa e60969
O = .obj
fukasawa e60969
E = .exe
fukasawa e60969
fukasawa e60969
RLDFLAGS = -nologo -subsystem:windows
fukasawa e60969
WLDFLAGS = -nologo
fukasawa e60969
fukasawa e60969
RPNG  = rpng-win
fukasawa e60969
RPNG2 = rpng2-win
fukasawa e60969
WPNG  = wpng
fukasawa e60969
fukasawa e60969
ROBJS  = $(RPNG)$(O) readpng$(O)
fukasawa e60969
ROBJS2 = $(RPNG2)$(O) readpng2$(O)
fukasawa e60969
WOBJS  = $(WPNG)$(O) writepng$(O)
fukasawa e60969
fukasawa e60969
EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
fukasawa e60969
fukasawa e60969
fukasawa e60969
# implicit make rules -------------------------------------------------------
fukasawa e60969
fukasawa e60969
.c$(O):
fukasawa e60969
	$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
fukasawa e60969
fukasawa e60969
fukasawa e60969
# dependencies --------------------------------------------------------------
fukasawa e60969
fukasawa e60969
all:  $(EXES)
fukasawa e60969
fukasawa e60969
$(RPNG)$(E): $(ROBJS)
fukasawa e60969
	$(LD) $(RLDFLAGS) -out:$@ $(ROBJS) $(RLIBS)
fukasawa e60969
fukasawa e60969
$(RPNG2)$(E): $(ROBJS2)
fukasawa e60969
	$(LD) $(RLDFLAGS) -out:$@ $(ROBJS2) $(RLIBS)
fukasawa e60969
fukasawa e60969
$(WPNG)$(E): $(WOBJS)
fukasawa e60969
	$(LD) $(WLDFLAGS) -out:$@ $(WOBJS) $(WLIBS)
fukasawa e60969
fukasawa e60969
$(RPNG)$(O):	$(RPNG).c readpng.h
fukasawa e60969
$(RPNG2)$(O):	$(RPNG2).c readpng2.h
fukasawa e60969
$(WPNG)$(O):	$(WPNG).c writepng.h
fukasawa e60969
fukasawa e60969
readpng$(O):	readpng.c readpng.h
fukasawa e60969
readpng2$(O):	readpng2.c readpng2.h
fukasawa e60969
writepng$(O):	writepng.c writepng.h
fukasawa e60969
fukasawa e60969
fukasawa e60969
# maintenance ---------------------------------------------------------------
fukasawa e60969
fukasawa e60969
clean:
fukasawa e60969
#	ideally we could just do this:
fukasawa e60969
#	$(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS)
fukasawa e60969
#	...but the Windows "DEL" command is none too bright, so:
fukasawa e60969
	$(RM) r*$(E)
fukasawa e60969
	$(RM) w*$(E)
fukasawa e60969
	$(RM) r*$(O)
fukasawa e60969
	$(RM) w*$(O)