blob: 5829d0797864c101f198ea81215e6e9a080eb62b [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@android.com179d6162010-12-20 18:32:39 +00008CFLAGS := -Wall -O2
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@android.com4c7d3d62009-01-21 03:15:13 +000022else
reed@google.comeeeb5a02010-12-23 15:12:59 +000023 DEFINES += -DSK_RELEASE -DGR_DEBUG=0
reed@android.com4c7d3d62009-01-21 03:15:13 +000024endif
reed@android.com4cb8bd12009-01-16 16:15:37 +000025
reed@android.comf5493692009-07-22 19:21:01 +000026DEFINES += -DSK_SUPPORT_LCDTEXT
27
reed@google.com07700442010-12-20 19:46:07 +000028ifeq ($(SKIA_PDF_SUPPORT),true)
29 DEFINES += -DSK_SUPPORT_PDF
reed@google.comd6423292010-12-20 20:53:13 +000030 DEFINES += -DSK_ZLIB_INCLUDE="<zlib.h>"
reed@google.com07700442010-12-20 19:46:07 +000031endif
32
reed@android.com4cb8bd12009-01-16 16:15:37 +000033# start with the core (required)
34include src/core/core_files.mk
35SRC_LIST := $(addprefix src/core/, $(SOURCE))
36
reed@android.comed7bd9b2009-07-30 02:25:54 +000037# add the opts (optimizations)
38include src/opts/opts_files.mk
39SRC_LIST += $(addprefix src/opts/, $(SOURCE))
40
reed@android.com4cb8bd12009-01-16 16:15:37 +000041# we usually need ports
42include src/ports/ports_files.mk
43SRC_LIST += $(addprefix src/ports/, $(SOURCE))
44
45# do we want effects?
46include src/effects/effects_files.mk
47SRC_LIST += $(addprefix src/effects/, $(SOURCE))
48
reed@android.com4c7d3d62009-01-21 03:15:13 +000049# core image files
50include src/images/images_files.mk
51SRC_LIST += $(addprefix src/images/, $(SOURCE))
52
reed@android.com9781ca52009-04-14 14:28:22 +000053# core util files
54include src/utils/utils_files.mk
55SRC_LIST += $(addprefix src/utils/, $(SOURCE))
56
reed@google.com873cb1e2010-12-23 15:00:45 +000057# GPU files
58include gpu/src/gr_files.mk
59SRC_LIST += $(addprefix gpu/src/, $(SOURCE))
60
61# GPU support files
62include src/gpu/skgr_files.mk
63SRC_LIST += $(addprefix src/gpu/, $(SOURCE))
64
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000065# pdf backend files
66ifeq ($(SKIA_PDF_SUPPORT),true)
67 C_INCLUDES += -Iinclude/pdf
68 include src/pdf/pdf_files.mk
69 SRC_LIST += $(addprefix src/pdf/, $(SOURCE))
70endif
71
reed@android.com9781ca52009-04-14 14:28:22 +000072# extra files we want to build to prevent bit-rot, but not link
73JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp
74
reed@android.com4c7d3d62009-01-21 03:15:13 +000075# conditional files based on our platform
reed@android.com9db60872009-01-21 15:07:03 +000076ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.comcf4ac252010-05-12 17:25:30 +000077 # make it work with 10.4 for our font port
reed@android.com179d6162010-12-20 18:32:39 +000078# GPP := g++-4.0
79# SDK := /Developer/SDKs/MacOSX10.4u.sdk
80# SDK_OPTS := -isysroot $(SDK) -mmacosx-version-min=10.4
81# CC := gcc-4.0 $(SDK_OPTS)
reed@android.comcf4ac252010-05-12 17:25:30 +000082
reed@google.com78761142010-12-23 16:34:58 +000083 C_INCLUDES += -I/opt/local/include
reed@google.com37df17d2010-12-23 20:20:51 +000084 LINKER_OPTS += -L/opt/local/lib -framework Carbon -lpng12 -framework OpenGL -framework AGL
reed@google.com78761142010-12-23 16:34:58 +000085 DEFINES += -DSK_BUILD_FOR_MAC -DSK_ENABLE_LIBPNG
reed@android.com4c7d3d62009-01-21 03:15:13 +000086
87 C_INCLUDES += -Iinclude/utils/mac
reed@google.com78761142010-12-23 16:34:58 +000088# SRC_LIST += src/ports/SkImageDecoder_CG.cpp
reed@android.com38669c12011-01-03 13:48:50 +000089 SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
reed@google.com873cb1e2010-12-23 15:00:45 +000090 SRC_LIST += src/utils/mac/SkEGLContext_mac.cpp
reed@android.com179d6162010-12-20 18:32:39 +000091 SRC_LIST += src/ports/SkFontHost_mac_coretext.cpp
reed@google.com78761142010-12-23 16:34:58 +000092
93 # these are our registry-based factories
94 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
95 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
96 SRC_LIST += src/images/SkImageDecoder_libpng.cpp
97 # support files
98 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000099else
reed@google.com37df17d2010-12-23 20:20:51 +0000100 LINKER_OPTS += -lpng -lfreetype -lGL
101 DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG -DGR_LINUX_BUILD=1
reed@android.com4c7d3d62009-01-21 03:15:13 +0000102
reed@android.comf2afb672009-09-28 16:12:48 +0000103 # needed for freetype support
104 C_INCLUDES += -I/usr/include/freetype2
105 SRC_LIST += src/ports/SkFontHost_linux.cpp
106 SRC_LIST += src/ports/SkFontHost_gamma_none.cpp
107 SRC_LIST += src/ports/SkFontHost_FreeType.cpp
108 SRC_LIST += src/ports/SkFontHost_FreeType_Subpixel.cpp
109 SRC_LIST += src/utils/SkOSFile.cpp
reed@google.com37df17d2010-12-23 20:20:51 +0000110 SRC_LIST += src/utils/SkEGLContext_none.cpp
reed@android.com7b830a12009-01-22 13:41:08 +0000111 # these are our registry-based factories
112 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
113 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
reed@android.comfd9714e2010-04-15 14:28:24 +0000114 SRC_LIST += src/images/SkImageDecoder_libpng.cpp
reed@android.com7b830a12009-01-22 13:41:08 +0000115 # support files
116 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +0000117endif
118
senorblanco@chromium.org4e753552009-11-16 21:09:00 +0000119# For these files, and these files only, compile with -msse2.
120SSE2_OBJS := out/src/opts/SkBlitRow_opts_SSE2.o \
senorblanco@chromium.org29e50542010-12-16 19:07:45 +0000121 out/src/opts/SkBitmapProcState_opts_SSE2.o \
senorblanco@chromium.org4e753552009-11-16 21:09:00 +0000122 out/src/opts/SkUtils_opts_SSE2.o
123$(SSE2_OBJS) : CFLAGS := $(CFLAGS_SSE2)
124
reed@android.com4cb8bd12009-01-16 16:15:37 +0000125out/%.o : %.cpp
126 @mkdir -p $(dir $@)
127 $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
128 @echo "compiling $@"
129
senorblanco@chromium.org4aa910e2009-10-30 18:50:23 +0000130%.s : %.cpp
131 @mkdir -p $(dir $@)
132 $(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -S -c $< -o $@
133
reed@android.com4cb8bd12009-01-16 16:15:37 +0000134# now build out objects
135OBJ_LIST := $(SRC_LIST:.cpp=.o)
136OBJ_LIST := $(addprefix out/, $(OBJ_LIST))
137
reed@android.com9781ca52009-04-14 14:28:22 +0000138# we want to compile these, but we don't actually link them
139JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o)
140JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS))
141
142out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS)
reed@android.com4cb8bd12009-01-16 16:15:37 +0000143 $(HIDE)$(AR) ru $@ $(OBJ_LIST)
144 $(HIDE)ranlib $@
145
reed@android.coma396a162009-02-28 18:26:14 +0000146##############################################################################
147
reed@android.com4d850592009-08-12 20:30:58 +0000148BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp \
reed@android.com7911e272010-04-15 16:34:54 +0000149 RepeatTileBench.cpp DecodeBench.cpp FPSBench.cpp
reed@android.com179d6162010-12-20 18:32:39 +0000150
reed@android.com4cb8bd12009-01-16 16:15:37 +0000151BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))
reed@android.com1b4c8152009-01-23 21:51:56 +0000152
reed@android.comfb210162009-01-23 21:24:39 +0000153# add any optional codecs for this app
reed@android.com3a859a02009-01-28 00:56:29 +0000154ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.comd6638e62009-04-08 05:03:52 +0000155 BENCH_SRCS += bench/TextBench.cpp
reed@android.com3a859a02009-01-28 00:56:29 +0000156else
reed@android.coma21ff6f2009-01-27 18:25:02 +0000157 BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp
reed@android.com1b4c8152009-01-23 21:51:56 +0000158endif
reed@android.comfb210162009-01-23 21:24:39 +0000159
reed@android.com4cb8bd12009-01-16 16:15:37 +0000160BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
161BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))
162
163bench: $(BENCH_OBJS) out/libskia.a
reed@android.com4c7d3d62009-01-21 03:15:13 +0000164 @echo "linking bench..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000165 $(HIDE)$(GPP) $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS)
reed@android.com4cb8bd12009-01-16 16:15:37 +0000166
reed@android.coma396a162009-02-28 18:26:14 +0000167##############################################################################
168
reed@android.com0650c6c2009-03-04 14:02:44 +0000169# we let tests cheat and see private headers, so we can unittest modules
170C_INCLUDES += -Isrc/core
171
reed@android.combbff1d52009-06-05 16:21:03 +0000172include tests/tests_files.mk
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +0000173ifeq ($(SKIA_PDF_SUPPORT),true)
174 SOURCE += PDFPrimitivesTest.cpp
175endif
reed@android.combbff1d52009-06-05 16:21:03 +0000176TESTS_SRCS := $(addprefix tests/, $(SOURCE))
reed@android.coma396a162009-02-28 18:26:14 +0000177
178TESTS_OBJS := $(TESTS_SRCS:.cpp=.o)
179TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS))
180
181tests: $(TESTS_OBJS) out/libskia.a
182 @echo "linking tests..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000183 $(HIDE)$(GPP) $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS)
reed@android.coma396a162009-02-28 18:26:14 +0000184
185##############################################################################
186
reed@android.comaf459792009-04-24 19:52:53 +0000187SKIMAGE_SRCS := skimage_main.cpp
188
189SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS))
190
191SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o)
192SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS))
193
194skimage: $(SKIMAGE_OBJS) out/libskia.a
195 @echo "linking skimage..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000196 $(HIDE)$(GPP) $(SKIMAGE_OBJS) out/libskia.a -o out/tools/skimage $(LINKER_OPTS)
reed@android.comaf459792009-04-24 19:52:53 +0000197
198##############################################################################
199
reed@android.com6413e792010-04-12 14:27:37 +0000200SKHELLO_SRCS := skhello.cpp
201
202SKHELLO_SRCS := $(addprefix tools/, $(SKHELLO_SRCS))
203
204SKHELLO_OBJS := $(SKHELLO_SRCS:.cpp=.o)
205SKHELLO_OBJS := $(addprefix out/, $(SKHELLO_OBJS))
206
207skhello: $(SKHELLO_OBJS) out/libskia.a
208 @echo "linking shkello..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000209 $(HIDE)$(GPP) $(SKHELLO_OBJS) out/libskia.a -o out/tools/skhello $(LINKER_OPTS)
reed@android.com6413e792010-04-12 14:27:37 +0000210
211##############################################################################
212
reed@android.com048522d2009-06-23 12:19:41 +0000213include gm/gm_files.mk
214GM_SRCS := $(addprefix gm/, $(SOURCE))
reed@android.comdd0ac282009-06-20 02:38:16 +0000215
senorblanco@chromium.org4aa910e2009-10-30 18:50:23 +0000216ifneq ($(SKIA_BUILD_FOR),mac)
217 GM_SRCS += src/images/SkImageDecoder_libpng.cpp
218endif
219
reed@android.comdd0ac282009-06-20 02:38:16 +0000220GM_OBJS := $(GM_SRCS:.cpp=.o)
221GM_OBJS := $(addprefix out/, $(GM_OBJS))
222
223gm: $(GM_OBJS) out/libskia.a
224 @echo "linking gm..."
reed@google.com37df17d2010-12-23 20:20:51 +0000225 $(HIDE)$(GPP) $(GM_OBJS) out/libskia.a -o out/gm/gm $(LINKER_OPTS)
reed@android.comdd0ac282009-06-20 02:38:16 +0000226
reed@google.com07700442010-12-20 19:46:07 +0000227SAMPLEPDF_SRCS := samplepdf.cpp
228
229SAMPLEPDF_SRCS := $(addprefix tools/, $(SAMPLEPDF_SRCS))
230
231SAMPLEPDF_OBJS := $(SAMPLEPDF_SRCS:.cpp=.o)
232SAMPLEPDF_OBJS := $(addprefix out/, $(SAMPLEPDF_OBJS))
233
234samplepdf: $(SAMPLEPDF_OBJS) out/libskia.a
235 @echo "linking samplepdf..."
236 $(HIDE)$(GPP) $(SAMPLEPDF_OBJS) out/libskia.a -o out/tools/samplepdf $(LINKER_OPTS)
237
reed@android.comdd0ac282009-06-20 02:38:16 +0000238##############################################################################
239
reed@android.comee0eb012009-06-23 17:13:30 +0000240.PHONY: all
reed@android.com6413e792010-04-12 14:27:37 +0000241all: $ bench gm skimage tests skhello
reed@android.comee0eb012009-06-23 17:13:30 +0000242
reed@android.com9db60872009-01-21 15:07:03 +0000243.PHONY: clean
reed@android.com4cb8bd12009-01-16 16:15:37 +0000244clean:
245 $(HIDE)rm -rf out
reed@android.com9db60872009-01-21 15:07:03 +0000246
247.PHONY: help
reed@android.com4c7d3d62009-01-21 03:15:13 +0000248help:
249 @echo "Targets:"
250 @echo " <default>: out/libskia.a"
251 @echo " bench: out/bench/bench"
reed@android.comdd0ac282009-06-20 02:38:16 +0000252 @echo " gm: out/gm/gm"
reed@android.comaf459792009-04-24 19:52:53 +0000253 @echo " skimage: out/tools/skimage"
reed@android.com6413e792010-04-12 14:27:37 +0000254 @echo " skhello: out/tools/skhello"
reed@android.coma396a162009-02-28 18:26:14 +0000255 @echo " tests: out/tests/tests"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000256 @echo " clean: removes entire out/ directory"
257 @echo " help: this text"
reed@android.com9db60872009-01-21 15:07:03 +0000258 @echo "Options: (after make, or in bash shell)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000259 @echo " SKIA_DEBUG=true for debug build"
reed@android.com9db60872009-01-21 15:07:03 +0000260 @echo " SKIA_SCALAR=fixed for fixed-point build"
261 @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)"
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +0000262 @echo " SKIA_PDF_SUPPORT=true to enable the pdf generation backend"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000263 @echo ""