2021-12-16 17:16:16 +01:00
|
|
|
-include config.out
|
|
|
|
|
2021-12-08 19:14:51 +01:00
|
|
|
CXX ?= g++
|
|
|
|
CXXFLAGS := -g -Wall -pedantic
|
|
|
|
OBJFLAGS := $(CXXFLAGS) -c
|
2021-12-10 11:09:03 +01:00
|
|
|
LDFLAGS := -lreadline
|
2021-12-08 19:14:51 +01:00
|
|
|
|
2021-12-16 16:00:40 +01:00
|
|
|
PREFIX ?= /usr/local
|
2021-12-16 17:03:16 +01:00
|
|
|
USER_NAME ?= $(USER)
|
|
|
|
TRACKING_DIR ?= /home/$(USER)/track
|
2021-12-16 16:00:40 +01:00
|
|
|
|
2021-12-08 19:14:51 +01:00
|
|
|
BIN_PATH := bin
|
|
|
|
SRC_PATH := src
|
|
|
|
|
|
|
|
SRC := $(foreach x, $(SRC_PATH), $(wildcard $(addprefix $(x)/*,cpp)))
|
|
|
|
OBJ := $(addprefix $(SRC_PATH)/, $(addsuffix .o, $(notdir $(basename $(SRC)))))
|
|
|
|
|
|
|
|
default: makedir all
|
|
|
|
|
|
|
|
$(BIN_PATH)/tt: $(OBJ)
|
2021-12-16 16:00:40 +01:00
|
|
|
$(CXX) $(CXXFLAGS) -o $@ $(OBJ) $(LDFLAGS)
|
2021-12-08 19:14:51 +01:00
|
|
|
|
|
|
|
$(SRC_PATH)/%.o: $(SRC_PATH)/%.cpp
|
2021-12-16 16:00:40 +01:00
|
|
|
$(CXX) -DPREFIX=$(PREFIX) $(OBJFLAGS) -o $@ $<
|
2021-12-08 19:14:51 +01:00
|
|
|
|
|
|
|
makedir:
|
|
|
|
@mkdir -p $(BIN_PATH)
|
|
|
|
|
|
|
|
all: $(BIN_PATH)/tt
|
2021-12-16 17:16:16 +01:00
|
|
|
@echo "PREFIX=$(PREFIX)" > config.out
|
|
|
|
@echo "USER_NAME=$(USER_NAME)" >> config.out
|
|
|
|
@echo "TRACKING_DIR=$(TRACKING_DIR)" >> config.out
|
2021-12-16 17:03:16 +01:00
|
|
|
install: all
|
|
|
|
@echo "Installing tt at $(PREFIX) for user $(USER_NAME). Tracking directory will be $(TRACKING_DIR)."
|
|
|
|
@mkdir -p $(PREFIX)/bin
|
|
|
|
@mkdir -p $(PREFIX)/etc
|
|
|
|
@cp bin/tt $(PREFIX)/bin
|
|
|
|
@touch $(PREFIX)/etc/tt.conf;\
|
|
|
|
echo "user_name=$(USER_NAME)" > $(PREFIX)/etc/tt.conf;\
|
|
|
|
echo "tracking_directory=$(TRACKING_DIR)" >> $(PREFIX)/etc/tt.conf
|
|
|
|
@echo "tt successfully installed. User name and tracking directory can be adjusted in $(PREFIX)/etc/tt.conf."
|
|
|
|
|
2021-12-16 17:16:16 +01:00
|
|
|
uninstall:
|
|
|
|
rm -rf $(PREFIX)/bin/tt
|
|
|
|
rm -rf $(PREFIX)/etc/tt.conf
|
2021-12-16 17:03:16 +01:00
|
|
|
|
2021-12-08 19:14:51 +01:00
|
|
|
clean:
|
2021-12-16 17:03:16 +01:00
|
|
|
rm -rf $(SRC_PATH)/*.o
|
2021-12-16 17:16:16 +01:00
|
|
|
rm -rf $(BIN_PATH)
|
|
|
|
rm -rf config.out
|
2021-12-08 19:14:51 +01:00
|
|
|
|
|
|
|
.PHONY: makedir clean
|