blob: aebe467b2cf5852b43dab42926a83ce97fde477f [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.comc4d40902009-04-08 18:05:24 +00005C_INCLUDES := -Iinclude/config -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/utils
reed@android.comf2afb672009-09-28 16:12:48 +00006CFLAGS := -Wall -g # -O2
senorblanco@chromium.org4e753552009-11-16 21:09:00 +00007CFLAGS_SSE2 = $(CFLAGS) -msse2
reed@android.com4c7d3d62009-01-21 03:15:13 +00008LINKER_OPTS := -lpthread
9DEFINES := -DSK_CAN_USE_FLOAT
reed@android.com4cb8bd12009-01-16 16:15:37 +000010HIDE = @
11
reed@android.com9db60872009-01-21 15:07:03 +000012ifeq ($(SKIA_SCALAR),fixed)
reed@android.com4c7d3d62009-01-21 03:15:13 +000013 DEFINES += -DSK_SCALAR_IS_FIXED
14else
15 DEFINES += -DSK_SCALAR_IS_FLOAT
16endif
17
18ifeq ($(SKIA_DEBUG),true)
19 DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT
20else
21 DEFINES += -DSK_RELEASE
22endif
reed@android.com4cb8bd12009-01-16 16:15:37 +000023
reed@android.comf5493692009-07-22 19:21:01 +000024DEFINES += -DSK_SUPPORT_LCDTEXT
25
reed@android.com4cb8bd12009-01-16 16:15:37 +000026# start with the core (required)
27include src/core/core_files.mk
28SRC_LIST := $(addprefix src/core/, $(SOURCE))
29
reed@android.comed7bd9b2009-07-30 02:25:54 +000030# add the opts (optimizations)
31include src/opts/opts_files.mk
32SRC_LIST += $(addprefix src/opts/, $(SOURCE))
33
reed@android.com4cb8bd12009-01-16 16:15:37 +000034# we usually need ports
35include src/ports/ports_files.mk
36SRC_LIST += $(addprefix src/ports/, $(SOURCE))
37
38# do we want effects?
39include src/effects/effects_files.mk
40SRC_LIST += $(addprefix src/effects/, $(SOURCE))
41
reed@android.com4c7d3d62009-01-21 03:15:13 +000042# core image files
43include src/images/images_files.mk
44SRC_LIST += $(addprefix src/images/, $(SOURCE))
45
reed@android.com9781ca52009-04-14 14:28:22 +000046# core util files
47include src/utils/utils_files.mk
48SRC_LIST += $(addprefix src/utils/, $(SOURCE))
49
50# extra files we want to build to prevent bit-rot, but not link
51JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp
52
reed@android.com4c7d3d62009-01-21 03:15:13 +000053# conditional files based on our platform
reed@android.com9db60872009-01-21 15:07:03 +000054ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.com4c7d3d62009-01-21 03:15:13 +000055 LINKER_OPTS += -framework Carbon
56 DEFINES += -DSK_BUILD_FOR_MAC
57
58 C_INCLUDES += -Iinclude/utils/mac
59 SRC_LIST += src/ports/SkImageDecoder_CG.cpp
60 SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
reed@android.com3a859a02009-01-28 00:56:29 +000061 SRC_LIST += src/ports/SkFontHost_mac.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000062else
reed@android.comf2afb672009-09-28 16:12:48 +000063 LINKER_OPTS += -lpng -lfreetype
reed@android.comdfee5792010-04-15 14:24:50 +000064 DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG
reed@android.com4c7d3d62009-01-21 03:15:13 +000065
reed@android.comf2afb672009-09-28 16:12:48 +000066 # needed for freetype support
67 C_INCLUDES += -I/usr/include/freetype2
68 SRC_LIST += src/ports/SkFontHost_linux.cpp
69 SRC_LIST += src/ports/SkFontHost_gamma_none.cpp
70 SRC_LIST += src/ports/SkFontHost_FreeType.cpp
71 SRC_LIST += src/ports/SkFontHost_FreeType_Subpixel.cpp
72 SRC_LIST += src/utils/SkOSFile.cpp
reed@android.com7b830a12009-01-22 13:41:08 +000073 # these are our registry-based factories
74 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
75 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
reed@android.comfd9714e2010-04-15 14:28:24 +000076 SRC_LIST += src/images/SkImageDecoder_libpng.cpp
reed@android.com7b830a12009-01-22 13:41:08 +000077 # support files
78 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000079endif
80
senorblanco@chromium.org4e753552009-11-16 21:09:00 +000081# For these files, and these files only, compile with -msse2.
82SSE2_OBJS := out/src/opts/SkBlitRow_opts_SSE2.o \
83 out/src/opts/SkUtils_opts_SSE2.o
84$(SSE2_OBJS) : CFLAGS := $(CFLAGS_SSE2)
85
reed@android.com4cb8bd12009-01-16 16:15:37 +000086out/%.o : %.cpp
87 @mkdir -p $(dir $@)
88 $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
89 @echo "compiling $@"
90
senorblanco@chromium.org4aa910e2009-10-30 18:50:23 +000091%.s : %.cpp
92 @mkdir -p $(dir $@)
93 $(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -S -c $< -o $@
94
reed@android.com4cb8bd12009-01-16 16:15:37 +000095# now build out objects
96OBJ_LIST := $(SRC_LIST:.cpp=.o)
97OBJ_LIST := $(addprefix out/, $(OBJ_LIST))
98
reed@android.com9781ca52009-04-14 14:28:22 +000099# we want to compile these, but we don't actually link them
100JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o)
101JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS))
102
103out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS)
reed@android.com4cb8bd12009-01-16 16:15:37 +0000104 $(HIDE)$(AR) ru $@ $(OBJ_LIST)
105 $(HIDE)ranlib $@
106
reed@android.coma396a162009-02-28 18:26:14 +0000107##############################################################################
108
reed@android.com4d850592009-08-12 20:30:58 +0000109BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp \
reed@android.com34e85802009-09-02 21:11:44 +0000110 RepeatTileBench.cpp DecodeBench.cpp
reed@android.com4cb8bd12009-01-16 16:15:37 +0000111BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))
reed@android.com1b4c8152009-01-23 21:51:56 +0000112
reed@android.comfb210162009-01-23 21:24:39 +0000113# add any optional codecs for this app
reed@android.com3a859a02009-01-28 00:56:29 +0000114ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.comd6638e62009-04-08 05:03:52 +0000115 BENCH_SRCS += bench/TextBench.cpp
reed@android.com3a859a02009-01-28 00:56:29 +0000116else
reed@android.coma21ff6f2009-01-27 18:25:02 +0000117 BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp
reed@android.com1b4c8152009-01-23 21:51:56 +0000118endif
reed@android.comfb210162009-01-23 21:24:39 +0000119
reed@android.com4cb8bd12009-01-16 16:15:37 +0000120BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
121BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))
122
123bench: $(BENCH_OBJS) out/libskia.a
reed@android.com4c7d3d62009-01-21 03:15:13 +0000124 @echo "linking bench..."
125 $(HIDE)g++ $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS)
reed@android.com4cb8bd12009-01-16 16:15:37 +0000126
reed@android.coma396a162009-02-28 18:26:14 +0000127##############################################################################
128
reed@android.com0650c6c2009-03-04 14:02:44 +0000129# we let tests cheat and see private headers, so we can unittest modules
130C_INCLUDES += -Isrc/core
131
reed@android.combbff1d52009-06-05 16:21:03 +0000132include tests/tests_files.mk
133TESTS_SRCS := $(addprefix tests/, $(SOURCE))
reed@android.coma396a162009-02-28 18:26:14 +0000134
135TESTS_OBJS := $(TESTS_SRCS:.cpp=.o)
136TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS))
137
138tests: $(TESTS_OBJS) out/libskia.a
139 @echo "linking tests..."
140 $(HIDE)g++ $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS)
141
142##############################################################################
143
reed@android.comaf459792009-04-24 19:52:53 +0000144SKIMAGE_SRCS := skimage_main.cpp
145
146SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS))
147
148SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o)
149SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS))
150
151skimage: $(SKIMAGE_OBJS) out/libskia.a
152 @echo "linking skimage..."
153 $(HIDE)g++ $(SKIMAGE_OBJS) out/libskia.a -o out/tools/skimage $(LINKER_OPTS)
154
155##############################################################################
156
reed@android.com6413e792010-04-12 14:27:37 +0000157SKHELLO_SRCS := skhello.cpp
158
159SKHELLO_SRCS := $(addprefix tools/, $(SKHELLO_SRCS))
160
161SKHELLO_OBJS := $(SKHELLO_SRCS:.cpp=.o)
162SKHELLO_OBJS := $(addprefix out/, $(SKHELLO_OBJS))
163
164skhello: $(SKHELLO_OBJS) out/libskia.a
165 @echo "linking shkello..."
166 $(HIDE)g++ $(SKHELLO_OBJS) out/libskia.a -o out/tools/skhello $(LINKER_OPTS)
167
168##############################################################################
169
reed@android.com048522d2009-06-23 12:19:41 +0000170include gm/gm_files.mk
171GM_SRCS := $(addprefix gm/, $(SOURCE))
reed@android.comdd0ac282009-06-20 02:38:16 +0000172
senorblanco@chromium.org4aa910e2009-10-30 18:50:23 +0000173ifneq ($(SKIA_BUILD_FOR),mac)
174 GM_SRCS += src/images/SkImageDecoder_libpng.cpp
175endif
176
reed@android.comdd0ac282009-06-20 02:38:16 +0000177GM_OBJS := $(GM_SRCS:.cpp=.o)
178GM_OBJS := $(addprefix out/, $(GM_OBJS))
179
180gm: $(GM_OBJS) out/libskia.a
181 @echo "linking gm..."
182 $(HIDE)g++ $(GM_OBJS) out/libskia.a -o out/gm/gm $(LINKER_OPTS)
183
184##############################################################################
185
reed@android.comee0eb012009-06-23 17:13:30 +0000186.PHONY: all
reed@android.com6413e792010-04-12 14:27:37 +0000187all: $ bench gm skimage tests skhello
reed@android.comee0eb012009-06-23 17:13:30 +0000188
reed@android.com9db60872009-01-21 15:07:03 +0000189.PHONY: clean
reed@android.com4cb8bd12009-01-16 16:15:37 +0000190clean:
191 $(HIDE)rm -rf out
reed@android.com9db60872009-01-21 15:07:03 +0000192
193.PHONY: help
reed@android.com4c7d3d62009-01-21 03:15:13 +0000194help:
195 @echo "Targets:"
196 @echo " <default>: out/libskia.a"
197 @echo " bench: out/bench/bench"
reed@android.comdd0ac282009-06-20 02:38:16 +0000198 @echo " gm: out/gm/gm"
reed@android.comaf459792009-04-24 19:52:53 +0000199 @echo " skimage: out/tools/skimage"
reed@android.com6413e792010-04-12 14:27:37 +0000200 @echo " skhello: out/tools/skhello"
reed@android.coma396a162009-02-28 18:26:14 +0000201 @echo " tests: out/tests/tests"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000202 @echo " clean: removes entire out/ directory"
203 @echo " help: this text"
reed@android.com9db60872009-01-21 15:07:03 +0000204 @echo "Options: (after make, or in bash shell)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000205 @echo " SKIA_DEBUG=true for debug build"
reed@android.com9db60872009-01-21 15:07:03 +0000206 @echo " SKIA_SCALAR=fixed for fixed-point build"
207 @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000208 @echo ""