Makefile.mingw32 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # Sample makefile for rpng-win / rpng2-win / wpng using mingw32-gcc and make.
  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. # make -f Makefile.mingw32
  14. #
  15. # This makefile assumes libpng and zlib have already been built or downloaded
  16. # and are in subdirectories at the same level as the current subdirectory
  17. # (as indicated by the PNGDIR and ZDIR macros below). It makes no assumptions
  18. # at all about the mingw32 installation tree (W32DIR). Edit as appropriate.
  19. #
  20. # Note that the names of the dynamic and static libpng and zlib libraries
  21. # used below may change in later releases of the libraries. This makefile
  22. # builds both statically and dynamically linked executables by default.
  23. # (You need only one set, but for testing it can be handy to have both.)
  24. # macros --------------------------------------------------------------------
  25. #PNGDIR = ../..# for libpng-x.y.z/contrib/gregbook builds
  26. PNGDIR = ../libpng-win32
  27. PNGINC = -I$(PNGDIR)
  28. PNGLIBd = $(PNGDIR)/libpng.dll.a # dynamically linked
  29. PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
  30. #ZDIR = ../../../zlib-win32# for libpng-x.y.z/contrib/gregbook builds
  31. ZDIR = ../zlib-win32
  32. ZINC = -I$(ZDIR)
  33. ZLIBd = $(ZDIR)/libzdll.a
  34. ZLIBs = $(ZDIR)/libz.a
  35. # change this to be the path where mingw32 installs its stuff:
  36. W32DIR =
  37. #W32DIR = /usr/local/cross-tools/i386-mingw32msvc
  38. W32INC = -I$(W32DIR)/include
  39. W32LIB = $(W32DIR)/lib/libuser32.a $(W32DIR)/lib/libgdi32.a
  40. CC = gcc
  41. #CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
  42. LD = $(CC)
  43. RM = rm -f
  44. CPPFLAGS = $(INCS)
  45. CFLAGS = -O -Wall $(MINGW_CCFLAGS)
  46. # [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
  47. # [-ansi, -pedantic and -W can also be used]
  48. LDFLAGS = $(MINGW_LDFLAGS)
  49. O = .o
  50. E = .exe
  51. INCS = $(PNGINC) $(ZINC) $(W32INC)
  52. RLIBSd = $(PNGLIBd) $(ZLIBd) $(W32LIB) -lm
  53. RLIBSs = $(PNGLIBs) $(ZLIBs) $(W32LIB) -lm
  54. WLIBSd = $(PNGLIBd) $(ZLIBd)
  55. WLIBSs = $(PNGLIBs) $(ZLIBs)
  56. RPNG = rpng-win
  57. RPNG2 = rpng2-win
  58. WPNG = wpng
  59. ROBJSd = $(RPNG)$(O) readpng.pic$(O)
  60. ROBJS2d = $(RPNG2)$(O) readpng2.pic$(O)
  61. WOBJSd = $(WPNG)$(O) writepng.pic$(O)
  62. RPNGs = $(RPNG)-static
  63. RPNG2s = $(RPNG2)-static
  64. WPNGs = $(WPNG)-static
  65. ROBJSs = $(RPNG)$(O) readpng$(O)
  66. ROBJS2s = $(RPNG2)$(O) readpng2$(O)
  67. WOBJSs = $(WPNG)$(O) writepng$(O)
  68. STATIC_EXES = $(RPNGs)$(E) $(RPNG2s)$(E) $(WPNGs)$(E)
  69. DYNAMIC_EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
  70. EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
  71. # implicit make rules -------------------------------------------------------
  72. .c$(O):
  73. $(CC) -c $(CPPFLAGS) $(CFLAGS) $<
  74. %.pic$(O): %.c
  75. $(CC) -c $(CPPFLAGS) $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
  76. # dependencies --------------------------------------------------------------
  77. all: $(EXES)
  78. $(RPNGs)$(E): $(ROBJSs)
  79. $(LD) $(LDFLAGS) -o $@ $(ROBJSs) $(RLIBSs)
  80. $(RPNG)$(E): $(ROBJSd)
  81. $(LD) $(LDFLAGS) -o $@ $(ROBJSd) $(RLIBSd)
  82. $(RPNG2s)$(E): $(ROBJS2s)
  83. $(LD) $(LDFLAGS) -o $@ $(ROBJS2s) $(RLIBSs)
  84. $(RPNG2)$(E): $(ROBJS2d)
  85. $(LD) $(LDFLAGS) -o $@ $(ROBJS2d) $(RLIBSd)
  86. $(WPNGs)$(E): $(WOBJSs)
  87. $(LD) $(LDFLAGS) -o $@ $(WOBJSs) $(WLIBSs)
  88. $(WPNG)$(E): $(WOBJSd)
  89. $(LD) $(LDFLAGS) -o $@ $(WOBJSd) $(WLIBSd)
  90. $(RPNG)$(O): $(RPNG).c readpng.h
  91. $(RPNG2)$(O): $(RPNG2).c readpng2.h
  92. $(WPNG)$(O): $(WPNG).c writepng.h
  93. readpng$(O) readpng.pic$(O): readpng.c readpng.h
  94. readpng2$(O) readpng2.pic$(O): readpng2.c readpng2.h
  95. writepng$(O) writepng.pic$(O): writepng.c writepng.h
  96. # maintenance ---------------------------------------------------------------
  97. clean:
  98. $(RM) $(EXES)
  99. $(RM) $(ROBJSs) $(ROBJS2s) $(WOBJSs)
  100. $(RM) $(ROBJSd) $(ROBJS2d) $(WOBJSd)