2023-07-03 14:58:09 +03:00
|
|
|
BD ?= build
|
|
|
|
SD ?= src
|
|
|
|
LIBS_DIR ?= libs
|
|
|
|
LIBS ?= $(wildcard $(LIBS_DIR)/*)
|
|
|
|
|
2023-07-05 14:43:56 +03:00
|
|
|
CGI_EXECS ?= view_comments.cgi new_client.cgi
|
2023-07-05 00:46:12 +03:00
|
|
|
EXEC_TARGETS := $(patsubst %.cgi,$(BD)/%.cgi,$(CGI_EXECS))
|
|
|
|
|
2023-07-04 18:39:14 +03:00
|
|
|
LDFLAGS ?= -L$(BD)/ -lcgic -lqments -lhiredis -ltomcrypt -luuid
|
2023-07-03 14:58:09 +03:00
|
|
|
|
|
|
|
SRC_FILES := $(shell find $(SD) -name *.c)
|
2023-07-05 00:46:12 +03:00
|
|
|
EXEC_OBJS := $(patsubst %.cgi,$(BD)/%.o,$(CGI_EXECS))
|
|
|
|
OBJ_FILES := $(filter-out $(EXEC_OBJS),$(patsubst $(SD)/%.c,$(BD)/%.o,$(SRC_FILES)))
|
2023-07-03 14:58:09 +03:00
|
|
|
|
|
|
|
INCLUDE_DIRS = -Ilibs/qments/include -Ilibs/cgic
|
|
|
|
LIB_TARGETS = $(patsubst $(LIBS_DIR)/%,$(BD)/lib%.a,$(LIBS))
|
|
|
|
|
2023-07-04 18:39:14 +03:00
|
|
|
CFLAGS ?= -O2 -std=c99 -pedantic
|
2023-07-03 20:52:50 +03:00
|
|
|
|
2023-07-03 14:58:09 +03:00
|
|
|
$(BD)/libcgic.a:
|
|
|
|
$(MAKE) -C $(LIBS_DIR)/cgic
|
2023-07-04 18:39:14 +03:00
|
|
|
mkdir -p $(@D)
|
2023-07-03 14:58:09 +03:00
|
|
|
cp $(LIBS_DIR)/cgic/libcgic.a $(BD)
|
|
|
|
|
|
|
|
$(BD)/libqments.a:
|
2023-07-03 16:39:36 +03:00
|
|
|
$(MAKE) -C $(LIBS_DIR)/qments static
|
2023-07-03 14:58:09 +03:00
|
|
|
cp $(LIBS_DIR)/qments/$(BD)/libqments.a $(BD)
|
|
|
|
|
2023-07-05 00:46:12 +03:00
|
|
|
$(BD)/%.cgi: $(BD)/%.o $(OBJ_FILES)
|
2023-07-05 14:43:56 +03:00
|
|
|
mkdir -p $(@D)
|
2023-07-03 14:58:09 +03:00
|
|
|
$(CC) $(INCLUDE_DIRS) $(CFLAGS) $^ -o $@ $(LDFLAGS)
|
|
|
|
|
|
|
|
$(BD)/%.o: $(SD)/%.c $(LIB_TARGETS)
|
|
|
|
mkdir -p $(@D)
|
|
|
|
$(CC) $(INCLUDE_DIRS) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
|
|
|
|
|
2023-07-05 14:43:56 +03:00
|
|
|
all: $(EXEC_TARGETS)
|
2023-07-03 14:58:09 +03:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rfI $(BD)/
|
|
|
|
|
|
|
|
.PHONY: all clean
|