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