summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: ccf8985c4f94f3a6a184a3cb12084ff32b3aef88 (about) (plain) (blame)
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
# udp514-journal - forward syslog from network (udp/514) to journal

# commands
CC	:= gcc
MD	:= markdown
INSTALL	:= install
RM	:= rm
CP	:= cp

# flags
CFLAGS	+= -std=c11 -O2 -fPIC -Wall -Werror
CFLAGS  += $(shell pkg-config --cflags --libs libsystemd 2>/dev/null)
LDFLAGS	+= -Wl,-z,now -Wl,-z,relro -pie

# this is just a fallback in case you do not use git but downloaded
# a release tarball...
VERSION := 0.0.3

all: udp514-journal README.html

version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile
	printf "#ifndef VERSION\n#define VERSION \"%s\"\n#endif\n" $(shell git describe --long 2>/dev/null || echo ${VERSION}) > $@

udp514-journal: udp514-journal.c udp514-journal.h version.h
	$(CC) $(CFLAGS) $(LDFLAGS) -o udp514-journal udp514-journal.c

README.html: README.md
	$(MD) README.md > README.html

install: install-bin install-doc

install-bin: udp514-journal
	$(INSTALL) -D -m0755 udp514-journal $(DESTDIR)/usr/bin/udp514-journal
	$(INSTALL) -D -m0644 udp514-journal.service $(DESTDIR)/usr/lib/systemd/system/udp514-journal.service

install-doc: README.html
	$(INSTALL) -D -m0644 README.md $(DESTDIR)/usr/share/doc/udp514-journal/README.md
	$(INSTALL) -D -m0644 README.html $(DESTDIR)/usr/share/doc/udp514-journal/README.html

clean:
	$(RM) -f *.o *~ udp514-journal README.html version.h

distclean:
	$(RM) -f *.o *~ udp514-journal README.html version.h config.h

release:
	git archive --format=tar.xz --prefix=udp514-journal-$(VERSION)/ $(VERSION) > udp514-journal-$(VERSION).tar.xz
	gpg -ab udp514-journal-$(VERSION).tar.xz
	git notes --ref=refs/notes/signatures/tar add -C $$(git archive --format=tar --prefix=udp514-journal-$(VERSION)/ $(VERSION) | gpg --armor --detach-sign | git hash-object -w --stdin) $(VERSION)