2021-12-16 17:16:16 +01:00
|
|
|
-include config.out
|
|
|
|
|
2021-12-08 19:14:51 +01:00
|
|
|
CXX ?= g++
|
2022-04-05 15:04:22 +02:00
|
|
|
CPPFLAGS ?= -DFORMATTED_TEXT
|
2021-12-17 10:25:32 +01:00
|
|
|
CXXFLAGS := -std=c++11 -g -Wall -pedantic
|
2021-12-08 19:14:51 +01:00
|
|
|
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)
|
2021-12-20 15:58:00 +01:00
|
|
|
TRACKING_DIR ?= $(HOME)/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
|
2022-04-05 15:04:22 +02:00
|
|
|
$(CXX) -DPREFIX=$(PREFIX) $(CPPFLAGS) $(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-20 15:58:00 +01:00
|
|
|
@echo "tt has been uninstalled from $(PREFIX). The tracking data in $(TRACKING_DIR) has not been deleted."
|
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
|