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
|
2024-02-11 23:23:50 +01:00
|
|
|
CFLAGS += -Iinclude
|
2024-02-09 12:05:06 +01:00
|
|
|
LDFLAGS =
|
|
|
|
|
2024-02-11 17:44:35 +01:00
|
|
|
NAME = modfetch
|
|
|
|
|
2024-02-11 23:23:50 +01:00
|
|
|
SRC = src
|
2024-02-11 23:46:59 +01:00
|
|
|
BIN = target
|
|
|
|
|
|
|
|
_PROG = config.c fetch.c main.c util.c
|
2024-02-11 23:23:50 +01:00
|
|
|
PROG = $(addprefix $(SRC)/, $(_PROG))
|
2024-02-11 23:46:59 +01:00
|
|
|
|
2024-02-11 23:27:01 +01:00
|
|
|
_LIB = semver.c
|
2024-02-11 23:23:50 +01:00
|
|
|
LIB = $(addprefix $(SRC)/, $(_LIB))
|
2024-02-11 23:46:59 +01:00
|
|
|
|
2024-02-11 23:23:50 +01:00
|
|
|
OBJ = $(_PROG:.c=.o) $(_LIB:.c=.o)
|
2024-02-11 23:46:59 +01:00
|
|
|
|
2024-02-11 23:23:50 +01:00
|
|
|
_MOD = $(wildcard modules/*.c)
|
|
|
|
MOD = $(_MOD:modules/%=%)
|
2024-02-09 12:05:06 +01:00
|
|
|
|
2024-02-09 13:33:06 +01:00
|
|
|
.PHONY: all clean
|
2024-02-09 12:05:06 +01:00
|
|
|
|
2024-02-11 17:44:35 +01:00
|
|
|
all: dirs modules $(NAME)
|
2024-02-09 12:05:06 +01:00
|
|
|
|
|
|
|
modules: dirs $(MOD:.c=.so)
|
|
|
|
|
|
|
|
dirs:
|
2024-02-11 17:44:35 +01:00
|
|
|
mkdir -p $(BIN)
|
|
|
|
|
|
|
|
$(NAME): $(OBJ)
|
2024-02-11 22:19:27 +01:00
|
|
|
$(CC) $(addprefix $(BIN)/, $^) $(LDFLAGS) -o $(BIN)/$@
|
2024-02-09 12:05:06 +01:00
|
|
|
|
2024-02-11 17:44:35 +01:00
|
|
|
%.so: modules/%.c $(LIB)
|
2024-02-11 22:19:27 +01:00
|
|
|
$(CC) $^ -shared -fPIC $(CFLAGS) $(LDFLAGS) -o $(BIN)/$@
|
2024-02-09 12:05:06 +01:00
|
|
|
|
2024-02-11 23:23:50 +01:00
|
|
|
%.o: src/%.c
|
2024-02-11 22:19:27 +01:00
|
|
|
$(CC) -c $< $(CFLAGS) -o $(BIN)/$@
|
2024-02-09 12:05:06 +01:00
|
|
|
|
2024-02-10 14:09:43 +01:00
|
|
|
clean: clean_modules
|
2024-02-11 17:44:35 +01:00
|
|
|
rm -rf $(addprefix $(BIN)/, $(OBJ))
|
|
|
|
rm -rf $(BIN)/$(NAME)
|
2024-02-10 14:09:43 +01:00
|
|
|
|
|
|
|
clean_modules:
|
|
|
|
rm -rf $(wildcard $(BIN)/*.so)
|