Skip to content

Commit

Permalink
Issue #287 - Support building on *BSD
Browse files Browse the repository at this point in the history
- build.rs
  * Default to `gmake` on BSD systems
  * Support `MAKE` variable for pointing to correct `make`
- mk/top_of_makefile.mk
  * Allow target triple on BSD* not to have abi (e.g. x86_64-unknown-freebsd)
- BUILDING.md
  * Add descriptions about `MAKE` variable.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
  • Loading branch information
tatsuya6502 committed Oct 12, 2016
1 parent 5a2c0a2 commit 4102ae7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Note in particular that if you are cross-compiling an x86 build on a 64-bit
version of Linux, then you need to have the proper gcc-multilibs and
g++-multilibs packages or equivalent installed.

On some platforms, you may need to specify `MAKE` variable for pointing to
correct GNU make command. By default, *ring* uses `gmake` on BSD systems, and
`make` on other platforms including Linux and Mac OS X.



This Sucks. What are you doing to fix it?
Expand Down
12 changes: 11 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,17 @@ fn build_c_code(out_dir: &str) -> Result<(), std::env::VarError> {
format!("CMAKE_BUILD_TYPE={}", cmake_build_type),
format!("BUILD_PREFIX={}/", out_dir),
];
run_command_with_args(&"make", &args);
// If $MAKE is given, use it as the make command. If not, use `gmake` for
// BSD systems and `make` for other systems.
let make = env::var_os("MAKE").unwrap_or_else(|| {
let m = if target_triple[2].contains("bsd") {
"gmake"
} else {
"make"
};
std::ffi::OsString::from(m)
});
run_command_with_args(&make, &args);
} else {
let arch = target_triple[0];
let (platform, optional_amd64) = match arch {
Expand Down
7 changes: 6 additions & 1 deletion mk/top_of_makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ TARGET_ABI = macho
# Set the correct VENDOR, SYS and ABI when building for Android.
else ifeq ($(findstring linux-android,$(TARGET_VENDOR)-$(TARGET_SYS)),linux-android)
TARGET_ABI = $(TARGET_SYS)
TARGET_VENDOR = unknow
TARGET_VENDOR = unknown
TARGET_SYS = linux
else

# If we find `bsd` in the target system, we can assume a target triple is OK,
# so skip the error here.
ifeq (,$(findstring bsd,$(TARGET_SYS)))
define NEWLINE


Expand All @@ -58,6 +62,7 @@ $(error TARGET must be of the form \
NOTE: Use "i586" instead of "x86")
endif
endif
endif

# XXX: Apple's toolchain fails to link when the |-target| arch is "x86_64",
# so just skip -target on Darwin for now.
Expand Down

0 comments on commit 4102ae7

Please sign in to comment.