Use GNUmakefile and Makefile to simplify MSVC compilation

This commit is contained in:
Turiiya 2023-10-10 01:55:03 +02:00
parent 5e7c407bc0
commit 5518a3e044
30 changed files with 1485 additions and 1485 deletions

View File

@ -4,5 +4,5 @@ end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{c,cpp,h,hpp,Makefile,js,ts,css,html}]
[*.{c,cpp,h,hpp,Makefile,GNUmakefile,js,ts,css,html}]
indent_style = tab

146
GNUmakefile Normal file
View File

@ -0,0 +1,146 @@
# WebUI Library
# == 1. VARIABLES =============================================================
MAKEFILE_DIR := $(shell git rev-parse --show-toplevel)
BUILD_DIR := $(MAKEFILE_DIR)/dist
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Allow to add arch-target for macOS CI cross compilation
ARCH_TARGET ?=
# BUILD FLAGS
CIVETWEB_BUILD_FLAGS := -o civetweb.o -I"$(MAKEFILE_DIR)/include/" -c "$(MAKEFILE_DIR)/src/civetweb/civetweb.c"
CIVETWEB_DEFINE_FLAGS = -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
WEBUI_BUILD_FLAGS := -o webui.o -I"$(MAKEFILE_DIR)/include/" -c "$(MAKEFILE_DIR)/src/webui.c"
# OUTPUT FILES
# The static output is the same for all platforms
# The dynamic output is platform dependent
LIB_STATIC_OUT := libwebui-2-static.a
# Platform defaults and dynamic library outputs
ifeq ($(OS),Windows_NT)
# Windows
SHELL := CMD
PLATFORM := windows
LIB_DYN_OUT := webui-2.dll
LWS2_OPT := -lws2_32
CIVETWEB_DEFINE_FLAGS += -DMUST_IMPLEMENT_CLOCK_GETTIME
else ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
LIB_DYN_OUT := webui-2.dylib
else
# Linux
PLATFORM := linux
LIB_DYN_OUT := webui-2.so
ifneq ($(filter $(CC),gcc clang aarch64-linux-gnu-gcc arm-linux-gnueabihf-gcc),$(CC))
$(error Invalid compiler specified: `$(CC)`)
else ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
# macOS can set `ARCH_TARGET=arm64` - intented for CI cross-compilation.
ifneq ($(ARCH_TARGET),)
ifneq ($(PLATFORM),macos)
$(error ARCH_TARGET is only available on macOS)
else ifeq ($(ARCH_TARGET),arm64)
TARGET := -target arm64-apple-darwin
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: --debug
release: --release
clean: --clean-$(PLATFORM)
# == 2.1 INTERNAL TARGETS =====================================================
--debug:
# Create build directory
ifeq ($(PLATFORM),windows)
@mkdir "$(BUILD_DIR)/debug" >nul 2>&1 ||:
else
@mkdir -p "$(BUILD_DIR)/debug"
endif
# Static with Debug info
@cd "$(BUILD_DIR)/debug" \
&& echo "Build WebUI library ($(CC) $(TARGET)debug static)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -g \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) -g -DWEBUI_LOG \
&& $(LLVM_OPT)ar rc $(LIB_STATIC_OUT) webui.o civetweb.o \
&& $(LLVM_OPT)ranlib $(LIB_STATIC_OUT)
# Dynamic with Debug info
@cd "$(BUILD_DIR)/debug" \
&& echo "Build WebUI library ($(CC) $(TARGET)debug dynamic)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -g -fPIC \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) -g -fPIC -DWEBUI_LOG \
&& $(CC) $(TARGET) -shared -o $(LIB_DYN_OUT) webui.o civetweb.o -g $(LWS2_OPT)
ifeq ($(PLATFORM),windows)
@cd "$(BUILD_DIR)/debug" && del *.o >nul 2>&1
else
@rm -f $(BUILD_DIR)/debug/*.o
endif
@echo "Done."
--release:
# Create build directory
ifeq ($(PLATFORM),windows)
@mkdir "$(BUILD_DIR)" >nul 2>&1 ||:
else
@mkdir -p "$(BUILD_DIR)"
endif
# Static Release
@cd "$(BUILD_DIR)" \
&& echo "Build WebUI library ($(CC) $(TARGET)release static)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -Os \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) -Os \
&& $(LLVM_OPT)ar rc $(LIB_STATIC_OUT) webui.o civetweb.o \
&& $(LLVM_OPT)ranlib $(LIB_STATIC_OUT)
# Dynamic Release
@cd "$(BUILD_DIR)" \
&& echo "Build WebUI library ($(CC) $(TARGET)release dynamic)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -Os -fPIC \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) -O3 -fPIC \
&& $(CC) $(TARGET) -shared -o $(LIB_DYN_OUT) webui.o civetweb.o $(LWS2_OPT)
# Clean
ifeq ($(PLATFORM),windows)
@strip --strip-unneeded $(BUILD_DIR)/$(LIB_DYN_OUT)
@cd "$(BUILD_DIR)" && del *.o >nul 2>&1
else
@rm -f $(BUILD_DIR)/*.o
endif
@echo "Done."
# PLATFROM CLEAN TARGETS
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
@- cd "$(BUILD_DIR)" \
&& rm -f *.o \
&& rm -f *.so \
&& rm -f *.dylib \
&& rm -f *.a
--clean-windows:
@- cd "$(BUILD_DIR)" \
&& del *.a >nul 2>&1 \
&& del *.o >nul 2>&1 \
&& del *.dll >nul 2>&1 \
&& del *.obj >nul 2>&1 \
&& del *.ilk >nul 2>&1 \
&& del *.pdb >nul 2>&1 \
&& del *.lib >nul 2>&1 \
&& del *.exp >nul 2>&1

187
Makefile
View File

@ -1,146 +1,73 @@
# WebUI Library
# Windows - Microsoft Visual C
# == 1. VARIABLES =============================================================
MAKEFILE_DIR := $(shell git rev-parse --show-toplevel)
BUILD_DIR := $(MAKEFILE_DIR)/dist
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Allow to add arch-target for macOS CI cross compilation
ARCH_TARGET ?=
# BUILD FLAGS
CIVETWEB_BUILD_FLAGS := -o civetweb.o -I"$(MAKEFILE_DIR)/include/" -c "$(MAKEFILE_DIR)/src/civetweb/civetweb.c"
# Build Flags
CIVETWEB_BUILD_FLAGS = /Fo"civetweb.obj" /c /EHsc "$(MAKEDIR)/src/civetweb/civetweb.c" /I"$(MAKEDIR)/src/civetweb/"
CIVETWEB_DEFINE_FLAGS = -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
WEBUI_BUILD_FLAGS := -o webui.o -I"$(MAKEFILE_DIR)/include/" -c "$(MAKEFILE_DIR)/src/webui.c"
WEBUI_BUILD_FLAGS = /Fo"webui.obj" /c /EHsc "$(MAKEDIR)/src/webui.c" /I"$(MAKEDIR)/include"
# OUTPUT FILES
# The static output is the same for all platforms
# The dynamic output is platform dependent
LIB_STATIC_OUT := libwebui-2-static.a
# Platform defaults and dynamic library outputs
ifeq ($(OS),Windows_NT)
# Windows
SHELL := CMD
PLATFORM := windows
LIB_DYN_OUT := webui-2.dll
LWS2_OPT := -lws2_32
CIVETWEB_DEFINE_FLAGS += -DMUST_IMPLEMENT_CLOCK_GETTIME
else ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
LIB_DYN_OUT := webui-2.dylib
else
# Linux
PLATFORM := linux
LIB_DYN_OUT := webui-2.so
ifneq ($(filter $(CC),gcc clang aarch64-linux-gnu-gcc arm-linux-gnueabihf-gcc),$(CC))
$(error Invalid compiler specified: `$(CC)`)
else ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
# macOS can set `ARCH_TARGET=arm64` - intented for CI cross-compilation.
ifneq ($(ARCH_TARGET),)
ifneq ($(PLATFORM),macos)
$(error ARCH_TARGET is only available on macOS)
else ifeq ($(ARCH_TARGET),arm64)
TARGET := -target arm64-apple-darwin
endif
endif
# Output Commands
LIB_STATIC_OUT = /OUT:"webui-2-static.lib" "webui.obj" "civetweb.obj"
LIB_DYN_OUT = /DLL /OUT:"webui-2.dll" "webui.obj" "civetweb.obj" user32.lib Advapi32.lib
# == 2.TARGETS ================================================================
all: release
debug: --debug
release: --release
clean: --clean-$(PLATFORM)
# == 2.1 INTERNAL TARGETS =====================================================
--debug:
# Create build directory
ifeq ($(PLATFORM),windows)
@mkdir "$(BUILD_DIR)/debug" >nul 2>&1 ||:
else
@mkdir -p "$(BUILD_DIR)/debug"
endif
debug:
@- mkdir dist\debug >nul 2>&1
# Static with Debug info
@cd "$(BUILD_DIR)/debug" \
&& echo "Build WebUI library ($(CC) $(TARGET)debug static)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -g \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) -g -DWEBUI_LOG \
&& $(LLVM_OPT)ar rc $(LIB_STATIC_OUT) webui.o civetweb.o \
&& $(LLVM_OPT)ranlib $(LIB_STATIC_OUT)
@- cd $(MAKEDIR)/dist/debug
@echo Build WebUI Library (MSVC Debug Static)...
@cl /Zl /Zi $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl /Zl /Zi $(WEBUI_BUILD_FLAGS) /DWEBUI_LOG
@lib $(LIB_STATIC_OUT)
# Dynamic with Debug info
@cd "$(BUILD_DIR)/debug" \
&& echo "Build WebUI library ($(CC) $(TARGET)debug dynamic)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -g -fPIC \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) -g -fPIC -DWEBUI_LOG \
&& $(CC) $(TARGET) -shared -o $(LIB_DYN_OUT) webui.o civetweb.o -g $(LWS2_OPT)
ifeq ($(PLATFORM),windows)
@cd "$(BUILD_DIR)/debug" && del *.o >nul 2>&1
else
@rm -f $(BUILD_DIR)/debug/*.o
endif
@echo "Done."
--release:
# Create build directory
ifeq ($(PLATFORM),windows)
@mkdir "$(BUILD_DIR)" >nul 2>&1 ||:
else
@mkdir -p "$(BUILD_DIR)"
endif
# Static Release
@cd "$(BUILD_DIR)" \
&& echo "Build WebUI library ($(CC) $(TARGET)release static)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -Os \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) -Os \
&& $(LLVM_OPT)ar rc $(LIB_STATIC_OUT) webui.o civetweb.o \
&& $(LLVM_OPT)ranlib $(LIB_STATIC_OUT)
# Dynamic Release
@cd "$(BUILD_DIR)" \
&& echo "Build WebUI library ($(CC) $(TARGET)release dynamic)..." \
&& $(CC) $(TARGET) $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS) -Os -fPIC \
&& $(CC) $(TARGET) $(WEBUI_BUILD_FLAGS) -O3 -fPIC \
&& $(CC) $(TARGET) -shared -o $(LIB_DYN_OUT) webui.o civetweb.o $(LWS2_OPT)
@echo Build WebUI Library (MSVC Debug Dynamic)...
@cl /Zi $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl /Zi $(WEBUI_BUILD_FLAGS) /DWEBUI_LOG
@link $(LIB_DYN_OUT)
# Move into `debug/` dir
@- move webui-2-static.lib "debug\"
@- move webui-2.dll "debug\"
# Clean
ifeq ($(PLATFORM),windows)
@strip --strip-unneeded $(BUILD_DIR)/$(LIB_DYN_OUT)
@cd "$(BUILD_DIR)" && del *.o >nul 2>&1
else
@rm -f $(BUILD_DIR)/*.o
endif
@echo "Done."
@- del *.pdb >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.pdb >nul 2>&1
@- del *.exp >nul 2>&1
@echo Done.
# PLATFROM CLEAN TARGETS
release:
@- mkdir dist >nul 2>&1
@- cd $(MAKEDIR)/dist
# Static Release
@echo Build WebUI Library (MSVC Release Static)...
@cl /Zl $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl /Zl $(WEBUI_BUILD_FLAGS)
@lib $(LIB_STATIC_OUT)
# Dynamic Release
@echo Build WebUI Library (MSVC Release Dynamic)...
@cl $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl $(WEBUI_BUILD_FLAGS)
@link $(LIB_DYN_OUT)
# Clean
@- del *.pdb >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.pdb >nul 2>&1
@- del *.exp >nul 2>&1
@- echo Done.
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
@- cd "$(BUILD_DIR)" \
&& rm -f *.o \
&& rm -f *.so \
&& rm -f *.dylib \
&& rm -f *.a
--clean-windows:
@- cd "$(BUILD_DIR)" \
&& del *.a >nul 2>&1 \
&& del *.o >nul 2>&1 \
&& del *.dll >nul 2>&1 \
&& del *.obj >nul 2>&1 \
&& del *.ilk >nul 2>&1 \
&& del *.pdb >nul 2>&1 \
&& del *.lib >nul 2>&1 \
&& del *.exp >nul 2>&1
clean:
@- cd $(BUILD_DIR)
@- del *.pdb >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.pdb >nul 2>&1
@- del *.exp >nul 2>&1
@- del *.dll >nul 2>&1
@- del *.lib >nul 2>&1
@- echo Done.

View File

@ -1,73 +0,0 @@
# WebUI Library
# Windows - Microsoft Visual C
# == 1. VARIABLES =============================================================
# Build Flags
CIVETWEB_BUILD_FLAGS = /Fo"civetweb.obj" /c /EHsc "$(MAKEDIR)/src/civetweb/civetweb.c" /I"$(MAKEDIR)/src/civetweb/"
CIVETWEB_DEFINE_FLAGS = -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
WEBUI_BUILD_FLAGS = /Fo"webui.obj" /c /EHsc "$(MAKEDIR)/src/webui.c" /I"$(MAKEDIR)/include"
# Output Commands
LIB_STATIC_OUT = /OUT:"webui-2-static.lib" "webui.obj" "civetweb.obj"
LIB_DYN_OUT = /DLL /OUT:"webui-2.dll" "webui.obj" "civetweb.obj" user32.lib Advapi32.lib
# == 2.TARGETS ================================================================
all: release
debug:
@- mkdir dist\debug >nul 2>&1
# Static with Debug info
@- cd $(MAKEDIR)/dist/debug
@echo Build WebUI Library (MSVC Debug Static)...
@cl /Zl /Zi $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl /Zl /Zi $(WEBUI_BUILD_FLAGS) /DWEBUI_LOG
@lib $(LIB_STATIC_OUT)
# Dynamic with Debug info
@echo Build WebUI Library (MSVC Debug Dynamic)...
@cl /Zi $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl /Zi $(WEBUI_BUILD_FLAGS) /DWEBUI_LOG
@link $(LIB_DYN_OUT)
# Move into `debug/` dir
@- move webui-2-static.lib "debug\"
@- move webui-2.dll "debug\"
# Clean
@- del *.pdb >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.pdb >nul 2>&1
@- del *.exp >nul 2>&1
@echo Done.
release:
@- mkdir dist >nul 2>&1
@- cd $(MAKEDIR)/dist
# Static Release
@echo Build WebUI Library (MSVC Release Static)...
@cl /Zl $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl /Zl $(WEBUI_BUILD_FLAGS)
@lib $(LIB_STATIC_OUT)
# Dynamic Release
@echo Build WebUI Library (MSVC Release Dynamic)...
@cl $(CIVETWEB_BUILD_FLAGS) $(CIVETWEB_DEFINE_FLAGS)
@cl $(WEBUI_BUILD_FLAGS)
@link $(LIB_DYN_OUT)
# Clean
@- del *.pdb >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.pdb >nul 2>&1
@- del *.exp >nul 2>&1
@- echo Done.
clean:
@- cd $(BUILD_DIR)
@- del *.pdb >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.pdb >nul 2>&1
@- del *.exp >nul 2>&1
@- del *.dll >nul 2>&1
@- del *.lib >nul 2>&1
@- echo Done.

View File

@ -0,0 +1,120 @@
# WebUI C++ Example
# == 1. VARIABLES =============================================================
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
CXX = g++
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
CXX = clang
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CXX),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
# Static with Debug info
@echo "Build C99 Example ($(CXX) debug static)..."
@$(CXX) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
# Dynamic with Debug info
@echo "Build C99 Example ($(CXX) debug dynamic)..."
@$(CXX) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
# Static Release
@echo "Build C99 Example ($(CXX) release static)..."
@$(CXX) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
# Dynamic Release
@echo "Build C99 Example ($(CXX) release dynamic)..."
@$(CXX) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CXX),g++ clang),$(CXX))
$(error Invalid compiler specified: `$(CXX)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
- del *.exe >nul 2>&1

View File

@ -1,120 +1,55 @@
# WebUI C++ Example
# Windows - Microsoft Visual C++
# == 1. VARIABLES =============================================================
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
CXX = g++
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
CXX = clang
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CXX),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
# Build the WebUI library if running `nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
!ENDIF
# Static with Debug info
@echo "Build C99 Example ($(CXX) debug static)..."
@$(CXX) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@echo Build C++ Example (Debug Static)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo "Build C99 Example ($(CXX) debug dynamic)..."
@$(CXX) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@echo Build C++ Example (Debug Dynamic)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
!ENDIF
# Static Release
@echo "Build C99 Example ($(CXX) release static)..."
@$(CXX) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
@echo Build C++ Example (Release Static)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo "Build C99 Example ($(CXX) release dynamic)..."
@$(CXX) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
@echo Build C++ Example (Release Dynamic)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CXX),g++ clang),$(CXX))
$(error Invalid compiler specified: `$(CXX)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -1,55 +0,0 @@
# WebUI C++ Example
# Windows - Microsoft Visual C++
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
# Build the WebUI library if running `nmake -f Makefile.nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake debug
!ENDIF
# Static with Debug info
@echo Build C++ Example (Debug Static)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo Build C++ Example (Debug Dynamic)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake
!ENDIF
# Static Release
@echo Build C++ Example (Release Static)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo Build C++ Example (Release Dynamic)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -0,0 +1,120 @@
# WebUI C++ Example
# == 1. VARIABLES =============================================================
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
CXX = g++
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
CXX = clang
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CXX),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
# Static with Debug info
@echo "Build C99 Example ($(CXX) debug static)..."
@$(CXX) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
# Dynamic with Debug info
@echo "Build C99 Example ($(CXX) debug dynamic)..."
@$(CXX) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
# Static Release
@echo "Build C99 Example ($(CXX) release static)..."
@$(CXX) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
# Dynamic Release
@echo "Build C99 Example ($(CXX) release dynamic)..."
@$(CXX) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CXX),g++ clang),$(CXX))
$(error Invalid compiler specified: `$(CXX)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
- del *.exe >nul 2>&1

View File

@ -1,120 +1,55 @@
# WebUI C++ Example
# Windows - Microsoft Visual C++
# == 1. VARIABLES =============================================================
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
CXX = g++
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
CXX = clang
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CXX),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
# Build the WebUI library if running `nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
!ENDIF
# Static with Debug info
@echo "Build C99 Example ($(CXX) debug static)..."
@$(CXX) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@echo Build C++ Example (Debug Static)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo "Build C99 Example ($(CXX) debug dynamic)..."
@$(CXX) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@echo Build C++ Example (Debug Dynamic)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
!ENDIF
# Static Release
@echo "Build C99 Example ($(CXX) release static)..."
@$(CXX) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
@echo Build C++ Example (Release Static)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo "Build C99 Example ($(CXX) release dynamic)..."
@$(CXX) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
@echo Build C++ Example (Release Dynamic)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CXX),g++ clang),$(CXX))
$(error Invalid compiler specified: `$(CXX)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -1,55 +0,0 @@
# WebUI C++ Example
# Windows - Microsoft Visual C++
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
# Build the WebUI library if running `nmake -f Makefile.nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake debug
!ENDIF
# Static with Debug info
@echo Build C++ Example (Debug Static)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo Build C++ Example (Debug Dynamic)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake
!ENDIF
# Static Release
@echo Build C++ Example (Release Static)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo Build C++ Example (Release Dynamic)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -0,0 +1,120 @@
# WebUI C++ Example
# == 1. VARIABLES =============================================================
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
CXX = g++
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
CXX = clang
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CXX),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
# Static with Debug info
@echo "Build C99 Example ($(CXX) debug static)..."
@$(CXX) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
# Dynamic with Debug info
@echo "Build C99 Example ($(CXX) debug dynamic)..."
@$(CXX) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
# Static Release
@echo "Build C99 Example ($(CXX) release static)..."
@$(CXX) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
# Dynamic Release
@echo "Build C99 Example ($(CXX) release dynamic)..."
@$(CXX) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CXX),g++ clang),$(CXX))
$(error Invalid compiler specified: `$(CXX)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
- del *.exe >nul 2>&1

View File

@ -1,120 +1,55 @@
# WebUI C++ Example
# Windows - Microsoft Visual C++
# == 1. VARIABLES =============================================================
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
CXX = g++
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
CXX = clang
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CXX),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
# Build the WebUI library if running `nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
!ENDIF
# Static with Debug info
@echo "Build C99 Example ($(CXX) debug static)..."
@$(CXX) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@echo Build C++ Example (Debug Static)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo "Build C99 Example ($(CXX) debug dynamic)..."
@$(CXX) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@echo Build C++ Example (Debug Dynamic)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
!ENDIF
# Static Release
@echo "Build C99 Example ($(CXX) release static)..."
@$(CXX) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
@echo Build C++ Example (Release Static)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo "Build C99 Example ($(CXX) release dynamic)..."
@$(CXX) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
@echo Build C++ Example (Release Dynamic)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CXX),g++ clang),$(CXX))
$(error Invalid compiler specified: `$(CXX)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -1,55 +0,0 @@
# WebUI C++ Example
# Windows - Microsoft Visual C++
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
# Build the WebUI library if running `nmake -f Makefile.nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake debug
!ENDIF
# Static with Debug info
@echo Build C++ Example (Debug Static)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo Build C++ Example (Debug Dynamic)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake
!ENDIF
# Static Release
@echo Build C++ Example (Release Static)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo Build C++ Example (Release Dynamic)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -0,0 +1,120 @@
# WebUI C++ Example
# == 1. VARIABLES =============================================================
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
CXX = g++
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
CXX = clang
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CXX),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
# Static with Debug info
@echo "Build C99 Example ($(CXX) debug static)..."
@$(CXX) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
# Dynamic with Debug info
@echo "Build C99 Example ($(CXX) debug dynamic)..."
@$(CXX) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
# Static Release
@echo "Build C99 Example ($(CXX) release static)..."
@$(CXX) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
# Dynamic Release
@echo "Build C99 Example ($(CXX) release dynamic)..."
@$(CXX) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CXX),g++ clang),$(CXX))
$(error Invalid compiler specified: `$(CXX)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
- del *.exe >nul 2>&1

View File

@ -1,120 +1,55 @@
# WebUI C++ Example
# Windows - Microsoft Visual C++
# == 1. VARIABLES =============================================================
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=g++` / `make CC=clang`
CXX = g++
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = -std=c++17 -lstdc++ main.cpp -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
CXX = clang
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CXX),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
# Build the WebUI library if running `nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
!ENDIF
# Static with Debug info
@echo "Build C99 Example ($(CXX) debug static)..."
@$(CXX) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@echo Build C++ Example (Debug Static)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo "Build C99 Example ($(CXX) debug dynamic)..."
@$(CXX) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@echo Build C++ Example (Debug Dynamic)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
!ENDIF
# Static Release
@echo "Build C99 Example ($(CXX) release static)..."
@$(CXX) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
@echo Build C++ Example (Release Static)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo "Build C99 Example ($(CXX) release dynamic)..."
@$(CXX) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
@echo Build C++ Example (Release Dynamic)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CXX),g++ clang),$(CXX))
$(error Invalid compiler specified: `$(CXX)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -1,55 +0,0 @@
# WebUI C++ Example
# Windows - Microsoft Visual C++
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
# Build the WebUI library if running `nmake -f Makefile.nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake debug
!ENDIF
# Static with Debug info
@echo Build C++ Example (Debug Static)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo Build C++ Example (Debug Dynamic)...
@cl /Zi /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake
!ENDIF
# Static Release
@echo Build C++ Example (Release Static)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo Build C++ Example (Release Dynamic)...
@cl /EHsc /std:c++17 main.cpp /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -20,7 +20,7 @@ To build an example, cd into its directory and run the make command.
mingw32-make
# MSVC
nmake -f Makefile.nmake
nmake
```
- **Linux**

View File

@ -0,0 +1,120 @@
# WebUI C99 Example
# == 1. VARIABLES =============================================================
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
# Static with Debug info
@echo "Build C99 Example ($(CC) debug static)..."
@$(CC) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
# Dynamic with Debug info
@echo "Build C99 Example ($(CC) debug dynamic)..."
@$(CC) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
# Static Release
@echo "Build C99 Example ($(CC) release static)..."
@$(CC) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
# Dynamic Release
@echo "Build C99 Example ($(CC) release dynamic)..."
@$(CC) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CC),gcc clang),$(CC))
$(error Invalid compiler specified: `$(CC)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
- del *.exe >nul 2>&1

View File

@ -1,120 +1,55 @@
# WebUI C99 Example
# Windows - Microsoft Visual C
# == 1. VARIABLES =============================================================
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
# Build the WebUI library if running `nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
!ENDIF
# Static with Debug info
@echo "Build C99 Example ($(CC) debug static)..."
@$(CC) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@echo Build C99 Example (Static Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo "Build C99 Example ($(CC) debug dynamic)..."
@$(CC) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@echo Build C99 Example (Dynamic Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
!ENDIF
# Static Release
@echo "Build C99 Example ($(CC) release static)..."
@$(CC) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
@echo Build C99 Example (Static Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo "Build C99 Example ($(CC) release dynamic)..."
@$(CC) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
@echo Build C99 Example (Dynamic Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CC),gcc clang),$(CC))
$(error Invalid compiler specified: `$(CC)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -1,55 +0,0 @@
# WebUI C99 Example
# Windows - Microsoft Visual C
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
# Build the WebUI library if running `nmake -f Makefile.nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake debug
!ENDIF
# Static with Debug info
@echo Build C99 Example (Static Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo Build C99 Example (Dynamic Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake
!ENDIF
# Static Release
@echo Build C99 Example (Static Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo Build C99 Example (Dynamic Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -0,0 +1,120 @@
# WebUI C99 Example
# == 1. VARIABLES =============================================================
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
# Static with Debug info
@echo "Build C99 Example ($(CC) debug static)..."
@$(CC) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
# Dynamic with Debug info
@echo "Build C99 Example ($(CC) debug dynamic)..."
@$(CC) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
# Static Release
@echo "Build C99 Example ($(CC) release static)..."
@$(CC) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
# Dynamic Release
@echo "Build C99 Example ($(CC) release dynamic)..."
@$(CC) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CC),gcc clang),$(CC))
$(error Invalid compiler specified: `$(CC)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
- del *.exe >nul 2>&1

View File

@ -1,120 +1,55 @@
# WebUI C99 Example
# Windows - Microsoft Visual C
# == 1. VARIABLES =============================================================
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
# Build the WebUI library if running `nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
!ENDIF
# Static with Debug info
@echo "Build C99 Example ($(CC) debug static)..."
@$(CC) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@echo Build C99 Example (Static Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo "Build C99 Example ($(CC) debug dynamic)..."
@$(CC) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@echo Build C99 Example (Dynamic Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
!ENDIF
# Static Release
@echo "Build C99 Example ($(CC) release static)..."
@$(CC) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
@echo Build C99 Example (Static Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo "Build C99 Example ($(CC) release dynamic)..."
@$(CC) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
@echo Build C99 Example (Dynamic Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CC),gcc clang),$(CC))
$(error Invalid compiler specified: `$(CC)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -1,55 +0,0 @@
# WebUI C99 Example
# Windows - Microsoft Visual C
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
# Build the WebUI library if running `nmake -f Makefile.nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake debug
!ENDIF
# Static with Debug info
@echo Build C99 Example (Static Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo Build C99 Example (Dynamic Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake
!ENDIF
# Static Release
@echo Build C99 Example (Static Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo Build C99 Example (Dynamic Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -0,0 +1,120 @@
# WebUI C99 Example
# == 1. VARIABLES =============================================================
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
# Static with Debug info
@echo "Build C99 Example ($(CC) debug static)..."
@$(CC) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
# Dynamic with Debug info
@echo "Build C99 Example ($(CC) debug dynamic)..."
@$(CC) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
# Static Release
@echo "Build C99 Example ($(CC) release static)..."
@$(CC) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
# Dynamic Release
@echo "Build C99 Example ($(CC) release dynamic)..."
@$(CC) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CC),gcc clang),$(CC))
$(error Invalid compiler specified: `$(CC)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
- del *.exe >nul 2>&1

View File

@ -1,120 +1,55 @@
# WebUI C99 Example
# Windows - Microsoft Visual C
# == 1. VARIABLES =============================================================
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
# Build the WebUI library if running `nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
!ENDIF
# Static with Debug info
@echo "Build C99 Example ($(CC) debug static)..."
@$(CC) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@echo Build C99 Example (Static Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo "Build C99 Example ($(CC) debug dynamic)..."
@$(CC) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@echo Build C99 Example (Dynamic Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
!ENDIF
# Static Release
@echo "Build C99 Example ($(CC) release static)..."
@$(CC) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
@echo Build C99 Example (Static Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo "Build C99 Example ($(CC) release dynamic)..."
@$(CC) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
@echo Build C99 Example (Dynamic Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CC),gcc clang),$(CC))
$(error Invalid compiler specified: `$(CC)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -1,55 +0,0 @@
# WebUI C99 Example
# Windows - Microsoft Visual C
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
# Build the WebUI library if running `nmake -f Makefile.nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake debug
!ENDIF
# Static with Debug info
@echo Build C99 Example (Static Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo Build C99 Example (Dynamic Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake
!ENDIF
# Static Release
@echo Build C99 Example (Static Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo Build C99 Example (Dynamic Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -0,0 +1,120 @@
# WebUI C99 Example
# == 1. VARIABLES =============================================================
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
# Static with Debug info
@echo "Build C99 Example ($(CC) debug static)..."
@$(CC) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
# Dynamic with Debug info
@echo "Build C99 Example ($(CC) debug dynamic)..."
@$(CC) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
# Static Release
@echo "Build C99 Example ($(CC) release static)..."
@$(CC) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
# Dynamic Release
@echo "Build C99 Example ($(CC) release dynamic)..."
@$(CC) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CC),gcc clang),$(CC))
$(error Invalid compiler specified: `$(CC)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
- del *.exe >nul 2>&1

View File

@ -1,120 +1,55 @@
# WebUI C99 Example
# Windows - Microsoft Visual C
# == 1. VARIABLES =============================================================
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
PROJECT_DIR := $(shell git rev-parse --show-toplevel)
LIB_DIR := $(PROJECT_DIR)/dist
INCLUDE_DIR := $(PROJECT_DIR)/include
# ARGS
# Set a compiler when running on Linux via `make CC=gcc` / `make CC=clang`
CC = gcc
# Build the WebUI library if running via `make BUILD_LIB=true`
BUILD_LIB ?=
# BUILD FLAGS
STATIC_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
DYN_BUILD_FLAGS = main.c -I"$(INCLUDE_DIR)" -L"$(LIB_DIR)"
# Platform conditions
ifeq ($(OS),Windows_NT)
# Windows
PLATFORM := windows
SHELL := CMD
STATIC_BUILD_FLAGS += -lwebui-2-static -lws2_32 -Wall -Wl,-subsystem=console -luser32 -static
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dll" -lws2_32 -Wall -Wl,-subsystem=console -luser32
STATIC_OUT := main.exe
DYN_OUT := main-dyn.exe
LWS2_OPT := -lws2_32
STRIP_OPT := --strip-all
else
STATIC_BUILD_FLAGS += -lpthread -lm -lwebui-2-static
DYN_BUILD_FLAGS += -lpthread -lm
STATIC_OUT := main
DYN_OUT := main-dyn
ifeq ($(shell uname),Darwin)
# MacOS
PLATFORM := macos
CC = clang
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.dylib"
else
# Linux
PLATFORM := linux
DYN_BUILD_FLAGS += "$(LIB_DIR)/webui-2.so"
STRIP_OPT := --strip-all
ifeq ($(CC),clang)
LLVM_OPT := llvm-
endif
endif
endif
# == 2.TARGETS ================================================================
# Build the WebUI library if running `nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug: LIB_DIR := $(LIB_DIR)/debug
debug: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE) debug
endif
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) debug
!ENDIF
# Static with Debug info
@echo "Build C99 Example ($(CC) debug static)..."
@$(CC) -g $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@echo Build C99 Example (Static Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo "Build C99 Example ($(CC) debug dynamic)..."
@$(CC) -g $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@echo Build C99 Example (Dynamic Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release: --validate-args
ifeq ($(BUILD_LIB),true)
@cd "$(PROJECT_DIR)" && $(MAKE)
endif
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE)
!ENDIF
# Static Release
@echo "Build C99 Example ($(CC) release static)..."
@$(CC) -Os $(STATIC_BUILD_FLAGS) $(LWS2_OPT) -o $(STATIC_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(STATIC_OUT)
@echo Build C99 Example (Static Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo "Build C99 Example ($(CC) release dynamic)..."
@$(CC) $(DYN_BUILD_FLAGS) $(LWS2_OPT) -o $(DYN_OUT)
@$(LLVM_OPT)strip $(STRIP_OPT) $(DYN_OUT)
@echo Build C99 Example (Dynamic Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
ifeq ($(PLATFORM),windows)
@- del *.o >nul 2>&1
else
@- rm -f *.o
@- rm -rf *.dSYM # macOS
endif
@echo "Done."
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean: --clean-$(PLATFORM)
# INTERNAL TARGETS
--validate-args:
ifneq ($(filter $(CC),gcc clang),$(CC))
$(error Invalid compiler specified: `$(CC)`)
endif
--clean-linux: --clean-unix
--clean-macos: --clean-unix
--clean-unix:
- rm -f *.o
- rm -f *.a
- rm -f *.so
- rm -f *.dylib
- rm -rf *.dSYM
--clean-windows:
- del *.o >nul 2>&1
- del *.dll >nul 2>&1
- del *.a >nul 2>&1
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1

View File

@ -1,55 +0,0 @@
# WebUI C99 Example
# Windows - Microsoft Visual C
SHELL = CMD
LIB_DIR = ../../../dist
INCLUDE_DIR = ../../../include
# Build the WebUI library if running `nmake -f Makefile.nmake BUILD_LIB=true`
BUILD_LIB =
all: release
debug:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake debug
!ENDIF
# Static with Debug info
@echo Build C99 Example (Static Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic with Debug info
@echo Build C99 Example (Dynamic Debug)...
@cl /Zi main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)/debug" /MACHINE:X64 /SUBSYSTEM:CONSOLE webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
release:
!IF "$(BUILD_LIB)" == "true"
@cd "$(LIB_DIR)" && cd .. && $(MAKE) -f Makefile.nmake
!ENDIF
# Static Release
@echo Build C99 Example (Static Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2-static.lib user32.lib Advapi32.lib /OUT:main.exe 1>NUL 2>&1
# Dynamic Release
@echo Build C99 Example (Dynamic Release)...
@cl main.c /I"$(INCLUDE_DIR)" /link /LIBPATH:"$(LIB_DIR)" /MACHINE:X64 /SUBSYSTEM:WINDOWS webui-2.lib user32.lib Advapi32.lib /OUT:main-dyn.exe 1>NUL 2>&1
# Clean
@- del *.exp >nul 2>&1
@- del *.ilk >nul 2>&1
@- del *.lib >nul 2>&1
@- del *.obj >nul 2>&1
@- del *.pdb >nul 2>&1
@echo Done.
clean:
- del *.obj >nul 2>&1
- del *.ilk >nul 2>&1
- del *.pdb >nul 2>&1
- del *.exp >nul 2>&1
- del *.exe >nul 2>&1
- del *.lib >nul 2>&1