forked from mrclksr/DSBDriverd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (82 loc) · 3.15 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
PROGRAM = dsbdriverd
DBFILE = drivers.db
RCSCRIPT = rc.d/${PROGRAM}
MANFILE = man/${PROGRAM}.8
LOGFILE = /var/log/${PROGRAM}.log
PIDFILE = /var/run/${PROGRAM}.pid
PREFIX ?= /usr/local
CFGDIR = ${PREFIX}/etc/${PROGRAM}
BINDIR = ${PREFIX}/libexec
MANDIR = ${PREFIX}/man/man8
RCDIR = ${PREFIX}/etc/rc.d
DBDIR = ${PREFIX}/share/${PROGRAM}
USBDB = ${PREFIX}/share/usbids/usb.ids
PCIDB0 = ${PREFIX}/share/pciids/pci.ids
PCIDB1 = /usr/share/misc/pci_vendors
CFGFILE = config.lua
CFGMODULES = netif.lua
SOURCES = ${PROGRAM}.c config.c device.c hints.c log.c
INSTALL_TARGETS= ${PROGRAM} ${RCSCRIPT} ${CFGFILE} ${MANFILE}
PROGRAM_FLAGS = -Wall ${CFLAGS} ${CPPFLAGS} -DPROGRAM=\"${PROGRAM}\"
PROGRAM_FLAGS += -DPATH_DRIVERS_DB=\"${DBDIR}/${DBFILE}\"
PROGRAM_FLAGS += -DPATH_LOG=\"${LOGFILE}\"
PROGRAM_FLAGS += -DPATH_PID_FILE=\"${PIDFILE}\"
PROGRAM_FLAGS += -DPATH_CFG_FILE=\"${CFGDIR}/${CFGFILE}\"
PROGRAM_FLAGS += -DPATH_PCIID_DB0=\"${PCIDB0}\"
PROGRAM_FLAGS += -DPATH_PCIID_DB1=\"${PCIDB1}\"
PROGRAM_FLAGS += -DPATH_USBID_DB=\"${USBDB}\"
PROGRAM_FLAGS += -L${PREFIX}/lib -I${PREFIX}/include/lua52
PROGRAM_LIBS = -lusb -lutil -llua-5.2
LUA_PROG ?= lua52
BSD_INSTALL_DATA ?= install -m 0644
BSD_INSTALL_SCRIPT ?= install -m 555
BSD_INSTALL_PROGRAM ?= install -s -m 555
all: ${INSTALL_TARGETS}
${PROGRAM}: ${SOURCES}
${CC} -o ${PROGRAM} ${PROGRAM_FLAGS} ${.ALLSRC} ${PROGRAM_LIBS}
${RCSCRIPT}: ${RCSCRIPT}.tmpl
sed -e 's|@PATH_PROGRAM@|${BINDIR}/${PROGRAM}|g' \
-e 's|@PATH_PIDFILE@|${PIDFILE}|g' \
< ${.ALLSRC} > ${RCSCRIPT}
${CFGFILE}: ${CFGFILE}.in
sed -e 's|@MODULE_PATH@|${CFGDIR}|g' < ${.ALLSRC} > ${CFGFILE}
${MANFILE}: ${MANFILE}.tmpl
sed -e 's|@PATH_DB@|${DBDIR}/${DBFILE}|g' \
-e 's|@PATH_LOG@|${LOGFILE}|g' \
-e 's|@PATH_CFG@|${CFGDIR}/${CFGFILE}|g' \
< ${.ALLSRC} > ${MANFILE}
install: ${INSTALL_TARGETS}
${BSD_INSTALL_PROGRAM} ${PROGRAM} ${DESTDIR}${BINDIR}
${BSD_INSTALL_SCRIPT} ${RCSCRIPT} ${DESTDIR}${RCDIR}
if [ ! -d ${DESTDIR}${DBDIR} ]; then \
mkdir -p ${DESTDIR}${DBDIR}; \
fi
if [ ! -d ${DESTDIR}${CFGDIR} ]; then \
mkdir -p ${DESTDIR}${CFGDIR}; \
fi
${BSD_INSTALL_DATA} ${DBFILE} ${DESTDIR}${DBDIR}
${BSD_INSTALL_DATA} ${MANFILE} ${DESTDIR}${MANDIR}
if [ ! -f ${DESTDIR}${CFGDIR}/${CFGFILE} ]; then \
${BSD_INSTALL_DATA} ${CFGFILE} ${DESTDIR}${CFGDIR}; \
fi
${BSD_INSTALL_DATA} ${CFGFILE} ${DESTDIR}${CFGDIR}/${CFGFILE}.sample
${BSD_INSTALL_DATA} ${CFGMODULES} ${DESTDIR}${CFGDIR}
readme: readme.mdoc
mandoc -mdoc readme.mdoc | perl -e '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; $$,$$d' > README.md
tests/${PROGRAM}-test: ${SOURCES} tests/test.h
${CC} -o tests/${PROGRAM}-test ${PROGRAM_FLAGS} \
-Wno-unused-function -Itests -DTEST=1 \
${SOURCES} ${PROGRAM_LIBS} -latf-c
test: tests/${PROGRAM}-test
kyua test -k tests/Kyuafile
${LUA_PROG} tests/netif_tests.lua
clean:
-rm -f ${PROGRAM}
-rm -f ${RCSCRIPT}
-rm -f ${CFGFILE}
-rm -f ${MANFILE}
-rm -f tests/${PROGRAM}-test