.SUFFIXES: .cxx .cpp .c .o # APPNAME is the parent directory of the current one APPNAME = ${shell perl -MCwd -e 'print +(split/\//,cwd)[-2]'} EXE = ${APPNAME} ... (the usual stuff follows) ...