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