| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | # Silently exit if the changes are already applied |
|---|
| 4 | [ -f $1/filter/imagetopdf.c ] && exit 0 |
|---|
| 5 | |
|---|
| 6 | # Copy files |
|---|
| 7 | cp filter/imagetopdf.c $1/filter/ |
|---|
| 8 | cp filter/pdftoijs.cxx $1/filter/ |
|---|
| 9 | cp filter/texttopdf.c $1/filter/ |
|---|
| 10 | cp filter/pdfutils.h $1/filter/ |
|---|
| 11 | cp filter/pdfutils.c $1/filter/ |
|---|
| 12 | cp filter/test_pdf1.c $1/filter/ |
|---|
| 13 | cp filter/test_pdf2.c $1/filter/ |
|---|
| 14 | cp conf/imagetopdf.convs $1/conf/ |
|---|
| 15 | cp conf/imagetopdf.types $1/conf/ |
|---|
| 16 | cp conf/pdftopdf.convs $1/conf/ |
|---|
| 17 | cp conf/pdf.types $1/conf/ |
|---|
| 18 | cp conf/texttopdf.convs $1/conf/ |
|---|
| 19 | cp data/pdf.utf-8.heavy $1/data/ |
|---|
| 20 | cp data/pdf.utf-8.simple $1/data/ |
|---|
| 21 | cp config-scripts/cups-pdf-filters.m4 $1/config-scripts/ |
|---|
| 22 | |
|---|
| 23 | # Copy directories |
|---|
| 24 | cp -r filter/fontembed $1/filter/ |
|---|
| 25 | cp -r pdftopdf $1 |
|---|
| 26 | cp -r pdftoopvp $1 |
|---|
| 27 | |
|---|
| 28 | cd $1 |
|---|
| 29 | |
|---|
| 30 | # Edit configure script |
|---|
| 31 | cp configure.in configure.in.pdf-filters |
|---|
| 32 | cp configure configure.pdf-filters |
|---|
| 33 | cp config.h.in config.h.in.pdf-filters |
|---|
| 34 | perl -p -i -e 's/(sinclude\(config-scripts\/cups-defaults\.m4\))/$1\nsinclude(config-scripts\/cups-pdf-filters.m4)/' configure.in |
|---|
| 35 | aclocal |
|---|
| 36 | autoconf |
|---|
| 37 | perl -p -i -e 's:(\#endif\s*\/\*\s*\!_CUPS_CONFIG_H_\s*\*\/): |
|---|
| 38 | |
|---|
| 39 | /* CUPS Version is 1.1 */ |
|---|
| 40 | \#undef CUPS_1_1 |
|---|
| 41 | |
|---|
| 42 | /* CUPS Version is 1.4 or newer */ |
|---|
| 43 | \#undef CUPS_1_4 |
|---|
| 44 | |
|---|
| 45 | /* Use libjpeg instead of builtin jpeg decoder. */ |
|---|
| 46 | \#undef ENABLE_LIBJPEG |
|---|
| 47 | |
|---|
| 48 | /* Use zlib instead of builtin zlib decoder. */ |
|---|
| 49 | \#undef ENABLE_ZLIB |
|---|
| 50 | |
|---|
| 51 | /* Have FreeType2 include files */ |
|---|
| 52 | \#undef HAVE_FREETYPE_H |
|---|
| 53 | |
|---|
| 54 | /* Define to 1 if you have the <inttypes.h> header file. */ |
|---|
| 55 | \#undef HAVE_INTTYPES_H |
|---|
| 56 | |
|---|
| 57 | /* Define to 1 if you have the "cups" library (-lcups). */ |
|---|
| 58 | \#define HAVE_LIBCUPS 1 |
|---|
| 59 | |
|---|
| 60 | /* Define to 1 if you have the <memory.h> header file. */ |
|---|
| 61 | \#undef HAVE_MEMORY_H |
|---|
| 62 | |
|---|
| 63 | /* have new GfxFontType */ |
|---|
| 64 | \#undef HAVE_NEW_GFX_FONTTYPE |
|---|
| 65 | |
|---|
| 66 | /* Define to 1 if you have the "popen" function. */ |
|---|
| 67 | \#undef HAVE_POPEN |
|---|
| 68 | |
|---|
| 69 | /* Define to 1 if you have the <stdint.h> header file. */ |
|---|
| 70 | \#undef HAVE_STDINT_H |
|---|
| 71 | |
|---|
| 72 | /* Define to 1 if you have the <dirent.h> header file, and it defines "DIR". |
|---|
| 73 | */ |
|---|
| 74 | \#undef HAVE_DIRENT_H |
|---|
| 75 | |
|---|
| 76 | /* Define to 1 if you have the <ndir.h> header file, and it defines "DIR". */ |
|---|
| 77 | \#undef HAVE_NDIR_H |
|---|
| 78 | |
|---|
| 79 | /* Define to 1 if you have the <sys/dir.h> header file, and it defines "DIR". |
|---|
| 80 | */ |
|---|
| 81 | \#undef HAVE_SYS_DIR_H |
|---|
| 82 | |
|---|
| 83 | /* Define to 1 if you have the <sys/ndir.h> header file, and it defines "DIR". |
|---|
| 84 | */ |
|---|
| 85 | \#undef HAVE_SYS_NDIR_H |
|---|
| 86 | |
|---|
| 87 | /* Define to 1 if you have the <zlib.h> header file. */ |
|---|
| 88 | \#undef HAVE_ZLIB_H |
|---|
| 89 | |
|---|
| 90 | /* Parser\:\:Parser has two arguments. */ |
|---|
| 91 | \#undef PARSER_HAS_2_ARGS |
|---|
| 92 | |
|---|
| 93 | /* Define to 1 if you have the "poppler" library (-lpoppler). */ |
|---|
| 94 | \#undef HAVE_LIBPOPPLER |
|---|
| 95 | |
|---|
| 96 | /* New font type enumeration */ |
|---|
| 97 | \#undef FONTTYPE_ENUM2 |
|---|
| 98 | |
|---|
| 99 | /* GlobalParams\:\:GlobalParams has a argument. */ |
|---|
| 100 | \#undef GLOBALPARAMS_HAS_A_ARG |
|---|
| 101 | |
|---|
| 102 | /* Have Stream\:\:getUndecodedStream */ |
|---|
| 103 | \#undef HAVE_GETUNDECODEDSTREAM |
|---|
| 104 | |
|---|
| 105 | /* Have UGooString.h */ |
|---|
| 106 | \#undef HAVE_UGOOSTRING_H |
|---|
| 107 | |
|---|
| 108 | /* Old CharCodeToUnicode\:\:mapToUnicode */ |
|---|
| 109 | \#undef OLD_MAPTOUNICODE |
|---|
| 110 | |
|---|
| 111 | /* Old GfxColorSpace\:\:parse */ |
|---|
| 112 | \#undef OLD_CS_PARSE |
|---|
| 113 | |
|---|
| 114 | /* Poppler uses CMS */ |
|---|
| 115 | \#undef USE_CMS |
|---|
| 116 | |
|---|
| 117 | /* Poppler data dir */ |
|---|
| 118 | \#undef POPPLER_DATADIR |
|---|
| 119 | |
|---|
| 120 | \n$1:' config.h.in |
|---|
| 121 | |
|---|
| 122 | # Edit Makefiles |
|---|
| 123 | cp conf/Makefile conf/Makefile.pdf-filters |
|---|
| 124 | cp filter/Makefile filter/Makefile.pdf-filters |
|---|
| 125 | cp data/Makefile data/Makefile.pdf-filters |
|---|
| 126 | cp Makefile Makefile.pdf-filters |
|---|
| 127 | cp Makedefs.in Makedefs.in.pdf-filters |
|---|
| 128 | perl -p -i -e 's/^(\s*REPLACE\s*=.*)$/$1 imagetopdf.convs imagetopdf.types pdftopdf.convs pdf.types texttopdf.convs/' conf/Makefile |
|---|
| 129 | perl -p -i -e 's/^(\s*FILTERS\s*=\s+)/$1imagetopdf pdftoijs texttopdf /' filter/Makefile |
|---|
| 130 | perl -p -i -e 's/^(\s*OBJS\s*=\s+)/$1imagetopdf.o pdftoijs.o texttopdf.o pdfutils.o /' filter/Makefile |
|---|
| 131 | perl -p -i -e 's/^(\s*CHARSETS\s*=\s+)/$1pdf.utf-8.heavy pdf.utf-8.simple /' data/Makefile |
|---|
| 132 | cat >> filter/Makefile <<EOF |
|---|
| 133 | |
|---|
| 134 | # |
|---|
| 135 | # imagetops |
|---|
| 136 | # |
|---|
| 137 | |
|---|
| 138 | imagetopdf: imagetopdf.o common.o \$(LIBCUPSIMAGE) \\ |
|---|
| 139 | ../cups/\$(LIBCUPS) |
|---|
| 140 | echo Linking \$@... |
|---|
| 141 | \$(CC) \$(LDFLAGS) -o \$@ imagetopdf.o common.o \$(LINKCUPSIMAGE) \\ |
|---|
| 142 | \$(IMGLIBS) \$(LIBS) |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | # |
|---|
| 146 | # pdftoijs |
|---|
| 147 | # |
|---|
| 148 | |
|---|
| 149 | pdftoijs: pdftoijs.o ../cups/\$(LIBCUPS) |
|---|
| 150 | echo Linking \$@... |
|---|
| 151 | \$(CXX) \$(LDFLAGS) -o \$@ pdftoijs.o \\ |
|---|
| 152 | \$(POPPLER_LIBS) \$(IJS_LIBS) |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | # |
|---|
| 156 | # texttopdf |
|---|
| 157 | # |
|---|
| 158 | |
|---|
| 159 | fontembed/libfontembed.a: |
|---|
| 160 | \$(MAKE) -C fontembed |
|---|
| 161 | |
|---|
| 162 | texttopdf: texttopdf.o textcommon.o common.o pdfutils.o fontembed/libfontembed.a \\ |
|---|
| 163 | ../cups/\$(LIBCUPS) |
|---|
| 164 | echo Linking \$@... |
|---|
| 165 | \$(CC) \$(LDFLAGS) -o \$@ texttopdf.o textcommon.o common.o pdfutils.o -Lfontembed -lfontembed \$(LIBS) |
|---|
| 166 | |
|---|
| 167 | EOF |
|---|
| 168 | perl -p -i -e 's/^(\s*DIRS\s*=.*\s+filter\s+)/$1pdftoopvp /' Makefile |
|---|
| 169 | perl -p -i -e 's/^(\s*DIRS\s*=.*\s+filter\s+)/$1pdftopdf /' Makefile |
|---|
| 170 | perl -p -i -e 's/^(\s*LIBS\s*=.*$)/$1\nPOPPLER_LIBS\t=\t\@POPPLER_LIBS\@ \$(LIBS)/' Makedefs.in |
|---|
| 171 | perl -p -i -e 's/^(\s*LIBS\s*=.*$)/$1\nIJS_LIBS\t=\t\@IJS_LIBS\@ \$(LIBS)/' Makedefs.in |
|---|
| 172 | perl -p -i -e 's/^(\s*LIBS\s*=.*$)/$1\nFREETYPE_LIBS\t=\t\@FREETYPE_LIBS\@ \$(LIBS)/' Makedefs.in |
|---|
| 173 | perl -p -i -e 's/^(\s*LIBS\s*=.*$)/$1\nFONTCONFIG_LIBS\t=\t\@FONTCONFIG_LIBS\@ \$(LIBS)/' Makedefs.in |
|---|
| 174 | perl -p -i -e 's/^(\s*ALL_CFLAGS\s*=\s*)/$1-Ifontembed /' Makedefs.in |
|---|
| 175 | perl -p -i -e 's/^(\s*ALL_CXXFLAGS\s*=\s*)/$1-Ioprs -Iopvp -I..\/opvp -I..\/.. /' Makedefs.in |
|---|