Added "help" option to makefile

This commit is contained in:
Dan Snyder 2025-05-23 11:45:18 -04:00
parent d18ea48346
commit 0debdf3251

View File

@ -1,5 +1,3 @@
help: ## show help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
CC = gcc
OUT_DIR = ./build
@ -17,23 +15,21 @@ INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CCFLAGS := $(INC_FLAGS)
.PHONY: clean install build
.PHONY: build clean install install-services uninstall-services create-services reinstall-services
install: build create-services install-services
install: build create-services install-services ## Full installation. Builds the proxmon executable, generates service files, installs and starts services
build: $(TARGET)
build: $(TARGET) create-services ## Build the proxmon executable, and generates service files for editing
clean:
clean: ## Remove all build artifacts including generated service files (does not uninstall service files)
@rm -rf bin/ $(OUT_DIR) $(SERVICE_DIR)
./bin:
@mkdir -p ./bin
@cp ./dist/* ./bin
$(OUT_DIR):
@mkdir -p $@
$(OUT_DIR)/%.o: $(SRC_DIRS)/%.c | $(OUT_DIR)
$(OUT_DIR)/%.o: $(SRC_DIRS)/%.c
@mkdir -p $(dir $@)
$(CC) $(CCFLAGS) -c $< -o $@
$(TARGET): $(OBJS) | ./bin
@ -62,14 +58,14 @@ $(SERVICE_DIR):
$(SERVICE_DIR)/%.service: $(TEMPLATE_DIR)/%.service.in | $(SERVICE_DIR)
sed 's|@WORKDIR@|$(WORKDIR)|g' $< > $@
create-services: $(SERVICES)
create-services: $(SERVICES) ## Generate service files from templates into the systemd/ directory
# install service into systemd
# install a service into systemd
$(INSTALL_DIR)/%.service: $(SERVICE_DIR)/%.service
install -m 644 $< $(INSTALL_DIR)/
install-services: create-services $(INSTALLED)
install-services: create-services $(INSTALLED) ## Installs all service files in the systemd/ directory into /etc/systemd/system
systemctl daemon-reload
@for srv in $(SERVICES); do \
name=$$(basename $$srv); \
@ -77,7 +73,7 @@ install-services: create-services $(INSTALLED)
systemctl start $$name; \
done
uninstall-services:
uninstall-services: ## Stops and uninstalls all services associated with ProxMon
@for srv in $(INSTALLED); do \
name=$$(basename $$srv); \
echo "Stopping and uninstalling $$name..."; \
@ -87,4 +83,7 @@ uninstall-services:
done
systemctl daemon-reload
reinstall-services: uninstall-services install-services
reinstall-services: uninstall-services install-services ## Uninstalls and reinstalls ProxMon services
help: ## Show help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)