parent
59e2223ef7
commit
c9b6fd5491
@ -1,14 +1,173 @@ |
||||
.PHONY: all clean espfsbuilder demo lib |
||||
.PHONY: clean all lib demo fstool |
||||
|
||||
all: demo espfsbuilder |
||||
# -*- Settings -*-
|
||||
|
||||
clean: |
||||
make -C ./spritehttpd clean
|
||||
make -C ./demo clean
|
||||
make -C ./espfsbuilder clean
|
||||
DEBUG = 1
|
||||
PLATFORM ?= POSIX # POSIX or ARM
|
||||
|
||||
|
||||
# -*- Target names -*-
|
||||
|
||||
LIB_TARGET = ./libspritehttpd.a
|
||||
DEMO_TARGET = ./spritehttpd-demo
|
||||
FSTOOL_TARGET = ./espfstool # Note: keep ./ here so it can be called when building demo
|
||||
|
||||
# Handy targets
|
||||
all: demo lib fstool |
||||
demo: $(DEMO_TARGET) |
||||
lib: $(LIB_TARGET) |
||||
fstool: $(FSTOOL_TARGET) |
||||
|
||||
# -*- Tools -*-
|
||||
|
||||
# hex dump tool
|
||||
XXD ?= xxd
|
||||
|
||||
HOST_CC = gcc
|
||||
|
||||
ifeq ($(PLATFORM),ARM) |
||||
CC = arm-none-eabi-gcc
|
||||
AR = arm-none-eabi-ar
|
||||
else |
||||
# Probably posix
|
||||
CC = gcc
|
||||
AR = ar
|
||||
endif |
||||
|
||||
|
||||
# -*- CFLAGS -*-
|
||||
|
||||
# Common variables
|
||||
GIT_HASH = $(shell git rev-parse --short HEAD)
|
||||
|
||||
# These flags are used by all targets
|
||||
COMMON_CFLAGS = -Wall -Wextra -Werror \
|
||||
-Wshadow -Wfloat-equal -Wundef -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wwrite-strings -Wunreachable-code -Wconversion -Winit-self \
|
||||
-std=gnu99 -DGIT_HASH='"$(GIT_HASH)"' -ffunction-sections -fdata-sections
|
||||
# The final binary linker should use -Wl,--gc-sections to take advantage of -ffunction-sections and -fdata-sections
|
||||
|
||||
LIB_CFLAGS = $(COMMON_CFLAGS) -c -fPIC
|
||||
FSTOOL_CFLAGS = $(COMMON_CFLAGS) -DZLIB_CONST -lz
|
||||
DEMO_CFLAGS = $(COMMON_CFLAGS)
|
||||
|
||||
ifeq ($(DEBUG), 1) |
||||
COMMON_CFLAGS += -DDEBUG -Og -ggdb
|
||||
else |
||||
FSTOOL_CFLAGS += -O2
|
||||
DEMO_CFLAGS += -O2
|
||||
LIB_CFLAGS += -DNDEBUG -Os
|
||||
endif |
||||
|
||||
|
||||
# -*- Library -*-
|
||||
|
||||
LIB_DIR = spritehttpd
|
||||
|
||||
LIB_SOURCES = \
|
||||
lib/espfs/espfs.c \
|
||||
lib/heatshrink/heatshrink_decoder.c \
|
||||
src/utils/base64.c \
|
||||
src/utils/sha1.c \
|
||||
src/httpd.c \
|
||||
src/httpd-auth.c \
|
||||
src/httpd-utils.c \
|
||||
src/httpd-loop.c \
|
||||
src/cgi-espfs.c \
|
||||
src/cgi-redirects.c \
|
||||
src/cgi-websocket.c
|
||||
|
||||
LIB_INCLUDE_DIRS = \
|
||||
src \
|
||||
include \
|
||||
lib/heatshrink \
|
||||
lib/espfs
|
||||
|
||||
ifeq ($(PLATFORM),ARM) |
||||
LIB_SOURCES += src/port/httpd-freertos.c
|
||||
else |
||||
LIB_SOURCES += src/port/httpd-posix.c
|
||||
endif |
||||
|
||||
espfsbuilder: |
||||
make -C ./espfsbuilder
|
||||
LIB_SOURCES := $(addprefix $(LIB_DIR)/, $(LIB_SOURCES))
|
||||
LIB_OBJS = $(LIB_SOURCES:.c=.o)
|
||||
LIB_CFLAGS += $(addprefix -I$(LIB_DIR)/, $(LIB_INCLUDE_DIRS))
|
||||
|
||||
demo: |
||||
make -C ./demo
|
||||
# This is only used for the library files. TODO restrict it somehow
|
||||
%.o: %.c |
||||
$(CC) $(LIB_CFLAGS) -o $@ $<
|
||||
|
||||
$(LIB_TARGET): $(LIB_OBJS) |
||||
$(AR) rcs $@ $^
|
||||
|
||||
# -*- Demo -*-
|
||||
|
||||
DEMO_DIR = demo
|
||||
|
||||
# these won't have dir prefix added - they can refer to other dirs
|
||||
DEMO_SOURCES = \
|
||||
$(DEMO_DIR)/server_demo.c \
|
||||
$(DEMO_DIR)/staticfiles.embed.c
|
||||
|
||||
DEMO_INCLUDE_DIRS = \
|
||||
$(DEMO_DIR) \
|
||||
$(LIB_DIR)/include
|
||||
|
||||
DEMO_STATIC_FILES = \
|
||||
index.html \
|
||||
kocour.jpg \
|
||||
template.tpl.txt
|
||||
|
||||
DEMO_OBJS = $(DEMO_SOURCES:.c=.o)
|
||||
DEMO_STATIC_FILES := $(addprefix $(DEMO_DIR)/staticfiles/, $(DEMO_STATIC_FILES))
|
||||
DEMO_CFLAGS += $(addprefix -I, $(DEMO_INCLUDE_DIRS))
|
||||
|
||||
demo/staticfiles.bin: $(FSTOOL_TARGET) $(DEMO_STATIC_FILES) |
||||
# Create the FS image
|
||||
$(FSTOOL_TARGET) -c1 -g jpg --strip-path demo/staticfiles -o $@ $(DEMO_STATIC_FILES)
|
||||
# Show content of the image
|
||||
$(FSTOOL_TARGET) -p $@
|
||||
|
||||
demo/staticfiles.embed.c: demo/staticfiles.bin |
||||
# Dump the FS image to a C file
|
||||
$(XXD) -i -n espfs_image $< $@
|
||||
|
||||
$(DEMO_TARGET): $(DEMO_SOURCES) $(LIB_TARGET) |
||||
$(CC) $(DEMO_CFLAGS) $(DEMO_SOURCES) \
|
||||
-o $@ \
|
||||
-lspritehttpd -L.
|
||||
|
||||
|
||||
# FS builder
|
||||
|
||||
FSTOOL_DIR = fstool
|
||||
|
||||
FSTOOL_SOURCES = \
|
||||
$(FSTOOL_DIR)/main.c \
|
||||
$(FSTOOL_DIR)/parsing.c \
|
||||
$(LIB_DIR)/lib/heatshrink/heatshrink_encoder.c \
|
||||
$(LIB_DIR)/lib/heatshrink/heatshrink_decoder.c \
|
||||
$(LIB_DIR)/lib/espfs/espfs.c
|
||||
|
||||
FSTOOL_INCLUDE_DIRS = \
|
||||
$(FSTOOL_DIR) \
|
||||
$(LIB_DIR)/lib/heatshrink/ \
|
||||
$(LIB_DIR)/lib/espfs/
|
||||
|
||||
FSTOOL_CFLAGS += $(addprefix -I, $(FSTOOL_INCLUDE_DIRS))
|
||||
|
||||
$(FSTOOL_TARGET): $(FSTOOL_SOURCES) |
||||
$(HOST_CC) $(FSTOOL_CFLAGS) $^ -o $@
|
||||
|
||||
|
||||
# -*- Clean -*-
|
||||
|
||||
clean: |
||||
rm -f $(FSTOOL_TARGET) $(DEMO_TARGET) $(LIB_TARGET)
|
||||
find . -type f \( \
|
||||
-name '*.o' \
|
||||
-o -name '*.embed.c' \
|
||||
-o -name '*.d' \
|
||||
-o -name '*.a' \
|
||||
-o -name '*.elf' \
|
||||
-o -name '*.bin' \
|
||||
\) -delete
|
||||
|
@ -1,7 +0,0 @@ |
||||
demo |
||||
*.o |
||||
.idea/ |
||||
*.bin |
||||
*.a |
||||
staticfiles-embed.c |
||||
staticfiles.bin |
@ -1,36 +0,0 @@ |
||||
DEMO_SOURCES = server_demo.c staticfiles-embed.c
|
||||
|
||||
FSBUILDER = ../espfsbuilder/mkespfsimage
|
||||
|
||||
LIBFILE = ../spritehttpd/libspritehttpd.a
|
||||
|
||||
STATIC_FILES = \
|
||||
staticfiles/index.html \
|
||||
staticfiles/kocour.jpg \
|
||||
staticfiles/template.tpl.txt
|
||||
|
||||
all: demo |
||||
|
||||
$(FSBUILDER): |
||||
make -C ../espfsbuilder
|
||||
|
||||
staticfiles.bin: $(FSBUILDER) ${STATIC_FILES} |
||||
$(FSBUILDER) -c1 -g jpg --strip-path staticfiles -o $@ ${STATIC_FILES}
|
||||
$(FSBUILDER) -p $@
|
||||
|
||||
staticfiles-embed.c: staticfiles.bin |
||||
xxd -i -n espfs_image $< $@
|
||||
|
||||
clean: |
||||
rm -f demo staticfiles.bin staticfiles-embed.c
|
||||
make -C ../spritehttpd clean
|
||||
|
||||
$(LIBFILE): |
||||
make -C ../spritehttpd PLATFORM=posix CFLAGS="-Og -g"
|
||||
|
||||
demo: ${DEMO_SOURCES} $(LIBFILE) |
||||
cc -Og -g -Wall ${DEMO_SOURCES} \
|
||||
-o $@ \
|
||||
-I../spritehttpd/include \
|
||||
-lspritehttpd \
|
||||
-L../spritehttpd/
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +0,0 @@ |
||||
mkespfsimage |
||||
*.o |
||||
.idea/ |
||||
*.bin |
@ -1,20 +0,0 @@ |
||||
TARGET=mkespfsimage
|
||||
|
||||
SOURCES = main.c parsing.c \
|
||||
../spritehttpd/lib/heatshrink/heatshrink_encoder.c \
|
||||
../spritehttpd/lib/heatshrink/heatshrink_decoder.c \
|
||||
../spritehttpd/lib/espfs/espfs.c
|
||||
|
||||
CFLAGS = -I. \
|
||||
-I../spritehttpd/lib/heatshrink/ \
|
||||
-I../spritehttpd/lib/espfs/ \
|
||||
-DZLIB_CONST
|
||||
|
||||
all: $(TARGET) |
||||
|
||||
$(TARGET): ${SOURCES} |
||||
#cc -O3 -lz $^ -o $@ ${CFLAGS}
|
||||
cc -Og -g -Wall -Wextra -lz $^ -o $@ ${CFLAGS}
|
||||
|
||||
clean: |
||||
rm $(TARGET)
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@ -1,5 +0,0 @@ |
||||
mkespfsimage |
||||
*.o |
||||
.idea/ |
||||
*.bin |
||||
*.a |
@ -1,49 +0,0 @@ |
||||
# If building for posix:
|
||||
ifeq ($(PLATFORM),arm-freertos) |
||||
CC ?= arm-none-eabi-gcc
|
||||
AR ?= arm-none-eabi-ar
|
||||
PORT_SOURCES = src/port/httpd-freertos.c
|
||||
else |
||||
# Probably posix
|
||||
CC ?= cc
|
||||
AR ?= ar
|
||||
PORT_SOURCES = src/port/httpd-posix.c
|
||||
endif |
||||
|
||||
# additional C flags can be specified via the CFLAGS variable
|
||||
|
||||
|
||||
LIB_FILE = libspritehttpd.a
|
||||
|
||||
LIB_SOURCES = ${PORT_SOURCES} \
|
||||
lib/espfs/espfs.c \
|
||||
lib/heatshrink/heatshrink_decoder.c \
|
||||
src/utils/base64.c \
|
||||
src/utils/sha1.c \
|
||||
src/httpd.c \
|
||||
src/httpd-auth.c \
|
||||
src/httpd-utils.c \
|
||||
src/httpd-loop.c \
|
||||
src/cgi-espfs.c \
|
||||
src/cgi-redirects.c \
|
||||
src/cgi-websocket.c
|
||||
|
||||
LIB_OBJS = $(LIB_SOURCES:.c=.o)
|
||||
|
||||
LIB_INCLUDES = -Iinclude -Ilib/heatshrink -Ilib/espfs
|
||||
|
||||
LIB_CFLAGS = -fPIC -Wall -Wextra -c -Os -ggdb -std=gnu99 -DGIT_HASH='"$(shell git rev-parse --short HEAD)"'
|
||||
|
||||
all: $(LIB_FILE) |
||||
|
||||
%.o: %.c |
||||
$(CC) -c $(LIB_INCLUDES) $(CFLAGS) $(LIB_CFLAGS) -o $@ $<
|
||||
|
||||
$(LIB_FILE): $(LIB_OBJS) |
||||
$(AR) rcs $@ $^
|
||||
|
||||
clean: |
||||
find . -type f -name '*.o' -delete
|
||||
find . -type f -name '*.d' -delete
|
||||
find . -type f -name '*.a' -delete
|
||||
find . -type f -name '*.elf' -delete
|
Loading…
Reference in new issue