From 541b6c05db584caf09597a55fcd5eb4f571e276a Mon Sep 17 00:00:00 2001 From: yc Date: Mon, 29 Apr 2024 09:17:12 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Heavily=20improve=20Makefile=20+?= =?UTF-8?q?=20Add=20'install'=20target.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yc --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 43cdda6..eb3ab60 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,24 @@ CC = cc CFLAGS = -O4 -Ofast -march=native -flto -fomit-frame-pointer -finline-functions -funroll-loops -std=c2x DIR = cgi +PREFIX = ~ + +FIND = find +CP = cp SOURCES = $(wildcard $(DIR)/*.c) TARGETS = $(patsubst $(DIR)/%.c,%,$(SOURCES)) +.PHONY: all install clean + all: $(TARGETS) %: $(DIR)/%.c $(CC) $(CFLAGS) -o $(DIR)/$@ $< +install: $(TARGETS) + mkdir -p $(PREFIX)/$(DIR) + $(FIND) $(DIR)/ -type f -exec file {} \; | grep "executable" | cut -d: -f1 | xargs -I {} $(CP) {} $(PREFIX)/$(DIR) + clean: - find $(DIR)/ -type f ! -name '*.c' -exec rm -f {} \; + $(FIND) $(DIR)/ -type f ! -name '*.c' -exec rm -f {} \;