makefile.std 4.6 KB
Newer Older
G
Guy Schalnat 已提交
1
# makefile for libpng
2
# Copyright (C) 2002, 2006, 2014 Glenn Randers-Pehrson
G
Guy Schalnat 已提交
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
G
Guy Schalnat 已提交
8

9 10
# where make install puts libpng.a and png.h
prefix=/usr/local
11 12 13 14 15 16 17 18 19
INCPATH=$(prefix)/include
LIBPATH=$(prefix)/lib

# override DESTDIR= on the make install command line to easily support
# installing into a temporary location.  Example:
#
#    make install DESTDIR=/tmp/build/libpng
#
# If you're going to install into a temporary location
20
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
21 22
# you execute make install.
DESTDIR=
23

A
Andreas Dilger 已提交
24 25 26 27 28 29
# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib

30 31 32 33 34 35
CC = cc
AR_RC = ar rc
MKDIR_P = mkdir
LN_SF = ln -sf
RANLIB = ranlib
RM_F = rm -f
36 37 38 39
AWK = awk
SED = sed
CPP = $(CC) -E
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 44 45
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS = -O # -g
LDFLAGS = -L. -L$(ZLIBLIB) -lpng -lz -lm
46

A
Andreas Dilger 已提交
47
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
G
Guy Schalnat 已提交
48 49
	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
	pngwtran.o pngmem.o pngerror.o pngpread.o
G
Guy Schalnat 已提交
50

51 52 53
.c.o:
	$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<

G
Guy Schalnat 已提交
54 55
all: libpng.a pngtest

56
# The standard pnglibconf.h exists as scripts/pnglibconf.h.prebuilt,
57 58
# copy this if the following doesn't work.
pnglibconf.h: pnglibconf.dfn
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
	$(RM_F) $@ pnglibconf.c pnglibconf.out pnglibconf.tmp
	$(ECHO) '#include "pnglibconf.dfn"' >pnglibconf.c
	$(ECHO) "If '$(CC) -E' crashes try /lib/cpp (e.g. CPP='/lib/cpp')" >&2
	$(CPP) $(DFNFLAGS) pnglibconf.c >pnglibconf.out
	$(AWK) -f "scripts/dfn.awk" out="pnglibconf.tmp" pnglibconf.out 1>&2
	mv pnglibconf.tmp $@

pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
	$(RM_F) $@ pnglibconf.pre pnglibconf.tmp
	$(ECHO) "Calling $(AWK) from scripts/pnglibconf.mak" >&2
	$(ECHO) "If 'awk' crashes try a better awk (e.g. AWK='nawk')" >&2
	$(AWK) -f scripts/options.awk out="pnglibconf.pre"\
	    version=search pngconf.h scripts/pnglibconf.dfa\
	    pngusr.dfa $(DFA_XTRA) 1>&2
	$(AWK) -f scripts/options.awk out="pnglibconf.tmp" pnglibconf.pre 1>&2
	mv pnglibconf.tmp $@
75

G
Guy Schalnat 已提交
76
libpng.a: $(OBJS)
77
	$(AR_RC) $@  $(OBJS)
G
Guy Schalnat 已提交
78 79 80
	$(RANLIB) $@

pngtest: pngtest.o libpng.a
81
	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
G
Guy Schalnat 已提交
82 83 84

test: pngtest
	./pngtest
G
Guy Schalnat 已提交
85

86
install: libpng.a pnglibconf.h
87 88 89 90 91
	-@$(MKDIR_P) $(DESTDIR)$(INCPATH)
	-@$(MKDIR_P) $(DESTDIR)$(INCPATH)/libpng
	-@$(MKDIR_P) $(DESTDIR)$(LIBPATH)
	-@$(RM_F) $(DESTDIR)$(INCPATH)/png.h
	-@$(RM_F) $(DESTDIR)$(INCPATH)/pngconf.h
92
	-@$(RM_F) $(DESTDIR)$(INCPATH)/pnglibconf.h
93 94
	cp png.h $(DESTDIR)$(INCPATH)/libpng
	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
95
	cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng
96 97
	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
98
	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h
99 100 101
	(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
	cp libpng.a $(DESTDIR)$(LIBPATH)
	chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
G
Guy Schalnat 已提交
102 103

clean:
104
	$(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.*
G
Guy Schalnat 已提交
105

106 107 108 109
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
writelock:
	chmod a-w *.[ch35] $(DOCS) scripts/*

G
Guy Schalnat 已提交
110 111
# DO NOT DELETE THIS LINE -- make depend depends on it.

112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
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