Skip to content

Commit

Permalink
static linking on os x
Browse files Browse the repository at this point in the history
  • Loading branch information
lomereiter committed Nov 12, 2014
1 parent e4ae585 commit 39eb541
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@ env:
- secure: J1ta2/K8lj5dbHRvk+jTUAMICSnepfyc8ILCfM/HFCRaXMJQJTX1HDzEMwK3tAzzKaKEp9Tbm2b3IwE1tCtFaAfYUGozmHLirkFfKqCu/jNUkxL807M8NiqMx+H7tu2aR6t9opYyBjNhtuthbIdir3c42nldYdpse0ZLhzQTLfs=

before_install:
- brew tap homebrew/science
- brew install htslib
- brew install ldc
- git submodule update --init --recursive
- wget https://dl.dropboxusercontent.com/u/7916095/ldc2-0.13.0-osx-x86_64.tar.bz2
- tar xjf ldc2-0.13.0-osx-x86_64.tar.bz2
- export PATH=ldc2-0.13.0-osx-x86_64/bin:$PATH
- wget https://github.com/craigcitro/r-travis/raw/master/scripts/dropbox.sh
- chmod +x dropbox.sh
- curl -L "https://dl.dropboxusercontent.com/u/7916095/shunit2-2.0.3.tgz" | tar zx

script:
- make sambamba-ldmd2-64-osx
- make sambamba-ldmd2-64
- ./.run_tests.sh

after_success:
Expand Down
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@ HTSLIB_PATH=-Lhtslib
HTSLIB_SUBCMD=$(HTSLIB_PATH) -Wl,-Bstatic -lhts -Wl,-Bdynamic
RDMD_FLAGS=--force --build-only --compiler=$(D_COMPILER) $(D_FLAGS)

# Linux & DMD only - this goal is used because of fast compilation speed, during development
all: htslib-static
mkdir -p build/
rdmd --force --build-only $(D_FLAGS) -c -ofbuild/sambamba.o main.d
gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(HTSLIB_SUBCMD) -l:libphobos2.a -lrt -lpthread -lm

PLATFORM := $(shell uname -s)

ifeq "$(PLATFORM)" "Darwin"
LINK_CMD=gcc -dead_strip -lphobos2-ldc -ldruntime-ldc -lm -lpthread htslib/libhts.a build/sambamba.o -o build/sambamba
else
LINK_CMD=gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(HTSLIB_SUBCMD) -l:libphobos2-ldc.a -l:libdruntime-ldc.a -lrt -lpthread -lm
endif

# This is the main Makefile goal, used for building releases (best performance)
sambamba-ldmd2-64: htslib-static
mkdir -p build/
ldmd2 @sambamba-ldmd-release.rsp
gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(HTSLIB_SUBCMD) -l:libphobos2-ldc.a -l:libdruntime-ldc.a -lrt -lpthread -lm
$(LINK_CMD)

# For debugging; GDB & Valgrind are more friendly to executables created using LDC/GDC than DMD
sambamba-ldmd2-debug: htslib-static
mkdir -p build/
ldmd2 @sambamba-ldmd-debug.rsp
gcc -Wl,--gc-sections -o build/sambamba build/sambamba.o $(HTSLIB_SUBCMD) -l:libphobos2-ldc.a -l:libdruntime-ldc.a -lrt -lpthread -lm
$(LINK_CMD)

htslib-static:
cd htslib && $(MAKE)

# all below link to libhts dynamically for simplicity

sambamba-ldmd2-64-osx:
mkdir -p build/
rdmd --force --build-only --compiler=ldmd2 -IBioD -O -L-lhts -release -inline -noboundscheck -ofbuild/sambamba main.d

sambamba-flagstat:
mkdir -p build/
rdmd $(RDMD_FLAGS) -L-lhts -version=standalone -ofbuild/sambamba-flagstat sambamba/flagstat.d
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,11 @@ which targets LLVM.

## Compiling for Mac OS X

(The Dropbox archive differs from the official LDC release in that it also contains `rdmd` executable from DMD distribution.)

```sh
brew tap homebrew/science
brew install htslib
wget https://dl.dropboxusercontent.com/u/7916095/ldc2-0.13.0-osx-x86_64.tar.bz2
tar xjf ldc2-0.13.0-osx-x86_64.tar.bz2
brew install ldc
git clone --recursive https://github.com/lomereiter/sambamba.git
cd sambamba
export PATH=../ldc2-0.13.0-osx-x86_64/bin:$PATH
make sambamba-ldmd2-64-osx
make sambamba-ldmd2-64
```

## Compiling for Linux using Docker
Expand Down

0 comments on commit 39eb541

Please sign in to comment.