blob: c78c101204eb34dbc6dc3d9a2d25b0cfac3006e4 [file] [log] [blame]
epoger@google.com1e8e0562011-06-07 14:48:41 +00001# Simple makefile for skia library and test apps
2#
3# This is the handmade Makefile that we *used* to use before changing over
4# to gyp. Keeping it around for now in case some folks need to use it...
5# but please contact epoger@google.com about anything you're still using in
6# here, so we can provide equivalent functionality in the gyp build.
7
8# setup our defaults
9CC := gcc
10GPP := g++
11C_INCLUDES := -Iinclude/config -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/ports
12C_INCLUDES += -Iinclude/gpu -Iinclude/utils -Igpu/include
13C_INCLUDES += -Ithird_party/glu
14
15CFLAGS := -Wall -fstrict-aliasing
16#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
17CFLAGS_SSE2 = $(CFLAGS) -msse2
18LINKER_OPTS := -lpthread -lz
19DEFINES := -DSK_CAN_USE_FLOAT
20HIDE = @
21
22ifeq ($(SKIA_SCALAR),fixed)
23 DEFINES += -DSK_SCALAR_IS_FIXED
24else
25 DEFINES += -DSK_SCALAR_IS_FLOAT
26endif
27
28ifeq ($(SKIA_DEBUG),true)
29 DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT -DGR_DEBUG=1
30 CFLAGS += -g
31else
32 CFLAGS += -O3
33 DEFINES += -DSK_RELEASE -DGR_DEBUG=0
34endif
35
36DEFINES += -DGR_IMPLEMENTATION=1
37
38ifneq ($(SKIA_PDF_SUPPORT),false)
39 DEFINES += -DSK_SUPPORT_PDF
40 DEFINES += -DSK_ZLIB_INCLUDE="<zlib.h>"
41endif
42
43ifeq ($(SKIA_SHARED),true)
44 CFLAGS += -fPIC
45 LIBSKIA = out/libskia.so
46else
47 LIBSKIA = out/libskia.a
48endif
49
50# start with the core (required)
51include src/core/core_files.mk
52SRC_LIST := $(addprefix src/core/, $(SOURCE))
53
54# add the opts (optimizations)
55include src/opts/opts_sse2_files.mk
56#include src/opts/opts_files.mk
57SRC_LIST += $(addprefix src/opts/, $(SOURCE))
58
59# we usually need ports
60include src/ports/ports_files.mk
61SRC_LIST += $(addprefix src/ports/, $(SOURCE))
62
63# do we want effects?
64include src/effects/effects_files.mk
65SRC_LIST += $(addprefix src/effects/, $(SOURCE))
66
67# core image files
68include src/images/images_files.mk
69SRC_LIST += $(addprefix src/images/, $(SOURCE))
70
71# core util files
72include src/utils/utils_files.mk
73SRC_LIST += $(addprefix src/utils/, $(SOURCE))
74
75# GPU files
76include gpu/src/gr_files.mk
77SRC_LIST += $(addprefix gpu/src/, $(SOURCE))
78
79# GPU support files
80include src/gpu/skgr_files.mk
81SRC_LIST += $(addprefix src/gpu/, $(SOURCE))
82
83# pdf backend files
84ifneq ($(SKIA_PDF_SUPPORT),false)
85 C_INCLUDES += -Iinclude/pdf
86 include src/pdf/pdf_files.mk
87 SRC_LIST += $(addprefix src/pdf/, $(SOURCE))
88endif
89
90# extra files we want to build to prevent bit-rot, but not link
91JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp
92
93# conditional files based on our platform
94ifeq ($(SKIA_BUILD_FOR),mac)
95 # make it work with 10.4 for our font port
96# GPP := g++-4.0
97# SDK := /Developer/SDKs/MacOSX10.4u.sdk
98# SDK_OPTS := -isysroot $(SDK) -mmacosx-version-min=10.4
99# CC := gcc-4.0 $(SDK_OPTS)
100
101 C_INCLUDES += -I/opt/local/include
102 LINKER_OPTS += -L/opt/local/lib -framework Carbon -lpng
103 DEFINES += -DSK_BUILD_FOR_MAC -DSK_ENABLE_LIBPNG
104 ifeq ($(SKIA_MESA),true)
105 C_INCLUDES += -I/usr/X11/include
106 LINKER_OPTS += -L/usr/X11/lib -lOSMesa -lGLU
107 DEFINES += -DSK_MESA
108 else
109 LINKER_OPTS += -framework OpenGL -framework AGL
110 endif
111 C_INCLUDES += -Iinclude/utils/mac
112# SRC_LIST += src/ports/SkImageDecoder_CG.cpp
113 SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
114 ifeq ($(SKIA_MESA),true)
115 SRC_LIST += src/utils/mesa/SkEGLContext_Mesa.cpp
116 else
117 SRC_LIST += src/utils/mac/SkEGLContext_mac.cpp
118 endif
119 SRC_LIST += src/core/SkTypefaceCache.cpp
120 SRC_LIST += src/ports/SkFontHost_mac_coretext.cpp
121
122 # these are our registry-based factories
123 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
124 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
125 SRC_LIST += src/images/SkImageDecoder_libpng.cpp
126 # support files
127 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
128
129 ifeq ($(SKIA_MESA),true)
130 SRC_LIST += gpu/src/mesa/GrGLDefaultInterface_mesa.cpp
131 else
132 SRC_LIST += gpu/src/mac/GrGLDefaultInterface_mac.cpp
133 endif
134
135else
bungeman@google.combe9ad4e2011-06-07 19:16:02 +0000136 LINKER_OPTS += -lpng -lfreetype -lrt
epoger@google.com1e8e0562011-06-07 14:48:41 +0000137 DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG -DGR_LINUX_BUILD=1
138 ifeq ($(SKIA_MESA),true)
139 LINKER_OPTS += -lOSMesa -lGLU
140 DEFINES += -DSK_MESA
141 else
142 LINKER_OPTS += -lGL -lGLU -lX11
143 endif
144
145 #Assume the color order for now.
146 DEFINES += -DSK_SAMPLES_FOR_X
147
148 # needed for freetype support
149 C_INCLUDES += -I/usr/include/freetype2
150 SRC_LIST += src/ports/SkFontHost_linux.cpp
151 SRC_LIST += src/ports/SkFontHost_gamma_none.cpp
152 SRC_LIST += src/ports/SkFontHost_FreeType.cpp
153 SRC_LIST += src/ports/SkFontHost_FreeType_Subpixel.cpp
154 ifeq ($(SKIA_MESA),true)
155 SRC_LIST += src/utils/mesa/SkEGLContext_Mesa.cpp
156 else
157 SRC_LIST += src/utils/unix/SkEGLContext_Unix.cpp
158 endif
159 # these are our registry-based factories
160 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
161 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
162 SRC_LIST += src/images/SkImageDecoder_libpng.cpp
163 # support files
164 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
165
166 ifeq ($(SKIA_MESA),true)
167 SRC_LIST += gpu/src/mesa/GrGLDefaultInterface_mesa.cpp
168 else
169 SRC_LIST += gpu/src/unix/GrGLDefaultInterface_unix.cpp
170 endif
171endif
172
173# For these files, and these files only, compile with -msse2.
174SSE2_OBJS := out/src/opts/SkBlitRow_opts_SSE2.o \
175 out/src/opts/SkBitmapProcState_opts_SSE2.o \
176 out/src/opts/SkUtils_opts_SSE2.o
177$(SSE2_OBJS) : CFLAGS := $(CFLAGS_SSE2)
178
179out/%.o : %.cpp
180 @mkdir -p $(dir $@)
181 $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
182 @echo "compiling $@"
183
184%.s : %.cpp
185 @mkdir -p $(dir $@)
186 $(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -S -c $< -o $@
187
188# now build out objects
189OBJ_LIST := $(SRC_LIST:.cpp=.o)
190OBJ_LIST := $(addprefix out/, $(OBJ_LIST))
191
192# we want to compile these, but we don't actually link them
193JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o)
194JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS))
195
196out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS)
197 $(HIDE)$(AR) ru $@ $(OBJ_LIST)
198 $(HIDE)ranlib $@
199
200out/libskia.so: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS)
201 $(HIDE)$(GPP) -shared -o $@ $(OBJ_LIST) $(JUST_COMPILE_OBJS) $(LINKER_OPTS)
202
203##############################################################################
204
205BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp \
bungeman@google.combe9ad4e2011-06-07 19:16:02 +0000206 RepeatTileBench.cpp DecodeBench.cpp FPSBench.cpp PathBench.cpp \
207 GradientBench.cpp MatrixBench.cpp ScalarBench.cpp \
208 BenchTimer.cpp BenchGpuTimer_gl.cpp
209
210ifeq ($(SKIA_BUILD_FOR),mac)
211 BENCH_SRCS += BenchSysTimer_mach.cpp
212else
213 BENCH_SRCS += BenchSysTimer_posix.cpp
214endif
epoger@google.com1e8e0562011-06-07 14:48:41 +0000215
216BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))
217
218# add any optional codecs for this app
219ifeq ($(SKIA_BUILD_FOR),mac)
220 BENCH_SRCS += bench/TextBench.cpp
221else
222 BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp
223endif
224
225BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
226BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))
227
228bench: $(BENCH_OBJS) $(LIBSKIA)
229 @echo "linking bench..."
230 $(HIDE)$(GPP) $(BENCH_OBJS) $(LIBSKIA) -o out/bench/bench $(LINKER_OPTS)
231
232##############################################################################
233
234# we let tests cheat and see private headers, so we can unittest modules
235C_INCLUDES += -Isrc/core
236
237include tests/tests_files.mk
238ifneq ($(SKIA_PDF_SUPPORT),false)
239 SOURCE += PDFPrimitivesTest.cpp
240endif
241TESTS_SRCS := $(addprefix tests/, $(SOURCE))
242
243TESTS_OBJS := $(TESTS_SRCS:.cpp=.o)
244TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS))
245
246tests: $(TESTS_OBJS) $(LIBSKIA)
247 @echo "linking tests..."
248 $(HIDE)$(GPP) $(TESTS_OBJS) $(LIBSKIA) -o out/tests/tests $(LINKER_OPTS)
249
250##############################################################################
251
252SKIMAGE_SRCS := skimage_main.cpp
253
254SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS))
255
256SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o)
257SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS))
258
259skimage: $(SKIMAGE_OBJS) $(LIBSKIA)
260 @echo "linking skimage..."
261 $(HIDE)$(GPP) $(SKIMAGE_OBJS) $(LIBSKIA) -o out/tools/skimage $(LINKER_OPTS)
262
263##############################################################################
264
265SKDIFF_SRCS := skdiff_main.cpp
266SKDIFF_SRCS := $(addprefix tools/, $(SKDIFF_SRCS))
267SKDIFF_OBJS := $(SKDIFF_SRCS:.cpp=.o)
268SKDIFF_OBJS := $(addprefix out/, $(SKDIFF_OBJS))
269skdiff: $(SKDIFF_OBJS) out/libskia.a
270 @echo "linking skdiff..."
271 $(HIDE)$(GPP) $(SKDIFF_OBJS) out/libskia.a -o out/tools/skdiff $(LINKER_OPTS)
272
273##############################################################################
274
275SKHELLO_SRCS := skhello.cpp
276
277SKHELLO_SRCS := $(addprefix tools/, $(SKHELLO_SRCS))
278
279SKHELLO_OBJS := $(SKHELLO_SRCS:.cpp=.o)
280SKHELLO_OBJS := $(addprefix out/, $(SKHELLO_OBJS))
281
282skhello: $(SKHELLO_OBJS) $(LIBSKIA)
283 @echo "linking shkello..."
284 $(HIDE)$(GPP) $(SKHELLO_OBJS) $(LIBSKIA) -o out/tools/skhello $(LINKER_OPTS)
285
286##############################################################################
287
288include gm/gm_files.mk
289GM_SRCS := $(addprefix gm/, $(SOURCE))
290
291ifneq ($(SKIA_BUILD_FOR),mac)
292 GM_SRCS += src/images/SkImageDecoder_libpng.cpp
293endif
294
295GM_OBJS := $(GM_SRCS:.cpp=.o)
296GM_OBJS := $(addprefix out/, $(GM_OBJS))
297
298gm: $(GM_OBJS) $(LIBSKIA)
299 @echo "linking gm..."
300 $(HIDE)$(GPP) $(GM_OBJS) $(LIBSKIA) -o out/gm/gm $(LINKER_OPTS)
301
302##############################################################################
303
304.PHONY: all
305all: $ bench gm skimage tests skhello skdiff
306
307.PHONY: clean
308clean:
309 $(HIDE)rm -rf out
310
311.PHONY: help
312help:
313 @echo "Targets:"
314 @echo " <default>: out/libskia.a"
315 @echo " bench: out/bench/bench"
316 @echo " gm: out/gm/gm"
317 @echo " skimage: out/tools/skimage"
318 @echo " skhello: out/tools/skhello"
319 @echo " tests: out/tests/tests"
320 @echo " clean: removes entire out/ directory"
321 @echo " help: this text"
322 @echo "Options: (after make, or in bash shell)"
323 @echo " SKIA_DEBUG=true for debug build"
324 @echo " SKIA_SHARED=true for shared-object libskia build"
325 @echo " SKIA_SCALAR=fixed for fixed-point build"
326 @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)"
327 @echo " SKIA_PDF_SUPPORT=false to disable the pdf generation backend"
bungeman@google.combe9ad4e2011-06-07 19:16:02 +0000328 @echo " SKIA_MESA=true to build with osmesa instead of native GL.
epoger@google.com1e8e0562011-06-07 14:48:41 +0000329 @echo ""