summaryrefslogtreecommitdiff
path: root/Makefile
blob: 5130c30f45856dcf72e2ead2bc80b70fc5eeff87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright (C) 2023 Aiden Gall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

.POSIX:

.PHONY: all clean dist install

VERSION = 0.1
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man

CC = gcc
CFLAGS = -std=c89 -pedantic -Wall -Wextra -D_POSIX_C_SOURCE=200809L

SRC = simplebl.c
OBJ = ${SRC:.c=.o}

all: simplebl

simplebl: ${OBJ}
	${CC} -o $@ $^ ${LDFLAGS}

%.o: %.c
	${CC} -c ${CFLAGS} $< -o $@

clean:
	rm -f simplebl ${OBJ}

dist: clean
	mkdir -p simplebl-${VERSION}
	cp -R LICENSE Makefile ${SRC} simplebl-${VERSION}
	tar -cf - simplebl-${VERSION} | gzip > simplebl-${VERSION}.tar.gz
	rm -rf simplebl-${VERSION}

install: all
	mkdir -p ${DESTDIR}${PREFIX}/bin
	mkdir -p $(DESTDIR)$(MANPREFIX)/man8
	sed "s/VERSION/$(VERSION)/g" < simplebl.8 > $(DESTDIR)$(MANPREFIX)/man8/simplebl.8
	chmod 644 $(DESTDIR)$(MANPREFIX)/man8/simplebl.8
	install -Dm755 simplebl ${DESTDIR}${PREFIX}/bin/simplebl
	chmod u+s ${DESTDIR}${PREFIX}/bin/simplebl