aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile
blob: e482060c6272435313ed688be4486e906fe5b13e (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# Simple makefile for skia library and test apps

# setup our defaults
CC := gcc
GPP := g++
C_INCLUDES := -Iinclude/config -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/gpu -Iinclude/utils -Igpu/include

CFLAGS := -Wall -fstrict-aliasing
#CFLAGS += -W -Wextra -Wcast-align -Wchar-subscripts -Wformat -Wformat-security -Wno-format-y2k -Wno-parentheses -Wno-unused-parameter -Wpointer-arith  -Wreturn-type -Wundef -Wwrite-strings
CFLAGS_SSE2 = $(CFLAGS) -msse2
LINKER_OPTS := -lpthread -lz
DEFINES := -DSK_CAN_USE_FLOAT
HIDE = @

ifeq ($(SKIA_SCALAR),fixed)
	DEFINES += -DSK_SCALAR_IS_FIXED
else
	DEFINES += -DSK_SCALAR_IS_FLOAT
endif

ifeq ($(SKIA_DEBUG),true)
 	DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT -DGR_DEBUG=1
	CFLAGS += -g
else
	CFLAGS += -O2
	DEFINES += -DSK_RELEASE -DGR_DEBUG=0
endif

DEFINES += -DSK_SUPPORT_LCDTEXT

ifneq ($(SKIA_PDF_SUPPORT),false)
	DEFINES += -DSK_SUPPORT_PDF
ifneq ($(SKIA_DEBUG),true)
	DEFINES += -DSK_ZLIB_INCLUDE="<zlib.h>"
endif
endif

# start with the core (required)
include src/core/core_files.mk
SRC_LIST := $(addprefix src/core/, $(SOURCE))

# add the opts (optimizations)
include src/opts/opts_sse2_files.mk
#include src/opts/opts_files.mk
SRC_LIST += $(addprefix src/opts/, $(SOURCE))

# we usually need ports
include src/ports/ports_files.mk
SRC_LIST += $(addprefix src/ports/, $(SOURCE))

# do we want effects?
include src/effects/effects_files.mk
SRC_LIST += $(addprefix src/effects/, $(SOURCE))

# core image files
include src/images/images_files.mk
SRC_LIST += $(addprefix src/images/, $(SOURCE))

# core util files
include src/utils/utils_files.mk
SRC_LIST += $(addprefix src/utils/, $(SOURCE))

# GPU files
include gpu/src/gr_files.mk
SRC_LIST += $(addprefix gpu/src/, $(SOURCE))

# GPU support files
include src/gpu/skgr_files.mk
SRC_LIST += $(addprefix src/gpu/, $(SOURCE))

# pdf backend files
ifneq ($(SKIA_PDF_SUPPORT),false)
	C_INCLUDES += -Iinclude/pdf
	include src/pdf/pdf_files.mk
	SRC_LIST += $(addprefix src/pdf/, $(SOURCE))
endif

# extra files we want to build to prevent bit-rot, but not link
JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp

# conditional files based on our platform
ifeq ($(SKIA_BUILD_FOR),mac)
	# make it work with 10.4 for our font port
#	GPP := g++-4.0
#	SDK := /Developer/SDKs/MacOSX10.4u.sdk
#	SDK_OPTS := -isysroot $(SDK) -mmacosx-version-min=10.4
#	CC := gcc-4.0 $(SDK_OPTS)

	C_INCLUDES += -I/opt/local/include
	LINKER_OPTS += -L/opt/local/lib -framework Carbon -lpng12 -framework OpenGL -framework AGL
	DEFINES += -DSK_BUILD_FOR_MAC -DSK_ENABLE_LIBPNG

	C_INCLUDES += -Iinclude/utils/mac
#	SRC_LIST += src/ports/SkImageDecoder_CG.cpp
	SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
	SRC_LIST += src/utils/mac/SkEGLContext_mac.cpp
	SRC_LIST += src/ports/SkFontHost_mac_coretext.cpp

    # these are our registry-based factories
	SRC_LIST += src/images/SkImageDecoder_Factory.cpp
	SRC_LIST += src/images/SkImageEncoder_Factory.cpp
        SRC_LIST += src/images/SkImageDecoder_libpng.cpp
    # support files
	SRC_LIST += src/images/SkScaledBitmapSampler.cpp
else
	LINKER_OPTS += -lpng -lfreetype -lGL
	DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG -DGR_LINUX_BUILD=1

	# needed for freetype support
	C_INCLUDES += -I/usr/include/freetype2
	SRC_LIST += src/ports/SkFontHost_linux.cpp
	SRC_LIST += src/ports/SkFontHost_gamma_none.cpp
	SRC_LIST += src/ports/SkFontHost_FreeType.cpp
	SRC_LIST += src/ports/SkFontHost_FreeType_Subpixel.cpp
	SRC_LIST += src/utils/SkOSFile.cpp
	SRC_LIST += src/utils/SkEGLContext_none.cpp
    # these are our registry-based factories
	SRC_LIST += src/images/SkImageDecoder_Factory.cpp
	SRC_LIST += src/images/SkImageEncoder_Factory.cpp
        SRC_LIST += src/images/SkImageDecoder_libpng.cpp
    # support files
	SRC_LIST += src/images/SkScaledBitmapSampler.cpp
endif

# For these files, and these files only, compile with -msse2.
SSE2_OBJS := out/src/opts/SkBlitRow_opts_SSE2.o \
             out/src/opts/SkBitmapProcState_opts_SSE2.o \
             out/src/opts/SkUtils_opts_SSE2.o
$(SSE2_OBJS) : CFLAGS := $(CFLAGS_SSE2)

out/%.o : %.cpp
	@mkdir -p $(dir $@)
	$(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
	@echo "compiling $@"

%.s : %.cpp
	@mkdir -p $(dir $@)
	$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -S -c $< -o $@

# now build out objects
OBJ_LIST := $(SRC_LIST:.cpp=.o)
OBJ_LIST := $(addprefix out/, $(OBJ_LIST))

# we want to compile these, but we don't actually link them
JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o)
JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS))

