aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/freeimage.rb
blob: 1aba29884bdee379d2f837e87715c70415088a82 (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
require 'formula'

class FreeimageHttpDownloadStrategy <CurlDownloadStrategy
  def stage
    # need to convert newlines or patch chokes
    safe_system '/usr/bin/unzip', '-aqq', @dl
    chdir
  end
end

class Freeimage <Formula
  url 'http://downloads.sourceforge.net/project/freeimage/Source%20Distribution/3.13.0/FreeImage3130.zip'
  md5 '5f64fd50ce18833edc27cf55d90c12c3'
  homepage 'http://sf.net/projects/freeimage'

  def download_strategy
    FreeimageHttpDownloadStrategy
  end

  def patches
    DATA
  end

  def install
    system "gnumake -f Makefile.gnu"
    system "gnumake -f Makefile.gnu install PREFIX=#{prefix}"
  end
end

__END__
--- old/Makefile.gnu	2009-07-27 20:35:26.000000000 -0400
+++ new/Makefile.gnu	2009-11-16 10:53:33.000000000 -0300
@@ -5,8 +5,9 @@
 
 # General configuration variables:
 DESTDIR ?= /
-INCDIR ?= $(DESTDIR)/usr/include
-INSTALLDIR ?= $(DESTDIR)/usr/lib
+PREFIX ?= /usr/local
+INCDIR ?= $(DESTDIR)$(PREFIX)/include
+INSTALLDIR ?= $(DESTDIR)$(PREFIX)/lib
 
 # Converts cr/lf to just lf
 DOS2UNIX = dos2unix
@@ -27,11 +28,10 @@
 
 TARGET  = freeimage
 STATICLIB = lib$(TARGET).a
-SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).so
-LIBNAME	= lib$(TARGET).so
-VERLIBNAME = $(LIBNAME).$(VER_MAJOR)
+SHAREDLIB = lib$(TARGET).$(VER_MAJOR).$(VER_MINOR).dylib
+LIBNAME	= lib$(TARGET).dylib
 HEADER = Source/FreeImage.h
-
+LIBTOOL ?= libtool
 
 
 default: all
@@ -40,7 +40,7 @@
 
 dist: FreeImage
 	cp *.a Dist
-	cp *.so Dist
+	cp *.dylib Dist
 	cp Source/FreeImage.h Dist
 
 dos2unix:
@@ -55,16 +55,17 @@
 	$(CXX) $(CXXFLAGS) -c $< -o $@
 
 $(STATICLIB): $(MODULES)
-	$(AR) r $@ $(MODULES)
+	$(LIBTOOL) -static -o $@ $(MODULES)
 
 $(SHAREDLIB): $(MODULES)
-	$(CC) -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
+	$(CXX) -dynamiclib -install_name $(LIBNAME) -current_version $(VER_MAJOR).$(VER_MINOR) -compatibility_version $(VER_MAJOR) -o $@ $(MODULES)
 
 install:
 	install -d $(INCDIR) $(INSTALLDIR)
-	install -m 644 -o root -g root $(HEADER) $(INCDIR)
-	install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
-	install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
+	install -m 644 $(HEADER) $(INCDIR)
+	install -m 644 $(STATICLIB) $(INSTALLDIR)
+	install -m 755 $(SHAREDLIB) $(INSTALLDIR)
+	ln -s $(SHAREDLIB) $(INSTALLDIR)/$(LIBNAME)
 
 clean:
 	rm -f core Dist/*.* u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)