~dlh/armagetronad/os-x-toolkit

« back to all changes in this revision

Viewing changes to os-x-toolkit.rb

  • Committer: Daniel Lee Harple
  • Date: 2013-08-23 05:41:08 UTC
  • Revision ID: leeharple@gmail.com-20130823054108-cnjeuvanopv29lpw
GLEW 1.10.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
    end
90
90
  }
91
91
 
92
 
  # TODO Install GLEW
93
 
  # libs["GLEW"] = Builder.new { |config, arch|
94
 
  #   archive = fetch("http://prdownloads.sourceforge.net/glew/glew-1.9.0.tgz?download")
95
 
  # }
 
92
  libs["GLEW"] = Builder.new("lib/libGLEW.a") { |config, arch|
 
93
    archive = fetch("http://prdownloads.sourceforge.net/glew/glew-1.10.0.tgz?download")
 
94
    source = expand_tgz(archive)
 
95
    Dir.chdir(source) do
 
96
      # GLEW uses their own Makefile-system. It's easier to compile
 
97
      # it manually rather than try passing the correct flags to their
 
98
      # build system.
 
99
      system(
 
100
        "gcc",
 
101
        "-DGLEW_NO_GLU", "-DGLEW_STATIC",
 
102
        "-O2", "-Wall", "-W", "-Iinclude",
 
103
        "-dynamic", "-fno-common",
 
104
        "-o", "glew.o",
 
105
        "-c", "src/glew.c",
 
106
        *config.cxxflags(arch)
 
107
      )
 
108
      system("ar", "cr", "libGLEW.a", "glew.o") # *config.ldflags(arch)
 
109
 
 
110
      include_dir = install_path(arch, ["include", "GL"])
 
111
      lib_dir = install_path(arch, "lib")
 
112
      FileUtils.mkdir_p(lib_dir) if !File.exist?(lib_dir)
 
113
      FileUtils.mkdir_p(include_dir) if !File.exist?(include_dir)
 
114
 
 
115
      system("install", "-m", "0644", "libGLEW.a", lib_dir)
 
116
      system("install", "-m", "0644", "include/GL/glew.h", include_dir)      
 
117
    end
 
118
  }
96
119
 
97
120
  return libs
98
121
end
203
226
  attr_reader(:archs)
204
227
 
205
228
  def env_variables(arch)
206
 
    ENV["CXXFLAGS"] = cxxflags(arch)
207
 
    ENV["CFLAGS"] = cxxflags(arch)
208
 
    ENV["LDFLAGS"] = ldflags(arch)
 
229
    ENV["CXXFLAGS"] = cxxflags(arch).join(" ")
 
230
    ENV["CFLAGS"] = ENV["CXXFLAGS"]
 
231
    ENV["LDFLAGS"] = ldflags_full(arch).join(" ")
209
232
  end
210
233
 
211
234
  def cxxflags(arch)
212
 
    flags = ["-arch #{arch}"]
213
 
    flags << "-isysroot #{@sdk}" if !@sdk.empty?
 
235
    flags = ["-arch", arch]
 
236
    flags += ["-isysroot", @sdk] if !@sdk.empty?
214
237
    flags << "-mmacosx-version-min=#{@version_min}" if !@version_min.empty?
215
 
    flags.join(" ")
 
238
    return flags
216
239
  end
217
240
 
218
241
  def ldflags(arch)
219
 
    flags = [cxxflags(arch)]
 
242
    flags = []
220
243
    flags << "-Wl,-syslibroot,#{@sdk}" if !@sdk.empty?
221
 
    return flags.join(" ")
 
244
    return flags
 
245
  end
 
246
 
 
247
  def ldflags_full(arch)
 
248
    flags = ldflags(arch)
 
249
    flags += cxxflags(arch)
 
250
    return flags
222
251
  end
223
252
end
224
253