sci/Makefile

96 lines
2.4 KiB
Makefile
Raw Normal View History

2024-08-01 21:35:35 +02:00
# sci - simple continuous integration
# See LICENSE file for copyright and license details.
# Note: If you're confused by the makefile, I do emplore you to read the info-page: $ info make
.POSIX:
2024-08-06 20:35:00 +02:00
2024-08-01 21:35:35 +02:00
NAME=sci
2024-08-02 19:11:12 +02:00
DESCRIPTION=$(NAME) is a simple contiuous integration system.
2024-08-06 20:35:00 +02:00
VERSION = 1.0.0
PREFIX ?= /usr/local
2024-08-06 20:35:00 +02:00
MANPREFIX = $(PREFIX)/share/man
2024-08-02 19:11:12 +02:00
CC = gcc
2024-08-01 21:35:35 +02:00
OUTDIR := out/
OBJDIR := out/obj
BINDIR := out/bin
2024-08-02 19:11:12 +02:00
CFLAGS += -DSCI_VERSION="\"$(VERSION)\""
CFLAGS += -DSCI_NAME="\"$(NAME)\""
CFLAGS += -DSCI_DESCRIPTION="\"$(DESCRIPTION)\""
CFLAGS += -D_POSIX_C_SOURCE=2
CFLAGS += -D_GNU_SOURCE
CFLAGS += -Wall -Werror -std=c11
2024-08-02 19:11:12 +02:00
CFLAGS += -Iinclude
2024-09-11 07:22:55 +02:00
CFLAGS += -lpthread -luuid -lrt
CFLAGS += -fsanitize=address
CFLAGS += -fsanitize=undefined
CFLAGS += -g
2024-08-01 21:35:35 +02:00
2024-08-06 20:35:00 +02:00
.PHONY: all clean dist install
2024-08-01 21:35:35 +02:00
all: out/bin/sci
out/obj/%.o: src/%.c | $(OBJDIR)
$(CC) -c $? $(CFLAGS) -o $@
2024-09-11 07:22:55 +02:00
OBJ += out/obj/api.o
2024-08-02 19:11:12 +02:00
OBJ += out/obj/cli.o
OBJ += out/obj/executor.o
2024-08-03 09:21:21 +02:00
OBJ += out/obj/log.o
OBJ += out/obj/main.o
2024-08-02 19:11:12 +02:00
OBJ += out/obj/notify.o
OBJ += out/obj/pipeline.o
OBJ += out/obj/strlist.o
OBJ += out/obj/threadlist.o
OBJ += out/obj/threadpool.o
OBJ += out/obj/util.o
2024-08-02 19:11:12 +02:00
out/bin/sci: $(OBJ) | $(BINDIR)
$(CC) -o $@ $^ $(CFLAGS)
2024-08-01 21:35:35 +02:00
clean:
2024-08-02 19:11:12 +02:00
rm -rf $(OUTDIR)
2024-08-06 20:35:00 +02:00
rm -rf $(NAME)-$(VERSION)
2024-08-01 21:35:35 +02:00
$(OUTDIR):
mkdir -p $@
$(OBJDIR): $(OUTDIR)
mkdir -p $@
$(BINDIR): $(OUTDIR)
mkdir -p $@
2024-08-06 20:35:00 +02:00
dist:
mkdir -p $(NAME)-$(VERSION)
cp -R \
TODO.md README.md\
Makefile src include scripts\
2024-08-06 20:35:00 +02:00
$(NAME)-$(VERSION)
tar -cf - $(NAME)-$(VERSION) | gzip > $(NAME)-$(VERSION).tar.gz
rm -rf $(NAME)-$(VERSION)
# NOTE: DESTDIR is meant for making packaging easier.
# If you want to install in a different directory than the default, please
# use: # make install PREFIX=/custom/path
install: out/bin/sci
mkdir -p $(DESTDIR)$(PREFIX)/bin
mkdir -p $(DESTDIR)$(PREFIX)/etc/sci
2024-08-06 20:35:00 +02:00
# install binaries
cp -f out/bin/sci $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/sci
# install libraries
# install extras
cp -r scripts $(DESTDIR)$(PREFIX)/etc/sci/
2024-08-06 20:35:00 +02:00
# install services (only if system is using systemd though)
# install manpages
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < src/sci.1 > $(DESTDIR)$(MANPREFIX)/man1/sci.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sci.1
uninstall:
# uninstall binaries
rm -f $(DESTDIR)$(PREFIX)/bin/sci
# uninstall libraries
# uninstall services (only if system is using systemd though)
# uninstall manpages
rm -f $(DESTDIR)$(MANPREFIX)/man1/sci.1