ringbuf/Makefile

68 lines
1.4 KiB
Makefile
Raw Normal View History

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
2024-06-30 05:28:58 +02:00
CFLAGS += -Wno-unused-but-set-variable -Wno-unused-value -Wno-unused-label
CFLAGS += -Wno-unused-result -Wno-unused-const-variable
2024-06-27 01:21:25 +02:00
CFLAGS += -I.
ifneq ($(RELEASE), 1)
CFLAGS += -g -O0 -std=c99 -march=native -mtune=native
CFLAGS += -DDEBUG
else
2024-06-30 05:28:58 +02:00
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-07-02 06:27:22 +02:00
CFLAGS += -fshort-enums
2024-07-02 10:31:52 +02:00
endif # DEBUG
2024-06-27 01:21:25 +02:00
2024-07-02 10:31:52 +02:00
LDFLAGS = -lm
2024-06-27 01:21:25 +02:00
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 16:27:51 +02:00
driver: $(OBJECTS)
2024-07-02 10:31:52 +02:00
@$(CC) $(LDFLAGS) $^ -o $@
2024-06-23 16:27:51 +02:00
run: driver
@./driver
2024-07-02 05:39:08 +02:00
lib: $(OBJECTS)
@ar rcs librbuf.a ringbuf.o
dylib: $(OBJECTS)
2024-07-02 10:31:52 +02:00
@$(CC) $(LDLAGS) -fPIC -shared -o librbuf.so ringbuf.o
2024-07-02 05:39:08 +02:00
install:
@cp librbuf.a /usr/local/lib
@cp ringbuf.h /usr/local/include
2024-06-23 14:08:44 +02:00
clean:
rm -f $(OBJECTS) $(ASMS) driver librbuf.a librbuf.so **/*.o **/*.elf
2024-06-23 14:08:44 +02:00
asm: $(ASMS) $(OBJECTS)
wc -l $(ASMS)
size $(OBJECTS)
2024-06-23 14:27:23 +02:00
2024-07-02 06:33:00 +02:00
tidy:
@clang-tidy $(C_SOURCES) -- $(CFLAGS)
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