2023-01-23 18:44:16 +01:00
|
|
|
##
|
|
|
|
## Gem-graph OpenGL experiments
|
|
|
|
##
|
|
|
|
## Desc: Makefile
|
|
|
|
##
|
|
|
|
## Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
|
|
|
|
## Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
|
|
|
|
##
|
|
|
|
## This file is part of Gem-graph.
|
|
|
|
##
|
|
|
|
## This program is free software: you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU Affero General Public License as published by
|
|
|
|
## the Free Software Foundation, either version 3 of the License, or
|
|
|
|
## (at your option) any later version.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU Affero General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU Affero General Public License
|
|
|
|
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
2022-06-24 20:02:09 +02:00
|
|
|
|
2023-01-23 18:44:16 +01:00
|
|
|
.PHONY: all clean install run build_system
|
|
|
|
.DELETE_ON_ERROR: $(BINDIR)/gem-graph-client
|
|
|
|
.DEFAULT_GOAL := all
|
2022-06-24 20:02:09 +02:00
|
|
|
|
2023-01-23 18:44:16 +01:00
|
|
|
#
|
|
|
|
# Color codes
|
|
|
|
#
|
|
|
|
CL='\033[0;32m'
|
|
|
|
CL2='\033[1;36m'
|
|
|
|
CL3='\033[0m'
|
|
|
|
NC='\033[1;37m'
|
2022-06-24 20:02:09 +02:00
|
|
|
|
2023-01-23 18:44:16 +01:00
|
|
|
#
|
|
|
|
# Variables & constants
|
|
|
|
#
|
|
|
|
NTHREADS= $(shell nproc)
|
2022-06-24 20:02:09 +02:00
|
|
|
|
2023-01-23 18:44:16 +01:00
|
|
|
CC=gcc
|
|
|
|
WARNINGS= -Wall
|
2024-05-26 07:37:38 +02:00
|
|
|
|
|
|
|
# applications should be compiled with the -Wl,--export-dynamic argument inside their compiler flags, < ?
|
|
|
|
# and linked against gmodule-export-2.0. < ? TODO
|
|
|
|
|
2023-12-20 18:01:27 +01:00
|
|
|
DEBUG= -ggdb -fno-omit-frame-pointer -fdiagnostics-color=always -fsanitize=bounds -fstack-check
|
|
|
|
#-fsanitize=address \
|
|
|
|
#-fsanitize=pointer-compare -fsanitize=pointer-subtract \
|
|
|
|
#-fsanitize=leak -fsanitize=undefined -fsanitize=null -fsanitize=bounds
|
2024-05-26 07:37:38 +02:00
|
|
|
|
2023-02-23 21:54:22 +01:00
|
|
|
OPTIMIZE= -O3
|
2023-01-23 18:44:16 +01: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
|
2023-01-25 12:24:52 +01:00
|
|
|
#vpath %.c $(SRCDIR)
|
2023-01-23 18:44:16 +01:00
|
|
|
|
2023-01-25 12:24:52 +01:00
|
|
|
SOURCES= $(shell find $(SRCDIR) -type f -name "*.c")
|
2023-01-23 18:44:16 +01:00
|
|
|
BUILDBINS=$(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
|
|
|
BUILDDEPS=$(patsubst %.c,$(BUILDDIR)/%.d,$(SOURCES))
|
|
|
|
|
|
|
|
-include /etc/os-release
|
|
|
|
|
|
|
|
#
|
|
|
|
# Directories
|
|
|
|
#
|
|
|
|
$(BUILDDIR):
|
|
|
|
@mkdir -p $@
|
|
|
|
@echo -e ${CL2}[$@] ${CL}folder generated.${CL3}
|
|
|
|
|
|
|
|
$(BINDIR):
|
|
|
|
@mkdir -p $@
|
|
|
|
@echo -e ${CL2}[$@] ${CL}folder generated.${CL3}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Dependencies
|
|
|
|
#
|
|
|
|
-include $(BUILDDEPS)
|
|
|
|
|
|
|
|
$(BUILDDIR)/%.d: %.c | $(BUILDDIR)
|
2023-01-25 12:24:52 +01:00
|
|
|
@mkdir -p $(shell dirname $@)
|
2023-01-23 18:44:16 +01:00
|
|
|
@$(CC) -MM -MT $(@:%.d=%.o) -MF $@ $<
|
|
|
|
@echo -e ${CL2}[$@] ${CL}dependencies generated.${CL3}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Compilation
|
|
|
|
#
|
|
|
|
$(BINDIR)/gem-graph-client: $(BUILDBINS) | $(BINDIR)
|
|
|
|
@$(CC) -o $@ $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ $(INCLUDE) $(LIBS)
|
|
|
|
@echo -e ${CL2}[$@] ${CL}built.${CL3}
|
|
|
|
|
|
|
|
|
|
|
|
$(BUILDDIR)/%.o: %.c | $(BUILDDIR)
|
2023-01-25 12:24:52 +01:00
|
|
|
@mkdir -p $(shell dirname $@)
|
2023-01-23 18:44:16 +01:00
|
|
|
@$(CC) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $(INCLUDE) -c $< -o $@
|
|
|
|
@echo -e ${CL2}[$@] ${CL}compiled.${CL3}
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Virtual recipes
|
|
|
|
#
|
|
|
|
clean:
|
|
|
|
@rm -rf $(BINDIR)
|
|
|
|
@rm -rf $(BUILDDIR)
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
|
|
|
|
install:
|
|
|
|
echo "Installing is not supported"
|
|
|
|
|
|
|
|
build_system:
|
|
|
|
@echo -e ${CL2}[$@] ${CL}building...${CL3}
|
|
|
|
@make $(BINDIR)/gem-graph-client -j $(NTHREADS)
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
|
|
|
|
run: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
|
|
|
@$(BINDIR)/gem-graph-client
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
|
2023-02-23 21:54:22 +01:00
|
|
|
debug: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
|
|
|
@gdb $(BINDIR)/gem-graph-client
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
|
2023-02-25 21:23:37 +01:00
|
|
|
valgrind: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
|
|
|
@valgrind $(BINDIR)/gem-graph-client
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
|
2023-01-23 18:44:16 +01:00
|
|
|
all: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
2022-06-24 20:02:09 +02:00
|
|
|
|
2023-02-23 21:54:22 +01:00
|
|
|
|