1
0
Fork 0
yc.hackclub.app/Makefile
yc 541b6c05db
🔨 Heavily improve Makefile + Add 'install' target.
Signed-off-by: yc <yc@hackclub.app>
2024-04-29 09:17:12 +00:00

24 lines
555 B
Makefile

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 {} \;