-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
79 lines (70 loc) · 2.7 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
77
78
PROGRAM = dsbmd
CFGFILE = ${PROGRAM}.conf
RCSCRIPT = rc.d/${PROGRAM}
LOGFILE = /var/log/${PROGRAM}.log
PIDFILE = /var/run/${PROGRAM}.pid
SOCKETPATH = /var/run/dsbmd.socket
PREFIX ?= /usr/local
BINDIR = ${PREFIX}/libexec
RCDIR = ${PREFIX}/etc/rc.d
CFGDIR = ${PREFIX}/etc
DOCSDIR ?= ${PREFIX}/share/doc/${PROGRAM}
DOCS = readme.mdoc
SOURCES = ${PROGRAM}.c config.c dsbcfg/dsbcfg.c fs.c common.c
FREEBSD_VERSION = `freebsd-version -u | (LC_ALL=C awk -F '-' \
'{ print int($$1 * 10) }')`
PROGRAM_FLAGS = -Wall ${CFLAGS} ${CPPFLAGS} -DPROGRAM=\"${PROGRAM}\"
PROGRAM_FLAGS += -DPATH_DSBMD_LOG=\"${LOGFILE}\"
PROGRAM_FLAGS += -DPATH_PID_FILE=\"${PIDFILE}\"
PROGRAM_FLAGS += -DPATH_DSBMD_SOCKET=\"${SOCKETPATH}\"
PROGRAM_FLAGS += -DPATH_CONFIG=\"${CFGDIR}/${CFGFILE}\"
PROGRAM_FLAGS += -DFREEBSD_VERSION=${FREEBSD_VERSION}
PROGRAM_LIBS = -lgeom -lcam -lutil -lkiconv -lpthread -lusb
BSD_INSTALL_DATA ?= install -m 0644
BSD_INSTALL_SCRIPT ?= install -m 555
BSD_INSTALL_PROGRAM ?= install -s -m 555
.if defined(DEBUG)
CFLAGS+= -O0 -g
.endif
all: ${PROGRAM} ${RCSCRIPT} ${CFGFILE}
${PROGRAM}: ${SOURCES}
${CC} -o ${PROGRAM} ${PROGRAM_FLAGS} ${SOURCES} ${PROGRAM_LIBS}
${RCSCRIPT}: ${RCSCRIPT}.tmpl
sed -e 's|@PATH_PROGRAM@|${BINDIR}/${PROGRAM}|g' \
-e 's|@PATH_PIDFILE@|${PIDFILE}|g' \
< ${.ALLSRC} > ${RCSCRIPT}
${CFGFILE}: ${CFGFILE}.tmpl
# Remove "large" mount option from config file on FreeBSD >= 12
# Replace "fuse" by "fusefs" on FreeBSD >= 12.1
version=${FREEBSD_VERSION}; \
cp ${CFGFILE}.tmpl ${CFGFILE}; \
if [ $${version} -ge 120 ]; then \
sed -i '' 's|large,||g' ${CFGFILE}; \
fi; \
if [ $${version} -ge 121 ]; then \
sed -i '' '/^preload_kmods/s|fuse|fusefs|g' ${CFGFILE}; \
fi
install: ${PROGRAM} ${RCSCRIPT} ${CFGFILE}
${BSD_INSTALL_PROGRAM} ${PROGRAM} ${DESTDIR}${BINDIR}
${BSD_INSTALL_SCRIPT} ${RCSCRIPT} ${DESTDIR}${RCDIR}
${BSD_INSTALL_DATA} ${CFGFILE} ${DESTDIR}${CFGDIR}/${CFGFILE}.sample
if [ ! -f ${DESTDIR}${CFGDIR}/${CFGFILE} ]; then \
${BSD_INSTALL_DATA} ${CFGFILE} ${DESTDIR}${CFGDIR}; \
fi
if [ ! -d ${DESTDIR}${DOCSDIR} ]; then \
mkdir ${DESTDIR}${DOCSDIR}; \
fi
${BSD_INSTALL_DATA} ${DOCS} ${DESTDIR}${DOCSDIR}
readme: readme.mdoc
mandoc -mdoc readme.mdoc | perl -e ' \
binmode STDIN, qq(:encoding(UTF-8)); \
binmode STDOUT, qq(:encoding(UTF-8)); \
foreach (<STDIN>) { \
$$_ =~ s/(.)\x08\1/$$1/g; $$_ =~ s/_\x08(.)/$$1/g; print $$_ \
}' | sed '1,1d' > README
readmemd: readme.mdoc
mandoc -mdoc -Tmarkdown readme.mdoc | sed '1,1d' > README.md
clean:
-rm -f ${PROGRAM}
-rm -f ${RCSCRIPT}
-rm -f ${CFGFILE}