blob: b1a18a1929e93e2f2d27dc302abd432fd3ca9bf4 [file] [log] [blame]
reed@android.com4c7d3d62009-01-21 03:15:13 +00001# Simple makefile for skia library and test apps
reed@android.com4cb8bd12009-01-16 16:15:37 +00002
reed@android.com9db60872009-01-21 15:07:03 +00003# setup our defaults
reed@android.com4c7d3d62009-01-21 03:15:13 +00004CC := gcc
reed@android.comcf4ac252010-05-12 17:25:30 +00005GPP := g++
reed@google.com873cb1e2010-12-23 15:00:45 +00006C_INCLUDES := -Iinclude/config -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/gpu -Iinclude/utils -Igpu/include
7
reed@google.com272e7542011-01-10 14:54:30 +00008CFLAGS := -Wall -fstrict-aliasing
senorblanco@chromium.org4e753552009-11-16 21:09:00 +00009CFLAGS_SSE2 = $(CFLAGS) -msse2
reed@google.com07700442010-12-20 19:46:07 +000010LINKER_OPTS := -lpthread -lz
reed@android.com4c7d3d62009-01-21 03:15:13 +000011DEFINES := -DSK_CAN_USE_FLOAT
reed@android.com4cb8bd12009-01-16 16:15:37 +000012HIDE = @
13
reed@android.com9db60872009-01-21 15:07:03 +000014ifeq ($(SKIA_SCALAR),fixed)
reed@android.com4c7d3d62009-01-21 03:15:13 +000015 DEFINES += -DSK_SCALAR_IS_FIXED
16else
17 DEFINES += -DSK_SCALAR_IS_FLOAT
18endif
19
20ifeq ($(SKIA_DEBUG),true)
reed@google.comeeeb5a02010-12-23 15:12:59 +000021 DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT -DGR_DEBUG=1
reed@google.com272e7542011-01-10 14:54:30 +000022 CFLAGS := -g
reed@android.com4c7d3d62009-01-21 03:15:13 +000023else
reed@google.com272e7542011-01-10 14:54:30 +000024 CFLAGS := -O2
reed@google.comeeeb5a02010-12-23 15:12:59 +000025 DEFINES += -DSK_RELEASE -DGR_DEBUG=0
reed@android.com4c7d3d62009-01-21 03:15:13 +000026endif
reed@android.com4cb8bd12009-01-16 16:15:37 +000027
reed@android.comf5493692009-07-22 19:21:01 +000028DEFINES += -DSK_SUPPORT_LCDTEXT
29
reed@google.com07700442010-12-20 19:46:07 +000030ifeq ($(SKIA_PDF_SUPPORT),true)
31 DEFINES += -DSK_SUPPORT_PDF
reed@google.comd6423292010-12-20 20:53:13 +000032 DEFINES += -DSK_ZLIB_INCLUDE="<zlib.h>"
reed@google.com07700442010-12-20 19:46:07 +000033endif
34
reed@android.com4cb8bd12009-01-16 16:15:37 +000035# start with the core (required)
36include src/core/core_files.mk
37SRC_LIST := $(addprefix src/core/, $(SOURCE))
38
reed@android.comed7bd9b2009-07-30 02:25:54 +000039# add the opts (optimizations)
40include src/opts/opts_files.mk
41SRC_LIST += $(addprefix src/opts/, $(SOURCE))
42
reed@android.com4cb8bd12009-01-16 16:15:37 +000043# we usually need ports
44include src/ports/ports_files.mk
45SRC_LIST += $(addprefix src/ports/, $(SOURCE))
46
47# do we want effects?
48include src/effects/effects_files.mk
49SRC_LIST += $(addprefix src/effects/, $(SOURCE))
50
reed@android.com4c7d3d62009-01-21 03:15:13 +000051# core image files
52include src/images/images_files.mk
53SRC_LIST += $(addprefix src/images/, $(SOURCE))
54
reed@android.com9781ca52009-04-14 14:28:22 +000055# core util files
56include src/utils/utils_files.mk
57SRC_LIST += $(addprefix src/utils/, $(SOURCE))
58
reed@google.com873cb1e2010-12-23 15:00:45 +000059# GPU files
60include gpu/src/gr_files.mk
61SRC_LIST += $(addprefix gpu/src/, $(SOURCE))
62
63# GPU support files
64include src/gpu/skgr_files.mk
65SRC_LIST += $(addprefix src/gpu/, $(SOURCE))
66
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000067# pdf backend files
68ifeq ($(SKIA_PDF_SUPPORT),true)
69 C_INCLUDES += -Iinclude/pdf
70 include src/pdf/pdf_files.mk
71 SRC_LIST += $(addprefix src/pdf/, $(SOURCE))
72endif
73
reed@android.com9781ca52009-04-14 14:28:22 +000074# extra files we want to build to prevent bit-rot, but not link
75JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp
76
reed@android.com4c7d3d62009-01-21 03:15:13 +000077# conditional files based on our platform
reed@android.com9db60872009-01-21 15:07:03 +000078ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.comcf4ac252010-05-12 17:25:30 +000079 # make it work with 10.4 for our font port
reed@android.com179d6162010-12-20 18:32:39 +000080# GPP := g++-4.0
81# SDK := /Developer/SDKs/MacOSX10.4u.sdk
82# SDK_OPTS := -isysroot $(SDK) -mmacosx-version-min=10.4
83# CC := gcc-4.0 $(SDK_OPTS)
reed@android.comcf4ac252010-05-12 17:25:30 +000084
reed@google.com78761142010-12-23 16:34:58 +000085 C_INCLUDES += -I/opt/local/include
reed@google.com37df17d2010-12-23 20:20:51 +000086 LINKER_OPTS += -L/opt/local/lib -framework Carbon -lpng12 -framework OpenGL -framework AGL
reed@google.com78761142010-12-23 16:34:58 +000087 DEFINES += -DSK_BUILD_FOR_MAC -DSK_ENABLE_LIBPNG
reed@android.com4c7d3d62009-01-21 03:15:13 +000088
89 C_INCLUDES += -Iinclude/utils/mac
reed@google.com78761142010-12-23 16:34:58 +000090# SRC_LIST += src/ports/SkImageDecoder_CG.cpp
reed@android.com38669c12011-01-03 13:48:50 +000091 SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
reed@google.com873cb1e2010-12-23 15:00:45 +000092 SRC_LIST += src/utils/mac/SkEGLContext_mac.cpp
reed@android.com179d6162010-12-20 18:32:39 +000093 SRC_LIST += src/ports/SkFontHost_mac_coretext.cpp
reed@google.com78761142010-12-23 16:34:58 +000094
95 # these are our registry-based factories
96 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
97 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
98 SRC_LIST += src/images/SkImageDecoder_libpng.cpp
99 # support files
100 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +0000101else
reed@google.com37df17d2010-12-23 20:20:51 +0000102 LINKER_OPTS += -lpng -lfreetype -lGL
103 DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG -DGR_LINUX_BUILD=1
reed@android.com4c7d3d62009-01-21 03:15:13 +0000104
reed@android.comf2afb672009-09-28 16:12:48 +0000105 # needed for freetype support
106 C_INCLUDES += -I/usr/include/freetype2
107 SRC_LIST += src/ports/SkFontHost_linux.cpp
108 SRC_LIST += src/ports/SkFontHost_gamma_none.cpp
109 SRC_LIST += src/ports/SkFontHost_FreeType.cpp
110 SRC_LIST += src/ports/SkFontHost_FreeType_Subpixel.cpp
111 SRC_LIST += src/utils/SkOSFile.cpp
reed@google.com37df17d2010-12-23 20:20:51 +0000112 SRC_LIST += src/utils/SkEGLContext_none.cpp
reed@android.com7b830a12009-01-22 13:41:08 +0000113 # these are our registry-based factories
114 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
115 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
reed@android.comfd9714e2010-04-15 14:28:24 +0000116 SRC_LIST += src/images/SkImageDecoder_libpng.cpp
reed@android.com7b830a12009-01-22 13:41:08 +0000117 # support files
118 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +0000119endif
120
senorblanco@chromium.org4e753552009-11-16 21:09:00 +0000121# For these files, and these files only, compile with -msse2.
122SSE2_OBJS := out/src/opts/SkBlitRow_opts_SSE2.o \
senorblanco@chromium.org29e50542010-12-16 19:07:45 +0000123 out/src/opts/SkBitmapProcState_opts_SSE2.o \
senorblanco@chromium.org4e753552009-11-16 21:09:00 +0000124 out/src/opts/SkUtils_opts_SSE2.o
125$(SSE2_OBJS) : CFLAGS := $(CFLAGS_SSE2)
126
reed@android.com4cb8bd12009-01-16 16:15:37 +0000127out/%.o : %.cpp
128 @mkdir -p $(dir $@)
129 $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
130 @echo "compiling $@"
reed@google.com1fcd51e2011-01-05 15:50:27 +0000131
senorblanco@chromium.org4aa910e2009-10-30 18:50:23 +0000132%.s : %.cpp
133 @mkdir -p $(dir $@)
134 $(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -S -c $< -o $@
135
reed@android.com4cb8bd12009-01-16 16:15:37 +0000136# now build out objects
137OBJ_LIST := $(SRC_LIST:.cpp=.o)
138OBJ_LIST := $(addprefix out/, $(OBJ_LIST))
139
reed@android.com9781ca52009-04-14 14:28:22 +0000140# we want to compile these, but we don't actually link them
141JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o)
142JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS))
143
144out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS)
reed@android.com4cb8bd12009-01-16 16:15:37 +0000145 $(HIDE)$(AR) ru $@ $(OBJ_LIST)
146 $(HIDE)ranlib $@
147
reed@android.coma396a162009-02-28 18:26:14 +0000148##############################################################################
149
reed@android.com4d850592009-08-12 20:30:58 +0000150BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp \
reed@android.com7911e272010-04-15 16:34:54 +0000151 RepeatTileBench.cpp DecodeBench.cpp FPSBench.cpp
reed@android.com179d6162010-12-20 18:32:39 +0000152
reed@android.com4cb8bd12009-01-16 16:15:37 +0000153BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))
reed@android.com1b4c8152009-01-23 21:51:56 +0000154
reed@android.comfb210162009-01-23 21:24:39 +0000155# add any optional codecs for this app
reed@android.com3a859a02009-01-28 00:56:29 +0000156ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.comd6638e62009-04-08 05:03:52 +0000157 BENCH_SRCS += bench/TextBench.cpp
reed@android.com3a859a02009-01-28 00:56:29 +0000158else
reed@android.coma21ff6f2009-01-27 18:25:02 +0000159 BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp
reed@android.com1b4c8152009-01-23 21:51:56 +0000160endif
reed@android.comfb210162009-01-23 21:24:39 +0000161
reed@android.com4cb8bd12009-01-16 16:15:37 +0000162BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
163BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))
164
165bench: $(BENCH_OBJS) out/libskia.a
reed@android.com4c7d3d62009-01-21 03:15:13 +0000166 @echo "linking bench..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000167 $(HIDE)$(GPP) $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS)
reed@google.com1fcd51e2011-01-05 15:50:27 +0000168
reed@android.coma396a162009-02-28 18:26:14 +0000169##############################################################################
170
reed@android.com0650c6c2009-03-04 14:02:44 +0000171# we let tests cheat and see private headers, so we can unittest modules
172C_INCLUDES += -Isrc/core
173
reed@android.combbff1d52009-06-05 16:21:03 +0000174include tests/tests_files.mk
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +0000175ifeq ($(SKIA_PDF_SUPPORT),true)
176 SOURCE += PDFPrimitivesTest.cpp
177endif
reed@android.combbff1d52009-06-05 16:21:03 +0000178TESTS_SRCS := $(addprefix tests/, $(SOURCE))
reed@android.coma396a162009-02-28 18:26:14 +0000179
180TESTS_OBJS := $(TESTS_SRCS:.cpp=.o)
181TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS))
182
183tests: $(TESTS_OBJS) out/libskia.a
184 @echo "linking tests..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000185 $(HIDE)$(GPP) $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS)
reed@google.com1fcd51e2011-01-05 15:50:27 +0000186
reed@android.coma396a162009-02-28 18:26:14 +0000187##############################################################################
188
reed@android.comaf459792009-04-24 19:52:53 +0000189SKIMAGE_SRCS := skimage_main.cpp
190
191SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS))
192
193SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o)
194SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS))
195
196skimage: $(SKIMAGE_OBJS) out/libskia.a
197 @echo "linking skimage..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000198 $(HIDE)$(GPP) $(SKIMAGE_OBJS) out/libskia.a -o out/tools/skimage $(LINKER_OPTS)
reed@android.comaf459792009-04-24 19:52:53 +0000199
200##############################################################################
201
reed@android.com6413e792010-04-12 14:27:37 +0000202SKHELLO_SRCS := skhello.cpp
203
204SKHELLO_SRCS := $(addprefix tools/, $(SKHELLO_SRCS))
205
206SKHELLO_OBJS := $(SKHELLO_SRCS:.cpp=.o)
207SKHELLO_OBJS := $(addprefix out/, $(SKHELLO_OBJS))
208
209skhello: $(SKHELLO_OBJS) out/libskia.a
210 @echo "linking shkello..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000211 $(HIDE)$(GPP) $(SKHELLO_OBJS) out/libskia.a -o out/tools/skhello $(LINKER_OPTS)
reed@android.com6413e792010-04-12 14:27:37 +0000212
213##############################################################################
214
reed@android.com048522d2009-06-23 12:19:41 +0000215include gm/gm_files.mk
216GM_SRCS := $(addprefix gm/, $(SOURCE))
reed@android.comdd0ac282009-06-20 02:38:16 +0000217
senorblanco@chromium.org4aa910e2009-10-30 18:50:23 +0000218ifneq ($(SKIA_BUILD_FOR),mac)
219 GM_SRCS += src/images/SkImageDecoder_libpng.cpp
220endif
221
reed@android.comdd0ac282009-06-20 02:38:16 +0000222GM_OBJS := $(GM_SRCS:.cpp=.o)
223GM_OBJS := $(addprefix out/, $(GM_OBJS))
224
225gm: $(GM_OBJS) out/libskia.a
226 @echo "linking gm..."
reed@google.com37df17d2010-12-23 20:20:51 +0000227 $(HIDE)$(GPP) $(GM_OBJS) out/libskia.a -o out/gm/gm $(LINKER_OPTS)
reed@android.comdd0ac282009-06-20 02:38:16 +0000228
reed@google.com07700442010-12-20 19:46:07 +0000229SAMPLEPDF_SRCS := samplepdf.cpp
230
231SAMPLEPDF_SRCS := $(addprefix tools/, $(SAMPLEPDF_SRCS))
232
233SAMPLEPDF_OBJS := $(SAMPLEPDF_SRCS:.cpp=.o)
234SAMPLEPDF_OBJS := $(addprefix out/, $(SAMPLEPDF_OBJS))
235
236samplepdf: $(SAMPLEPDF_OBJS) out/libskia.a
237 @echo "linking samplepdf..."
238 $(HIDE)$(GPP) $(SAMPLEPDF_OBJS) out/libskia.a -o out/tools/samplepdf $(LINKER_OPTS)
239
reed@android.comdd0ac282009-06-20 02:38:16 +0000240##############################################################################
241
reed@android.comee0eb012009-06-23 17:13:30 +0000242.PHONY: all
reed@android.com6413e792010-04-12 14:27:37 +0000243all: $ bench gm skimage tests skhello
reed@android.comee0eb012009-06-23 17:13:30 +0000244
reed@android.com9db60872009-01-21 15:07:03 +0000245.PHONY: clean
reed@android.com4cb8bd12009-01-16 16:15:37 +0000246clean:
247 $(HIDE)rm -rf out
reed@android.com9db60872009-01-21 15:07:03 +0000248
249.PHONY: help
reed@android.com4c7d3d62009-01-21 03:15:13 +0000250help:
251 @echo "Targets:"
252 @echo " <default>: out/libskia.a"
253 @echo " bench: out/bench/bench"
reed@android.comdd0ac282009-06-20 02:38:16 +0000254 @echo " gm: out/gm/gm"
reed@android.comaf459792009-04-24 19:52:53 +0000255 @echo " skimage: out/tools/skimage"
reed@android.com6413e792010-04-12 14:27:37 +0000256 @echo " skhello: out/tools/skhello"
reed@android.coma396a162009-02-28 18:26:14 +0000257 @echo " tests: out/tests/tests"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000258 @echo " clean: removes entire out/ directory"
259 @echo " help: this text"
reed@android.com9db60872009-01-21 15:07:03 +0000260 @echo "Options: (after make, or in bash shell)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000261 @echo " SKIA_DEBUG=true for debug build"
reed@android.com9db60872009-01-21 15:07:03 +0000262 @echo " SKIA_SCALAR=fixed for fixed-point build"
263 @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)"
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +0000264 @echo " SKIA_PDF_SUPPORT=true to enable the pdf generation backend"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000265 @echo ""