-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (62 loc) · 1.98 KB
/
Makefile
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
include config.mk
HEADERS = config.h $(wildcard src/*.h)
SRC_COMMON = $(wildcard src/*.c)
OBJ_COMMON = ${SRC_COMMON:.c=.o}
BIN_DAEMON = tsupd
SRC_DAEMON = tsupd.c
OBJ_DAEMON = tsupd.o
BIN_CLIENT = tsupq
SRC_CLIENT = tsupq.c
OBJ_CLIENT = tsupq.o
BINS = $(BIN_DAEMON) $(BIN_CLIENT)
.PHONY : all options dist clean install uninstall install-man
all: options $(BINS)
options:
@echo tsup build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "CPPFLAGS = ${CPPFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
config.h: config.def.h
@echo Creating $@ from $<
@cp $< $@
%.o: %.c $(HEADERS)
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
$(BINS): % : %.o $(OBJ_COMMON)
$(CC) -o $@ $^ $(LDFLAGS)
install-man:
@echo Installing man pages to ${DESTDIR}$(MANDIR)/
mkdir -p ${DESTDIR}$(MANDIR)/man1
sed "s/VERSION/$(VERSION)/g" man/$(BIN_DAEMON).1 \
> ${DESTDIR}$(MANDIR)/man1/$(BIN_DAEMON).1
sed "s/VERSION/$(VERSION)/g" man/$(BIN_CLIENT).1 \
> ${DESTDIR}$(MANDIR)/man1/$(BIN_CLIENT).1
chmod 0644 ${DESTDIR}$(MANDIR)/man1/$(BIN_DAEMON).1
chmod 0644 ${DESTDIR}$(MANDIR)/man1/$(BIN_CLIENT).1
install: all install-man
@echo Installing executables to ${DESTDIR}$(PREFIX)/bin
mkdir -p ${DESTDIR}$(PREFIX)/bin
cp $(BINS) ${DESTDIR}$(PREFIX)/bin
chmod 0755 ${DESTDIR}$(PREFIX)/bin/$(BIN_DAEMON)
chmod 0755 ${DESTDIR}$(PREFIX)/bin/$(BIN_CLIENT)
uninstall:
rm -f ${DESTDIR}$(PREFIX)/bin/$(BIN_DAEMON) \
${DESTDIR}$(PREFIX)/bin/$(BIN_CLIENT)
rm -f ${DESTDIR}$(MANDIR)/man1/$(BIN_DAEMON).1 \
${DESTDIR}$(MANDIR)/man1/$(BIN_CLIENT).1
dist:
@echo Creating dist release $(DISTDIR)
mkdir -p $(DISTDIR)
cp config.mk Makefile config.def.h LICENSE README.rst $(DISTDIR)/
cp $(SRC_DAEMON) $(SRC_CLIENT) $(DISTDIR)/
mkdir -p $(DISTDIR)/src
cp src/*.c src/*.h $(DISTDIR)/src/
mkdir -p $(DISTDIR)/man
cp -r man/. $(DISTDIR)/man/
tar -c -f $(DISTDIR).tar --remove-files $(DISTDIR)/
gzip $(DISTDIR).tar
clean:
@echo Cleaning
rm -f $(BINS)
rm -f $(OBJ_DAEMON) $(OBJ_CLIENT) $(OBJ_COMMON)
rm -f config.h
rm -f $(DISTDIR).tar.gz