-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
72 lines (54 loc) · 1.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- Makefile -*- for libpng
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifndef V
QUIET_CC = @echo ' ' CC $@;
QUIET_AR = @echo ' ' AR $@;
QUIET_RANLIB = @echo ' ' RANLIB $@;
QUIET_INSTALL = @echo ' ' INSTALL $<;
export V
endif
endif
LIB = libpng.a
AR ?= ar
CC ?= gcc
RANLIB?= ranlib
RM ?= rm -f
prefix ?= /usr/local
libdir := $(prefix)/lib
includedir := $(prefix)/include
HEADERS = png.h pngconf.h pnglibconf.h
SOURCES = png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c
HEADERS_INST := $(patsubst %,$(includedir)/%,$(HEADERS))
OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
CFLAGS ?= -O2
CFLAGS += -DPNG_STATIC -I../zlib
.PHONY: install
all: $(LIB)
$(includedir)/%.h: %.h
-@if [ ! -d $(includedir) ]; then mkdir -p $(includedir); fi
$(QUIET_INSTALL)cp $< $@
@chmod 0644 $@
$(libdir)/%.a: %.a
-@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
$(QUIET_INSTALL)cp $< $@
@chmod 0644 $@
install: $(HEADERS_INST) $(libdir)/$(LIB)
clean:
$(RM) $(OBJECTS) $(LIB) .cflags
distclean: clean
$(LIB): $(OBJECTS)
@$(RM) $@
$(QUIET_AR)$(AR) rcu $@ $^
$(QUIET_RANLIB)$(RANLIB) $@
%.o: %.c .cflags
$(QUIET_CC)$(CC) $(CFLAGS) -o $@ -c $<
TRACK_CFLAGS = $(subst ','\'',$(CC) $(CFLAGS))
.cflags: .force-cflags
@FLAGS='$(TRACK_CFLAGS)'; \
if test x"$$FLAGS" != x"`cat .cflags 2>/dev/null`" ; then \
echo " * rebuilding libpng: new build flags or prefix"; \
echo "$$FLAGS" > .cflags; \
fi
.PHONY: .force-cflags