blob: 65f0b715b460e842458d6f7a4718ab6ab6102200 [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@android.comc4d40902009-04-08 18:05:24 +00006C_INCLUDES := -Iinclude/config -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/utils
reed@android.comf2afb672009-09-28 16:12:48 +00007CFLAGS := -Wall -g # -O2
senorblanco@chromium.org4e753552009-11-16 21:09:00 +00008CFLAGS_SSE2 = $(CFLAGS) -msse2
reed@android.com4c7d3d62009-01-21 03:15:13 +00009LINKER_OPTS := -lpthread
10DEFINES := -DSK_CAN_USE_FLOAT
reed@android.com4cb8bd12009-01-16 16:15:37 +000011HIDE = @
12
reed@android.com9db60872009-01-21 15:07:03 +000013ifeq ($(SKIA_SCALAR),fixed)
reed@android.com4c7d3d62009-01-21 03:15:13 +000014 DEFINES += -DSK_SCALAR_IS_FIXED
15else
16 DEFINES += -DSK_SCALAR_IS_FLOAT
17endif
18
19ifeq ($(SKIA_DEBUG),true)
20 DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT
21else
22 DEFINES += -DSK_RELEASE
23endif
reed@android.com4cb8bd12009-01-16 16:15:37 +000024
reed@android.comf5493692009-07-22 19:21:01 +000025DEFINES += -DSK_SUPPORT_LCDTEXT
26
reed@android.com4cb8bd12009-01-16 16:15:37 +000027# start with the core (required)
28include src/core/core_files.mk
29SRC_LIST := $(addprefix src/core/, $(SOURCE))
30
reed@android.comed7bd9b2009-07-30 02:25:54 +000031# add the opts (optimizations)
32include src/opts/opts_files.mk
33SRC_LIST += $(addprefix src/opts/, $(SOURCE))
34
reed@android.com4cb8bd12009-01-16 16:15:37 +000035# we usually need ports
36include src/ports/ports_files.mk
37SRC_LIST += $(addprefix src/ports/, $(SOURCE))
38
39# do we want effects?
40include src/effects/effects_files.mk
41SRC_LIST += $(addprefix src/effects/, $(SOURCE))
42
reed@android.com4c7d3d62009-01-21 03:15:13 +000043# core image files
44include src/images/images_files.mk
45SRC_LIST += $(addprefix src/images/, $(SOURCE))
46
reed@android.com9781ca52009-04-14 14:28:22 +000047# core util files
48include src/utils/utils_files.mk
49SRC_LIST += $(addprefix src/utils/, $(SOURCE))
50
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +000051# pdf backend files
52ifeq ($(SKIA_PDF_SUPPORT),true)
53 C_INCLUDES += -Iinclude/pdf
54 include src/pdf/pdf_files.mk
55 SRC_LIST += $(addprefix src/pdf/, $(SOURCE))
56endif
57
reed@android.com9781ca52009-04-14 14:28:22 +000058# extra files we want to build to prevent bit-rot, but not link
59JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp
60
reed@android.com4c7d3d62009-01-21 03:15:13 +000061# conditional files based on our platform
reed@android.com9db60872009-01-21 15:07:03 +000062ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.comcf4ac252010-05-12 17:25:30 +000063 # make it work with 10.4 for our font port
64 GPP := g++-4.0
65 SDK := /Developer/SDKs/MacOSX10.4u.sdk
66 SDK_OPTS := -isysroot $(SDK) -mmacosx-version-min=10.4
67 CC := gcc-4.0 $(SDK_OPTS)
68
reed@android.com4c7d3d62009-01-21 03:15:13 +000069 LINKER_OPTS += -framework Carbon
70 DEFINES += -DSK_BUILD_FOR_MAC
71
72 C_INCLUDES += -Iinclude/utils/mac
73 SRC_LIST += src/ports/SkImageDecoder_CG.cpp
74 SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
reed@android.com3a859a02009-01-28 00:56:29 +000075 SRC_LIST += src/ports/SkFontHost_mac.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000076else
reed@android.comf2afb672009-09-28 16:12:48 +000077 LINKER_OPTS += -lpng -lfreetype
reed@android.comdfee5792010-04-15 14:24:50 +000078 DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG
reed@android.com4c7d3d62009-01-21 03:15:13 +000079
reed@android.comf2afb672009-09-28 16:12:48 +000080 # needed for freetype support
81 C_INCLUDES += -I/usr/include/freetype2
82 SRC_LIST += src/ports/SkFontHost_linux.cpp
83 SRC_LIST += src/ports/SkFontHost_gamma_none.cpp
84 SRC_LIST += src/ports/SkFontHost_FreeType.cpp
85 SRC_LIST += src/ports/SkFontHost_FreeType_Subpixel.cpp
86 SRC_LIST += src/utils/SkOSFile.cpp
reed@android.com7b830a12009-01-22 13:41:08 +000087 # these are our registry-based factories
88 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
89 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
reed@android.comfd9714e2010-04-15 14:28:24 +000090 SRC_LIST += src/images/SkImageDecoder_libpng.cpp
reed@android.com7b830a12009-01-22 13:41:08 +000091 # support files
92 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000093endif
94
senorblanco@chromium.org4e753552009-11-16 21:09:00 +000095# For these files, and these files only, compile with -msse2.
96SSE2_OBJS := out/src/opts/SkBlitRow_opts_SSE2.o \
97 out/src/opts/SkUtils_opts_SSE2.o
98$(SSE2_OBJS) : CFLAGS := $(CFLAGS_SSE2)
99
reed@android.com4cb8bd12009-01-16 16:15:37 +0000100out/%.o : %.cpp
101 @mkdir -p $(dir $@)
102 $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
103 @echo "compiling $@"
104
senorblanco@chromium.org4aa910e2009-10-30 18:50:23 +0000105%.s : %.cpp
106 @mkdir -p $(dir $@)
107 $(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -S -c $< -o $@
108
reed@android.com4cb8bd12009-01-16 16:15:37 +0000109# now build out objects
110OBJ_LIST := $(SRC_LIST:.cpp=.o)
111OBJ_LIST := $(addprefix out/, $(OBJ_LIST))
112
reed@android.com9781ca52009-04-14 14:28:22 +0000113# we want to compile these, but we don't actually link them
114JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o)
115JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS))
116
117out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS)
reed@android.com4cb8bd12009-01-16 16:15:37 +0000118 $(HIDE)$(AR) ru $@ $(OBJ_LIST)
119 $(HIDE)ranlib $@
120
reed@android.coma396a162009-02-28 18:26:14 +0000121##############################################################################
122
reed@android.com4d850592009-08-12 20:30:58 +0000123BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp \
reed@android.com7911e272010-04-15 16:34:54 +0000124 RepeatTileBench.cpp DecodeBench.cpp FPSBench.cpp
reed@android.com4cb8bd12009-01-16 16:15:37 +0000125BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))
reed@android.com1b4c8152009-01-23 21:51:56 +0000126
reed@android.comfb210162009-01-23 21:24:39 +0000127# add any optional codecs for this app
reed@android.com3a859a02009-01-28 00:56:29 +0000128ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.comd6638e62009-04-08 05:03:52 +0000129 BENCH_SRCS += bench/TextBench.cpp
reed@android.com3a859a02009-01-28 00:56:29 +0000130else
reed@android.coma21ff6f2009-01-27 18:25:02 +0000131 BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp
reed@android.com1b4c8152009-01-23 21:51:56 +0000132endif
reed@android.comfb210162009-01-23 21:24:39 +0000133
reed@android.com4cb8bd12009-01-16 16:15:37 +0000134BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
135BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))
136
137bench: $(BENCH_OBJS) out/libskia.a
reed@android.com4c7d3d62009-01-21 03:15:13 +0000138 @echo "linking bench..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000139 $(HIDE)$(GPP) $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS)
reed@android.com4cb8bd12009-01-16 16:15:37 +0000140
reed@android.coma396a162009-02-28 18:26:14 +0000141##############################################################################
142
reed@android.com0650c6c2009-03-04 14:02:44 +0000143# we let tests cheat and see private headers, so we can unittest modules
144C_INCLUDES += -Isrc/core
145
reed@android.combbff1d52009-06-05 16:21:03 +0000146include tests/tests_files.mk
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +0000147ifeq ($(SKIA_PDF_SUPPORT),true)
148 SOURCE += PDFPrimitivesTest.cpp
149endif
reed@android.combbff1d52009-06-05 16:21:03 +0000150TESTS_SRCS := $(addprefix tests/, $(SOURCE))
reed@android.coma396a162009-02-28 18:26:14 +0000151
152TESTS_OBJS := $(TESTS_SRCS:.cpp=.o)
153TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS))
154
155tests: $(TESTS_OBJS) out/libskia.a
156 @echo "linking tests..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000157 $(HIDE)$(GPP) $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS)
reed@android.coma396a162009-02-28 18:26:14 +0000158
159##############################################################################
160
reed@android.comaf459792009-04-24 19:52:53 +0000161SKIMAGE_SRCS := skimage_main.cpp
162
163SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS))
164
165SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o)
166SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS))
167
168skimage: $(SKIMAGE_OBJS) out/libskia.a
169 @echo "linking skimage..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000170 $(HIDE)$(GPP) $(SKIMAGE_OBJS) out/libskia.a -o out/tools/skimage $(LINKER_OPTS)
reed@android.comaf459792009-04-24 19:52:53 +0000171
172##############################################################################
173
reed@android.com6413e792010-04-12 14:27:37 +0000174SKHELLO_SRCS := skhello.cpp
175
176SKHELLO_SRCS := $(addprefix tools/, $(SKHELLO_SRCS))
177
178SKHELLO_OBJS := $(SKHELLO_SRCS:.cpp=.o)
179SKHELLO_OBJS := $(addprefix out/, $(SKHELLO_OBJS))
180
181skhello: $(SKHELLO_OBJS) out/libskia.a
182 @echo "linking shkello..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000183 $(HIDE)$(GPP) $(SKHELLO_OBJS) out/libskia.a -o out/tools/skhello $(LINKER_OPTS)
reed@android.com6413e792010-04-12 14:27:37 +0000184
185##############################################################################
186
reed@android.com048522d2009-06-23 12:19:41 +0000187include gm/gm_files.mk
188GM_SRCS := $(addprefix gm/, $(SOURCE))
reed@android.comdd0ac282009-06-20 02:38:16 +0000189
senorblanco@chromium.org4aa910e2009-10-30 18:50:23 +0000190ifneq ($(SKIA_BUILD_FOR),mac)
191 GM_SRCS += src/images/SkImageDecoder_libpng.cpp
192endif
193
reed@android.comdd0ac282009-06-20 02:38:16 +0000194GM_OBJS := $(GM_SRCS:.cpp=.o)
195GM_OBJS := $(addprefix out/, $(GM_OBJS))
196
197gm: $(GM_OBJS) out/libskia.a
198 @echo "linking gm..."
reed@android.comcf4ac252010-05-12 17:25:30 +0000199 $(HIDE)$(GPP) $(GM_OBJS) out/libskia.a -o out/gm/gm $(LINKER_OPTS)
reed@android.comdd0ac282009-06-20 02:38:16 +0000200
201##############################################################################
202
reed@android.comee0eb012009-06-23 17:13:30 +0000203.PHONY: all
reed@android.com6413e792010-04-12 14:27:37 +0000204all: $ bench gm skimage tests skhello
reed@android.comee0eb012009-06-23 17:13:30 +0000205
reed@android.com9db60872009-01-21 15:07:03 +0000206.PHONY: clean
reed@android.com4cb8bd12009-01-16 16:15:37 +0000207clean:
208 $(HIDE)rm -rf out
reed@android.com9db60872009-01-21 15:07:03 +0000209
210.PHONY: help
reed@android.com4c7d3d62009-01-21 03:15:13 +0000211help:
212 @echo "Targets:"
213 @echo " <default>: out/libskia.a"
214 @echo " bench: out/bench/bench"
reed@android.comdd0ac282009-06-20 02:38:16 +0000215 @echo " gm: out/gm/gm"
reed@android.comaf459792009-04-24 19:52:53 +0000216 @echo " skimage: out/tools/skimage"
reed@android.com6413e792010-04-12 14:27:37 +0000217 @echo " skhello: out/tools/skhello"
reed@android.coma396a162009-02-28 18:26:14 +0000218 @echo " tests: out/tests/tests"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000219 @echo " clean: removes entire out/ directory"
220 @echo " help: this text"
reed@android.com9db60872009-01-21 15:07:03 +0000221 @echo "Options: (after make, or in bash shell)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000222 @echo " SKIA_DEBUG=true for debug build"
reed@android.com9db60872009-01-21 15:07:03 +0000223 @echo " SKIA_SCALAR=fixed for fixed-point build"
224 @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)"
vandebo@chromium.org8459d4e2010-09-24 22:25:30 +0000225 @echo " SKIA_PDF_SUPPORT=true to enable the pdf generation backend"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000226 @echo ""