aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 982352c256cbf472f13dc2830b5c0acfec042243 (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
# Copyright (C) 2018 Tomasz Kramkowski <tk@the-tk.com>
# SPDX-License-Identifier: MIT
-include config.mk

PROG := bie
MANPAGE := $(PROG).1
VERSION != git describe --tags 2>/dev/null || echo "v0.1"

EPRINTF_PATH ?= ../eprintf
PKG_CONFIG ?= pkg-config
LN ?= ln -sf

CPPFLAGS += -DVERSION=\"$(VERSION)\"
CFLAGS += -std=c11 -MMD -MP

OBJ := bie.o eprintf.o
DEP := $(OBJ:.o=.d)

prefix ?= /usr/local
exec_prefix ?= $(prefix)
bindir = $(exec_prefix)/bin
datarootdir = $(prefix)/share
mandir = $(datarootdir)/man
man1dir = $(mandir)/man1

all: $(PROG) $(MANPAGE)
$(PROG): $(OBJ)
bie.o: eprintf.h
$(MANPAGE): $(MANPAGE).in
	m4 -DVERSION=$(VERSION) $^ >$@

install: $(PROG) $(MANPAGE)
	install -Dm755 -s $(PROG) -t $(DESTDIR)$(bindir)
	install -Dm644 $(MANPAGE) -t $(DESTDIR)$(man1dir)

clean:
	$(RM) $(OBJ) $(DEP) $(PROG) $(MANPAGE)

include $(EPRINTF_PATH)/module.mk

-include $(DEP)

.PHONY: all install clean