[uw.mfcf.people] how do I make sure a directory exists from a Makefile?

jmsellens@watmath.waterloo.edu (10/01/89)

From: John M Sellens <jmsellens>

mkdir -f exits 1 if it already exists
and neither of these seem to work
	if [ ! -d /usr/lib/wup ]; then mkdir /usr/lib/wup || exit 0; fi; exit 0
	mkdir -f /usr/lib/wup || exit 0

Any ideas?

D. Allen [CGL]) (10/02/89)

You can't have anything fail directly in Makefile scripts.

Method 1:

	set - /software/foo/ba[r]/. && \
	case "$1" in \
	/software/foo/bar/.) echo is a directory ;; \
	*) mkdir /software/foo/bar ;; \
	esac

Method 2:

	case `sh -c "test -d /software/foo/bar/. && echo OKAY ; :"` in \
	OKAY) echo is a directory ;; \
	*) mkdir /software/foo/bar ;; \
	esac

Method 3:

	sh -c "test -d /software/foo/bar/. || mkdir /software/foo/bar"
-- 
-IAN! (Ian! D. Allen) idallen@watcgl.uwaterloo.ca idallen@watcgl.waterloo.edu
 129.97.128.64    Computer Graphics Lab/University of Waterloo/Ontario/Canada