blob: d687e15f4fb27c21e73992d5ba594a14577c681d [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.com4cb8bd12009-01-16 16:15:37 +00005C_INCLUDES := -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/utils
reed@android.com4c7d3d62009-01-21 03:15:13 +00006CFLAGS := -O2
7LINKER_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
23# start with the core (required)
24include src/core/core_files.mk
25SRC_LIST := $(addprefix src/core/, $(SOURCE))
26
27# we usually need ports
28include src/ports/ports_files.mk
29SRC_LIST += $(addprefix src/ports/, $(SOURCE))
30
31# do we want effects?
32include src/effects/effects_files.mk
33SRC_LIST += $(addprefix src/effects/, $(SOURCE))
34
reed@android.com4c7d3d62009-01-21 03:15:13 +000035# core image files
36include src/images/images_files.mk
37SRC_LIST += $(addprefix src/images/, $(SOURCE))
38
39# conditional files based on our platform
reed@android.com9db60872009-01-21 15:07:03 +000040ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.com4c7d3d62009-01-21 03:15:13 +000041 LINKER_OPTS += -framework Carbon
42 DEFINES += -DSK_BUILD_FOR_MAC
43
44 C_INCLUDES += -Iinclude/utils/mac
45 SRC_LIST += src/ports/SkImageDecoder_CG.cpp
46 SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
reed@android.com3a859a02009-01-28 00:56:29 +000047 SRC_LIST += src/ports/SkFontHost_mac.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000048else
reed@android.comfb210162009-01-23 21:24:39 +000049 LINKER_OPTS += -lpng
reed@android.com4c7d3d62009-01-21 03:15:13 +000050 DEFINES += -DSK_BUILD_FOR_UNIX
51
reed@android.com7b830a12009-01-22 13:41:08 +000052 # these are our registry-based factories
53 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
54 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
reed@android.com7b830a12009-01-22 13:41:08 +000055 # support files
56 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000057endif
58
reed@android.com4cb8bd12009-01-16 16:15:37 +000059out/%.o : %.cpp
60 @mkdir -p $(dir $@)
61 $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
62 @echo "compiling $@"
63
64# now build out objects
65OBJ_LIST := $(SRC_LIST:.cpp=.o)
66OBJ_LIST := $(addprefix out/, $(OBJ_LIST))
67
68out/libskia.a: Makefile $(OBJ_LIST)
69 $(HIDE)$(AR) ru $@ $(OBJ_LIST)
70 $(HIDE)ranlib $@
71
reed@android.coma396a162009-02-28 18:26:14 +000072##############################################################################
73
reed@android.comf523e252009-01-26 23:15:37 +000074BENCH_SRCS := RectBench.cpp SkBenchmark.cpp main.cpp BitmapBench.cpp
reed@android.com4cb8bd12009-01-16 16:15:37 +000075BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))
reed@android.com1b4c8152009-01-23 21:51:56 +000076
reed@android.comfb210162009-01-23 21:24:39 +000077# add any optional codecs for this app
reed@android.com3a859a02009-01-28 00:56:29 +000078ifeq ($(SKIA_BUILD_FOR),mac)
79# BENCH_SRCS += bench/TextBench.cpp
80else
reed@android.coma21ff6f2009-01-27 18:25:02 +000081 BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp
reed@android.com1b4c8152009-01-23 21:51:56 +000082endif
reed@android.comfb210162009-01-23 21:24:39 +000083
reed@android.com4cb8bd12009-01-16 16:15:37 +000084BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
85BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))
86
87bench: $(BENCH_OBJS) out/libskia.a
reed@android.com4c7d3d62009-01-21 03:15:13 +000088 @echo "linking bench..."
89 $(HIDE)g++ $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS)
reed@android.com4cb8bd12009-01-16 16:15:37 +000090
reed@android.coma396a162009-02-28 18:26:14 +000091##############################################################################
92
reed@android.com0650c6c2009-03-04 14:02:44 +000093# we let tests cheat and see private headers, so we can unittest modules
94C_INCLUDES += -Isrc/core
95
reed@android.coma396a162009-02-28 18:26:14 +000096TESTS_SRCS := GeometryTest.cpp MathTest.cpp MatrixTest.cpp PackBitsTest.cpp \
reed@android.com3abec1d2009-03-02 05:36:20 +000097 Sk64Test.cpp StringTest.cpp Test.cpp UtilsTest.cpp PathTest.cpp \
reed@android.com5e5adfd2009-03-07 03:39:23 +000098 ClipCubicTest.cpp SrcOverTest.cpp StreamTest.cpp SortTest.cpp \
99 PathMeasureTest.cpp main.cpp
reed@android.comd66efc22009-03-03 18:35:18 +0000100
reed@android.coma396a162009-02-28 18:26:14 +0000101TESTS_SRCS := $(addprefix tests/, $(TESTS_SRCS))
102
103TESTS_OBJS := $(TESTS_SRCS:.cpp=.o)
104TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS))
105
106tests: $(TESTS_OBJS) out/libskia.a
107 @echo "linking tests..."
108 $(HIDE)g++ $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS)
109
110##############################################################################
111
reed@android.com9db60872009-01-21 15:07:03 +0000112.PHONY: clean
reed@android.com4cb8bd12009-01-16 16:15:37 +0000113clean:
114 $(HIDE)rm -rf out
reed@android.com9db60872009-01-21 15:07:03 +0000115
116.PHONY: help
reed@android.com4c7d3d62009-01-21 03:15:13 +0000117help:
118 @echo "Targets:"
119 @echo " <default>: out/libskia.a"
120 @echo " bench: out/bench/bench"
reed@android.coma396a162009-02-28 18:26:14 +0000121 @echo " tests: out/tests/tests"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000122 @echo " clean: removes entire out/ directory"
123 @echo " help: this text"
reed@android.com9db60872009-01-21 15:07:03 +0000124 @echo "Options: (after make, or in bash shell)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000125 @echo " SKIA_DEBUG=true for debug build"
reed@android.com9db60872009-01-21 15:07:03 +0000126 @echo " SKIA_SCALAR=fixed for fixed-point build"
127 @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000128 @echo ""