Skip to content
Snippets Groups Projects
Commit 915746cb authored by Assaf Gordon's avatar Assaf Gordon
Browse files

Makefile: extract the sub-dir make into targets.

Allows parallel make with "-j N" .
Recommended in "Managing Projects with GNU Make", chapter 6, page 109.
parent 3db23b18
No related branches found
No related tags found
No related merge requests found
...@@ -78,25 +78,7 @@ UTIL_SUBDIRS = $(SRC_DIR)/utils/bedFile \ ...@@ -78,25 +78,7 @@ UTIL_SUBDIRS = $(SRC_DIR)/utils/bedFile \
BUILT_OBJECTS = $(OBJ_DIR)/*.o BUILT_OBJECTS = $(OBJ_DIR)/*.o
all: gitversion all: print_banner $(OBJ_DIR) $(BIN_DIR) gitversion $(UTIL_SUBDIRS) $(SUBDIRS)
[ -d $(OBJ_DIR) ] || mkdir -p $(OBJ_DIR)
[ -d $(BIN_DIR) ] || mkdir -p $(BIN_DIR)
@echo "Building BEDTools:"
@echo "========================================================="
@for dir in $(UTIL_SUBDIRS); do \
echo "- Building in $$dir"; \
$(MAKE) --no-print-directory -C $$dir; \
echo ""; \
done
@for dir in $(SUBDIRS); do \
echo "- Building in $$dir"; \
$(MAKE) --no-print-directory -C $$dir; \
echo ""; \
done
@echo "- Building main bedtools binary." @echo "- Building main bedtools binary."
@$(CXX) $(CXXFLAGS) -c src/bedtools.cpp -o obj/bedtools.o -I$(UTIL_DIR)/version/ @$(CXX) $(CXXFLAGS) -c src/bedtools.cpp -o obj/bedtools.o -I$(UTIL_DIR)/version/
@$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/bedtools $(BUILT_OBJECTS) -L$(UTIL_DIR)/BamTools/lib/ -lbamtools $(LIBS) @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/bedtools $(BUILT_OBJECTS) -L$(UTIL_DIR)/BamTools/lib/ -lbamtools $(LIBS)
...@@ -110,6 +92,22 @@ all: gitversion ...@@ -110,6 +92,22 @@ all: gitversion
.PHONY: all .PHONY: all
print_banner:
@echo "Building BEDTools:"
@echo "========================================================="
.PHONY: print_banner
# make the "obj/" and "bin/" directories, if they don't exist
$(OBJ_DIR) $(BIN_DIR):
@mkdir -p $@
# even though these are real directories, treat them as phony targets, forcing to always go in them are re-make.
# a future improvement would be the check for the compiled object, and rebuild only if the source code is newer.
.PHONY: $(UTIL_SUBDIRS) $(SUBDIRS)
$(UTIL_SUBDIRS) $(SUBDIRS): $(OBJ_DIR) $(BIN_DIR)
@echo "- Building in $@"
@$(MAKE) --no-print-directory --directory=$@
clean: clean:
@echo "Cleaning up." @echo "Cleaning up."
@rm -f $(OBJ_DIR)/* $(BIN_DIR)/* @rm -f $(OBJ_DIR)/* $(BIN_DIR)/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment