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 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
|
# ==========================
# BEDTools Makefile
# (c) 2009 Aaron Quinlan
# ==========================
SHELL := /bin/bash -e
VERSION_FILE=./src/utils/version/version_git.h
RELEASED_VERSION_FILE=./src/utils/version/version_release.txt
# define our object and binary directories
ifeq ($(VERBOSE),1)
CCPREFIX =
else
CCPREFIX = @
endif
OBJ_DIR = obj
BIN_DIR = bin
SRC_DIR = src
CXX = g++
PYTHON ?= $(shell python --version >/dev/null 2>&1 && echo "python" || echo python3)
ifeq ($(DEBUG),1)
BT_CPPFLAGS = -DDEBUG -D_DEBUG -D_FILE_OFFSET_BITS=64 -DWITH_HTS_CB_API $(INCLUDES)
BT_CXXFLAGS = -Wconversion -Wall -Wextra -g -O0
else
BT_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -DWITH_HTS_CB_API $(INCLUDES)
BT_CXXFLAGS = -g -Wall -O2
endif
# If the user has specified to do so, tell the compile to use rand() (instead of mt19937).
ifeq ($(USE_RAND),1)
BT_CXXFLAGS += -DUSE_RAND
else
BT_CXXFLAGS += -std=c++11
endif
BT_LDFLAGS =
BT_LIBS = -lz -lm -lbz2 -llzma -lpthread
prefix ?= /usr/local
SUBDIRS = $(SRC_DIR)/annotateBed \
$(SRC_DIR)/bamToBed \
$(SRC_DIR)/bamToFastq \
$(SRC_DIR)/bedToBam \
$(SRC_DIR)/bedpeToBam \
$(SRC_DIR)/bedToIgv \
$(SRC_DIR)/bed12ToBed6 \
$(SRC_DIR)/closestFile \
$(SRC_DIR)/clusterBed \
$(SRC_DIR)/complementFile \
$(SRC_DIR)/coverageFile \
$(SRC_DIR)/expand \
$(SRC_DIR)/fastaFromBed \
$(SRC_DIR)/flankBed \
$(SRC_DIR)/genomeCoverageBed \
$(SRC_DIR)/getOverlap \
$(SRC_DIR)/groupBy \
$(SRC_DIR)/intersectFile \
$(SRC_DIR)/fisher \
$(SRC_DIR)/jaccard \
$(SRC_DIR)/linksBed \
$(SRC_DIR)/maskFastaFromBed \
$(SRC_DIR)/mapFile \
$(SRC_DIR)/mergeFile \
$(SRC_DIR)/multiBamCov \
$(SRC_DIR)/multiIntersectBed \
$(SRC_DIR)/nucBed \
$(SRC_DIR)/pairToBed \
$(SRC_DIR)/pairToPair \
$(SRC_DIR)/randomBed \
$(SRC_DIR)/regressTest \
$(SRC_DIR)/reldist \
$(SRC_DIR)/sampleFile \
$(SRC_DIR)/shiftBed \
$(SRC_DIR)/shuffleBed \
$(SRC_DIR)/slopBed \
$(SRC_DIR)/sortBed \
$(SRC_DIR)/spacingFile \
$(SRC_DIR)/split \
$(SRC_DIR)/subtractFile \
$(SRC_DIR)/summaryFile \
$(SRC_DIR)/tagBam \
$(SRC_DIR)/unionBedGraphs \
$(SRC_DIR)/windowBed \
$(SRC_DIR)/windowMaker
UTIL_SUBDIRS = $(SRC_DIR)/utils/FileRecordTools \
$(SRC_DIR)/utils/FileRecordTools/FileReaders \
$(SRC_DIR)/utils/FileRecordTools/Records \
$(SRC_DIR)/utils/bedFile \
$(SRC_DIR)/utils/BinTree \
$(SRC_DIR)/utils/version \
$(SRC_DIR)/utils/bedGraphFile \
$(SRC_DIR)/utils/chromsweep \
$(SRC_DIR)/utils/Contexts \
$(SRC_DIR)/utils/general \
$(SRC_DIR)/utils/gzstream \
$(SRC_DIR)/utils/fileType \
$(SRC_DIR)/utils/bedFilePE \
$(SRC_DIR)/utils/KeyListOps \
$(SRC_DIR)/utils/NewChromsweep \
$(SRC_DIR)/utils/sequenceUtilities \
$(SRC_DIR)/utils/tabFile \
$(SRC_DIR)/utils/BamTools-Ancillary \
$(SRC_DIR)/utils/BlockedIntervals \
$(SRC_DIR)/utils/Fasta \
$(SRC_DIR)/utils/VectorOps \
$(SRC_DIR)/utils/GenomeFile \
$(SRC_DIR)/utils/RecordOutputMgr \
$(SRC_DIR)/utils/ToolBase \
$(SRC_DIR)/utils/driver \
$(SRC_DIR)/utils/BamTools
INCLUDES = $(addprefix -I,$(SUBDIRS) $(UTIL_SUBDIRS)) \
-I$(SRC_DIR)/utils/BamTools/include \
-I$(HTSDIR) \
-I$(SRC_DIR)/utils/lineFileUtilities \
-I$(SRC_DIR)/utils/Point \
-I$(SRC_DIR)/utils/stringUtilities
# Ensure that the user's $CXXFLAGS/etc are applied after bedtools's.
ALL_CXXFLAGS = $(BT_CXXFLAGS) $(CXXFLAGS)
ALL_CPPFLAGS = $(BT_CPPFLAGS) $(CPPFLAGS)
ALL_LDFLAGS = $(BT_LDFLAGS) $(LDFLAGS)
ALL_LIBS = $(BT_LIBS) $(LIBS)
all: print_banner $(BIN_DIR)/bedtools $(BIN_DIR)/intersectBed
static: print_banner $(BIN_DIR)/bedtools.static
BUILT_OBJECTS = $(OBJ_DIR)/bedtools.o $(OBJ_DIR)/htsutil.o
# Include all the Makefile fragments, which add to $(BUILT_OBJECTS)
include $(patsubst %,%/Makefile.frag,$(SUBDIRS) $(UTIL_SUBDIRS))
## Automatically generate C++ dependencies.
## $(DEPFLAGS) is a set of compiler flags that causes the compiler to generate
## dependencies as a byproduct (which we write to a temporary file, only moving
## it into place on successful compilations).
## We then include the dependency files into this Makefile.
## The subdirectories' Makefile fragments contain rules like the one for
## $(OBJ_DIR)/bedtools.o below, with a dependency on obj/foo.d so that if
## the dependency file is missing the target will be rebuilt.
##
DEPFLAGS = -MT $@ -MMD -MP -MF $*.Td
define CXX_COMPILE
@echo " * compiling $<"
$(CCPREFIX) $(CC_WRAPPER) $(CXX) $(ALL_CXXFLAGS) $(ALL_CPPFLAGS) $(DEPFLAGS) -c -o $@ $<
@mv -f $*.Td $*.d
endef
$(OBJ_DIR)/%.d: ;
.PRECIOUS: $(OBJ_DIR)/%.d
-include $(patsubst %.o,%.d,$(BUILT_OBJECTS))
$(OBJ_DIR)/bedtools.o: $(SRC_DIR)/bedtools.cpp $(OBJ_DIR)/bedtools.d
$(CXX_COMPILE)
$(OBJ_DIR)/htsutil.o: $(SRC_DIR)/htsutil.cpp $(OBJ_DIR)/htsutil.d
$(CXX_COMPILE)
# HTSlib's htslib.mk provides rules to rebuild $(HTSDIR)/libhts.a.
HTSDIR = src/utils/htslib
include $(HTSDIR)/htslib.mk
# This order-only prerequisite ensures OBJ_DIR exists before building any .o file
# but ignores the directory's timestamp, which changes every time a .o file is written.
$(BUILT_OBJECTS): | $(OBJ_DIR)
$(BUILT_OBJECTS): autoversion
$(BIN_DIR)/bedtools: autoversion $(BUILT_OBJECTS) $(HTSDIR)/libhts.a | $(BIN_DIR)
@echo "- Building main bedtools binary."
$(CCPREFIX) $(CC_WRAPPER) $(CXX) $(ALL_LDFLAGS) -o $(BIN_DIR)/bedtools $(BUILT_OBJECTS) $(HTSDIR)/libhts.a $(ALL_LIBS)
@echo "done."
$(BIN_DIR)/bedtools.static: autoversion $(BUILT_OBJECTS) $(HTSDIR)/libhts.a | $(BIN_DIR)
@echo "- Building main bedtools binary."
$(CCPREFIX) $(CC_WRAPPER) $(CXX) -static $(ALL_LDFLAGS) -o $(BIN_DIR)/bedtools.static $(BUILT_OBJECTS) $(HTSDIR)/libhts.a $(ALL_LIBS)
@echo "done."
test/htsutil: $(OBJ_DIR)/htsutil.o $(HTSDIR)/libhts.a
$(CCPREFIX) $(CC_WRAPPER) $(CXX) $(ALL_LDFLAGS) -o test/htsutil $(OBJ_DIR)/htsutil.o $(HTSDIR)/libhts.a $(ALL_LIBS)
$(BIN_DIR)/intersectBed: | $(BIN_DIR)
@echo "- Creating executables for old CLI."
@$(PYTHON) scripts/makeBashScripts.py
@chmod +x bin/*
@echo "done."
.PHONY: all
install:
mkdir -p $(DESTDIR)$(prefix)/bin
for file in bin/* ; do \
cp -f $$file $(DESTDIR)$(prefix)/bin; \
done
print_banner:
@echo "Building BEDTools:"
@echo "========================================================="
@echo "CXXFLAGS is [$(ALL_CXXFLAGS)]"
.PHONY: print_banner
# make the "obj/" and "bin/" directories, if they don't exist
$(OBJ_DIR) $(BIN_DIR):
@mkdir -p $@
# Usually HTSlib's configure script has not been used (detected via config.mk
# not existing), so clean should also remove the generated config.h.
clean:
@echo " * Cleaning up."
@rm -f $(VERSION_FILE) $(OBJ_DIR)/* $(BIN_DIR)/* test/htsutil
@cd src/utils/htslib && make clean > /dev/null
@test -e src/utils/htslib/config.mk || rm -f src/utils/htslib/config.h
.PHONY: clean
test:
@cd test; bash test.sh
.PHONY: test
## For BEDTools developers (not users):
## When you want to release (and tag) a new version, run:
## $ make setversion VERSION=v2.17.2
## This will:
## 1. Update the "/src/utils/version/version_release.txt" file
## 2. Commit the file
## 3. Git-Tag the commit with the latest version
##
.PHONY: setversion
setversion:
ifeq "$(VERSION)" ""
$(error please set VERSION variable to the new version (e.g "make setversion VERSION=v2.17.2"))
endif
@echo "# This file was auto-generated by running \"make setversion VERSION=$(VERSION)\"" > "$(RELEASED_VERSION_FILE)"
@echo "# on $$(date) ." >> "$(RELEASED_VERSION_FILE)"
@echo "# Please do not edit or commit this file manually." >> "$(RELEASED_VERSION_FILE)"
@echo "#" >> "$(RELEASED_VERSION_FILE)"
@echo "$(VERSION)" >> $(RELEASED_VERSION_FILE)
@git add $(RELEASED_VERSION_FILE)
@git commit -q -m "Setting Release-Version $(VERSION)"
@git tag "$(VERSION)"
@echo "Version updated to $(VERSION)."
@echo ""
@echo "Don't forget to push the commits AND the tags:"
@echo " git push --all --tags"
@echo ""
## Automatic version detection
##
## What's going on here?
## 1. If there's a ".git" repository - use the version from the repository.
## ignore any released-version file. git repository is authorative.
##
## 2, If there's no ".git" repository,
## get the "released" version number from the release-version file.
##
## 2.1. If the current directory looks like "arq5x-bedtools-XXXXXXX",
## assume "-XXXXXX" is the last revision number (and the user
## probably downloaded the ZIP from github).
## Append the revision number to the released version string.
##
## 3. Compare the detected version (from steps 1,2) to the current string
## in ./src/utils/version/version_git.h .
## If they differ, update the header file - will cause a recompilation
## of version.o .
##
.PHONY: autoversion
autoversion:
@( \
if [ -d ".git" ] && which git > /dev/null ; then \
DETECTED_VERSION=$$(git describe --always --tags --dirty) ; \
else \
DETECTED_VERSION=$$(grep -v "^#" "$(RELEASED_VERSION_FILE)") ; \
if basename $$(pwd) | grep -q "^[[:alnum:]]*-bedtools-[[:alnum:]]*$$" ; then \
DETECTED_VERSION=$${DETECTED_VERSION}-zip-$$(basename "$$(pwd)" | sed 's/^[[:alnum:]]*-bedtools-//') ; \
fi ; \
fi ; \
\
CURRENT_VERSION="" ; \
[ -e "$(VERSION_FILE)" ] && CURRENT_VERSION=$$(grep "define VERSION_GIT " "$(VERSION_FILE)" | cut -f3 -d" " | sed 's/"//g') ; \
\
echo "DETECTED_VERSION = $$DETECTED_VERSION" ; \
echo "CURRENT_VERSION = $$CURRENT_VERSION" ; \
if [ "$${DETECTED_VERSION}" != "$${CURRENT_VERSION}" ] ; then \
echo "Updating version file." ; \
echo "#ifndef VERSION_GIT_H" > $(VERSION_FILE) ; \
echo "#define VERSION_GIT_H" >> $(VERSION_FILE) ; \
echo "#define VERSION_GIT \"$${DETECTED_VERSION}\"" >> $(VERSION_FILE) ; \
echo "#endif /* VERSION_GIT_H */" >> $(VERSION_FILE) ; \
fi )
|