2024-10-28 13:57:44 +01:00
|
|
|
.PHONY: run clean install all docs
|
2024-04-20 11:17:01 +02:00
|
|
|
.DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK
|
|
|
|
.DEFAULT_GOAL: all
|
|
|
|
|
2024-11-01 23:54:29 +01:00
|
|
|
CPUS ?= $(shell (nproc --all || sysctl -n hw.ncpu) 2>/dev/null || echo 1)
|
|
|
|
MAKEFLAGS += --jobs=$(CPUS)
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
CC=gcc
|
2024-10-28 13:57:44 +01:00
|
|
|
DOXYGEN=doxygen
|
2024-11-01 23:54:29 +01: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
|
2024-04-20 11:17:01 +02:00
|
|
|
WARNINGS = -Wall
|
2024-11-22 16:38:30 +01:00
|
|
|
DEBUG = -ggdb -fno-omit-frame-pointer \
|
|
|
|
-fdiagnostics-color=always \
|
|
|
|
-fsanitize=address,undefined -fstack-protector-strong
|
2024-04-20 11:17:01 +02:00
|
|
|
OPTIMIZE = -O3
|
|
|
|
|
|
|
|
BINDIR=bin
|
|
|
|
BUILDDIR=build
|
|
|
|
SRCDIR=src
|
2024-10-28 13:57:44 +01:00
|
|
|
DOCSDIR=docs
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
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):
|
2024-11-01 23:54:29 +01:00
|
|
|
@mkdir -p $@
|
|
|
|
@echo " MKDIR $@"
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
$(BINDIR):
|
2024-11-01 23:54:29 +01:00
|
|
|
@mkdir -p $@
|
|
|
|
@echo " MKDIR $@"
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Dependencies
|
|
|
|
#
|
|
|
|
-include $(DEPENDENCIES)
|
|
|
|
|
|
|
|
$(BUILDDIR)/%.d: %.c Makefile | $(BUILDDIR)
|
2024-11-01 23:54:29 +01:00
|
|
|
@mkdir -p $(shell dirname $@)
|
|
|
|
@$(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $<
|
|
|
|
@echo " DEP $@"
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Main program
|
|
|
|
#
|
|
|
|
$(BINDIR)/gem-graph-client: $(OBJECTS) | $(BINDIR)
|
2024-11-01 23:54:29 +01:00
|
|
|
@$(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@
|
|
|
|
@echo " LD $@"
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Objects
|
|
|
|
#
|
|
|
|
$(BUILDDIR)/%.o: %.c Makefile | $(BUILDDIR)
|
2024-11-01 23:54:29 +01:00
|
|
|
@mkdir -p $(shell dirname $@)
|
|
|
|
@$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@
|
|
|
|
@echo " CC $@"
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Virtual recipes
|
|
|
|
#
|
|
|
|
install:
|
2024-11-01 23:54:29 +01:00
|
|
|
@echo "Installing is not supported"
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
run: $(BINDIR)/gem-graph-client
|
|
|
|
$(BINDIR)/gem-graph-client
|
|
|
|
|
2024-10-28 13:57:44 +01:00
|
|
|
docs: $(SOURCES) $(DEPENDENCIES)
|
|
|
|
@$(DOXYGEN) $(DOCSDIR)/doxyfile
|
|
|
|
@echo " DOXYGEN $(DOCSDIR)/doxyfile"
|
|
|
|
|
2024-04-20 11:17:01 +02:00
|
|
|
clean:
|
2024-11-01 23:54:29 +01:00
|
|
|
@rm -rf $(BINDIR)
|
|
|
|
@echo " RM $(BINDIR)"
|
|
|
|
@rm -rf $(BUILDDIR)
|
|
|
|
@echo " RM $(BUILDDIR)"
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
# More docs :
|
|
|
|
# https://www.gnu.org/software/make/manual/
|
|
|
|
# accessoirement : https://blog.stephane-robert.info/docs/makefile/ & /docs/task/
|
|
|
|
|