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 | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 5 | C_INCLUDES := -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/utils |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 6 | CFLAGS := -O2 |
| 7 | LINKER_OPTS := -lpthread |
| 8 | DEFINES := -DSK_CAN_USE_FLOAT |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 9 | HIDE = @ |
| 10 | |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 11 | ifeq ($(SKIA_SCALAR),fixed) |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 12 | DEFINES += -DSK_SCALAR_IS_FIXED |
| 13 | else |
| 14 | DEFINES += -DSK_SCALAR_IS_FLOAT |
| 15 | endif |
| 16 | |
| 17 | ifeq ($(SKIA_DEBUG),true) |
| 18 | DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT |
| 19 | else |
| 20 | DEFINES += -DSK_RELEASE |
| 21 | endif |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 22 | |
| 23 | # start with the core (required) |
| 24 | include src/core/core_files.mk |
| 25 | SRC_LIST := $(addprefix src/core/, $(SOURCE)) |
| 26 | |
| 27 | # we usually need ports |
| 28 | include src/ports/ports_files.mk |
| 29 | SRC_LIST += $(addprefix src/ports/, $(SOURCE)) |
| 30 | |
| 31 | # do we want effects? |
| 32 | include src/effects/effects_files.mk |
| 33 | SRC_LIST += $(addprefix src/effects/, $(SOURCE)) |
| 34 | |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 35 | # core image files |
| 36 | include src/images/images_files.mk |
| 37 | SRC_LIST += $(addprefix src/images/, $(SOURCE)) |
| 38 | |
| 39 | # conditional files based on our platform |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 40 | ifeq ($(SKIA_BUILD_FOR),mac) |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 41 | 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.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 47 | SRC_LIST += src/ports/SkFontHost_mac.cpp |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 48 | else |
reed@android.com | fb21016 | 2009-01-23 21:24:39 +0000 | [diff] [blame] | 49 | LINKER_OPTS += -lpng |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 50 | DEFINES += -DSK_BUILD_FOR_UNIX |
| 51 | |
reed@android.com | 7b830a1 | 2009-01-22 13:41:08 +0000 | [diff] [blame] | 52 | # these are our registry-based factories |
| 53 | SRC_LIST += src/images/SkImageDecoder_Factory.cpp |
| 54 | SRC_LIST += src/images/SkImageEncoder_Factory.cpp |
reed@android.com | 7b830a1 | 2009-01-22 13:41:08 +0000 | [diff] [blame] | 55 | # support files |
| 56 | SRC_LIST += src/images/SkScaledBitmapSampler.cpp |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 57 | endif |
| 58 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 59 | out/%.o : %.cpp |
| 60 | @mkdir -p $(dir $@) |
| 61 | $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@ |
| 62 | @echo "compiling $@" |
| 63 | |
| 64 | # now build out objects |
| 65 | OBJ_LIST := $(SRC_LIST:.cpp=.o) |
| 66 | OBJ_LIST := $(addprefix out/, $(OBJ_LIST)) |
| 67 | |
| 68 | out/libskia.a: Makefile $(OBJ_LIST) |
| 69 | $(HIDE)$(AR) ru $@ $(OBJ_LIST) |
| 70 | $(HIDE)ranlib $@ |
| 71 | |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 72 | ############################################################################## |
| 73 | |
reed@android.com | f523e25 | 2009-01-26 23:15:37 +0000 | [diff] [blame] | 74 | BENCH_SRCS := RectBench.cpp SkBenchmark.cpp main.cpp BitmapBench.cpp |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 75 | BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS)) |
reed@android.com | 1b4c815 | 2009-01-23 21:51:56 +0000 | [diff] [blame] | 76 | |
reed@android.com | fb21016 | 2009-01-23 21:24:39 +0000 | [diff] [blame] | 77 | # add any optional codecs for this app |
reed@android.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 78 | ifeq ($(SKIA_BUILD_FOR),mac) |
| 79 | # BENCH_SRCS += bench/TextBench.cpp |
| 80 | else |
reed@android.com | a21ff6f | 2009-01-27 18:25:02 +0000 | [diff] [blame] | 81 | BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp |
reed@android.com | 1b4c815 | 2009-01-23 21:51:56 +0000 | [diff] [blame] | 82 | endif |
reed@android.com | fb21016 | 2009-01-23 21:24:39 +0000 | [diff] [blame] | 83 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 84 | BENCH_OBJS := $(BENCH_SRCS:.cpp=.o) |
| 85 | BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS)) |
| 86 | |
| 87 | bench: $(BENCH_OBJS) out/libskia.a |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 88 | @echo "linking bench..." |
| 89 | $(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] | 90 | |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 91 | ############################################################################## |
| 92 | |
reed@android.com | 0650c6c | 2009-03-04 14:02:44 +0000 | [diff] [blame^] | 93 | # we let tests cheat and see private headers, so we can unittest modules |
| 94 | C_INCLUDES += -Isrc/core |
| 95 | |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 96 | TESTS_SRCS := GeometryTest.cpp MathTest.cpp MatrixTest.cpp PackBitsTest.cpp \ |
reed@android.com | 3abec1d | 2009-03-02 05:36:20 +0000 | [diff] [blame] | 97 | Sk64Test.cpp StringTest.cpp Test.cpp UtilsTest.cpp PathTest.cpp \ |
reed@android.com | d66efc2 | 2009-03-03 18:35:18 +0000 | [diff] [blame] | 98 | ClipCubicTest.cpp SrcOverTest.cpp main.cpp |
| 99 | |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 100 | TESTS_SRCS := $(addprefix tests/, $(TESTS_SRCS)) |
| 101 | |
| 102 | TESTS_OBJS := $(TESTS_SRCS:.cpp=.o) |
| 103 | TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS)) |
| 104 | |
| 105 | tests: $(TESTS_OBJS) out/libskia.a |
| 106 | @echo "linking tests..." |
| 107 | $(HIDE)g++ $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS) |
| 108 | |
| 109 | ############################################################################## |
| 110 | |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 111 | .PHONY: clean |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 112 | clean: |
| 113 | $(HIDE)rm -rf out |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 114 | |
| 115 | .PHONY: help |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 116 | help: |
| 117 | @echo "Targets:" |
| 118 | @echo " <default>: out/libskia.a" |
| 119 | @echo " bench: out/bench/bench" |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 120 | @echo " tests: out/tests/tests" |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 121 | @echo " clean: removes entire out/ directory" |
| 122 | @echo " help: this text" |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 123 | @echo "Options: (after make, or in bash shell)" |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 124 | @echo " SKIA_DEBUG=true for debug build" |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 125 | @echo " SKIA_SCALAR=fixed for fixed-point build" |
| 126 | @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] | 127 | @echo "" |