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
29my_src_files_arm := \
30    arm/arm_init.c \
31    arm/filter_neon.S \
32    arm/filter_neon_intrinsics.c
33
34my_cflags_intel := -DPNG_INTEL_SSE_OPT=1
35
36my_src_files_intel := \
37    contrib/intel/intel_init.c \
38    contrib/intel/filter_sse2_intrinsics.c
39
40common_CFLAGS := -std=gnu89 -Wno-unused-parameter #-fvisibility=hidden ## -fomit-frame-pointer
41
42# For the host
43# =====================================================
44
45include $(CLEAR_VARS)
46LOCAL_SRC_FILES := $(common_SRC_FILES)
47LOCAL_SRC_FILES_x86 += $(my_src_files_intel)
48LOCAL_SRC_FILES_x86_64 += $(my_src_files_intel)
49LOCAL_CFLAGS += $(common_CFLAGS)
50
51# Disable optimizations because they crash on windows
52# LOCAL_CFLAGS_x86 += $(my_cflags_intel)
53# LOCAL_CFLAGS_x86_64 += $(my_cflags_intel)
54
55LOCAL_ASFLAGS += $(common_ASFLAGS)
56LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
57LOCAL_STATIC_LIBRARIES := libz
58LOCAL_MODULE:= libpng
59LOCAL_MODULE_HOST_OS := darwin linux windows
60include $(BUILD_HOST_STATIC_LIBRARY)
61
62
63# For the device (static) for NDK
64# =====================================================
65
66include $(CLEAR_VARS)
67LOCAL_CLANG := true
68LOCAL_SRC_FILES := $(common_SRC_FILES)
69LOCAL_SRC_FILES_arm := $(my_src_files_arm)
70LOCAL_SRC_FILES_arm64 := $(my_src_files_arm)
71LOCAL_SRC_FILES_x86 += $(my_src_files_intel)
72LOCAL_SRC_FILES_x86_64 += $(my_src_files_intel)
73LOCAL_CFLAGS += $(common_CFLAGS) -ftrapv
74LOCAL_CFLAGS_arm := $(my_cflags_arm)
75LOCAL_CFLAGS_arm64 := $(my_cflags_arm64)
76LOCAL_CFLAGS_x86 += $(my_cflags_intel)
77LOCAL_CFLAGS_x86_64 += $(my_cflags_intel)
78LOCAL_ASFLAGS += $(common_ASFLAGS)
79LOCAL_SANITIZE := never
80LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
81LOCAL_SHARED_LIBRARIES := libz
82LOCAL_MODULE:= libpng_ndk
83LOCAL_SDK_VERSION := 14
84include $(BUILD_STATIC_LIBRARY)
85
86# For the device (static) for platform (retains fortify support)
87# =====================================================
88
89include $(CLEAR_VARS)
90LOCAL_CLANG := true
91LOCAL_SRC_FILES := $(common_SRC_FILES)
92LOCAL_SRC_FILES_arm := $(my_src_files_arm)
93LOCAL_SRC_FILES_arm64 := $(my_src_files_arm)
94LOCAL_SRC_FILES_x86 += $(my_src_files_intel)
95LOCAL_SRC_FILES_x86_64 += $(my_src_files_intel)
96LOCAL_CFLAGS += $(common_CFLAGS) -ftrapv
97LOCAL_CFLAGS_arm := $(my_cflags_arm)
98LOCAL_CFLAGS_arm64 := $(my_cflags_arm64)
99LOCAL_CFLAGS_x86 += $(my_cflags_intel)
100LOCAL_CFLAGS_x86_64 += $(my_cflags_intel)
101LOCAL_ASFLAGS += $(common_ASFLAGS)
102LOCAL_SANITIZE := never
103LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
104LOCAL_SHARED_LIBRARIES := libz
105LOCAL_MODULE:= libpng
106include $(BUILD_STATIC_LIBRARY)
107
108# For the device (shared)
109# =====================================================
110
111include $(CLEAR_VARS)
112LOCAL_CLANG := true
113LOCAL_SRC_FILES := $(common_SRC_FILES)
114LOCAL_SRC_FILES_arm := $(my_src_files_arm)
115LOCAL_SRC_FILES_arm64 := $(my_src_files_arm)
116LOCAL_SRC_FILES_x86 += $(my_src_files_intel)
117LOCAL_SRC_FILES_x86_64 += $(my_src_files_intel)
118LOCAL_CFLAGS += $(common_CFLAGS) -ftrapv
119LOCAL_CFLAGS_arm := $(my_cflags_arm)
120LOCAL_CFLAGS_arm64 := $(my_cflags_arm64)
121LOCAL_CFLAGS_x86 += $(my_cflags_intel)
122LOCAL_CFLAGS_x86_64 += $(my_cflags_intel)
123LOCAL_ASFLAGS += $(common_ASFLAGS)
124LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
125LOCAL_SHARED_LIBRARIES := libz
126LOCAL_MODULE:= libpng
127include $(BUILD_SHARED_LIBRARY)
128
129# For testing
130# =====================================================
131
132include $(CLEAR_VARS)
133LOCAL_CLANG := true
134LOCAL_SRC_FILES:= pngtest.c
135LOCAL_MODULE := pngtest
136LOCAL_SHARED_LIBRARIES:= libpng libz
137LOCAL_MODULE_TAGS := debug
138include $(BUILD_EXECUTABLE)
139