modfetch/Makefile

41 lines
839 B
Makefile
Raw Normal View History

2024-02-09 12:05:06 +01:00
CC = gcc
CFLAGS = -std=c99 -O3 -Wall -Wextra -Wpedantic -Wstrict-aliasing
CFLAGS += -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wcast-align
CFLAGS += -Wstrict-prototypes -Wstrict-overflow=5 -Wwrite-strings
CFLAGS += -Wcast-qual -Wswitch-default -Wswitch-enum
CFLAGS += -Wconversion -Wunreachable-code
# for asprintf() and getline()
CFLAGS += -D_GNU_SOURCE
LDFLAGS =
SRC = modfetch.c
OBJ = $(BIN)/$(SRC:.c=.o)
BIN = target
TEMPMOD = $(wildcard modules/*.c)
MOD = $(TEMPMOD:modules/%=%)
PROGRAM = modfetch
2024-02-09 13:33:06 +01:00
.PHONY: all clean
2024-02-09 12:05:06 +01:00
2024-02-09 13:33:06 +01:00
all: dirs modules $(PROGRAM)
2024-02-09 12:05:06 +01:00
modules: dirs $(MOD:.c=.so)
dirs:
mkdir -p ./$(BIN)
run: all
$(BIN)/$(PROGRAM)
$(PROGRAM): $(OBJ)
$(CC) -o $(BIN)/$(PROGRAM) $^ $(LDFLAGS)
$(BIN)/%.o: %.c
$(CC) -o $@ -c $< $(CFLAGS)
%.so: modules/%.c
$(CC) -o $(BIN)/$@ $^ -shared -fPIC $(CFLAGS)
2024-02-09 13:33:06 +01:00
clean:
2024-02-09 12:05:06 +01:00
rm -rf $(BIN)