1LOCAL_PATH:= $(call my-dir)
2
3# We need to build this for both the device (as a shared library)
4# and the host (as a static library for tools to use).
5
6common_SRC_FILES := \
7	png.c \
8	pngerror.c \
9	pngget.c \
10	pngmem.c \
11	pngpread.c \
12	pngread.c \
13	pngrio.c \
14	pngrtran.c \
15	pngrutil.c \
16	pngset.c \
17	pngtrans.c \
18	pngwio.c \
19	pngwrite.c \
20	pngwtran.c \
21	pngwutil.c \
22
23ifeq ($(ARCH_ARM_HAVE_NEON),true)
24my_cflags_arm := -DPNG_ARM_NEON_OPT=2
25endif
26
27my_cflags_arm64 := -DPNG_ARM_NEON_OPT=2
28
29# BUG: http://llvm.org/PR19472 - SLP vectorization (on ARM at least) crashes
30# when we can't lower a vectorized bswap.
31my_cflags_arm += -fno-slp-vectorize
32
33my_src_files_arm := \
34			arm/arm_init.c \
35			arm/filter_neon.S \
36			arm/filter_neon_intrinsics.c
37
38
39common_CFLAGS := -std=gnu89 #-fvisibility=hidden ## -fomit-frame-pointer
40
41ifeq ($(HOST_OS),windows)
42	ifeq ($(USE_MINGW),)
43#		Case where we're building windows but not under linux (so it must be cygwin)
44#		In this case, gcc cygwin doesn't recognize -fvisibility=hidden
45		$(info libpng: Ignoring gcc flag $(common_CFLAGS) on Cygwin)
46	common_CFLAGS :=
47	endif
48endif
49
50ifeq ($(HOST_OS),darwin)
51common_CFLAGS += -no-integrated-as
52common_ASFLAGS += -no-integrated-as
53endif
54
55common_C_INCLUDES +=
56
57common_COPY_HEADERS_TO := libpng
58common_COPY_HEADERS := png.h pngconf.h pngusr.h
59
60# For the host
61# =====================================================
62
63include $(CLEAR_VARS)
64
65LOCAL_SRC_FILES := $(common_SRC_FILES)
66LOCAL_CFLAGS += $(common_CFLAGS)
67LOCAL_ASFLAGS += $(common_ASFLAGS)
68LOCAL_C_INCLUDES += $(common_C_INCLUDES) external/zlib
69
70LOCAL_MODULE:= libpng
71
72LOCAL_COPY_HEADERS_TO := $(common_COPY_HEADERS_TO)
73LOCAL_COPY_HEADERS := $(common_COPY_HEADERS)
74
75include $(BUILD_HOST_STATIC_LIBRARY)
76
77
78# For the device (static)
79# =====================================================
80
81include $(CLEAR_VARS)
82LOCAL_CLANG := true
83LOCAL_SRC_FILES := $(common_SRC_FILES)
84LOCAL_CFLAGS += $(common_CFLAGS) -ftrapv
85LOCAL_CFLAGS_arm := $(my_cflags_arm)
86LOCAL_ASFLAGS += $(common_ASFLAGS)
87LOCAL_SRC_FILES_arm := $(my_src_files_arm)
88LOCAL_CFLAGS_arm64 := $(my_cflags_arm64)
89LOCAL_SRC_FILES_arm64 := $(my_src_files_arm)
90
91LOCAL_C_INCLUDES += $(common_C_INCLUDES) \
92	external/zlib
93LOCAL_SHARED_LIBRARIES := \
94	libz
95
96LOCAL_MODULE:= libpng
97
98include $(BUILD_STATIC_LIBRARY)
99
100# For the device (shared)
101# =====================================================
102
103include $(CLEAR_VARS)
104LOCAL_CLANG := true
105LOCAL_SRC_FILES := $(common_SRC_FILES)
106LOCAL_CFLAGS += $(common_CFLAGS) -ftrapv
107LOCAL_CFLAGS_arm := $(my_cflags_arm)
108LOCAL_ASFLAGS += $(common_ASFLAGS)
109LOCAL_SRC_FILES_arm := $(my_src_files_arm)
110LOCAL_CFLAGS_arm64 := $(my_cflags_arm64)
111LOCAL_SRC_FILES_arm64 := $(my_src_files_arm)
112
113LOCAL_C_INCLUDES += $(common_C_INCLUDES) \
114	external/zlib
115LOCAL_SHARED_LIBRARIES := \
116	libz
117
118LOCAL_MODULE:= libpng
119
120LOCAL_COPY_HEADERS_TO := $(common_COPY_HEADERS_TO)
121LOCAL_COPY_HEADERS := $(common_COPY_HEADERS)
122
123include $(BUILD_SHARED_LIBRARY)
124
125# For testing
126# =====================================================
127
128include $(CLEAR_VARS)
129LOCAL_CLANG := true
130LOCAL_C_INCLUDES:= $(common_C_INCLUDES) external/zlib
131LOCAL_SRC_FILES:= pngtest.c
132LOCAL_MODULE := pngtest
133LOCAL_SHARED_LIBRARIES:= libpng libz
134LOCAL_MODULE_TAGS := debug
135include $(BUILD_EXECUTABLE)
136