2024-05-05 20:53:52 +02:00
|
|
|
|
.PHONY: run clean install all
|
2024-06-04 21:36:05 +02:00
|
|
|
|
.DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK
|
2024-05-05 20:53:52 +02:00
|
|
|
|
.DEFAULT_GOAL: all
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
2024-06-04 21:36:05 +02:00
|
|
|
|
NTHREADS= $(shell nproc)
|
|
|
|
|
|
2024-04-22 18:40:30 +02:00
|
|
|
|
CC=gcc
|
2024-05-05 20:53:52 +02:00
|
|
|
|
CFLAGS=`pkg-config --cflags gtk4 gl glib-2.0`
|
|
|
|
|
LDFLAGS=`pkg-config --libs gtk4 gl glib-2.0`
|
2024-04-20 11:17:01 +02:00
|
|
|
|
WARNINGS = -Wall
|
2024-06-04 21:36:05 +02:00
|
|
|
|
DEBUG = -ggdb -fno-omit-frame-pointer #-fdiagnostics-color=always -fsanitize=bounds -fstack-check
|
2024-05-05 20:53:52 +02:00
|
|
|
|
OPTIMIZE = -O3
|
2024-06-04 21:36:05 +02:00
|
|
|
|
INCLUDE= $(shell pkg-config --cflags glib-2.0 libxml-2.0 gtk4)
|
|
|
|
|
LIBS= $(shell pkg-config --libs glib-2.0 libxml-2.0 gtk4) -lGL -lGLU -lm -lepoxy -lX11 -lGLEW
|
|
|
|
|
|
|
|
|
|
BINDIR=bin
|
|
|
|
|
BUILDDIR=build
|
|
|
|
|
SRCDIR=src
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
2024-05-05 20:53:52 +02:00
|
|
|
|
sources = $(shell find . -maxdepth 1 -type f -name "*.c")
|
|
|
|
|
objects = $(patsubst %.c,%.o,$(sources))
|
|
|
|
|
dependencies = $(patsubst %.c,%.d,$(sources))
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
2024-05-05 20:53:52 +02:00
|
|
|
|
all: myprogram
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
2024-05-05 20:53:52 +02:00
|
|
|
|
-include $(dependencies)
|
|
|
|
|
|
|
|
|
|
myprogram: $(objects)
|
|
|
|
|
$(CC) $(LDFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ -o $@
|
|
|
|
|
|
|
|
|
|
%.o: %.c Makefile
|
|
|
|
|
$(CC) $(CFLAGS) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -c $< -o $@
|
|
|
|
|
|
|
|
|
|
%.d: %.c Makefile
|
|
|
|
|
$(CC) $(CFLAGS) -MM -MT $(@:%.d=%.o) -MF $@ $<
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|
|
|
|
|
install:
|
|
|
|
|
echo "Installing is not supported"
|
|
|
|
|
|
2024-05-05 20:53:52 +02:00
|
|
|
|
run: myprogram
|
|
|
|
|
./myprogram
|
2024-04-26 19:40:19 +02:00
|
|
|
|
|
2024-05-05 20:53:52 +02:00
|
|
|
|
clean:
|
|
|
|
|
rm -f myprogram
|
|
|
|
|
rm -f *.o
|
|
|
|
|
rm -f *.d
|
2024-04-27 14:59:32 +02:00
|
|
|
|
|
2024-05-01 10:07:50 +02:00
|
|
|
|
# /!\ erreur fatale: GL/glu.h <?>
|
|
|
|
|
# gcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -g -Wall -Wextra
|
|
|
|
|
# -std=c99 -lm *.c -o formattage `pkg-config --cflags --libs glib-2.0`
|
2024-04-27 14:59:32 +02:00
|
|
|
|
|
2024-05-05 20:53:52 +02:00
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
|
# 'make' has an implicit rule for updating a ‘.o’ file #
|
|
|
|
|
# from a correspondingly named ‘.c’ file #
|
|
|
|
|
# using a ‘cc -c’ command. #
|
|
|
|
|
# Implicit rules are listed and applied in a predefined order (C before P...) #
|
|
|
|
|
# Predefined implicit rules are implemented in make as suffix rules #
|
|
|
|
|
# The default suffix list is: .out, .a, .ln, .o, .c, .cc, .C, .cpp, .p,... #
|
|
|
|
|
# Rules whose suffixes fail to be on the list are disabled. #
|
|
|
|
|
# You can define your own implicit rules by writing pattern rules. #
|
|
|
|
|
#------------------------------------------------------------------------------#
|
2024-04-27 14:59:32 +02:00
|
|
|
|
|
2024-05-05 20:53:52 +02:00
|
|
|
|
# If there are many implicit rules with the same target pattern,
|
|
|
|
|
# the rule that actually applies is the one whose prerequisites exist or can be made
|
|
|
|
|
# ex: a .o can be made from a .c (C compiler) or a .p (Pascal compiler)
|
2024-04-27 16:16:21 +02:00
|
|
|
|
|
2024-05-05 20:53:52 +02:00
|
|
|
|
# Variables allow a text string to be defined once
|
|
|
|
|
# and substituted in multiple places later.
|
|
|
|
|
# (see Chapter 6 [How to Use Variables], page 65)
|
2024-04-27 16:16:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
2024-04-28 06:21:57 +02:00
|
|
|
|
# To study : how can the following commands be modified ? #
|
2024-04-27 16:16:21 +02:00
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
|
|
#SHELL = /bin/sh
|
|
|
|
|
#.SUFFIXES:
|
|
|
|
|
#.SUFFIXES: .c .o .h # is .h useful ?
|
|
|
|
|
#.PHONY = run
|
|
|
|
|
#.PHONY = clean
|
|
|
|
|
#.PHONY: Makefile
|
|
|
|
|
|
|
|
|
|
#CC=gcc
|
|
|
|
|
#CFLAGS=`pkg-config --cflags gtk4 --libs gtk4`
|
|
|
|
|
#WARNINGS = -Wall
|
|
|
|
|
#DEBUG = -ggdb -fno-omit-frame-pointer
|
|
|
|
|
#OPTIMIZE = -O2
|
|
|
|
|
|
|
|
|
|
# in exec.o:
|
2024-04-28 06:21:57 +02:00
|
|
|
|
# $(WARNINGS) $(DEBUG) $(OPTIMIZE) < ne sont pas indispensables
|
|
|
|
|
# si le $@ est supprimé, main.cest modifié
|
2024-04-27 16:16:21 +02:00
|
|
|
|
#all:
|
|
|
|
|
# exec
|
|
|
|
|
|
|
|
|
|
#install:
|
|
|
|
|
# echo "Installing is not supported"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
|
# Personnal notes & links #
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
|
|
|
2024-04-26 19:40:19 +02:00
|
|
|
|
# gcc $( pkg-config --cflags gtk4 ) -o exec main.c $( pkg-config --libs gtk4 )
|
|
|
|
|
|
|
|
|
|
# https://www.gnu.org/software/make/manual/
|
|
|
|
|
|
|
|
|
|
# Makefiles contain five kinds of things:
|
|
|
|
|
# explicit rules, implicit rules, variable definitions, directives and comments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Variables automatiques --------------------------------------------------
|
|
|
|
|
# $@ fait référence à la cible de la règle (au nom de la cible).
|
|
|
|
|
# $< fait référence à la première dépendance.
|
|
|
|
|
# $? fait référence aux noms de touess les dépendances plus récentes que la cible.
|
|
|
|
|
# = les fichiers qui ont été modifiés après la compilation de code la plus récente
|
|
|
|
|
# $^ fait référence aux noms de touess les dépendances avec des espaces entre eux.
|
|
|
|
|
|
|
|
|
|
# Variables implicites -------------------------------------------------
|
|
|
|
|
# VPATH Équivalent utilitaire de la variable PATH de Bash. Vide par défaut.
|
|
|
|
|
# Les chemins sont séparés par le signe deux-points (:).
|
|
|
|
|
# CC Le programme pour compiler des fichiers C.
|
|
|
|
|
# La valeur par défaut est cc. (Habituellement, cc pointe vers gcc.)
|
|
|
|
|
# CPP Le programme qui exécute le préprocesseur C.
|
|
|
|
|
# La valeur par défaut est $ (CC) -E.
|
|
|
|
|
# LEX Le programme qui transforme les grammaires lexicales en code source.
|
|
|
|
|
# La valeur par défaut est lex. (Vous devriez remplacer cela par flex.)
|
|
|
|
|
# LINT Le programme qui lint votre code source. La valeur par défaut est lint.
|
|
|
|
|
# RM La commande pour supprimer un fichier. La valeur par défaut est rm -f.
|
|
|
|
|
# CFLAGS Contient tous les indicateurs du compilateur C (cc).
|
|
|
|
|
# CPPFLAGS tous les indicateurs du préprocesseur C.
|
|
|
|
|
# .PHONY Spécifie des cibles qui ne ressemblent pas au nom d'un fichier.
|
|
|
|
|
# Un exemple est la cible "make clean" ; où clean est une valeur de .PHONY
|
|
|
|
|
|
|
|
|
|
# Syntaxe de Base
|
|
|
|
|
# Règles : Une règle se compose d'une cible, des dépendances et des commandes.
|
|
|
|
|
# Elle est généralement structurée comme suit :
|
|
|
|
|
# cible: dépendances
|
|
|
|
|
# commande
|
|
|
|
|
#
|
|
|
|
|
# La cible (target) est le fichier à générer,
|
|
|
|
|
# les dépendances (prerequisites) sont les fichiers requis pour construire la cible
|
|
|
|
|
# et les commandes (recipe) sont les instructions exécutées pour créer la cible.
|
|
|
|
|
#
|
|
|
|
|
# A simple makefile consists of “rules” with the following shape:
|
|
|
|
|
# target ... : prerequisites ...
|
|
|
|
|
# recipe
|
|
|
|
|
# ...
|
|
|
|
|
# A target is usually the name of a file that is generated by a program;
|
|
|
|
|
# examples of targets are executable or object files.
|
|
|
|
|
# A target can also be the name of an action to carry out, such as ‘clean’
|
|
|
|
|
|
|
|
|
|
|
2024-04-27 14:59:32 +02:00
|
|
|
|
# accessoirement : https://blog.stephane-robert.info/docs/makefile/ & /docs/task/
|
2024-04-20 11:17:01 +02:00
|
|
|
|
|