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 |
| 47 | else |
| 48 | LINKER_OPTS += -lpng -ljpeg |
| 49 | DEFINES += -DSK_BUILD_FOR_UNIX |
| 50 | |
| 51 | SRC_LIST += src/images/SkImageDecoder_libpng.cpp |
| 52 | SRC_LIST += src/images/SkImageDecoder_libjpeg.cpp |
| 53 | endif |
| 54 | |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 55 | out/%.o : %.cpp |
| 56 | @mkdir -p $(dir $@) |
| 57 | $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@ |
| 58 | @echo "compiling $@" |
| 59 | |
| 60 | # now build out objects |
| 61 | OBJ_LIST := $(SRC_LIST:.cpp=.o) |
| 62 | OBJ_LIST := $(addprefix out/, $(OBJ_LIST)) |
| 63 | |
| 64 | out/libskia.a: Makefile $(OBJ_LIST) |
| 65 | $(HIDE)$(AR) ru $@ $(OBJ_LIST) |
| 66 | $(HIDE)ranlib $@ |
| 67 | |
| 68 | BENCH_SRCS := RectBench.cpp SkBenchmark.cpp main.cpp |
| 69 | BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS)) |
| 70 | BENCH_OBJS := $(BENCH_SRCS:.cpp=.o) |
| 71 | BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS)) |
| 72 | |
| 73 | bench: $(BENCH_OBJS) out/libskia.a |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 74 | @echo "linking bench..." |
| 75 | $(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] | 76 | |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame^] | 77 | .PHONY: clean |
reed@android.com | 4cb8bd1 | 2009-01-16 16:15:37 +0000 | [diff] [blame] | 78 | clean: |
| 79 | $(HIDE)rm -rf out |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame^] | 80 | |
| 81 | .PHONY: help |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 82 | help: |
| 83 | @echo "Targets:" |
| 84 | @echo " <default>: out/libskia.a" |
| 85 | @echo " bench: out/bench/bench" |
| 86 | @echo " clean: removes entire out/ directory" |
| 87 | @echo " help: this text" |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame^] | 88 | @echo "Options: (after make, or in bash shell)" |
reed@android.com | 4c7d3d6 | 2009-01-21 03:15:13 +0000 | [diff] [blame] | 89 | @echo " SKIA_DEBUG=true for debug build" |
reed@android.com | 9db6087 | 2009-01-21 15:07:03 +0000 | [diff] [blame^] | 90 | @echo " SKIA_SCALAR=fixed for fixed-point build" |
| 91 | @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] | 92 | @echo "" |
| 93 | |