2024-06-23 14:08:44 +02:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
CC = gcc
|
|
|
|
CFLAGS = -Wall -Wextra -Werror -Wno-unused-parameter
|
|
|
|
CFLAGS += -Wno-unused-variable -Wno-unused-function
|
|
|
|
CFLAGS += -Wno-unused-but-set-variable -Wno-unused-value -Wno-unused-label
|
2024-06-23 15:06:21 +02:00
|
|
|
CFLAGS += -Wno-unused-result -Wno-unused-const-variable
|
|
|
|
CFLAGS += -fno-exceptions -fno-asynchronous-unwind-tables -fno-ident
|
|
|
|
CFLAGS += -fno-unwind-tables -fno-stack-protector -fno-plt -fno-pic
|
|
|
|
CFLAGS += -O3 -std=c99 -march=native -mtune=native -fomit-frame-pointer
|
2024-06-23 14:08:44 +02:00
|
|
|
|
|
|
|
C_SOURCES = $(wildcard *.c)
|
|
|
|
C_HEADERS = $(wildcard *.h)
|
|
|
|
OBJECTS = $(C_SOURCES:.c=.o)
|
2024-06-23 14:27:23 +02:00
|
|
|
ASMS = $(C_SOURCES:.c=.s)
|
2024-06-23 14:08:44 +02:00
|
|
|
|
|
|
|
all: $(OBJECTS)
|
|
|
|
|
|
|
|
%.o: %.c $(C_HEADERS)
|
|
|
|
@echo "CC $<"
|
|
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2024-06-23 14:27:23 +02:00
|
|
|
%.s: %.c $(C_HEADERS)
|
|
|
|
@echo "CC $<"
|
|
|
|
@$(CC) $(CFLAGS) -S -masm=intel $<
|
2024-06-23 15:06:21 +02:00
|
|
|
wc -l $@
|
2024-06-23 14:27:23 +02:00
|
|
|
|
2024-06-23 16:27:51 +02:00
|
|
|
driver: $(OBJECTS)
|
|
|
|
@$(CC) $(CFLAGS) $^ -o $@
|
|
|
|
|
|
|
|
run: driver
|
|
|
|
@./driver
|
|
|
|
|
2024-06-23 14:08:44 +02:00
|
|
|
clean:
|
2024-06-23 14:44:19 +02:00
|
|
|
rm -f $(OBJECTS) $(ASMS)
|
2024-06-23 14:08:44 +02:00
|
|
|
|
2024-06-23 14:27:23 +02:00
|
|
|
asm: $(ASMS)
|
|
|
|
|
2024-06-23 14:08:44 +02:00
|
|
|
format:
|
|
|
|
clang-format -i $(C_SOURCES) $(C_HEADERS)
|
|
|
|
|
2024-06-23 14:44:19 +02:00
|
|
|
.PHONY: all clean format asm
|