fukasawa e60969
# This is an OpenWatcom make file which builds pnglibconf.h - the libpng
fukasawa e60969
# configuration header.  You can ignore this file if you don't need to
fukasawa e60969
# configure libpng; a default configuration will be built.
fukasawa e60969
#
fukasawa e60969
# For more information build libpng.wpj under the IDE and then read the
fukasawa e60969
# generated files:
fukasawa e60969
#
fukasawa e60969
#    config.inf: Basic configuration information for a standard build.
fukasawa e60969
#    pngconfig.dfa: Advanced configuration for non-standard libpng builds.
fukasawa e60969
#
fukasawa e60969
DELETE=rm -f
fukasawa e60969
ECHO=echo
fukasawa e60969
COPY=copy
fukasawa e60969
#
fukasawa e60969
# If your configuration needs to test compiler flags when building
fukasawa e60969
# pnglibconf.h you may need to override the following on the wmake command
fukasawa e60969
# line:
fukasawa e60969
CFLAGS=
fukasawa e60969
CC=wcl386
fukasawa e60969
CPP=$(CC) -pw0
fukasawa e60969
#
fukasawa e60969
# Read awk from the environment if set, else it can be set on the command
fukasawa e60969
# line (the default approach is to set the %awk% environment variable in the
fukasawa e60969
# IDE libpng.wpj 'before' rule - this setting is local.)
fukasawa e60969
!ifdef %awk
fukasawa e60969
AWK=$(%awk)
fukasawa e60969
!endif
fukasawa e60969
#
fukasawa e60969
# pnglibconf.h must exist in the source directory, this is the final rule
fukasawa e60969
# which copies the local built version (and this is the default target for
fukasawa e60969
# this makefile.)
fukasawa e60969
..\..\pnglibconf.h: pnglibconf.h
fukasawa e60969
 $(COPY) pnglibconf.h $@
fukasawa e60969

fukasawa e60969
!ifdef AWK
fukasawa e60969
# CPPFLAGS should contain the options to control the result,
fukasawa e60969
# but DEFS and CFLAGS are also supported here, override
fukasawa e60969
# as appropriate
fukasawa e60969
DFNFLAGS = $(DEFS) $(CPPFLAGS) $(CFLAGS)
fukasawa e60969

fukasawa e60969
pnglibconf.h: pnglibconf.dfn
fukasawa e60969
 $(DELETE) $@ dfn.c dfn1.out dfn2.out
fukasawa e60969
 $(ECHO) $#include "pnglibconf.dfn" >dfn.c
fukasawa e60969
 $(CPP) $(DFNFLAGS) dfn.c >dfn1.out
fukasawa e60969
 $(AWK) -f << dfn1.out >dfn2.out
fukasawa e60969
/^.*PNG_DEFN_MAGIC-.*-PNG_DEFN_END.*$$/{
fukasawa e60969
 sub(/^.*PNG_DEFN_MAGIC-/, "")
fukasawa e60969
 sub(/ *-PNG_DEFN_END.*$$/, "")
fukasawa e60969
 gsub(/ *@@@ */, "")
fukasawa e60969
 print
fukasawa e60969
}
fukasawa e60969
<<
fukasawa e60969
 $(COPY) dfn2.out $@
fukasawa e60969
 @type << >pngconfig.inf
fukasawa e60969
This is a locally configurable build of libpng.lib; for configuration
fukasawa e60969
instructions consult and edit projects/openwatcom/pngconfig.dfa
fukasawa e60969
<<
fukasawa e60969
 $(DELETE) dfn.c dfn1.out dfn2.out
fukasawa e60969

fukasawa e60969
pnglibconf.dfn: ..\..\scripts\pnglibconf.dfa ..\..\scripts\options.awk pngconfig.dfa ..\..\pngconf.h
fukasawa e60969
 $(DELETE) $@ dfn1.out dfn2.out
fukasawa e60969
 $(AWK) -f ..\..\scripts\options.awk out=dfn1.out version=search ..\..\pngconf.h ..\..\scripts\pnglibconf.dfa pngconfig.dfa $(DFA_XTRA) 1>&2
fukasawa e60969
 $(AWK) -f ..\..\scripts\options.awk out=dfn2.out dfn1.out 1>&2
fukasawa e60969
 $(COPY) dfn2.out $@
fukasawa e60969
 $(DELETE) dfn1.out dfn2.out
fukasawa e60969

fukasawa e60969
!else
fukasawa e60969
# The following lines are used to copy scripts\pnglibconf.h.prebuilt and make
fukasawa e60969
# the required change to the calling convention.
fukasawa e60969
#
fukasawa e60969
# By default libpng is built to use the __cdecl calling convention on
fukasawa e60969
# Windows.  This gives compatibility with MSVC and GCC.  Unfortunately it
fukasawa e60969
# does not work with OpenWatcom because OpenWatcom implements longjmp using
fukasawa e60969
# the __watcall convention (compared with both MSVC and GCC which use __cdecl
fukasawa e60969
# for library functions.)
fukasawa e60969
#
fukasawa e60969
# Thus the default must be changed to build on OpenWatcom and, once changed,
fukasawa e60969
# the result will not be compatible with applications built using other
fukasawa e60969
# compilers (in fact attempts to build will fail at compile time.)
fukasawa e60969
#
fukasawa e60969
pnglibconf.h: ..\..\scripts\pnglibconf.h.prebuilt .existsonly
fukasawa e60969
 @$(ECHO) .
