diff --git a/Makefile b/Makefile index 6f13331..d8d1461 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,16 @@ -CGI_EXEC ?= main.cgi - BD ?= build SD ?= src LIBS_DIR ?= libs LIBS ?= $(wildcard $(LIBS_DIR)/*) +CGI_EXECS ?= view_comments.cgi +EXEC_TARGETS := $(patsubst %.cgi,$(BD)/%.cgi,$(CGI_EXECS)) + LDFLAGS ?= -L$(BD)/ -lcgic -lqments -lhiredis -ltomcrypt -luuid SRC_FILES := $(shell find $(SD) -name *.c) -OBJ_FILES := $(patsubst $(SD)/%.c,$(BD)/%.o,$(SRC_FILES)) +EXEC_OBJS := $(patsubst %.cgi,$(BD)/%.o,$(CGI_EXECS)) +OBJ_FILES := $(filter-out $(EXEC_OBJS),$(patsubst $(SD)/%.c,$(BD)/%.o,$(SRC_FILES))) INCLUDE_DIRS = -Ilibs/qments/include -Ilibs/cgic LIB_TARGETS = $(patsubst $(LIBS_DIR)/%,$(BD)/lib%.a,$(LIBS)) @@ -24,14 +26,14 @@ $(BD)/libqments.a: $(MAKE) -C $(LIBS_DIR)/qments static cp $(LIBS_DIR)/qments/$(BD)/libqments.a $(BD) -$(BD)/$(CGI_EXEC): $(OBJ_FILES) +$(BD)/%.cgi: $(BD)/%.o $(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) +all: $(BD)/$(CGI_EXECS) clean: rm -rfI $(BD)/ diff --git a/src/auth.h b/src/auth.h index 1e02bbc..5f78fca 100644 --- a/src/auth.h +++ b/src/auth.h @@ -7,6 +7,7 @@ int user_by_session_id(const char *session_id, char *username); /* return 0 on failure, 1 on success, negative number on error */ +/* authenticate must assign a session id */ int authenticate(const char *username, const char *password, char *sid); #endif /* AUTH_H */ diff --git a/src/main.c b/src/view_comments.c similarity index 100% rename from src/main.c rename to src/view_comments.c