gem-graph-client/Makefile

92 lines
1.9 KiB
Makefile
Raw Normal View History

2024-10-05 18:32:30 +02:00
.PHONY: run clean install all gl_test
.DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK
.DEFAULT_GOAL: all
2024-06-29 17:29:45 +02:00
CPUS ?= $(shell (nproc --all || sysctl -n hw.ncpu) 2>/dev/null || echo 1)
MAKEFLAGS += --jobs=$(CPUS)
CC=gcc
2024-09-10 15:20:25 +02:00
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
BINDIR=bin
BUILDDIR=build
SRCDIR=src
SOURCES = $(shell find $(SRCDIR) -type f -name "*.c")
OBJECTS = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
DEPENDENCIES = $(patsubst %.c,$(BUILDDIR)/%.d,$(SOURCES))
2024-10-05 19:08:44 +02:00
sandbox: opengl_sandbox/main.c
2024-10-05 18:32:30 +02:00
$(CC) $(CFLAGS) $(LDFLAGS) $(WARNINGS) $(DEBUG)-o $@ $<
2024-10-05 19:08:44 +02:00
gl_run: sandbox
2024-10-05 18:32:30 +02:00
./$<
gl_clean:
2024-10-05 19:08:44 +02:00
rm sandbox
2024-10-05 18:32:30 +02:00
all: $(BINDIR)/gem-graph-client
-include /etc/os-release
#
# Directories
#
$(BUILDDIR):
2024-06-29 17:29:45 +02:00
@mkdir -p $@
@echo " MKDIR $@"
$(BINDIR):
2024-06-29 17:29:45 +02:00
@mkdir -p $@
@echo " MKDIR $@"
#
# Dependencies
#
-include $(DEPENDENCIES)
$(BUILDDIR)/%.d: %.c Makefile | $(BUILDDIR)
2024-06-29 17:29:45 +02:00
@mkdir -p $(shell dirname $@)
@$(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $<
@echo " DEP $@"
#
# Main program
#
$(BINDIR)/gem-graph-client: $(OBJECTS) | $(BINDIR)
2024-06-29 17:29:45 +02:00
@$(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@
@echo " LD $@"
#
# Objects
#
$(BUILDDIR)/%.o: %.c Makefile | $(BUILDDIR)
2024-06-29 17:29:45 +02:00
@mkdir -p $(shell dirname $@)
@$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@
@echo " CC $@"
#
# Virtual recipes
#
install:
2024-06-29 17:29:45 +02:00
@echo "Installing is not supported"
run: $(BINDIR)/gem-graph-client
$(BINDIR)/gem-graph-client
clean:
2024-06-29 17:29:45 +02:00
@rm -rf $(BINDIR)
@echo " RM $(BINDIR)"
@rm -rf $(BUILDDIR)
@echo " RM $(BUILDDIR)"
# More docs :
# https://www.gnu.org/software/make/manual/
# accessoirement : https://blog.stephane-robert.info/docs/makefile/ & /docs/task/