Advertisement
bueddl

self counting makefile

May 12th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 0.82 KB | None | 0 0
  1. OBJS_PRESENT := $(shell find source -iname '*.o' -type f | wc -w)
  2. OBJS_REBUILD := $(shell for FILE in $(find source -iname '*.cpp'); do OBJ_FILE=$(echo $FILE | sed 's/.cpp/.o/'); SOURCE_FILE=$(basename $FILE); find $(dirname $FILE) -name $SOURCE_FILE -newer $OBJ_FILE; done | wc -l)
  3. TOTAL := $(shell echo $(OBJS) | wc -w)
  4. $(eval TOTAL = $(shell echo $$(($(TOTAL) + $(OBJS_REBUILD) - $(OBJS_PRESENT)))))
  5. COUNT := 0
  6.  
  7. $(BIN): $(OBJS)
  8.     $(eval BIN_NAME = $(shell echo $(BIN) | sed -r 's/(.*\/)?(.*?)$$/\2/'))
  9.     @echo -ne "\e[1mLD \e[100m[\e[31m$(BIN_NAME)\e[39m]\e[0m "
  10.     $(LD) $(LDFLAGS) -o $(BIN) $^ -lpthread -Wl,-Bstatic -lcryptopp
  11.  
  12. %.o: %.cpp
  13.     $(eval COUNT = $(shell echo $$(($(COUNT) + 1))))
  14.     @echo -ne "\e[1mCXX \e[100m[\e[32m$(COUNT)\e[39m/\e[32m$(TOTAL)\e[39m]\e[0m "
  15.     $(CXX) $(CXXFLAGS) $< -o $@ -Isource/helper -Isource
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement