File: Makefile

package info (click to toggle)
stringtie 3.0.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,888 kB
  • sloc: cpp: 32,956; sh: 448; python: 429; makefile: 146
file content (189 lines) | stat: -rw-r--r-- 5,390 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#-- for now these MUST point to the included "samtools-0.x.x" and "gclib" sub-directories
GDIR := ./gclib
#--

INCDIRS := -I. -I${GDIR} -I/usr/include/samtools -I/usr/include/htslib

CXX   := $(if $(CXX),$(CXX),g++)

BASEFLAGS := -Wall -Wextra ${INCDIRS} -fsigned-char -D_FILE_OFFSET_BITS=64 \
-D_LARGEFILE_SOURCE -std=c++11 -fno-strict-aliasing -fno-exceptions -fno-rtti
#for gcc 8+ add: -Wno-class-memaccess
GCCGTE5 := $(shell expr `${CXX} -dumpversion | cut -f1 -d.` \>= 5)
ifeq "$(GCCGTE5)" "1"
 BASEFLAGS += -Wno-implicit-fallthrough
endif

GCCVER8 := $(shell expr `${CXX} -dumpversion | cut -f1 -d.` \>= 8)
ifeq "$(GCCVER8)" "1"
  BASEFLAGS += -Wno-class-memaccess
endif

LINKER  := $(if $(LINKER),$(LINKER),g++)

LDFLAGS := $(if $(LDFLAGS),$(LDFLAGS),-g)

# LDFLAGS += -L${BAM}

LIBS    := -lhts -lbz2 -lz -lm

ifneq (,$(filter %nothreads %prof %profile, $(MAKECMDGOALS)))
 NOTHREADS=1
endif

#detect MinGW (Windows environment)
ifneq (,$(findstring mingw,$(shell ${CXX} -dumpmachine)))
 WINDOWS=1
endif

# Misc. system commands
#ifdef WINDOWS ##<-- use MSYS
# RM = del /Q
#else
RM = rm -f
#endif

# Non-windows systems need pthread
ifndef WINDOWS
 ifndef NOTHREADS
   LIBS := -pthread ${LIBS}
   BASEFLAGS += -pthread
 endif
endif

ifdef NOTHREADS
  BASEFLAGS += -DNOTHREADS
endif

# Compiling for Windows with MinGW?
#ifneq ($(findstring -mingw,$(shell $(CC) -dumpmachine 2>/dev/null)),)
#LIBS += -lregex -lws2_32
#endif
# File endings
ifdef WINDOWS
 EXE = .exe
 LIBS += -lregex -lws2_32
else
 EXE =
endif

DMACH := $(shell ${CXX} -dumpmachine)

ifneq (,$(filter %release %static %static-cpp, $(MAKECMDGOALS)))
  # -- release build
  RELEASE_BUILD=1
  CXXFLAGS := $(if $(CXXFLAGS),$(CXXFLAGS),-g -O3)
  CXXFLAGS += -DNDEBUG $(BASEFLAGS)
else
  ifneq (,$(filter %memcheck %memdebug %tsan %tcheck %thrcheck, $(MAKECMDGOALS)))
     ifneq "$(GCCGTE5)" "1"
       $(error g++ version 5 or greater is required for this build target)
     endif
     CXXFLAGS := $(if $(CXXFLAGS),$(CXXFLAGS),-g -O0)
     SANLIBS :=
     ifneq (,$(filter %tsan %tcheck %thrcheck, $(MAKECMDGOALS)))
        # thread sanitizer only (incompatible with address sanitizer)
        CXXFLAGS += -fno-omit-frame-pointer -fsanitize=thread -fsanitize=undefined $(BASEFLAGS)
        SANLIBS := -ltsan
     else
        # address sanitizer
        CXXFLAGS += -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address $(BASEFLAGS)
        SANLIBS := -lasan
     endif
     ifeq "$(GCCGTE5)" "1"
       CXXFLAGS += -fsanitize=bounds -fsanitize=float-divide-by-zero -fsanitize=vptr
       CXXFLAGS += -fsanitize=float-cast-overflow -fsanitize=object-size
       #CXXFLAGS += -fcheck-pointer-bounds -mmpx
     endif
     CXXFLAGS += -DDEBUG -D_DEBUG -DGDEBUG -fno-common -fstack-protector
     LIBS := ${SANLIBS} -lubsan -ldl ${LIBS}
  else
     ifneq (,$(filter %prof %profile, $(MAKECMDGOALS)))
     ## profiling build
       CXXFLAGS := -DNDEBUG $(BASEFLAGS) -g -pg
       LDFLAGS += -g -pg
     else
        #just plain debug build
        DEBUG_BUILD=1
        CXXFLAGS := $(if $(CXXFLAGS),$(CXXFLAGS),-g -O0)
        ifneq (, $(findstring darwin, $(DMACH)))
           CXXFLAGS += -gdwarf-3
        endif
        CXXFLAGS += -DDEBUG -D_DEBUG -DGDEBUG $(BASEFLAGS)
     endif
  endif
