pngconfig.mak 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # This is an OpenWatcom make file which builds pnglibconf.h - the libpng
  2. # configuration header. You can ignore this file if you don't need to
  3. # configure libpng; a default configuration will be built.
  4. #
  5. # For more information build libpng.wpj under the IDE and then read the
  6. # generated files:
  7. #
  8. # config.inf: Basic configuration information for a standard build.
  9. # pngconfig.dfa: Advanced configuration for non-standard libpng builds.
  10. #
  11. DELETE=rm -f
  12. ECHO=echo
  13. COPY=copy
  14. #
  15. # If your configuration needs to test compiler flags when building
  16. # pnglibconf.h you may need to override the following on the wmake command
  17. # line:
  18. CFLAGS=
  19. CC=wcl386
  20. CPP=$(CC) -pw0
  21. #
  22. # Read awk from the environment if set, else it can be set on the command
  23. # line (the default approach is to set the %awk% environment variable in the
  24. # IDE libpng.wpj 'before' rule - this setting is local.)
  25. !ifdef %awk
  26. AWK=$(%awk)
  27. !endif
  28. #
  29. # pnglibconf.h must exist in the source directory, this is the final rule
  30. # which copies the local built version (and this is the default target for
  31. # this makefile.)
  32. ..\..\pnglibconf.h: pnglibconf.h
  33. $(COPY) pnglibconf.h $@
  34. !ifdef AWK
  35. # CPPFLAGS should contain the options to control the result,
  36. # but DEFS and CFLAGS are also supported here, override
  37. # as appropriate
  38. DFNFLAGS = $(DEFS) $(CPPFLAGS) $(CFLAGS)
  39. pnglibconf.h: pnglibconf.dfn
  40. $(DELETE) $@ dfn.c dfn1.out dfn2.out
  41. $(ECHO) $#include "pnglibconf.dfn" >dfn.c
  42. $(CPP) $(DFNFLAGS) dfn.c >dfn1.out
  43. $(AWK) -f << dfn1.out >dfn2.out
  44. /^.*PNG_DEFN_MAGIC-.*-PNG_DEFN_END.*$$/{
  45. sub(/^.*PNG_DEFN_MAGIC-/, "")
  46. sub(/ *-PNG_DEFN_END.*$$/, "")
  47. gsub(/ *@@@ */, "")
  48. print
  49. }
  50. <<
  51. $(COPY) dfn2.out $@
  52. @type << >pngconfig.inf
  53. This is a locally configurable build of libpng.lib; for configuration
  54. instructions consult and edit projects/openwatcom/pngconfig.dfa
  55. <<
  56. $(DELETE) dfn.c dfn1.out dfn2.out
  57. pnglibconf.dfn: ..\..\scripts\pnglibconf.dfa ..\..\scripts\options.awk pngconfig.dfa ..\..\pngconf.h
  58. $(DELETE) $@ dfn1.out dfn2.out
  59. $(AWK) -f ..\..\scripts\options.awk out=dfn1.out version=search ..\..\pngconf.h ..\..\scripts\pnglibconf.dfa pngconfig.dfa $(DFA_XTRA) 1>&2
  60. $(AWK) -f ..\..\scripts\options.awk out=dfn2.out dfn1.out 1>&2
  61. $(COPY) dfn2.out $@
  62. $(DELETE) dfn1.out dfn2.out
  63. !else
  64. # The following lines are used to copy scripts\pnglibconf.h.prebuilt and make
  65. # the required change to the calling convention.
  66. #
  67. # By default libpng is built to use the __cdecl calling convention on
  68. # Windows. This gives compatibility with MSVC and GCC. Unfortunately it
  69. # does not work with OpenWatcom because OpenWatcom implements longjmp using
  70. # the __watcall convention (compared with both MSVC and GCC which use __cdecl
  71. # for library functions.)
  72. #
  73. # Thus the default must be changed to build on OpenWatcom and, once changed,
  74. # the result will not be compatible with applications built using other
  75. # compilers (in fact attempts to build will fail at compile time.)
  76. #
  77. pnglibconf.h: ..\..\scripts\pnglibconf.h.prebuilt .existsonly
  78. @$(ECHO) .
  79. @$(ECHO) .
  80. @$(ECHO) $$(AWK) NOT AVAILABLE: COPYING scripts\pnglibconf.h.prebuilt
  81. @$(ECHO) .
  82. @$(ECHO) .
  83. vi -q -k ":1,$$s/PNG_API_RULE 0$$/PNG_API_RULE 2/\n:w! $@\n:q!\n" ..\..\scripts\pnglibconf.h.prebuilt
  84. @$(ECHO) .
  85. @$(ECHO) .
  86. @$(ECHO) YOU HAVE A DEFAULT CONFIGURATION BECAUSE YOU DO NOT HAVE AWK!
  87. @$(ECHO) .
  88. @$(ECHO) .
  89. @type << >pngconfig.inf
  90. This is the default configuration of libpng.lib, if you wish to
  91. change the configuration please consult the instructions in
  92. projects/owatcom/pngconfig.dfa.
  93. <<
  94. !endif
  95. # Make the default files
  96. defaults: .symbolic
  97. @$(COPY) << config.inf
  98. $# The libpng project is incompletely configured. To complete configuration
  99. $# please complete the following steps:
  100. $#
  101. $# 1) Edit the 'before' rule of libpng.wpj (from the IDE) to define the
  102. $# locations of the zlib include file zlib.h and the built zlib library,
  103. $# zlib.lib.
  104. $#
  105. $# 2) If you want to change libpng to a non-standard configuration also
  106. $# change the definition of 'awk' in the before rule to the name of your
  107. $# awk command. For more instructions on configuration read
  108. $# pngconfig.dfa.
  109. $#
  110. $# 3) Delete this file (config.inf).
  111. <<
  112. @$(COPY) << pngconfig.dfa
  113. $# pngconfig.dfa: this file contains configuration options for libpng.
  114. $# If emtpy the standard configuration will be built. For this file to be
  115. $# used a working version of the program 'awk' is required and the program
  116. $# must be identified in the 'before' rule of the project.
  117. $#
  118. $# If you don't already have 'awk', or the version of awk you have seems not
  119. $# to work, download Brian Kernighan's awk (Brian Kernighan is the author of
  120. $# awk.) You can find source code and a built executable (called awk95.exe)
  121. $# here:
  122. $#
  123. $# http://www.cs.princeton.edu/~bwk/btl.mirror/
  124. $#
  125. $# The executable works just fine.
  126. $#
  127. $# If build issues errors after a change to pngconfig.dfa you have entered
  128. $# inconsistent feature requests, or even malformed requests, in
  129. $# pngconfig.dfa. The error messages from awk should be comprehensible, but
  130. $# if not simply go back to the start (nothing but comments in this file) and
  131. $# enter configuration lines one by one until one produces an error. (Or, of
  132. $# course, do the standard binary chop.)
  133. $#
  134. $# You need to rebuild everything after a change to pnglibconf.dfa - i.e. you
  135. $# must do Actions/Mark All Targets for Remake. This is because the compiler
  136. $# generated dependency information (as of OpenWatcom 1.9) does not record the
  137. $# dependency on pnglibconf.h correctly.
  138. $#
  139. $# If awk isn't set then this file is bypassed. If you just want the standard
  140. $# configuration it is automatically produced from the distributed version
  141. $# (scripts\pnglibconf.h.prebuilt) by editting PNG_API_RULE to 2 (to force use
  142. $# of the OpenWatcom library calling convention.)
  143. $#
  144. <<
  145. clean:: .symbolic
  146. $(DELETE) ..\..\pnglibconf.h pnglibconf.* dfn.c *.out pngconfig.inf
  147. $(DELETE) *.obj *.mbr *.sym *.err *.pch libpng.mk
  148. $(DELETE) libpng.lib libpng.lbr libpng.lb1 libpng.cbr libpng.mk1
  149. $(DELETE) pngtest.exe pngtest.map pngtest.lk1 pngtest.mk1
  150. $(DELETE) pngvalid.exe pngvalid.map pngvalid.lk1 pngvalid.mk1
  151. distclean:: clean .symbolic
  152. $(DELETE) zlib.inf awk.inf config.inf pngconfig.dfa