gem-graph-client/Makefile

75 lines
1.5 KiB
Makefile
Raw Normal View History

.PHONY: run clean install all
.DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK
.DEFAULT_GOAL: all
NTHREADS= $(shell nproc)
2024-04-22 18:40:30 +02:00
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
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))
all: $(BINDIR)/gem-graph-client
-include /etc/os-release
#
# Directories
#
$(BUILDDIR):
mkdir -p $@
$(BINDIR):
mkdir -p $@
#
# Dependencies
#
-include $(DEPENDENCIES)
$(BUILDDIR)/%.d: %.c Makefile | $(BUILDDIR)
mkdir -p $(shell dirname $@)
$(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $<
#
# Main program
#
$(BINDIR)/gem-graph-client: $(OBJECTS) | $(BINDIR)
$(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@
#
# Objects
#
$(BUILDDIR)/%.o: %.c Makefile | $(BUILDDIR)
mkdir -p $(shell dirname $@)
$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@
#
# Virtual recipes
#
install:
echo "Installing is not supported"
run: $(BINDIR)/gem-graph-client
$(BINDIR)/gem-graph-client
2024-04-26 19:40:19 +02:00
clean:
rm -rf $(BINDIR)
rm -rf $(BUILDDIR)
2024-04-27 16:16:21 +02:00
2024-04-26 19:40:19 +02:00
# More docs :
2024-04-26 19:40:19 +02:00
# https://www.gnu.org/software/make/manual/
2024-04-27 14:59:32 +02:00
# accessoirement : https://blog.stephane-robert.info/docs/makefile/ & /docs/task/