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 | 04225dc | 2009-03-20 04:59:37 +0000 | [diff] [blame] | 6 | CFLAGS := -Wall # -O2 |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 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 | |
reed@android.com | 9781ca5 | 2009-04-14 14:28:22 +0000 | [diff] [blame] | 39 | # core util files |
| 40 | include src/utils/utils_files.mk |
| 41 | SRC_LIST += $(addprefix src/utils/, $(SOURCE)) |
| 42 | |
| 43 | # extra files we want to build to prevent bit-rot, but not link |
| 44 | JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp |
| 45 | |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 46 | # conditional files based on our platform |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 47 | ifeq ($(SKIA_BUILD_FOR),mac) |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 48 | 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.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 54 | SRC_LIST += src/ports/SkFontHost_mac.cpp |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 55 | else |
reed@android.com | fb21016 | 2009-01-23 21:24:39 +0000 | [diff] [blame] | 56 | LINKER_OPTS += -lpng |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 57 | DEFINES += -DSK_BUILD_FOR_UNIX |
| 58 | |
reed@android.com | 8015dd8 | 2009-06-21 00:49:18 +0000 | [diff] [blame] | 59 | SRC_LIST += src/ports/SkFontHost_none.cpp |
reed@android.com | 7b830a1 | 2009-01-22 13:41:08 +0000 | [diff] [blame] | 60 | # these are our registry-based factories |
| 61 | SRC_LIST += src/images/SkImageDecoder_Factory.cpp |
| 62 | SRC_LIST += src/images/SkImageEncoder_Factory.cpp |
reed@android.com | 7b830a1 | 2009-01-22 13:41:08 +0000 | [diff] [blame] | 63 | # support files |
| 64 | SRC_LIST += src/images/SkScaledBitmapSampler.cpp |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 65 | endif |
| 66 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 67 | out/%.o : %.cpp |
| 68 | @mkdir -p $(dir $@) |
| 69 | $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@ |
| 70 | @echo "compiling $@" |
| 71 | |
| 72 | # now build out objects |
| 73 | OBJ_LIST := $(SRC_LIST:.cpp=.o) |
| 74 | OBJ_LIST := $(addprefix out/, $(OBJ_LIST)) |
| 75 | |
reed@android.com | 9781ca5 | 2009-04-14 14:28:22 +0000 | [diff] [blame] | 76 | # we want to compile these, but we don't actually link them |
| 77 | JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o) |
| 78 | JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS)) |
| 79 | |
| 80 | out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS) |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 81 | $(HIDE)$(AR) ru $@ $(OBJ_LIST) |
| 82 | $(HIDE)ranlib $@ |
| 83 | |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 84 | ############################################################################## |
| 85 | |
reed@android.com | 953ce8d | 2009-04-01 18:38:43 +0000 | [diff] [blame] | 86 | BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 87 | BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS)) |
reed@android.com | 1b4c815 | 2009-01-23 21:51:56 +0000 | [diff] [blame] | 88 | |
reed@android.com | 6c924ad | 2009-03-31 03:48:49 +0000 | [diff] [blame] | 89 | BENCH_SRCS += src/effects/SkNWayCanvas.cpp |
| 90 | |
reed@android.com | fb21016 | 2009-01-23 21:24:39 +0000 | [diff] [blame] | 91 | # add any optional codecs for this app |
reed@android.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 92 | ifeq ($(SKIA_BUILD_FOR),mac) |
reed@android.com | d6638e6 | 2009-04-08 05:03:52 +0000 | [diff] [blame] | 93 | BENCH_SRCS += bench/TextBench.cpp |
reed@android.com | 3a859a0 | 2009-01-28 00:56:29 +0000 | [diff] [blame] | 94 | else |
reed@android.com | a21ff6f | 2009-01-27 18:25:02 +0000 | [diff] [blame] | 95 | BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp |
reed@android.com | 1b4c815 | 2009-01-23 21:51:56 +0000 | [diff] [blame] | 96 | endif |
reed@android.com | fb21016 | 2009-01-23 21:24:39 +0000 | [diff] [blame] | 97 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 98 | BENCH_OBJS := $(BENCH_SRCS:.cpp=.o) |
| 99 | BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS)) |
| 100 | |
| 101 | bench: $(BENCH_OBJS) out/libskia.a |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 102 | @echo "linking bench..." |
| 103 | $(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] | 104 | |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 105 | ############################################################################## |
| 106 | |
reed@android.com | 0650c6c | 2009-03-04 14:02:44 +0000 | [diff] [blame] | 107 | # we let tests cheat and see private headers, so we can unittest modules |
| 108 | C_INCLUDES += -Isrc/core |
| 109 | |
reed@android.com | bbff1d5 | 2009-06-05 16:21:03 +0000 | [diff] [blame] | 110 | include tests/tests_files.mk |
| 111 | TESTS_SRCS := $(addprefix tests/, $(SOURCE)) |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 112 | |
| 113 | TESTS_OBJS := $(TESTS_SRCS:.cpp=.o) |
| 114 | TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS)) |
| 115 | |
| 116 | tests: $(TESTS_OBJS) out/libskia.a |
| 117 | @echo "linking tests..." |
| 118 | $(HIDE)g++ $(TESTS_OBJS) out/libskia.a -o out/tests/tests $(LINKER_OPTS) |
| 119 | |
| 120 | ############################################################################## |
| 121 | |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 122 | SKIMAGE_SRCS := skimage_main.cpp |
| 123 | |
| 124 | SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS)) |
| 125 | |
| 126 | SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o) |
| 127 | SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS)) |
| 128 | |
| 129 | skimage: $(SKIMAGE_OBJS) out/libskia.a |
| 130 | @echo "linking skimage..." |
| 131 | $(HIDE)g++ $(SKIMAGE_OBJS) out/libskia.a -o out/tools/skimage $(LINKER_OPTS) |
| 132 | |
| 133 | ############################################################################## |
| 134 | |
reed@android.com | 048522d | 2009-06-23 12:19:41 +0000 | [diff] [blame^] | 135 | include gm/gm_files.mk |
| 136 | GM_SRCS := $(addprefix gm/, $(SOURCE)) |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 137 | |
| 138 | GM_OBJS := $(GM_SRCS:.cpp=.o) |
| 139 | GM_OBJS := $(addprefix out/, $(GM_OBJS)) |
| 140 | |
| 141 | gm: $(GM_OBJS) out/libskia.a |
| 142 | @echo "linking gm..." |
| 143 | $(HIDE)g++ $(GM_OBJS) out/libskia.a -o out/gm/gm $(LINKER_OPTS) |
| 144 | |
| 145 | ############################################################################## |
| 146 | |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 147 | .PHONY: clean |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 148 | clean: |
| 149 | $(HIDE)rm -rf out |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 150 | |
| 151 | .PHONY: help |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 152 | help: |
| 153 | @echo "Targets:" |
| 154 | @echo " <default>: out/libskia.a" |
| 155 | @echo " bench: out/bench/bench" |
reed@android.com | dd0ac28 | 2009-06-20 02:38:16 +0000 | [diff] [blame] | 156 | @echo " gm: out/gm/gm" |
reed@android.com | af45979 | 2009-04-24 19:52:53 +0000 | [diff] [blame] | 157 | @echo " skimage: out/tools/skimage" |
reed@android.com | a396a16 | 2009-02-28 18:26:14 +0000 | [diff] [blame] | 158 | @echo " tests: out/tests/tests" |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 159 | @echo " clean: removes entire out/ directory" |
| 160 | @echo " help: this text" |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 161 | @echo "Options: (after make, or in bash shell)" |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 162 | @echo " SKIA_DEBUG=true for debug build" |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame] | 163 | @echo " SKIA_SCALAR=fixed for fixed-point build" |
| 164 | @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] | 165 | @echo "" |