1 # dhcpcd Makefile 2 3 PROG= dhcpcd 4 SRCS= arp.c bind.c common.c control.c dhcp.c dhcpcd.c duid.c eloop.c 5 SRCS+= if-options.c if-pref.c ipv4ll.c ipv6rs.c net.c signals.c 6 SRCS+= configure.c 7 8 CFLAGS?= -O2 9 CSTD?= c99 10 CFLAGS+= -std=${CSTD} 11 include config.mk 12 13 OBJS+= ${SRCS:.c=.o} ${COMPAT_SRCS:.c=.o} 14 15 SCRIPT= ${LIBEXECDIR}/dhcpcd-run-hooks 16 HOOKDIR= ${LIBEXECDIR}/dhcpcd-hooks 17 18 MAN5= dhcpcd.conf.5 19 MAN8= dhcpcd.8 dhcpcd-run-hooks.8 20 CLEANFILES= dhcpcd.conf.5 dhcpcd.8 dhcpcd-run-hooks.8 21 22 SCRIPTS= dhcpcd-run-hooks 23 SCRIPTSDIR= ${LIBEXECDIR} 24 CLEANFILES+= dhcpcd-run-hooks 25 CLEANFILES+= .depend 26 27 FILES= dhcpcd.conf 28 FILESDIR= ${SYSCONFDIR} 29 30 SUBDIRS= dhcpcd-hooks 31 32 SED_DBDIR= -e 's:@DBDIR@:${DBDIR}:g' 33 SED_HOOKDIR= -e 's:@HOOKDIR@:${HOOKDIR}:g' 34 SED_SERVICEEXISTS= -e 's:@SERVICEEXISTS@:${SERVICEEXISTS}:g' 35 SED_SERVICECMD= -e 's:@SERVICECMD@:${SERVICECMD}:g' 36 SED_SERVICESTATUS= -e 's:@SERVICESTATUS@:${SERVICESTATUS}:g' 37 SED_SCRIPT= -e 's:@SCRIPT@:${SCRIPT}:g' 38 SED_SYS= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' 39 40 _DEPEND_SH= test -e .depend && echo ".depend" || echo "" 41 _DEPEND!= ${_DEPEND_SH} 42 DEPEND= ${_DEPEND}$(shell ${_DEPEND_SH}) 43 44 _VERSION_SH= sed -n 's/\#define VERSION[[:space:]]*"\(.*\)".*/\1/p' defs.h 45 _VERSION!= ${_VERSION_SH} 46 VERSION= ${_VERSION}$(shell ${_VERSION_SH}) 47 48 GITREF?= HEAD 49 DISTPREFIX?= ${PROG}-${VERSION} 50 DISTFILE?= ${DISTPREFIX}.tar.bz2 51 52 CLEANFILES+= *.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 63 all: 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 71 depend: .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 96 install: _proginstall _scriptsinstall _maninstall _confinstall 97 for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done 98 99 clean: 100 rm -f ${OBJS} ${PROG} ${PROG}.core ${CLEANFILES} 101 102 distclean: clean 103 rm -f .depend config.h config.mk 104 105 dist: 106 git archive --prefix=${DISTPREFIX}/ ${GITREF} | bzip2 > ${DISTFILE} 107 108 import: 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 127 include Makefile.inc 128