Home | History | Annotate | Download | only in scripts
      1 # makefile for libpng
      2 # Copyright (C) 2002, 2006, 2014 Glenn Randers-Pehrson
      3 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
      4 #
      5 # This code is released under the libpng license.
      6 # For conditions of distribution and use, see the disclaimer
      7 # and license in png.h
      8 
      9 # where make install puts libpng.a and png.h
     10 prefix=/usr/local
     11 INCPATH=$(prefix)/include
     12 LIBPATH=$(prefix)/lib
     13 
     14 # override DESTDIR= on the make install command line to easily support
     15 # installing into a temporary location.  Example:
     16 #
     17 #    make install DESTDIR=/tmp/build/libpng
     18 #
     19 # If you're going to install into a temporary location
     20 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
     21 # you execute make install.
     22 DESTDIR=
     23 
     24 # Where the zlib library and include files are located
     25 #ZLIBLIB=/usr/local/lib
     26 #ZLIBINC=/usr/local/include
     27 ZLIBLIB=../zlib
     28 ZLIBINC=../zlib
     29 
     30 CC = cc
     31 AR_RC = ar rc
     32 MKDIR_P = mkdir
     33 LN_SF = ln -sf
     34 RANLIB = ranlib
     35 RM_F = rm -f
     36 AWK = awk
     37 SED = sed
     38 CPP = $(CC) -E
     39 ECHO = echo
     40 
     41 DFNFLAGS = # DFNFLAGS contains -D options to use in the libpng build
     42 DFA_EXTRA = # extra files that can be used to control configuration
     43 CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
     44 CFLAGS = -O # -g
     45 LDFLAGS = -L. -L$(ZLIBLIB) -lpng -lz -lm
     46 
     47 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
     48 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
     49 	pngwtran.o pngmem.o pngerror.o pngpread.o
     50 
     51 .c.o:
     52 	$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
     53 
     54 all: libpng.a pngtest
     55 
     56 # The standard pnglibconf.h exists as scripts/pnglibconf.h.prebuilt,
     57 # copy this if the following doesn't work.
     58 pnglibconf.h: pnglibconf.dfn
     59 	$(RM_F) $@ pnglibconf.c pnglibconf.out pnglibconf.tmp
     60 	$(ECHO) '#include "pnglibconf.dfn"' >pnglibconf.c
     61 	$(ECHO) "If '$(CC) -E' crashes try /lib/cpp (e.g. CPP='/lib/cpp')" >&2
     62 	$(CPP) $(DFNFLAGS) pnglibconf.c >pnglibconf.out
     63 	$(AWK) -f "scripts/dfn.awk" out="pnglibconf.tmp" pnglibconf.out 1>&2
     64 	mv pnglibconf.tmp $@
     65 
     66 pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
     67 	$(RM_F) $@ pnglibconf.pre pnglibconf.tmp
     68 	$(ECHO) "Calling $(AWK) from scripts/pnglibconf.mak" >&2
     69 	$(ECHO) "If 'awk' crashes try a better awk (e.g. AWK='nawk')" >&2
     70 	$(AWK) -f scripts/options.awk out="pnglibconf.pre"\
     71 	    version=search pngconf.h scripts/pnglibconf.dfa\
     72 	    pngusr.dfa $(DFA_XTRA) 1>&2
     73 	$(AWK) -f scripts/options.awk out="pnglibconf.tmp" pnglibconf.pre 1>&2
     74 	mv pnglibconf.tmp $@
     75 
     76 libpng.a: $(OBJS)
     77 	$(AR_RC) $@  $(OBJS)
     78 	$(RANLIB) $@
     79 
     80 pngtest: pngtest.o libpng.a
     81 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
     82 
     83 test: pngtest
     84 	./pngtest
     85 
     86 install: libpng.a pnglibconf.h
     87 	-@$(MKDIR_P) $(DESTDIR)$(INCPATH)
     88 	-@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng
     89 	-@$(MKDIR_P) $(DESTDIR)$(LIBPATH)
     90 	-@$(RM_F) $(DESTDIR)$(INCPATH)/png.h
     91 	-@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h
     92 	-@$(RM_F) $(DESTDIR)$(INCPATH)/pnglibconf.h
     93 	cp png.h $(DESTDIR)$(INCPATH)/libpng
     94 	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
     95 	cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng
     96 	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
     97 	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
     98 	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h
     99 	(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
    100 	cp libpng.a $(DESTDIR)$(LIBPATH)
    101 	chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
    102 
    103 clean:
    104 	$(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.*
    105 
    106 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
    107 writelock:
    108 	chmod a-w *.[ch35] $(DOCS) scripts/*
    109 
    110 # DO NOT DELETE THIS LINE -- make depend depends on it.
    111 
    112 png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    113 pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    114 pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    115 pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    116 pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    117 pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    118 pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    119 pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    120 pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    121 pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    122 pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    123 pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    124 pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    125 pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    126 pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
    127 
    128 pngtest.o: png.h pngconf.h pnglibconf.h
    129