Add a build for MacOS

This copies the Linux build to generate binaries for MacOS
This commit is contained in:
Charles Lowell 2023-03-28 15:50:10 -05:00
parent 9aca227129
commit 599d452a70
No known key found for this signature in database
GPG Key ID: 8D79AB5C09E2C228
2 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,44 @@
# WebUI Library
# MacOS - Clang
SOURCE=../../../src
INCLUDE=../../../include
all: release
debug:
# Static with Debug info
@echo "Build WebUI Library (Debug Static)..."
@clang -g -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
@clang -g -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@ar rc libwebui-2-aarch64-apple-darwin.a webui.o mongoose.o
@ranlib libwebui-2-aarch64-apple-darwin.a
# Dynamic with Debug info
@echo "Build WebUI Library (Debug Dynamic)..."
@clang -g -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
@clang -g -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@clang -g -shared -o webui-2-aarch64-apple-darwin.dylib webui.o mongoose.o
# Clean
@- rm -f *.o
@echo "Done."
release:
# Static Release
@echo "Build WebUI Library (Release Static)..."
@clang -Os -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
@clang -Os -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@ar rc libwebui-2-aarch64-apple-darwin.a webui.o mongoose.o
@ranlib libwebui-2-aarch64-apple-darwin.a
# Dynamic Release
@echo "Build WebUI Library (Release Dynamic)..."
@clang -O3 -fPIC -m64 -o mongoose.o -I "$(INCLUDE)" -c "$(SOURCE)/mongoose.c"
@clang -O3 -fPIC -m64 -o webui.o -I "$(INCLUDE)" -c "$(SOURCE)/webui.c"
@clang -shared -o webui-2-aarch64-apple-darwin.dylib webui.o mongoose.o
# Clean
@- rm -f *.o
@echo "Done."
clean:
- rm -f *.o
- rm -f *.dylib
- rm -f *.a

View File

@ -82,6 +82,21 @@
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Apple ---------------------------
#ifdef __APPLE__
#include <pthread.h> // POSIX threading
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <poll.h>
#define WEBUI_GET_CURRENT_DIR getcwd
#define WEBUI_FILE_EXIST access
#define WEBUI_POPEN popen
#define WEBUI_PCLOSE pclose
#define WEBUI_MAX_PATH PATH_MAX
#endif
// -- Structs -------------------------
struct webui_event_t;