blob: af28159aa00ccf84dfeab0d58c3918ce7bf5688c [file] [log] [blame]
reed@android.com4c7d3d62009-01-21 03:15:13 +00001# Simple makefile for skia library and test apps
reed@android.com4cb8bd12009-01-16 16:15:37 +00002
reed@android.com9db60872009-01-21 15:07:03 +00003# setup our defaults
reed@android.com4c7d3d62009-01-21 03:15:13 +00004CC := gcc
reed@android.com4cb8bd12009-01-16 16:15:37 +00005C_INCLUDES := -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/utils
reed@android.com4c7d3d62009-01-21 03:15:13 +00006CFLAGS := -O2
7LINKER_OPTS := -lpthread
8DEFINES := -DSK_CAN_USE_FLOAT
reed@android.com4cb8bd12009-01-16 16:15:37 +00009HIDE = @
10
reed@android.com9db60872009-01-21 15:07:03 +000011ifeq ($(SKIA_SCALAR),fixed)
reed@android.com4c7d3d62009-01-21 03:15:13 +000012 DEFINES += -DSK_SCALAR_IS_FIXED
13else
14 DEFINES += -DSK_SCALAR_IS_FLOAT
15endif
16
17ifeq ($(SKIA_DEBUG),true)
18 DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT
19else
20 DEFINES += -DSK_RELEASE
21endif
reed@android.com4cb8bd12009-01-16 16:15:37 +000022
23# start with the core (required)
24include src/core/core_files.mk
25SRC_LIST := $(addprefix src/core/, $(SOURCE))
26
27# we usually need ports
28include src/ports/ports_files.mk
29SRC_LIST += $(addprefix src/ports/, $(SOURCE))
30
31# do we want effects?
32include src/effects/effects_files.mk
33SRC_LIST += $(addprefix src/effects/, $(SOURCE))
34
reed@android.com4c7d3d62009-01-21 03:15:13 +000035# core image files
36include src/images/images_files.mk
37SRC_LIST += $(addprefix src/images/, $(SOURCE))
38
39# conditional files based on our platform
reed@android.com9db60872009-01-21 15:07:03 +000040ifeq ($(SKIA_BUILD_FOR),mac)
reed@android.com4c7d3d62009-01-21 03:15:13 +000041 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
47else
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
53endif
54
reed@android.com4cb8bd12009-01-16 16:15:37 +000055out/%.o : %.cpp
56 @mkdir -p $(dir $@)
57 $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@
58 @echo "compiling $@"
59
60# now build out objects
61OBJ_LIST := $(SRC_LIST:.cpp=.o)
62OBJ_LIST := $(addprefix out/, $(OBJ_LIST))
63
64out/libskia.a: Makefile $(OBJ_LIST)
65 $(HIDE)$(AR) ru $@ $(OBJ_LIST)
66 $(HIDE)ranlib $@
67
68BENCH_SRCS := RectBench.cpp SkBenchmark.cpp main.cpp
69BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS))
70BENCH_OBJS := $(BENCH_SRCS:.cpp=.o)
71BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS))
72
73bench: $(BENCH_OBJS) out/libskia.a
reed@android.com4c7d3d62009-01-21 03:15:13 +000074 @echo "linking bench..."
75 $(HIDE)g++ $(BENCH_OBJS) out/libskia.a -o out/bench/bench $(LINKER_OPTS)
reed@android.com4cb8bd12009-01-16 16:15:37 +000076
reed@android.com9db60872009-01-21 15:07:03 +000077.PHONY: clean
reed@android.com4cb8bd12009-01-16 16:15:37 +000078clean:
79 $(HIDE)rm -rf out
reed@android.com9db60872009-01-21 15:07:03 +000080
81.PHONY: help
reed@android.com4c7d3d62009-01-21 03:15:13 +000082help:
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.com9db60872009-01-21 15:07:03 +000088 @echo "Options: (after make, or in bash shell)"
reed@android.com4c7d3d62009-01-21 03:15:13 +000089 @echo " SKIA_DEBUG=true for debug build"
reed@android.com9db60872009-01-21 15:07:03 +000090 @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.com4c7d3d62009-01-21 03:15:13 +000092 @echo ""
93