Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
99 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
# Setting up global constants | ||
CC = ENV['CC'].nil? ? 'clang' : ENV['CC'] | ||
# cpp = ENV['CPP'].nil? ? 'clang++' : ENV['CPP'] | ||
AR = 'ar' | ||
LD = 'ld' | ||
IS_LINUX = `uname -s`.strip == 'Linux' | ||
VERSION = `cat ./VERSION`.strip | ||
|
||
# $ldflags = "-lpthread -L. #{include_env 'LDFLAGS'}".strip | ||
warnings = '-Wall -Wextra -Wconversion' | ||
cflags = "-g -fPIC #{warnings} -std=c99 -I. #{include_env 'CFLAGS'}".strip | ||
|
||
# Expose cflags and Lua for `cflags_for` | ||
CFLAGS = cflags | ||
LUA = 'lua5.1' | ||
|
||
# Settings for LLVM | ||
llvm_config = 'llvm-config' | ||
if `uname -s`.strip == 'Darwin' | ||
llvm_config = "#{`brew --prefix llvm`.strip}/bin/llvm-config" | ||
end | ||
LLVM_CONFIG = llvm_config | ||
LLVM_MODULES = 'core analysis mcjit native' | ||
LLVM_LIBDIR = `#{llvm_config} --libdir`.strip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
def include_env v | ||
ENV[v].to_s | ||
end | ||
|
||
def cflags_for file | ||
basename = File.basename file | ||
flags = CFLAGS | ||
if %w{object.o generator.o exception.o debug.o bootstrap.o}.include? basename | ||
flags += " #{`pkg-config --cflags glib-2.0`.strip}" | ||
end | ||
if basename == 'object.o' && IS_LINUX | ||
flags += ' -I/usr/local/include' | ||
end | ||
# TODO: Refactor to make this unnecessary | ||
if basename == "generator.o" || basename == "bootstrap.o" || basename == "debug.o" | ||
flags += ' -Wno-unused-parameter' | ||
end | ||
if basename == "vm-db.o" || basename == "debug.o" | ||
flags += " -DHVM_VM_DEBUG #{`pkg-config --cflags #{LUA}`.strip}" | ||
end | ||
if basename == "jit-compiler.o" | ||
flags += " "+`#{LLVM_CONFIG} --cflags`.strip | ||
end | ||
# Optimization passes on some objects | ||
if basename =~ /^vm/ || basename == "gc1.o" | ||
flags += ' -O2' | ||
end | ||
return flags | ||
end | ||
|
||
# Search in a few default places for the jemalloc static library | ||
def find_jemalloc | ||
paths = [ | ||
'/usr/local/lib/libjemalloc.a', | ||
'/usr/local/libjemalloc.a' | ||
] | ||
paths.each do |p| | ||
return p if File.exists? p | ||
end | ||
raise 'libjemalloc.a not found' | ||
end |