out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS)
	$(HIDE)$(AR) ru $@ $(OBJ_LIST)
	$(HIDE)ranlib $@

##############################################################################

BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp \
			  RepeatTileBench.cpp DecodeBench.cpp FPSBench.cpp

BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))

# add any optional codecs for this app
ifeq ($(SKIA_BUILD_FOR),mac)
    BENCH_SRCS += bench/TextBench.cpp
else
    BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp
endif

BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))

bench: $(BENCH_OBJS) out/libskia.a
	@echo "linking bench..."
	$(HIDE)$(GPP) $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS)

##############################################################################

# we let tests cheat and see private headers, so we can unittest modules
C_INCLUDES += -Isrc/core

include tests/tests_files.mk
ifneq ($(SKIA_PDF_SUPPORT),false)
  SOURCE += PDFPrimitivesTest.cpp
endif
TESTS_SRCS := $(addprefix tests/, $(SOURCE))

TESTS_OBJS := $(TESTS_SRCS:.cpp=.o)
TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS))

tests: $(TESTS_OBJS) out/libskia.a
	@echo "linking tests..."
	$(HIDE)$(GPP) $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS)

##############################################################################

SKIMAGE_SRCS := skimage_main.cpp

SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS))

SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o)
SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS))

skimage: $(SKIMAGE_OBJS) out/libskia.a
	@echo "linking skimage..."
	$(HIDE)$(GPP) $(SKIMAGE_OBJS) out/libskia.a -o out/tools/skimage $(LINKER_OPTS)

##############################################################################

SKHELLO_SRCS := skhello.cpp

SKHELLO_SRCS := $(addprefix tools/, $(SKHELLO_SRCS))

SKHELLO_OBJS := $(SKHELLO_SRCS:.cpp=.o)
SKHELLO_OBJS := $(addprefix out/, $(SKHELLO_OBJS))

skhello: $(SKHELLO_OBJS) out/libskia.a
	@echo "linking shkello..."
	$(HIDE)$(GPP) $(SKHELLO_OBJS) out/libskia.a -o out/tools/skhello $(LINKER_OPTS)

##############################################################################

include gm/gm_files.mk
GM_SRCS := $(addprefix gm/, $(SOURCE))

ifneq ($(SKIA_BUILD_FOR),mac)
    GM_SRCS += src/images/SkImageDecoder_libpng.cpp
endif

GM_OBJS := $(GM_SRCS:.cpp=.o)
GM_OBJS := $(addprefix out/, $(GM_OBJS))

gm: $(GM_OBJS) out/libskia.a
	@echo "linking gm..."
	$(HIDE)$(GPP) $(GM_OBJS) out/libskia.a -o out/gm/gm $(LINKER_OPTS)

##############################################################################

.PHONY: all
all: $ bench gm skimage tests skhello

.PHONY: clean
clean:
	$(HIDE)rm -rf out

.PHONY: help
help:
	@echo "Targets:"
	@echo "    <default>: out/libskia.a"
	@echo "    bench: out/bench/bench"
	@echo "    gm: out/gm/gm"
	@echo "    skimage: out/tools/skimage"
	@echo "    skhello: out/tools/skhello"
	@echo "    tests: out/tests/tests"
	@echo "    clean: removes entire out/ directory"
	@echo "    help: this text"
	@echo "Options: (after make, or in bash shell)"
	@echo "    SKIA_DEBUG=true for debug build"
	@echo "    SKIA_SCALAR=fixed for fixed-point build"
	@echo "    SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)"
	@echo "    SKIA_PDF_SUPPORT=false to disable the pdf generation backend"
	@echo ""