blob: d970b2d647f7aed4e36918d7fc33df3dfd865c9e (
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
60
61
62
63
64
65
66
67
68
|
# rules to build a program
# based on FreeBSD's bsd.prog.mk
# Copyright 2008 Roy Marples <roy@marples.name>
include ${MK}/cc.mk
OBJS+= ${SRCS:.c=.o}
# If building for /, ensure we use the libc in / if different from
# the default one in /usr/lib
LINK_RPATH?= -Wl,-rpath
_RPATH_SH= if test "${PREFIX}" = "" -o "${PREIX}" = "/"; then \
echo "${LINK_RPATH}=${PREFIX}/${LIBNAME}"; \
else \
echo ""; \
fi
_RPATH!= ${_RPATH_SH}
LDFLAGS+= ${_RPATH}$(shell ${_RPATH_SH})
# If building for /, ensure we use the linker in /libexec if different from
# the default one in /usr/libexec
_DYNLINK_SH= if test "${PREFIX}" = "" -o "${PREFIX}" = "/" && test -e /libexec/ld.elf_so; then \
echo "-Wl,-dynamic-linker=/libexec/ld.elf_so"; \
else \
echo ""; \
fi
_DYNLINK!= ${_DYNLINK_SH}
LDFLAGS+= ${_DYNLINK}$(shell ${_DYNLINK_SH})
all: ${PROG} ${SCRIPTS} _man
.c.o:
${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
${PROG}: ${OBJS}
${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
# We could save about 600 bytes by building it like this
# instead of the more traditional method above
small: ${SRCS}
echo "" > _${PROG}.c
for src in ${SRCS}; do echo "#include \"$$src\"" >> _${PROG}.c; done
${CC} ${CFLAGS} ${CPPFLAGS} -c _${PROG}.c -o _${PROG}.o
${CC} ${LDFLAGS} -o ${PROG} _${PROG}.o ${LDADD}
_proginstall: ${PROG}
${INSTALL} -d ${DESTDIR}${BINDIR}
${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${BINDIR}
${INSTALL} -d ${DESTDIR}${DBDIR}
include ${MK}/depend.mk
include ${MK}/files.mk
include ${MK}/scripts.mk
include ${MK}/man.mk
include ${MK}/dist.mk
install: _proginstall _scriptsinstall _filesinstall _maninstall
for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
clean:
rm -f ${OBJS} ${PROG} _${PROG}.c _${PROG}.o ${PROG}.core ${CLEANFILES}
LINTFLAGS?= -hx
LINTFLAGS+= -X 159,247,352
lint: ${SRCS:.c=.c}
${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} $^ ${.ALLSRC}
|