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