# GNU Makefile for third party libraries used by MuPDF # # If thirdparty libraries are supplied, they will be built as # static libraries. # # Use 'git submodule init' and 'git submodule update' to check # out the thirdparty libraries from git. FREETYPE_DIR := thirdparty/freetype JBIG2DEC_DIR := thirdparty/jbig2dec JPEG_DIR := thirdparty/jpeg OPENJPEG_DIR := thirdparty/openjpeg OPENSSL_DIR := thirdparty/openssl ZLIB_DIR := thirdparty/zlib # --- V8 --- # # V8 is too big to be used as a submodule. # V8_DIR := $(wildcard thirdparty/v8*) ifneq "$(V8_DIR)" "" CFLAGS += -I$(V8_DIR)/include ifeq "$(build)" "release" V8LIB_CHOICE := release else ifeq "$(build)" "profile" V8LIB_CHOICE := release else V8LIB_CHOICE := debug endif # If you are building for 32bit linux use V8_ARCH=ia32 # MacOSX has a 64bit kernel, but a 32 bit userspace. ifeq "$(OS)" "Darwin" V8_ARCH ?= ia32 V8LIBS = -L$(V8_DIR)/out-mac/$(V8_ARCH).$(V8LIB_CHOICE)/ -lv8_base -lv8_snapshot else V8_ARCH ?= x64 V8LIBS = -L$(V8_DIR)/out/$(V8_ARCH).$(V8LIB_CHOICE)/obj.target/tools/gyp -lv8_base -lv8_snapshot -lpthread endif V8_PRESENT := 1 else V8_PRESENT := 0 endif # --- FreeType 2 --- ifneq "$(wildcard $(FREETYPE_DIR)/README)" "" FREETYPE_LIB := $(OUT)/libfreetype.a FREETYPE_SRC := \ ftbase.c \ ftbbox.c \ ftbitmap.c \ ftgasp.c \ ftglyph.c \ ftinit.c \ ftstroke.c \ ftsynth.c \ ftsystem.c \ fttype1.c \ ftxf86.c \ cff.c \ psaux.c \ pshinter.c \ psnames.c \ raster.c \ sfnt.c \ smooth.c \ truetype.c \ type1.c \ type1cid.c \ $(FREETYPE_LIB): $(addprefix $(OUT)/ft_, $(FREETYPE_SRC:%.c=%.o)) FT_CFLAGS := -DFT2_BUILD_LIBRARY -DDARWIN_NO_CARBON \ '-DFT_CONFIG_MODULES_H="slimftmodules.h"' \ '-DFT_CONFIG_OPTIONS_H="slimftoptions.h"' $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/base/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/cff/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/cid/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/psaux/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/pshinter/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/psnames/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/raster/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/smooth/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/sfnt/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/truetype/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) $(OUT)/ft_%.o: $(FREETYPE_DIR)/src/type1/%.c | $(OUT) $(CC_CMD) $(FT_CFLAGS) FREETYPE_CFLAGS := -I$(FREETYPE_DIR)/include else FREETYPE_CFLAGS := $(SYS_FREETYPE_CFLAGS) FREETYPE_LIBS := $(SYS_FREETYPE_LIBS) endif # --- JBIG2DEC --- ifneq "$(wildcard $(JBIG2DEC_DIR)/README)" "" JBIG2DEC_LIB := $(OUT)/libjbig2dec.a JBIG2DEC_SRC := \ jbig2.c \ jbig2_arith.c \ jbig2_arith_iaid.c \ jbig2_arith_int.c \ jbig2_generic.c \ jbig2_halftone.c \ jbig2_huffman.c \ jbig2_image.c \ jbig2_metadata.c \ jbig2_mmr.c \ jbig2_page.c \ jbig2_refinement.c \ jbig2_segment.c \ jbig2_symbol_dict.c \ jbig2_text.c \ $(JBIG2DEC_LIB): $(addprefix $(OUT)/, $(JBIG2DEC_SRC:%.c=%.o)) $(OUT)/%.o: $(JBIG2DEC_DIR)/%.c | $(OUT) $(CC_CMD) -DHAVE_STDINT_H JBIG2DEC_CFLAGS := -I$(JBIG2DEC_DIR) else JBIG2DEC_CFLAGS := $(SYS_JBIG2DEC_CFLAGS) JBIG2DEC_LIBS := $(SYS_JBIG2DEC_LIBS) endif # --- JPEG library from IJG --- ifneq "$(wildcard $(JPEG_DIR)/README)" "" JPEG_LIB := $(OUT)/libjpeg.a JPEG_SRC := \ jaricom.c \ jcomapi.c \ jdapimin.c \ jdapistd.c \ jdarith.c \ jdatadst.c \ jdatasrc.c \ jdcoefct.c \ jdcolor.c \ jddctmgr.c \ jdhuff.c \ jdinput.c \ jdmainct.c \ jdmarker.c \ jdmaster.c \ jdmerge.c \ jdpostct.c \ jdsample.c \ jdtrans.c \ jerror.c \ jfdctflt.c \ jfdctfst.c \ jfdctint.c \ jidctflt.c \ jidctfst.c \ jidctint.c \ jmemmgr.c \ jmemnobs.c \ jquant1.c \ jquant2.c \ jutils.c \ $(JPEG_LIB): $(addprefix $(OUT)/jpeg_, $(JPEG_SRC:%.c=%.o)) $(OUT)/jpeg_%.o: $(JPEG_DIR)/%.c | $(OUT) $(CC_CMD) -Dmain=xxxmain JPEG_CFLAGS := -I$(JPEG_DIR) else JPEG_CFLAGS := $(SYS_JPEG_CFLAGS) JPEG_LIBS := $(SYS_JPEG_LIBS) endif # --- OpenJPEG --- ifneq "$(wildcard $(OPENJPEG_DIR)/README)" "" OPENJPEG_LIB := $(OUT)/libopenjpeg.a OPENJPEG_SRC := \ bio.c \ cidx_manager.c \ cio.c \ dwt.c \ event.c \ function_list.c \ image.c \ invert.c \ j2k.c \ jp2.c \ mct.c \ mqc.c \ openjpeg.c \ opj_clock.c \ phix_manager.c \ pi.c \ ppix_manager.c \ raw.c \ t1.c \ t2.c \ tcd.c \ tgt.c \ thix_manager.c \ tpix_manager.c \ $(OPENJPEG_LIB): $(addprefix $(OUT)/opj_, $(OPENJPEG_SRC:%.c=%.o)) $(OUT)/opj_%.o: $(OPENJPEG_DIR)/src/lib/openjp2/%.c | $(OUT) $(CC_CMD) -DOPJ_STATIC -DOPJ_HAVE_STDINT_H OPENJPEG_CFLAGS += -I$(OPENJPEG_DIR)/src/lib/openjp2 else OPENJPEG_CFLAGS := $(SYS_OPENJPEG_CFLAGS) OPENJPEG_LIBS := $(SYS_OPENJPEG_LIBS) endif # --- ZLIB --- ifneq "$(wildcard $(ZLIB_DIR)/README)" "" ZLIB_LIB := $(OUT)/libz.a ZLIB_SRC := \ adler32.c \ compress.c \ crc32.c \ deflate.c \ inffast.c \ inflate.c \ inftrees.c \ trees.c \ uncompr.c \ zutil.c \ $(ZLIB_LIB): $(addprefix $(OUT)/zlib_, $(ZLIB_SRC:%.c=%.o)) $(OUT)/zlib_%.o: $(ZLIB_DIR)/%.c | $(OUT) $(CC_CMD) -Dverbose=-1 ZLIB_CFLAGS := -I$(ZLIB_DIR) else ZLIB_CFLAGS := $(SYS_ZLIB_CFLAGS) ZLIB_LIBS := $(SYS_ZLIB_LIBS) endif # --- OpenSSL --- ifneq "$(wildcard $(OPENSSL_DIR)/README)" "" OPENSSL_LIB := $(OUT)/libcrypto.a OPENSSL_DIR_MAK := $(OPENSSL_DIR)/Makefile OPENSSL_DIR_LIB := $(OPENSSL_DIR)/libcrypto.a $(OPENSSL_DIR_MAK): cd $(OPENSSL_DIR) && ./config no-threads no-zlib no-shared no-asm no-dso $(OPENSSL_DIR_LIB): $(OPENSSL_DIR_MAK) $(MAKE) -C $(OPENSSL_DIR) build_crypto $(OPENSSL_LIB): $(OPENSSL_DIR_LIB) | $(OUT) cp $(OPENSSL_DIR_LIB) $(OPENSSL_LIB) openssl-clean: $(MAKE) -C $(OPENSSL_DIR) clean rm -f thirdparty/openssl/Makefile thirdparty/openssl/libcrypto.a OPENSSL_CFLAGS := -DHAVE_OPENSSL -I$(OPENSSL_DIR)/include else OPENSSL_CFLAGS := $(SYS_OPENSSL_CFLAGS) OPENSSL_LIBS := $(SYS_OPENSSL_LIBS) endif # --- X11 --- ifeq "$(NOX11)" "" X11_CFLAGS := $(SYS_X11_CFLAGS) X11_LIBS := $(SYS_X11_LIBS) else X11_CFLAGS := X11_LIBS := endif