diff --git a/examples/captive-dns-server/Makefile b/examples/captive-dns-server/Makefile index 2be9594e..68fd0420 100644 --- a/examples/captive-dns-server/Makefile +++ b/examples/captive-dns-server/Makefile @@ -1,26 +1,28 @@ -SOURCES = mongoose.c main.c -CFLAGS = -W -Wall -Wextra -g +SOURCES = main.c mongoose.c # Source code files +CFLAGS = -W -Wall -Wextra -g -I. # Build options # Mongoose build options. See https://mongoose.ws/documentation/#build-options -CFLAGS += -DMG_IO_SIZE=8192 -DMG_ENABLE_LINES +CFLAGS_MONGOOSE += -DMG_IO_SIZE=8192 -DMG_ENABLE_LINES ifeq ($(OS),Windows_NT) - # Windows settings. Assume MinGW compiler + # Windows settings. Assume MinGW compiler. To use VC: make CC=cl CFLAGS=/MD OUT=/Feprog.exe PROG ?= example.exe # Use .exe suffix for the binary CC = gcc # Use MinGW gcc compiler CFLAGS += -lws2_32 # Link against Winsock library DELETE = cmd /C del /Q /F /S # Command prompt command to delete files + OUT ?= -o $(PROG) # Build output else # Mac, Linux PROG ?= example DELETE = rm -rf + OUT ?= -o $(PROG) endif all: $(PROG) $(RUN) ./$(PROG) $(ARGS) $(PROG): $(SOURCES) - $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_EXTRA) -o $@ + $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT) clean: - $(DELETE) $(PROG) *.dSYM pack tmp + $(DELETE) $(PROG) *.o *.obj *.exe *.dSYM diff --git a/examples/device-dashboard/Makefile b/examples/device-dashboard/Makefile index 2cc444cc..d59281d3 100644 --- a/examples/device-dashboard/Makefile +++ b/examples/device-dashboard/Makefile @@ -1,19 +1,21 @@ -SOURCES = ../../mongoose.c main.c net.c packed_fs.c -CFLAGS = -W -Wall -Wextra -g +SOURCES = mongoose.c main.c net.c packed_fs.c # Source code files +CFLAGS = -W -Wall -Wextra -g -I. # Build options # Mongoose build options. See https://mongoose.ws/documentation/#build-options -CFLAGS += -I ../.. -DMG_ENABLE_PACKED_FS=1 +CFLAGS_MONGOOSE += -DMG_ENABLE_PACKED_FS=1 ifeq ($(OS),Windows_NT) - # Windows settings. Assume MinGW compiler + # Windows settings. Assume MinGW compiler. To use VC: make CC=cl CFLAGS=/MD OUT=/Feprog.exe PROG ?= example.exe # Use .exe suffix for the binary CC = gcc # Use MinGW gcc compiler CFLAGS += -lws2_32 # Link against Winsock library DELETE = cmd /C del /Q /F /S # Command prompt command to delete files + OUT ?= -o $(PROG) # Build output else # Mac, Linux PROG ?= example DELETE = rm -rf + OUT ?= -o $(PROG) endif all: $(PROG) @@ -27,7 +29,7 @@ packed_fs.c: $(shell find web_root -type f) Makefile cd tmp && ../pack `find web_root -type f` > ../$@ $(PROG): $(SOURCES) - $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_EXTRA) -o $@ + $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT) clean: - $(DELETE) $(PROG) *.dSYM pack tmp + $(DELETE) $(PROG) *.o *.obj *.exe *.dSYM pack tmp diff --git a/examples/device-dashboard/mongoose.c b/examples/device-dashboard/mongoose.c new file mode 120000 index 00000000..8ef6e62d --- /dev/null +++ b/examples/device-dashboard/mongoose.c @@ -0,0 +1 @@ +../../mongoose.c \ No newline at end of file diff --git a/examples/device-dashboard/mongoose.h b/examples/device-dashboard/mongoose.h new file mode 120000 index 00000000..488ef358 --- /dev/null +++ b/examples/device-dashboard/mongoose.h @@ -0,0 +1 @@ +../../mongoose.h \ No newline at end of file diff --git a/examples/embedded-filesystem/Makefile b/examples/embedded-filesystem/Makefile index 950b815a..9f42f0c6 100644 --- a/examples/embedded-filesystem/Makefile +++ b/examples/embedded-filesystem/Makefile @@ -1,38 +1,39 @@ -PROG ?= example -SOURCES ?= ../../mongoose.c main.c packed_fs.c -CFLAGS ?= -I../.. -DMG_ENABLE_PACKED_FS=1 -DMG_ENABLE_LINES=1 $(EXTRA) +SOURCES = mongoose.c main.c packed_fs.c # Source code files +CFLAGS = -W -Wall -Wextra -g -I. # Build options + +# Mongoose build options. See https://mongoose.ws/documentation/#build-options +CFLAGS_MONGOOSE += -DMG_ENABLE_PACKED_FS=1 + FILES_TO_EMBED ?= $(wildcard web_root/*) -ROOT ?= $(realpath $(CURDIR)/../../..) -DOCKER ?= docker run --rm -e Tmp=. -e WINEDEBUG=-all -v $(ROOT):$(ROOT) -w $(CURDIR) -VC98 ?= $(DOCKER) mdashnet/vc98 wine -MINGW ?= $(DOCKER) mdashnet/mingw + +ifeq ($(OS),Windows_NT) + # Windows settings. Assume MinGW compiler. To use VC: make CC=cl CFLAGS=/MD OUT=/Feprog.exe + PROG ?= example.exe # Use .exe suffix for the binary + CC = gcc # Use MinGW gcc compiler + CFLAGS += -lws2_32 # Link against Winsock library + DELETE = cmd /C del /Q /F /S # Command prompt command to delete files + OUT ?= -o $(PROG) # Build output +else + # Mac, Linux + PROG ?= example + DELETE = rm -rf + OUT ?= -o $(PROG) +endif all: $(PROG) - $(RUN) ./$(PROG) + $(RUN) ./$(PROG) $(ARGS) $(PROG): $(SOURCES) $(FILES_TO_EMBED) $(CC) ../../test/pack.c -o pack ./pack $(FILES_TO_EMBED) > packed_fs.c - $(CC) -W -Wall -Wextra -O0 -g3 $(CFLAGS) -o $(PROG) $(SOURCES) - - -mingw: $(SOURCES) $(FILES_TO_EMBED) - $(MINGW) i686-w64-mingw32-gcc $(CFLAGS) ../../test/pack.c -o pack.exe - $(MINGW) wine cmd /c 'pack.exe $(FILES_TO_EMBED) > packed_fs.c' - $(MINGW) i686-w64-mingw32-gcc $(CFLAGS) $(SOURCES) -lws2_32 -o $(PROG).exe - $(MINGW) wine $(PROG).exe - -vc98: $(SOURCES) $(FILES_TO_EMBED) - $(VC98) cl.exe /nologo $(CFLAGS) ../../test/pack.c /Fepack.exe - $(VC98) cmd /c 'pack.exe $(FILES_TO_EMBED) > packed_fs.c' - $(VC98) cl.exe /nologo /O2 $(CFLAGS) $(SOURCES) /Fe$(PROG).exe - $(VC98) $(PROG).exe + $(CC) $(SOURCES) $(CFLAGS) $(CFLAGS_MONGOOSE) $(CFLAGS_EXTRA) $(OUT) clean: - rm -rf $(PROG) *.o *.dSYM *.gcov *.gcno *.gcda *.obj *.exe *.ilk *.pdb log.txt pack + $(DELETE) $(PROG) *.dSYM pack .PHONY: compress expand gzipped plain all +# See tutorial gzipped: compress $(MAKE) all diff --git a/examples/embedded-filesystem/README.md b/examples/embedded-filesystem/README.md new file mode 100644 index 00000000..c5425b24 --- /dev/null +++ b/examples/embedded-filesystem/README.md @@ -0,0 +1 @@ +See detailed tutorial at https://mongoose.ws/tutorials/embedded-filesystem/ diff --git a/examples/embedded-filesystem/mongoose.c b/examples/embedded-filesystem/mongoose.c new file mode 120000 index 00000000..8ef6e62d --- /dev/null +++ b/examples/embedded-filesystem/mongoose.c @@ -0,0 +1 @@ +../../mongoose.c \ No newline at end of file diff --git a/examples/embedded-filesystem/mongoose.h b/examples/embedded-filesystem/mongoose.h new file mode 120000 index 00000000..488ef358 --- /dev/null +++ b/examples/embedded-filesystem/mongoose.h @@ -0,0 +1 @@ +../../mongoose.h \ No newline at end of file