aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/ghostscript.rb
blob: 195e921deb624707ed61d226f2cbd82683b9fd0a (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
require 'formula'

class Ghostscript < Formula
  homepage 'http://www.ghostscript.com/'

  stable do
    url 'http://downloads.ghostscript.com/public/ghostscript-9.14.tar.gz'
    sha1 '85001be316ebc11a6060ae7e208fe08dcbfd70ae'

    patch :DATA # Uncomment OS X-specific make vars
  end

  bottle do
    revision 1
    sha1 "308a8f34a919cf8b7aaa919b74aa3bc7606cf24f" => :mavericks
    sha1 "db1b4c91a40cedba2386ced95bd63f9bcb832efa" => :mountain_lion
    sha1 "b63f8d414e7e07ac554c5869385e7cb657c3a26a" => :lion
  end

  head do
    url 'git://git.ghostscript.com/ghostpdl.git'

    resource 'djvu' do
      url 'git://git.code.sf.net/p/djvu/gsdjvu-git'
    end

    depends_on :autoconf
    depends_on :automake
    depends_on :libtool

    # Uncomment OS X-specific make vars
    patch do
      url "https://gist.githubusercontent.com/jacknagel/9559501/raw/9709b3234cc888d29f717838650d29e7062da917/gs.patch"
      sha1 "65c99df4f0d57368a086154d34722f5c4b9c84cc"
    end
  end

  option 'with-djvu', 'Build drivers for DjVU file format'

  depends_on 'pkg-config' => :build
  depends_on 'jpeg'
  depends_on 'libtiff'
  depends_on 'jbig2dec'
  depends_on 'little-cms2'
  depends_on 'libpng'
  depends_on :x11 => ['2.7.2', :optional]
  depends_on 'djvulibre' if build.with? 'djvu'
  depends_on 'freetype'

  conflicts_with 'gambit-scheme', :because => 'both install `gsc` binaries'

  # http://sourceforge.net/projects/gs-fonts/
  resource 'fonts' do
    url 'https://downloads.sourceforge.net/project/gs-fonts/gs-fonts/8.11%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-8.11.tar.gz'
    sha1 '2a7198e8178b2e7dba87cb5794da515200b568f5'
  end

  # http://djvu.sourceforge.net/gsdjvu.html
  resource 'djvu' do
    url 'https://downloads.sourceforge.net/project/djvu/GSDjVu/1.5/gsdjvu-1.5.tar.gz'
    sha1 'c7d0677dae5fe644cf3d714c04b3c2c343906342'
  end

  def move_included_source_copies
    # If the install version of any of these doesn't match
    # the version included in ghostscript, we get errors
    # Taken from the MacPorts portfile - http://bit.ly/ghostscript-portfile
    renames = %w{freetype jbig2dec jpeg libpng tiff}
    renames.each { |lib| mv lib, "#{lib}_local" }
  end

  def install
    src_dir = build.head? ? "gs" : "."

    resource('djvu').stage do
      inreplace 'gdevdjvu.c', /#include "gserror.h"/, ''
      (buildpath+'base').install 'gdevdjvu.c'
      (buildpath+'lib').install 'ps2utf8.ps'
      ENV['EXTRA_INIT_FILES'] = 'ps2utf8.ps'
      (buildpath/'devices/contrib.mak').open('a') { |f| f.write(File.read('gsdjvu.mak')) }
    end if build.with? 'djvu'

    cd src_dir do
      move_included_source_copies
      args = %W[
        --prefix=#{prefix}
        --disable-cups
        --disable-compile-inits
        --disable-gtk
        --with-system-libtiff
      ]
      args << '--without-x' if build.without? 'x11'

      if build.head?
        system './autogen.sh', *args
      else
        system './configure', *args
      end

      # versioned stuff in main tree is pointless for us
      inreplace 'Makefile', '/$(GS_DOT_VERSION)', ''

      inreplace 'Makefile' do |s|
        s.change_make_var!('DEVICE_DEVS17','$(DD)djvumask.dev $(DD)djvusep.dev')
      end if build.with? 'djvu'

      # Install binaries and libraries
      system 'make', 'install'
      system 'make', 'install-so'
    end

    (share+'ghostscript/fonts').install resource('fonts')

    (man+'de').rmtree
  end
end

__END__
diff --git a/base/unix-dll.mak b/base/unix-dll.mak
index ae2d7d8..4f4daed 100644
--- a/base/unix-dll.mak
+++ b/base/unix-dll.mak
@@ -64,12 +64,12 @@ GS_SONAME_MAJOR_MINOR=$(GS_SONAME_BASE)$(GS_SOEXT)$(SO_LIB_VERSION_SEPARATOR)$(G
 
 
 # MacOS X
-#GS_SOEXT=dylib
-#GS_SONAME=$(GS_SONAME_BASE).$(GS_SOEXT)
-#GS_SONAME_MAJOR=$(GS_SONAME_BASE).$(GS_VERSION_MAJOR).$(GS_SOEXT)
-#GS_SONAME_MAJOR_MINOR=$(GS_SONAME_BASE).$(GS_VERSION_MAJOR).$(GS_VERSION_MINOR).$(GS_SOEXT)
+GS_SOEXT=dylib
+GS_SONAME=$(GS_SONAME_BASE).$(GS_SOEXT)
+GS_SONAME_MAJOR=$(GS_SONAME_BASE).$(GS_VERSION_MAJOR).$(GS_SOEXT)
+GS_SONAME_MAJOR_MINOR=$(GS_SONAME_BASE).$(GS_VERSION_MAJOR).$(GS_VERSION_MINOR).$(GS_SOEXT)
 #LDFLAGS_SO=-dynamiclib -flat_namespace
-#LDFLAGS_SO_MAC=-dynamiclib -install_name $(GS_SONAME_MAJOR_MINOR)
+LDFLAGS_SO_MAC=-dynamiclib -install_name __PREFIX__/lib/$(GS_SONAME_MAJOR_MINOR)
 #LDFLAGS_SO=-dynamiclib -install_name $(FRAMEWORK_NAME)
 
 GS_SO=$(BINDIR)/$(GS_SONAME)

"w"> all phones), and all of the template code was located in the `index.html` file. The next step in building the app is to add a view that will show detailed information about each of the devices in our list. To add the detailed view, we could expand the `index.html` file to contain template code for both views, but that would get messy very quickly. Instead, we are going to turn the `index.html` template into what we call a "layout template". This is a template that is common for all views in our application. Other "partial templates" are then included into this layout template depending on the current "route" the view that is currently displayed to the user. Application routes in Angular are declared via the {@link api/ngRoute.$routeProvider $routeProvider}, which is the provider of the {@link api/ngRoute.$route $route service}. This service makes it easy to wire together controllers, view templates, and the current URL location in the browser. Using this feature we can implement {@link http://en.wikipedia.org/wiki/Deep_linking deep linking}, which lets us utilize the browser's history (back and forward navigation) and bookmarks. ### A Note About DI, Injector and Providers As you {@link tutorial/step_05 noticed}, {@link guide/di dependency injection} (DI) is the core feature of AngularJS, so it's important for you to understand a thing or two about how it works. When the application bootstraps, Angular creates an injector that will be used for all DI stuff in this app. The injector itself doesn't know anything about what `$http` or `$route` services do, in fact it doesn't even know about the existence of these services unless it is configured with proper module definitions. The sole responsibilities of the injector are to load specified module definition(s), register all service providers defined in these modules, and when asked, inject a specified function with dependencies (services) that it lazily instantiates via their providers. Providers are objects that provide (create) instances of services and expose configuration APIs that can be used to control the creation and runtime behavior of a service. In case of the `$route` service, the `$routeProvider` exposes APIs that allow you to define routes for your application. Angular modules solve the problem of removing global state from the application and provide a way of configuring the injector. As opposed to AMD or require.js modules, Angular modules don't try to solve the problem of script load ordering or lazy script fetching. These goals are totally independent and both module systems can live side by side and fulfil their goals. ## The App Module __`app/js/app.js`:__ <pre> angular.module('phonecat', []). config(['$routeProvider', function($routeProvider) { $routeProvider. when('/phones', {templateUrl: 'partials/phone-list.html', controller: PhoneListCtrl}). when('/phones/:phoneId', {templateUrl: 'partials/phone-detail.html', controller: PhoneDetailCtrl}). otherwise({redirectTo: '/phones'}); }]); </pre> In order to configure our application with routes, we need to create a module for our application. We call this module `phonecat` and using the `config` API we request the `$routeProvider` to be injected into our config function and use `$routeProvider.when` API to define our routes. Note that during the injector configuration phase, the providers can be injected as well, but they will not be available for injection once the injector is created and starts creating service instances. Our application routes were defined as follows: * The phone list view will be shown when the URL hash fragment is `/phones`. To construct this view, Angular will use the `phone-list.html` template and the `PhoneListCtrl` controller. * The phone details view will be shown when the URL hash fragment matches '/phone/:phoneId', where `:phoneId` is a variable part of the URL. To construct the phone details view, angular will use the `phone-detail.html` template and the `PhoneDetailCtrl` controller. We reused the `PhoneListCtrl` controller that we constructed in previous steps and we added a new, empty `PhoneDetailCtrl` controller to the `app/js/controllers.js` file for the phone details view. The statement `$route.otherwise({redirectTo: '/phones'})` triggers a redirection to `/phones` when the browser address doesn't match either of our routes. Note the use of the `:phoneId` parameter in the second route declaration. The `$route` service uses the route declaration `'/phones/:phoneId'` as a template that is matched against the current URL. All variables defined with the `:` notation are extracted into the {@link api/ngRoute.$routeParams $routeParams} object. In order for our application to bootstrap with our newly created module we'll also need to specify the module name as the value of the {@link api/ng.directive:ngApp ngApp} directive: __`app/index.html`:__ <pre> <!doctype html> <html lang="en" ng-app="phonecat"> ... </pre> ## Controllers __`app/js/controllers.js`:__ <pre> ... function PhoneDetailCtrl($scope, $routeParams) { $scope.phoneId = $routeParams.phoneId; } //PhoneDetailCtrl.$inject = ['$scope', '$routeParams']; </pre> ## Template The `$route` service is usually used in conjunction with the {@link api/ngRoute.directive:ngView ngView} directive. The role of the `ngView` directive is to include the view template for the current route into the layout template, which makes it a perfect fit for our `index.html` template. __`app/index.html`:__ <pre> <html lang="en" ng-app="phonecat"> <head> ... <script src="lib/angular/angular.js"></script> <script src="js/app.js"></script> <script src="js/controllers.js"></script> </head> <body> <div ng-view></div> </body> </html> </pre> Note that we removed most of the code in the `index.html` template and replaced it with a single line containing a div with the `ng-view` attribute. The code that we removed was placed into the `phone-list.html` template: __`app/partials/phone-list.html`:__ <pre> <div class="container-fluid"> <div class="row-fluid"> <div class="span2"> <!--Sidebar content--> Search: <input ng-model="query"> Sort by: <select ng-model="orderProp"> <option value="name">Alphabetical</option> <option value="age">Newest</option> </select> </div> <div class="span10"> <!--Body content--> <ul class="phones"> <li ng-repeat="phone in phones | filter:query | orderBy:orderProp" class="thumbnail"> <a href="#/phones/{{phone.id}}" class="thumb"><img ng-src="{{phone.imageUrl}}"></a> <a href="#/phones/{{phone.id}}">{{phone.name}}</a> <p>{{phone.snippet}}</p> </li> </ul> </div> </div> </div> </pre> <div style="display:none"> TODO! <img class="diagram" src="img/tutorial/tutorial_07_final.png"> </div> We also added a placeholder template for the phone details view: __`app/partials/phone-detail.html`:__ <pre> TBD: detail view for {{phoneId}} </pre> Note how we are using `phoneId` model defined in the `PhoneDetailCtrl` controller. ## Test To automatically verify that everything is wired properly, we wrote end-to-end tests that navigate to various URLs and verify that the correct view was rendered. <pre> ... it('should redirect index.html to index.html#/phones', function() { browser().navigateTo('../../app/index.html'); expect(browser().location().url()).toBe('/phones'); }); ... describe('Phone detail view', function() { beforeEach(function() { browser().navigateTo('../../app/index.html#/phones/nexus-s'); }); it('should display placeholder page with phoneId', function() { expect(binding('phoneId')).toBe('nexus-s'); }); }); </pre> You can now rerun `./scripts/e2e-test.sh` or refresh the browser tab with the end-to-end test runner to see the tests run, or you can see them running on {@link http://angular.github.com/angular-phonecat/step-7/test/e2e/runner.html Angular's server}. # Experiments * Try to add an `{{orderProp}}` binding to `index.html`, and you'll see that nothing happens even when you are in the phone list view. This is because the `orderProp` model is visible only in the scope managed by `PhoneListCtrl`, which is associated with the `<div ng-view>` element. If you add the same binding into the `phone-list.html` template, the binding will work as expected. <div style="display: none"> * In `PhoneCatCtrl`, create a new model called "`hero`" with `this.hero = 'Zoro'`. In `PhoneListCtrl` let's shadow it with `this.hero = 'Batman'`, and in `PhoneDetailCtrl` we'll use `this.hero = "Captain Proton"`. Then add the `<p>hero = {{hero}}</p>` to all three of our templates (`index.html`, `phone-list.html`, and `phone-detail.html`). Open the app and you'll see scope inheritance and model property shadowing do some wonders. </div> # Summary With the routing set up and the phone list view implemented, we're ready to go to {@link step_08 step 8} to implement the phone details view. <ul doc-tutorial-nav="7"></ul>