blob: 91e92fdd614f54bfabad22e5c18919ae8c1d6b60 [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.com04225dc2009-03-20 04:59:37 +00006CFLAGS := -Wall # -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
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
reed@android.com9781ca52009-04-14 14:28:22 +000039# core util files
40include src/utils/utils_files.mk
41SRC_LIST += $(addprefix src/utils/, $(SOURCE))
42
43# extra files we want to build to prevent bit-rot, but not link
44JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp
45
reed@android.com4c7d3d62009-01-21 03:15:13 +000046# conditional files based on our platform
reed@android.com9db60872009-01-21 15:07:03 +000047ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.com4c7d3d62009-01-21 03:15:13 +000048 LINKER_OPTS += -framework Carbon
49 DEFINES += -DSK_BUILD_FOR_MAC
50
51 C_INCLUDES += -Iinclude/utils/mac
52 SRC_LIST += src/ports/SkImageDecoder_CG.cpp
53 SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
reed@android.com3a859a02009-01-28 00:56:29 +000054 SRC_LIST += src/ports/SkFontHost_mac.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000055else
reed@android.comfb210162009-01-23 21:24:39 +000056 LINKER_OPTS += -lpng
reed@android.com4c7d3d62009-01-21 03:15:13 +000057 DEFINES += -DSK_BUILD_FOR_UNIX
58
reed@android.com7b830a12009-01-22 13:41:08 +000059 # these are our registry-based factories
60 SRC_LIST += src/images/SkImageDecoder_Factory.cpp
61 SRC_LIST += src/images/SkImageEncoder_Factory.cpp
reed@android.com7b830a12009-01-22 13:41:08 +000062 # support files
63 SRC_LIST += src/images/SkScaledBitmapSampler.cpp
reed@android.com4c7d3d62009-01-21 03:15:13 +000064endif
65
reed@android.com4cb8bd12009-01-16 16:15:37 +000066out/%.o : %.cpp
67 @mkdir -p $(dir $@)
68 $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
69 @echo "compiling $@"
70
71# now build out objects
72OBJ_LIST := $(SRC_LIST:.cpp=.o)
73OBJ_LIST := $(addprefix out/, $(OBJ_LIST))
74
reed@android.com9781ca52009-04-14 14:28:22 +000075# we want to compile these, but we don't actually link them
76JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o)
77JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS))
78
79out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS)
reed@android.com4cb8bd12009-01-16 16:15:37 +000080 $(HIDE)$(AR) ru $@ $(OBJ_LIST)
81 $(HIDE)ranlib $@
82
reed@android.coma396a162009-02-28 18:26:14 +000083##############################################################################
84
reed@android.com953ce8d2009-04-01 18:38:43 +000085BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp
reed@android.com4cb8bd12009-01-16 16:15:37 +000086BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))
reed@android.com1b4c8152009-01-23 21:51:56 +000087
reed@android.com6c924ad2009-03-31 03:48:49 +000088BENCH_SRCS += src/effects/SkNWayCanvas.cpp
89
reed@android.comfb210162009-01-23 21:24:39 +000090# add any optional codecs for this app
reed@android.com3a859a02009-01-28 00:56:29 +000091ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.comd6638e62009-04-08 05:03:52 +000092 BENCH_SRCS += bench/TextBench.cpp
reed@android.com3a859a02009-01-28 00:56:29 +000093else
reed@android.coma21ff6f2009-01-27 18:25:02 +000094 BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp
reed@android.com1b4c8152009-01-23 21:51:56 +000095endif
reed@android.comfb210162009-01-23 21:24:39 +000096
reed@android.com4cb8bd12009-01-16 16:15:37 +000097BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
98BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))
99
100bench: $(BENCH_OBJS) out/libskia.a
reed@android.com4c7d3d62009-01-21 03:15:13 +0000101 @echo "linking bench..."
102 $(HIDE)g++ $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS)
reed@android.com4cb8bd12009-01-16 16:15:37 +0000103
reed@android.coma396a162009-02-28 18:26:14 +0000104##############################################################################
105
reed@android.com0650c6c2009-03-04 14:02:44 +0000106# we let tests cheat and see private headers, so we can unittest modules
107C_INCLUDES += -Isrc/core
108
reed@android.combbff1d52009-06-05 16:21:03 +0000109include tests/tests_files.mk
110TESTS_SRCS := $(addprefix tests/, $(SOURCE))
reed@android.coma396a162009-02-28 18:26:14 +0000111
112TESTS_OBJS := $(TESTS_SRCS:.cpp=.o)
113TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS))
114
115tests: $(TESTS_OBJS) out/libskia.a
116 @echo "linking tests..."
117 $(HIDE)g++ $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS)
118
119##############################################################################
120
reed@android.comaf459792009-04-24 19:52:53 +0000121SKIMAGE_SRCS := skimage_main.cpp
122
123SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS))
124
125SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o)
126SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS))
127
128skimage: $(SKIMAGE_OBJS) out/libskia.a
129 @echo "linking skimage..."
130 $(HIDE)g++ $(SKIMAGE_OBJS) out/libskia.a -o out/tools/skimage $(LINKER_OPTS)
131
132##############################################################################
133
reed@android.comdd0ac282009-06-20 02:38:16 +0000134GM_SRCS := gmmain.cpp xfermodes.cpp
135GM_SRCS := $(addprefix gm/, $(GM_SRCS))
136
137GM_OBJS := $(GM_SRCS:.cpp=.o)
138GM_OBJS := $(addprefix out/, $(GM_OBJS))
139
140gm: $(GM_OBJS) out/libskia.a
141 @echo "linking gm..."
142 $(HIDE)g++ $(GM_OBJS) out/libskia.a -o out/gm/gm $(LINKER_OPTS)
143
144##############################################################################
145
reed@android.com9db60872009-01-21 15:07:03 +0000146.PHONY: clean
reed@android.com4cb8bd12009-01-16 16:15:37 +0000147clean:
148 $(HIDE)rm -rf out
reed@android.com9db60872009-01-21 15:07:03 +0000149
150.PHONY: help
reed@android.com4c7d3d62009-01-21 03:15:13 +0000151help:
152 @echo "Targets:"
153 @echo " <default>: out/libskia.a"
154 @echo " bench: out/bench/bench"
reed@android.comdd0ac282009-06-20 02:38:16 +0000155 @echo " gm: out/gm/gm"
reed@android.comaf459792009-04-24 19:52:53 +0000156 @echo " skimage: out/tools/skimage"
reed@android.coma396a162009-02-28 18:26:14 +0000157 @echo " tests: out/tests/tests"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000158 @echo " clean: removes entire out/ directory"
159 @echo " help: this text"
reed@android.com9db60872009-01-21 15:07:03 +0000160 @echo "Options: (after make, or in bash shell)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000161 @echo " SKIA_DEBUG=true for debug build"
reed@android.com9db60872009-01-21 15:07:03 +0000162 @echo " SKIA_SCALAR=fixed for fixed-point build"
163 @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)"
reed@android.com4c7d3d62009-01-21 03:15:13 +0000164 @echo ""