aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/tex-live.rb
blob: b20a95be48e866e3e1392778f586aeabf801ad6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
require 'formula'

class CurlXZDownloadStrategy < CurlDownloadStrategy
  def stage
    # As far as I can tell, the LZMA format does not have any magic header bits that we could use to
    # identify LZMA archives in the CurlDownloadStrategy, so use this awesome hack
    safe_system "lzma -k --force --stdout --decompress #{@dl} | /usr/bin/tar x"
   
    # You could also do this, but it leaves the tar file lying around...
    #safe_system '/usr/local/bin/lzma', '-k', '--force', '--decompress', @dl
    #safe_system '/usr/bin/tar', 'xf', @dl.to_s.gsub( ".lzma", "" )
    chdir
  end
end

class Texmf <Formula
  version '20080822'
  url "http://students.dec.bournemouth.ac.uk/ebarrett/texlive/distfiles/texlive-#{version}-texmf.tar.lzma"
  md5 'fa74072e1344e8390eb156bcda61a8b2'

  def download_strategy
    CurlXZDownloadStrategy
  end
end

class TexLive <Formula
  version '20080816'
  url "http://students.dec.bournemouth.ac.uk/ebarrett/texlive/distfiles/texlive-#{version}-source.tar.lzma"
  #Alternatively (slower):
  #url 'ftp://ftp.openbsd.org/pub/OpenBSD/distfiles/texlive-20080816-source.tar.lzma'
  homepage 'http://www.tug.org/texlive/'
  md5 '554287c3e458da776edd684506048d45'

  depends_on 'lzma'
  depends_on 'icu4c'
  depends_on 'gd'

  def download_strategy
    CurlXZDownloadStrategy
  end
  
  def patches
    # Steal all the TexLive 2008 OpenBSD patches
    patches = [
      "configure",
      "libs_configure",
      "libs_graphite-engine_configure",
      "libs_icu-xetex_Makefile_in",
      # Hijacked: we needed to add a CFLAG to the patch, so I merged this and my change below
      #{}"libs_lua51_Makefile",
      "libs_lua51_lcoco_c",
      "libs_lua51_lcoco_h",
      "texk_afm2pl_Makefile_in",
      "texk_bibtex8_Makefile_in",
      "texk_cjkutils_conv_Makefile_in",
      "texk_cjkutils_hbf2gf_Makefile_in",
      "texk_cjkutils_scripts_Makefile_in",
      "texk_dtl_Makefile_in",
      "texk_dvidvi_Makefile_in",
      "texk_dviljk_Makefile_in",
      "texk_dvipdfm_Makefile_in",
      "texk_dvipng_configure",
      "texk_dvipos_Makefile_in",
      "texk_dvipsk_Makefile_in",
      "texk_gsftopk_Makefile_in",
      "texk_kpathsea_Makefile_in",
      "texk_kpathsea_texmf_cnf",
      "texk_lacheck_Makefile_in",
      "texk_make_man_mk",
      "texk_makeindexk_Makefile_in",
      "texk_musixflx_Makefile_in",
      "texk_ps2pkm_Makefile_in",
      "texk_seetexk_Makefile_in",
      "texk_tetex_Makefile_in",
      "texk_tex4htk_Makefile_in",
      "texk_texlive_Makefile_in",
      "texk_texlive_linked_scripts_texdoc_tlu",
      "texk_ttf2pk_Makefile_in",
      "texk_web2c_Makefile_in",
      "texk_web2c_alephdir_aleph_mk",
      "texk_web2c_configure",
      "texk_web2c_doc_Makefile_in",
      "texk_web2c_luatexdir_luatex_mk",
      "texk_web2c_mpware_Makefile_in",
      "texk_web2c_omegadir_omega_mk",
      "texk_web2c_omegafonts_Makefile_in",
      "texk_web2c_otps_Makefile_in",
      "texk_web2c_pdftexdir_pdftex_mk",
      "texk_xdvik_Makefile_in",
      "texk_xdvipdfmx_Makefile_in",
      "texk_xdvipdfmx_configure",
      "utils_dialog_Makefile_in",
      "utils_tpic2pdftex_Makefile_in"
    ].collect! {|middle| "http://www.openbsd.org/cgi-bin/cvsweb/ports/print/texlive/base/patches/patch-#{middle}?rev=HEAD;content-type=text%2Fplain"}
    # Putting DATA in p0 seemed to cause trouble, so we put nonsense in the filenames and put it in p1
    { :p0 => patches, :p1 => DATA }
  end

  def install
    # Notes:
    # Several OSX-specific files (texk/web2c/xetexdir/XeTeXFontMgr_Mac.mm and others) can't build in 
    # 64 bit mode on OSX, since they use deprecated functions only available when building in 32bit.
    
    ENV.gcc_4_2
    ENV.m32
    ENV.deparallelize
    
    #Some of the makefiles doesn't use CFLAGS during linking, which causes things to break when building as 32bit.
    # Ugly hack to force -m32 always and forever.
    ENV['CC']="gcc-4.2 -m32 -arch i386"
    ENV['CXX']="g++-4.2 -m32 -arch i386"
    # I even had to patch a Makefile since it hardcoded using cc and c++, see below.

    # Is there a way to get these programmatically?
    # no, but they will always be these directories on OS X --mxcl
    x11_libdir = "/usr/X11/lib/"
    x11_includedir = "/usr/X11/include/"
    
    # The build scripts don't create this directory for no apparent reason...
    # It's easier to just do it here than it is to patch the Makefiles
    # Actually, if compilation fails brew thinks that we succeeded because this directory exists. Maybe we should patch the makefiles...
    FileUtils.mkdir_p "#{prefix}/share/man/man5"
    
    build_dir='Work'
    FileUtils.mkdir build_dir
    Dir.chdir build_dir do
      system "../configure", "--prefix=#{prefix}", "--datadir=#{prefix}", \
      "--with-xdvi-x-toolkit=xaw", "--disable-threads", "--with-old-mac-fonts", "--without-xindy", \
      "--x-libraries=#{x11_libdir}", "--x-includes=#{x11_includedir}", \
      "--with-freetype2-libdir=#{x11_libdir}", "--with-freetype2-include=#{x11_includedir}", \
      "--with-pnglib-libdir=#{x11_libdir}", "--with-pnglib-include=#{x11_includedir}", \
      "--with-system-ncurses", "--with-system-freetype2", "--with-system-pnglib", \
      "--with-system-zlib", "--with-system-gd", "--with-system-icu", \
      "--disable-multiplatform", "--without-texinfo", "--without-xdvipdfmx", \
      "--without-texi2html", "--without-psutils"
      
      system "make world"
    end

    Texmf.new.brew{ share.install Dir['*'] }

    # The texlive makefiles are supposed to do this, I don't know why they don't...
    Dir.chdir bin do
      system "PATH=$PATH:#{bin} texlinks -f #{share}/texmf/web2c/fmtutil.cnf"
      system "PATH=$PATH:#{bin} fmtutil-sys --all"
    end
  end
