New C-based make by default

This commit is contained in:
Alex Hultman
2022-11-04 07:28:27 +01:00
parent b6604b2996
commit 79bd64b4c8
3 changed files with 40 additions and 6 deletions
+24
View File
@@ -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
+16 -3
View File
@@ -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");
}
}
-3
View File
@@ -1,3 +0,0 @@
default:
$(CC) build.c
./a.out || build.exe || a.exe