modfetch/Makefile
jacekpoz d24c1d3767
big refactor of pretty much everything
I still need to make the Makefile better as it's pretty shit right now
but it's alright for now I think
2024-02-11 23:23:50 +01:00

47 lines
1.1 KiB
Makefile

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
CFLAGS += -Iinclude
LDFLAGS =
NAME = modfetch
SRC = src
_PROG = modfetch.c
PROG = $(addprefix $(SRC)/, $(_PROG))
_LIB = config.c semver.c util.c
LIB = $(addprefix $(SRC)/, $(_LIB))
OBJ = $(_PROG:.c=.o) $(_LIB:.c=.o)
BIN = target
_MOD = $(wildcard modules/*.c)
MOD = $(_MOD:modules/%=%)
.PHONY: all clean
all: dirs modules $(NAME)
modules: dirs $(MOD:.c=.so)
dirs:
mkdir -p $(BIN)
$(NAME): $(OBJ)
$(CC) $(addprefix $(BIN)/, $^) $(LDFLAGS) -o $(BIN)/$@
%.so: modules/%.c $(LIB)
$(CC) $^ -shared -fPIC $(CFLAGS) $(LDFLAGS) -o $(BIN)/$@
%.o: src/%.c
$(CC) -c $< $(CFLAGS) -o $(BIN)/$@
clean: clean_modules
rm -rf $(addprefix $(BIN)/, $(OBJ))
rm -rf $(BIN)/$(NAME)
clean_modules:
rm -rf $(wildcard $(BIN)/*.so)