2021-04-09 19:59:52 +02:00
|
|
|
#=----------------------------------------------------------------------------=#
|
|
|
|
# Makefile #
|
|
|
|
# #
|
2021-10-13 09:44:00 +02:00
|
|
|
# Copyright © 2021 Libre en Communs (contact@a-lec.org) #
|
|
|
|
# Copyright © 2021 Adrien Bourmault (neox@a-lec.org) #
|
2021-04-09 19:59:52 +02:00
|
|
|
# #
|
|
|
|
# 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 <https://www.gnu.org/licenses/>. #
|
|
|
|
#=----------------------------------------------------------------------------=#
|
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
.PHONY: all clean install run build_system
|
|
|
|
.DELETE_ON_ERROR: $(BINDIR)/gem-graph-server
|
|
|
|
.DEFAULT_GOAL := all
|
|
|
|
|
|
|
|
#
|
|
|
|
# Color codes
|
|
|
|
#
|
|
|
|
CL='\033[0;32m'
|
|
|
|
CL2='\033[1;36m'
|
|
|
|
CL3='\033[0m'
|
|
|
|
NC='\033[1;37m'
|
|
|
|
|
|
|
|
#
|
|
|
|
# Variables & constants
|
|
|
|
#
|
|
|
|
NTHREADS= $(shell nproc)
|
|
|
|
|
|
|
|
CC=gcc
|
|
|
|
WARNINGS= -Wall
|
|
|
|
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
|
|
|
|
OPTIMIZE= -O3
|
|
|
|
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
|
2021-07-14 00:41:21 +02:00
|
|
|
|
2021-06-08 18:05:32 +02:00
|
|
|
BINDIR=bin
|
2024-03-10 21:19:12 +01:00
|
|
|
BUILDDIR=build
|
2021-06-08 18:05:32 +02:00
|
|
|
SRCDIR=src
|
2024-03-10 21:19:12 +01:00
|
|
|
#vpath %.c $(SRCDIR)
|
2021-07-14 00:41:21 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
SOURCES= $(shell find $(SRCDIR) -maxdepth 1 -type f -name "*.c")
|
|
|
|
BUILDBINS=$(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
|
|
|
BUILDDEPS=$(patsubst %.c,$(BUILDDIR)/%.d,$(SOURCES))
|
2021-04-09 19:59:52 +02:00
|
|
|
|
2021-07-14 00:41:21 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
-include /etc/os-release
|
2021-07-14 00:41:21 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
#
|
|
|
|
# Directories
|
|
|
|
#
|
|
|
|
$(BUILDDIR):
|
|
|
|
@mkdir -p $@
|
|
|
|
@echo -e ${CL2}[$@] ${CL}folder generated.${CL3}
|
2021-07-14 00:41:21 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
$(BINDIR):
|
|
|
|
@mkdir -p $@
|
|
|
|
@echo -e ${CL2}[$@] ${CL}folder generated.${CL3}
|
2021-07-14 00:41:21 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
#
|
|
|
|
# Dependencies
|
|
|
|
#
|
|
|
|
-include $(BUILDDEPS)
|
2021-07-14 00:41:21 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
$(BUILDDIR)/%.d: %.c | $(BUILDDIR)
|
|
|
|
@mkdir -p $(shell dirname $@)
|
|
|
|
@$(CC) -MM -MT $(@:%.d=%.o) -MF $@ $<
|
|
|
|
@echo -e ${CL2}[$@] ${CL}dependencies generated.${CL3}
|
2021-07-14 00:41:21 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
#
|
|
|
|
# Compilation
|
|
|
|
#
|
|
|
|
$(BINDIR)/gem-graph-server: $(BUILDBINS) | $(BINDIR)
|
|
|
|
@$(CC) -o $@ $(WARNINGS) $(DEBUG) $(OPTIMIZE) $^ $(INCLUDE) $(LIBS)
|
|
|
|
@echo -e ${CL2}[$@] ${CL}built.${CL3}
|
2021-06-14 20:22:11 +02:00
|
|
|
|
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
$(BUILDDIR)/%.o: %.c | $(BUILDDIR)
|
|
|
|
@mkdir -p $(shell dirname $@)
|
|
|
|
@$(CC) $(WARNINGS) $(DEBUG) $(OPTIMIZE) $(INCLUDE) -c $< -o $@
|
|
|
|
@echo -e ${CL2}[$@] ${CL}compiled.${CL3}
|
2021-06-08 18:05:32 +02:00
|
|
|
|
2021-04-10 22:03:38 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
#
|
|
|
|
# Virtual recipes
|
|
|
|
#
|
2021-04-10 22:03:38 +02:00
|
|
|
clean:
|
2024-03-10 21:19:12 +01:00
|
|
|
@rm -rf $(BINDIR)
|
|
|
|
@rm -rf $(BUILDDIR)
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
|
2021-06-11 19:34:00 +02:00
|
|
|
install:
|
|
|
|
echo "Installing is not supported"
|
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
build_system:
|
|
|
|
@echo -e ${CL2}[$@] ${CL}building...${CL3}
|
|
|
|
@make $(BINDIR)/gem-graph-server -j $(NTHREADS)
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
|
|
|
|
run: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
2021-08-24 19:39:53 +02:00
|
|
|
@gdb bin/gem-graph-server \
|
|
|
|
-ex "set args -C debian/etc -M debian/var/models -U debian/var/users"
|
2024-03-10 21:19:12 +01:00
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
2021-08-24 19:39:53 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
debug: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
|
|
|
@gdb $(BINDIR)/gem-graph-server
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
|
|
|
|
valgrind: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
2021-09-22 16:43:01 +02:00
|
|
|
@valgrind --leak-check=full --show-leak-kinds=all -s \
|
2021-09-21 23:28:19 +02:00
|
|
|
bin/gem-graph-server -C debian/etc -M debian/var/models \
|
|
|
|
-U debian/var/users
|
2024-03-10 21:19:12 +01:00
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
2021-09-17 16:14:04 +02:00
|
|
|
|
2024-03-10 21:19:12 +01:00
|
|
|
run-both: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
2021-08-24 18:25:44 +02:00
|
|
|
@bin/gem-graph-server -C debian/etc -M debian/var/models \
|
|
|
|
-U debian/var/users & sleep 1 && bin/gem-graph-ctl
|
2024-03-10 21:19:12 +01:00
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
run-server: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}executing...${CL3}
|
2021-08-24 18:25:44 +02:00
|
|
|
@bin/gem-graph-server -C debian/etc -M debian/var/models \
|
|
|
|
-U debian/var/users
|
2024-03-10 21:19:12 +01:00
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|
|
|
|
|
|
|
|
all: build_system
|
|
|
|
@echo -e ${CL2}[$@] ${CL}done.${CL3}
|