From d74e590199f10cd00fd40f35de9c1a85a0796c07 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Fri, 1 Nov 2024 23:54:29 +0100 Subject: [PATCH] Makefile: fixes and parallel by default This commit: - fixes the OpenGL lib configurations (gl->epoxy) - added an exclusion for bin/ and build/ in .gitignore - make the Makefile parallel --- .gitignore | 2 ++ Makefile | 34 +++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c58ac0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/* +build/* diff --git a/Makefile b/Makefile index de22701..668b4af 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,12 @@ .DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK .DEFAULT_GOAL: all -NTHREADS= $(shell nproc) +CPUS ?= $(shell (nproc --all || sysctl -n hw.ncpu) 2>/dev/null || echo 1) +MAKEFLAGS += --jobs=$(CPUS) CC=gcc -CFLAGS=`pkg-config --cflags gtk4 gl glib-2.0 libxml-2.0` -LDFLAGS=`pkg-config --libs gtk4 gl glib-2.0 libxml-2.0` -lGL -lGLU -lm -lepoxy -lX11 -lGLEW +CFLAGS=`pkg-config --cflags gtk4 epoxy glib-2.0 libxml-2.0` +LDFLAGS=`pkg-config --libs gtk4 epoxy glib-2.0 libxml-2.0` -lGL -lGLU -lm -lepoxy -lX11 -lGLEW WARNINGS = -Wall DEBUG = -ggdb -fno-omit-frame-pointer #-fdiagnostics-color=always -fsanitize=bounds -fstack-check OPTIMIZE = -O3 @@ -27,10 +28,12 @@ all: $(BINDIR)/gem-graph-client # Directories # $(BUILDDIR): - mkdir -p $@ + @mkdir -p $@ + @echo " MKDIR $@" $(BINDIR): - mkdir -p $@ + @mkdir -p $@ + @echo " MKDIR $@" # # Dependencies @@ -38,34 +41,39 @@ $(BINDIR): -include $(DEPENDENCIES) $(BUILDDIR)/%.d: %.c Makefile | $(BUILDDIR) - mkdir -p $(shell dirname $@) - $(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $< + @mkdir -p $(shell dirname $@) + @$(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $< + @echo " DEP $@" # # Main program # $(BINDIR)/gem-graph-client: $(OBJECTS) | $(BINDIR) - $(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@ + @$(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@ + @echo " LD $@" # # Objects # $(BUILDDIR)/%.o: %.c Makefile | $(BUILDDIR) - mkdir -p $(shell dirname $@) - $(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@ + @mkdir -p $(shell dirname $@) + @$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@ + @echo " CC $@" # # Virtual recipes # install: - echo "Installing is not supported" + @echo "Installing is not supported" run: $(BINDIR)/gem-graph-client $(BINDIR)/gem-graph-client clean: - rm -rf $(BINDIR) - rm -rf $(BUILDDIR) + @rm -rf $(BINDIR) + @echo " RM $(BINDIR)" + @rm -rf $(BUILDDIR) + @echo " RM $(BUILDDIR)" # More docs :