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