lobase

Linux port of OpenBSDs userland.

bsd.subdir.mk (1395B)


      1 MAKEOBJDIR?=	obj
      2 
      3 .TOPDIR?=	..
      4 .OBJDIR?=	${MAKEOBJDIR}
      5 .SRCDIR?=	.
      6 .CURDIR?=	.
      7 .RELDIR:=	$(.SRCDIR:.%=$(.TOPDIR)/../%)
      8 
      9 SUBDIR_MFLAGS=	--no-print-directory \
     10 		-I$(.NEXTTOP)/mk \
     11 		-C ${.OBJDIR}/$$nextdir \
     12 		-f ${.RELDIR}/$$nextdir/Makefile \
     13 		.OBJDIR=. \
     14 		.TOPDIR=${.TOPDIR}/.. \
     15 		.CURDIR=${.RELDIR}/$$nextdir \
     16 		.SRCDIR=${.SRCDIR}/$$nextdir \
     17 		MAKEOBJDIR=${.TOPDIR}/${MAKEOBJDIR} \
     18 		_THISDIR_=$$nextdir
     19 		
     20 
     21 
     22 SUBDIR_TARGETS = all install clean cleandir includes depend regress obj tags manlint
     23 
     24 $(SUBDIR_TARGETS): _SUBDIRUSE
     25 
     26 define __SUBDIRUSE
     27 for nextdir in $(SUBDIR); do                                                   \
     28 	b=; for s in $(SKIPDIR); do                                            \
     29 		[ "$$s" = "$$nextdir" ] && b=1 && break;                       \
     30 	done;                                                                  \
     31 	[ -n "$$b" ] && echo "($$nextdir skipped)" && continue;                \
     32 	echo "===> $${_THISDIR_:+$${_THISDIR_}/}$$nextdir";                    \
     33 	mkdir -p "${.OBJDIR}/$$nextdir"                                        \
     34 	&& $(MAKE) $(SUBDIR_MFLAGS) $(MAKECMDGOALS) || exit 1;                 \
     35 done
     36 endef
     37 
     38 _SUBDIRUSE:
     39 ifneq ($(SUBDIR),)
     40 	+@$(__SUBDIRUSE)
     41 
     42 $(SUBDIR):
     43 	+@nextdir="$@"; \
     44 	echo "===> $$nextdir"; \
     45 	mkdir -p "${.OBJDIR}/$$nextdir" \
     46 	&& $(MAKE) $(SUBDIR_MFLAGS) all || exit 1
     47 endif
     48 
     49 .PHONY: _SUBDIRUSE $(SUBDIR_TARGETS) $(SUBDIR)