|
1 | | -# make FLAGS=-D__REGRESSION__ |
2 | 1 | #c++ -I /opt/homebrew/Cellar/eigen/3.4.0_1/include/ -c -I/Users/fvr124/metaDMG-cpp/htslib regression.cpp -std=c++14 -D__REGRESSION__ |
3 | 2 |
|
| 3 | + |
| 4 | +FLAGS := -O2 -lgsl |
| 5 | +CFLAGS := $(FLAGS) |
| 6 | +CXXFLAGS := $(FLAGS) -std=c++14 |
| 7 | +CPPFLAGS := $(CPPFLAGS) -Wall -Wextra |
| 8 | +LDFLAGS := $(LDFLAGS) |
| 9 | + |
4 | 10 | CC ?= gcc |
5 | 11 | CXX ?= g++ |
6 | 12 |
|
7 | | -LIBS = -lz -lm -lbz2 -llzma -lpthread -lcurl -lgsl -lgslcblas |
| 13 | +CXXSRC := $(wildcard *.cpp) |
| 14 | +CSRC := $(wildcard *.c) |
| 15 | +OBJ := $(CSRC:.c=.o) $(CXXSRC:.cpp=.o) |
8 | 16 |
|
9 | | -CRYPTO_TRY=$(shell echo 'int main(){}'|$(CXX) -x c++ - -lcrypto 2>/dev/null -o /dev/null; echo $$?) |
10 | | -ifeq "$(CRYPTO_TRY)" "0" |
11 | | -$(info Crypto library is available to link; adding -lcrypto to LIBS) |
12 | | -LIBS += -lcrypto |
13 | | -else |
14 | | -$(info Crypto library is not available to link; will not use -lcrypto) |
| 17 | +# --- Brugervalgte paths og biblioteker --- |
| 18 | +ifdef PREFIX |
| 19 | +CPPFLAGS += -I$(PREFIX)/include |
| 20 | +LDFLAGS += -L$(PREFIX)/lib |
15 | 21 | endif |
16 | 22 |
|
| 23 | +ifdef EXTRA_INC |
| 24 | +CPPFLAGS += $(addprefix -I,$(EXTRA_INC)) |
| 25 | +endif |
17 | 26 |
|
18 | | -#if htslib source is defined |
19 | | -ifdef HTSSRC |
20 | | - |
21 | | -#if hts source is set to systemwide |
22 | | -ifeq ($(HTSSRC),systemwide) |
23 | | -$(info HTSSRC set to systemwide; assuming systemwide installation) |
24 | | -LIBS += -lhts |
| 27 | +ifdef EXTRA_LIB |
| 28 | +LDFLAGS += $(addprefix -L,$(EXTRA_LIB)) |
| 29 | +endif |
25 | 30 |
|
26 | | -else |
| 31 | +ifdef EXTRA_LIBS |
| 32 | +LIBS += $(EXTRA_LIBS) |
| 33 | +endif |
27 | 34 |
|
28 | | -#if hts source path is given |
29 | | -# Adjust $(HTSSRC) to point to your top-level htslib directory |
30 | | -$(info HTSSRC defined: $(HTSSRC)) |
31 | | -CPPFLAGS += -I"$(realpath $(HTSSRC))" |
32 | | -LIBHTS := $(HTSSRC)/libhts.a |
33 | | -LIBS := $(LIBHTS) $(LIBS) |
| 35 | +# --- Crypto-detektion --- |
| 36 | +HAVE_CRYPTO := $(shell echo 'int main(){}'|$(CXX) -x c++ - -lcrypto -o /dev/null 2>/dev/null && echo 0 || echo 1) |
| 37 | +LIBS := -lz -lm -lbz2 -llzma -lpthread -lcurl |
34 | 38 |
|
| 39 | +ifeq ($(HAVE_CRYPTO),0) |
| 40 | + $(info Crypto library is available to link; adding -lcrypto) |
| 41 | + LIBS += -lcrypto |
| 42 | +else |
| 43 | + $(info Crypto library is not available to link; skipping -lcrypto) |
35 | 44 | endif |
36 | 45 |
|
37 | | -#if htssrc not defined |
| 46 | +# --- HTSSRC håndtering --- |
| 47 | +ifdef HTSSRC |
| 48 | + ifeq ($(HTSSRC),systemwide) |
| 49 | + $(info HTSSRC set to systemwide; using systemwide installation) |
| 50 | + LIBS += -lhts |
| 51 | + else |
| 52 | + $(info HTSSRC defined: $(HTSSRC)) |
| 53 | + CPPFLAGS += -I"$(realpath $(HTSSRC))" |
| 54 | + LIBHTS := $(HTSSRC)/libhts.a |
| 55 | + LIBS := $(LIBHTS) $(LIBS) |
| 56 | + endif |
38 | 57 | else |
39 | | - |
40 | | -$(info HTSSRC not defined; using htslib submodule) |
41 | | -$(info Use `make HTSSRC=/path/to/htslib` to build metadamage using a local htslib installation) |
42 | | -$(info Use `make HTSSRC=systemwide` to build metadamage using the systemwide htslib installation) |
43 | | - |
44 | | - |
45 | | -HTSSRC := $(CURDIR)/htslib |
46 | | -CPPFLAGS += -I$(HTSSRC) |
47 | | -LIBHTS := $(HTSSRC)/libhts.a |
48 | | -LIBS := $(LIBHTS) $(LIBS) |
49 | | - |
50 | | -all: .activate_module |
51 | | - |
| 58 | + $(info HTSSRC not defined; using htslib submodule) |
| 59 | + $(info ================================) |
| 60 | + $(info Use `make HTSSRC=/path/to/htslib` for custom) |
| 61 | + $(info Use `make HTSSRC=systemwide` for system install) |
| 62 | + $(info ================================) |
| 63 | + HTSSRC := $(CURDIR)/htslib |
| 64 | + CPPFLAGS += -I$(HTSSRC) |
| 65 | + LIBHTS := $(HTSSRC)/libhts.a |
| 66 | + LIBS := $(LIBHTS) $(LIBS) |
| 67 | + |
| 68 | + .PHONY: .activate_module |
| 69 | + all: .activate_module |
| 70 | + .activate_module: |
| 71 | + @git submodule update --init --recursive |
| 72 | + @$(MAKE) -C $(HTSSRC) |
52 | 73 | endif |
53 | 74 |
|
54 | | -.PHONY: .activate_module |
55 | | - |
56 | | -.activate_module: |
57 | | - git submodule update --init --recursive |
58 | | - $(MAKE) -C $(HTSSRC) |
59 | | - |
60 | | - |
61 | | - |
62 | | -#modied from htslib makefile |
63 | | -FLAGS = -O3 |
64 | | -CPPFLAGS := $(filter-out -DNDEBUG,$(CPPFLAGS)) |
65 | | -FLAGS2 = $(CPPFLAGS) $(FLAGS) $(LDFLAGS) |
66 | | - |
67 | | -CFLAGS := $(FLAGS2) $(CFLAGS) |
68 | | -CXXFLAGS := $(FLAGS2) $(CXXFLAGS) |
69 | | - |
70 | | -OPT=-Wl,-O2 |
71 | | -# filter -O2 optimization flag CXXFLAGS |
72 | | -CXXFLAGS := $(filter-out -O2,$(CXXFLAGS)) |
73 | | -CXXFLAGS := $(subst $(OPT),,$(CXXFLAGS)) |
74 | | - |
75 | | -CSRC = $(wildcard *.c) |
76 | | -CXXSRC = $(wildcard *.cpp) |
77 | | -OBJ = $(CSRC:.c=.o) $(CXXSRC:.cpp=.o) |
78 | | - |
79 | | -prefix = /usr/local |
80 | | -exec_prefix = $(prefix) |
81 | | -bindir = $(exec_prefix)/bin |
82 | | - |
83 | | -INSTALL = install |
84 | | -INSTALL_DIR = $(INSTALL) -dm0755 |
85 | | -INSTALL_PROGRAM = $(INSTALL) -m0755 |
86 | | - |
87 | | -PROGRAMS = metaDMG-cpp |
88 | | - |
89 | | -all: $(PROGRAMS) misc |
90 | | - |
91 | | -PACKAGE_VERSION = 0.4 |
92 | | - |
93 | | -ifneq "$(wildcard .git)" "" |
94 | | -PACKAGE_VERSION := $(shell git describe --always --dirty) |
95 | | -version.h: $(if $(wildcard version.h),$(if $(findstring "$(PACKAGE_VERSION)",$(shell cat version.h)),,force)) |
| 75 | +# --- Versionsnummer og version.h --- |
| 76 | +PACKAGE_VERSION := 0.4 |
| 77 | +ifneq ("$(wildcard .git)","") |
| 78 | + PACKAGE_VERSION := $(shell git describe --always --dirty) |
96 | 79 | endif |
97 | 80 |
|
98 | 81 | version.h: |
99 | 82 | echo '#define METADAMAGE_VERSION "$(PACKAGE_VERSION)"' > $@ |
100 | 83 |
|
101 | | -.PHONY: all clean install install-all install-misc misc test |
| 84 | +# --- Mål og bygning --- |
| 85 | +PROGRAM = metaDMG-cpp |
| 86 | + |
| 87 | +all: $(PROGRAM) misc |
102 | 88 |
|
| 89 | +$(PROGRAM): version.h $(OBJ) |
| 90 | + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) |
| 91 | + |
| 92 | +.PHONY: misc |
103 | 93 | misc: |
104 | 94 | $(MAKE) -C misc HTSSRC="$(realpath $(HTSSRC))" |
105 | 95 |
|
| 96 | +# --- Automatisk afhængighedshåndtering --- |
106 | 97 | -include $(OBJ:.o=.d) |
107 | 98 |
|
108 | 99 | %.o: %.c |
109 | | - $(CC) -c $(CFLAGS) $*.c |
110 | | - $(CC) -MM $(CFLAGS) $*.c >$*.d |
| 100 | + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ |
| 101 | + $(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $*.d |
111 | 102 |
|
112 | 103 | %.o: %.cpp |
113 | | - $(CXX) -c $(CXXFLAGS) $*.cpp |
114 | | - $(CXX) -MM $(CXXFLAGS) $*.cpp >$*.d |
115 | | - |
| 104 | + $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ |
| 105 | + $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $*.d |
116 | 106 |
|
117 | | -metaDMG-cpp: version.h $(OBJ) |
118 | | - $(CXX) $(FLAGS) -o metaDMG-cpp *.o $(LIBS) |
| 107 | +# --- Rens og tests --- |
| 108 | +.PHONY: clean test testclean force |
119 | 109 |
|
| 110 | +clean: testclean |
| 111 | + rm -f *.o *.d $(PROGRAM) version.h *~ |
| 112 | + $(MAKE) -C misc clean |
120 | 113 |
|
121 | 114 | testclean: |
122 | | - rm -f test/acc2taxid.map.gzf570b1db7c.dedup.filtered.rname.bam.bin |
123 | | - rm -f test/data/f570b1db7c.dedup.filtered.rname.bam |
| 115 | + rm -f test/*.bam.bin test/data/*.bam |
124 | 116 | rm -rf test/output test/logfile version.h |
125 | 117 |
|
126 | | -clean: testclean |
127 | | - rm -f *.o *.d $(PROGRAMS) version.h *~ |
128 | | - $(MAKE) -C misc clean |
129 | | - |
130 | 118 | test: |
131 | 119 | echo "Running unit tests for metaDMG" |
132 | | - cd test;./testAll.sh |
| 120 | + cd test && ./testAll.sh |
133 | 121 |
|
134 | 122 | force: |
135 | | - |
136 | | -install: all |
137 | | - $(INSTALL_DIR) $(DESTDIR)$(bindir) |
138 | | - $(INSTALL_PROGRAM) $(PROGRAMS) $(DESTDIR)$(bindir) |
139 | | - $(MAKE) -C misc HTSSRC="$(realpath $(HTSSRC))" install |
140 | | - |
141 | | -install-misc: misc |
142 | | - $(MAKE) -C misc HTSSRC="$(realpath $(HTSSRC))" install-misc |
143 | | - |
144 | | -install-all: install install-misc |
0 commit comments