reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 1 | # Simple makefile for skia library and test apps |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 2 | |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 3 | # setup our defaults |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 4 | CC := gcc |
reed@android.com | c4d4090 | 2009-04-08 18:05:24 +0000 | [diff] [blame] | 5 | C_INCLUDES := -Iinclude/config -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/utils |
reed@android.com | f2afb67 | 2009-09-28 16:12:48 +0000 | [diff] [blame] | 6 | CFLAGS := -Wall -g # -O2 |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 7 | CFLAGS_SSE2 = $(CFLAGS) -msse2 |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 8 | LINKER_OPTS := -lpthread |
| 9 | DEFINES := -DSK_CAN_USE_FLOAT |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 10 | HIDE = @ |
| 11 | |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 12 | ifeq ($(SKIA_SCALAR),fixed) |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 13 | DEFINES += -DSK_SCALAR_IS_FIXED |
| 14 | else |
| 15 | DEFINES += -DSK_SCALAR_IS_FLOAT |
| 16 | endif |
| 17 | |
| 18 | ifeq ($(SKIA_DEBUG),true) |
| 19 | DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT |
| 20 | else |
| 21 | DEFINES += -DSK_RELEASE |
| 22 | endif |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 23 | |
reed@android.com | f549369 | 2009-07-22 19:21:01 +0000 | [diff] [blame] | 24 | DEFINES += -DSK_SUPPORT_LCDTEXT |
| 25 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 26 | # start with the core (required) |
| 27 | include src/core/core_files.mk |
| 28 | SRC_LIST := $(addprefix src/core/, $(SOURCE)) |
| 29 | |
reed@android.com | ed7bd9b | 2009-07-30 02:25:54 +0000 | [diff] [blame] | 30 | # add the opts (optimizations) |
| 31 | include src/opts/opts_files.mk |
| 32 | SRC_LIST += $(addprefix src/opts/, $(SOURCE)) |
| 33 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 34 | # we usually need ports |
| 35 | include src/ports/ports_files.mk |
| 36 | SRC_LIST += $(addprefix src/ports/, $(SOURCE)) |
| 37 | |
| 38 | # do we want effects? |
| 39 | include src/effects/effects_files.mk |
| 40 | SRC_LIST += $(addprefix src/effects/, $(SOURCE)) |
| 41 | |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 42 | # core image files |
| 43 | include src/images/images_files.mk |
| 44 | SRC_LIST += $(addprefix src/images/, $(SOURCE)) |
| 45 | |
reed@android.com | 9781ca5 | 2009-04-14 14:28:22 +0000 | [diff] [blame] | 46 | # core util files |
| 47 | include src/utils/utils_files.mk |
| 48 | SRC_LIST += $(addprefix src/utils/, $(SOURCE)) |
| 49 | |
| 50 | # extra files we want to build to prevent bit-rot, but not link |
| 51 | JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp |
| 52 | |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 53 | # conditional files based on our platform |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 54 | ifeq ($(SKIA_BUILD_FOR),mac) |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 55 | 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.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 61 | SRC_LIST += src/ports/SkFontHost_mac.cpp |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 62 | else |
reed@android.com | f2afb67 | 2009-09-28 16:12:48 +0000 | [diff] [blame] | 63 | LINKER_OPTS += -lpng -lfreetype |
reed@android.com | dfee579 | 2010-04-15 14:24:50 +0000 | [diff] [blame^] | 64 | DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 65 | |
reed@android.com | f2afb67 | 2009-09-28 16:12:48 +0000 | [diff] [blame] | 66 | # 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.com | 7b830a1 | 2009-01-22 13:41:08 +0000 | [diff] [blame] | 73 | # these are our registry-based factories |
| 74 | SRC_LIST += src/images/SkImageDecoder_Factory.cpp |
| 75 | SRC_LIST += src/images/SkImageEncoder_Factory.cpp |
reed@android.com | 7b830a1 | 2009-01-22 13:41:08 +0000 | [diff] [blame] | 76 | # support files |
| 77 | SRC_LIST += src/images/SkScaledBitmapSampler.cpp |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 78 | endif |
| 79 | |
senorblanco@chromium.org | 4e75355 | 2009-11-16 21:09:00 +0000 | [diff] [blame] | 80 | # For these files, and these files only, compile with -msse2. |
| 81 | SSE2_OBJS := out/src/opts/SkBlitRow_opts_SSE2.o \ |
| 82 | out/src/opts/SkUtils_opts_SSE2.o |
| 83 | $(SSE2_OBJS) : CFLAGS := $(CFLAGS_SSE2) |
| 84 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 85 | out/%.o : %.cpp |
| 86 | @mkdir -p $(dir $@) |
| 87 | $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@ |
| 88 | @echo "compiling $@" |
| 89 | |
senorblanco@chromium.org | 4aa910e | 2009-10-30 18:50:23 +0000 | [diff] [blame] | 90 | %.s : %.cpp |
| 91 | @mkdir -p $(dir $@) |
| 92 | $(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -S -c $< -o $@ |
| 93 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 94 | # now build out objects |
| 95 | OBJ_LIST := $(SRC_LIST:.cpp=.o) |
| 96 | OBJ_LIST := $(addprefix out/, $(OBJ_LIST)) |
| 97 | |
reed@android.com | 9781ca5 | 2009-04-14 14:28:22 +0000 | [diff] [blame] | 98 | # we want to compile these, but we don't actually link them |
| 99 | JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o) |
| 100 | JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS)) |
| 101 | |
| 102 | out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS) |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 103 | $(HIDE)$(AR) ru $@ $(OBJ_LIST) |
| 104 | $(HIDE)ranlib $@ |
| 105 | |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 106 | ############################################################################## |
| 107 | |
reed@android.com | 4d85059 | 2009-08-12 20:30:58 +0000 | [diff] [blame] | 108 | BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp \ |
reed@android.com | 34e8580 | 2009-09-02 21:11:44 +0000 | [diff] [blame] | 109 | RepeatTileBench.cpp DecodeBench.cpp |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 110 | BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS)) |
reed@android.com | 1b4c815 | 2009-01-23 21:51:56 +0000 | [diff] [blame] | 111 | |
reed@android.com | fb21016 | 2009-01-23 21:24:39 +0000 | [diff] [blame] | 112 | # add any optional codecs for this app |
reed@android.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 113 | ifeq ($(SKIA_BUILD_FOR),mac) |
reed@android.com | d6638e6 | 2009-04-08 05:03:52 +0000 | [diff] [blame] | 114 | BENCH_SRCS += bench/TextBench.cpp |
reed@android.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 115 | else |
reed@android.com | a21ff6f | 2009-01-27 18:25:02 +0000 | [diff] [blame] | 116 | BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp |
reed@android.com | 1b4c815 | 2009-01-23 21:51:56 +0000 | [diff] [blame] | 117 | endif |
reed@android.com | fb21016 | 2009-01-23 21:24:39 +0000 | [diff] [blame] | 118 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 119 | BENCH_OBJS := $(BENCH_SRCS:.cpp=.o) |
| 120 | BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS)) |
| 121 | |
| 122 | bench: $(BENCH_OBJS) out/libskia.a |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 123 | @echo "linking bench..." |
| 124 | $(HIDE)g++ $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS) |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 125 | |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 126 | ############################################################################## |
| 127 | |
reed@android.com | 0650c6c | 2009-03-04 14:02:44 +0000 | [diff] [blame] | 128 | # we let tests cheat and see private headers, so we can unittest modules |
| 129 | C_INCLUDES += -Isrc/core |
| 130 | |
reed@android.com | bbff1d5 | 2009-06-05 16:21:03 +0000 | [diff] [blame] | 131 | include tests/tests_files.mk |
| 132 | TESTS_SRCS := $(addprefix tests/, $(SOURCE)) |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 133 | |
| 134 | TESTS_OBJS := $(TESTS_SRCS:.cpp=.o) |
| 135 | TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS)) |
| 136 | |
| 137 | tests: $(TESTS_OBJS) out/libskia.a |
| 138 | @echo "linking tests..." |
| 139 | $(HIDE)g++ $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS) |
| 140 | |
| 141 | ############################################################################## |
| 142 | |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 143 | SKIMAGE_SRCS := skimage_main.cpp |
| 144 | |
| 145 | SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS)) |
| 146 | |
| 147 | SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o) |
| 148 | SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS)) |
| 149 | |
| 150 | skimage: $(SKIMAGE_OBJS) out/libskia.a |
| 151 | @echo "linking skimage..." |
| 152 | $(HIDE)g++ $(SKIMAGE_OBJS) out/libskia.a -o out/tools/skimage $(LINKER_OPTS) |
| 153 | |
| 154 | ############################################################################## |
| 155 | |
reed@android.com | 6413e79 | 2010-04-12 14:27:37 +0000 | [diff] [blame] | 156 | SKHELLO_SRCS := skhello.cpp |
| 157 | |
| 158 | SKHELLO_SRCS := $(addprefix tools/, $(SKHELLO_SRCS)) |
| 159 | |
| 160 | SKHELLO_OBJS := $(SKHELLO_SRCS:.cpp=.o) |
| 161 | SKHELLO_OBJS := $(addprefix out/, $(SKHELLO_OBJS)) |
| 162 | |
| 163 | skhello: $(SKHELLO_OBJS) out/libskia.a |
| 164 | @echo "linking shkello..." |
| 165 | $(HIDE)g++ $(SKHELLO_OBJS) out/libskia.a -o out/tools/skhello $(LINKER_OPTS) |
| 166 | |
| 167 | ############################################################################## |
| 168 | |
reed@android.com | 048522d | 2009-06-23 12:19:41 +0000 | [diff] [blame] | 169 | include gm/gm_files.mk |
| 170 | GM_SRCS := $(addprefix gm/, $(SOURCE)) |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 171 | |
senorblanco@chromium.org | 4aa910e | 2009-10-30 18:50:23 +0000 | [diff] [blame] | 172 | ifneq ($(SKIA_BUILD_FOR),mac) |
| 173 | GM_SRCS += src/images/SkImageDecoder_libpng.cpp |
| 174 | endif |
| 175 | |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 176 | GM_OBJS := $(GM_SRCS:.cpp=.o) |
| 177 | GM_OBJS := $(addprefix out/, $(GM_OBJS)) |
| 178 | |
| 179 | gm: $(GM_OBJS) out/libskia.a |
| 180 | @echo "linking gm..." |
| 181 | $(HIDE)g++ $(GM_OBJS) out/libskia.a -o out/gm/gm $(LINKER_OPTS) |
| 182 | |
| 183 | ############################################################################## |
| 184 | |
reed@android.com | ee0eb01 | 2009-06-23 17:13:30 +0000 | [diff] [blame] | 185 | .PHONY: all |
reed@android.com | 6413e79 | 2010-04-12 14:27:37 +0000 | [diff] [blame] | 186 | all: $ bench gm skimage tests skhello |
reed@android.com | ee0eb01 | 2009-06-23 17:13:30 +0000 | [diff] [blame] | 187 | |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 188 | .PHONY: clean |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 189 | clean: |
| 190 | $(HIDE)rm -rf out |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 191 | |
| 192 | .PHONY: help |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 193 | help: |
| 194 | @echo "Targets:" |
| 195 | @echo " <default>: out/libskia.a" |
| 196 | @echo " bench: out/bench/bench" |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 197 | @echo " gm: out/gm/gm" |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 198 | @echo " skimage: out/tools/skimage" |
reed@android.com | 6413e79 | 2010-04-12 14:27:37 +0000 | [diff] [blame] | 199 | @echo " skhello: out/tools/skhello" |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 200 | @echo " tests: out/tests/tests" |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 201 | @echo " clean: removes entire out/ directory" |
| 202 | @echo " help: this text" |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 203 | @echo "Options: (after make, or in bash shell)" |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 204 | @echo " SKIA_DEBUG=true for debug build" |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 205 | @echo " SKIA_SCALAR=fixed for fixed-point build" |
| 206 | @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)" |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 207 | @echo "" |