endif

ifdef RELEASE_BUILD
 ifneq ($(findstring static,$(MAKECMDGOALS)),) 
  # static or static-cpp found
  ifneq ($(findstring static-cpp,$(MAKECMDGOALS)),) 
     #not a full static build, only c/c++ libs
     LDFLAGS := -static-libgcc -static-libstdc++ ${LDFLAGS}
  else
     #full static build
     LDFLAGS := -static -static-libgcc -static-libstdc++ ${LDFLAGS}
  endif
 endif
endif

ifdef DEBUG_BUILD
  #$(warning Building DEBUG version of stringtie.. )
  DBG_WARN=@echo
  DBG_WARN+='WARNING: built DEBUG version [much slower], use "make clean release" for a faster, optimized version of the program.'
endif

OBJS := ${GDIR}/GBase.o ${GDIR}/GArgs.o ${GDIR}/GStr.o ${GDIR}/GSam.o \
 ${GDIR}/gdna.o ${GDIR}/codons.o ${GDIR}/GFastaIndex.o ${GDIR}/GFaSeqGet.o ${GDIR}/gff.o 

ifneq (,$(filter %memtrace %memusage %memuse, $(MAKECMDGOALS)))
    CXXFLAGS += -DGMEMTRACE
    OBJS += ${GDIR}/proc_mem.o
endif

ifndef NOTHREADS
 OBJS += ${GDIR}/GThreads.o 
endif

%.o : %.cpp
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -c $< -o $@

OBJS += bundle.o rlink.o tablemaker.o tmerge.o

all release static static-cpp debug: stringtie${EXE}
memcheck memdebug tsan tcheck thrcheck: stringtie${EXE}
memuse memusage memtrace: stringtie${EXE}
prof profile: stringtie${EXE}
nothreads: stringtie${EXE}

stringtie.o : $(GDIR)/GBitVec.h $(GDIR)/GHashMap.hh $(GDIR)/GSam.h
rlink.o : rlink.h tablemaker.h bundle.h $(GDIR)/GSam.h $(GDIR)/GBitVec.h
bundle.o : bundle.h rlink.h tablemaker.h $(GDIR)/GSam.h
tmerge.o : rlink.h tmerge.h
tablemaker.o : tablemaker.h rlink.h

##${BAM}/libbam.a: 
##	cd ${BAM} && make lib

stringtie${EXE}: $(OBJS) stringtie.o
	${LINKER} ${LDFLAGS} -o $@ ${filter-out %.a %.so, $^} ${LIBS}
	@echo
	${DBG_WARN}
test demo tests: stringtie${EXE}
	@./run_tests.sh
.PHONY : clean clean-htslib

# target for removing all object files

#	echo $(PATH)
clean:
	${RM} stringtie${EXE} stringtie.o*  $(OBJS)
	${RM} core.*
clean-all: clean
	cd ${HTSLIB} && ./build_lib.sh clean
clean-htslib:
	cd ${HTSLIB} && ./build_lib.sh clean
##allclean cleanAll cleanall:
##	cd ${BAM} && make clean
##	${RM} stringtie${EXE} stringtie.o* $(OBJS)
##	${RM} core.*