diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | Makerules | 18 | ||||
-rwxr-xr-x | ios/MuPDF.xcodeproj/project.pbxproj | 124 | ||||
-rw-r--r-- | ios/build_libs.sh | 47 | ||||
-rw-r--r-- | scripts/cmapdump.c | 3 | ||||
-rw-r--r-- | scripts/fontdump.c | 4 |
6 files changed, 88 insertions, 116 deletions
@@ -2,12 +2,7 @@ build ?= debug -ifneq "$(OS)" "" -OUT := build/$(build)-$(OS) -else -OUT := build/$(build) -endif - +OUT ?= build/$(build) GEN := generated # --- Variables, Commands, etc... --- @@ -81,7 +76,6 @@ $(MUPDF_LIB) : $(addprefix $(OUT)/, $(MUPDF_SRC:%.c=%.o)) $(MUXPS_LIB) : $(addprefix $(OUT)/, $(MUXPS_SRC:%.c=%.o)) libs: $(MUXPS_LIB) $(MUPDF_LIB) $(FITZ_LIB) $(THIRD_LIBS) - @ echo MuPDF/XPS and underlying libraries built # --- Generated CMAP and FONT files --- @@ -85,21 +85,15 @@ CROSSCOMPILE=yes NOX11=yes endif -ifeq "$(OS)" "iphonesimulator" -CC = $(PLATFORM_DEVELOPER_BIN_DIR)/gcc -AR = $(PLATFORM_DEVELOPER_BIN_DIR)/ar -CFLAGS += -arch i386 -isysroot $(SDKROOT) -LDFLAGS += -arch i386 -isysroot $(SDKROOT) -RANLIB_CMD = $(PLATFORM_DEVELOPER_BIN_DIR)/ranlib $@ -CROSSCOMPILE=yes -NOX11=yes -endif +# Most variables when building for iOS are set up in ios/build_libs.sh, +# which is called from the Xcode project as a "Run Script" build step. +# The following section works for both device and simulator builds. -ifeq "$(OS)" "iphoneos" +ifeq "$(OS)" "ios" +# sadly, llvm generates invalid arm code when compiling freetype, +# so no clang or llvm-gcc for us :( CC = $(PLATFORM_DEVELOPER_BIN_DIR)/gcc AR = $(PLATFORM_DEVELOPER_BIN_DIR)/ar -CFLAGS += -arch armv7 -isysroot $(SDKROOT) -LDFLAGS += -arch armv7 -isysroot $(SDKROOT) RANLIB_CMD = $(PLATFORM_DEVELOPER_BIN_DIR)/ranlib $@ CROSSCOMPILE=yes NOX11=yes diff --git a/ios/MuPDF.xcodeproj/project.pbxproj b/ios/MuPDF.xcodeproj/project.pbxproj index 5b4f842d..2e971be5 100755 --- a/ios/MuPDF.xcodeproj/project.pbxproj +++ b/ios/MuPDF.xcodeproj/project.pbxproj @@ -6,33 +6,19 @@ objectVersion = 46; objects = { -/* Begin PBXAggregateTarget section */ - 969E1929141FB5E200189AA3 /* Libraries */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 969E1934141FB62400189AA3 /* Build configuration list for PBXAggregateTarget "Libraries" */; - buildPhases = ( - 96165BEE143B4F3D00699814 /* ShellScript */, - ); - dependencies = ( - ); - name = Libraries; - productName = Libraries; - }; -/* End PBXAggregateTarget section */ - /* Begin PBXBuildFile section */ 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; + 964FF8C1144F618000F5FF22 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 964FF8BA144F618000F5FF22 /* libfreetype.a */; }; + 964FF8C2144F618000F5FF22 /* libjbig2dec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 964FF8BB144F618000F5FF22 /* libjbig2dec.a */; }; + 964FF8C3144F618000F5FF22 /* libjpeg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 964FF8BC144F618000F5FF22 /* libjpeg.a */; }; + 964FF8C4144F618000F5FF22 /* libmupdf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 964FF8BD144F618000F5FF22 /* libmupdf.a */; }; + 964FF8C5144F618000F5FF22 /* libmuxps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 964FF8BE144F618000F5FF22 /* libmuxps.a */; }; + 964FF8C6144F618000F5FF22 /* libopenjpeg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 964FF8BF144F618000F5FF22 /* libopenjpeg.a */; }; + 964FF8C7144F618000F5FF22 /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 964FF8C0144F618000F5FF22 /* libz.a */; }; 968184A3143E251A00374B41 /* libfitz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9681849B143E251A00374B41 /* libfitz.a */; }; - 968184A4143E251A00374B41 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9681849C143E251A00374B41 /* libfreetype.a */; }; - 968184A5143E251A00374B41 /* libjbig2dec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9681849D143E251A00374B41 /* libjbig2dec.a */; }; - 968184A6143E251A00374B41 /* libjpeg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9681849E143E251A00374B41 /* libjpeg.a */; }; - 968184A7143E251A00374B41 /* libmupdf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9681849F143E251A00374B41 /* libmupdf.a */; }; - 968184A8143E251A00374B41 /* libmuxps.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 968184A0143E251A00374B41 /* libmuxps.a */; }; - 968184A9143E251A00374B41 /* libopenjpeg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 968184A1143E251A00374B41 /* libopenjpeg.a */; }; - 968184AA143E251A00374B41 /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 968184A2143E251A00374B41 /* libz.a */; }; 969E1294141FA57800189AA3 /* mupdf_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 969E1293141FA57800189AA3 /* mupdf_icon.png */; }; /* End PBXBuildFile section */ @@ -44,14 +30,14 @@ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; }; 96165BEB143B4F2800699814 /* build_libs.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = build_libs.sh; sourceTree = "<group>"; }; - 9681849B143E251A00374B41 /* libfitz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfitz.a; path = "build/Debug-iphonesimulator/libfitz.a"; sourceTree = "<group>"; }; - 9681849C143E251A00374B41 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfreetype.a; path = "build/Debug-iphonesimulator/libfreetype.a"; sourceTree = "<group>"; }; - 9681849D143E251A00374B41 /* libjbig2dec.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjbig2dec.a; path = "build/Debug-iphonesimulator/libjbig2dec.a"; sourceTree = "<group>"; }; - 9681849E143E251A00374B41 /* libjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjpeg.a; path = "build/Debug-iphonesimulator/libjpeg.a"; sourceTree = "<group>"; }; - 9681849F143E251A00374B41 /* libmupdf.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmupdf.a; path = "build/Debug-iphonesimulator/libmupdf.a"; sourceTree = "<group>"; }; - 968184A0143E251A00374B41 /* libmuxps.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmuxps.a; path = "build/Debug-iphonesimulator/libmuxps.a"; sourceTree = "<group>"; }; - 968184A1143E251A00374B41 /* libopenjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libopenjpeg.a; path = "build/Debug-iphonesimulator/libopenjpeg.a"; sourceTree = "<group>"; }; - 968184A2143E251A00374B41 /* libz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libz.a; path = "build/Debug-iphonesimulator/libz.a"; sourceTree = "<group>"; }; + 964FF8BA144F618000F5FF22 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfreetype.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 964FF8BB144F618000F5FF22 /* libjbig2dec.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libjbig2dec.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 964FF8BC144F618000F5FF22 /* libjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libjpeg.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 964FF8BD144F618000F5FF22 /* libmupdf.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libmupdf.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 964FF8BE144F618000F5FF22 /* libmuxps.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libmuxps.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 964FF8BF144F618000F5FF22 /* libopenjpeg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libopenjpeg.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 964FF8C0144F618000F5FF22 /* libz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libz.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 9681849B143E251A00374B41 /* libfitz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfitz.a; sourceTree = BUILT_PRODUCTS_DIR; }; 969E1293141FA57800189AA3 /* mupdf_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mupdf_icon.png; sourceTree = "<group>"; }; /* End PBXFileReference section */ @@ -64,13 +50,13 @@ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */, 968184A3143E251A00374B41 /* libfitz.a in Frameworks */, - 968184A4143E251A00374B41 /* libfreetype.a in Frameworks */, - 968184A5143E251A00374B41 /* libjbig2dec.a in Frameworks */, - 968184A6143E251A00374B41 /* libjpeg.a in Frameworks */, - 968184A7143E251A00374B41 /* libmupdf.a in Frameworks */, - 968184A8143E251A00374B41 /* libmuxps.a in Frameworks */, - 968184A9143E251A00374B41 /* libopenjpeg.a in Frameworks */, - 968184AA143E251A00374B41 /* libz.a in Frameworks */, + 964FF8C1144F618000F5FF22 /* libfreetype.a in Frameworks */, + 964FF8C2144F618000F5FF22 /* libjbig2dec.a in Frameworks */, + 964FF8C3144F618000F5FF22 /* libjpeg.a in Frameworks */, + 964FF8C4144F618000F5FF22 /* libmupdf.a in Frameworks */, + 964FF8C5144F618000F5FF22 /* libmuxps.a in Frameworks */, + 964FF8C6144F618000F5FF22 /* libopenjpeg.a in Frameworks */, + 964FF8C7144F618000F5FF22 /* libz.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -80,15 +66,15 @@ 19C28FACFE9D520D11CA2CBB /* Products */ = { isa = PBXGroup; children = ( - 9681849B143E251A00374B41 /* libfitz.a */, - 9681849C143E251A00374B41 /* libfreetype.a */, - 9681849D143E251A00374B41 /* libjbig2dec.a */, - 9681849E143E251A00374B41 /* libjpeg.a */, - 9681849F143E251A00374B41 /* libmupdf.a */, - 968184A0143E251A00374B41 /* libmuxps.a */, - 968184A1143E251A00374B41 /* libopenjpeg.a */, - 968184A2143E251A00374B41 /* libz.a */, 1D6058910D05DD3D006BFB54 /* MuPDF.app */, + 9681849B143E251A00374B41 /* libfitz.a */, + 964FF8BD144F618000F5FF22 /* libmupdf.a */, + 964FF8BE144F618000F5FF22 /* libmuxps.a */, + 964FF8BA144F618000F5FF22 /* libfreetype.a */, + 964FF8BB144F618000F5FF22 /* libjbig2dec.a */, + 964FF8BC144F618000F5FF22 /* libjpeg.a */, + 964FF8BF144F618000F5FF22 /* libopenjpeg.a */, + 964FF8C0144F618000F5FF22 /* libz.a */, ); name = Products; sourceTree = "<group>"; @@ -131,6 +117,7 @@ isa = PBXNativeTarget; buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "MuPDF" */; buildPhases = ( + 965A1554144E144F001A6426 /* Build Libraries */, 1D60588D0D05DD3D006BFB54 /* Resources */, 1D60588E0D05DD3D006BFB54 /* Sources */, 1D60588F0D05DD3D006BFB54 /* Frameworks */, @@ -164,7 +151,6 @@ projectRoot = ""; targets = ( 1D6058900D05DD3D006BFB54 /* MuPDF */, - 969E1929141FB5E200189AA3 /* Libraries */, ); }; /* End PBXProject section */ @@ -181,18 +167,19 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 96165BEE143B4F3D00699814 /* ShellScript */ = { + 965A1554144E144F001A6426 /* Build Libraries */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); + name = "Build Libraries"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "sh build_libs.sh\n"; + shellScript = "exec sh build_libs.sh"; }; /* End PBXShellScriptBuildPhase section */ @@ -217,10 +204,8 @@ GCC_OPTIMIZATION_LEVEL = 0; HEADER_SEARCH_PATHS = ..; INFOPLIST_FILE = Info.plist; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)/build/Debug-iphonesimulator\"", - ); + IPHONEOS_DEPLOYMENT_TARGET = 3.0; + LIBRARY_SEARCH_PATHS = "$(inherited)"; PRODUCT_NAME = MuPDF; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -233,11 +218,10 @@ ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; COPY_PHASE_STRIP = YES; + HEADER_SEARCH_PATHS = ..; INFOPLIST_FILE = Info.plist; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)/build/Debug-iphonesimulator\"", - ); + IPHONEOS_DEPLOYMENT_TARGET = 3.0; + LIBRARY_SEARCH_PATHS = "$(inherited)"; PRODUCT_NAME = MuPDF; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -245,27 +229,6 @@ }; name = Release; }; - 969E192A141FB5E200189AA3 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = Libraries; - }; - name = Debug; - }; - 969E192B141FB5E200189AA3 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - PRODUCT_NAME = Libraries; - ZERO_LINK = NO; - }; - name = Release; - }; C01FCF4F08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -305,15 +268,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 969E1934141FB62400189AA3 /* Build configuration list for PBXAggregateTarget "Libraries" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 969E192A141FB5E200189AA3 /* Debug */, - 969E192B141FB5E200189AA3 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; C01FCF4E08A954540054247B /* Build configuration list for PBXProject "MuPDF" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/ios/build_libs.sh b/ios/build_libs.sh index 0a7f74f0..ded12ec7 100644 --- a/ios/build_libs.sh +++ b/ios/build_libs.sh @@ -1,17 +1,44 @@ -#!/bin/sh +#!/bin/bash # Call this script from a "Run Script" target in the Xcode project to -# set up the environment and use the regular makefile to cross compile -# MuPDF and third party libraries. +# cross compile MuPDF and third party libraries using the regular Makefile. +# Also see "iOS" section in Makerules. -# Ensure we have all the generated cmap and font files from a -# regular build. -make -C .. generate +echo Generating cmap and font files +make -C .. generate || exit 1 + +export OS=ios +export build=$(echo $BUILD_STYLE | tr A-Z a-z) + +for ARCH in $ARCHS +do + case $ARCH in + armv6) ARCHFLAGS="-arch armv6 -mno-thumb" ;; + armv7) ARCHFLAGS="-arch armv7 -mthumb" ;; + *) ARCHFLAGS="-arch $ARCH" ;; + esac + + export CFLAGS="$ARCHFLAGS -isysroot $SDKROOT" + export LDFLAGS="$ARCHFLAGS -isysroot $SDKROOT" + export OUT=build/$build-$OS-$ARCH + + echo Building libraries for $ARCH. + make -C .. libs || exit 1 +done + +echo Performing liposuction -OS=$(basename $PLATFORM_DIR | sed s/\.platform// | tr A-Z a-z) -build=$(echo $BUILD_STYLE | tr A-Z a-z) -make -C .. CROSSCOMPILE=yes libs || exit 1 mkdir -p "$BUILT_PRODUCTS_DIR" -cp ../build/$build-$OS/lib*.a "$BUILT_PRODUCTS_DIR" + +for LIB in ../$OUT/lib*.a +do + LIB=$(basename $LIB) + IN="" + for ARCH in $ARCHS + do + IN="$IN ../build/$build-$OS-$ARCH/$LIB" + done + lipo $IN -output $BUILT_PRODUCTS_DIR/$LIB -create +done echo Done. diff --git a/scripts/cmapdump.c b/scripts/cmapdump.c index 16ef1b8a..68a5c3cf 100644 --- a/scripts/cmapdump.c +++ b/scripts/cmapdump.c @@ -142,7 +142,8 @@ main(int argc, char **argv) fprintf(fo, "};\n"); - printf("\t{\"%s\",&cmap_%s},\n", cmap->cmap_name, name); + if (getenv("verbose")) + printf("\t{\"%s\",&cmap_%s},\n", cmap->cmap_name, name); fz_close(fi); } diff --git a/scripts/fontdump.c b/scripts/fontdump.c index e40bf4ab..34d996a4 100644 --- a/scripts/fontdump.c +++ b/scripts/fontdump.c @@ -1,6 +1,7 @@ /* fontdump.c -- an "xxd -i" workalike for dumping binary fonts as source code */ #include <stdio.h> +#include <stdlib.h> #include <string.h> static int @@ -88,7 +89,8 @@ main(int argc, char **argv) len = ftell(fi); fseek(fi, 0, SEEK_SET); - printf("\t{\"%s\",pdf_font_%s,%d},\n", origname, fontname, len); + if (getenv("verbose")) + printf("\t{\"%s\",pdf_font_%s,%d},\n", origname, fontname, len); fprintf(fo, "\n#ifdef HAVE_INCBIN\n"); fprintf(fo, "extern const unsigned char pdf_font_%s[%d];\n", fontname, len); |