Skip to content

Commit

Permalink
Merge pull request #28 from mklarqvist/dev
Browse files Browse the repository at this point in the history
Fix build for OSX-based machines.
  • Loading branch information
mklarqvist authored Apr 25, 2019
2 parents eef5fce + ea07115 commit 0e816bc
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 26 deletions.
115 changes: 104 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Control file for continuous integration testing at http://travis-ci.org/
language: cpp
dist: trusty

matrix:
include:
# works on Precise and Trusty
Expand All @@ -20,7 +21,7 @@ matrix:
- libcurl4-openssl-dev
- liblz-dev
- libbz2-dev
- liblzma-dev
- liblzma-dev
env:
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
compiler: gcc
Expand Down Expand Up @@ -66,6 +67,50 @@ matrix:
env:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
compiler: gcc

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
- pkg-config
- libncurses5-dev
- libncursesw5-dev
- zlib1g-dev
- libssl-dev
- liblz4-dev
- libcurl4-openssl-dev
- liblz-dev
- libbz2-dev
- liblzma-dev
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
compiler: gcc

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-8
- pkg-config
- libncurses5-dev
- libncursesw5-dev
- zlib1g-dev
- libssl-dev
- liblz4-dev
- libcurl4-openssl-dev
- liblz-dev
- libbz2-dev
- liblzma-dev
env:
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
compiler: gcc

# works on Precise and Trusty
- os: linux
Expand Down Expand Up @@ -196,26 +241,74 @@ matrix:
- MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"
compiler: clang

# works on Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
packages:
- clang-6.0
- libstdc++-6-dev
- pkg-config
- libncurses5-dev
- libncursesw5-dev
- zlib1g-dev
- libssl-dev
- liblz4-dev
- libcurl4-openssl-dev
- liblz-dev
- libbz2-dev
- liblzma-dev
env:
- MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
compiler: clang

# works on Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
packages:
- clang-7
- libstdc++-7-dev
- pkg-config
- libncurses5-dev
- libncursesw5-dev
- zlib1g-dev
- libssl-dev
- liblz4-dev
- libcurl4-openssl-dev
- liblz-dev
- libbz2-dev
- liblzma-dev
env:
- MATRIX_EVAL="CC=clang-7 && CXX=clang++-7"
compiler: clang

# OSX begin
- os: osx
osx_image: xcode8
osx_image: xcode10
env:
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
- MATRIX_EVAL="brew update && brew install gcc@5 && CC=gcc-5 && CXX=g++-5"

- os: osx
osx_image: xcode8
osx_image: xcode10
env:
- MATRIX_EVAL="brew update && brew install gcc5 && CC=gcc-5 && CXX=g++-5"
- MATRIX_EVAL="brew update && brew install gcc@6 && CC=gcc-6 && CXX=g++-6"

- os: osx
osx_image: xcode8
osx_image: xcode10
env:
- MATRIX_EVAL="brew update && brew install gcc6 && CC=gcc-6 && CXX=g++-6"
- MATRIX_EVAL="brew update && brew install gcc@7 && CC=gcc-7 && CXX=g++-7"

- os: osx
osx_image: xcode8
osx_image: xcode10
env:
- MATRIX_EVAL="brew update && brew install gcc && CC=gcc-7 && CXX=g++-7"
- MATRIX_EVAL="brew update && brew install gcc@8 && CC=gcc-8 && CXX=g++-8"


before_install:
Expand All @@ -227,5 +320,5 @@ before_install:

script:
- git submodule update --recursive
- make -j4

- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make -j 4 2>/dev/null; fi
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then make -j 4; fi
4 changes: 2 additions & 2 deletions lib/aggregation.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct twk_agg_slave {

if(stream.good()) stream.close();

stream = std::ifstream(filename,std::ios::binary | std::ios::in);
stream.open(filename,std::ios::binary | std::ios::in);
if(stream.good() == false){
std::cerr << utility::timestamp("ERROR","THREAD") << "Failed to open \"" << filename << "\"..." << std::endl;
return nullptr;
Expand Down Expand Up @@ -94,7 +94,7 @@ struct twk_agg_slave {

if(stream.good()) stream.close();

stream = std::ifstream(filename,std::ios::binary | std::ios::in);
stream.open(filename,std::ios::binary | std::ios::in);
if(stream.good() == false){
std::cerr << utility::timestamp("ERROR","THREAD") << "Failed to open \"" << filename << "\"..." << std::endl;
return nullptr;
Expand Down
1 change: 0 additions & 1 deletion lib/importer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "importer.h"

#include <omp.h>
#include <thread>

#include "zstd.h"
Expand Down
6 changes: 3 additions & 3 deletions lib/two_sorter_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ std::thread* twk_sort_slave::Start(IndexOutput& rdr){
if(t - f == 0) return nullptr;
//delete thread;

stream = std::ifstream(filename,std::ios::binary | std::ios::in);
stream.open(filename,std::ios::binary | std::ios::in);
if(stream.good() == false){
std::cerr << utility::timestamp("ERROR","THREAD") << "Failed to open \"" << filename << "\"..." << std::endl;
return nullptr;
Expand All @@ -25,7 +25,7 @@ std::thread* twk_sort_slave::Start(IndexOutput& rdr){
blk->resize((m_limit*1e9)/sizeof(twk1_two_t));
it->stream = &stream;

ostream = std::ofstream(tmp_filename, std::ios::binary | std::ios::out);
ostream.open(tmp_filename, std::ios::binary | std::ios::out);
if(ostream.good() == false){
std::cerr << utility::timestamp("ERROR","THREAD") << "Failed to open temp output file \"" << tmp_filename << "\"..." << std::endl;
return nullptr;
Expand Down Expand Up @@ -191,7 +191,7 @@ bool twk_two_stream_iterator::Open(const std::string file,
const uint32_t n_uncompressed,
const uint32_t n_compressed)
{
stream = std::ifstream(file, std::ios::binary);
stream.open(file, std::ios::binary);
if(stream.good() == false){
std::cerr << utility::timestamp("ERROR") << "Could not open \"" << file << "\"..." << std::endl;
return false;
Expand Down
28 changes: 19 additions & 9 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,24 @@ endif

# OS X linker doesn't support -soname, and use different extension
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
# Use LDFLAGS for passing additional flags. Avoid using LD_LIB_FLAGS.
ifneq ($(shell uname), Darwin)
SHARED_EXT = so
LD_LIB_FLAGS = -shared '-Wl,-rpath-link,$$ORIGIN/,-rpath-link,$(PWD),-rpath-link,$$ORIGIN/zstd/lib,-rpath-link,$$ORIGIN/htslib,-soname,libtomahawk.$(SHARED_EXT)'
LD_LIB_FLAGS = -shared '-Wl,-rpath-link,$$ORIGIN/,-rpath-link,$(PWD),-rpath-link,$$ORIGIN/zstd/lib,-rpath-link,$$ORIGIN/htslib,-soname,libtomahawk.$(SHARED_EXT)' $(LDFLAGS)
else
SHARED_EXT = dylib
LD_LIB_FLAGS = -dynamiclib -install_name libtomahawk.$(SHARED_EXT) '-Wl,-rpath-link,$$ORIGIN/,-rpath-link,$(PWD),-rpath-link,$$ORIGIN/zstd/lib,-rpath-link,$$ORIGIN/htslib'
LD_LIB_FLAGS = -dynamiclib -install_name "@rpath/libtomahawk.$(SHARED_EXT)" '-Wl,-rpath,@loader_path/,-rpath,$(PWD),-rpath,@loader_path/zstd/lib,-rpath,@loader_path/htslib' $(LDFLAGS)
endif

CXXFLAGS = -std=c++0x $(OPTFLAGS) $(DEBUG_FLAGS)
CFLAGS = -std=c99 $(OPTFLAGS) $(DEBUG_FLAGS)
CFLAGS_VENDOR = -std=c99 $(OPTFLAGS)

ifneq ($(shell uname), Darwin)
BINARY_RPATHS = '-Wl,-rpath,$$ORIGIN/,-rpath,$(PWD),-rpath,$$ORIGIN/zstd/lib,-rpath,$$ORIGIN/htslib'
else
BINARY_RPATHS = '-Wl,-rpath,@loader_path/,-rpath,$(PWD),-rpath,@loader_path/zstd/lib,-rpath,@loader_path/htslib'
endif

LIBS := -lzstd -lhts
CXX_SOURCE = $(wildcard lib/*.cpp) \
Expand All @@ -146,23 +152,27 @@ all: tomahawk

# Generic rules
%.o: %.cpp
g++ $(CXXFLAGS) $(INCLUDE_PATH) -c -DVERSION=\"$(GIT_VERSION)\" -o $@ $<
$(CXX) $(CXXFLAGS) $(INCLUDE_PATH) -c -DVERSION=\"$(GIT_VERSION)\" -o $@ $<

tomahawk: $(OBJECTS)
g++ $(BINARY_RPATHS) $(LIBRARY_PATHS) -pthread $(OBJECTS) $(LIBS) -o tomahawk
$(CXX) $(BINARY_RPATHS) $(LIBRARY_PATHS) -pthread $(OBJECTS) $(LIBS) -o tomahawk
$(MAKE) cleanmost
$(MAKE) library library=true

library: $(OBJECTS)
@echo 'Building dynamic library...'
g++ $(LD_LIB_FLAGS) $(LIBRARY_PATHS) -pthread $(OBJECTS) $(LIBS) -o libtomahawk.$(SHARED_EXT).$(LIBVER)
$(CXX) $(LD_LIB_FLAGS) $(LIBRARY_PATHS) -pthread $(OBJECTS) $(LIBS) -o libtomahawk.$(SHARED_EXT).$(LIBVER)
@echo 'Building static library...'
ar crs libtomahawk.a $(OBJECTS)
$(AR) crs libtomahawk.a $(OBJECTS)
@echo 'Symlinking library...'
ln -sf libtomahawk.$(SHARED_EXT).$(LIBVER) libtomahawk.$(SHARED_EXT)
ln -sf libtomahawk.$(SHARED_EXT).$(LIBVER) ltomahawk.$(SHARED_EXT)

install: $(PROGRAMS)
install_deps:
@$(MAKE) tomahawk
@$(MAKE) library library=true

install: install_deps
$(INSTALL_DIR) $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)/tomahawk $(DESTDIR)$(libdir)
$(INSTALL_DATA) include/*.h $(DESTDIR)$(includedir)/tomahawk
$(INSTALL_PROGRAM) tomahawk $(DESTDIR)$(bindir)
Expand All @@ -177,6 +187,6 @@ cleanmost:
rm -f $(OBJECTS) $(CPP_DEPS)

clean: cleanmost clean_examples
rm -f tomahawk libtomahawk.so libtomahawk.so.* ltomahawk.so libtomahawk.a
rm -f tomahawk libtomahawk.so libtomahawk.so.* ltomahawk.so libtomahawk.a libtomahawk.dylib* ltomahawk.dylib

.PHONY: all clean clean_examples cleanmost library install
.PHONY: all clean clean_examples cleanmost library install install_deps

0 comments on commit 0e816bc

Please sign in to comment.