From 79bd64b4c8d0729b8568aac740286e0e47185352 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Fri, 4 Nov 2022 07:28:27 +0100 Subject: [PATCH] New C-based make by default --- GNUmakefile | 24 ++++++++++++++++++++++++ build.c | 19 ++++++++++++++++--- shim | 3 --- 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 GNUmakefile delete mode 100644 shim diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..6b19b70 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,24 @@ +# This is the GNU Make shim for Linux and macOS + +DESTDIR ?= +prefix ?= /usr/local + +examples: default + ./build examples + +clean: default + ./build clean + +capi: default + ./build capi + +install: + mkdir -p "$(DESTDIR)$(prefix)/include/uWebSockets" + cp -r src/* "$(DESTDIR)$(prefix)/include/uWebSockets" + +all: default + ./build all + +default: + $(MAKE) -C uSockets + $(CC) build.c -o build diff --git a/build.c b/build.c index 3e02402..3aecfde 100644 --- a/build.c +++ b/build.c @@ -1,6 +1,6 @@ #include "build.h" -int main() { +int main(int argc, char **argv) { /* Some variables we need */ char *CXXFLAGS = strcpy(calloc(1024, 1), maybe(getenv("CXXFLAGS"))); char *CFLAGS = strcpy(calloc(1024, 1), maybe(getenv("CFLAGS"))); @@ -71,7 +71,20 @@ int main() { strcat(LDFLAGS, " -lasan"); } - for (int i = 0; i < sizeof(EXAMPLE_FILES) / sizeof(char *); i++) { - run("%s%s examples/%s.cpp %s -o %s", CXX, CXXFLAGS, EXAMPLE_FILES[i], LDFLAGS, EXAMPLE_FILES[i]); + if (!strcmp(argv[1], "examples")) { + for (int i = 0; i < sizeof(EXAMPLE_FILES) / sizeof(char *); i++) { + if (run("%s%s examples/%s.cpp %s -o %s", CXX, CXXFLAGS, EXAMPLE_FILES[i], LDFLAGS, EXAMPLE_FILES[i])) { + return -1; + } + } + } else if (!strcmp(argv[1], "capi")) { + printf("capi target does nothing yet\n"); + } else if (!strcmp(argv[1], "clean")) { + printf("clean target does nothing yet\n"); + } else if (!strcmp(argv[1], "install")) { + // install target is not even supposed to be cross platform + printf("install target does nothing yet\n"); + } else if (!strcmp(argv[1], "all")) { + printf("all target does nothing yet\n"); } } \ No newline at end of file diff --git a/shim b/shim deleted file mode 100644 index 2076426..0000000 --- a/shim +++ /dev/null @@ -1,3 +0,0 @@ -default: - $(CC) build.c - ./a.out || build.exe || a.exe