Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ jobs:
- uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt-get update;sudo apt-get install -y libbz2-dev liblzma-dev libcurl4-openssl-dev libgsl-dev samtools
- name: prepare htslib
run: git clone --branch=develop --recursive https://github.com/samtools/htslib.git;cd htslib; make;cd ..;
- name: Compile htslib
run: |
git clone --branch=develop --recursive https://github.com/samtools/htslib.git
cd htslib
make
cd ../
- name: make
run: export HTSSRC=`pwd`/htslib; make
run: |
export CPATH=`pwd`/htslib:${CPATH}
export LD_LIBRARY_PATH=`pwd`/htslib:${LD_LIBRARY_PATH}
export LIBRARY_PATH=`pwd`/htslib:${LIBRARY_PATH}
make
- name: make test
run: make test
- name: Upload test/output folder
Expand Down
56 changes: 6 additions & 50 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif

# --- Crypto library detektion ---
HAVE_CRYPTO := $(shell echo 'int main(){}'|$(CXX) -x c++ - -lcrypto -o /dev/null 2>/dev/null && echo 0 || echo 1)
LIBS := -lz -lm -lbz2 -llzma -lpthread -lcurl
LIBS := -lz -lm -lbz2 -llzma -lpthread -lcurl -lhts

# --- Mål og bygning ---
PROGRAM = metaDMG-cpp
Expand All @@ -47,49 +47,6 @@ else
$(info Crypto library is not available to link; skipping -lcrypto)
endif

# --- HTSLIB håndtering ---
# HTSSRC is an absolute path (e.g., $(CURDIR)/htslib or user-specified)

ifndef HTSSRC
$(info HTSSRC not defined; cloning htslib from GitHub)
HTSSRC := $(CURDIR)/htslib
ABSPATH=$(HTSSRC) #donkykong
endif

ABSPATH=$(HTSSRC) #donkykong
ifeq ($(HTSSRC),systemwide)
$(info HTSSRC set to systemwide; using systemwide installation)
LIBS += -lhts
LIBHTS :=
else
# Use HTSSRC directly for include path
CPPFLAGS += -I$(HTSSRC)
LIBHTS := $(HTSSRC)/libhts.a
LIBS := $(LIBHTS) $(LIBS)
$(PROGRAM): $(LIBHTS)

ifneq ($(filter /%,$(HTSSRC)),$(HTSSRC))
ABSPATH=../$(HTSSRC)
endif
endif

# Ensure htslib is cloned and built only if libhts.a is missing
$(LIBHTS): .clone_htslib

.clone_htslib:
@if [ ! -d "$(HTSSRC)" ]; then \
echo "Cloning htslib into $(HTSSRC) with submodules..."; \
git clone --recursive https://github.com/samtools/htslib.git $(HTSSRC) || { echo "Clone failed"; exit 1; }; \
else \
echo "$(HTSSRC) already exists, skipping clone."; \
fi
@if [ ! -f "$(LIBHTS)" ]; then \
$(MAKE) -C $(HTSSRC) libhts.a || { echo "Failed to build libhts.a"; exit 1; }; \
else \
echo "$(LIBHTS) already exists, skipping build."; \
fi
$(info CPPFLAGS=$(CPPFLAGS) HTSSRC=$(HTSSRC) (absolute path))

# --- Versionsnummer og version.h ---
PACKAGE_VERSION := 0.4
ifneq ("$(wildcard .git)","")
Expand All @@ -101,21 +58,21 @@ version.h:
@cmp -s version.h.tmp version.h || mv version.h.tmp version.h
@rm -f version.h.tmp

$(PROGRAM): version.h $(OBJ) $(LIBHTS)
$(PROGRAM): version.h $(OBJ)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ $(OBJ) $(LIBS) $(LDFLAGS)

.PHONY: misc
misc: $(LIBHTS) $(OBJ)
$(MAKE) -C misc HTSSRC=$(ABSPATH)
misc: $(OBJ)
$(MAKE) -C misc

# --- Automatisk afhængighedshåndtering ---
-include $(OBJ:.o=.d)

%.o: %.c $(LIBHTS)
%.o: %.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $*.d

%.o: %.cpp $(LIBHTS)
%.o: %.cpp
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $*.d

Expand All @@ -124,7 +81,6 @@ misc: $(LIBHTS) $(OBJ)

clean:
rm -f *.o *.d $(PROGRAM) version.h *~
rm -rf $(HTSSRC)
$(MAKE) -C misc clean

testclean:
Expand Down
31 changes: 1 addition & 30 deletions misc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CFLAGS := $(FLAGS)
CXXFLAGS := $(FLAGS)
CPPFLAGS := $(CPPFLAGS) -Wall -Wextra
LDFLAGS := $(LDFLAGS)
LIBS := -lz -lm -lbz2 -llzma -lpthread -lcurl
LIBS := -lz -lm -lbz2 -llzma -lpthread -lcurl -lhts

# --- Crypto library detection ---
HAVE_CRYPTO := $(shell echo 'int main(){}'|$(CXX) -x c++ - -lcrypto -o /dev/null 2>/dev/null && echo 0 || echo 1)
Expand All @@ -20,41 +20,12 @@ else
$(info Crypto library is not available to link; skipping -lcrypto)
endif

ifeq ($(HTSSRC),systemwide)
$(info Using systemwide htslib installation)
LIBS += -lhts
LIBHTS :=
else
# Convert relative HTSSRC to absolute if needed
ifneq ($(filter /%,$(HTSSRC)),$(HTSSRC))
override HTSSRC := $(shell [ -d "$(HTSSRC)" ] && cd "$(HTSSRC)" && pwd || echo "__INVALID__")
ifeq ($(HTSSRC),__INVALID__)
$(error HTSSRC is not a valid directory in misc folder)
endif
$(info Converted HTSSRC to absolute path: $(HTSSRC))
endif
CPPFLAGS += -I$(HTSSRC)
LIBHTS := $(HTSSRC)/libhts.a
LIBS := $(LIBHTS) $(LIBS)
endif

PROGRAMS := compressbam extract_reads
PROGRAMS_MISC := MAP dfit_optim
OBJ := kmath.o Likelihood.o M3Load.o

all: $(PROGRAMS) $(PROGRAMS_MISC)

# Ensure htslib and shared.o are available
$(PROGRAMS) $(PROGRAMS_MISC): $(LIBHTS)
$(OBJ): $(LIBHTS)

# Check if libhts.a exists
$(LIBHTS):
@if [ ! -f "$(LIBHTS)" ]; then \
echo "Error: $(LIBHTS) not found; ensure parent Makefile has built htslib"; \
exit 1; \
fi

# Check if shared.o exists for extract_reads
../shared.o:
@if [ ! -f "../shared.o" ]; then \
Expand Down