simple-discuss/Makefile

39 lines
827 B
Makefile
Raw Normal View History

2023-07-03 14:58:09 +03:00
CGI_EXEC ?= main.cgi
BD ?= build
SD ?= src
LIBS_DIR ?= libs
LIBS ?= $(wildcard $(LIBS_DIR)/*)
LDFLAGS ?= -L$(BD)/ -lcgic -lqments
SRC_FILES := $(shell find $(SD) -name *.c)
OBJ_FILES := $(patsubst $(SD)/%.c,$(BD)/%.o,$(SRC_FILES))
INCLUDE_DIRS = -Ilibs/qments/include -Ilibs/cgic
LIB_TARGETS = $(patsubst $(LIBS_DIR)/%,$(BD)/lib%.a,$(LIBS))
2023-07-03 20:52:50 +03:00
CFLAGS ?= -O2 -ansi -pedantic
2023-07-03 14:58:09 +03:00
$(BD)/libcgic.a:
$(MAKE) -C $(LIBS_DIR)/cgic
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)
$(BD)/$(CGI_EXEC): $(OBJ_FILES)
$(CC) $(INCLUDE_DIRS) $(CFLAGS) $^ -o $@ $(LDFLAGS)
$(BD)/%.o: $(SD)/%.c $(LIB_TARGETS)
mkdir -p $(@D)
$(CC) $(INCLUDE_DIRS) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
all: $(BD)/$(CGI_EXEC)
clean:
rm -rfI $(BD)/
.PHONY: all clean