gem-graph-server/Makefile

136 lines
5.2 KiB
Makefile
Raw Normal View History

#=----------------------------------------------------------------------------=#
# Makefile #
# #
# Copyright © 2021 The Gem-graph Project #
# #
# 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/>. #
#=----------------------------------------------------------------------------=#
2021-08-24 00:41:49 +02:00
CCOPTS=-pthread -Wall -g -Os -I/usr/include/libxml2
LDFLAGS= -lc -lpthread -lxml2
2021-06-08 18:05:32 +02:00
BINDIR=bin
2021-06-16 19:44:48 +02:00
INCDIR=include
2021-06-08 18:05:32 +02:00
SRCDIR=src
2021-06-08 20:15:47 +02:00
DEBDIR=debian
2021-06-21 14:26:09 +02:00
SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o \
$(BINDIR)/centers.o $(BINDIR)/cmds.o $(BINDIR)/model.o \
2021-06-23 09:13:46 +02:00
$(BINDIR)/main.o $(BINDIR)/arrows.o
2021-06-16 19:44:48 +02:00
CLIOBJ= $(BINDIR)/cli.o
SRCS=$(patsubst $(BINDIR)/%.o,$(SRCDIR)/%.c,$(SERVEROBJ)) \
$(patsubst $(BINDIR)/%.o,$(SRCDIR)/%.c,$(CLIOBJ))
DEPS=$(patsubst $(BINDIR)/%.o,$(BINDIR)/%.d,$(SERVEROBJ)) \
$(patsubst $(BINDIR)/%.o,$(BINDIR)/%.d,$(CLIOBJ))
2021-06-08 18:05:32 +02:00
.DEFAULT_GOAL:= all
.PHONY: all clean deb tests install run run-cli run-tests dependencies
# ---- Dependencies enumeration ---------------------------------------------- #
dependencies: $(DEPS)
$(BINDIR)/%.d: $(BINDIR)/%.o $(SRCDIR)/%.c
@$(CC) $(CFLAGS) -MM -MT $< $(word 2,$^) -MF $@
2021-06-14 20:22:11 +02:00
# ---- Tests enumeration ----------------------------------------------------- #
2021-06-15 23:26:27 +02:00
TEST_SCHEDULER=$(BINDIR)/tests/centers
2021-06-14 20:22:11 +02:00
TESTS=$(TEST_SCHEDULER)
2021-06-15 23:26:27 +02:00
$(BINDIR)/tests/centers: $(SRCDIR)/tests/centers.c
2021-06-14 20:22:11 +02:00
@echo "Compiling $<"
@$(CC) $(CCINCLUDES) $(CCOPTS) $(CCFLAGS) $(LDFLAGS) -o $@ $<
2021-06-08 18:05:32 +02:00
2021-04-10 22:03:38 +02:00
# ---- General recipes ------------------------------------------------------- #
$(BINDIR)/%.o: $(SRCDIR)/%.c
2021-06-08 20:15:47 +02:00
@echo "Compiling $<"
@$(CC) $(CCINCLUDES) $(CCOPTS) $(CCFLAGS) -c -o $@ $<
2021-04-10 23:02:40 +02:00
2021-04-10 22:03:38 +02:00
# ---- Main recipe ----------------------------------------------------------- #
$(BINDIR)/main.o: $(SRCDIR)/main.c
2021-06-16 19:44:48 +02:00
@echo "Compiling $<"
@$(CC) $(CCINCLUDES) $(CCOPTS) $(CCFLAGS) -c -o $@ $<
2021-07-09 18:34:54 +02:00
$(BINDIR)/gem-graph-server: $(SERVEROBJ)
2021-06-16 19:44:48 +02:00
@echo "Building program to $@"
@$(CC) -o $@ $(SERVEROBJ) $(LDFLAGS)
@echo "Success!"
2021-07-09 18:34:54 +02:00
$(BINDIR)/gem-graph-ctl: $(CLIOBJ)
2021-04-10 22:03:38 +02:00
@echo "Building program to $@"
2021-06-16 19:44:48 +02:00
@$(CC) -o $@ $(CLIOBJ) $(LDFLAGS)
2021-04-10 22:03:38 +02:00
@echo "Success!"
2021-04-09 18:01:29 +02:00
2021-04-10 22:03:38 +02:00
# ---- Misc recipes ---------------------------------------------------------- #
clean:
2021-06-14 20:22:11 +02:00
-rm -f $(SRCDIR)/*.o $(BINDIR)/* $(BINDIR)/tests/* *.deb
all: dependencies $(BINDIR)/gem-graph-server $(BINDIR)/gem-graph-ctl
2021-04-09 18:01:29 +02:00
2021-06-14 20:22:11 +02:00
tests: $(TESTS)
2021-06-08 20:15:47 +02:00
# ---- Build debian package -------------------------------------------------- #
$(BINDIR)/gem-graph-server.deb: all $(DEBDIR)/control \
$(DEBDIR)/conffiles \
$(DEBDIR)/etc/server.conf \
$(DEBDIR)/copyright
2021-06-08 20:15:47 +02:00
mkdir -p gem-graph-server/usr/bin
mkdir -p gem-graph-server/var/lib/gem-graph-server/models
mkdir -p gem-graph-server/var/lib/gem-graph-server/users
mkdir -p gem-graph-server/etc/gem-graph-server
2021-06-16 18:10:04 +02:00
mkdir -p gem-graph-server/usr/share/doc/gem-graph-server
2021-06-08 20:15:47 +02:00
mkdir -p gem-graph-server/DEBIAN
cp $(DEBDIR)/control gem-graph-server/DEBIAN/control
cp $(DEBDIR)/conffiles gem-graph-server/DEBIAN/conffiles
cp $(DEBDIR)/etc/* gem-graph-server/etc/gem-graph-server
2021-06-08 20:20:27 +02:00
cp $(BINDIR)/gem-graph-server gem-graph-server/usr/bin
2021-07-15 16:31:53 +02:00
cp $(BINDIR)/gem-graph-ctl gem-graph-server/usr/bin
cp $(DEBDIR)/copyright \
gem-graph-server/usr/share/doc/gem-graph-server/copyright
2021-06-08 20:15:47 +02:00
dpkg-deb --build gem-graph-server
rm -rf gem-graph-server
deb: $(BINDIR)/gem-graph-server.deb
2021-06-11 19:34:00 +02:00
# ---- Builder will call this to install the application before running ------ #
install:
echo "Installing is not supported"
2021-07-15 16:31:53 +02:00
# ---- Builder uses this target to run the application ----------------------- #
2021-06-14 20:22:11 +02:00
run: all
2021-08-24 18:25:44 +02:00
@bin/gem-graph-server -C debian/etc -M debian/var/models \
-U debian/var/users
2021-08-24 19:39:53 +02:00
run-gdb: all
@gdb bin/gem-graph-server \
-ex "set args -C debian/etc -M debian/var/models -U debian/var/users"
2021-08-05 13:22:30 +02:00
run-both: all
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
2021-08-05 13:22:30 +02:00
run-server: all
2021-08-24 18:25:44 +02:00
@bin/gem-graph-server -C debian/etc -M debian/var/models \
-U debian/var/users
2021-06-30 15:50:39 +02:00
run-cli: all
2021-08-24 18:25:44 +02:00
@bin/gem-graph-ctl
2021-06-14 20:22:11 +02:00
run-tests: tests
2021-08-24 18:25:44 +02:00
@bin/tests/scheduler
2021-06-11 19:34:00 +02:00
include $(DEPS)