|
| 1 | +# |
| 2 | +# Copyright 2012-2015 Chef Software, Inc. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | + |
| 17 | +name "zlib" |
| 18 | +default_version "1.2.8" |
| 19 | + |
| 20 | +version "1.2.8" do |
| 21 | + source md5: "44d667c142d7cda120332623eab69f40" |
| 22 | +end |
| 23 | +version "1.2.6" do |
| 24 | + source md5: "618e944d7c7cd6521551e30b32322f4a" |
| 25 | +end |
| 26 | + |
| 27 | +source url: "http://downloads.sourceforge.net/project/libpng/zlib/#{version}/zlib-#{version}.tar.gz" |
| 28 | + |
| 29 | +license "Zlib" |
| 30 | +license_file "README" |
| 31 | +skip_transitive_dependency_licensing true |
| 32 | + |
| 33 | +relative_path "zlib-#{version}" |
| 34 | + |
| 35 | +build do |
| 36 | + if windows? |
| 37 | + env = with_standard_compiler_flags(with_embedded_path) |
| 38 | + |
| 39 | + patch source: "zlib-windows-relocate.patch", env: env |
| 40 | + |
| 41 | + # We can't use the top-level Makefile. Instead, the developers have made |
| 42 | + # an organic, artisanal, hand-crafted Makefile.gcc for us which takes a few |
| 43 | + # variables. |
| 44 | + env["BINARY_PATH"] = "/bin" |
| 45 | + env["LIBRARY_PATH"] = "/lib" |
| 46 | + env["INCLUDE_PATH"] = "/include" |
| 47 | + env["DESTDIR"] = "#{install_dir}/embedded" |
| 48 | + |
| 49 | + make_args = [ |
| 50 | + "-fwin32/Makefile.gcc", |
| 51 | + "SHARED_MODE=1", |
| 52 | + "CFLAGS=\"#{env['CFLAGS']} -Wall\"", |
| 53 | + "ASFLAGS=\"#{env['CFLAGS']} -Wall\"", |
| 54 | + "LDFLAGS=\"#{env['LDFLAGS']}\"", |
| 55 | + # The win32 makefile for zlib does not handle parallel make correctly. |
| 56 | + # In particular, see its rule for IMPLIB and SHAREDLIB. The ld step in |
| 57 | + # SHAREDLIB will generate both the dll and the dll.a files. The step to |
| 58 | + # strip the dll occurs next but since the dll.a file is already present, |
| 59 | + # make will attempt to link example_d.exe and minigzip_d.exe in parallel |
| 60 | + # with the strip step - causing gcc to freak out when a source file is |
| 61 | + # rewritten part way through the linking stage. |
| 62 | + #"-j #{workers}", |
| 63 | + ] |
| 64 | + |
| 65 | + make(*make_args, env: env) |
| 66 | + make("install", *make_args, env: env) |
| 67 | + else |
| 68 | + # We omit the omnibus path here because it breaks mac_os_x builds by picking |
| 69 | + # up the embedded libtool instead of the system libtool which the zlib |
| 70 | + # configure script cannot handle. |
| 71 | + # TODO: Do other OSes need this? Is this strictly a mac thing? |
| 72 | + env = with_standard_compiler_flags |
| 73 | + |
| 74 | + # Ensure the PATH is still available |
| 75 | + env['PATH'] = ENV['PATH'] |
| 76 | + |
| 77 | + if freebsd? |
| 78 | + # FreeBSD 10+ gets cranky if zlib is not compiled in a |
| 79 | + # position-independent way. |
| 80 | + env["CFLAGS"] << " -fPIC" |
| 81 | + end |
| 82 | + |
| 83 | + configure env: env |
| 84 | + |
| 85 | + make "-j #{workers}", env: env |
| 86 | + make "-j #{workers} install", env: env |
| 87 | + end |
| 88 | +end |
0 commit comments