1
1
PROG ?= example # Program we are building
2
+ PACK ?= ./pack # Packing executable
2
3
DELETE = rm -rf # Command to remove files
3
4
OUT ?= -o $(PROG ) # Compiler argument for output file
4
5
SOURCES = main.c mongoose.c net.c packed_fs.c # Source code files
@@ -7,8 +8,11 @@ CFLAGS = -W -Wall -Wextra -g -I. # Build options
7
8
# Mongoose build options. See https://mongoose.ws/documentation/#build-options
8
9
CFLAGS_MONGOOSE += -DMG_ENABLE_PACKED_FS=1
9
10
11
+ FILES_TO_EMBED ?= $(wildcard web_root/* )
12
+
10
13
ifeq ($(OS ) ,Windows_NT) # Windows settings. Assume MinGW compiler. To use VC : make CC=cl CFLAGS=/MD OUT=/Feprog.exe
11
14
PROG ?= example.exe # Use .exe suffix for the binary
15
+ PACK = pack.exe # Packing executable
12
16
CC = gcc # Use MinGW gcc compiler
13
17
CFLAGS += -lws2_32 # Link against Winsock library
14
18
DELETE = cmd /C del /Q /F /S # Command prompt command to delete files
@@ -19,12 +23,14 @@ endif
19
23
all : $(PROG ) # Default target. Build and run program
20
24
$(RUN ) ./$(PROG ) $(ARGS )
21
25
22
- ifneq ($(OS ) ,Windows_NT)
23
26
# Before embedding files, gzip them to save space
24
- packed_fs.c : $(shell find web_root -type f) Makefile
27
+ packed_fs.c : $(FILES_TO_EMBED ) Makefile
28
+ $(CC ) ../../test/pack.c -o $(PACK )
29
+ ifeq ($(OS ) ,Windows_NT)
30
+ $(PACK) $(FILES_TO_EMBED) > $@
31
+ else
25
32
rm -rf tmp/web_root && mkdir tmp && cp -r web_root tmp/
26
33
find tmp -type f | xargs -n1 gzip
27
- $(CC ) ../../test/pack.c -o pack
28
34
cd tmp && ../pack `find web_root -type f` > ../$@
29
35
endif
30
36
0 commit comments