lat/Makefile

42 lines
827 B
Makefile
Raw Permalink Normal View History

2023-04-10 22:55:54 +00:00
NAME:=lat
2023-04-09 17:42:44 +00:00
2023-04-10 22:55:54 +00:00
SRCDIR:=src
IDIR:=include
ODIR:=obj
BINDIR:=build
2023-04-09 17:42:44 +00:00
2023-04-10 22:55:54 +00:00
CC:=cc
2023-05-01 22:07:53 +00:00
# OMG SO FAST (see https://www.shlomifish.org/humour/by-others/funroll-loops/Gentoo-is-Rice.html)
# CFLAGS:=-I$(IDIR) -Wall -Wextra -pedantic -Ofast -faggressive-loop-optimizations -funroll-all-loops -march=native
# For a stable experience
CFLAGS:=-I$(IDIR) -Wall -Wextra -pedantic -O2 -march=native
2023-04-10 22:55:54 +00:00
LIB:=
2023-04-09 17:42:44 +00:00
2023-04-10 22:55:54 +00:00
DEPS:=$($(IDIR)/%.h)
2023-04-09 17:42:44 +00:00
2023-04-10 22:55:54 +00:00
SRCS=$(shell find . -name "*.c")
2023-04-10 23:09:11 +00:00
BASENAME:=$(shell basename -a $(SRCS))
2023-04-09 17:42:44 +00:00
2023-04-10 22:55:54 +00:00
VPATH=$(dir $(SRCS))
2023-04-09 17:42:44 +00:00
2023-04-10 22:55:54 +00:00
OBJ=$(patsubst %.c,./$(ODIR)/%.o,$(BASENAME))
$(ODIR)/%.o: %.c $(DEPS)
2023-04-09 17:42:44 +00:00
$(CC) -c -o $@ $< $(CFLAGS) $(LIB)
$(NAME): $(OBJ)
$(CC) -o $(BINDIR)/$@ $^ $(CFLAGS) $(LIB)
.PHONY: prep
prep:
-@mkdir -p $(SRCDIR)
-@mkdir -p $(IDIR)
-@mkdir -p $(ODIR)
-@mkdir -p $(BINDIR)
.PHONY: clean
clean:
-rm -f $(ODIR)/*
-rm -f $(BINDIR)/*