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
This commit is contained in:
parent
62987bbd33
commit
5c0289217e
|
@ -0,0 +1,2 @@
|
||||||
|
bin/*
|
||||||
|
build/*
|
34
Makefile
34
Makefile
|
@ -2,11 +2,12 @@
|
||||||
.DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK
|
.DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK
|
||||||
.DEFAULT_GOAL: all
|
.DEFAULT_GOAL: all
|
||||||
|
|
||||||
NTHREADS= $(shell nproc)
|
CPUS ?= $(shell (nproc --all || sysctl -n hw.ncpu) 2>/dev/null || echo 1)
|
||||||
|
MAKEFLAGS += --jobs=$(CPUS)
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=`pkg-config --cflags gtk4 gl glib-2.0 libxml-2.0`
|
CFLAGS=`pkg-config --cflags gtk4 epoxy glib-2.0 libxml-2.0`
|
||||||
LDFLAGS=`pkg-config --libs gtk4 gl glib-2.0 libxml-2.0` -lGL -lGLU -lm -lepoxy -lX11 -lGLEW
|
LDFLAGS=`pkg-config --libs gtk4 epoxy glib-2.0 libxml-2.0` -lGL -lGLU -lm -lepoxy -lX11 -lGLEW
|
||||||
WARNINGS = -Wall
|
WARNINGS = -Wall
|
||||||
DEBUG = -ggdb -fno-omit-frame-pointer #-fdiagnostics-color=always -fsanitize=bounds -fstack-check
|
DEBUG = -ggdb -fno-omit-frame-pointer #-fdiagnostics-color=always -fsanitize=bounds -fstack-check
|
||||||
OPTIMIZE = -O3
|
OPTIMIZE = -O3
|
||||||
|
@ -27,10 +28,12 @@ all: $(BINDIR)/gem-graph-client
|
||||||
# Directories
|
# Directories
|
||||||
#
|
#
|
||||||
$(BUILDDIR):
|
$(BUILDDIR):
|
||||||
mkdir -p $@
|
@mkdir -p $@
|
||||||
|
@echo " MKDIR $@"
|
||||||
|
|
||||||
$(BINDIR):
|
$(BINDIR):
|
||||||
mkdir -p $@
|
@mkdir -p $@
|
||||||
|
@echo " MKDIR $@"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
@ -38,34 +41,39 @@ $(BINDIR):
|
||||||
-include $(DEPENDENCIES)
|
-include $(DEPENDENCIES)
|
||||||
|
|
||||||
$(BUILDDIR)/%.d: %.c Makefile | $(BUILDDIR)
|
$(BUILDDIR)/%.d: %.c Makefile | $(BUILDDIR)
|
||||||
mkdir -p $(shell dirname $@)
|
@mkdir -p $(shell dirname $@)
|
||||||
$(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $<
|
@$(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $<
|
||||||
|
@echo " DEP $@"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main program
|
# Main program
|
||||||
#
|
#
|
||||||
$(BINDIR)/gem-graph-client: $(OBJECTS) | $(BINDIR)
|
$(BINDIR)/gem-graph-client: $(OBJECTS) | $(BINDIR)
|
||||||
$(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@
|
@$(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@
|
||||||
|
@echo " LD $@"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Objects
|
# Objects
|
||||||
#
|
#
|
||||||
$(BUILDDIR)/%.o: %.c Makefile | $(BUILDDIR)
|
$(BUILDDIR)/%.o: %.c Makefile | $(BUILDDIR)
|
||||||
mkdir -p $(shell dirname $@)
|
@mkdir -p $(shell dirname $@)
|
||||||
$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@
|
@$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@
|
||||||
|
@echo " CC $@"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Virtual recipes
|
# Virtual recipes
|
||||||
#
|
#
|
||||||
install:
|
install:
|
||||||
echo "Installing is not supported"
|
@echo "Installing is not supported"
|
||||||
|
|
||||||
run: $(BINDIR)/gem-graph-client
|
run: $(BINDIR)/gem-graph-client
|
||||||
$(BINDIR)/gem-graph-client
|
$(BINDIR)/gem-graph-client
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BINDIR)
|
@rm -rf $(BINDIR)
|
||||||
rm -rf $(BUILDDIR)
|
@echo " RM $(BINDIR)"
|
||||||
|
@rm -rf $(BUILDDIR)
|
||||||
|
@echo " RM $(BUILDDIR)"
|
||||||
|
|
||||||
|
|
||||||
# More docs :
|
# More docs :
|
||||||
|
|
Loading…
Reference in New Issue