1 # Sample makefile for rpng-win / rpng2-win / wpng using MSVC and NMAKE. 2 # Greg Roelofs 3 # Last modified: 2 June 2007 4 # 5 # The programs built by this makefile are described in the book, 6 # "PNG: The Definitive Guide," by Greg Roelofs (O'Reilly and 7 # Associates, 1999). Go buy a copy, eh? Well, OK, it's not 8 # generally for sale anymore, but it's the thought that counts, 9 # right? (Hint: http://www.libpng.org/pub/png/book/ ) 10 # 11 # Invoke this makefile from a DOS prompt window via: 12 # 13 # %devstudio%\vc\bin\vcvars32.bat 14 # nmake -nologo -f Makefile.w32 15 # 16 # where %devstudio% is the installation directory for MSVC / DevStudio. If 17 # you get "environment out of space" errors, create a desktop shortcut with 18 # "c:\windows\command.com /e:4096" as the program command line and set the 19 # working directory to this directory. Then double-click to open the new 20 # DOS-prompt window with a bigger environment and retry the commands above. 21 # 22 # This makefile assumes libpng and zlib have already been built or downloaded 23 # and are in subdirectories at the same level as the current subdirectory 24 # (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate. 25 # 26 # Note that the names of the dynamic and static libpng and zlib libraries 27 # used below may change in later releases of the libraries. This makefile 28 # builds statically linked executables, but that can be changed by uncom- 29 # menting the appropriate PNGLIB and ZLIB lines. 30 31 !include <ntwin32.mak> 32 33 34 # macros -------------------------------------------------------------------- 35 36 PNGPATH = ../libpng 37 PNGINC = -I$(PNGPATH) 38 #PNGLIB = $(PNGPATH)/pngdll.lib 39 PNGLIB = $(PNGPATH)/libpng.lib 40 41 ZPATH = ../zlib 42 ZINC = -I$(ZPATH) 43 #ZLIB = $(ZPATH)/zlibdll.lib 44 ZLIB = $(ZPATH)/zlibstat.lib 45 46 WINLIBS = -defaultlib:user32.lib gdi32.lib 47 # ["real" apps may also need comctl32.lib, comdlg32.lib, winmm.lib, etc.] 48 49 INCS = $(PNGINC) $(ZINC) 50 RLIBS = $(PNGLIB) $(ZLIB) $(WINLIBS) 51 WLIBS = $(PNGLIB) $(ZLIB) 52 53 CC = cl 54 LD = link 55 RM = del 56 CPPFLAGS = $(INCS) 57 CFLAGS = -nologo -O -W3 $(cvars) 58 # [note that -W3 is an MSVC-specific compilation flag ("all warnings on")] 59 # [see %devstudio%\vc\include\win32.mak for cvars macro definition] 60 O = .obj 61 E = .exe 62 63 RLDFLAGS = -nologo -subsystem:windows 64 WLDFLAGS = -nologo 65 66 RPNG = rpng-win 67 RPNG2 = rpng2-win 68 WPNG = wpng 69 70 ROBJS = $(RPNG)$(O) readpng$(O) 71 ROBJS2 = $(RPNG2)$(O) readpng2$(O) 72 WOBJS = $(WPNG)$(O) writepng$(O) 73 74 EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) 75 76 77 # implicit make rules ------------------------------------------------------- 78 79 .c$(O): 80 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< 81 82 83 # dependencies -------------------------------------------------------------- 84 85 all: $(EXES) 86 87 $(RPNG)$(E): $(ROBJS) 88 $(LD) $(RLDFLAGS) -out:$@ $(ROBJS) $(RLIBS) 89 90 $(RPNG2)$(E): $(ROBJS2) 91 $(LD) $(RLDFLAGS) -out:$@ $(ROBJS2) $(RLIBS) 92 93 $(WPNG)$(E): $(WOBJS) 94 $(LD) $(WLDFLAGS) -out:$@ $(WOBJS) $(WLIBS) 95 96 $(RPNG)$(O): $(RPNG).c readpng.h 97 $(RPNG2)$(O): $(RPNG2).c readpng2.h 98 $(WPNG)$(O): $(WPNG).c writepng.h 99 100 readpng$(O): readpng.c readpng.h 101 readpng2$(O): readpng2.c readpng2.h 102 writepng$(O): writepng.c writepng.h 103 104 105 # maintenance --------------------------------------------------------------- 106 107 clean: 108 # ideally we could just do this: 109 # $(RM) $(EXES) $(ROBJS) $(ROBJS2) $(WOBJS) 110 # ...but the Windows "DEL" command is none too bright, so: 111 $(RM) r*$(E) 112 $(RM) w*$(E) 113 $(RM) r*$(O) 114 $(RM) w*$(O) 115