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