standardize

This commit is contained in:
Sergio R. Caprile 2023-02-15 18:04:48 -03:00
parent 9ec064f9d9
commit 824763aae9
6 changed files with 43 additions and 35 deletions

View File

@ -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

View File

@ -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 += -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

View File

@ -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

View File

@ -0,0 +1 @@
See detailed tutorial at https://mongoose.ws/tutorials/embedded-filesystem/

View File

@ -0,0 +1 @@
../../mongoose.c

View File

@ -0,0 +1 @@
../../mongoose.h