summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 428c6f71e576ad99ce5831dfef57ec08764ba8dc (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
54
55
56
57
58
59

.PHONY: clean clobber uninstall

CFLAGS := -Wall -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE

COMMON := qarsh_packet.c sockutil.c

TARGETS := qarshd qarsh qacp btimed btimec

all: $(TARGETS)

qarshd: qarshd.c $(COMMON) 
qarsh: qarsh.c $(COMMON) btime.c hbeat.c
qacp: qacp.c $(COMMON)
btimed: btimed.c
btimec: btimec.c btime.c

install: all
	install -D qacp $(INSTROOT)/usr/bin/qacp
	install -D qarsh $(INSTROOT)/usr/bin/qarsh
	install -D qarshd $(INSTROOT)/usr/sbin/qarshd
	install -D qarshd.socket $(INSTROOT)/usr/lib/systemd/system/qarshd.socket
	install -D qarshd@.service $(INSTROOT)/usr/lib/systemd/system/qarshd@.service
	install -D btimed $(INSTROOT)/usr/sbin/btimed
	install -D btimed.socket $(INSTROOT)/usr/lib/systemd/system/btimed.socket
	install -D btimed.service $(INSTROOT)/usr/lib/systemd/system/btimed.service
	install -D btimec $(INSTROOT)/usr/bin/btimec
	install -D qarsh.1 $(INSTROOT)/usr/share/man/man1/qarsh.1
	install -D qacp.1 $(INSTROOT)/usr/share/man/man1/qacp.1
	install -D btimec.1 $(INSTROOT)/usr/share/man/man1/btimec.1
	install -D qarshd.8 $(INSTROOT)/usr/share/man/man8/qarshd.8
	install -D btimed.8 $(INSTROOT)/usr/share/man/man8/btimed.8

clean:
	$(RM) $(TARGETS)

VERSION := $(shell awk '/^Version:/ { print $$2 }' qarsh.spec)

ifdef DIST
  RPMDEFS := -D "dist $(DIST)"
endif

QARSH_TARNAME=qarsh-$(VERSION)

$(QARSH_TARNAME).tar.bz2: qarsh.spec
	git archive --format=tar --prefix=$(QARSH_TARNAME)/ HEAD^{tree} > $(QARSH_TARNAME).tar
	bzip2 -f -9 $(QARSH_TARNAME).tar

tarball: $(QARSH_TARNAME).tar.bz2

rpm: $(QARSH_TARNAME).tar.bz2 qarsh.spec
	rpmbuild -ta $< $(RPMDEFS)

srpm: $(QARSH_TARNAME).tar.bz2 qarsh.spec
	rpmbuild -ts $< $(RPMDEFS)

# Redefine the default compile rule to include target specific parts
%: %.c
	$(LINK.c) $(CFLAGS_$@) $^ $(LIBS_$@) $(LOADLIBES) -o $@