1 # Makefile for PngMinus (pnm2pngm) 2 # Linux / Unix 3 4 #CC=cc 5 CC=gcc 6 LD=$(CC) 7 8 # If awk fails try 9 # make AWK=nawk 10 11 # If cpp fails try 12 # make CPP=/lib/cpp 13 14 RM=rm -f 15 COPY=cp 16 17 CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP 18 CFLAGS=-O1 -Wall 19 20 C=.c 21 O=.o 22 L=.a 23 E= 24 25 # Where to find the source code: 26 PNGSRC =../../.. 27 ZLIBSRC=$(PNGSRC)/../zlib 28 PROGSRC=$(PNGSRC)/contrib/pngminus 29 30 # Zlib 31 ZSRCS = adler32$(C) compress$(C) crc32$(C) deflate$(C) \ 32 trees$(C) zutil$(C) 33 34 # Standard headers 35 #ZH = zlib.h crc32.h deflate.h trees.h zutil.h 36 ZH = zlib.h crc32.h deflate.h trees.h zutil.h 37 38 # Machine generated headers 39 ZCONF = zconf.h 40 41 # Headers callers use 42 ZINC = zlib.h $(ZCONF) 43 44 # Headers the Zlib source uses 45 ZHDRS = $(ZH) $(ZCONF) 46 47 # compress is not required; it is needed to link the zlib 48 # code because deflate defines an unused API function deflateBound 49 # which itself calls compressBound from compress. 50 ZOBJS = adler32$(O) compress$(O) crc32$(O) deflate$(O) \ 51 trees$(O) zutil$(O) 52 53 # libpng 54 PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \ 55 pngset$(C) pngtrans$(C) pngwio$(C) pngwrite$(C) \ 56 pngwtran$(C) pngwutil$(C) 57 58 # Standard headers 59 PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h 60 61 # Machine generated headers 62 PNGCONF=pnglibconf.h 63 64 # Headers callers use 65 PNGINC= png.h pngconf.h pngusr.h $(PNGCONF) 66 67 # Headers the PNG library uses 68 PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h 69 70 PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \ 71 pngset$(O) pngtrans$(O) pngwio$(O) pngwrite$(O) \ 72 pngwtran$(O) pngwutil$(O) 73 74 PROGSRCS= pnm2pngm$(C) 75 PROGHDRS= 76 PROGDOCS= 77 PROGOBJS= pnm2pngm$(O) 78 79 OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS) 80 81 # implicit make rules ------------------------------------------------------- 82 83 .c$(O): 84 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< 85 86 # dependencies 87 88 all: pnm2pngm$(E) 89 90 pnm2pngm$(E): $(OBJS) 91 $(LD) -o pnm2pngm$(E) $(OBJS) 92 93 # The DFA_XTRA setting turns all libpng options off then 94 # turns on those required for this minimal build. 95 # The CPP_FLAGS setting causes pngusr.h to be included in 96 # both the build of pnglibconf.h and, subsequently, when 97 # building libpng itself. 98 $(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\ 99 $(PNGSRC)/scripts/pnglibconf.dfa \ 100 $(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa 101 $(RM) pnglibconf.h pnglibconf.dfn 102 $(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\ 103 srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\ 104 DFA_XTRA="pngusr.dfa" $@ 105 106 clean: 107 $(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\ 108 srcdir=$(PNGSRC) clean 109 $(RM) pnm2pngm$(O) 110 $(RM) pnm2pngm$(E) 111 $(RM) $(OBJS) 112 113 # distclean also removes the copied source and headers 114 distclean: clean 115 $(RM) -r scripts # historical reasons 116 $(RM) $(PNGSRCS) $(PNGH) 117 $(RM) $(ZSRCS) $(ZH) $(ZCONF) 118 $(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS) 119 120 # Header file dependencies: 121 $(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC) 122 $(PNGOBJS): $(PNGHDRS) $(ZINC) 123 $(ZOBJS): $(ZHDRS) 124 125 # Gather the source code from the respective directories 126 $(PNGSRCS) $(PNGH): $(PNGSRC)/$@ 127 $(RM) $@ 128 $(COPY) $(PNGSRC)/$@ $@ 129 130 # No dependency on the ZLIBSRC target so that it only needs 131 # to be specified once. 132 $(ZSRCS) $(ZH): 133 $(RM) $@ 134 $(COPY) $(ZLIBSRC)/$@ $@ 135 136 # The unconfigured zconf.h varies in name according to the 137 # zlib release 138 $(ZCONF): 139 $(RM) $@ 140 @for f in zconf.h.in zconf.in.h zconf.h; do\ 141 test -r $(ZLIBSRC)/$$f &&\ 142 echo $(COPY) $(ZLIBSRC)/$$f $@ &&\ 143 $(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\ 144 done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1 145 146 pnm2pngm.c: $(PROGSRC)/pnm2png.c 147 $(RM) $@ 148 $(COPY) $(PROGSRC)/pnm2png.c $@ 149 150 # End of makefile for pnm2pngm 151