Add support for HTTPS, Windows, and Linux builds to Makefile

This commit is contained in:
2025-11-26 16:10:52 +01:00
parent 52ee89252c
commit bb753ad8ee
2 changed files with 24 additions and 7 deletions
+21 -4
View File
@@ -1,12 +1,29 @@
CFLAGS = -ggdb
LFLAGS =
ifeq ($(shell uname -s),Linux)
EXT =
else
EXT = .exe
LFLAGS += -lws2_32
endif
HTTPS ?= 0
ifneq ($(HTTPS),0)
CFLAGS += -DHTTPS_ENABLED
LFLAGS += -lcrypto -lssl
endif
.PHONY: all clean example .PHONY: all clean example
all: chttp.c chttp.h simple_client simple_server all: chttp.c chttp.h simple_client$(EXT) simple_server$(EXT)
chttp.c chttp.h: $(wildcard src/*.c src/*.h) misc/amalg.py Makefile chttp.c chttp.h: $(wildcard src/*.c src/*.h) misc/amalg.py Makefile
python misc/amalg.py python misc/amalg.py
%: examples/%.c chttp.c chttp.h %$(EXT): examples/%.c chttp.c chttp.h
gcc $< chttp.c -o $@ -ggdb gcc $< chttp.c -o $@ $(CFLAGS) $(LFLAGS)
clean: clean:
rm chttp.c chttp.h rm chttp.c chttp.h simple_client simple_client.exe simple_server simple_server.exe
+3 -3
View File
@@ -20,13 +20,13 @@ int main(void)
for (;;) { for (;;) {
void *ptrs[HTTP_SERVER_CAPACITY+3]; void *ptrs[HTTP_SERVER_POLL_CAPACITY];
struct pollfd polled[HTTP_SERVER_CAPACITY+3]; struct pollfd polled[HTTP_SERVER_POLL_CAPACITY];
EventRegister reg = { EventRegister reg = {
.ptrs=ptrs, .ptrs=ptrs,
.polled=polled, .polled=polled,
.max_polled=HTTP_SERVER_CAPACITY+3, .max_polled=HTTP_SERVER_POLL_CAPACITY,
.num_polled=0, .num_polled=0,
}; };