epoger@google.com | 1e8e056 | 2011-06-07 14:48:41 +0000 | [diff] [blame] | 1 | # Simple makefile for skia library and test apps |
| 2 | # |
| 3 | # This is the handmade Makefile that we *used* to use before changing over |
| 4 | # to gyp. Keeping it around for now in case some folks need to use it... |
| 5 | # but please contact epoger@google.com about anything you're still using in |
| 6 | # here, so we can provide equivalent functionality in the gyp build. |
| 7 | |
| 8 | # setup our defaults |
| 9 | CC := gcc |
| 10 | GPP := g++ |
| 11 | C_INCLUDES := -Iinclude/config -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/ports |
| 12 | C_INCLUDES += -Iinclude/gpu -Iinclude/utils -Igpu/include |
| 13 | C_INCLUDES += -Ithird_party/glu |
| 14 | |
| 15 | CFLAGS := -Wall -fstrict-aliasing |
| 16 | #CFLAGS += -W -Wextra -Wcast-align -Wchar-subscripts -Wformat -Wformat-security -Wno-format-y2k -Wno-parentheses -Wno-unused-parameter -Wpointer-arith -Wreturn-type -Wundef -Wwrite-strings |
| 17 | CFLAGS_SSE2 = $(CFLAGS) -msse2 |
| 18 | LINKER_OPTS := -lpthread -lz |
| 19 | DEFINES := -DSK_CAN_USE_FLOAT |
| 20 | HIDE = @ |
| 21 | |
| 22 | ifeq ($(SKIA_SCALAR),fixed) |
| 23 | DEFINES += -DSK_SCALAR_IS_FIXED |
| 24 | else |
| 25 | DEFINES += -DSK_SCALAR_IS_FLOAT |
| 26 | endif |
| 27 | |
| 28 | ifeq ($(SKIA_DEBUG),true) |
| 29 | DEFINES += -DSK_DEBUG -DSK_SUPPORT_UNIT -DGR_DEBUG=1 |
| 30 | CFLAGS += -g |
| 31 | else |
| 32 | CFLAGS += -O3 |
| 33 | DEFINES += -DSK_RELEASE -DGR_DEBUG=0 |
| 34 | endif |
| 35 | |
| 36 | DEFINES += -DGR_IMPLEMENTATION=1 |
| 37 | |
| 38 | ifneq ($(SKIA_PDF_SUPPORT),false) |
| 39 | DEFINES += -DSK_SUPPORT_PDF |
| 40 | DEFINES += -DSK_ZLIB_INCLUDE="<zlib.h>" |
| 41 | endif |
| 42 | |
| 43 | ifeq ($(SKIA_SHARED),true) |
| 44 | CFLAGS += -fPIC |
| 45 | LIBSKIA = out/libskia.so |
| 46 | else |
| 47 | LIBSKIA = out/libskia.a |
| 48 | endif |
| 49 | |
| 50 | # start with the core (required) |
| 51 | include src/core/core_files.mk |
| 52 | SRC_LIST := $(addprefix src/core/, $(SOURCE)) |
| 53 | |
| 54 | # add the opts (optimizations) |
| 55 | include src/opts/opts_sse2_files.mk |
| 56 | #include src/opts/opts_files.mk |
| 57 | SRC_LIST += $(addprefix src/opts/, $(SOURCE)) |
| 58 | |
| 59 | # we usually need ports |
| 60 | include src/ports/ports_files.mk |
| 61 | SRC_LIST += $(addprefix src/ports/, $(SOURCE)) |
| 62 | |
| 63 | # do we want effects? |
| 64 | include src/effects/effects_files.mk |
| 65 | SRC_LIST += $(addprefix src/effects/, $(SOURCE)) |
| 66 | |
| 67 | # core image files |
| 68 | include src/images/images_files.mk |
| 69 | SRC_LIST += $(addprefix src/images/, $(SOURCE)) |
| 70 | |
| 71 | # core util files |
| 72 | include src/utils/utils_files.mk |
| 73 | SRC_LIST += $(addprefix src/utils/, $(SOURCE)) |
| 74 | |
| 75 | # GPU files |
| 76 | include gpu/src/gr_files.mk |
| 77 | SRC_LIST += $(addprefix gpu/src/, $(SOURCE)) |
| 78 | |
| 79 | # GPU support files |
| 80 | include src/gpu/skgr_files.mk |
| 81 | SRC_LIST += $(addprefix src/gpu/, $(SOURCE)) |
| 82 | |
| 83 | # pdf backend files |
| 84 | ifneq ($(SKIA_PDF_SUPPORT),false) |
| 85 | C_INCLUDES += -Iinclude/pdf |
| 86 | include src/pdf/pdf_files.mk |
| 87 | SRC_LIST += $(addprefix src/pdf/, $(SOURCE)) |
| 88 | endif |
| 89 | |
| 90 | # extra files we want to build to prevent bit-rot, but not link |
| 91 | JUST_COMPILE_LIST := src/ports/SkFontHost_tables.cpp |
| 92 | |
| 93 | # conditional files based on our platform |
| 94 | ifeq ($(SKIA_BUILD_FOR),mac) |
| 95 | # make it work with 10.4 for our font port |
| 96 | # GPP := g++-4.0 |
| 97 | # SDK := /Developer/SDKs/MacOSX10.4u.sdk |
| 98 | # SDK_OPTS := -isysroot $(SDK) -mmacosx-version-min=10.4 |
| 99 | # CC := gcc-4.0 $(SDK_OPTS) |
| 100 | |
| 101 | C_INCLUDES += -I/opt/local/include |
| 102 | LINKER_OPTS += -L/opt/local/lib -framework Carbon -lpng |
| 103 | DEFINES += -DSK_BUILD_FOR_MAC -DSK_ENABLE_LIBPNG |
| 104 | ifeq ($(SKIA_MESA),true) |
| 105 | C_INCLUDES += -I/usr/X11/include |
| 106 | LINKER_OPTS += -L/usr/X11/lib -lOSMesa -lGLU |
| 107 | DEFINES += -DSK_MESA |
| 108 | else |
| 109 | LINKER_OPTS += -framework OpenGL -framework AGL |
| 110 | endif |
| 111 | C_INCLUDES += -Iinclude/utils/mac |
| 112 | # SRC_LIST += src/ports/SkImageDecoder_CG.cpp |
| 113 | SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp |
| 114 | ifeq ($(SKIA_MESA),true) |
| 115 | SRC_LIST += src/utils/mesa/SkEGLContext_Mesa.cpp |
| 116 | else |
| 117 | SRC_LIST += src/utils/mac/SkEGLContext_mac.cpp |
| 118 | endif |
| 119 | SRC_LIST += src/core/SkTypefaceCache.cpp |
| 120 | SRC_LIST += src/ports/SkFontHost_mac_coretext.cpp |
| 121 | |
| 122 | # these are our registry-based factories |
| 123 | SRC_LIST += src/images/SkImageDecoder_Factory.cpp |
| 124 | SRC_LIST += src/images/SkImageEncoder_Factory.cpp |
| 125 | SRC_LIST += src/images/SkImageDecoder_libpng.cpp |
| 126 | # support files |
| 127 | SRC_LIST += src/images/SkScaledBitmapSampler.cpp |
| 128 | |
| 129 | ifeq ($(SKIA_MESA),true) |
| 130 | SRC_LIST += gpu/src/mesa/GrGLDefaultInterface_mesa.cpp |
| 131 | else |
| 132 | SRC_LIST += gpu/src/mac/GrGLDefaultInterface_mac.cpp |
| 133 | endif |
| 134 | |
| 135 | else |
| 136 | LINKER_OPTS += -lpng -lfreetype |
| 137 | DEFINES += -DSK_BUILD_FOR_UNIX -DSK_ENABLE_LIBPNG -DGR_LINUX_BUILD=1 |
| 138 | ifeq ($(SKIA_MESA),true) |
| 139 | LINKER_OPTS += -lOSMesa -lGLU |
| 140 | DEFINES += -DSK_MESA |
| 141 | else |
| 142 | LINKER_OPTS += -lGL -lGLU -lX11 |
| 143 | endif |
| 144 | |
| 145 | #Assume the color order for now. |
| 146 | DEFINES += -DSK_SAMPLES_FOR_X |
| 147 | |
| 148 | # needed for freetype support |
| 149 | C_INCLUDES += -I/usr/include/freetype2 |
| 150 | SRC_LIST += src/ports/SkFontHost_linux.cpp |
| 151 | SRC_LIST += src/ports/SkFontHost_gamma_none.cpp |
| 152 | SRC_LIST += src/ports/SkFontHost_FreeType.cpp |
| 153 | SRC_LIST += src/ports/SkFontHost_FreeType_Subpixel.cpp |
| 154 | ifeq ($(SKIA_MESA),true) |
| 155 | SRC_LIST += src/utils/mesa/SkEGLContext_Mesa.cpp |
| 156 | else |
| 157 | SRC_LIST += src/utils/unix/SkEGLContext_Unix.cpp |
| 158 | endif |
| 159 | # these are our registry-based factories |
| 160 | SRC_LIST += src/images/SkImageDecoder_Factory.cpp |
| 161 | SRC_LIST += src/images/SkImageEncoder_Factory.cpp |
| 162 | SRC_LIST += src/images/SkImageDecoder_libpng.cpp |
| 163 | # support files |
| 164 | SRC_LIST += src/images/SkScaledBitmapSampler.cpp |
| 165 | |
| 166 | ifeq ($(SKIA_MESA),true) |
| 167 | SRC_LIST += gpu/src/mesa/GrGLDefaultInterface_mesa.cpp |
| 168 | else |
| 169 | SRC_LIST += gpu/src/unix/GrGLDefaultInterface_unix.cpp |
| 170 | endif |
| 171 | endif |
| 172 | |
| 173 | # For these files, and these files only, compile with -msse2. |
| 174 | SSE2_OBJS := out/src/opts/SkBlitRow_opts_SSE2.o \ |
| 175 | out/src/opts/SkBitmapProcState_opts_SSE2.o \ |
| 176 | out/src/opts/SkUtils_opts_SSE2.o |
| 177 | $(SSE2_OBJS) : CFLAGS := $(CFLAGS_SSE2) |
| 178 | |
| 179 | out/%.o : %.cpp |
| 180 | @mkdir -p $(dir $@) |
| 181 | $(HIDE)$(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -c $< -o $@ |
| 182 | @echo "compiling $@" |
| 183 | |
| 184 | %.s : %.cpp |
| 185 | @mkdir -p $(dir $@) |
| 186 | $(CC) $(C_INCLUDES) $(CFLAGS) $(DEFINES) -S -c $< -o $@ |
| 187 | |
| 188 | # now build out objects |
| 189 | OBJ_LIST := $(SRC_LIST:.cpp=.o) |
| 190 | OBJ_LIST := $(addprefix out/, $(OBJ_LIST)) |
| 191 | |
| 192 | # we want to compile these, but we don't actually link them |
| 193 | JUST_COMPILE_OBJS := $(JUST_COMPILE_LIST:.cpp=.o) |
| 194 | JUST_COMPILE_OBJS := $(addprefix out/, $(JUST_COMPILE_OBJS)) |
| 195 | |
| 196 | out/libskia.a: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS) |
| 197 | $(HIDE)$(AR) ru $@ $(OBJ_LIST) |
| 198 | $(HIDE)ranlib $@ |
| 199 | |
| 200 | out/libskia.so: Makefile $(OBJ_LIST) $(JUST_COMPILE_OBJS) |
| 201 | $(HIDE)$(GPP) -shared -o $@ $(OBJ_LIST) $(JUST_COMPILE_OBJS) $(LINKER_OPTS) |
| 202 | |
| 203 | ############################################################################## |
| 204 | |
| 205 | BENCH_SRCS := RectBench.cpp SkBenchmark.cpp benchmain.cpp BitmapBench.cpp \ |
| 206 | RepeatTileBench.cpp DecodeBench.cpp FPSBench.cpp PathBench.cpp \ |
| 207 | GradientBench.cpp MatrixBench.cpp ScalarBench.cpp |
| 208 | |
| 209 | BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS)) |
| 210 | |
| 211 | # add any optional codecs for this app |
| 212 | ifeq ($(SKIA_BUILD_FOR),mac) |
| 213 | BENCH_SRCS += bench/TextBench.cpp |
| 214 | else |
| 215 | BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp |
| 216 | endif |
| 217 | |
| 218 | BENCH_OBJS := $(BENCH_SRCS:.cpp=.o) |
| 219 | BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS)) |
| 220 | |
| 221 | bench: $(BENCH_OBJS) $(LIBSKIA) |
| 222 | @echo "linking bench..." |
| 223 | $(HIDE)$(GPP) $(BENCH_OBJS) $(LIBSKIA) -o out/bench/bench $(LINKER_OPTS) |
| 224 | |
| 225 | ############################################################################## |
| 226 | |
| 227 | # we let tests cheat and see private headers, so we can unittest modules |
| 228 | C_INCLUDES += -Isrc/core |
| 229 | |
| 230 | include tests/tests_files.mk |
| 231 | ifneq ($(SKIA_PDF_SUPPORT),false) |
| 232 | SOURCE += PDFPrimitivesTest.cpp |
| 233 | endif |
| 234 | TESTS_SRCS := $(addprefix tests/, $(SOURCE)) |
| 235 | |
| 236 | TESTS_OBJS := $(TESTS_SRCS:.cpp=.o) |
| 237 | TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS)) |
| 238 | |
| 239 | tests: $(TESTS_OBJS) $(LIBSKIA) |
| 240 | @echo "linking tests..." |
| 241 | $(HIDE)$(GPP) $(TESTS_OBJS) $(LIBSKIA) -o out/tests/tests $(LINKER_OPTS) |
| 242 | |
| 243 | ############################################################################## |
| 244 | |
| 245 | SKIMAGE_SRCS := skimage_main.cpp |
| 246 | |
| 247 | SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS)) |
| 248 | |
| 249 | SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o) |
| 250 | SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS)) |
| 251 | |
| 252 | skimage: $(SKIMAGE_OBJS) $(LIBSKIA) |
| 253 | @echo "linking skimage..." |
| 254 | $(HIDE)$(GPP) $(SKIMAGE_OBJS) $(LIBSKIA) -o out/tools/skimage $(LINKER_OPTS) |
| 255 | |
| 256 | ############################################################################## |
| 257 | |
| 258 | SKDIFF_SRCS := skdiff_main.cpp |
| 259 | SKDIFF_SRCS := $(addprefix tools/, $(SKDIFF_SRCS)) |
| 260 | SKDIFF_OBJS := $(SKDIFF_SRCS:.cpp=.o) |
| 261 | SKDIFF_OBJS := $(addprefix out/, $(SKDIFF_OBJS)) |
| 262 | skdiff: $(SKDIFF_OBJS) out/libskia.a |
| 263 | @echo "linking skdiff..." |
| 264 | $(HIDE)$(GPP) $(SKDIFF_OBJS) out/libskia.a -o out/tools/skdiff $(LINKER_OPTS) |
| 265 | |
| 266 | ############################################################################## |
| 267 | |
| 268 | SKHELLO_SRCS := skhello.cpp |
| 269 | |
| 270 | SKHELLO_SRCS := $(addprefix tools/, $(SKHELLO_SRCS)) |
| 271 | |
| 272 | SKHELLO_OBJS := $(SKHELLO_SRCS:.cpp=.o) |
| 273 | SKHELLO_OBJS := $(addprefix out/, $(SKHELLO_OBJS)) |
| 274 | |
| 275 | skhello: $(SKHELLO_OBJS) $(LIBSKIA) |
| 276 | @echo "linking shkello..." |
| 277 | $(HIDE)$(GPP) $(SKHELLO_OBJS) $(LIBSKIA) -o out/tools/skhello $(LINKER_OPTS) |
| 278 | |
| 279 | ############################################################################## |
| 280 | |
| 281 | include gm/gm_files.mk |
| 282 | GM_SRCS := $(addprefix gm/, $(SOURCE)) |
| 283 | |
| 284 | ifneq ($(SKIA_BUILD_FOR),mac) |
| 285 | GM_SRCS += src/images/SkImageDecoder_libpng.cpp |
| 286 | endif |
| 287 | |
| 288 | GM_OBJS := $(GM_SRCS:.cpp=.o) |
| 289 | GM_OBJS := $(addprefix out/, $(GM_OBJS)) |
| 290 | |
| 291 | gm: $(GM_OBJS) $(LIBSKIA) |
| 292 | @echo "linking gm..." |
| 293 | $(HIDE)$(GPP) $(GM_OBJS) $(LIBSKIA) -o out/gm/gm $(LINKER_OPTS) |
| 294 | |
| 295 | ############################################################################## |
| 296 | |
| 297 | .PHONY: all |
| 298 | all: $ bench gm skimage tests skhello skdiff |
| 299 | |
| 300 | .PHONY: clean |
| 301 | clean: |
| 302 | $(HIDE)rm -rf out |
| 303 | |
| 304 | .PHONY: help |
| 305 | help: |
| 306 | @echo "Targets:" |
| 307 | @echo " <default>: out/libskia.a" |
| 308 | @echo " bench: out/bench/bench" |
| 309 | @echo " gm: out/gm/gm" |
| 310 | @echo " skimage: out/tools/skimage" |
| 311 | @echo " skhello: out/tools/skhello" |
| 312 | @echo " tests: out/tests/tests" |
| 313 | @echo " clean: removes entire out/ directory" |
| 314 | @echo " help: this text" |
| 315 | @echo "Options: (after make, or in bash shell)" |
| 316 | @echo " SKIA_DEBUG=true for debug build" |
| 317 | @echo " SKIA_SHARED=true for shared-object libskia build" |
| 318 | @echo " SKIA_SCALAR=fixed for fixed-point build" |
| 319 | @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)" |
| 320 | @echo " SKIA_PDF_SUPPORT=false to disable the pdf generation backend" |
| 321 | @echo "" |