🔨 Heavily improve Makefile + Add 'install' target.
Signed-off-by: yc <yc@hackclub.app>
This commit is contained in:
parent
54efca802d
commit
541b6c05db
1 changed files with 11 additions and 1 deletions
12
Makefile
12
Makefile
|
@ -1,14 +1,24 @@
|
||||||
CC = cc
|
CC = cc
|
||||||
CFLAGS = -O4 -Ofast -march=native -flto -fomit-frame-pointer -finline-functions -funroll-loops -std=c2x
|
CFLAGS = -O4 -Ofast -march=native -flto -fomit-frame-pointer -finline-functions -funroll-loops -std=c2x
|
||||||
DIR = cgi
|
DIR = cgi
|
||||||
|
PREFIX = ~
|
||||||
|
|
||||||
|
FIND = find
|
||||||
|
CP = cp
|
||||||
|
|
||||||
SOURCES = $(wildcard $(DIR)/*.c)
|
SOURCES = $(wildcard $(DIR)/*.c)
|
||||||
TARGETS = $(patsubst $(DIR)/%.c,%,$(SOURCES))
|
TARGETS = $(patsubst $(DIR)/%.c,%,$(SOURCES))
|
||||||
|
|
||||||
|
.PHONY: all install clean
|
||||||
|
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
|
|
||||||
%: $(DIR)/%.c
|
%: $(DIR)/%.c
|
||||||
$(CC) $(CFLAGS) -o $(DIR)/$@ $<
|
$(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:
|
clean:
|
||||||
find $(DIR)/ -type f ! -name '*.c' -exec rm -f {} \;
|
$(FIND) $(DIR)/ -type f ! -name '*.c' -exec rm -f {} \;
|
||||||
|
|
Loading…
Reference in a new issue