end

# OpenBSD patches:
# http://www.openbsd.org/cgi-bin/cvsweb/ports/print/texlive/

# Notes for below:
# Patch 1: No idea why this declaration is wrong, but we'll go ahead and fix it.
# Patch 2: Slightly modified patch from OpenBSD. Adding the _XOPEN_SOURCE preprocessor flag in 
#   libs/lua51/Makefile undeprecates some things in /usr/include/ucontext.h (Snow Leopard).
# Patch 3: These are hardcoded and do not respect CFLAGS, so force them to use 32bit mode.
__END__
--- nonsense/texk/web2c/xetexdir/XeTeX_ext.h	2009-10-28 02:27:34.000000000 -0700
+++ nonsense/texk/web2c/xetexdir/XeTeX_ext.h	2009-10-28 02:31:38.000000000 -0700
@@ -300,7 +300,7 @@
 
 #ifdef XETEX_MAC
 /* functions in XeTeX_mac.c */
-	void* loadAATfont(ATSFontRef fontRef, integer scaled_size, const char* cp1);
+	void* loadAATfont(ATSFontRef fontRef, long scaled_size, const char* cp1);
 	void DoAtsuiLayout(void* node, int justify);
 	void GetGlyphBBox_AAT(ATSUStyle style, UInt16 gid, GlyphBBox* bbox);
 	float GetGlyphWidth_AAT(ATSUStyle style, UInt16 gid);
  $OpenBSD: patch-libs_lua51_Makefile,v 1.2 2008/12/04 22:29:06 steven Exp $
--- nonsense/libs/lua51/Makefile.orig	Mon Mar 24 15:47:15 2008
+++ nonsense/libs/lua51/Makefile	Sun Oct 26 15:30:26 2008
@@ -8,7 +8,7 @@
 PLAT= none

 CC= gcc
-CFLAGS= -g -O2 -Wall $(XCFLAGS) $(MYCFLAGS) $(COCOFLAGS)
+LOCALCFLAGS= -g -O2 -Wall -D_XOPEN_SOURCE $(MYCFLAGS) $(COCOCFLAGS)
 AR= ar rcu
 RANLIB= ranlib
 RM= rm -f
@@ -77,12 +77,14 @@ clean:
 	$(RM) $(ALL_T) $(ALL_O)

 depend:
-	@$(CC) $(CFLAGS) -MM l*.c print.c
+	@$(CC) $(LOCALCFLAGS) $(CFLAGS) $(XCFLAGS) -MM l*.c print.c

 echo:
 	@echo "PLAT = $(PLAT)"
 	@echo "CC = $(CC)"
+	@echo "LOCALCFLAGS = $(LOCALCFLAGS)"
 	@echo "CFLAGS = $(CFLAGS)"
+	@echo "XCFLAGS = $(XCFLAGS)"
 	@echo "AR = $(AR)"
 	@echo "RANLIB = $(RANLIB)"
 	@echo "RM = $(RM)"
@@ -96,7 +98,7 @@ none:
 	@echo "Please choose a platform: $(PLATS)"

 aix:
-	$(MAKE) a CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"
+	$(MAKE) a CC="xlc" LOCALCFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"

 ansi:
 	$(MAKE) a MYCFLAGS=-DLUA_ANSI
@@ -130,6 +132,10 @@ posix:

 solaris:
 	$(MAKE) a MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"
+
+.c.o:
+	$(CC) $(LOCALCFLAGS) $(CFLAGS) $(XCFLAGS) -c $<
+

 # list targets that do not create files (but not all makes understand .PHONY)
 .PHONY: all $(PLATS) default o a clean depend echo none
--- nonsense/texk/xdv2pdf/Makefile.in.orig	2009-10-28 15:18:25.000000000 -0700
+++ nonsense/texk/xdv2pdf/Makefile.in	2009-10-28 15:18:51.000000000 -0700
@@ -4,8 +4,8 @@
 kpse_include ../make/common.mk
 kpse_include ../make/programs.mk

-CXX = c++
-OBJC = cc
+CXX = c++ -m32 -arch i386
+OBJC = cc -m32 -arch i386
 CXXLD = $(CXX)
 cxx_link_command = $(CXXLD) -o $@ $(LDFLAGS)
 kpathsea_cxx_link = $(LIBTOOL) --mode=link $(cxx_link_command)