makefile.std 4.8 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
CC = cc
AR_RC = ar rc
MKDIR_P = mkdir
LN_SF = ln -sf
RANLIB = ranlib
35
CP = cp
36
RM_F = rm -f
37 38 39 40
AWK = awk
SED = sed
CPP = $(CC) -E
ECHO = echo
41

42
DFNFLAGS = # DFNFLAGS contains -D options to use in the libpng build
43
DFA_EXTRA = # extra files that can be used to control configuration
44 45 46
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS = -O # -g
LDFLAGS = -L. -L$(ZLIBLIB) -lpng -lz -lm
47

48 49 50 51
# Pre-built configuration
# See scripts/pnglibconf.mak for more options
PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt

A
Andreas Dilger 已提交
52
OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
G
Guy Schalnat 已提交
53 54
	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
	pngwtran.o pngmem.o pngerror.o pngpread.o
G
Guy Schalnat 已提交
55

56 57 58
.c.o:
	$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<

G
Guy Schalnat 已提交
59 60
all: libpng.a pngtest

61
# The standard pnglibconf.h exists as scripts/pnglibconf.h.prebuilt,
62 63
# copy this if the following doesn't work.
pnglibconf.h: pnglibconf.dfn
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
	$(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 $@
80

G
Guy Schalnat 已提交
81
libpng.a: $(OBJS)
82
	$(AR_RC) $@  $(OBJS)
G
Guy Schalnat 已提交
83 84 85
	$(RANLIB) $@

pngtest: pngtest.o libpng.a
86
	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
G
Guy Schalnat 已提交
87 88 89

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

91
install: libpng.a pnglibconf.h
92 93 94 95 96
	-@$(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
97
	-@$(RM_F) $(DESTDIR)$(INCPATH)/pnglibconf.h
98 99
	cp png.h $(DESTDIR)$(INCPATH)/libpng
	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
100
	cp pnglibconf.h $(DESTDIR)$(INCPATH)/libpng
101 102
	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
103
	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pnglibconf.h
104 105 106
	(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
	cp libpng.a $(DESTDIR)$(LIBPATH)
	chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
G
Guy Schalnat 已提交
107 108

clean:
109 110
	$(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.h pnglibconf.c \
	pnglibconf.out
G
Guy Schalnat 已提交
111

112
DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO
113 114 115
writelock:
	chmod a-w *.[ch35] $(DOCS) scripts/*

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

118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
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
133

134
pngtest.o: png.h pngconf.h pnglibconf.h