fukasawa e60969
 @$(ECHO) .
fukasawa e60969
 @$(ECHO) $$(AWK) NOT AVAILABLE: COPYING scripts\pnglibconf.h.prebuilt
fukasawa e60969
 @$(ECHO) .
fukasawa e60969
 @$(ECHO) .
fukasawa e60969
 vi -q -k ":1,$$s/PNG_API_RULE 0$$/PNG_API_RULE 2/\n:w! $@\n:q!\n" ..\..\scripts\pnglibconf.h.prebuilt
fukasawa e60969
 @$(ECHO) .
fukasawa e60969
 @$(ECHO) .
fukasawa e60969
 @$(ECHO) YOU HAVE A DEFAULT CONFIGURATION BECAUSE YOU DO NOT HAVE AWK!
fukasawa e60969
 @$(ECHO) .
fukasawa e60969
 @$(ECHO) .
fukasawa e60969
 @type << >pngconfig.inf
fukasawa e60969
This is the default configuration of libpng.lib, if you wish to
fukasawa e60969
change the configuration please consult the instructions in
fukasawa e60969
projects/owatcom/pngconfig.dfa.
fukasawa e60969
<<
fukasawa e60969

fukasawa e60969
!endif
fukasawa e60969

fukasawa e60969
# Make the default files
fukasawa e60969
defaults: .symbolic
fukasawa e60969
 @$(COPY) << config.inf
fukasawa e60969
$# The libpng project is incompletely configured.  To complete configuration
fukasawa e60969
$# please complete the following steps:
fukasawa e60969
$#
fukasawa e60969
$#   1) Edit the 'before' rule of libpng.wpj (from the IDE) to define the
fukasawa e60969
$#      locations of the zlib include file zlib.h and the built zlib library,
fukasawa e60969
$#      zlib.lib.
fukasawa e60969
$#
fukasawa e60969
$#   2) If you want to change libpng to a non-standard configuration also
fukasawa e60969
$#      change the definition of 'awk' in the before rule to the name of your
fukasawa e60969
$#      awk command.  For more instructions on configuration read
fukasawa e60969
$#      pngconfig.dfa.
fukasawa e60969
$#
fukasawa e60969
$#   3) Delete this file (config.inf).
fukasawa e60969
<<
fukasawa e60969
 @$(COPY) << pngconfig.dfa
fukasawa e60969
$# pngconfig.dfa: this file contains configuration options for libpng.
fukasawa e60969
$# If emtpy the standard configuration will be built.  For this file to be
fukasawa e60969
$# used a working version of the program 'awk' is required and the program
fukasawa e60969
$# must be identified in the 'before' rule of the project.
fukasawa e60969
$#
fukasawa e60969
$# If you don't already have 'awk', or the version of awk you have seems not
fukasawa e60969
$# to work, download Brian Kernighan's awk (Brian Kernighan is the author of
fukasawa e60969
$# awk.)  You can find source code and a built executable (called awk95.exe)
fukasawa e60969
$# here:
fukasawa e60969
$#
fukasawa e60969
$#     http://www.cs.princeton.edu/~bwk/btl.mirror/
fukasawa e60969
$#
fukasawa e60969
$# The executable works just fine.
fukasawa e60969
$#
fukasawa e60969
$# If build issues errors after a change to pngconfig.dfa you have entered
fukasawa e60969
$# inconsistent feature requests, or even malformed requests, in
fukasawa e60969
$# pngconfig.dfa.  The error messages from awk should be comprehensible, but
fukasawa e60969
$# if not simply go back to the start (nothing but comments in this file) and
fukasawa e60969
$# enter configuration lines one by one until one produces an error.  (Or, of
fukasawa e60969
$# course, do the standard binary chop.)
fukasawa e60969
$#
fukasawa e60969
$# You need to rebuild everything after a change to pnglibconf.dfa - i.e. you
fukasawa e60969
$# must do Actions/Mark All Targets for Remake.  This is because the compiler
fukasawa e60969
$# generated dependency information (as of OpenWatcom 1.9) does not record the
fukasawa e60969
$# dependency on pnglibconf.h correctly.
fukasawa e60969
$#
fukasawa e60969
$# If awk isn't set then this file is bypassed.  If you just want the standard
fukasawa e60969
$# configuration it is automatically produced from the distributed version
fukasawa e60969
$# (scripts\pnglibconf.h.prebuilt) by editting PNG_API_RULE to 2 (to force use
fukasawa e60969
$# of the OpenWatcom library calling convention.)
fukasawa e60969
$#
fukasawa e60969
<<
fukasawa e60969

fukasawa e60969
clean:: .symbolic
fukasawa e60969
 $(DELETE) ..\..\pnglibconf.h pnglibconf.* dfn.c *.out pngconfig.inf
fukasawa e60969
 $(DELETE) *.obj *.mbr *.sym *.err *.pch libpng.mk
fukasawa e60969
 $(DELETE) libpng.lib libpng.lbr libpng.lb1 libpng.cbr libpng.mk1
fukasawa e60969
 $(DELETE) pngtest.exe pngtest.map pngtest.lk1 pngtest.mk1
fukasawa e60969
 $(DELETE) pngvalid.exe pngvalid.map pngvalid.lk1 pngvalid.mk1
fukasawa e60969

fukasawa e60969
distclean:: clean .symbolic
fukasawa e60969
 $(DELETE) zlib.inf awk.inf config.inf pngconfig.dfa