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 |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 136 | LINKER_OPTS += -lpng -lfreetype -lrt |
epoger@google.com | 1e8e056 | 2011-06-07 14:48:41 +0000 | [diff] [blame] | 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 \ |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 206 | RepeatTileBench.cpp DecodeBench.cpp FPSBench.cpp PathBench.cpp \ |
| 207 | GradientBench.cpp MatrixBench.cpp ScalarBench.cpp \ |
| 208 | BenchTimer.cpp BenchGpuTimer_gl.cpp |
| 209 | |
| 210 | ifeq ($(SKIA_BUILD_FOR),mac) |
| 211 | BENCH_SRCS += BenchSysTimer_mach.cpp |
| 212 | else |
| 213 | BENCH_SRCS += BenchSysTimer_posix.cpp |
| 214 | endif |
epoger@google.com | 1e8e056 | 2011-06-07 14:48:41 +0000 | [diff] [blame] | 215 | |
| 216 | BENCH_SRCS := $(addprefix bench/, $(BENCH_SRCS)) |
| 217 | |
| 218 | # add any optional codecs for this app |
| 219 | ifeq ($(SKIA_BUILD_FOR),mac) |
| 220 | BENCH_SRCS += bench/TextBench.cpp |
| 221 | else |
| 222 | BENCH_SRCS += src/images/SkImageDecoder_libpng.cpp |
| 223 | endif |
| 224 | |
| 225 | BENCH_OBJS := $(BENCH_SRCS:.cpp=.o) |
| 226 | BENCH_OBJS := $(addprefix out/, $(BENCH_OBJS)) |
| 227 | |
| 228 | bench: $(BENCH_OBJS) $(LIBSKIA) |
| 229 | @echo "linking bench..." |
| 230 | $(HIDE)$(GPP) $(BENCH_OBJS) $(LIBSKIA) -o out/bench/bench $(LINKER_OPTS) |
| 231 | |
| 232 | ############################################################################## |
| 233 | |
| 234 | # we let tests cheat and see private headers, so we can unittest modules |
| 235 | C_INCLUDES += -Isrc/core |
| 236 | |
| 237 | include tests/tests_files.mk |
| 238 | ifneq ($(SKIA_PDF_SUPPORT),false) |
| 239 | SOURCE += PDFPrimitivesTest.cpp |
| 240 | endif |
| 241 | TESTS_SRCS := $(addprefix tests/, $(SOURCE)) |
| 242 | |
| 243 | TESTS_OBJS := $(TESTS_SRCS:.cpp=.o) |
| 244 | TESTS_OBJS := $(addprefix out/, $(TESTS_OBJS)) |
| 245 | |
| 246 | tests: $(TESTS_OBJS) $(LIBSKIA) |
| 247 | @echo "linking tests..." |
| 248 | $(HIDE)$(GPP) $(TESTS_OBJS) $(LIBSKIA) -o out/tests/tests $(LINKER_OPTS) |
| 249 | |
| 250 | ############################################################################## |
| 251 | |
| 252 | SKIMAGE_SRCS := skimage_main.cpp |
| 253 | |
| 254 | SKIMAGE_SRCS := $(addprefix tools/, $(SKIMAGE_SRCS)) |
| 255 | |
| 256 | SKIMAGE_OBJS := $(SKIMAGE_SRCS:.cpp=.o) |
| 257 | SKIMAGE_OBJS := $(addprefix out/, $(SKIMAGE_OBJS)) |
| 258 | |
| 259 | skimage: $(SKIMAGE_OBJS) $(LIBSKIA) |
| 260 | @echo "linking skimage..." |
| 261 | $(HIDE)$(GPP) $(SKIMAGE_OBJS) $(LIBSKIA) -o out/tools/skimage $(LINKER_OPTS) |
| 262 | |
| 263 | ############################################################################## |
| 264 | |
| 265 | SKDIFF_SRCS := skdiff_main.cpp |
| 266 | SKDIFF_SRCS := $(addprefix tools/, $(SKDIFF_SRCS)) |
| 267 | SKDIFF_OBJS := $(SKDIFF_SRCS:.cpp=.o) |
| 268 | SKDIFF_OBJS := $(addprefix out/, $(SKDIFF_OBJS)) |
| 269 | skdiff: $(SKDIFF_OBJS) out/libskia.a |
| 270 | @echo "linking skdiff..." |
| 271 | $(HIDE)$(GPP) $(SKDIFF_OBJS) out/libskia.a -o out/tools/skdiff $(LINKER_OPTS) |
| 272 | |
| 273 | ############################################################################## |
| 274 | |
| 275 | SKHELLO_SRCS := skhello.cpp |
| 276 | |
| 277 | SKHELLO_SRCS := $(addprefix tools/, $(SKHELLO_SRCS)) |
| 278 | |
| 279 | SKHELLO_OBJS := $(SKHELLO_SRCS:.cpp=.o) |
| 280 | SKHELLO_OBJS := $(addprefix out/, $(SKHELLO_OBJS)) |
| 281 | |
| 282 | skhello: $(SKHELLO_OBJS) $(LIBSKIA) |
| 283 | @echo "linking shkello..." |
| 284 | $(HIDE)$(GPP) $(SKHELLO_OBJS) $(LIBSKIA) -o out/tools/skhello $(LINKER_OPTS) |
| 285 | |
| 286 | ############################################################################## |
| 287 | |
| 288 | include gm/gm_files.mk |
| 289 | GM_SRCS := $(addprefix gm/, $(SOURCE)) |
| 290 | |
| 291 | ifneq ($(SKIA_BUILD_FOR),mac) |
| 292 | GM_SRCS += src/images/SkImageDecoder_libpng.cpp |
| 293 | endif |
| 294 | |
| 295 | GM_OBJS := $(GM_SRCS:.cpp=.o) |
| 296 | GM_OBJS := $(addprefix out/, $(GM_OBJS)) |
| 297 | |
| 298 | gm: $(GM_OBJS) $(LIBSKIA) |
| 299 | @echo "linking gm..." |
| 300 | $(HIDE)$(GPP) $(GM_OBJS) $(LIBSKIA) -o out/gm/gm $(LINKER_OPTS) |
| 301 | |
| 302 | ############################################################################## |
| 303 | |
| 304 | .PHONY: all |
| 305 | all: $ bench gm skimage tests skhello skdiff |
| 306 | |
| 307 | .PHONY: clean |
| 308 | clean: |
| 309 | $(HIDE)rm -rf out |
| 310 | |
| 311 | .PHONY: help |
| 312 | help: |
| 313 | @echo "Targets:" |
| 314 | @echo " <default>: out/libskia.a" |
| 315 | @echo " bench: out/bench/bench" |
| 316 | @echo " gm: out/gm/gm" |
| 317 | @echo " skimage: out/tools/skimage" |
| 318 | @echo " skhello: out/tools/skhello" |
| 319 | @echo " tests: out/tests/tests" |
| 320 | @echo " clean: removes entire out/ directory" |
| 321 | @echo " help: this text" |
| 322 | @echo "Options: (after make, or in bash shell)" |
| 323 | @echo " SKIA_DEBUG=true for debug build" |
| 324 | @echo " SKIA_SHARED=true for shared-object libskia build" |
| 325 | @echo " SKIA_SCALAR=fixed for fixed-point build" |
| 326 | @echo " SKIA_BUILD_FOR=mac for mac build (e.g. CG for image decoding)" |
| 327 | @echo " SKIA_PDF_SUPPORT=false to disable the pdf generation backend" |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 328 | @echo " SKIA_MESA=true to build with osmesa instead of native GL. |
epoger@google.com | 1e8e056 | 2011-06-07 14:48:41 +0000 | [diff] [blame] | 329 | @echo "" |