Ticket #15996: Portfile.x264

File Portfile.x264, 4.0 KB (added by hvdwolf@…, 16 years ago)

Modified Portfile that does build universally

Line 
1# $Id: Portfile 38598 2008-07-25 12:50:01Z acho@macports.org $
2
3PortSystem 1.0
4
5name            x264
6version         20080724
7revision        1
8categories      multimedia
9platforms       darwin
10maintainers     acho@macports.org
11description     x264 - a free h264/avc encoder
12long_description x264 is a free library for encoding H264/AVC video streams. \
13                The code is written by Laurent Aimar, Eric Petit(OS X), Min \
14                Chen (vfw/nasm), Justin Clay(vfw), Måns Rullgård and Loren \
15                Merritt from scratch. It is released under the terms of the \
16                GPL license.
17homepage        http://www.videolan.org/x264.html
18master_sites    ftp://ftp.videolan.org/pub/videolan/x264/snapshots/
19distname        ${name}-snapshot-${version}-2245
20checksums       sha1 8f3023d82d06b34a609e8c67ace8328e6c01aacb
21use_bzip2       yes
22
23depends_build   bin:svn:subversion port:yasm
24
25configure.args \
26                --enable-pthread --enable-pic
27
28configure.cflags-append -fno-common -read_only_relocs suppress
29
30destroot.args   DIR_INSTALL=${destroot}${prefix}
31
32build.target    default
33
34variant noasm description {disable assembler optimization and remove yasm dep} {
35        depends_build-delete    port:yasm
36        configure.args-append   --disable-asm
37}
38
39variant G5 description {G5 specific optimizations} {
40        configure.cflags-append "-mcpu=970 -mtune=970 -mpowerpc64 -mpowerpc-gpopt -fast -mabi=altivec -maltivec"
41}
42
43set my_universal_archs {i386 ppc}
44set first_arch [lindex ${my_universal_archs} 0]
45
46set my_worksrcpaths ${worksrcpath}
47
48variant universal {
49  set my_worksrcpaths {}
50  foreach arch ${my_universal_archs} {
51    lappend my_worksrcpaths ${workpath}/${arch}
52  }
53
54  post-patch {
55    foreach arch ${my_universal_archs} {
56      if {[string equal ${arch} ${first_arch}]} {
57        move ${worksrcpath} ${workpath}/${first_arch}
58      } else {
59        copy ${workpath}/${first_arch} ${workpath}/${arch}
60      }
61    }
62  }
63  configure {
64    foreach arch ${my_universal_archs} {
65      set my_arch_flag "-arch ${arch}"
66      set my_cflags "${configure.cflags} -isysroot ${sysroot} ${my_arch_flag} -I${prefix}/include -L${prefix}/lib"
67      set my_ldflags "${configure.ldflags} ${my_arch_flag}"
68      if {[string equal ${arch} i386 ]} {
69         set my_configure_args "CC=\"gcc -arch ${arch}\""
70      } else {
71         set my_configure_args "CC=\"gcc -arch ${arch}\" --disable-asm"
72      }
73      system "cd ${workpath}/${arch} && CFLAGS=\"${my_cflags}\" CXXFLAGS=\"${my_cflags}\" LDFLAGS=\"${my_ldflags}\" ${configure.cmd} ${configure.pre_args} ${configure.args} ${my_configure_args}"
74    }
75  }
76
77  build {
78    foreach arch ${my_universal_archs} {
79      system "cd ${workpath}/${arch} && ${build.cmd} ${build.pre_args}"
80      # This was a first look at dylib. Needs some more investigation as I don't know ins&outs of macports
81      #system "cd ${workpath}/${arch} && gcc -dynamiclib -arch ${arch} -o ${workpath}/${arch}/libx264.dylib common/*.o common/${arch}/*.o encoder/*.o"
82    }
83  }
84
85  destroot {
86    system "cd ${workpath}/${first_arch} && ${destroot.cmd} ${destroot.pre_args} ${destroot.post_args}"
87    # leave .dylib and .a for later. Only .a now
88    #foreach lib [list [file readlink ${workpath}/${first_arch}/libx264.dylib] libx264.a] {
89    #  set output_lib ${destroot}${prefix}/lib/${lib}
90    #  set lipo_args {}
91    #  foreach arch ${my_universal_archs} {
92    #    lappend lipo_args -arch ${arch} ${workpath}/${arch}/${lib}
93    #  }
94    #  lappend lipo_args -create -output ${output_lib}
95    #  delete ${output_lib}
96    #  system "lipo ${lipo_args}"
97    #}
98    # Do currently only .a
99    set output_lib ${destroot}${prefix}/lib/libx264.a
100    set lipo_args {}
101    foreach arch ${my_universal_archs} {
102      lappend lipo_args -arch ${arch} ${workpath}/${arch}/libx264.a
103    }
104    lappend lipo_args -create -output ${output_lib}
105    delete ${output_lib}
106    system "lipo ${lipo_args}"
107 
108    set output_bin ${destroot}${prefix}/bin/x264
109    set lipo_args {}
110    foreach arch ${my_universal_archs} {
111      lappend lipo_args -arch ${arch} ${workpath}/${arch}/x264
112    }
113    lappend lipo_args -create -output ${output_bin}
114    delete ${output_bin}
115    system "lipo ${lipo_args}"
116  }
117}
118