modfetch/Makefile
jacekpoz 0e9a7d6bd8
"clean up" makefile
will need to rework it again later
2024-02-11 17:44:35 +01:00

43 lines
967 B
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
LDFLAGS =
NAME = modfetch
PROG = modfetch.c
LIB = semver.c
OBJ = $(PROG:.c=.o) $(LIB:.c=.o)
BIN = target
TEMPMOD = $(wildcard modules/*.c)
MOD = $(TEMPMOD:modules/%=%)
.PHONY: all clean
all: dirs modules $(NAME)
modules: dirs $(MOD:.c=.so)
dirs:
mkdir -p $(BIN)
$(NAME): $(OBJ)
$(CC) -o $(BIN)/$(NAME) $(addprefix $(BIN)/, $^) $(LDFLAGS)
%.so: modules/%.c $(LIB)
$(CC) -o $(BIN)/$@ $^ -shared -fPIC $(CFLAGS) $(LDFLAGS)
%.o: %.c
$(CC) -o $(BIN)/$@ -c $< $(CFLAGS)
clean: clean_modules
rm -rf $(addprefix $(BIN)/, $(OBJ))
rm -rf $(BIN)/$(NAME)
clean_modules:
rm -rf $(wildcard $(BIN)/*.so)