diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index dfd4ed1..376f9cf 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -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 diff --git a/Makefile b/Makefile index 027001f..04badaf 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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)","") @@ -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 @@ -124,7 +81,6 @@ misc: $(LIBHTS) $(OBJ) clean: rm -f *.o *.d $(PROGRAM) version.h *~ - rm -rf $(HTSSRC) $(MAKE) -C misc clean testclean: diff --git a/misc/Makefile b/misc/Makefile index 9d110d1..06a94dd 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -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) @@ -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 \