2024-09-05 07:25:49 +00:00
|
|
|
CC ?= gcc
|
|
|
|
|
2024-09-11 04:28:06 +00:00
|
|
|
COMMON_FLAGS := -Wall -Wextra -Wpedantic \
|
2024-08-31 05:43:53 +00:00
|
|
|
-Ithird_party
|
2024-09-11 04:28:06 +00:00
|
|
|
DEBUG_FLAGS := -Og -g
|
|
|
|
RELEASE_FLAGS := -O3 -DNDEBUG
|
2024-08-29 05:19:46 +00:00
|
|
|
|
2024-09-11 03:56:00 +00:00
|
|
|
ifndef MINIMAL_BUILD_FLAGS
|
2024-09-11 04:11:55 +00:00
|
|
|
COMMON_FLAGS := ${COMMON_FLAGS} \
|
2024-09-11 03:56:00 +00:00
|
|
|
-Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough \
|
|
|
|
-Werror=format-security \
|
|
|
|
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 \
|
|
|
|
-D_GLIBCXX_ASSERTIONS \
|
|
|
|
-fstrict-flex-arrays=3 \
|
|
|
|
-fstack-clash-protection -fstack-protector-strong \
|
|
|
|
-Wl,-z,nodlopen -Wl,-z,noexecstack \
|
|
|
|
-Wl,-z,relro -Wl,-z,now \
|
|
|
|
-Wl,--as-needed -Wl,--no-copy-dt-needed-entries \
|
|
|
|
-fPIE -pie \
|
|
|
|
-Werror=implicit -Werror=incompatible-pointer-types \
|
|
|
|
-Werror=int-conversion
|
2024-09-11 04:11:55 +00:00
|
|
|
ifdef RELEASE
|
|
|
|
COMMON_FLAGS := ${COMMON_FLAGS} \
|
|
|
|
-fno-delete-null-pointer-checks -fno-strict-overflow \
|
|
|
|
-fno-strict-aliasing -ftrivial-auto-var-init=zero
|
|
|
|
endif
|
2024-09-11 03:56:00 +00:00
|
|
|
endif
|
|
|
|
|
2024-08-29 05:19:46 +00:00
|
|
|
ifdef RELEASE
|
2024-09-11 04:11:55 +00:00
|
|
|
CFLAGS = ${COMMON_FLAGS} ${RELEASE_FLAGS}
|
2024-08-29 05:19:46 +00:00
|
|
|
else
|
2024-09-11 04:11:55 +00:00
|
|
|
CFLAGS = ${COMMON_FLAGS} ${DEBUG_FLAGS}
|
2024-08-29 05:19:46 +00:00
|
|
|
endif
|
|
|
|
|
2024-09-01 03:36:04 +00:00
|
|
|
HEADERS = \
|
|
|
|
src/arg_parse.h \
|
|
|
|
src/big_endian.h \
|
|
|
|
src/tcp_socket.h \
|
|
|
|
src/globals.h \
|
|
|
|
src/signal_handling.h \
|
|
|
|
src/constants.h \
|
|
|
|
src/http.h \
|
2024-09-03 07:20:18 +00:00
|
|
|
src/config.h \
|
2024-09-09 03:39:47 +00:00
|
|
|
src/http_template.h \
|
2024-09-22 06:44:04 +00:00
|
|
|
src/helpers.h \
|
2024-10-29 03:42:24 +00:00
|
|
|
src/html_cache.h \
|
|
|
|
src/static.h
|
2024-09-01 03:36:04 +00:00
|
|
|
|
2024-08-29 05:19:46 +00:00
|
|
|
SOURCES = \
|
2024-08-29 06:38:44 +00:00
|
|
|
src/main.c \
|
|
|
|
src/arg_parse.c \
|
|
|
|
src/big_endian.c \
|
|
|
|
src/tcp_socket.c \
|
|
|
|
src/signal_handling.c \
|
2024-08-30 02:58:11 +00:00
|
|
|
src/globals.c \
|
2024-08-30 05:08:31 +00:00
|
|
|
src/http.c \
|
2024-08-31 07:48:24 +00:00
|
|
|
src/config.c \
|
2024-09-03 07:20:18 +00:00
|
|
|
src/http_template.c \
|
2024-09-09 03:39:47 +00:00
|
|
|
src/helpers.c \
|
2024-09-22 06:44:04 +00:00
|
|
|
src/html_cache.c \
|
2024-10-29 03:42:24 +00:00
|
|
|
src/static.c \
|
2024-08-30 05:08:31 +00:00
|
|
|
third_party/SimpleArchiver/src/helpers.c \
|
2024-08-30 02:58:11 +00:00
|
|
|
third_party/SimpleArchiver/src/data_structures/linked_list.c \
|
|
|
|
third_party/SimpleArchiver/src/data_structures/hash_map.c \
|
|
|
|
third_party/SimpleArchiver/src/data_structures/priority_heap.c \
|
|
|
|
third_party/SimpleArchiver/src/algorithms/linear_congruential_gen.c
|
2024-08-29 06:38:44 +00:00
|
|
|
|
2024-08-29 05:19:46 +00:00
|
|
|
OBJECT_DIR = objs
|
|
|
|
OBJECTS = $(addprefix ${OBJECT_DIR}/,$(patsubst %.c,%.c.o,${SOURCES}))
|
|
|
|
|
2024-08-30 09:11:03 +00:00
|
|
|
all: c_simple_http unit_test
|
2024-08-29 05:19:46 +00:00
|
|
|
|
|
|
|
c_simple_http: ${OBJECTS}
|
2024-09-05 07:25:49 +00:00
|
|
|
${CC} -o c_simple_http ${CFLAGS} $^
|
2024-08-29 05:19:46 +00:00
|
|
|
|
2024-08-30 09:11:03 +00:00
|
|
|
unit_test: $(filter-out ${OBJECT_DIR}/src/main.c.o,${OBJECTS}) ${OBJECT_DIR}/src/test.c.o
|
2024-09-05 07:25:49 +00:00
|
|
|
${CC} -o unit_test ${CFLAGS} $^
|
2024-08-30 09:11:03 +00:00
|
|
|
|
2024-08-29 05:19:46 +00:00
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f c_simple_http
|
2024-08-30 09:11:03 +00:00
|
|
|
rm -f unit_test
|
2024-08-29 05:19:46 +00:00
|
|
|
rm -rf ${OBJECT_DIR}
|
|
|
|
|
2024-09-01 03:36:04 +00:00
|
|
|
${OBJECT_DIR}/%.c.o: %.c ${HEADERS}
|
2024-08-29 05:19:46 +00:00
|
|
|
@mkdir -p $(dir $@)
|
2024-09-05 07:25:49 +00:00
|
|
|
${CC} -o $@ -c ${CFLAGS} $<
|