blob: 106a6206f3bfdd71950f857950c966c38ebad534 [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
reed@android.com4c7d3d62009-01-21 03:15:13 +00007LINKER_OPTS := -lpthread
8DEFINES := -DSK_CAN_USE_FLOAT
reed@android.com4cb8bd12009-01-16 16:15:37 +00009HIDE = @
10
reed@android.com9db60872009-01-21 15:07:03 +000011ifeq ($(SKIA_SCALAR),fixed)
reed@android.com4c7d3d62009-01-21 03:15:13 +000012 DEFINES += -DSK_SCALAR_IS_FIXED
13else
14 DEFINES += -DSK_SCALAR_IS_FLOAT
15endif
16
17ifeq ($(SKIA_DEBUG),true)
18 DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT
19else
20 DEFINES += -DSK_RELEASE
21endif
reed@android.com4cb8bd12009-01-16 16:15:37 +000022
reed@android.comf5493692009-07-22 19:21:01 +000023DEFINES += -DSK_SUPPORT_LCDTEXT
24
reed@android.com4cb8bd12009-01-16 16:15:37 +000025# start with the core (required)
26include src/core/core_files.mk
27SRC_LIST := $(addprefix src/core/, $(SOURCE))
28
reed@android.comed7bd9b2009-07-30 02:25:54 +000029# add the opts (optimizations)
30include src/opts/opts_files.mk
31SRC_LIST += $(addprefix src/opts/, $(SOURCE))
32
reed@android.com4cb8bd12009-01-16 16:15:37 +000033# we usually need ports
34include src/ports/ports_files.mk
35SRC_LIST += $(addprefix src/ports/, $(SOURCE))
36
37# do we want effects?
38include src/effects/effects_files.mk
39SRC_LIST += $(addprefix src/effects/, $(SOURCE))
40
reed@android.com4c7d3d62009-01-21 03:15:13 +000041# core image files
42include src/images/images_files.mk
43SRC_LIST += $(addprefix src/images/, $(SOURCE))
44
reed@android.com9781ca52009-04-14 14:28:22 +000045# core util files
46include src/utils/utils_files.mk
47SRC_LIST += $(addprefix src/utils/, $(SOURCE))
48
49# extra files we want to build to prevent bit-rot, but not link
50JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp
51
reed@android.com4c7d3d62009-01-21 03:15:13 +000052# conditional files based on our platform
reed@android.com9db60872009-01-21 15:07:03 +000053ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.com4c7d3d62009-01-21 03:15:13 +000054 LINKER_OPTS += -framework Carbon
55 DEFINES += -DSK_BUILD_FOR_MAC
56
57 C_INCLUDES += -Iinclude/utils/mac
58 SRC_LIST += src/ports/SkImageDecoder_CG.cpp
59 SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
reed@android.com3a859a02009-01-28 00:56:29 +000060 SRC_LIST += src/ports/SkFontHost_mac.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000061else
reed@android.comf2afb672009-09-28 16:12:48 +000062 LINKER_OPTS += -lpng -lfreetype
reed@android.com4c7d3d62009-01-21 03:15:13 +000063 DEFINES += -DSK_BUILD_FOR_UNIX
64
reed@android.comf2afb672009-09-28 16:12:48 +000065 # needed for freetype support
66 C_INCLUDES += -I/usr/include/freetype2
67 SRC_LIST += src/ports/SkFontHost_linux.cpp
68 SRC_LIST += src/ports/SkFontHost_gamma_none.cpp
69 SRC_LIST += src/ports/SkFontHost_FreeType.cpp
70 SRC_LIST += src/ports/SkFontHost_FreeType_Subpixel.cpp
71 SRC_LIST += src/utils/SkOSFile.cpp
reed@android.com7b830a12009-01-22 13:41:08 +000072 # these are our registry-based factories
73 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
74 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
reed@android.com7b830a12009-01-22 13:41:08 +000075 # support files
76 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000077endif
78
reed@android.com4cb8bd12009-01-16 16:15:37 +000079out/%.o : %.cpp
80 @mkdir -p $(dir $@)
81 $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
82 @echo "compiling $@"
83
84# now build out objects
85OBJ_LIST := $(SRC_LIST:.cpp=.o)
86OBJ_LIST := $(addprefix out/, $(OBJ_LIST))
87
reed@android.com9781ca52009-04-14 14:28:22 +000088# we want to compile these, but we don't actually link them
89JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o)
90JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS))
91
92out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS)
reed@android.com4cb8bd12009-01-16 16:15:37 +000093 $(HIDE)$(AR) ru $@ $(OBJ_LIST)
94 $(HIDE)ranlib $@
95
reed@android.coma396a162009-02-28 18:26:14 +000096##############################################################################
97
reed@android.com4d850592009-08-12 20:30:58 +000098BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp \
reed@android.com34e85802009-09-02 21:11:44 +000099 RepeatTileBench.cpp DecodeBench.cpp
reed@android.com4cb8bd12009-01-16 16:15:37 +0000100BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))
reed@android.com1b4c8152009-01-23 21:51:56 +0000101
reed@android.comfb210162009-01-23 21:24:39 +0000102# add any optional codecs for this app
reed@android.com3a859a02009-01-28 00:56:29 +0000103ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.comd6638e62009-04-08 05:03:52 +0000104 BENCH_SRCS += bench/TextBench.cpp
reed@android.com3a859a02009-01-28 00:56:29 +0000105else
reed@android.coma21ff6f2009-01-27 18:25:02 +0000106 BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp
reed@android.com1b4c8152009-01-23 21:51:56 +0000107endif
reed@android.comfb210162009-01-23 21:24:39 +0000108
reed@android.com4cb8bd12009-01-16 16:15:37 +0000109BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
110BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))
111
112bench: $(BENCH_OBJS) out/libskia.a
reed@android.com4c7d3d62009-01-21 03:15:13 +0000113 @echo "linking bench..."
114 $(HIDE)g++ $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS)
reed@android.com4cb8bd12009-01-16 16:15:37 +0000115
reed@android.coma396a162009-02-28 18:26:14 +0000116##############################################################################
117
reed@android.com0650c6c2009-03-04 14:02:44 +0000118# we let tests cheat and see private headers, so we can unittest modules
119C_INCLUDES += -Isrc/core
120
reed@android.combbff1d52009-06-05 16:21:03 +0000121include tests/tests_files.mk
122TESTS_SRCS := $(addprefix tests/, $(SOURCE))
reed@android.coma396a162009-02-28 18:26:14 +0000123
124TESTS_OBJS := $(TESTS_SRCS:.cpp=.o)
125TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS))
126
127tests: $(TESTS_OBJS) out/libskia.a
128 @echo "linking tests..."
129 $(HIDE)g++ $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS)
130
131##############################################################################
132
reed@android.comaf459792009-04-24 19:52:53 +0000133SKIMAGE_SRCS := skimage_main.cpp
134
135SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS))
136
137SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o)
138SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS))
139
140skimage: $(SKIMAGE_OBJS) out/libskia.a
141 @echo "linking skimage..."
142 $(HIDE)g++ $(SKIMAGE_OBJS) out/libskia.a -o out/tools/skimage $(LINKER_OPTS)
143
144##############################################################################
145
reed@android.com048522d2009-06-23 12:19:41 +0000146include gm/gm_files.mk
147GM_SRCS := $(addprefix gm/, $(SOURCE))
reed@android.comdd0ac282009-06-20 02:38:16 +0000148
149GM_OBJS := $(GM_SRCS:.cpp=.o)
150GM_OBJS := $(addprefix out/, $(GM_OBJS))
151
152gm: $(GM_OBJS) out/libskia.a
153 @echo "linking gm..."
154 $(HIDE)g++ $(GM_OBJS) out/libskia.a -o out/gm/gm $(LINKER_OPTS)
155
156##############################################################################
157
reed@android.comee0eb012009-06-23 17:13:30 +0000158.PHONY: all
159all: $ bench gm skimage tests
160
reed@android.com9db60872009-01-21 15:07:03 +0000161.PHONY: clean
reed@android.com4cb8bd12009-01-16 16:15:37 +0000162clean:
163 $(HIDE)rm -rf out
reed@android.com9db60872009-01-21 15:07:03 +0000164
165.PHONY: help
reed@android.com4c7d3d62009-01-21 03:15:13 +0000166help:
167 @echo "Targets:"
168 @echo " <default>: out/libskia.a"
169 @echo " bench: out/bench/bench"
reed@android.comdd0ac282009-06-20 02:38:16 +0000170 @echo " gm: out/gm/gm"
reed@android.comaf459792009-04-24 19:52:53 +0000171 @echo " skimage: out/tools/skimage"
reed@android.coma396a162009-02-28 18:26:14 +0000172 @echo " tests: out/tests/tests"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000173 @echo " clean: removes entire out/ directory"
174 @echo " help: this text"
reed@android.com9db60872009-01-21 15:07:03 +0000175 @echo "Options: (after make, or in bash shell)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000176 @echo " SKIA_DEBUG=true for debug build"
reed@android.com9db60872009-01-21 15:07:03 +0000177 @echo " SKIA_SCALAR=fixed for fixed-point build"
178 @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000179 @echo ""