Skip to content

Commit 0bbe9cb

Browse files
authored
Merge pull request #15 from manulera/master
Instructions and fixes to compile in mac
2 parents 7807f9a + d81d3d8 commit 0bbe9cb

4 files changed

Lines changed: 101 additions & 3 deletions

File tree

.github/workflows/compile.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build MARS
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
include:
14+
- os: ubuntu-latest
15+
name: Debian-Bookworm
16+
container: debian:bookworm
17+
- os: ubuntu-latest
18+
name: Linux
19+
- os: macos-latest
20+
name: macOS Intel
21+
- os: macos-14
22+
name: macOS ARM
23+
24+
runs-on: ${{ matrix.os }}
25+
container: ${{ matrix.container }}
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Install Dependencies (Linux - Container)
31+
if: matrix.container == 'debian:bookworm'
32+
run: |
33+
apt-get update
34+
apt-get install -y build-essential cmake unzip
35+
./pre-install.sh
36+
37+
- name: Install Dependencies (Linux - Native)
38+
if: matrix.os == 'ubuntu-latest' && matrix.container == ''
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y build-essential cmake
42+
./pre-install.sh
43+
44+
- name: Install Dependencies (macOS)
45+
if: startsWith(matrix.os, 'macos')
46+
run: |
47+
brew install cmake libomp
48+
./pre-install.sh
49+
50+
- name: Build
51+
run: |
52+
make -f Makefile
53+
54+
- name: Test Binary
55+
run: |
56+
./mars -h | grep "Usage: mars <options>"
57+
58+
- name: Upload Artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: mars-${{ matrix.name }}
62+
path: mars
63+
retention-days: 7

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.o
2+
libsdsl/
3+
sdsl-lite/
4+
seqan/
5+
mars

INSTALL

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ After compilation the binary `mars' will be created in the working
1717
directory, e.g. you may call it from this directory via
1818

1919
S ./mars -h
20+
21+
Compiling in M3 Mac
22+
===================
23+
24+
It can be compiled with clang.
25+
26+
You will have to install libomp to allow the flag -fopenmp to work with.
27+
28+
brew install libomp

Makefile

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,30 @@ MF= Makefile
22

33
CC= g++
44

5-
CFLAGS= -g -fopenmp -D_USE_OMP -msse4.2 -O3 -fomit-frame-pointer -funroll-loops
5+
CFLAGS= -g -D_USE_OMP -O3 -fomit-frame-pointer -funroll-loops -pthread
6+
7+
# Detect OS for platform-specific settings
8+
UNAME_S := $(shell uname -s)
9+
ifeq ($(UNAME_S),Darwin)
10+
# macOS
11+
RPATH_FLAG := -Wl,-rpath,$(PWD)/libsdsl/lib
12+
# Dynamically get Homebrew prefix (libomp path)
13+
BREW_PREFIX := $(shell brew --prefix libomp)
14+
# OpenMP flags for macOS
15+
OPENMP_FLAGS := -Xpreprocessor -fopenmp -I$(BREW_PREFIX)/include
16+
OPENMP_LIBS := -L$(BREW_PREFIX)/lib -lomp
17+
CFLAGS += $(OPENMP_FLAGS)
18+
LFLAGS += $(OPENMP_LIBS)
19+
else
20+
# Linux and others
21+
RPATH_FLAG := -Wl,-rpath=$(PWD)/libsdsl/lib
22+
CFLAGS += -fopenmp
23+
LFLAGS += -fopenmp
24+
endif
25+
26+
627

7-
LFLAGS= -std=c++11 -I ./ -I ./libsdsl/include/ -L ./libsdsl/lib/ -lsdsl -ldivsufsort -ldivsufsort64 -Wl,-rpath=$(PWD)/libsdsl/lib
28+
LFLAGS= -std=c++11 -I ./ -I ./libsdsl/include/ -L ./libsdsl/lib/ -lsdsl -ldivsufsort -ldivsufsort64 $(RPATH_FLAG) $(OPENMP_LIBS)
829

930
EXE= mars
1031

@@ -22,7 +43,7 @@ HD= EBLOSUM62.h EDNAFULL.h mars.h sacsc.h ced.h nj.h RestrictedLevenshtein.h
2243
OBJ= $(SRC:.cc=.o)
2344

2445
.cc.o:
25-
$(CC) $(CFLAGS)-c $(LFLAGS) $<
46+
$(CC) $(CFLAGS) -c $(LFLAGS) $<
2647

2748
all: $(EXE)
2849

0 commit comments

Comments
 (0)