programming: Makefile

George Georgalis george at galis.org
Fri May 27 12:18:15 PDT 2005


I'm using a Makefile in the top of a checked out cvs repository
to create hardlinks from the checked out tree to the real filesystem.
This helps keep the repository consistent with the live files.

This Makefile target worked fine in each "copy point" but I found I was
duplicating the code in several places, so I changed absolute file paths
to ${REAL} and made it a target in a top level functions.mk which is
included by the Makefile being called


MAKE_REAL_HARD_LINKS :
	# Replicate cvs checked out directory into real location,
	# as directories and hardlinks.
	test -f CVS/Repository # for sanity
	mkdir -p ${REAL}
	test -d ${REAL}
	test -w ${REAL}
	# Create directories as required
	for dir in `find . -mindepth 1 ! \( -path '*/CVS' -prune \) -type d -printf "%P\n"`; do \
		[ -a "${REAL}/$${dir}" -a ! -d "${REAL}/$${dir}" ] || exit 1; \
		mkdir -p ${REAL}/$${dir}; \
	done
	# Make hardlinks for files, but not cvs saved backups or Makefiles
	for file in `find . ! \( -path '*/CVS' -prune \) -type f ! -name .$#\* ! -name Makefile -printf "%P\n"`; do \
		ln -f $${file} ${REAL}/$${file}; \
	done


But now, when I do this (home/geo is a cvs module):

include function.mk
geo :
	make -C home/geo MAKE_REAL_HARD_LINKS REAL=/home/geo

I get...

% make geo       
make -C home/geo MAKE_REAL_HARD_LINKS REAL=/home/geo
make: don't know how to make MAKE_REAL_HARD_LINKS. Stop
*** Error code 2


So how does one "include" targets, or am I going about this wrong?

// George


-- 
George Georgalis, systems architect, administrator Linux BSD IXOYE
http://galis.org/george/ cell:646-331-2027 mailto:george at xxxxxxxxx





More information about the Users mailing list