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)) $(BD)/libcgic.a: $(MAKE) -C $(LIBS_DIR)/cgic cp $(LIBS_DIR)/cgic/libcgic.a $(BD) $(BD)/libqments.a: $(MAKE) -C $(LIBS_DIR)/qments static 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