• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# dhcpcd Makefile
2
3PROG=		dhcpcd
4SRCS=		arp.c bind.c common.c control.c dhcp.c dhcpcd.c duid.c eloop.c
5SRCS+=		if-options.c if-pref.c ipv4ll.c ipv6rs.c net.c signals.c
6SRCS+=		configure.c
7
8CFLAGS?=	-O2
9CSTD?=		c99
10CFLAGS+=	-std=${CSTD}
11include config.mk
12
13OBJS+=		${SRCS:.c=.o} ${COMPAT_SRCS:.c=.o}
14
15SCRIPT=		${LIBEXECDIR}/dhcpcd-run-hooks
16HOOKDIR=	${LIBEXECDIR}/dhcpcd-hooks
17
18MAN5=		dhcpcd.conf.5
19MAN8=		dhcpcd.8 dhcpcd-run-hooks.8
20CLEANFILES=	dhcpcd.conf.5 dhcpcd.8 dhcpcd-run-hooks.8
21
22SCRIPTS=	dhcpcd-run-hooks
23SCRIPTSDIR=	${LIBEXECDIR}
24CLEANFILES+=	dhcpcd-run-hooks
25CLEANFILES+=	.depend
26
27FILES=		dhcpcd.conf
28FILESDIR=	${SYSCONFDIR}
29
30SUBDIRS=	dhcpcd-hooks
31
32SED_DBDIR=		-e 's:@DBDIR@:${DBDIR}:g'
33SED_HOOKDIR=		-e 's:@HOOKDIR@:${HOOKDIR}:g'
34SED_SERVICEEXISTS=	-e 's:@SERVICEEXISTS@:${SERVICEEXISTS}:g'
35SED_SERVICECMD=		-e 's:@SERVICECMD@:${SERVICECMD}:g'
36SED_SERVICESTATUS=	-e 's:@SERVICESTATUS@:${SERVICESTATUS}:g'
37SED_SCRIPT=		-e 's:@SCRIPT@:${SCRIPT}:g'
38SED_SYS=		-e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
39
40_DEPEND_SH=	test -e .depend && echo ".depend" || echo ""
41_DEPEND!=	${_DEPEND_SH}
42DEPEND=		${_DEPEND}$(shell ${_DEPEND_SH})
43
44_VERSION_SH=	sed -n 's/\#define VERSION[[:space:]]*"\(.*\)".*/\1/p' defs.h
45_VERSION!=	${_VERSION_SH}
46VERSION=	${_VERSION}$(shell ${_VERSION_SH})
47
48GITREF?=	HEAD
49DISTPREFIX?=	${PROG}-${VERSION}
50DISTFILE?=	${DISTPREFIX}.tar.bz2
51
52CLEANFILES+=	*.tar.bz2
53
54.PHONY:		import import-bsd
55
56.SUFFIXES:	.in
57
58.in:
59	${SED} ${SED_DBDIR} ${SED_HOOKDIR} ${SED_SCRIPT} ${SED_SYS} \
60		${SED_SERVICEEXISTS} ${SED_SERVICECMD} ${SED_SERVICESTATUS} \
61		$< > $@
62
63all: config.h ${PROG} ${SCRIPTS} ${MAN5} ${MAN8}
64
65.c.o:
66	${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
67
68.depend: ${SRCS} ${COMPAT_SRCS}
69	${CC} ${CPPFLAGS} -MM ${SRCS} ${COMPAT_SRCS} > .depend
70
71depend: .depend
72
73${PROG}: ${DEPEND} ${OBJS}
74	${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
75
76_proginstall: ${PROG}
77	${INSTALL} -d ${DESTDIR}${SBINDIR}
78	${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${SBINDIR}
79	${INSTALL} -d ${DESTDIR}${DBDIR}
80
81_scriptsinstall: ${SCRIPTS}
82	${INSTALL} -d ${DESTDIR}${SCRIPTSDIR}
83	${INSTALL} -m ${BINMODE} ${SCRIPTS} ${DESTDIR}${SCRIPTSDIR}
84
85_maninstall: ${MAN5} ${MAN8}
86	${INSTALL} -d ${DESTDIR}${MANDIR}/man5
87	${INSTALL} -m ${MANMODE} ${MAN5} ${DESTDIR}${MANDIR}/man5
88	${INSTALL} -d ${DESTDIR}${MANDIR}/man8
89	${INSTALL} -m ${MANMODE} ${MAN8} ${DESTDIR}${MANDIR}/man8
90
91_confinstall:
92	${INSTALL} -d ${DESTDIR}${SYSCONFDIR}
93	test -e ${DESTDIR}${SYSCONFDIR}/dhcpcd.conf || \
94		${INSTALL} -m ${CONFMODE} dhcpcd.conf ${DESTDIR}${SYSCONFDIR}
95
96install: _proginstall _scriptsinstall _maninstall _confinstall
97	for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
98
99clean:
100	rm -f ${OBJS} ${PROG} ${PROG}.core ${CLEANFILES}
101
102distclean: clean
103	rm -f .depend config.h config.mk
104
105dist:
106	git archive --prefix=${DISTPREFIX}/ ${GITREF} | bzip2 > ${DISTFILE}
107
108import:
109	rm -rf /tmp/${DISTPREFIX}
110	${INSTALL} -d /tmp/${DISTPREFIX}
111	cp ${SRCS} dhcpcd.conf *.in /tmp/${DISTPREFIX}
112	cp $$(${CC} ${CPPFLAGS} -MM ${SRCS} | \
113		sed -e 's/^.*\.c //g' -e 's/.*\.c$$//g' -e 's/\\//g' | \
114		tr ' ' '\n' | \
115		sed -e '/^compat\//d' | \
116		sort -u) /tmp/${DISTPREFIX}
117	if test -n "${COMPAT_SRCS}"; then \
118		${INSTALL} -d /tmp/${DISTPREFIX}/compat; \
119		cp ${COMPAT_SRCS} /tmp/${DISTPREFIX}/compat; \
120		cp $$(${CC} ${CPPFLAGS} -MM ${COMPAT_SRCS} | \
121			sed -e 's/^.*c //g' -e 's/.*\.c$$//g' -e 's/\\//g' | \
122			tr ' ' '\n' | \
123			sort -u) /tmp/${DISTPREFIX}/compat; \
124	fi;
125	cd dhcpcd-hooks; ${MAKE} DISTPREFIX=${DISTPREFIX} $@
126
127include Makefile.inc
128