|
fukasawa |
e60969 |
# Sample makefile for rpng-win / rpng2-win / wpng using mingw32-gcc and make.
|
|
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 |
# make -f Makefile.mingw32
|
|
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 PNGDIR and ZDIR macros below). It makes no assumptions
|
|
fukasawa |
e60969 |
# at all about the mingw32 installation tree (W32DIR). 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 both statically and dynamically linked executables by default.
|
|
fukasawa |
e60969 |
# (You need only one set, but for testing it can be handy to have both.)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# macros --------------------------------------------------------------------
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
#PNGDIR = ../..# for libpng-x.y.z/contrib/gregbook builds
|
|
fukasawa |
e60969 |
PNGDIR = ../libpng-win32
|
|
fukasawa |
e60969 |
PNGINC = -I$(PNGDIR)
|
|
fukasawa |
e60969 |
PNGLIBd = $(PNGDIR)/libpng.dll.a # dynamically linked
|
|
fukasawa |
e60969 |
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
#ZDIR = ../../../zlib-win32# for libpng-x.y.z/contrib/gregbook builds
|
|
fukasawa |
e60969 |
ZDIR = ../zlib-win32
|
|
fukasawa |
e60969 |
ZINC = -I$(ZDIR)
|
|
fukasawa |
e60969 |
ZLIBd = $(ZDIR)/libzdll.a
|
|
fukasawa |
e60969 |
ZLIBs = $(ZDIR)/libz.a
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# change this to be the path where mingw32 installs its stuff:
|
|
fukasawa |
e60969 |
W32DIR =
|
|
fukasawa |
e60969 |
#W32DIR = /usr/local/cross-tools/i386-mingw32msvc
|
|
fukasawa |
e60969 |
W32INC = -I$(W32DIR)/include
|
|
fukasawa |
e60969 |
W32LIB = $(W32DIR)/lib/libuser32.a $(W32DIR)/lib/libgdi32.a
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
CC = gcc
|
|
fukasawa |
e60969 |
#CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
|
|
fukasawa |
e60969 |
LD = $(CC)
|
|
fukasawa |
e60969 |
RM = rm -f
|
|
fukasawa |
e60969 |
CPPFLAGS = $(INCS)
|
|
fukasawa |
e60969 |
CFLAGS = -O -Wall $(MINGW_CCFLAGS)
|
|
fukasawa |
e60969 |
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
|
fukasawa |
e60969 |
# [-ansi, -pedantic and -W can also be used]
|
|
fukasawa |
e60969 |
LDFLAGS = $(MINGW_LDFLAGS)
|
|
fukasawa |
e60969 |
O = .o
|
|
fukasawa |
e60969 |
E = .exe
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
INCS = $(PNGINC) $(ZINC) $(W32INC)
|
|
fukasawa |
e60969 |
RLIBSd = $(PNGLIBd) $(ZLIBd) $(W32LIB) -lm
|
|
fukasawa |
e60969 |
RLIBSs = $(PNGLIBs) $(ZLIBs) $(W32LIB) -lm
|
|
fukasawa |
e60969 |
WLIBSd = $(PNGLIBd) $(ZLIBd)
|
|
fukasawa |
e60969 |
WLIBSs = $(PNGLIBs) $(ZLIBs)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
RPNG = rpng-win
|
|
fukasawa |
e60969 |
RPNG2 = rpng2-win
|
|
fukasawa |
e60969 |
WPNG = wpng
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
ROBJSd = $(RPNG)$(O) readpng.pic$(O)
|
|
fukasawa |
e60969 |
ROBJS2d = $(RPNG2)$(O) readpng2.pic$(O)
|
|
fukasawa |
e60969 |
WOBJSd = $(WPNG)$(O) writepng.pic$(O)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
RPNGs = $(RPNG)-static
|
|
fukasawa |
e60969 |
RPNG2s = $(RPNG2)-static
|
|
fukasawa |
e60969 |
WPNGs = $(WPNG)-static
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
ROBJSs = $(RPNG)$(O) readpng$(O)
|
|
fukasawa |
e60969 |
ROBJS2s = $(RPNG2)$(O) readpng2$(O)
|
|
fukasawa |
e60969 |
WOBJSs = $(WPNG)$(O) writepng$(O)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E)
|
|
fukasawa |
e60969 |
DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
|
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 |
%.pic$(O): %.c
|
|
fukasawa |
e60969 |
$(CC) -c $(CPPFLAGS) $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# dependencies --------------------------------------------------------------
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
all: $(EXES)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
$(RPNGs)$(E): $(ROBJSs)
|
|
fukasawa |
e60969 |
$(LD) $(LDFLAGS) -o $@ $(ROBJSs) $(RLIBSs)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
$(RPNG)$(E): $(ROBJSd)
|
|
fukasawa |
e60969 |
$(LD) $(LDFLAGS) -o $@ $(ROBJSd) $(RLIBSd)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
$(RPNG2s)$(E): $(ROBJS2s)
|
|
fukasawa |
e60969 |
$(LD) $(LDFLAGS) -o $@ $(ROBJS2s) $(RLIBSs)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
$(RPNG2)$(E): $(ROBJS2d)
|
|
fukasawa |
e60969 |
$(LD) $(LDFLAGS) -o $@ $(ROBJS2d) $(RLIBSd)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
$(WPNGs)$(E): $(WOBJSs)
|
|
fukasawa |
e60969 |
$(LD) $(LDFLAGS) -o $@ $(WOBJSs) $(WLIBSs)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
$(WPNG)$(E): $(WOBJSd)
|
|
fukasawa |
e60969 |
$(LD) $(LDFLAGS) -o $@ $(WOBJSd) $(WLIBSd)
|
|
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.pic$(O): readpng.c readpng.h
|
|
fukasawa |
e60969 |
readpng2$(O) readpng2.pic$(O): readpng2.c readpng2.h
|
|
fukasawa |
e60969 |
writepng$(O) writepng.pic$(O): writepng.c writepng.h
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# maintenance ---------------------------------------------------------------
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
clean:
|
|
fukasawa |
e60969 |
$(RM) $(EXES)
|
|
fukasawa |
e60969 |
$(RM) $(ROBJSs) $(ROBJS2s) $(WOBJSs)
|
|
fukasawa |
e60969 |
$(RM) $(ROBJSd) $(ROBJS2d) $(WOBJSd)
|