Home | History | Annotate | Download | only in dhcpcd-6.8.2
      1 # dhcpcd Makefile
      2 
      3 PROG=		dhcpcd
      4 SRCS=		common.c control.c dhcpcd.c duid.c eloop.c
      5 SRCS+=		if.c if-options.c
      6 SRCS+=		dhcp-common.c
      7 PKG_CONFIG ?= pkg-config
      8 
      9 CFLAGS?=	-O2
     10 MKDIRS=
     11 
     12 TOP?=		.
     13 include ${TOP}/iconfig.mk
     14 
     15 CSTD?=		c99
     16 CFLAGS+=	-std=${CSTD}
     17 
     18 SRCS+=		${DHCPCD_SRCS}
     19 
     20 SRCS+=		auth.c
     21 CPPFLAGS+=	-I./crypt
     22 CRYPT_SRCS=	crypt/hmac_md5.c ${MD5_SRC} ${SHA256_SRC}
     23 
     24 OBJS+=		${SRCS:.c=.o} ${COMPAT_SRCS:.c=.o} ${CRYPT_SRCS:.c=.o}
     25 
     26 SCRIPT=		${LIBEXECDIR}/dhcpcd-run-hooks
     27 HOOKDIR=	${LIBEXECDIR}/dhcpcd-hooks
     28 
     29 MAN5=		dhcpcd.conf.5
     30 MAN8=		dhcpcd.8 dhcpcd-run-hooks.8
     31 CLEANFILES=	dhcpcd.conf.5 dhcpcd.8 dhcpcd-run-hooks.8
     32 
     33 SCRIPTS=	dhcpcd-run-hooks
     34 
     35 FILES=		dhcpcd.conf
     36 
     37 ifeq ($(DBUS_SUPPORT),yes)
     38 FILES+= 	dbus/dhcpcd-dbus.conf
     39 
     40 _DBUSCFLAGS_SH= $(PKG_CONFIG) --cflags dbus-1
     41 _DBUSCFLAGS!= ${_DBUSCFLAGS_SH}
     42 DBUSCFLAGS= ${_DBUSCFLAGS}$(shell ${_DBUSCFLAGS_SH})
     43 
     44 _DBUSLIBS_SH= $(PKG_CONFIG) --libs dbus-1
     45 _DBUSLIBS!= ${_DBUSLIBS_SH}
     46 DBUSLIBS= ${_DBUSLIBS}$(shell ${_DBUSLIBS_SH})
     47 DBUSDIR= ${SYSCONFDIR}/dbus-1/system.d
     48 
     49 CFLAGS+= ${DBUSCFLAGS}
     50 LDADD+= ${DBUSLIBS}
     51 endif
     52 
     53 # Linux needs librt
     54 _LIBRT_SH=	[ "$$(uname -s)" = "Linux" ] && echo "-lrt" || echo ""
     55 _LIBRT!= 	${_LIBRT_SH}
     56 LIBRT?=		${_LIBRT} $(shell ${_LIBRT_SH})
     57 LDADD+=		${LIBRT}
     58 
     59 SCRIPTSDIR=	${LIBEXECDIR}
     60 CLEANFILES+=	dhcpcd-run-hooks
     61 
     62 FILESDIR=	${SYSCONFDIR}
     63 
     64 SUBDIRS=	${MKDIRS}
     65 
     66 ifeq ($(HOOK_SUPPORT),yes)
     67 SUBDIRS+= 	dhcpcd-hooks
     68 endif
     69 
     70 SED_RUNDIR=		-e 's:@RUNDIR@:${RUNDIR}:g'
     71 SED_DBDIR=		-e 's:@DBDIR@:${DBDIR}:g'
     72 SED_LIBDIR=		-e 's:@LIBDIR@:${LIBDIR}:g'
     73 SED_HOOKDIR=		-e 's:@HOOKDIR@:${HOOKDIR}:g'
     74 SED_SERVICEEXISTS=	-e 's:@SERVICEEXISTS@:${SERVICEEXISTS}:g'
     75 SED_SERVICECMD=		-e 's:@SERVICECMD@:${SERVICECMD}:g'
     76 SED_SERVICESTATUS=	-e 's:@SERVICESTATUS@:${SERVICESTATUS}:g'
     77 SED_SCRIPT=		-e 's:@SCRIPT@:${SCRIPT}:g'
     78 SED_SYS=		-e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
     79 
     80 DEPEND!=	test -e .depend && echo ".depend" || echo ""
     81 VERSION!=	sed -n 's/\#define VERSION[[:space:]]*"\(.*\)".*/\1/p' defs.h
     82 
     83 FOSSILID?=	current
     84 
     85 DISTPREFIX?=	${PROG}-${VERSION}
     86 DISTFILEGZ?=	${DISTPREFIX}.tar.gz
     87 DISTFILE?=	${DISTPREFIX}.tar.bz2
     88 
     89 HOST_SH?=	/bin/sh
     90 
     91 CLEANFILES+=	*.tar.bz2
     92 
     93 .PHONY:		import import-bsd dev test
     94 
     95 .SUFFIXES:	.in
     96 
     97 .in:
     98 	${SED} ${SED_RUNDIR} ${SED_DBDIR} ${SED_LIBDIR} ${SED_HOOKDIR} \
     99 		${SED_SYS} ${SED_SCRIPT} \
    100 		${SED_SERVICEEXISTS} ${SED_SERVICECMD} ${SED_SERVICESTATUS} \
    101 		$< > $@
    102 
    103 all: config.h ${PROG} ${SCRIPTS} ${MAN5} ${MAN8} ${FILES}
    104 	for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
    105 
    106 dev:
    107 	cd dev && ${MAKE}
    108 
    109 .c.o:
    110 	${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
    111 
    112 CLEANFILES+=	dhcpcd-embedded.h dhcpcd-embedded.c
    113 
    114 dhcpcd-embedded.h: genembedh dhcpcd-definitions.conf dhcpcd-embedded.h.in
    115 	${HOST_SH} ${.ALLSRC} $^ > $@
    116 
    117 dhcpcd-embedded.c: genembedc dhcpcd-definitions.conf
    118 	${HOST_SH} ${.ALLSRC} $^ > $@
    119 
    120 if-options.c: dhcpcd-embedded.h
    121 
    122 .depend: ${SRCS} ${COMPAT_SRCS} ${CRYPT_SRCS}
    123 	${CC} ${CPPFLAGS} -MM ${SRCS} ${COMPAT_SRCS} ${CRYPT_SRCS} > .depend
    124 
    125 depend: .depend
    126 
    127 ${PROG}: ${DEPEND} ${OBJS}
    128 	${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
    129 
    130 test:
    131 	cd $@; ${MAKE} $@; ./$@
    132 
    133 _embeddedinstall: dhcpcd-definitions.conf
    134 	${INSTALL} -d ${DESTDIR}${SCRIPTSDIR}
    135 	${INSTALL} -m ${CONFMODE} dhcpcd-definitions.conf ${DESTDIR}${SCRIPTSDIR}
    136 
    137 _proginstall: ${PROG}
    138 	${INSTALL} -d ${DESTDIR}${SBINDIR}
    139 	${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${SBINDIR}
    140 	${INSTALL} -d ${DESTDIR}${DBDIR}
    141 
    142 _scriptsinstall: ${SCRIPTS}
    143 	${INSTALL} -d ${DESTDIR}${SCRIPTSDIR}
    144 	${INSTALL} -m ${BINMODE} ${SCRIPTS} ${DESTDIR}${SCRIPTSDIR}
    145 
    146 proginstall: _proginstall ${SCRIPTSINSTALL} ${EMBEDDEDINSTALL}
    147 	for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
    148 
    149 _maninstall: ${MAN5} ${MAN8}
    150 	${INSTALL} -d ${DESTDIR}${MANDIR}/man5
    151 	${INSTALL} -m ${MANMODE} ${MAN5} ${DESTDIR}${MANDIR}/man5
    152 	${INSTALL} -d ${DESTDIR}${MANDIR}/man8
    153 	${INSTALL} -m ${MANMODE} ${MAN8} ${DESTDIR}${MANDIR}/man8
    154 
    155 _dbusinstall: dbus/dhcpcd-dbus.conf
    156 	${INSTALL} -d ${DESTDIR}${DBUSDIR}
    157 	${INSTALL} -m ${CONFMODE} dbus/dhcpcd-dbus.conf \
    158 		${DESTDIR}${DBUSDIR}/dhcpcd.conf
    159 
    160 _confinstall: ${DBUSINSTALL}
    161 	${INSTALL} -d ${DESTDIR}${SYSCONFDIR}
    162 	test -e ${DESTDIR}${SYSCONFDIR}/dhcpcd.conf || \
    163 		${INSTALL} -m ${CONFMODE} dhcpcd.conf ${DESTDIR}${SYSCONFDIR}
    164 
    165 install: proginstall _confinstall
    166 
    167 clean:
    168 	rm -f ${OBJS} ${PROG} ${PROG}.core ${CLEANFILES}
    169 	for x in ${SUBDIRS} test; do cd $$x; ${MAKE} $@; cd ..; done
    170 
    171 distclean: clean
    172 	rm -f .depend config.h config.mk config.log
    173 
    174 dist:
    175 	fossil tarball --name ${DISTPREFIX} ${FOSSILID} ${DISTFILEGZ}
    176 	gunzip -c ${DISTFILEGZ} |  bzip2 >${DISTFILE}
    177 	rm ${DISTFILEGZ}
    178 
    179 snapshot:
    180 	rm -rf /tmp/${DISTPREFIX}
    181 	${INSTALL} -d /tmp/${DISTPREFIX}
    182 	cp -RPp * /tmp/${DISTPREFIX}
    183 	cd /tmp/${DISTPREFIX} && ${MAKE} distclean
    184 	cd /tmp && tar -cvjpf ${DISTFILE} ${DISTPREFIX}
    185 	mv /tmp/${DISTFILE} .
    186 	ls -l ${DISTFILE}
    187 
    188 import: ${SRCS}
    189 	rm -rf /tmp/${DISTPREFIX}
    190 	${INSTALL} -d /tmp/${DISTPREFIX}
    191 	cp ${SRCS} dhcpcd.conf dhcpcd-definitions.conf *.in /tmp/${DISTPREFIX}
    192 	cp $$(${CC} ${CPPFLAGS} -DDEPGEN -MM ${SRCS} | \
    193 		sed -e 's/^.*\.c //g' -e 's/.*\.c$$//g' -e 's/\\//g' | \
    194 		tr ' ' '\n' | \
    195 		sed -e '/^compat\//d' | \
    196 		sed -e '/^crypt\//d' | \
    197 		sort -u) /tmp/${DISTPREFIX}; \
    198 	if test -n "${CRYPT_SRCS}"; then \
    199 		${INSTALL} -d /tmp/${DISTPREFIX}/crypt; \
    200 		cp ${CRYPT_SRCS} /tmp/${DISTPREFIX}/crypt; \
    201 		cp $$(${CC} ${CPPFLAGS} -DDEPGEN -MM ${CRYPT_SRCS} | \
    202 			sed -e 's/^.*c //g' -e 's/.*\.c$$//g' -e 's/\\//g' | \
    203 			tr ' ' '\n' | sed -e '/\/\.\.\//d'  | \
    204 			sort -u) /tmp/${DISTPREFIX}/crypt; \
    205 	fi;
    206 	if test -n "${COMPAT_SRCS}"; then \
    207 		${INSTALL} -d /tmp/${DISTPREFIX}/compat; \
    208 		cp ${COMPAT_SRCS} /tmp/${DISTPREFIX}/compat; \
    209 		cp $$(${CC} ${CPPFLAGS} -DDEPGEN -MM ${COMPAT_SRCS} | \
    210 			sed -e 's/^.*c //g' -e 's/.*\.c$$//g' -e 's/\\//g' | \
    211 			tr ' ' '\n' | \
    212 			sort -u) /tmp/${DISTPREFIX}/compat; \
    213 	fi;
    214 	cd dhcpcd-hooks; ${MAKE} DISTPREFIX=${DISTPREFIX} $@
    215 
    216 include Makefile.inc
    217