1. Please see README.mk-devel for a full description of the changes
from a Make perspective.
2. Several files were changed to accomodate correct installation
practices, most notably ones in testcases/network/{ipv6,tcp_cmds},
testcases/kernel/sched/hyperthreading/ht_enabled/..., and some items
in tools/..., and also to avoid collisions as far as installed
testcases (scripts, compiled C apps) were concerned.
3. Several apps weren't autoconf safe and some autoconf tests and
conditional statements have been placed in sourcecode and in Makefiles
to either a) prevent the tests from being built / installed or b) turn
the tests into dummy apps which print out TCONF messages due to
lack-of-build support.

Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
diff --git a/Makefile b/Makefile
index e86872e..703e0c7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,160 +1,200 @@
-# See toplevel INSTALL for build info
+#
+#    Top-level Makefile for LTP. See INSTALL for more info.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-ifdef CROSS_COMPILE
-CROSS_COMPILER = $(CROSS_COMPILE)
-endif
-ifdef CROSS_COMPILER
-CC=$(CROSS_COMPILER)gcc
-AR=$(CROSS_COMPILER)ar
-RANLIB=$(CROSS_COMPILER)ranlib
+# Force IDcheck.sh to fix any issues found with $(DESTDIR)/etc/group and
+# $(DESTDIR)/etc/passwd automatically when after running the top-level
+# install target.
+CREATE_ENTRIES		?= 0
+
+top_srcdir		?= $(CURDIR)
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/automake.mk
+
+# This variable is automatically changed from help to all once someone has
+# run configure, or the equivalent steps manually, as described in
+# README.mk-user.
+ifeq ($(wildcard $(top_builddir)/include/config.h),)
+.DEFAULT_GOAL		:= help
 else
-# RANLIB isn't a standard Make variable, which means that when it's exported
-# to leaf callers as an empty value, builds fail.
-# testcases/network/lib6/Makefile is a prime example.
-RANLIB?=ranlib
+.DEFAULT_GOAL		:= all
 endif
 
-HAS_NUMA=$(shell sh tools/scripts/numa_test.sh)
+.SUFFIXES:
+.SUFFIXES: .am .default .h .in .m4 .mk
 
-export CFLAGS += -Wall $(CROSS_CFLAGS)
-export CC AR RANLIB CPPFLAGS LDFLAGS HAS_NUMA
+vpath %.am		$(top_srcdir)/m4
+vpath %.default		$(top_srcdir)/include
+vpath %.h		$(top_srcdir)/include:$(top_builddir)/include
+vpath %.in		$(top_srcdir)/include
+vpath %.m4		$(top_srcdir)/m4
+vpath %.mk		$(top_srcdir)/mk:$(top_srcdir)/mk/include
 
-# SKIP_IDCHECK	!= 1, defaults to previous behavior, which is to execute
-# IDcheck.sh at the end of `make install'.
-SKIP_IDCHECK		?= 0 
+# Skip running IDcheck.sh at the end of install?
+SKIP_IDCHECK		?= 0
 
--include config.mk
+# User wants uclinux binaries?
+UCLINUX			?= 0
 
-VPATH += include m4
-all: config.h config.mk libltp.a 
-	@$(MAKE) -C pan $@
-	@$(MAKE) -C testcases $@
-	@$(MAKE) -C tools $@
-	@$(MAKE) -C utils $@
-	@echo
-	@echo "***********************************************"
-	@echo "** You now need to do a make install as root **"
-	@echo "***********************************************"
-
-install: all
-	@$(MAKE) -C testcases install
-	@$(MAKE) -C tools install
-	@$(MAKE) -C lib install
-	@$(MAKE) -C include install
-	@$(MAKE) -C pan install
-	@$(MAKE) -C m4 install
-	@$(MAKE) -C doc/man1 install
-	@$(MAKE) -C doc/man3 install
-	@$(MAKE) -C utils install
-ifneq ($(strip $(SKIP_IDCHECK)),1)
-	@./IDcheck.sh
+# User wants uclinux binaries. Do this for backwards compatibility, but
+# print out a warning.
+ifneq ($(filter uclinux%,$(MAKECMDGOALS)),)
+$(warning uclinux* targets will be deprecated in the future.)
+$(warning Please specify UCLINUX=1 on the command line to achieve the same)
+$(warning functionality.)
+UCLINUX			:= 1
 endif
 
-libltp.a: config.h
-	@$(MAKE) -C lib $@
+export UCLINUX
 
-uclinux: uclinux_libltp.a
-	#@$(MAKE) -C pan all
-	@$(MAKE) -C testcases uclinux
-	@$(MAKE) -C tools all
-	@echo
+# CLEAN_TARGETS:	Targets which exist solely in clean.
+# COMMON_TARGETS:	Targets which exist in all, clean, and install.
+# INSTALL_TARGETS:	Targets which exist in clean and install (contains
+# 			COMMON_TARGETS).
+# BOOTSTRAP_TARGETS:	Directories required to bootstrap out-of-build-tree
+# 			support.
+
+# We're not using uclinux based targets (default).
+ifneq ($(UCLINUX),1)
+COMMON_TARGETS		:= pan utils
+INSTALL_TARGETS		:= doc
+endif
+
+COMMON_TARGETS		+= testcases tools
+INSTALL_TARGETS		+= $(COMMON_TARGETS) runtest
+CLEAN_TARGETS		+= $(COMMON_TARGETS) lib include runtest
+BOOTSTRAP_TARGETS	:= $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS)\
+				  $(INSTALL_TARGETS))
+
+CLEAN_TARGETS		:= $(addsuffix -clean,$(CLEAN_TARGETS))
+INSTALL_TARGETS		:= $(addsuffix -install,$(INSTALL_TARGETS))
+MAKE_TARGETS		:= $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))
+
+# There's no reason why we should run `all' twice. Otherwise we're just wasting
+# 3+ mins of useful CPU cycles on a modern machine, and even more time on an
+# overtaxed one, or one where -j => 1 was specified.
+all: $(addsuffix -all,$(COMMON_TARGETS))
+
+$(MAKE_TARGETS): lib-install
+
+.PHONY: include-all include-install
+include-install: include/config.h include/mk/config.mk include-all
+
+# build tree bootstrap targets.
+$(addprefix $(abs_top_builddir)/,$(BOOTSTRAP_TARGETS)) $(INSTALL_DIR): %:
+	mkdir -m 00755 -p "$@"
+
+## Pattern based subtarget rules.
+lib-all: include-install
+
+lib-install: lib-all
+
+.SECONDEXPANSION:
+$(MAKE_TARGETS) include-all lib-all: %-all: $(abs_top_builddir)/$$*
+	$(MAKE) -C $* -f "$(abs_top_srcdir)/$*/Makefile" all 
+
+# Let's not conflict with ac-clean, maintainer-clean, etc, so.
+.SECONDEXPANSION:
+$(filter-out include-clean,$(CLEAN_TARGETS)):: %-clean: $(abs_top_builddir)/$$*
+	-$(MAKE) -C $* -f "$(abs_top_srcdir)/$*/Makefile" clean
+
+# Just like everything depends on include-all / -install, we need to get rid
+# of include last to ensure that things won't be monkey screwed up. Only do
+# this if we're invoking clean or a subclean directly though.
+ifneq ($(filter clean,$(MAKECMDGOALS)),)
+INCLUDE_CLEAN_RDEP_SUBJECT	:= $(CLEAN_TARGETS)
+else
+ifneq ($(filter %clean,$(MAKECMDGOALS)),)
+INCLUDE_CLEAN_RDEP_SUBJECT	:= $(MAKECMDGOALS)
+endif
+endif
+
+# Remove potential for circular dependencies.
+INCLUDE_CLEAN_RDEPS		:= $(filter-out include-clean,\
+						$(INCLUDE_CLEAN_RDEP_SUBJECT))
+
+include-clean:: $(INCLUDE_CLEAN_RDEPS) $(abs_top_builddir)/include
+	-$(MAKE) -C include -f "$(abs_top_srcdir)/include/Makefile" clean
+
+# include-install is separate to avoid creating a circular dependency below in
+# the install target.
+.SECONDEXPANSION:
+$(INSTALL_TARGETS) include-install lib-install: %-install: \
+    $(abs_top_builddir)/$$*
+	$(MAKE) -C $* -f "$(abs_top_srcdir)/$*/Makefile" install 
+
+INSTALL_DIR		:= $(DESTDIR)/$(prefix)
+
+# Just in case configure hasn't been run yet, let's not overambitiously remove
+# the $(INSTALL_DIR).
+clean:: $(CLEAN_TARGETS)
+	$(RM) -f Version
+	$(if $(DESTDIR)$(prefix),-$(RM) -Rf "$(INSTALL_DIR)")
+
+SRCDIR_INSTALL_SCRIPTS	:= runltp runltplite.sh ver_linux
+SRCDIR_INSTALL_READONLY	:= Version
+SRCDIR_INSTALL_TARGETS	:= $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY)
+
+# Save space. We only need the first line in ChangeLog for runltp*.
+Version: $(top_srcdir)/ChangeLog
+	head -n 1 "$^" > "$@"
+
+$(INSTALL_DIR)/Version: Version
+	install -m 00644 "$(top_builddir)/$(@F)" "$@"
+
+$(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)) \
+$(addprefix $(INSTALL_DIR)/,$(SRCDIR_INSTALL_SCRIPTS)): %:
+	install -m 00755 "$(top_srcdir)/$(@F)" "$@"
+
+INSTALL_TARGETS		+= $(addprefix $(INSTALL_DIR)/,\
+				$(SRCDIR_INSTALL_TARGETS))
+
+$(INSTALL_TARGETS): $(INSTALL_DIR)
+
+## Install
+install: $(INSTALL_TARGETS)
+ifeq ($(SKIP_IDCHECK),0)
+	@CREATE_ENTRIES=$(CREATE_ENTRIES) \
+	 DESTDIR="$(DESTDIR)" \
+	 "$(top_srcdir)/IDcheck.sh"
+else
 	@echo "*******************************************************"
-	@echo "** You now need to do a make uclinux_install as root **"
+	@echo "** Will not run IDcheck.sh (SKIP_IDCHECK set to 1).  **"
 	@echo "*******************************************************"
-
-uclinux_install: uclinux
-	@$(MAKE) -C testcases uclinux_install
-	@$(MAKE) -C tools install
-ifneq ($(strip $(SKIP_IDCHECK)),1)
-	@./IDcheck.sh
 endif
 
-uclinux_libltp.a:
-	@$(MAKE) -C lib UCLINUX=1 libltp.a
+## Misc targets.
 
-menuconfig:
-	@./ltpmenu
-
-clean: ac-clean
-	@$(MAKE) -C lib $@
-	@$(MAKE) -C pan $@
-	@$(MAKE) -C tools $@
-	@$(MAKE) -C testcases $@
-	@$(MAKE) -C utils $@
-
-distclean: clean ac-distclean
-	@$(MAKE) -C include $@
-
-maintainer-clean: distclean ac-maintainer-clean
-	@$(MAKE) -C include $@
-
-package: 
-	rpmbuild -ba ltp-devel.spec
-
-
-#
-# Autotools related
-#
-.PHONY: autotools
-autotools: aclocal autoconf autoheader automake
-
-.PHONY: aclocal
-aclocal: aclocal.m4
-aclocal.m4: $(wildcard m4/*.m4)
-	aclocal -I m4
-
-.PHONY: autoconf
-autoconf: configure
-configure: configure.ac aclocal.m4
-	autoconf
-
-.PHONY: autoheader
-autoheader: config.h.in
-config.h.in: configure.ac $(wildcard m4/*.m4)
-	autoheader
-	touch include/$@
-config.h: config.h.default
-	cp include/config.h.default include/config.h
-config.mk:
-	touch $@
-
-.PHONY: automake
-AUTOMAKE_FILES = config.guess config.sub install-sh missing
-automake: aclocal $(AUTOMAKE_FILES)
-$(AUTOMAKE_FILES): m4/Makefile.in
-m4/Makefile.in: m4/Makefile.am
-	automake -c -a
-
-.PHONY: ac-clean ac-distclean ac-maintainer-clean
-ac-clean:
-	rm -rf autom4te.cache
-	rm -f config.log config.status
-ac-distclean: ac-clean
-ac-maintainer-clean: ac-distclean
-	rm -f aclocal.m4 configure $(AUTOMAKE_FILES) m4/Makefile.in
-
-#
-# Help
-#
+## Help
 .PHONY: help
 help:
-	@echo
-	@echo 'About configuration'
-	@echo '-------------------'
-	@echo 'If you want to use auto configuration,   '
-	@echo 'be sure autoconf and automake are installed. Then run: '
-	@echo '	$$ make autotools '
-	@echo '	$$ ./configure   '
-	@echo '	$$ make all      '
-	@echo
-	@echo 'If you want to use default configuration,  '
-	@echo 'autoconf is not needed. Just run:          '
-	@echo '	$$ touch include/config.h.default '
-	@echo '	$$ make config.h                  '
-	@echo '	$$ make all                       '
-	@echo
-	@echo 'If make all is failed even if you use the '
-	@echo 'auto configuration, please, report it to  '
-	@echo 'ltp developers with config.log, generated '
-	@echo 'by running the configure script.          '
-	@echo
+	@cat "$(top_srcdir)/README.mk-user"; exit 1
+
+## Menuconfig
+menuconfig:
+	@$(SHELL) "$(top_srcdir)/ltpmenu"
+
+## Package
+package: 
+	@$(RPMBUILD) -ba ltp-devel.spec
+
+## End misc targets.
diff --git a/README.ltp-devel b/README.ltp-devel.in
similarity index 78%
rename from README.ltp-devel
rename to README.ltp-devel.in
index aa51d44..98bec47 100644
--- a/README.ltp-devel
+++ b/README.ltp-devel.in
@@ -2,13 +2,13 @@
 
 "make install" is to build and install:
 
-	/scratch/ltp-install2/bin/ltp-bump
-	/scratch/ltp-install2/bin/ltp-pan
-	/scratch/ltp-install2/bin/ltp-scanner
-	/scratch/ltp-install2/lib/libltp.a
-	${prefix}/share/pkgconfig/ltp.pc
-	/scratch/ltp-install2/include/
-	${datarootdir}/man
+	@prefix@/bin/ltp-bump
+	@prefix@/bin/ltp-pan
+	@prefix@/bin/ltp-scanner
+	@prefix@/lib/libltp.a
+	@datarootdir@/pkgconfig/ltp.pc
+	@prefix@/include/
+	@mandir@
 
 "make package" is to rpm package what was installed above:
 
diff --git a/README.mk-devel b/README.mk-devel
new file mode 100644
index 0000000..7b976f5
--- /dev/null
+++ b/README.mk-devel
@@ -0,0 +1,188 @@
+==============================
+Introduction
+==============================
+
+The following document briefly describes the steps and methodologies used for
+the new and improved Makefile system.
+
+==============================
+The Problem
+==============================
+
+The problem with the old Makefile system is that it was very difficult to
+maintain and it lacked any sense of formal structure, thus developing for LTP
+and including new targets was very more difficult than it should have been
+(maintenance). Furthermore, proper option-based cross-compilation was
+impossible due to the fact that the Makefiles didn't support a prefixing
+system, and the appropriate implicit / static rules hadn't been configured to
+compile into multiple object directories for out-of-tree build support (easy of
+use / functionality). Finally, there wasn't a means to setup dependencies
+between components, such that if a component required libltp.a in order to
+compile, it would go off and compile libltp.a first (easy of use).
+
+These items needed to be fixed to reduce maintenance nightmares for the
+development community contributing to LTP, as well as the individuals
+maintaining the project.
+
+==============================
+Design
+==============================
+
+The system was designed such that including a single GNU Makefile compatible
+set in each new directory component is all that's essentially required to
+build the system.
+
+Say you had a directory like the following (with .c files in them which
+directly tie into applications, e.g. baz.c -> baz):
+
+        .../foo/
+	     |--> Makefile
+	     |
+	      --> bar/
+		   |
+		    --> Makefile
+                   |
+                    --> baz.c
+
+Here's an example of how one would accomplish that:
+
+.../foo/Makefile:
+#
+# Copyright disclaimer goes here -- please use GPLv2.
+#
+
+top_srcdir		?= ..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
+
+.../foo/bar/Makefile:
+#
+# Copyright disclaimer goes here -- please use GPLv2.
+#
+
+top_srcdir		?= ..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+==============================
+Make Rules and Make Variables
+==============================
+
+When using make rules, avoid writing adhoc rules like:
+
+[prog]: [dependencies]
+	cc -I../../include $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LDLIBS) \
+	    -o [prog] [dependencies]
+
+etc. This makes cross-compilation and determinism difficult, if not impossible.
+Besides, implicit rules are your friends and as long as you use `MAKEOPTS=;' in
+the top-level caller (or do $(subst r,$(MAKEOPTS)) to remove -r), the compile
+will complete successfully, assuming all other prerequisites have been
+fulfilled (libraries, headers, etc).
+
+$(AR)			: The library archiver.
+
+$(CC)			: The system C compiler.
+
+$(CXX)			: The system C++ compiler.
+
+$(CPP)			: The system C preprocessor.
+
+$(CFLAGS)		: C compiler flags. 
+
+$(CPPFLAGS)		: Preprocessor flags, e.g. -I arguments.
+
+$(CXXFLAGS)		: C++ compiler flags, e.g. -I arguments.
+
+$(DEBUG_CFLAGS)		: Debug flags to pass to $(CC), -g, etc.
+
+$(DEBUG_CXXFLAGS)	: Debug flags to pass to $(CXX).
+
+$(LD)			: The system linker (typically $(CC), but not
+			  necessarily).
+
+$(LDFLAGS)		: What to pass in to the linker, including -L arguments
+			  and other ld arguments, apart from -l library
+			  includes (see $(LDLIBS)).
+
+			  This should be done in the $(CC) args passing style
+			  when LD := $(CC), e.g. `-Wl,-foo', as opposed to
+			  `-foo'.
+
+$(LDLIBS)		: Libraries to pass to the linker (e.g. -lltp, etc).
+
+$(OPT_CFLAGS)		: Optimization flags to pass into the C compiler, -O2,
+			  etc. If you specify -O2 or higher, you should also
+			  specify -fno-strict-aliasing, because of gcc
+			  fstrict-aliasing optimization bugs in the tree
+			  optimizer. Search for `fstrict-aliasing optimization
+			  bug' with your favorite search engine.
+
+			  Examples of more recent bugs:
+			  1. tree-optimization/17510
+			  2. tree-optimization/39100
+
+			  Various bugs have occurred in the past due to buggy
+			  logic in the tree-optimization portion of the gcc
+			  compiler, from 3.3.x to 4.4.
+
+$(OPT_CXXFLAGS)		: Optimization flags to pass to the C++ compiler.
+
+$(RANLIB)		: What to run after archiving a library.
+
+$(WCFLAGS)		: Warning flags to pass to $(CC), e.g. -Werror,
+			  -Wall, etc.
+
+$(WCXXFLAGS)		: Same as $(WCFLAGS), but for $(CXX).
+
+==============================
+Make System Variables
+==============================
+
+A series of variables are used within the make system that direct what actions
+need to be taken. Rather than me listing the variables here, please instead
+refer to the comments contained in `.../include/mk/env_pre.mk'.
+
+==============================
+Guidelines and Recommendations
+==============================
+
+Of course, the GNU Make manual is key to understanding the Make system, but
+here are the following sections and chapters I suggest reviewing:
+
+- implicit rules: http://www.gnu.org/software/make/manual/make.html#Implicit-Rules
+- variables and expansion: http://www.gnu.org/software/make/manual/make.html#Using-Variables
+- origin use: http://www.gnu.org/software/make/manual/make.html#Origin-Function
+- vpath use: http://www.gnu.org/software/make/manual/make.html#Directory-Search
+
+==============================
+Before Committing
+==============================
+
+One should rebuild from scratch before committing. Here's an example of how to
+do that:
+#!/bin/sh
+
+TOOLS_PATH=/path/to/tools
+
+# Replace [options] with any make specific options and variables, for each
+# step, example: -j 4, DESTDIR=/path/for/install, etc.
+make maintainer-clean [options]
+make \
+  ACLOCAL=$TOOLS_PATH/bin/aclocal \
+  AUTOCONF=$TOOLS_PATH/bin/autoconf \
+  AUTOHEADER=$TOOLS_PATH/bin/autoheader \
+  AUTOMAKE=$TOOLS_PATH/bin/automake \
+  autotools
+./configure [options]
+make all [options]
+make install [options]
+
+==============================
+Other Errata
+==============================
+
+Please see TODO for any issues related to the Makefile infrastructure, and
+build structure / source tree in general.
diff --git a/README.mk-user b/README.mk-user
new file mode 100644
index 0000000..c46fe4c
--- /dev/null
+++ b/README.mk-user
@@ -0,0 +1,33 @@
+==============================
+About configuration
+==============================
+
+If you want to use auto configuration, be sure autoconf and automake are
+installed. Then run: 
+ $ make autotools 
+ $ ./configure   
+ $ make all      
+
+If you want to use default configuration, autoconf is not needed. Just run:         
+ $ touch include/config.h.default 
+ $ make config.h                  
+ $ make all                       
+
+If make all is failed even if you use the auto configuration, please, report
+your issue to the ltp developers with config.log, generated by running the
+configure script.
+
+==============================
+Using non-standard tools
+==============================
+
+Some systems (RHEL 4, etc) only have outdated tools available, due to
+licensing concerns. So if you happen to install these tools in a non-standard
+spot, here's how you bootstrap LTP with these tools:
+
+ $ make \
+   ACLOCAL=/path/to/aclocal \
+   AUTOCONF=/path/to/autoconf \
+   AUTOHEADER=/path/to/autoheader \
+   AUTOMAKE=/path/to/automake \
+   autotools
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..815ca2d
--- /dev/null
+++ b/TODO
@@ -0,0 +1,178 @@
+The following items need fixing with the new Makefile infrastructure:
+
+testcases/kernel/controllers/memcg/functional/Makefile:
+1. For whatever reason this Makefile's are calling up relative CPPFLAGS
+   (the old ../../../../include value) for -I$(include), despite the fact that
+   the Makefile infra been updated. This should be investigated and fixed, but
+   for now it's just an observation; not a blocking point.
+
+include/mk/functions.mk:
+1. The dependency work for $(@D) isn't 100% functional in generate_install_rule.
+   Thus `test -d .. || mkdir -p ..' is required today to ensure that things
+   function in specific cases, like testcases/kernel/power_management/... with
+   lib/sched_mc.py .
+
+testcases/Makefile:
+1. mce-test doesn't fit cleanly in the build, yet.
+2. pounder21 is just broken (wasn't traversed before).
+3. Not sure why realtime should still be disabled for build; the aggregated
+   list was the original list of disabled items for UCLINUX != 1.
+
+testcases/commands/ade/Makefile:
+1. .../objdump's Makefile needs fixing. Basically some of the obj files used
+   as stimuli are .o files, which a) is a bad idea, and b) are intermediary's
+   for some apps. Either the tests or the Makefiles need to be fixed, and
+   this is a call that needs to be made by someone else including myself.
+
+testcases/kernel/aio/aio02/Makefile:
+1. Not sure why, but ld fails to link these two files together properly, even
+   though I have a function prototype defined at the top of main.c and as you
+   can see below, gcc is trying to link the right pieces together. Hrmmm...
+
+  gcooper@orangebox /scratch2/ltp-makefile-infra-rework $ make -C /scratch2/ltp-makefile-infra-rework/testcases/kernel/io/aio/aio02/ all  
+  make: Entering directory `/scratch2/ltp-makefile-infra-rework/testcases/kernel/io/aio/aio02'
+  gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall  -I//scratch/ltp-install5/include -D_GNU_SOURCE -I../../../../../include  -c -o main.o main.c
+  gcc  -L//scratch/ltp-install5/lib   aio_tio.o main.o  -laio -lltp -laio -o aio_tio
+  main.o: In function `main':
+  /scratch2/ltp-makefile-infra-rework/testcases/kernel/io/aio/aio02/main.c:26: undefined reference to `test_main'
+  collect2: ld returned 1 exit status
+  make: *** [aio_tio] Error 1
+  make: Leaving directory `/scratch2/ltp-makefile-infra-rework/testcases/kernel/io/aio/aio02'
+
+testcases/kernel/fs/dmapi/Makefile:
+1. This test requires JFS support, which most systems don't have. So a set of
+   proper autoconf tests need to be added for this as well.
+
+testcases/kernel/fs/doio/rwtest.sh:
+1. rwtest.sh isn't determining where to pick up the files from appropriately
+   (bad relative path logic somewhere... not sure where).
+
+testcases/kernel/sched/nptl/Makefile:
+1. There's a $(shell ) call in the Makefile that needs to be replaced.
+
+testcases/kernel/syscalls/utils/*.mk:
+1. There are unused variables and unneeded logic that needs to be evaluated
+   and potentially removed.
+
+testcases/misc/crash/crash02.c:
+#if defined(__ia64__)
+      SYS_clone2,
+#else
+      /*
+       * No SYS_fork(vfork) on IA-64. Instead, it uses,
+       * clone(child_stack=0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD)
+       * clone2()
+       */
+
+      /*
+       * NOTE (garrcoop):
+       *  Could not find reference to SYS_fork(vfork) on mips32
+       *  with the Montavista / Octeon toolchain. Need to develop an
+       *  autoconf check for this item.
+       */
+#if defined(__NR_vfork) && __NR_vfork
+      SYS_vfork,
+#endif
+#if defined(__NR_fork) && __NR_fork
+      SYS_fork,
+#endif
+#endif /* __ia64__ */
+#if defined(__NR_clone) && __NR_clone
+      SYS_clone,
+#endif
+
+testcases/network/tcp_cmds/perf_lan/Makefile:
+1. There are duplicate sourcefiles because I don't feel confident as far as
+   the changes were concerned on the sourcefiles and I was running into
+   compile issues with the IPv6 code.
+
+testcases/network/stress/udp/...:
+1. Many of the scripts are installing themselves using the old-status quo
+   method of hardlinking into $(abs_top_srcdir)/testcases/bin, which means
+   that all of the scripts are being linked to the file
+   $(abs_top_srcdir)/testcases/bin .
+
+tools/Makefile:
+1. netpipe* needs fixing and reorg, because it's referencing /home/mpich, etc.
+
+utils/benchmark/Makefile:
+1. kernbench needs to be fixed because its makefile doesn't have support
+   out-of-build-tree building.
+
+Other items of issue are listed below (from testscripts/ltp-missing-install-files.py):
+
+io-output.log: Tag | App
+io-output.log: runfstests.sh runfstests.sh
+ipv6-output.log: Tag | App
+ipv6-output.log: finger601 finger601
+ipv6-output.log: ping601 ping601
+ipv6-output.log: rlogin01 rlogin01
+ipv6-output.log: tcpdump601 tcpdump601
+ipv6-output.log: telnet01 telnet01
+ipv6_expect-output.log: Tag | App
+ipv6_expect-output.log: rlogin01 rlogin01
+ipv6_noexpect-output.log: Tag | App
+ipv6_noexpect-output.log: /scratch/ltp-install5/testcases/bin/echo01 /scratch/ltp-install5/testcases/bin/createfile
+modules-output.log: Tag | App
+modules-output.log: delete_module01 delete_module01
+modules-output.log: delete_module02 delete_module02
+modules-output.log: delete_module03 delete_module03
+multicast-output.log: Tag | App
+multicast-output.log: /scratch/ltp-install5/testcases/bin/mc_opts /scratch/ltp-install5/bin/mc_opts9521/opts
+selinux-output.log: Tag | App
+selinux-output.log: selinux_capable_file.sh selinux_capable_file.sh
+selinux-output.log: selinux_capable_net.sh selinux_capable_net.sh
+selinux-output.log: selinux_capable_sys.sh selinux_capable_sys.sh
+selinux-output.log: selinux_domain_trans.sh selinux_domain_trans.sh
+selinux-output.log: selinux_entrypoint.sh selinux_entrypoint.sh
+selinux-output.log: selinux_execshare.sh selinux_execshare.sh
+selinux-output.log: selinux_exectrace.sh selinux_exectrace.sh
+selinux-output.log: selinux_execute_no_trans.sh selinux_execute_no_trans.sh
+selinux-output.log: selinux_fdreceive.sh selinux_fdreceive.sh
+selinux-output.log: selinux_file.sh selinux_file.sh
+selinux-output.log: selinux_inherit.sh selinux_inherit.sh
+selinux-output.log: selinux_ioctl.sh selinux_ioctl.sh
+selinux-output.log: selinux_link.sh selinux_link.sh
+selinux-output.log: selinux_mkdir.sh selinux_mkdir.sh
+selinux-output.log: selinux_msg.sh selinux_msg.sh
+selinux-output.log: selinux_open.sh selinux_open.sh
+selinux-output.log: selinux_ptrace.sh selinux_ptrace.sh
+selinux-output.log: selinux_readlink.sh selinux_readlink.sh
+selinux-output.log: selinux_relabel.sh selinux_relabel.sh
+selinux-output.log: selinux_rename.sh selinux_rename.sh
+selinux-output.log: selinux_rxdir.sh selinux_rxdir.sh
+selinux-output.log: selinux_sem.sh selinux_sem.sh
+selinux-output.log: selinux_setattr.sh selinux_setattr.sh
+selinux-output.log: selinux_setnice.sh selinux_setnice.sh
+selinux-output.log: selinux_shm.sh selinux_shm.sh
+selinux-output.log: selinux_sigkill.sh selinux_sigkill.sh
+selinux-output.log: selinux_stat.sh selinux_stat.sh
+selinux-output.log: selinux_sysctl.sh selinux_sysctl.sh
+selinux-output.log: selinux_task_create.sh selinux_task_create.sh
+selinux-output.log: selinux_task_getpgid.sh selinux_task_getpgid.sh
+selinux-output.log: selinux_task_getscheduler.sh selinux_task_getscheduler.sh
+selinux-output.log: selinux_task_getsid.sh selinux_task_getsid.sh
+selinux-output.log: selinux_task_setnice.sh selinux_task_setnice.sh
+selinux-output.log: selinux_task_setpgid.sh selinux_task_setpgid.sh
+selinux-output.log: selinux_task_setscheduler.sh selinux_task_setscheduler.sh
+selinux-output.log: selinux_wait.sh selinux_wait.sh
+selinux-output.log: selinux_dyntrace.sh selinux_dyntrace.sh
+selinux-output.log: selinux_dyntrans.sh selinux_dyntrans.sh
+selinux-output.log: selinux_bounds.sh selinux_bounds.sh
+stress.part3-output.log: Tag | App
+stress.part3-output.log: /scratch/ltp-install5/testcases/bin/mc_opts /scratch/ltp-install5/bin/mc_opts4243/opts
+tcp_cmds-output.log: Tag | App
+tcp_cmds-output.log: /scratch/ltp-install5/testcases/bin/echo01 /scratch/ltp-install5/testcases/bin/createfile
+tcp_cmds-output.log: rlogin01 rlogin01
+tcp_cmds-output.log: telnet01 telnet01
+tcp_cmds_expect-output.log: Tag | App
+tcp_cmds_expect-output.log: rlogin01 rlogin01
+tcp_cmds_expect-output.log: telnet01 telnet01
+tcp_cmds_noexpect-output.log: Tag | App
+tcp_cmds_noexpect-output.log: /scratch/ltp-install5/testcases/bin/echo01 /scratch/ltp-install5/testcases/bin/createfile
+
+1. selinux is disabled on purpose (doesn't fit within build and probably won't
+   until autoconf tests are created to detect SELinux).
+2. Unsure why the tcp_cmds scripts aren't showing up.
+3. runfstests.sh is missing because aio02 is disabled right now (being a pain
+   and won't compile for me >:(...).
diff --git a/config.mk.in b/config.mk.in
deleted file mode 100644
index 64e3847..0000000
--- a/config.mk.in
+++ /dev/null
@@ -1,13 +0,0 @@
-CC = @CC@
-AR = @AR@
-RANLIB = @RANLIB@
-
-CPPFLAGS = @CPPFLAGS@
-CFLAGS = @CFLAGS@
-LDFLAGS = @LDFLAGS@
-
-AIO_LIBS = @AIO_LIBS@
-SELINUX_LIBS = @SELINUX_LIBS@
-CRYPTO_LIB = @CRYPTO_LIB@
-
-LTP_CHECK_CGROUPSTATS_HEADER = @LTP_CHECK_CGROUPSTATS_HEADER@
diff --git a/configure.ac b/configure.ac
index 9642084..1a0d788 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,28 +1,63 @@
 AC_PREREQ([2.61])
-AC_INIT([ltp], [cvs], [ltp-results@lists.sourceforge.net])
-AM_INIT_AUTOMAKE([1.10])
+AC_INIT([ltp], [LTP_VERSION], [ltp-results@lists.sourceforge.net])
+AC_CONFIG_AUX_DIR([.])
+AM_INIT_AUTOMAKE
 AC_CONFIG_HEADERS([include/config.h])
-AC_CONFIG_FILES([config.mk m4/Makefile])
-
-AC_CANONICAL_HOST
-AC_PROG_CC
-AC_PROG_AR
-AC_PROG_RANLIB
-
-AC_CHECK_HEADERS_ONCE([ \
-ifaddrs.h \
-sys/capability.h \
-sys/inotify.h \
-sys/epoll.h \
+AC_CONFIG_FILES([ \
+    include/mk/config.mk \
+    lib/ltp.pc \
+    ltp-devel.spec \
+    m4/Makefile \
+    README.ltp-devel \
 ])
 
+AM_CONDITIONAL(CROSS_COMPILATION, test x$cross_compiling = xyes)
+
+AC_CANONICAL_HOST
+
+AC_PROG_CC
+AC_PROG_AR
+AC_PROG_LEX
+AC_PROG_RANLIB
+AC_PROG_YACC
+
+AC_PREFIX_DEFAULT(/opt/ltp)
+
+AC_CHECK_HEADERS_ONCE([ \
+    dmapi.h \
+    ifaddrs.h \
+    libaio.h \
+    mm.h \
+    linux/genetlink.h \
+    linux/module.h \
+    linux/netlink.h \
+    sys/acl.h \
+    sys/epoll.h \
+    sys/inotify.h \
+    sys/jfsdmapi.h \
+    sys/prctl.h \
+])
+
+# open_hpi_testsuite does NOT fit cleanly in the build. BLAH.
+#AC_CONFIG_SUBDIRS([ \
+#    testcases/open_hpi_testsuite/ \
+#    testcases/kernel/syscalls/pcllib/ \
+#])
+
+AC_CONFIG_SUBDIRS([ \
+    testcases/kernel/syscalls/pcllib/ \
+])
+
+LTP_CHECK_CAPABILITY_SUPPORT
+LTP_CHECK_CRYPTO
+LTP_CHECK_LINUX_PTRACE
+LTP_CHECK_SELINUX
 LTP_CHECK_SYSCALL_EVENTFD
 LTP_CHECK_SYSCALL_MODIFY_LDT
+LTP_CHECK_SYSCALL_NUMA
+LTP_CHECK_SYSCALL_QUOTACTL
 LTP_CHECK_SYSCALL_SIGNALFD
 LTP_CHECK_SYSCALL_UNSHARE
-LTP_CHECK_SELINUX
-LTP_CHECK_CRYPTO
 LTP_CHECK_TASKSTATS
-LTP_CHECK_CGROUPSTATS
 
 AC_OUTPUT
diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 0000000..b5f5b4c
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,29 @@
+#
+#    Doc Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir			?= ..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+RECURSIVE_TARGETS	:= install
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/doc/man1/Makefile b/doc/man1/Makefile
index 87f4e59..faa189e 100644
--- a/doc/man1/Makefile
+++ b/doc/man1/Makefile
@@ -1,12 +1,27 @@
+#
+#    man1 Makefile.
+# 
+#    Copyright (C) 2009, Cisco Systems Inc.
+# 
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+# 
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+# 
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Garrett Cooper, July 2009
+#
 
+MANPREFIX		:= 1
 
-PREFIX=/usr
-MANPAGES=ltp-bump.1 doio.1 iogen.1 ltp-pan.1
+top_srcdir		?= ../..
 
-all:
-
-install: $(MANPAGES)
-	@set -e; for i in $(MANPAGES); do \
-		install -D -m 644 $$i $(DESTDIR)/$(PREFIX)/share/man/man1/$$i; \
-	done
-
+include $(top_srcdir)/include/mk/man.mk
diff --git a/doc/man3/Makefile b/doc/man3/Makefile
index bcd2a26..46d6729 100644
--- a/doc/man3/Makefile
+++ b/doc/man3/Makefile
@@ -1,15 +1,27 @@
+#
+#    man3 Makefile.
+# 
+#    Copyright (C) 2009, Cisco Systems Inc.
+# 
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+# 
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+# 
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Garrett Cooper, July 2009
+#
 
+MANPREFIX		:= 3
 
-PREFIX=/usr
-MANPAGES=forker.3 get_attrib.3 parse_open_flags.3 parse_opts.3 \
-	parse_ranges.3 pattern.3 random_range.3 random_range_seed.3 \
-	rmobj.3 string_to_tokens.3 str_to_bytes.3 tst_res.3 \
-	tst_set_error.3 tst_sig.3 tst_tmpdir.3 usctest.3 write_log.3
+top_srcdir		?= ../..
 
-all:
-
-install: $(MANPAGES)
-	@set -e; for i in $(MANPAGES); do \
-		install -D -m 644 $$i $(DESTDIR)/$(PREFIX)/share/man/man3/$$i; \
-	done
-
+include $(top_srcdir)/include/mk/man.mk
diff --git a/include/Makefile b/include/Makefile
index b5944aa..ba34d1f 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -1,27 +1,47 @@
+#
+#    include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
+top_srcdir		?= ..
 
-PREFIX=/opt/ltp
-HEADERS=compiler.h dataascii.h databin.h file_lock.h forker.h open_flags.h \
-	pattern.h random_range.h rmobj.h search_path.h string_to_tokens.h \
-	str_to_bytes.h test.h tlibio.h usctest.h write_log.h \
-	linux_syscall_numbers.h libtestsuite.h config.h
+include $(top_srcdir)/include/mk/env_pre.mk
 
-.PHONY: all install
-all:
+clean:: ac-clean
 
-install: $(HEADERS)
-	@set -e; for i in $(HEADERS); do \
-		install -D -m 644 $$i $(DESTDIR)/$(PREFIX)/include/ltp/$$i; \
-	done
+INSTALL_DIR		:= $(includedir)
 
-.PHONY: clean distclean maintainer-clean
-clean: ac-clean
-distclean: clean ac-distclean
-maintainer-clean: distclean ac-maintainer-clean
+INSTALL_MODE		:= 00644
 
-.PHONY: ac-clean ac-distclean ac-maintainerclean
-ac-clean:
-ac-distclean:
-	rm -f config.h
-ac-maintainer-clean:
-	rm -f config.h.in
+INSTALL_TARGETS		:= *.h
+
+MAKE_TARGETS		:=
+
+.PHONY: ac-clean ac-distclean ac-maintainer-clean distclean maintainer-clean
+distclean:: clean ac-distclean
+maintainer-clean:: distclean ac-maintainer-clean
+ac-clean ac-distclean::
+	$(RM) -f config.h
+ac-maintainer-clean::
+	$(RM) -f config.h.in
+
+$(eval $(call generate_vpath_rule,h))
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/include/mk/automake.mk b/include/mk/automake.mk
new file mode 100644
index 0000000..420ae05
--- /dev/null
+++ b/include/mk/automake.mk
@@ -0,0 +1,105 @@
+#
+#    Autotools include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# Override these variables to use non-system available tools.
+ACLOCAL		?= aclocal
+AUTOCONF	?= autoconf
+AUTOHEADER	?= autoheader
+AUTOMAKE	?= automake
+
+.PHONY: autotools
+autotools: aclocal autoconf autoheader automake
+
+.PHONY: aclocal
+aclocal: aclocal.m4
+
+aclocal.m4: $(wildcard m4/*.m4) m4/ltp-version.m4
+	$(ACLOCAL) -I m4
+
+.PHONY: autoconf
+autoconf: configure
+
+configure: configure.ac aclocal.m4
+	$(AUTOCONF)
+
+.PHONY: autoheader
+autoheader: include/config.h.in
+
+include:
+	mkdir -p "$@"
+
+include/config.h.in: configure.ac $(wildcard m4/*.m4) m4/ltp-version.m4
+	$(AUTOHEADER)
+	touch $@
+
+include/config.h: include/config.h.default | include
+	cp $^ $@
+
+m4/ltp-version.m4: ChangeLog
+	sed -n '1{s:LTP-:AC_DEFUN([LTP_VERSION],[:;s:$$:]):;p;q}' $< > $@
+
+.PHONY: automake
+AUTOMAKE_FILES := config.guess config.sub install-sh missing stamp-h1
+automake: aclocal $(AUTOMAKE_FILES)
+$(AUTOMAKE_FILES): m4/Makefile.in
+m4/Makefile.in: m4/Makefile.am
+	$(AUTOMAKE) -c -a
+
+.PHONY: ac-clean ac-distclean ac-maintainer-clean
+ac-clean::
+	$(RM) -rf autom4te.cache
+	$(RM) -f aclocal.m4 config.log config.status
+	$(RM) -f include/config.h* include/stamp-h1 m4/Makefile m4/ltp-version.m4
+	-for d in $(AUTOCONFED_SUBDIRS); do \
+	    $(MAKE) -C "$(top_srcdir)/$$d" $@; \
+	done
+
+ac-distclean:: ac-clean
+ac-maintainer-clean:: ac-distclean
+	$(RM) -f aclocal.m4 configure $(AUTOMAKE_FILES) m4/Makefile.in
+
+AUTOCONFED_SUBDIRS	= \
+			testcases/kernel/syscalls/pcllib
+
+# Don't include config.h, or make will (rightfully) whine about overriding
+# rules.
+AUTOGENERATED_FILES	= \
+			include/mk/config.mk	\
+			lib/ltp.pc		\
+			m4/Makefile		\
+			ltp-devel.spec		\
+			README.ltp-devel
+
+distclean:: %: clean ac-distclean include-clean
+	-for d in $(AUTOCONFED_SUBDIRS); do \
+	    $(MAKE) -C "$(top_srcdir)/$$d" $@; \
+	done
+	$(RM) -f $(AUTOGENERATED_FILES)
+
+maintainer-clean:: distclean ac-maintainer-clean
+
+$(AUTOGENERATED_FILES): $(top_builddir)/config.status
+	$(SHELL) $^
+
+$(top_builddir)/config.status:
+	$(MAKE) -C $(top_srcdir) help; \
+	exit 1
diff --git a/include/mk/config.mk.in b/include/mk/config.mk.in
new file mode 100644
index 0000000..b651141
--- /dev/null
+++ b/include/mk/config.mk.in
@@ -0,0 +1,70 @@
+#
+#    config.mk.in.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# See this page for more info about LEX*:
+# http://www.gnu.org/software/hello/manual/autoconf/Particular-Programs.html
+
+# Application specifying variables. You should never have to change these.
+AR			:= @AR@
+CC			:= @CC@
+LEX			:= @LEX@
+RANLIB			:= @RANLIB@
+YACC			:= @YACC@
+
+AIO_LIBS		:= @AIO_LIBS@
+CAP_LIBS		:= @CAP_LIBS@
+CRYPTO_LIBS		:= @CRYPTO_LIBS@
+LEXLIB			:= @LEXLIB@
+NUMA_LIBS		:= @NUMA_LIBS@
+SELINUX_LIBS		:= @SELINUX_LIBS@
+
+prefix			:= @prefix@
+
+datarootdir		:= @datarootdir@
+includedir		:= @includedir@
+exec_prefix		:= @exec_prefix@
+libdir			:= @libdir@
+mandir			:= @mandir@
+
+RPMBUILD		?= rpmbuild
+
+CPPFLAGS		:= @CPPFLAGS@
+CFLAGS			:= @CFLAGS@
+LDLIBS			:= @LIBS@
+LDFLAGS			:= @LDFLAGS@
+
+DEBUG_CFLAGS		?= -g
+DEBUG_CXXFLAGS		?= $(DEBUG_CFLAGS)
+
+# Please see README.mk-devel about -fstrict-aliasing.
+OPT_CFLAGS		?= -O2 -fno-strict-aliasing -pipe
+OPT_CXXFLAGS		?= $(OPT_CFLAGS)
+
+WCFLAGS			?= -Wall
+WCXXFLAGS		?= $(WCFLAGS)
+
+CPPFLAGS		+= -I$(DESTDIR)/$(includedir)
+LDFLAGS			+= -L$(DESTDIR)/$(libdir) $(WLDFLAGS)
+CFLAGS			+= $(DEBUG_CFLAGS) $(OPT_CFLAGS) $(WCFLAGS)
+CXXFLAGS		+= $(DEBUG_CXXFLAGS) $(OPT_CXXFLAGS) $(WCXXFLAGS)
+
+export datarootdir includedir libdir mandir prefix
diff --git a/include/mk/env_post.mk b/include/mk/env_post.mk
new file mode 100644
index 0000000..b144334
--- /dev/null
+++ b/include/mk/env_post.mk
@@ -0,0 +1,69 @@
+#
+#    Environment post-setup Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+ENV_PRE_LOADED			?= $(error You must load env_pre.mk before including this file)
+
+include $(top_srcdir)/include/mk/functions.mk
+
+ifndef ENV_POST_LOADED
+ENV_PRE_LOADED = 1
+
+# Default source search path. Modify as necessary, but I would call that
+# poor software design if you need more than one search directory, and
+# would suggest creating a general purpose static library to that end.
+$(eval $(call generate_vpath_rule,c))
+
+# For config.h, et all.
+CPPFLAGS			+= -I$(top_builddir)/include
+
+MAKE_TARGETS			?= $(notdir $(patsubst %.c,%,$(wildcard $(abs_srcdir)/*.c)))
+
+CLEAN_TARGETS			+= $(MAKE_TARGETS) *.o *.pyc
+
+# Majority of the files end up in testcases/bin...
+INSTALL_DIR			?= testcases/bin
+
+ifeq ($(strip $(INSTALL_DIR)),)
+INSTALL_DIR			:= $(error You must define INSTALL_DIR before including this file)
+endif
+
+# Value specified by INSTALL_DIR isn't an absolute path, so let's tack on $(prefix).
+ifneq ($(patsubst /%,,$(INSTALL_DIR)),)
+INSTALL_DIR			:= $(prefix)/$(INSTALL_DIR)
+endif
+
+# Glob any possible expressions, but make sure to zap the $(abs_srcdir)
+# reference at the start of the filename instead of using $(notdir), so that
+# way we don't accidentally nuke the relative path from $(abs_srcdir) that
+# may have been set in the Makefile.
+INSTALL_TARGETS			:= $(addprefix $(abs_srcdir)/,$(wildcard $(INSTALL_TARGETS)))
+INSTALL_TARGETS			:= $(patsubst $(abs_srcdir)/%,%,$(INSTALL_TARGETS))
+
+# The large majority of the files that we install are going to be apps and
+# scripts, so let's chmod them like that.
+INSTALL_MODE			?= 00775
+
+$(foreach im_dir,$(sort $(dir $(INSTALL_TARGETS) $(MAKE_TARGETS))),$(eval $(call generate_install_rule_dir_dep,$(im_dir),$(INSTALL_DIR))))
+$(foreach install_target,$(INSTALL_TARGETS),$(eval $(call generate_install_rule,$(install_target),$(abs_srcdir),$(INSTALL_DIR))))
+$(foreach make_target,$(MAKE_TARGETS),$(eval $(call generate_install_rule,$(make_target),$(abs_builddir),$(INSTALL_DIR))))
+
+endif
diff --git a/include/mk/env_pre.mk b/include/mk/env_pre.mk
new file mode 100644
index 0000000..f785501
--- /dev/null
+++ b/include/mk/env_pre.mk
@@ -0,0 +1,67 @@
+#
+#    Make pre-include environment Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
+# This Makefile must be included first. NO IF'S, AND'S, OR BUT'S.
+#
+# This sets the stage for all operations required within Makefiles.
+#
+
+ifndef ENV_PRE_LOADED
+ENV_PRE_LOADED = 1
+
+# Get the absolute path for the source directory.
+top_srcdir			?= $(error You must define top_srcdir before including this file)
+
+# Where's the root source directory?
+abs_top_srcdir			:= $(abspath $(top_srcdir))
+
+#
+# Where's the root object directory?
+#
+# Just in case it's not specified, set it to the top srcdir (because the user
+# must not have wanted out of build tree support)...
+#
+top_builddir			?= $(top_srcdir)
+
+# We need the absolute path...
+abs_top_builddir		:= $(abspath $(top_builddir))
+
+# Where's the root object directory?
+builddir			:= .
+
+abs_builddir			:= $(CURDIR)
+
+# Where's the source located at? Squish all of the / away by using abspath...
+abs_srcdir			:= $(abspath $(abs_top_srcdir)/$(subst $(abs_top_builddir),,$(abs_builddir)))
+
+srcdir				:= $(or $(subst $(abs_top_srcdir)/,,$(abs_srcdir)),.)
+
+ifneq ($(abs_builddir),$(abs_srcdir))
+export OUT_OF_BUILD_TREE	:= 1
+endif
+
+# We can piece together where we're located in the source and object trees with
+# just these two vars and $(CURDIR).
+export abs_top_srcdir abs_top_builddir
+
+-include $(top_builddir)/include/mk/config.mk
+
+endif
diff --git a/include/mk/functions.mk b/include/mk/functions.mk
new file mode 100644
index 0000000..941a379
--- /dev/null
+++ b/include/mk/functions.mk
@@ -0,0 +1,89 @@
+#
+#  A Makefile with a collection of reusable functions.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+#
+# Generate the directory install dependency separate from generate_install_rule
+# to avoid noise from Make about redefining existing targets, for good reason.
+#
+# 1 -> The base install directory, based off $(prefix), or another
+#      $(prefix)-like variable. Automatically gets $(DESTDIR) tacked on it.
+# 2 -> The install target. This can be relative to $(srcdir), but will most
+#      likely be `empty'.
+#
+define generate_install_rule_dir_dep
+
+#$$(warning Called generate_install_rule_dir_dep for $(abspath $(DESTDIR)/$(1)/$(2)) )
+
+$(abspath $(DESTDIR)/$(1)/$(2)):
+	mkdir -p "$$@"
+
+endef
+
+#
+# Generate an install rule which also creates the install directory if needed
+# to avoid unnecessary bourne shell based for-loops and install errors, as well
+# as adhoc install rules.
+#
+# 1 -> Target basename.
+# 2 -> Source directory.
+# 3 -> Destination directory.
+#
+define generate_install_rule
+
+CLEAN_TARGETS		+= $(DESTDIR)/$(3)/$(1)
+INSTALL_FILES		+= $(DESTDIR)/$(3)/$(1)
+
+# $$(warning Called generate_install_rule for $(2)/$(1) -> $(DESTDIR)/$(3)/$(1) )
+
+# XXX (garrcoop): FIXME -- relative path install based logic doesn't work
+# 100%, as proven by `testcases/network/tcp_cmds/generate'. This needs to be
+# seriously fixed.
+$(DESTDIR)/$(3)/$(1): $$(abspath $(DESTDIR)/$(3))
+ifdef INSTALL_PRE
+	@echo "Executing preinstall command."
+	$$(INSTALL_PRE)
+endif
+	test -d "$$(@D)" || mkdir -p "$$(@D)"
+	install -m $$(INSTALL_MODE) "$(2)/$(1)" "$$@"
+ifdef INSTALL_POST
+	@echo "Executing preinstall command."
+	$$(INSTALL_POST)
+endif
+endef
+
+#
+# Create a vpath rule for a given extension.
+#
+# 1 -> file extension
+# 2 -> search directory. Defaults to $(abs_srcdir) if not specified.
+# 
+define generate_vpath_rule
+vpath %.$(1)	$$(if $(2),$(2),$(abs_srcdir))
+endef
+
+#
+# Set SUBDIRS to the subdirectories where Makefiles were found.
+# 
+define get_make_dirs
+SUBDIRS	?= $$(subst $(abs_srcdir)/,,$$(patsubst %/Makefile,%,$$(wildcard $(abs_srcdir)/*/Makefile)))
+SUBDIRS	:= $$(filter-out $$(FILTER_OUT_DIRS),$$(SUBDIRS))
+endef
diff --git a/include/mk/generic_leaf_target.inc b/include/mk/generic_leaf_target.inc
new file mode 100644
index 0000000..3f362d0
--- /dev/null
+++ b/include/mk/generic_leaf_target.inc
@@ -0,0 +1,99 @@
+#
+#    Generic leaf rules include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+#
+# generic_leaf_target
+#
+# Generate a set of basic targets (all, clean, install) for a leaf directory
+# (no subdirectories).
+#
+# $(INSTALL_FILES) -> install
+#
+# Helpful variables are:
+#
+# $(MAKE_TARGETS)		: What to execute as direct dependencies of
+# 				  all.
+# 				  1. Defaults to the basename of the targets
+# 				     produced by the %.c -> % implicit pattern
+# 				     rules, e.g. the MAKE_TARGET in a directory
+# 				     like the following:
+#
+#				  $$ ls /bar
+# 				  foo.c
+#
+#				     Would be `foo'. Similarly, the following
+#				     dir structure:
+#
+#				  $$ ls /bar
+# 				  foo.c zanzibar.c
+#
+#				     Would be `foo zanzibar'.
+#
+#				  2. If you define MAKE_TARGETS as an empty
+#				     string, this will override the defaults.
+#				     I did this to avoid providing too much
+#				     rope to hang one's self in the event of
+#				     unwanted behavior.
+#
+# $(CLEAN_TARGETS)		: What targets should be cleaned (must be
+#				  real files). This will automatically append
+#				  adds the .o suffix to all files referenced
+#				  by $(MAKE_TARGETS)) to CLEAN_TARGETS, if
+#				  MAKE_TARGETS wasn't defined (see
+#				  $(MAKE_TARGETS)).
+# $(INSTALL_MODE)		: What mode should we using when calling
+# 				  install(1)?
+#
+# Also, if you wish to change the installation directory, from the set default
+# (testcases/bin) you must do something like either one of the following items:
+#
+# Method A:
+#
+# INSTALL_DIR			:= /path/to/installdir/from/$(DESTDIR)/$(prefix)
+#
+# e.g. if I wanted to install my binaries in testcases/bin, I would do:
+#
+# INSTALL_DIR			:= testcases/bin
+#
+# in my calling Makefile.
+#
+# Or Method B:
+#
+# INSTALL_DIR			:= /path/to/installdir/from/$(DESTDIR)
+#
+# e.g. if I wanted to install my binaries in $(libdir) (which may not exist
+# outside of $(prefix) right now, but could in the future), I could do the
+# following:
+#
+# INSTALL_DIR			:= $(libdir)
+#
+
+.PHONY: all clean install
+
+all: $(MAKE_TARGETS) | $(builddir)
+
+clean::
+	-$(RM) -f $(CLEAN_TARGETS)
+
+install: $(INSTALL_FILES) | $(INSTALL_DEPS)
+
+# vim: syntax=make
diff --git a/include/mk/generic_leaf_target.mk b/include/mk/generic_leaf_target.mk
new file mode 100644
index 0000000..cb6db5e
--- /dev/null
+++ b/include/mk/generic_leaf_target.mk
@@ -0,0 +1,24 @@
+#
+#    Generic leaf include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+include $(top_srcdir)/include/mk/env_post.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.inc
diff --git a/include/mk/generic_trunk_target.inc b/include/mk/generic_trunk_target.inc
new file mode 100644
index 0000000..35b2569
--- /dev/null
+++ b/include/mk/generic_trunk_target.inc
@@ -0,0 +1,94 @@
+#
+#    Generic trunk rules include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+#
+# generic_trunk_target
+#
+# Generate a set of recursive targets to apply over a trunk directory (has
+# directories) -- optionally with a set of trunk-based files.
+#
+# All variables in this canned define are essentially the same as
+# generic_leaf_target, with the exception that the install flow for local
+# targets is:
+#
+# $(INSTALL_FILES) -> trunk-install -> install (recursive)
+#
+# All recursive targets are traverse SUBDIRS as defined by the user, or if
+# undefined, defaults to any subdirectories where Makefile's are contained
+# within.
+#
+# generic_trunk_target specific variables are:
+#
+# RECURSIVE_TARGETS		: a list of targets to apply over an entire
+# 				  directory tree. This defaults to
+# 				  `all install'.
+#
+# See generic_leaf_target, generic_target_env_setup, and get_make_dirs for
+# more details and design notes.
+#
+
+include $(top_srcdir)/include/mk/functions.mk
+
+RECURSIVE_TARGETS		?= all install
+
+$(eval $(get_make_dirs))
+
+.PHONY: $(RECURSIVE_TARGETS) $(addprefix trunk-,$(RECURSIVE_TARGETS))
+
+$(SUBDIRS): %:
+	mkdir -m 00755 -p "$@"
+
+trunk-all: $(MAKE_TARGETS)
+
+trunk-clean:: | $(SUBDIRS)
+	$(if $(strip $(CLEAN_TARGETS)),$(RM) -f $(CLEAN_TARGETS))
+
+trunk-install: $(INSTALL_FILES)
+
+# Avoid creating duplicate .PHONY references to all, clean, and install. IIRC,
+# I've seen some indeterministic behavior when one does this in the past with
+# GNU Make...
+.PHONY: $(filter-out $(RECURSIVE_TARGETS),all clean install)
+all: trunk-all
+
+clean:: trunk-clean
+	set -e; for dir in $(SUBDIRS); do \
+	    $(MAKE) -C "$$dir" -f "$(abs_srcdir)/$$dir/Makefile" $@; \
+	done
+ifneq ($(abs_builddir),$(abs_srcdir))
+	$(RM) -Rf $(SUBDIRS)
+endif
+
+install: trunk-install
+
+# Print out CURDIR to check for a recursion issue.
+ifeq ($(strip $(SUBDIRS)),)
+	$(warning CURDIR is: $(CURDIR))
+	$(error SUBDIRS empty -- did you want generic_leaf_target instead?)
+else
+$(RECURSIVE_TARGETS): %: | $(SUBDIRS)
+	@set -e; for dir in $(SUBDIRS); do \
+	    $(MAKE) -C $$dir -f "$(abs_srcdir)/$$dir/Makefile" $@; \
+	done
+endif
+
+# vim: syntax=make
diff --git a/include/mk/generic_trunk_target.mk b/include/mk/generic_trunk_target.mk
new file mode 100644
index 0000000..f480ef6
--- /dev/null
+++ b/include/mk/generic_trunk_target.mk
@@ -0,0 +1,24 @@
+#
+#    Generic trunk include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+include $(top_srcdir)/include/mk/env_post.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.inc
diff --git a/include/mk/lib.mk b/include/mk/lib.mk
new file mode 100644
index 0000000..b429899
--- /dev/null
+++ b/include/mk/lib.mk
@@ -0,0 +1,63 @@
+#
+#    library include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# Makefile to include for libraries.
+
+# Change the default goal when nothing is specified to install because we want
+# to ensure that the libraries get installed ASAP so they can be properly
+# linked in with all required apps.
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+.DEFAULT_GOAL	:= install
+
+INSTALL_DIR	:= $(libdir)
+
+# An extension of generic_leaf_target, strictly for libraries.
+.PHONY: install_headers
+
+ifndef LIB
+$(error You must define LIB when including this Makefile)
+endif
+
+install_headers: $(addprefix $(DESTDIR)/$(includedir)/,$(notdir $(HEADER_FILES)))
+
+.DEFAULT_GOAL	:= install
+
+INSTALL_MODE	?= 00664
+
+MAKE_TARGETS	:= $(LIB)
+
+LIBSRCS		?= $(wildcard $(abs_srcdir)/*.c)
+LIBSRCS		:= $(subst $(abs_srcdir)/,,$(wildcard $(abspath $(LIBSRCS))))
+
+LIBOBJS		:= $(LIBSRCS:.c=.o)
+
+$(LIB): $(notdir $(LIBOBJS))
+	if [ -z "$(strip $^)" ] ; then \
+		echo "Cowardly refusing to create empty archive"; \
+		exit 1; \
+	fi
+	$(AR) -rc "$@" $^
+	$(RANLIB) "$@"
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/include/mk/man.mk b/include/mk/man.mk
new file mode 100644
index 0000000..f66f61a
--- /dev/null
+++ b/include/mk/man.mk
@@ -0,0 +1,40 @@
+#
+#    Manpage include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+ifeq ($(strip $(MANPREFIX)),)
+$(error $$(MANPREFIX) not defined)
+endif
+
+include $(top_srcdir)/include/mk/config.mk
+
+MANPAGES	?= $(wildcard $(abs_srcdir)/*.$(MANPREFIX))
+
+clean:
+	-(cd $(DESTDIR)/$(mandir)/man$(MANPREFIX) && $(RM) -f $(MANPAGES))
+
+$(DESTDIR)/$(mandir)/man$(MANPREFIX):
+	mkdir -p "$@"
+
+install: $(DESTDIR)/$(mandir)/man$(MANPREFIX) $(MANPAGES)
+	@set -e; for i in $(filter-out $<,$^); do \
+	    install -m 644 "$$i" "$</$$i"; \
+	done
diff --git a/include/mk/testcases.mk b/include/mk/testcases.mk
new file mode 100644
index 0000000..1482ed6
--- /dev/null
+++ b/include/mk/testcases.mk
@@ -0,0 +1,27 @@
+#
+#    testcases include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_DIR		:= testcases/bin
+
+LDLIBS			+= -lltp
diff --git a/lib/Makefile b/lib/Makefile
index 7e3b81a..10d8d6a 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,28 +1,41 @@
+#
+#    lib Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-PREFIX=/opt/ltp
+top_srcdir		?= ..
 
-CFLAGS+= -Wall
-CPPFLAGS+= -I../include 
-ifeq ($(shell uname -s),HP-UX)
-CFLAGS+=-Ae -D_LARGEFILE64_SOURCE +DA1.1
-endif
+include $(top_srcdir)/include/mk/env_pre.mk
+
 ifeq ($(UCLINUX),1)
-CFLAGS+= -D_USC_LIB_ -D__UCLIBC__ -DUCLINUX
+CFLAGS			+= -D_USC_LIB_ -D__UCLIBC__ -DUCLINUX
 endif
-LDFLAGS+=
-TARGET=libltp.a
-SRCS=$(wildcard *.c)
-OBJS=$(patsubst %.c,%.o,$(SRCS))
 
-all: $(TARGET)
+LIB			:= libltp.a
 
-$(TARGET): $(OBJS)
-	$(AR) -cr $@ $^
+pc_file			:= $(DESTDIR)/$(datarootdir)/pkgconfig/ltp.pc
 
-clean:
-	rm -f $(TARGET) *.o
+INSTALL_TARGETS		:= $(pc_file)
 
-install: $(TARGET)
-	install -D -m 644 $(TARGET) $(DESTDIR)/$(PREFIX)/lib$(LIBSUFFIX)/$(TARGET)
-	install -D -m 644 ltp.pc $(DESTDIR)/$(PREFIX)/share/pkgconfig/ltp.pc
+$(pc_file):
+	test -d "$(@D)" || mkdir -p "$(@D)"
+	install -m $(INSTALL_MODE) "$(builddir)/$(@F)" "$@"
 
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/lib/ltp.pc.in b/lib/ltp.pc.in
new file mode 100644
index 0000000..814b537
--- /dev/null
+++ b/lib/ltp.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+
+Name: LTP
+Description: Linux Test Project
+Version: 1.0
+Libs: -L${libdir} -lltp
+Cflags: -I${includedir}
diff --git a/ltp-devel.spec b/ltp-devel.spec
deleted file mode 100644
index e82cceb..0000000
--- a/ltp-devel.spec
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# RPM Package Manager (RPM) spec file for ltp-devel
-#
-Summary: Linux Test Project (LTP) Software Development Kit (SDK)
-Name: ltp-devel
-Version: 2.0
-Release: 0.0
-Prefix: /opt/ltp
-License: GPL
-Group: Development/Libraries
-URL: http://www.linuxtestproject.org
-Vendor: IBM Corp
-Packager: Subrata Modak <subrata.modak@@in.ibm.com>
-AutoReqProv:    0
-Provides:       LTP
-#ExclusiveArch:  i386
-ExclusiveOS:    linux
-%description
-This is a development package of the Linux Test Project (LTP).
-It is intended to be used to build testcases using the provided API.
-%files
-/opt/ltp/lib/libltp.a
-/usr/share/pkgconfig/ltp.pc
-/opt/ltp/bin/ltp-pan
-/opt/ltp/bin/ltp-scanner
-/opt/ltp/bin/ltp-bump
-/opt/ltp/include/linux_syscall_numbers.h
-/opt/ltp/include/libtestsuite.h
-/opt/ltp/include/usctest.h
-/opt/ltp/include/string_to_tokens.h
-/opt/ltp/include/str_to_bytes.h
-/opt/ltp/include/databin.h
-/opt/ltp/include/open_flags.h
-/opt/ltp/include/write_log.h
-/opt/ltp/include/dataascii.h
-/opt/ltp/include/forker.h
-/opt/ltp/include/compiler.h
-/opt/ltp/include/test.h
-/opt/ltp/include/tlibio.h
-/opt/ltp/include/pattern.h
-/opt/ltp/include/file_lock.h
-/opt/ltp/include/random_range.h
-/opt/ltp/include/search_path.h
-/opt/ltp/include/rmobj.h
-/usr/share/man/man3/tst_tmpdir.3
-/usr/share/man/man3/random_range_seed.3
-/usr/share/man/man3/pattern.3
-/usr/share/man/man3/parse_ranges.3
-/usr/share/man/man3/usctest.3
-/usr/share/man/man3/random_range.3
-/usr/share/man/man3/forker.3
-/usr/share/man/man3/rmobj.3
-/usr/share/man/man3/parse_open_flags.3
-/usr/share/man/man3/tst_res.3
-/usr/share/man/man3/write_log.3
-/usr/share/man/man3/str_to_bytes.3
-/usr/share/man/man3/tst_set_error.3
-/usr/share/man/man3/parse_opts.3
-/usr/share/man/man3/string_to_tokens.3
-/usr/share/man/man3/tst_sig.3
-/usr/share/man/man3/get_attrib.3
-/usr/share/man/man1/ltp-pan.1
-/usr/share/man/man1/doio.1
-/usr/share/man/man1/iogen.1
-/usr/share/man/man1/ltp-bump.1
-# Post-install stuff would go here.
-#EOF
-
diff --git a/ltp-devel.spec.in b/ltp-devel.spec.in
new file mode 100644
index 0000000..83d0942
--- /dev/null
+++ b/ltp-devel.spec.in
@@ -0,0 +1,68 @@
+#
+# RPM Package Manager (RPM) spec file for ltp-devel
+#
+Summary: Linux Test Project (LTP) Software Development Kit (SDK)
+Name: ltp-devel
+Version: 2.0
+Release: 0.0
+Prefix: @prefix@
+License: GPL
+Group: Development/Libraries
+URL: http://www.linuxtestproject.org
+Vendor: IBM Corp
+Packager: Subrata Modak <subrata.modak@@in.ibm.com>
+AutoReqProv:    0
+Provides:       LTP
+#ExclusiveArch:  i386
+ExclusiveOS:    linux
+%description
+This is a development package of the Linux Test Project (LTP).
+It is intended to be used to build testcases using the provided API.
+%files
+@prefix@/lib/libltp.a
+@datarootdir@/pkgconfig/ltp.pc
+@prefix@/bin/ltp-pan
+@prefix@/bin/ltp-scanner
+@prefix@/bin/ltp-bump
+@prefix@/include/linux_syscall_numbers.h
+@prefix@/include/libtestsuite.h
+@prefix@/include/usctest.h
+@prefix@/include/string_to_tokens.h
+@prefix@/include/str_to_bytes.h
+@prefix@/include/databin.h
+@prefix@/include/open_flags.h
+@prefix@/include/write_log.h
+@prefix@/include/dataascii.h
+@prefix@/include/forker.h
+@prefix@/include/compiler.h
+@prefix@/include/test.h
+@prefix@/include/tlibio.h
+@prefix@/include/pattern.h
+@prefix@/include/file_lock.h
+@prefix@/include/random_range.h
+@prefix@/include/search_path.h
+@prefix@/include/rmobj.h
+@mandir@/man3/tst_tmpdir.3
+@mandir@/man3/random_range_seed.3
+@mandir@/man3/pattern.3
+@mandir@/man3/parse_ranges.3
+@mandir@/man3/usctest.3
+@mandir@/man3/random_range.3
+@mandir@/man3/forker.3
+@mandir@/man3/rmobj.3
+@mandir@/man3/parse_open_flags.3
+@mandir@/man3/tst_res.3
+@mandir@/man3/write_log.3
+@mandir@/man3/str_to_bytes.3
+@mandir@/man3/tst_set_error.3
+@mandir@/man3/parse_opts.3
+@mandir@/man3/string_to_tokens.3
+@mandir@/man3/tst_sig.3
+@mandir@/man3/get_attrib.3
+@mandir@/man1/ltp-pan.1
+@mandir@/man1/doio.1
+@mandir@/man1/iogen.1
+@mandir@/man1/ltp-bump.1
+# Post-install stuff would go here.
+#EOF
+
diff --git a/m4/GNUmakefile b/m4/GNUmakefile
index a1641d4..79c8ae2 100644
--- a/m4/GNUmakefile
+++ b/m4/GNUmakefile
@@ -1,12 +1,37 @@
+#
+#    m4 Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
+top_srcdir		?= ..
 
-PREFIX=/opt/ltp
-M4MACROS=$(notdir $(wildcard *.m4))
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all:
+M4MACROS		:= $(notdir $(wildcard *.m4))
 
-install: $(M4MACROS)
-	for i in $(M4MACROS); do \
-		install -D -m 644 $$i $(DESTDIR)/$(PREFIX)/share/aclocal/$$i; \
-	done
+INSTALL_DIR		:= $(datarootdir)/aclocal
 
+INSTALL_MODE		:= 00644
+
+INSTALL_TARGETS		:= $(M4_MACROS)
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/m4/ltp-cap.m4 b/m4/ltp-cap.m4
new file mode 100644
index 0000000..5f8d969
--- /dev/null
+++ b/m4/ltp-cap.m4
@@ -0,0 +1,43 @@
+dnl
+dnl Copyright (c) Cisco Systems Inc., 2009
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program;  if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+dnl Author: Garrett Cooper <yanegomi@gmail.com>
+dnl
+
+dnl
+dnl LTP_CHECK_CAPABILITY_SUPPORT
+dnl ----------------------------
+dnl
+AC_DEFUN([LTP_CHECK_CAPABILITY_SUPPORT],[
+AC_CHECK_HEADERS(sys/capability.h,[
+	AC_CHECK_HEADERS(attr/xattr.h)
+	LTP_CAPABILITY_SUPPORT=yes
+	AC_CHECK_LIB(cap,cap_free,[
+		AC_CHECK_LIB(cap,cap_from_text,[
+			AC_CHECK_LIB(cap,cap_set_proc,[
+				AC_CHECK_LIB(cap,cap_compare,[
+					CAP_LIBS="-lcap"
+				])
+			])
+		])
+	])
+	AC_CHECK_DECLS([CAP_BSET_DROP, CAP_BSET_READ, PR_CAPBSET_READ, cap_compare, cap_free, cap_from_text, cap_get_proc, cap_set_file, cap_set_flag, cap_set_proc, cap_to_text],[],[],[dnl
+#include <sys/capability.h>
+]) dnl AC_CHECK_DECLS
+])]
+AC_SUBST(CAP_LIBS)
+)
diff --git a/m4/ltp-crypto.m4 b/m4/ltp-crypto.m4
index ad2795b..3dfc512 100644
--- a/m4/ltp-crypto.m4
+++ b/m4/ltp-crypto.m4
@@ -4,6 +4,6 @@
 dnl
 AC_DEFUN([LTP_CHECK_CRYPTO],
 [dnl
-AC_CHECK_HEADERS(openssl/sha.h,[CRYPTO_LIB=-lcrypto],[CRYPTO_LIB=])
-AC_SUBST(CRYPTO_LIB)
+AC_CHECK_HEADERS(openssl/sha.h,[CRYPTO_LIBS=-lcrypto],[CRYPTO_LIBS=])
+AC_SUBST(CRYPTO_LIBS)
 ])
diff --git a/m4/ltp-numa.m4 b/m4/ltp-numa.m4
new file mode 100644
index 0000000..9a9947c
--- /dev/null
+++ b/m4/ltp-numa.m4
@@ -0,0 +1,38 @@
+dnl
+dnl Copyright (c) Cisco Systems Inc., 2009
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program;  if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+dnl Author: Garrett Cooper <yanegomi@gmail.com>
+dnl
+
+dnl
+dnl LTP_CHECK_SYSCALL_NUMA
+dnl ----------------------------
+dnl
+AC_DEFUN([LTP_CHECK_SYSCALL_NUMA],
+[dnl
+AC_CHECK_HEADERS(numa.h,[
+	LTP_SYSCALL_NUMA_HEADER=yes
+	AC_CHECK_FUNCS(numa_alloc_onnode,numa_move_pages)
+	AC_CHECK_HEADERS(numaif.h,[LTP_SYSCALL_NUMAIF_HEADER=yes], [], [], [
+#include <numa.h>
+])
+]
+	AC_CHECK_LIB(numa,numa_available,[
+		NUMA_LIBS="-lnuma"
+	])
+AC_SUBST(NUMA_LIBS)
+)])
diff --git a/m4/ltp-ptrace.m4 b/m4/ltp-ptrace.m4
new file mode 100644
index 0000000..3c7441c
--- /dev/null
+++ b/m4/ltp-ptrace.m4
@@ -0,0 +1,38 @@
+dnl
+dnl Copyright (c) Jiri Palecek 2009
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program;  if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+
+
+AC_DEFUN([LTP_CHECK_LINUX_PTRACE],
+_LTP_CHECK_LINUX_PTRACE
+)dnl
+
+dnl _LTP_CHECK_LINUX_PTRACE
+dnl ----------------------------------------
+dnl
+dnl Check for ptrace support
+dnl in commit 016ae219 in July 2008
+dnl
+
+AC_DEFUN([_LTP_CHECK_LINUX_PTRACE],[
+AC_CHECK_HEADERS(linux/ptrace.h,[
+	LINUX_PTRACE_HEADER=yes
+	AC_CHECK_DECLS([PTRACE_GETSIGINFO, PTRACE_O_TRACEVFORKDONE, PTRACE_SETOPTIONS],[],[],[dnl
+#include <linux/ptrace.h>
+]) dnl AC_CHECK_DECLS
+]) dnl AC_CHECK_HEADERS
+]) dnl _LTP_CHECK_TASKSTATS_FREEPAGES
diff --git a/m4/ltp-quota.m4 b/m4/ltp-quota.m4
new file mode 100644
index 0000000..f638ada
--- /dev/null
+++ b/m4/ltp-quota.m4
@@ -0,0 +1,45 @@
+dnl
+dnl Copyright (c) Cisco Systems, Inc, 2008
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program;  if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+
+dnl
+dnl LTP_CHECK_SYSCALL_QUOTACTL
+dnl ----------------------------
+dnl
+AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[AC_TRY_COMPILE([
+#include <linux/quota.h>
+#include <xfs/xqm.h>
+#include <linux/dqblk_v1.h>
+#include <linux/dqblk_v2.h>
+#include <unistd.h>
+int main(void) {
+    return quotactl(Q_GETINFO, (const char *)NULL, geteuid(void), (caddr_t)NULL);
+}
+],[has_old_quotactl="yes"],[AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/quota.h>
+#include <unistd.h>
+int main(void) {
+    return quotactl(Q_GETINFO, (const char *)NULL, geteuid(void), (caddr_t)NULL);
+}
+],[has_new_quotactl="yes"],[AC_MSG_WARN([Couldn't find functional copy of quotactl])])])
+if test "$has_old_quotactl" = "yes"; then
+	AC_DEFINE(HAS_OLD_QUOTACTL,1,[Define to 1 if you have the old implementation of quotactl])
+elif test "$has_new_quotactl" = "yes"; then
+	AC_DEFINE(HAS_NEW_QUOTACTL,1,[Define to 1 if you have the new implementation of quotactl])
+fi
+])
diff --git a/m4/ltp-taskstats.m4 b/m4/ltp-taskstats.m4
index 63e10a2..070902f 100644
--- a/m4/ltp-taskstats.m4
+++ b/m4/ltp-taskstats.m4
@@ -28,11 +28,13 @@
 dnl in commit 016ae219 in July 2008
 dnl
 
-AC_DEFUN([_LTP_CHECK_TASKSTATS_FREEPAGES],
-[dnl
-AC_CHECK_MEMBERS([struct taskstats.freepages_count, struct taskstats.nvcsw, struct taskstats.read_bytes],[],[],[dnl
+AC_DEFUN([_LTP_CHECK_TASKSTATS_FREEPAGES],[
+AC_CHECK_HEADERS(linux/taskstats.h,[
+	LINUX_TASKSTATS_HEADER=yes
+	AC_CHECK_MEMBERS([struct taskstats.freepages_count, struct taskstats.nvcsw, struct taskstats.read_bytes],[],[],[dnl
+#include <asm/types.h>
 #include <linux/types.h>
 #include <linux/taskstats.h>
-])
-]dnl
-)dnl
+]) dnl AC_CHECK_MEMBERS
+]) dnl AC_CHECK_HEADERS
+]) dnl _LTP_CHECK_TASKSTATS_FREEPAGES
diff --git a/pan/Makefile b/pan/Makefile
index 234f9d4..d973d58 100644
--- a/pan/Makefile
+++ b/pan/Makefile
@@ -1,24 +1,49 @@
+#
+#    pan Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-LOADLIBES += -lm
-LFLAGS += -l -w
-CFLAGS += -w 
-PREFIX = /opt/ltp
+top_srcdir		?= ..
 
-all: ltp-pan ltp-bump ltp-scanner
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/functions.mk
 
-ltp-pan: ltp-pan.o zoolib.o splitstr.o
+CPPFLAGS		+= -I$(abs_srcdir)
 
+LDLIBS			+= -lm $(LEXLIB)
+
+LFLAGS			+= -l
+
+INSTALL_DIR		:= bin
+
+MAKE_TARGETS		:= ltp-bump ltp-pan ltp-scanner
 
 ltp-bump: ltp-bump.o zoolib.o
 
+ltp-pan: ltp-pan.o zoolib.o splitstr.o
 
 ltp-scanner: scan.o ltp-scanner.o reporter.o tag_report.o symbol.o splitstr.o debug.o
 
+# flex does some whacky junk when it generates files on the fly, so let's make
+# sure gcc doesn't get lost...
+$(eval $(call generate_vpath_rule,c,$(abs_srcdir):$(abs_builddir)))
+$(eval $(call generate_vpath_rule,l))
 
-install: ltp-pan ltp-bump ltp-scanner
-	install -D ltp-scanner $(DESTDIR)/$(PREFIX)/bin/ltp-scanner
-	install -D ltp-pan $(DESTDIR)/$(PREFIX)/bin/ltp-pan
-	install -D ltp-bump $(DESTDIR)/$(PREFIX)/bin/ltp-bump
-
-clean:
-	rm -f *.o ltp-pan ltp-bump ltp-scanner
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/runltp b/runltp
index 88ec237..41e7a14 100755
--- a/runltp
+++ b/runltp
@@ -80,14 +80,14 @@
     export TMPBASE="/tmp"
     export PATH="${PATH}:${LTPROOT}/testcases/bin"
 
-    [ -d $LTPROOT/testcases/bin ] ||
+    [ -d "$LTPROOT/testcases/bin" ] ||
     {
         echo "FATAL: Test suite not installed correctly"
         echo "INFO: as root user type 'make ; make install'"
         exit 1
     }
 
-    [ -e $LTPROOT/pan/ltp-pan ] ||
+    [ -e "$LTPROOT/bin/ltp-pan" ] ||
     {
         echo "FATAL: Test suite driver 'ltp-pan' not found"
         echo "INFO: as root user type 'make ; make install'"
@@ -97,7 +97,7 @@
 
 version_of_ltp()
 {
-    head -n 1  $LTPROOT/ChangeLog
+    cat "$LTPROOT/Version"
     exit 0
 }
 
@@ -189,11 +189,11 @@
     local DURATION=""
     local CMDFILEADDR=""
     local FAILCMDFILE=""
-	local INJECT_KERNEL_FAULT=""
-	local INJECT_KERNEL_FAULT_PERCENTAGE=""
-	local INJECT_FAULT_LOOPS_PER_TEST=""
-	local VALGRIND_CHECK=""
-	local VALGRIND_CHECK_TYPE=""
+    local INJECT_KERNEL_FAULT=""
+    local INJECT_KERNEL_FAULT_PERCENTAGE=""
+    local INJECT_FAULT_LOOPS_PER_TEST=""
+    local VALGRIND_CHECK=""
+    local VALGRIND_CHECK_TYPE=""
     local LOGFILE_NAME=""
     local LOGFILE=""
     local OUTPUTFILE_NAME=""
@@ -205,7 +205,7 @@
     local TAG_RESTRICT_STRING=""
     local PAN_COMMAND=""
     local DEFAULT_FILE_NAME_GENERATION_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
-    version_date=`head -n 1 $LTPROOT/ChangeLog`
+    version_date=$(cat "$LTPROOT/Version")
 
     while getopts a:c:C:d:D:f:F:ehi:g:l:m:M:Nno:pqr:s:S:t:T:vw:x:b:B: arg
     do  case $arg in
@@ -753,7 +753,7 @@
     fi
 
     [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
-    PAN_COMMAND="${LTPROOT}/pan/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
+    PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
     -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE"
     if [ ! -z "$VERBOSE_MODE" ] ; then
       echo "COMMAND:    $PAN_COMMAND"
@@ -829,7 +829,7 @@
 
     # Some tests need to run inside the "bin" directory.
     cd "${LTPROOT}/testcases/bin"
-    ${LTPROOT}/pan/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
+    "${LTPROOT}/bin/ltp-pan" $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE
      
     if [ $? -eq 0 ]; then
       echo "INFO: ltp-pan reported all tests PASS"
diff --git a/runltplite.sh b/runltplite.sh
index 5c2e03d..b764257 100755
--- a/runltplite.sh
+++ b/runltplite.sh
@@ -57,7 +57,7 @@
         exit 1
     }
 
-    [ -e $LTPROOT/pan/ltp-pan ] ||
+    [ -e $LTPROOT/bin/ltp-pan ] ||
     {
         echo "FATAL: Test suite driver 'ltp-pan' not found"
         echo "INFO: as root user type 'make ; make install'"
@@ -284,7 +284,7 @@
     }
 
     [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
-    PAN_COMMAND="${LTPROOT}/pan/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
+    PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
     -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE"
     if [ ! -z "$VERBOSE_MODE" ] ; then
       echo "COMMAND:    $PAN_COMMAND"
@@ -295,7 +295,7 @@
     #$PAN_COMMAND #Duplicated code here, because otherwise if we fail, only "PAN_COMMAND" gets output
     # Some tests need to run inside the "bin" directory.
     cd "${LTPROOT}/testcases/bin"
-    ${LTPROOT}/pan/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
+    ${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
     -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE
     
     if [ $? -eq 0 ]; then
diff --git a/runtest/Makefile b/runtest/Makefile
new file mode 100644
index 0000000..0907ef6
--- /dev/null
+++ b/runtest/Makefile
@@ -0,0 +1,39 @@
+#
+#    runtest Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir		?= ..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_DIR		:= runtest
+
+# We don't want to copy over directories like CVS, STAX, etc, or the Makefile
+# itself.
+UNWANTED_FILES		:= Makefile CVS STAX
+
+INSTALL_MODE		:= 00644
+
+INSTALL_TARGETS		:= $(filter-out $(UNWANTED_FILES),$(notdir $(patsubst $(abs_srcdir)/%,%,$(wildcard $(abs_srcdir)/*))))
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/runtest/fs b/runtest/fs
index fce6a71..c9f2755 100644
--- a/runtest/fs
+++ b/runtest/fs
@@ -29,15 +29,15 @@
 gf28 growfiles -W gf28 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u gfsparse-2-$$
 gf29 growfiles -W gf29 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u gfsparse-3-$$
 gf30 growfiles -W gf30 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/rwtest01%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/rwtest01%f
 
 #must be run as root
 #iogen01 iogen -i 120s -s read,write 500b:doio.f1.$$ 1000b:doio.f2.$$ | doio -akv -n 2
-iogen01 export LTPROOT; rwtest -N iogen01 -i 120s -s read,write -Da -Dv -n 2 500b:doio.f1.$$ 1000b:doio.f2.$$
+iogen01 export LTPROOT; rwtest.sh -N iogen01 -i 120s -s read,write -Da -Dv -n 2 500b:doio.f1.$$ 1000b:doio.f2.$$
 
 fs_inod01 fs_inod $TMP 10 10 10
 linker01 linktest.pl 1000 1000
diff --git a/runtest/io b/runtest/io
index e48542d..75274c4 100644
--- a/runtest/io
+++ b/runtest/io
@@ -1,3 +1,3 @@
 #AIO01 & AIO02 tests to be run
 aio01 aio01
-aio02 (cd $LTPROOT/testcases/kernel/io/aio/aio02/; ./runfstests.sh cases/aio_tio)
+aio02 runfstests.sh aio_tio
diff --git a/runtest/ipv6_expect b/runtest/ipv6_expect
new file mode 100644
index 0000000..522082e
--- /dev/null
+++ b/runtest/ipv6_expect
@@ -0,0 +1,2 @@
+#DESCRIPTION:IPV6 related tests which require expect
+rlogin6 rlogin01 -6
diff --git a/runtest/ipv6_noexpect b/runtest/ipv6_noexpect
index c0703d7..14b80e8 100644
--- a/runtest/ipv6_noexpect
+++ b/runtest/ipv6_noexpect
@@ -1,11 +1,11 @@
 #DESCRIPTION:IPV6 related tests that do not require expect
-echo6 export TCbin=$LTPROOT/testcases/network/ipv6/echo6;echo601
-finger6 finger601
-ftp6 export TCbin=$LTPROOT/testcases/network/ipv6/ftp6; ftp01
-perf_lan6 export TCbin=$LTPROOT/testcases/network/ipv6/perf_lan6; perf_lan6
-ping6 ping601
-rcp6 export TCbin=$LTPROOT/testcases/network/ipv6/rcp6; rcp01
-rsh6 rsh01
-rwho6 rwho01
-sendfile6 export TCbin=$LTPROOT/testcases/network/ipv6/sendfile6; sendfile60
-tcpdump6 tcpdump601
+echo6 echo01 -6
+finger6 finger01
+ftp6 ftp01 -6
+perf_lan6 perf_lan -6
+ping6 ping01 -6
+rcp6 rcp01 -6
+rsh6 rsh01 -6
+rwho6 rwho01 -6
+sendfile6 sendfile01 -6
+tcpdump6 tcpdump01 -6
diff --git a/runtest/ltp-aiodio.part4 b/runtest/ltp-aiodio.part4
index caa8a4f..4b9dab4 100644
--- a/runtest/ltp-aiodio.part4
+++ b/runtest/ltp-aiodio.part4
@@ -2,69 +2,67 @@
 # Malcles Jacky: this file is a copy from Ridgeway Marty's aio script
 #     goal: all aio tests using the same framework
 #Running dio_sparse & dirty tests
-DI000 testcases/kernel/io/ltp-aiodio/dirty
-DS000 testcases/kernel/io/ltp-aiodio/dio_sparse
-DI001 testcases/kernel/io/ltp-aiodio/dirty
-DS001 testcases/kernel/io/ltp-aiodio/dio_sparse
-DI002 testcases/kernel/io/ltp-aiodio/dirty
-DS002 testcases/kernel/io/ltp-aiodio/dio_sparse
-DI003 testcases/kernel/io/ltp-aiodio/dirty
-DS003 testcases/kernel/io/ltp-aiodio/dio_sparse
-DI004 testcases/kernel/io/ltp-aiodio/dirty
-DS004 testcases/kernel/io/ltp-aiodio/dio_sparse
-DI005 testcases/kernel/io/ltp-aiodio/dirty
-DS005 testcases/kernel/io/ltp-aiodio/dio_sparse
-DI006 testcases/kernel/io/ltp-aiodio/dirty
-DS006 testcases/kernel/io/ltp-aiodio/dio_sparse
-DI007 testcases/kernel/io/ltp-aiodio/dirty
-DS007 testcases/kernel/io/ltp-aiodio/dio_sparse
-DI008 testcases/kernel/io/ltp-aiodio/dirty
-DS008 testcases/kernel/io/ltp-aiodio/dio_sparse
-DI009 testcases/kernel/io/ltp-aiodio/dirty
-DS009 testcases/kernel/io/ltp-aiodio/dio_sparse
+DI000 dirty
+DS000 dio_sparse
+DI001 dirty
+DS001 dio_sparse
+DI002 dirty
+DS002 dio_sparse
+DI003 dirty
+DS003 dio_sparse
+DI004 dirty
+DS004 dio_sparse
+DI005 dirty
+DS005 dio_sparse
+DI006 dirty
+DS006 dio_sparse
+DI007 dirty
+DS007 dio_sparse
+DI008 dirty
+DS008 dio_sparse
+DI009 dirty
+DS009 dio_sparse
 #iteration on dio_sparse
-DIO00 testcases/kernel/io/ltp-aiodio/dio_sparse
-DIO01 testcases/kernel/io/ltp-aiodio/dio_sparse
-DIO02 testcases/kernel/io/ltp-aiodio/dio_sparse
-DIO03 testcases/kernel/io/ltp-aiodio/dio_sparse
-DIO04 testcases/kernel/io/ltp-aiodio/dio_sparse
-DIO05 testcases/kernel/io/ltp-aiodio/dio_sparse
-DIO06 testcases/kernel/io/ltp-aiodio/dio_sparse
-DIO07 testcases/kernel/io/ltp-aiodio/dio_sparse
-DIO08 testcases/kernel/io/ltp-aiodio/dio_sparse
-DIO09 testcases/kernel/io/ltp-aiodio/dio_sparse
+DIO00 dio_sparse
+DIO01 dio_sparse
+DIO02 dio_sparse
+DIO03 dio_sparse
+DIO04 dio_sparse
+DIO05 dio_sparse
+DIO06 dio_sparse
+DIO07 dio_sparse
+DIO08 dio_sparse
+DIO09 dio_sparse
 #Running aiodio_append
-AD000 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
-AD001 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
-AD002 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
-AD003 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
-AD004 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
-AD005 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
-AD006 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
-AD007 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
-AD008 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
-AD009 testcases/kernel/io/ltp-aiodio/aiodio_append /test/aiodio/file2
+AD000 aiodio_append /test/aiodio/file2
+AD001 aiodio_append /test/aiodio/file2
+AD002 aiodio_append /test/aiodio/file2
+AD003 aiodio_append /test/aiodio/file2
+AD004 aiodio_append /test/aiodio/file2
+AD005 aiodio_append /test/aiodio/file2
+AD006 aiodio_append /test/aiodio/file2
+AD007 aiodio_append /test/aiodio/file2
+AD008 aiodio_append /test/aiodio/file2
+AD009 aiodio_append /test/aiodio/file2
 #Running dio_append
-ADI000 testcases/kernel/io/ltp-aiodio/dio_append
-ADI001 testcases/kernel/io/ltp-aiodio/dio_append
-ADI002 testcases/kernel/io/ltp-aiodio/dio_append
-ADI003 testcases/kernel/io/ltp-aiodio/dio_append
-ADI004 testcases/kernel/io/ltp-aiodio/dio_append
-ADI005 testcases/kernel/io/ltp-aiodio/dio_append
-ADI006 testcases/kernel/io/ltp-aiodio/dio_append
-ADI007 testcases/kernel/io/ltp-aiodio/dio_append
-ADI008 testcases/kernel/io/ltp-aiodio/dio_append
-ADI009 testcases/kernel/io/ltp-aiodio/dio_append
+ADI000 dio_append
+ADI001 dio_append
+ADI002 dio_append
+ADI003 dio_append
+ADI004 dio_append
+ADI005 dio_append
+ADI006 dio_append
+ADI007 dio_append
+ADI008 dio_append
+ADI009 dio_append
 #Running dio_truncate
-DIT000 testcases/kernel/io/ltp-aiodio/dio_truncate 
-DIT001 testcases/kernel/io/ltp-aiodio/dio_truncate 
-DIT002 testcases/kernel/io/ltp-aiodio/dio_truncate
+DIT000 dio_truncate 
+DIT001 dio_truncate 
+DIT002 dio_truncate
 #Running read_checkzero
-#testcases/kernel/io/ltp-aiodio/read_checkzero 
+#gread_checkzero 
 #Running ltp-diorh
-DOR000 testcases/kernel/io/ltp-aiodio/ltp-diorh /test/aiodio/file2
-DOR001 testcases/kernel/io/ltp-aiodio/ltp-diorh /test/aiodio/file3
-DOR002 testcases/kernel/io/ltp-aiodio/ltp-diorh /test/aiodio/file4
-DOR003 testcases/kernel/io/ltp-aiodio/ltp-diorh /test/aiodio/file5
-
-
+DOR000 ltp-diorh /test/aiodio/file2
+DOR001 ltp-diorh /test/aiodio/file3
+DOR002 ltp-diorh /test/aiodio/file4
+DOR003 ltp-diorh /test/aiodio/file5
diff --git a/runtest/ltplite b/runtest/ltplite
index 48ad88c..b6fb07f 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -1078,10 +1078,10 @@
 #gf28 growfiles -W gf28 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u gfsparse-2-$$
 #gf29 growfiles -W gf29 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u gfsparse-3-$$
 gf30 growfiles -W gf30 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/rwtest01%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/rwtest01%f
 
 
diff --git a/runtest/lvm.part1 b/runtest/lvm.part1
index b2e9c05..26e98eb 100644
--- a/runtest/lvm.part1
+++ b/runtest/lvm.part1
@@ -30,11 +30,11 @@
 gf128 growfiles -W gf128 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /test/growfiles/msdos/gfsparse-2-$$
 gf129 growfiles -W gf129 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /test/growfiles/msdos/gfsparse-3-$$
 gf130 growfiles -W gf130 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /test/growfiles/msdos/gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/msdos/rwtest01%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/msdos/rwtest02%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/msdos/rwtest03%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/msdos/rwtest04%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/msdos/rwtest05%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/msdos/rwtest01%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/msdos/rwtest02%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/msdos/rwtest03%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/msdos/rwtest04%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/msdos/rwtest05%f
 # Check the Reiserfs filesystem
 gf202 growfiles -W gf202 -d /test/growfiles/reiser -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
 gf203 growfiles -W gf203 -d /test/growfiles/reiser -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
@@ -66,11 +66,11 @@
 gf228 growfiles -W gf228 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /test/growfiles/reiser/gfsparse-2-$$
 gf229 growfiles -W gf229 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /test/growfiles/reiser/gfsparse-3-$$
 gf230 growfiles -W gf230 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /test/growfiles/reiser/gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/reiser/rwtest06%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/reiser/rwtest07%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/reiser/rwtest08%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/reiser/rwtest09%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/reiser/rwtest10%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/reiser/rwtest06%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/reiser/rwtest07%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/reiser/rwtest08%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/reiser/rwtest09%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/reiser/rwtest10%f
 # Check the EXT2 filesystem
 gf302 growfiles -W gf302 -d /test/growfiles/ext2 -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
 gf303 growfiles -W gf303 -d /test/growfiles/ext2 -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
@@ -102,11 +102,11 @@
 gf328 growfiles -W gf328 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /test/growfiles/ext2/gfsparse-2-$$
 gf329 growfiles -W gf329 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /test/growfiles/ext2/gfsparse-3-$$
 gf330 growfiles -W gf330 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /test/growfiles/ext2/gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ext2/rwtest11%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ext2/rwtest12%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ext2/rwtest13%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ext2/rwtest14%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ext2/rwtest15%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ext2/rwtest11%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ext2/rwtest12%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ext2/rwtest13%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ext2/rwtest14%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ext2/rwtest15%f
 # Check an NFS filesystem
 gf402 growfiles -W gf402 -d /test/growfiles/nfs -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
 gf403 growfiles -W gf403 -d /test/growfiles/nfs -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
@@ -138,11 +138,11 @@
 gf428 growfiles -W gf428 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /test/growfiles/nfs/gfsparse-2-$$
 gf429 growfiles -W gf429 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /test/growfiles/nfs/gfsparse-3-$$
 gf430 growfiles -W gf430 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /test/growfiles/nfs/gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/nfs/rwtest16%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/nfs/rwtest17%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/nfs/rwtest18%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/nfs/rwtest19%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/nfs/rwtest20%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/nfs/rwtest16%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/nfs/rwtest17%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/nfs/rwtest18%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/nfs/rwtest19%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/nfs/rwtest20%f
 # Check a Ram Disk filesystem
 gf502 growfiles -W gf502 -d /test/growfiles/ramdisk -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
 gf503 growfiles -W gf503 -d /test/growfiles/ramdisk -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
@@ -174,11 +174,11 @@
 gf528 growfiles -W gf528 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /test/growfiles/ramdisk/gfsparse-2-$$
 gf529 growfiles -W gf529 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /test/growfiles/ramdisk/gfsparse-3-$$
 gf530 growfiles -W gf530 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /test/growfiles/ramdisk/gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ramdisk/rwtest21%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ramdisk/rwtest22%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ramdisk/rwtest23%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ramdisk/rwtest24%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ramdisk/rwtest25%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ramdisk/rwtest21%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ramdisk/rwtest22%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ramdisk/rwtest23%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ramdisk/rwtest24%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ramdisk/rwtest25%f
 # Check the MINIX filesystem
 gf602 growfiles -W gf602 -d /test/growfiles/minix -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
 gf603 growfiles -W gf603 -d /test/growfiles/minix -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
@@ -210,8 +210,8 @@
 gf628 growfiles -W gf628 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /test/growfiles/minix/gfsparse-2-$$
 gf629 growfiles -W gf629 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /test/growfiles/minix/gfsparse-3-$$
 gf630 growfiles -W gf630 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /test/growfiles/minix/gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/minix/rwtest26%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/minix/rwtest27%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/minix/rwtest28%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/minix/rwtest29%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/minix/rwtest30%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/minix/rwtest26%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/minix/rwtest27%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/minix/rwtest28%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/minix/rwtest29%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/minix/rwtest30%f
diff --git a/runtest/lvm.part2 b/runtest/lvm.part2
index f0dbf32..d2c3ea3 100644
--- a/runtest/lvm.part2
+++ b/runtest/lvm.part2
@@ -29,11 +29,11 @@
 gf728 growfiles -W gf728 -d /test/growfiles/ext3 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u gfsparse-2-$$
 gf729 growfiles -W gf729 -d /test/growfiles/ext3 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u gfsparse-3-$$
 gf730 growfiles -W gf730 -d /test/growfiles/ext3 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ext3/rwtest11%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ext3/rwtest12%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ext3/rwtest13%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ext3/rwtest14%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ext3/rwtest15%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ext3/rwtest11%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ext3/rwtest12%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ext3/rwtest13%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ext3/rwtest14%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ext3/rwtest15%f
 # Check the JFS filesystem
 gf802 growfiles -W gf802 -d /test/growfiles/jfs -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
 gf803 growfiles -W gf803 -d /test/growfiles/jfs -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
@@ -65,8 +65,8 @@
 gf828 growfiles -W gf828 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /test/growfiles/jfs/gfsparse-2-$$
 gf829 growfiles -W gf829 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /test/growfiles/jfs/gfsparse-3-$$
 gf830 growfiles -W gf830 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /test/growfiles/jfs/gf-sync-$$
-rwtest11 export LTPROOT; rwtest -N rwtest11 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/jfs/rwtest11%f
-rwtest12 export LTPROOT; rwtest -N rwtest12 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/jfs/rwtest12%f
-rwtest13 export LTPROOT; rwtest -N rwtest13 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/jfs/rwtest13%f
-rwtest14 export LTPROOT; rwtest -N rwtest14 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/jfs/rwtest14%f
-rwtest15 export LTPROOT; rwtest -N rwtest15 -c -q -i 50 -T 64b 500b:/test/growfiles/jfs/rwtest15%f
+rwtest11 export LTPROOT; rwtest.sh -N rwtest11 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/jfs/rwtest11%f
+rwtest12 export LTPROOT; rwtest.sh -N rwtest12 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/jfs/rwtest12%f
+rwtest13 export LTPROOT; rwtest.sh -N rwtest13 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/jfs/rwtest13%f
+rwtest14 export LTPROOT; rwtest.sh -N rwtest14 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/jfs/rwtest14%f
+rwtest15 export LTPROOT; rwtest.sh -N rwtest15 -c -q -i 50 -T 64b 500b:/test/growfiles/jfs/rwtest15%f
diff --git a/runtest/nfs b/runtest/nfs
index 5922070..4f5d876 100644
--- a/runtest/nfs
+++ b/runtest/nfs
@@ -2,16 +2,16 @@
 #
 # PLEASE READ THE README FILE IN /nfs BEFORE RUNNING THESE.
 #
-nfs01 export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/network/nfs/nfs01; nfs01
-nfs02 export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/network/nfs/nfs02; nfs02
-nfs03 export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/network/nfs/nfs03; nfs03
-nfs04 export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/network/nfs/nfs04; nfs04
-nfslock01 export VERSION; export TCbin=$LTPROOT/testcases/network/nfs/nfslock01; nfslock01
+nfs01 export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/bin nfs01
+nfs02 export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/bin nfs02
+nfs03 export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/bin nfs03
+nfs04 export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/bin nfs04
+nfslock01 export VERSION; nfslock01
 
 # This will run 1 thread on 20 directories with 50 files in each.
-nfsstress export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/network/nfs/nfsstress; nfsstress 20 50 1
+nfsstress export VERSION SOCKET_TYPE; nfsstress 20 50 1
 
-nfsstat01 export VERSION; export TCbin=$LTPROOT/testcases/network/nfs/nfsstat01; nfsstat01
+nfsstat01 export VERSION; export TCbin=$LTPROOT/testcases/bin; nfsstat01
 nfsx-linux export VERSION SOCKET_TYPE; export TCbin=$LTPROOT/testcases/bin; fsx.sh
 
 
diff --git a/runtest/numa b/runtest/numa
index 2a8a2a5..cd2bb4b 100644
--- a/runtest/numa
+++ b/runtest/numa
@@ -1,7 +1,7 @@
 Numa-testcases numa01.sh
 move_pages01 move_pages.sh 01
 move_pages02 move_pages.sh 02
-move_pages03 move_pages.sh 03
+move_pages03 cd $LTPROOT/bin && chown root move_pages03 && chmod 04755 && move_pages.sh 03
 move_pages04 move_pages.sh 04
 move_pages05 move_pages.sh 05
 move_pages06 move_pages.sh 06
@@ -9,6 +9,4 @@
 move_pages08 move_pages.sh 08
 move_pages09 move_pages.sh 09
 move_pages10 move_pages.sh 10
-move_pages11 move_pages.sh 11
-
-
+move_pages11 cd $LTPROOT/bin && chown root move_pages11 && chmod 04755 && move_pages.sh 11
diff --git a/runtest/rpc b/runtest/rpc
index e813d85..c9e5f0d 100644
--- a/runtest/rpc
+++ b/runtest/rpc
@@ -2,8 +2,8 @@
 #
 # PLEASE READ THE README FILE IN /rpc BEFORE RUNNING THESE.
 #
-run_rpc_tests.sh export TCbin=$LTPROOT/testcases/network/rpc/rpc-tirpc-full-test-suite; run_rpc_tests.sh
-rpc01 export TCbin=$LTPROOT/testcases/network/rpc/basic_tests/rpc01; rpc01
-rpcinfo export TCbin=$LTPROOT/testcases/network/rpc/basic_tests/rpcinfo01; rpcinfo01
-rup export TCbin=$LTPROOT/testcases/network/rpc/basic_tests/rup; rup01
-rusers export TCbin=$LTPROOT/testcases/network/rpc/basic_tests/rusers; rusers01
+run_rpc_tests.sh run_rpc_tests.sh
+rpc01 rpc01
+rpcinfo rpcinfo01
+rup rup01
+rusers rusers01
diff --git a/runtest/scsi_debug.part1 b/runtest/scsi_debug.part1
index 1ca8d5f..b0f6cb7 100644
--- a/runtest/scsi_debug.part1
+++ b/runtest/scsi_debug.part1
@@ -31,11 +31,11 @@
 gf228 growfiles -W gf228 -d /test/growfiles/reiser -b -D 0 -w -g 16b -C 1 -b -i 1000 -u gfsparse-2-$$
 gf229 growfiles -W gf229 -d /test/growfiles/reiser -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u gfsparse-3-$$
 gf230 growfiles -W gf230 -d /test/growfiles/reiser -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/reiser/rwtest06%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/reiser/rwtest07%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/reiser/rwtest08%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/reiser/rwtest09%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/reiser/rwtest10%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/reiser/rwtest06%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/reiser/rwtest07%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/reiser/rwtest08%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/reiser/rwtest09%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/reiser/rwtest10%f
 # Check the EXT2 filesystem
 gf301 growfiles -W gf301 -d /test/growfiles/ext2 -b -e 1 -u -i 0 -L 20 -w -C 1 -l -I r -T 10 glseek20 glseek20.2
 gf302 growfiles -W gf302 -d /test/growfiles/ext2 -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
@@ -67,11 +67,11 @@
 gf328 growfiles -W gf328 -d /test/growfiles/ext2 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u gfsparse-2-$$
 gf329 growfiles -W gf329 -d /test/growfiles/ext2 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u gfsparse-3-$$
 gf330 growfiles -W gf330 -d /test/growfiles/ext2 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ext2/rwtest11%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ext2/rwtest12%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ext2/rwtest13%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ext2/rwtest14%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ext2/rwtest15%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ext2/rwtest11%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ext2/rwtest12%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ext2/rwtest13%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ext2/rwtest14%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ext2/rwtest15%f
 # Check the EXT3 filesystem
 gf701 growfiles -W gf701 -d /test/growfiles/ext3 -b -e 1 -u -i 0 -L 20 -w -C 1 -l -I r -T 10 glseek20 glseek20.2gf702 growfiles -W gf702 -d /test/growfiles/ext3 -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
 gf703 growfiles -W gf703 -d /test/growfiles/ext3 -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
@@ -102,11 +102,11 @@
 gf728 growfiles -W gf728 -d /test/growfiles/ext3 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u gfsparse-2-$$
 gf729 growfiles -W gf729 -d /test/growfiles/ext3 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u gfsparse-3-$$
 gf730 growfiles -W gf730 -d /test/growfiles/ext3 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ext3/rwtest11%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ext3/rwtest12%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ext3/rwtest13%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ext3/rwtest14%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ext3/rwtest15%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/ext3/rwtest11%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/ext3/rwtest12%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/ext3/rwtest13%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/ext3/rwtest14%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/ext3/rwtest15%f
 # Check the MSDOS filesystem
 gf101 growfiles -W gf101 -d /test/growfiles/msdos -b -e 1 -u -i 0 -L 20 -w -C 1 -l -I r -T 10 glseek20 glseek20.2
 gf102 growfiles -W gf102 -d /test/growfiles/msdos -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
@@ -138,11 +138,11 @@
 gf128 growfiles -W gf128 -d /test/growfiles/msdos -b -D 0 -w -g 16b -C 1 -b -i 1000 -u gfsparse-2-$$
 gf129 growfiles -W gf129 -d /test/growfiles/msdos -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u gfsparse-3-$$
 gf130 growfiles -W gf130 -d /test/growfiles/msdos -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/msdos/rwtest01%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/msdos/rwtest02%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/msdos/rwtest03%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/msdos/rwtest04%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/msdos/rwtest05%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/msdos/rwtest01%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/msdos/rwtest02%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/msdos/rwtest03%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/msdos/rwtest04%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/msdos/rwtest05%f
 # Check the Reiserfs filesystem
 gf201 growfiles -W gf201 -d /test/growfiles/reiser -b -e 1 -u -i 0 -L 20 -w -C 1 -l -I r -T 10 glseek20 glseek20.2
 gf202 growfiles -W gf202 -d /test/growfiles/reiser -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
@@ -174,9 +174,9 @@
 gf228 growfiles -W gf228 -d /test/growfiles/reiser -b -D 0 -w -g 16b -C 1 -b -i 1000 -u gfsparse-2-$$
 gf229 growfiles -W gf229 -d /test/growfiles/reiser -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u gfsparse-3-$$
 gf230 growfiles -W gf230 -d /test/growfiles/reiser -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/reiser/rwtest06%f
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/reiser/rwtest07%f
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/reiser/rwtest08%f
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/reiser/rwtest09%f
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/reiser/rwtest10%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/test/growfiles/reiser/rwtest06%f
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/test/growfiles/reiser/rwtest07%f
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/test/growfiles/reiser/rwtest08%f
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/test/growfiles/reiser/rwtest09%f
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/test/growfiles/reiser/rwtest10%f
 
diff --git a/runtest/stress.part1 b/runtest/stress.part1
index 705d9d7..dae4b8a 100644
--- a/runtest/stress.part1
+++ b/runtest/stress.part1
@@ -145,15 +145,15 @@
 gf28 growfiles -W gf28 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u gfsparse-2-$$
 gf29 growfiles -W gf29 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u gfsparse-3-$$
 gf30 growfiles -W gf30 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 gf-sync-$$
-rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$
-rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$
-rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$
-rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$
-rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/rwtest01%f
+rwtest01 export LTPROOT; rwtest.sh -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$
+rwtest02 export LTPROOT; rwtest.sh -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$
+rwtest03 export LTPROOT; rwtest.sh -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$
+rwtest04 export LTPROOT; rwtest.sh -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$
+rwtest05 export LTPROOT; rwtest.sh -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/rwtest01%f
 
 #must be run as root
 #iogen01 iogen -i 120s -s read,write 500b:doio.f1.$$ 1000b:doio.f2.$$ | doio -akv -n 2
-iogen01 export LTPROOT; rwtest -N iogen01 -i 120s -s read,write -Da -Dv -n 2 500b:doio.f1.$$ 1000b:doio.f2.$$
+iogen01 export LTPROOT; rwtest.sh -N iogen01 -i 120s -s read,write -Da -Dv -n 2 500b:doio.f1.$$ 1000b:doio.f2.$$
 
 fs_inod01 fs_inod $TMP 10 10 1
 linker01 linktest.pl
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index dc7fa9f..1c3d312 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -883,5 +883,5 @@
 mc_opts export TCsrc=$LTPROOT/testcases/network/multicast/mc_opts; mc_opts
 rpc01 export TCbin=$LTPROOT/testcases/network/rpc/basic_tests/rpc01; rpc01
 run_rpc_tests.sh export TCbin=$LTPROOT/testcases/network/rpc/rpc-tirpc-full-test-suite; run_rpc_tests.sh
-perf_lan export TCbin=$LTPROOT/testcases/network/tcp_cmds/perf_lan; perf_lan
+perf_lan perf_lan
 
diff --git a/runtest/syscalls b/runtest/syscalls
index 0f14794..a6ba25e 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -571,7 +571,7 @@
 
 move_pages01 move_pages.sh 01
 move_pages02 move_pages.sh 02
-move_pages03 move_pages.sh 03
+move_pages03 cd $LTPROOT/bin && chown root move_pages03 && chmod 04755 && move_pages.sh 03
 move_pages04 move_pages.sh 04
 move_pages05 move_pages.sh 05
 move_pages06 move_pages.sh 06
@@ -579,7 +579,7 @@
 move_pages08 move_pages.sh 08
 move_pages09 move_pages.sh 09
 move_pages10 move_pages.sh 10
-move_pages11 move_pages.sh 11
+move_pages11 cd $LTPROOT/bin && chown root move_pages11 && chmod 04755 && move_pages.sh 11
 
 mprotect01 mprotect01
 mprotect02 mprotect02
@@ -731,7 +731,8 @@
 ptrace02 ptrace02
 ptrace03 ptrace03
 ptrace04 ptrace04
-ptrace06 ptrace06
+# Broken test; See: testcases/kernel/syscalls/ptrace/Makefile for more details.
+#ptrace06 ptrace06
 
 pwrite01 pwrite01
 pwrite02 pwrite02
diff --git a/runtest/tcp_cmds_expect b/runtest/tcp_cmds_expect
new file mode 100644
index 0000000..760cdb8
--- /dev/null
+++ b/runtest/tcp_cmds_expect
@@ -0,0 +1,8 @@
+#DESCRIPTION:TCP/IP commands tests that require expect
+#
+# PLEASE READ THE README FILE IN /tcp_cmds BEFORE RUNNING THESE.
+#
+rlogin rlogin01
+telnet telnet01
+iptables iptables_tests.sh
+dhcpd dhcpd_tests.sh
diff --git a/runtest/tcp_cmds_noexpect b/runtest/tcp_cmds_noexpect
index 1cb3a63..8e47217 100644
--- a/runtest/tcp_cmds_noexpect
+++ b/runtest/tcp_cmds_noexpect
@@ -3,16 +3,16 @@
 # PLEASE READ THE README FILE IN /tcp_cmds BEFORE RUNNING THESE.
 #
 arp arp01
-echo export TCbin=$LTPROOT/testcases/network/tcp_cmds/echo; echo01 
+echo echo01
 finger finger01
-ftp export TCbin=$LTPROOT/testcases/network/tcp_cmds/ftp; ftp01
+ftp ftp01
 host host01
 netstat netstat01
-perf_lan export TCbin=$LTPROOT/testcases/network/tcp_cmds/perf_lan; perf_lan
+perf_lan perf_lan
 ping ping01
-rcp export TCbin=$LTPROOT/testcases/network/tcp_cmds/rcp; rcp01
-rdist export TCbin=$LTPROOT/testcases/network/tcp_cmds/rdist; rdist01
+rcp rcp01
+rdist rdist01
 rsh rsh01
 rwho rwho01
-sendfile export TCbin=$LTPROOT/testcases/network/tcp_cmds/sendfile; sendfile01
+sendfile sendfile01
 tcpdump tcpdump01
diff --git a/testcases/Makefile b/testcases/Makefile
index 0763070..9783d9d 100644
--- a/testcases/Makefile
+++ b/testcases/Makefile
@@ -1,21 +1,46 @@
-	SUBDIRS = `ls */Makefile | sed "s/Makefile//g" | grep -v open | grep -v pounder | grep -v DOTS | grep -v kdump | grep -v realtime | grep -v audit-test | grep -v mce-test` 
-UCLINUX_SUBDIRS = kernel
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+#
+#    testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	mkdir -p bin
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+top_srcdir		?= ..
 
-uclinux:
-	@set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-uclinux_install:
-	mkdir -p bin
-	@set -e; for i in $(UCLINUX_SUBDIRS); \
-		do $(MAKE) -C $$i uclinux_install ; done
+# XXX (garrcoop):
+# 1. mce-test doesn't fit cleanly in the build, yet.
+# 2. pounder21 is just broken.
+FILTER_OUT_DIRS		:= mce-test pounder21
 
-clean:
-	rm -rf bin/
-	@set -e; for i in $(SUBDIRS) ; do $(MAKE) -C $$i clean ; done
+# ballista needs to be fixed so that out-of-build-tree support functions
+# properly.
+ifneq ($(abs_builddir),$(abs_srcdir))
+FILTER_OUT_DIRS		+= $(if $(OUT_OF_BUILD_TREE),ballista)
+endif
 
+# XXX (garrcoop): Not sure why realtime is still in this list; this was the
+# original list of disabled items...
+ifneq ($(UCLINUX),1)
+FILTER_OUT_DIRS		+= audit-test DOTS kdump open% realtime
+else
+SUBDIRS			:= kernel
+endif
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/ballista/ballista/Makefile b/testcases/ballista/ballista/Makefile
index 870b761..084c44d 100644
--- a/testcases/ballista/ballista/Makefile
+++ b/testcases/ballista/ballista/Makefile
@@ -116,7 +116,7 @@
 	${CC} -Itemplates ${CFLAGS} pause_harness.cpp ${OBJS} -o pause_harness 
 
 # clean up everything that we build
-clean :
+clean:
 	$(MAKE) -C templates clean
 	$(RM) -f *.o *.out ballista blexer bparser callGen callGen_standAlone \
-	            genCodeCreator replacer testmarshal
+	            genCodeCreator replacer testmarshal MakefileHost MakefileTarget
diff --git a/testcases/commands/Makefile b/testcases/commands/Makefile
index 4d39e6e..277d03b 100644
--- a/testcases/commands/Makefile
+++ b/testcases/commands/Makefile
@@ -1,12 +1,26 @@
-#SUBDIRS = `ls */Makefile | sed "s/Makefile//g" | grep -v at | grep -v unzip`
-SUBDIRS = `ls */Makefile | sed "s/Makefile//g"`
+#
+#    commands test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/ade/Makefile b/testcases/commands/ade/Makefile
index 1161035..cf7a487 100644
--- a/testcases/commands/ade/Makefile
+++ b/testcases/commands/ade/Makefile
@@ -1,10 +1,30 @@
-SUBDIRS = ar objdump size ld ldd nm file
+#
+#    commands/ade test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+# XXX (garrcoop): objdump's Makefile needs fixing.
+FILTER_OUT_DIRS		:= objdump
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/ade/ar/Makefile b/testcases/commands/ade/ar/Makefile
index 027adf2..b6ab633 100644
--- a/testcases/commands/ade/ar/Makefile
+++ b/testcases/commands/ade/ar/Makefile
@@ -1,20 +1,36 @@
-CFLAGS += -w -O
-LDFLAGS += 
+#
+#    commands/ade/ar testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS) file1.o
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f ar01 ../../../bin
-	ln -f file*.in ../../../bin
-	ln -f file1.o ../../../bin
+CPPFLAGS		+= -fpic
 
-$(TARGETS):
-	$(CC) -o $@ $@.c $(CFLAGS) $(LDFLAGS)
+INSTALL_TARGETS		:= ar01 *.in
 
-clean:
-	rm -f $(TARGETS) file1.o
+MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%.obj,$(wildcard $(abs_srcdir)/*.c))
 
+$(MAKE_TARGETS): %.obj: %.o
+	mv "$^" "$@"
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/file/Makefile b/testcases/commands/ade/file/Makefile
index c2054a1..1411b3e 100644
--- a/testcases/commands/ade/file/Makefile
+++ b/testcases/commands/ade/file/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    commands/ade/file testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f file_test.sh ../../../bin/
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= file_test.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/ld/Makefile b/testcases/commands/ade/ld/Makefile
index 04c1f83..f59a136 100644
--- a/testcases/commands/ade/ld/Makefile
+++ b/testcases/commands/ade/ld/Makefile
@@ -1,16 +1,36 @@
-CFLAGS += -O -Wall -fPIC
-LOADLIBES += 
+#
+#    commands/ade/ld testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-OBJECTS=$(patsubst %.c,%.o,$(SRCS))
+top_srcdir		?= ../../../..
 
-all:  $(OBJECTS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f ld01 ../../../bin
-	ln -f *.o ../../../bin
+CPPFLAGS		+= -fPIC
 
-clean:
-	rm -f main.o d1.o f1.o rd1.o rf1.o ldmain.o lola a.out
+INSTALL_TARGETS		:= ld01
 
+MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%.obj,$(wildcard $(abs_srcdir)/*.c))
 
+$(MAKE_TARGETS): %.obj: %.o
+	mv $^ $@
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/ldd/Makefile b/testcases/commands/ade/ldd/Makefile
index 6fa3d80..eae06cd 100644
--- a/testcases/commands/ade/ldd/Makefile
+++ b/testcases/commands/ade/ldd/Makefile
@@ -1,14 +1,36 @@
-CFLAGS += -c -O -fpic
-LDFLAGS += 
+#
+#    commands/ade/ldd testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS:=$(wildcard *.c)
-TARGETS:=$(patsubst %.c,%.o,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f ldd01 ../../../bin
-	ln -f *.o ../../../bin
+CPPFLAGS		+= -fpic
 
-clean:
-	rm -f $(TARGETS)
+INSTALL_TARGETS		:= ldd01
+
+MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%.obj,$(wildcard $(abs_srcdir)/*.c))
+
+$(MAKE_TARGETS): %.obj: %.o
+	mv $^ $@
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/nm/Makefile b/testcases/commands/ade/nm/Makefile
index 4e07441..de8e3b4 100644
--- a/testcases/commands/ade/nm/Makefile
+++ b/testcases/commands/ade/nm/Makefile
@@ -1,17 +1,34 @@
-CFLAGS += -O -Wall
-LOADLIBES += 
+#
+#    commands/ade/nm testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-OBJECTS=$(patsubst %.c,%.o,$(SRCS))
+top_srcdir		?= ../../../..
 
-all:  $(OBJECTS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f nm01 ../../../bin
-	ln -f nmfile*.c ../../../bin
-	ln -f *.o ../../../bin
+INSTALL_TARGETS		:= nm01 nmfile.c
 
-clean:
-	rm -f nmfile*.o 
+MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%.obj,$(wildcard $(abs_srcdir)/*.c))
 
+$(MAKE_TARGETS): %.obj: %.o
+	mv $^ $@
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/objdump/Makefile b/testcases/commands/ade/objdump/Makefile
index 80bde31..862438c 100644
--- a/testcases/commands/ade/objdump/Makefile
+++ b/testcases/commands/ade/objdump/Makefile
@@ -1,22 +1,39 @@
-CFLAGS += -w -o
-LDFLAGS +=
+#
+#    commands/ade/objdump testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TESTS= test test_arch.o test_D
+top_srcdir		?= ../../../..
 
-all: $(TESTS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f objdump01 ../../../bin
-	ln -f test_arch.o ../../../bin
-	ln -f test ../../../bin
-	ln -f test_D ../../../bin
+test: CPPFLAGS += -O
 
+test_arch.obj: test.o
+	mv $< "$@"
 
-clean:
-	rm -f $(TESTS)
+test_D: test.o
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION) $@
 
-$(TESTS): 
-	$(CC) -O $(CFLAGS) $(cflags) test $(LDFLAGS) ./test.c
-	$(CC) -c $(CFLAGS) $(cflags) test_arch.o ./test.c
-	$(CC) $(CFLAGS) $(cflags) test_D $(LDFLAGS) ./test.c
+INSTALL_TARGETS		:= objdump01
+ 
+MAKE_TARGETS		:= test test_arch.obj test_D
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/objdump/test.c b/testcases/commands/ade/objdump/test.c
index b2a57ae..357aead 100644
--- a/testcases/commands/ade/objdump/test.c
+++ b/testcases/commands/ade/objdump/test.c
@@ -1,20 +1,15 @@
+#include <stdio.h>
 
-int main()
+int main(void)
 {
 
 	int i=0;
 
-
-	for( i=0; i<10; i++)
-	{
-
+	for(i=0; i<10; i++) {
 		if ( i %2 )
-
 			printf(" Hello \n ");
-
 		else
 			printf("World \n");
-
 	}
 
 	printf(" the end \n");
@@ -22,5 +17,3 @@
 	return 0;
 
 }
-	
-
diff --git a/testcases/commands/ade/size/Makefile b/testcases/commands/ade/size/Makefile
index 75d84c2..ae2543c 100644
--- a/testcases/commands/ade/size/Makefile
+++ b/testcases/commands/ade/size/Makefile
@@ -1,16 +1,29 @@
-CFLAGS += -w -O
-LDFLAGS += 
+#
+#    commands/ade/size testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f size01 ../../../bin
+INSTALL_TARGETS		:= size01
 
-clean:
-	rm -f $(TARGETS)
-
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/size/test.c b/testcases/commands/ade/size/test.c
index b2a57ae..3be1dff 100644
--- a/testcases/commands/ade/size/test.c
+++ b/testcases/commands/ade/size/test.c
@@ -1,20 +1,16 @@
+#include <stdio.h>
 
-int main()
+int main(void)
 {
 
 	int i=0;
 
-
 	for( i=0; i<10; i++)
 	{
-
 		if ( i %2 )
-
 			printf(" Hello \n ");
-
 		else
 			printf("World \n");
-
 	}
 
 	printf(" the end \n");
@@ -22,5 +18,3 @@
 	return 0;
 
 }
-	
-
diff --git a/testcases/commands/at/Makefile b/testcases/commands/at/Makefile
index e799efd..fd63092 100644
--- a/testcases/commands/at/Makefile
+++ b/testcases/commands/at/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    commands/at testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f at_deny01 ../../bin/
-	ln -f at_allow01 ../../bin/
-clean:
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= at_allow01 at_deny01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/cpio/Makefile b/testcases/commands/cpio/Makefile
index 974c73c..32c111c 100644
--- a/testcases/commands/cpio/Makefile
+++ b/testcases/commands/cpio/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    commands/cpio testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f cpio_tests.sh ../../bin/cpio_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= cpio_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/cron/Makefile b/testcases/commands/cron/Makefile
index ee0ef69..1b49488 100644
--- a/testcases/commands/cron/Makefile
+++ b/testcases/commands/cron/Makefile
@@ -1,20 +1,29 @@
-all: cron_dirs_check
+#
+#    commands/cron testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-cron_dirs_check:
-	$(CC) $(CROSS_CFLAGS) $(LDFLAGS) -o cron_dirs_check cron_dirs_check.c
+top_srcdir		?= ../../..
 
-install:
-	chmod 755 cron_tests.sh
-	@ln -f cron_tests.sh ../../bin/cron_tests.sh
-	@ln -f cron02  ../../bin/cron02
-	@ln -f cron03  ../../bin/cron03
-	@ln -f cron_illegal_cron_lines ../../bin/cron_illegal_cron_lines
-	@ln -f cron_pos_tests.sh ../../bin/cron_pos_tests.sh
-	@ln -f cron_neg_tests.sh ../../bin/cron_neg_tests.sh
-	@ln -f cron_allow01 ../../bin/cron_allow01
-	@ln -f cron_deny01 ../../bin/cron_deny01
-	@ln -f cron_dirs_checks01 ../../bin/cron_dirs_checks01
-	@ln -f cron_dirs_check ../../bin/cron_dirs_check
-clean:
-	rm -f cron_dirs_check
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= cron0[23] cron_illegal_cron_lines cron_allow01 cron_deny01 cron_dirs_checks01 *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/cron/cron02 b/testcases/commands/cron/cron02
index b2656e3..2bd6b48 100755
--- a/testcases/commands/cron/cron02
+++ b/testcases/commands/cron/cron02
@@ -54,10 +54,13 @@
 
 	# restart cron daemon
 	# Red Hat uses crond, SuSE/Other uses cron.
-	if [ -f /etc/init.d/crond ]; then
+	if [ -x /etc/init.d/crond ]; then
 		/etc/init.d/crond restart
-	else
+	elif [ -x /etc/init.d/cron ]; then
 		/etc/init.d/cron restart
+	else
+		echo "Could not determine cron init.d script."
+		exit 1
 	fi
 }
 
diff --git a/testcases/commands/eject/Makefile b/testcases/commands/eject/Makefile
index 1125c67..d22173d 100644
--- a/testcases/commands/eject/Makefile
+++ b/testcases/commands/eject/Makefile
@@ -1,14 +1,29 @@
-CFLAGS+=    -I../../../include -Wall
-LOADLIBES+= -L../../../lib
+#
+#    commands/eject testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../bin/$$i ; done
-	@ln -f eject-tests.sh ../../bin/eject_tests.sh
+INSTALL_TARGETS		:= eject-tests.sh
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/fileutils/Makefile b/testcases/commands/fileutils/Makefile
index dfd5bb2..65616f7 100644
--- a/testcases/commands/fileutils/Makefile
+++ b/testcases/commands/fileutils/Makefile
@@ -1,9 +1,27 @@
-SUBDIRS = cp mv mkdir ln
+#
+#    commands/fileutils test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/fileutils/cp/Makefile b/testcases/commands/fileutils/cp/Makefile
index de7a2a5..caea044 100644
--- a/testcases/commands/fileutils/cp/Makefile
+++ b/testcases/commands/fileutils/cp/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    commands/fileutils/cp testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f cp_tests.sh ../../../bin/
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= cp_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/fileutils/ln/Makefile b/testcases/commands/fileutils/ln/Makefile
index 273f0e9..4637a9c 100644
--- a/testcases/commands/fileutils/ln/Makefile
+++ b/testcases/commands/fileutils/ln/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    commands/fileutils/ln testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f ln_tests.sh ../../../bin/
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= ln_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/fileutils/mkdir/Makefile b/testcases/commands/fileutils/mkdir/Makefile
index 1ce6d45..3738b7c 100644
--- a/testcases/commands/fileutils/mkdir/Makefile
+++ b/testcases/commands/fileutils/mkdir/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    commands/fileutils/mkdir testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f mkdir_tests.sh ../../../bin/
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= mkdir_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/fileutils/mv/Makefile b/testcases/commands/fileutils/mv/Makefile
index ee739f8..a01a308 100644
--- a/testcases/commands/fileutils/mv/Makefile
+++ b/testcases/commands/fileutils/mv/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    commands/fileutils/mv testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f mv_tests.sh ../../../bin/
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= mv_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/gzip/Makefile b/testcases/commands/gzip/Makefile
index 6ea49be..5c1c256 100644
--- a/testcases/commands/gzip/Makefile
+++ b/testcases/commands/gzip/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    commands/gzip testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f gzip_tests.sh ../../bin/gzip_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= gzip_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/logrotate/Makefile b/testcases/commands/logrotate/Makefile
index b32c6ba..2bab1b3 100644
--- a/testcases/commands/logrotate/Makefile
+++ b/testcases/commands/logrotate/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    commands/logrotate testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f logrotate_tests.sh ../../bin/logrotate_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= logrotate_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/mail/Makefile b/testcases/commands/mail/Makefile
index 7098099..4bc6617 100644
--- a/testcases/commands/mail/Makefile
+++ b/testcases/commands/mail/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    commands/mail testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f mail_tests.sh ../../bin/mail_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= mail_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/su/Makefile b/testcases/commands/su/Makefile
index 75ee919..dd220e6 100644
--- a/testcases/commands/su/Makefile
+++ b/testcases/commands/su/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    commands/su testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f su01 ../../bin
-	ln -f su01_s1 ../../bin
-	ln -f su_set_passwd ../../bin
-clean:
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= su01 su01_s1 su_set_passwd
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tar/Makefile b/testcases/commands/tar/Makefile
index 6e71818..ac1fa4c 100644
--- a/testcases/commands/tar/Makefile
+++ b/testcases/commands/tar/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    commands/tar testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tar_tests.sh ../../bin/tar_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= tar_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/Makefile b/testcases/commands/tpm-tools/Makefile
index c6b4d70..191f2b8 100644
--- a/testcases/commands/tpm-tools/Makefile
+++ b/testcases/commands/tpm-tools/Makefile
@@ -1,9 +1,27 @@
-SUBDIRS = tpm tpmtoken
+#
+#    commands/tpm_tools testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/tpm-tools/tpm/Makefile b/testcases/commands/tpm-tools/tpm/Makefile
index 318c214..3c087ba 100644
--- a/testcases/commands/tpm-tools/tpm/Makefile
+++ b/testcases/commands/tpm-tools/tpm/Makefile
@@ -1,15 +1,27 @@
-SUBDIRS	= tpm_selftest		\
-	tpm_version		\
-	tpm_getpubek		\
-	tpm_takeownership	\
-	tpm_restrictpubek	\
-	tpm_changeauth		\
-	tpm_clear
+#
+#    commands/tpm-tools/tpm test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/tpm-tools/tpm/tpm_changeauth/Makefile b/testcases/commands/tpm-tools/tpm/tpm_changeauth/Makefile
index ab2fab2..91177d8 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_changeauth/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_changeauth/Makefile
@@ -1,10 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpm/tpm_changeauth testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpm_changeauth_tests.sh ../../../../bin/
-	@ln -f tpm_changeauth_tests_exp01.sh ../../../../bin/
-	@ln -f tpm_changeauth_tests_exp02.sh ../../../../bin/
-	@ln -f tpm_changeauth_tests_exp03.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpm/tpm_clear/Makefile b/testcases/commands/tpm-tools/tpm/tpm_clear/Makefile
index f15fa3d..eb93af7 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_clear/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_clear/Makefile
@@ -1,8 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpm/tpm_clear testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpm_clear_tests.sh ../../../../bin/
-	@ln -f tpm_clear_tests_exp01.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpm/tpm_getpubek/Makefile b/testcases/commands/tpm-tools/tpm/tpm_getpubek/Makefile
index f636a25..bd87204 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_getpubek/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_getpubek/Makefile
@@ -1,8 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpm/tpm_getpubek testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpm_getpubek_tests.sh ../../../../bin/
-	@ln -f tpm_getpubek_tests_exp01.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpm/tpm_restrictpubek/Makefile b/testcases/commands/tpm-tools/tpm/tpm_restrictpubek/Makefile
index 0e5a4e3..183d6cb 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_restrictpubek/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_restrictpubek/Makefile
@@ -1,10 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpm/tpm_restrictpubek testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpm_restrictpubek_tests.sh ../../../../bin/
-	@ln -f tpm_restrictpubek_tests_exp01.sh ../../../../bin/
-	@ln -f tpm_restrictpubek_tests_exp02.sh ../../../../bin/
-	@ln -f tpm_restrictpubek_tests_exp03.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpm/tpm_selftest/Makefile b/testcases/commands/tpm-tools/tpm/tpm_selftest/Makefile
index 6a87546..353a822 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_selftest/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_selftest/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpm/tpm_selftest testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpm_selftest_tests.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpm/tpm_takeownership/Makefile b/testcases/commands/tpm-tools/tpm/tpm_takeownership/Makefile
index d82166c..bfbb413 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_takeownership/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_takeownership/Makefile
@@ -1,8 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpm/tpm_takeownership testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpm_takeownership_tests.sh ../../../../bin/
-	@ln -f tpm_takeownership_tests_exp01.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpm/tpm_version/Makefile b/testcases/commands/tpm-tools/tpm/tpm_version/Makefile
index a926a8c..6c21852 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_version/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_version/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpm/tpm_version testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpm_version_tests.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpmtoken/Makefile b/testcases/commands/tpm-tools/tpmtoken/Makefile
index 3e46f21..63565d9 100644
--- a/testcases/commands/tpm-tools/tpmtoken/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/Makefile
@@ -1,13 +1,27 @@
-SUBDIRS	= tpmtoken_init		\
-	tpmtoken_setpasswd	\
-	tpmtoken_import		\
-	tpmtoken_protect	\
-	tpmtoken_objects
+#
+#    commands/tpm-tools/tpmtoken test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/Makefile
index e1de1be..964ac8e 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/Makefile
@@ -1,16 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpmtoken/tpmtoken_import testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpmtoken_import_tests.sh ../../../../bin/
-	@ln -f tpmtoken_import_tests_exp01.sh ../../../../bin/
-	@ln -f tpmtoken_import_tests_exp02.sh ../../../../bin/
-	@ln -f tpmtoken_import_tests_exp03.sh ../../../../bin/
-	@ln -f tpmtoken_import_tests_exp04.sh ../../../../bin/
-	@ln -f tpmtoken_import_tests_exp05.sh ../../../../bin/
-	@ln -f tpmtoken_import_tests_exp06.sh ../../../../bin/
-	@ln -f tpmtoken_import_tests_exp07.sh ../../../../bin/
-	@ln -f tpmtoken_import_tests_exp08.sh ../../../../bin/
-	@ln -f tpmtoken_import_openssl.cnf ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_init/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_init/Makefile
index 9a4c89e..b57b960 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_init/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_init/Makefile
@@ -1,11 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpmtoken/tpmtoken_init testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpmtoken_init_tests.sh ../../../../bin/
-	@ln -f tpmtoken_init_tests_exp00.sh ../../../../bin/
-	@ln -f tpmtoken_init_tests_exp01.sh ../../../../bin/
-	@ln -f tpmtoken_init_tests_exp02.sh ../../../../bin/
-	@ln -f tpmtoken_init_tests_exp03.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_objects/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_objects/Makefile
index 09ad25f..53080c9 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_objects/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_objects/Makefile
@@ -1,8 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpmtoken/tpmtoken_objects testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpmtoken_objects_tests.sh ../../../../bin/
-	@ln -f tpmtoken_objects_tests_exp01.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_protect/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_protect/Makefile
index 774ede8..112e8cf 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_protect/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_protect/Makefile
@@ -1,10 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpmtoken/tpmtoken_protect testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpmtoken_protect_tests.sh ../../../../bin/
-	@ln -f tpmtoken_protect_tests_exp01.sh ../../../../bin/
-	@ln -f tpmtoken_protect_tests_exp02.sh ../../../../bin/
-	@ln -f tpmtoken_protect_data.txt ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_setpasswd/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_setpasswd/Makefile
index 145fc23..e47ffa5 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_setpasswd/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_setpasswd/Makefile
@@ -1,11 +1,31 @@
-all:
+#
+#    commands/tpm-tools/tpmtoken/tpmtoken_setpasswd testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f tpmtoken_setpasswd_tests.sh ../../../../bin/
-	@ln -f tpmtoken_setpasswd_tests_exp01.sh ../../../../bin/
-	@ln -f tpmtoken_setpasswd_tests_exp02.sh ../../../../bin/
-	@ln -f tpmtoken_setpasswd_tests_exp03.sh ../../../../bin/
-	@ln -f tpmtoken_setpasswd_tests_exp04.sh ../../../../bin/
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/unzip/Makefile b/testcases/commands/unzip/Makefile
index 7c7aa60..271a765 100644
--- a/testcases/commands/unzip/Makefile
+++ b/testcases/commands/unzip/Makefile
@@ -1,28 +1,49 @@
-# Only build and install if we have the zip and unzip commands
-HAVE_ZIPTOOLS=$(shell which zip >/dev/null 2>&1\
- && which unzip >/dev/null 2>&1 && echo t)
-ifeq ($(HAVE_ZIPTOOLS),t)
-BINS := unzip_tests.sh
-DEPS := tst_unzip_file.zip $(BINS)
-else
-BINS :=
-DEPS :=
+#
+#    commands/unzip testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+# Only build and install if we have the zip command.
+HAVE_ZIPTOOLS		:= $(shell if which zip >/dev/null; then echo yes; else echo no; fi)
+
+DIR			:= tst_unzip.dir
+
+MAKE_TARGETS		:=
+
+ifeq ($(HAVE_ZIPTOOLS),yes)
+INSTALL_TARGETS		:= unzip_tests.sh
+$(INSTALL_TARGETS): $(ZIPFILE)
 endif
 
-all: $(DEPS)
+$(ZIPFILE): $(DIR)
+	$(ZIP) -r $@ $(DIR) && chmod 777 $@
 
-tst_unzip_file.zip: tst_unzip.dir
-	zip -r tst_unzip_file.zip tst_unzip.dir && chmod 777 tst_unzip_file.zip
+CLEAN_TARGETS		:= $(DIR)
 
 # This target should be auto-removed by Make
-.INTERMEDIATE: tst_unzip.dir
-tst_unzip.dir: unzip_genfile.sh
-	./unzip_genfile.sh tst_unzip.dir
+.INTERMEDIATE: $(DIR)
+$(DIR): unzip_genfile.sh
+	./$^ $(DIR)
 
-install: all
-	@set -e; for i in $(BINS); do \
-		ln -f $$i ../../bin/$$i ; \
-	done
-
-clean:
-	rm -rf tst_unzip.dir tst_unzip_file.zip
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/Makefile b/testcases/kernel/Makefile
index 40b704c..0715739 100644
--- a/testcases/kernel/Makefile
+++ b/testcases/kernel/Makefile
@@ -1,23 +1,50 @@
-include ../../config.mk
+#
+#    kernel test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SUBDIRS = power_management numa containers connectors include fs io ipc mem pty sched security syscalls timers
-UCLINUX_SUBDIRS = include syscalls
+top_srcdir	?= ../..
 
-ifeq ($(LTP_CHECK_CGROUPSTATS_HEADER),yes)
-	SUBDIRS+= controllers
+include $(top_srcdir)/include/mk/env_pre.mk
+
+ifneq ($(UCLINUX),1)
+SUBDIRS		:= containers connectors controllers fs io ipc mem numa \
+		   performance_counters power_management pty sched security \
+		   syscalls timers
+else
+SUBDIRS		:= syscalls
 endif
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+trunk-all: $(includedir)/linux_syscall_numbers.h
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+trunk-clean:: | linux-syscall-numbers-clean
 
-uclinux:
-	@set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux ; done
+include:
+	mkdir -p "$@"
 
-uclinux_install:
-	@set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux_install ; done
+linux-syscall-numbers-clean:: include
+	$(MAKE) -C $^ -f "$(abs_srcdir)/include/Makefile" clean
 
-clean:
-	@set -e; for i in $(SUBDIRS) timers; do $(MAKE) -C $$i clean ; done
+$(includedir)/linux_syscall_numbers.h: include
+	set -e; for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/connectors/Makefile b/testcases/kernel/connectors/Makefile
index 7e16b53..7661c57 100644
--- a/testcases/kernel/connectors/Makefile
+++ b/testcases/kernel/connectors/Makefile
@@ -1,18 +1,29 @@
-SUBDIRS = pec
+#
+#    testcases/kernel/connectors test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems, Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; \
-	if ! test -f /proc/net/connector; then \
-		echo "system does not support process event connector"; \
-	else for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done; true; fi
+top_srcdir		?= ../../..
 
-install:
-	@set -e; \
-	ln -f connector_test.sh ../../bin/connector_test.sh; \
-	chmod ugo+x connector_test.sh; \
-	if ! test -f /proc/net/connector; then \
-		echo "system does not support process event connector"; \
-	else for i in $(SUBDIRS); do $(MAKE) -C $$i install; done; true; fi
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done
+INSTALL_TARGETS		:= connector_test.sh
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/connectors/pec/Makefile b/testcases/kernel/connectors/pec/Makefile
index 8969a2f..e9f6448 100644
--- a/testcases/kernel/connectors/pec/Makefile
+++ b/testcases/kernel/connectors/pec/Makefile
@@ -1,14 +1,29 @@
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+#
+#    kernel/connectors/pec testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS:=$(wildcard *.c)
-TARGETS:=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; chmod +x run_pec_test ; done ;
-	ln -f run_pec_test ../../../bin/
-	chmod +x run_pec_test
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+
+INSTALL_TARGETS		:= run_pec_test
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk 
diff --git a/testcases/kernel/connectors/pec/pec_listener.c b/testcases/kernel/connectors/pec/pec_listener.c
index 20f269d..8690936 100644
--- a/testcases/kernel/connectors/pec/pec_listener.c
+++ b/testcases/kernel/connectors/pec/pec_listener.c
@@ -20,15 +20,16 @@
 /*                                                                            */
 /******************************************************************************/
 
+#include <sys/socket.h>
+#include <sys/poll.h>
+#include <sys/types.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <signal.h>
-#include <sys/socket.h>
-#include <sys/poll.h>
-
+#include <linux/types.h>
 #include <linux/netlink.h>
 
 #ifndef NETLINK_CONNECTOR
diff --git a/testcases/kernel/containers/Makefile b/testcases/kernel/containers/Makefile
index 9e1a4ba..44a339d 100644
--- a/testcases/kernel/containers/Makefile
+++ b/testcases/kernel/containers/Makefile
@@ -1,37 +1,47 @@
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2007                 ##
-##                                                                            ##
-## This program is free software;  you can redistribute it and#or modify      ##
-## it under the terms of the GNU General Public License as published by       ##
-## the Free Software Foundation; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    ##
-##                                                                            ##
-################################################################################
+#
+# Copyright (c) International Business Machines  Corp., 2007
+#
+# This program is free software;  you can redistribute it and#or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program;  if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
 
-SUBDIRS := libclone utsname sysvipc pidns netns mqns
+top_srcdir		?= ../../..
 
-all: check_for_unshare
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-check_for_unshare: check_for_unshare.c
-	$(CC) $(CFLAGS) -rdynamic -o $@ $< ../../../lib/tst_kvercmp.c -I../../../include -ldl
+LIB			:= $(DESTDIR)/$(libdir)/libclone.a
+LIBDIR			:= libclone
 
-install: check_for_unshare
-	@set -e; ln -f check_for_unshare ../../bin/check_for_unshare; \
-	ln -f container_test.sh ../../bin/container_test.sh; \
-	for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done; \
-	chmod ugo+x container_test.sh
+FILTER_OUT_DIRS		:= $(LIBDIR)
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done
-	rm -f check_for_unshare
+INSTALL_TARGETS		:= *.sh 
+
+$(LIBDIR):
+	mkdir -p "$@"
+
+# Make the target the real lib so we don't have to deal with rebuilding this
+# every time the dependency is evaluated, like with PHONY rules.
+$(LIB): $(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$(LIBDIR)/Makefile" $$i; \
+	done
+
+trunk-all: $(LIB)
+
+trunk-clean:: | lib-clean
+
+lib-clean:: $(LIBDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$(LIBDIR)/Makefile" clean
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/containers/Makefile.inc b/testcases/kernel/containers/Makefile.inc
new file mode 100644
index 0000000..ad424ea
--- /dev/null
+++ b/testcases/kernel/containers/Makefile.inc
@@ -0,0 +1,46 @@
+#
+#    kernel/containers testcase suite common definitions Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# DO NOT USE THIS FILE FOR containers / libclone!!!
+
+LIBS			:= $(DESTDIR)/$(libdir)/libclone.a
+
+LIBDIR			:= libclone
+
+CPPFLAGS		+= -I$(abs_srcdir)/../$(LIBDIR)
+
+../$(LIBDIR):
+	mkdir -p "$@"
+
+# Make the target the real lib so we don't have to deal with rebuilding this
+# every time the dependency is evaluated, like with PHONY rules.
+$(LIBS): ../$(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" \
+	    $$i; \
+	done
+
+INSTALL_TARGETS		?= *.sh
+
+$(MAKE_TARGETS): | $(LIBS)
+
+# vim: syntax=make
diff --git a/testcases/kernel/containers/check_for_unshare.c b/testcases/kernel/containers/check_for_unshare.c
deleted file mode 100644
index 06bdfd7..0000000
--- a/testcases/kernel/containers/check_for_unshare.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Copyright (c) International Business Machines Corp., 2008
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
-* the GNU General Public License for more details.
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*
-**************************************************************************/
-/*
-* Description:
-* This program verifies the kernel version to be no later than 2.6.16
-* And checks if the unshare() system call is defined using dlsym(),
-* in the Dynamically Linked Libraries.
-*
-* Date : 26-11-2008
-* Author : Veerendra C <vechandr@in.ibm.com>
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <dlfcn.h>
-#include <linux/version.h>
-
-int main(int argc, char **argv)
-{
-	void *handle;
-	void *ret;
-	char *error;
-	if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16))
-	return 1;
-
-	handle = dlopen(NULL, RTLD_LAZY);
-	if (!handle) {
-		fprintf(stderr, "%s\n", dlerror());
-		exit(1);
-	}
-
-	dlerror();    /* Clear any existing error */
-	ret = dlsym(handle, "unshare");
-	if ((error = dlerror()) != NULL)  {
-		fprintf(stderr, "Error: %s\n", error);
-		exit(1);
-	}
-
-	dlclose(handle);
-	return 0;
-}
diff --git a/testcases/kernel/containers/libclone/Makefile b/testcases/kernel/containers/libclone/Makefile
index a5373f3..51608f4 100755
--- a/testcases/kernel/containers/libclone/Makefile
+++ b/testcases/kernel/containers/libclone/Makefile
@@ -18,28 +18,10 @@
 ##                                                                            ##
 ################################################################################
 
-SRCS := $(wildcard *.c)
-OBJS := $(SRCS:%.c=%.o)
+top_srcdir		?= ../../../..
 
-CFLAGS += -I../../../../include
+include $(top_srcdir)/include/mk/env_pre.mk
 
-HAS_UNSHARE ?= $(shell ../check_for_unshare && echo y)
-ifeq ($(HAS_UNSHARE),y)
-TARGET := libclone.a libnetns.a
-else
-TARGET :=
-endif
+LIB			:= libclone.a
 
-all: $(TARGET)
-
-libclone.a: $(OBJS)
-	$(AR) -cr $@ libclone.o
-
-libnetns.a: $(OBJS)
-	$(AR) -cr $@ libnetns.o 
-#	$(AR) -cr $@ $^
-
-clean:
-	rm -f $(TARGET) $(OBJS)
-
-install:
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/kernel/containers/mqns/Makefile b/testcases/kernel/containers/mqns/Makefile
index d9aba3d..aafb892 100644
--- a/testcases/kernel/containers/mqns/Makefile
+++ b/testcases/kernel/containers/mqns/Makefile
@@ -19,24 +19,11 @@
 ##                                                                            ##
 ################################################################################
 
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include -I../libclone
-LDLIBS += -L../../../../lib -L../libclone ../libclone/libclone.a -lltp -lrt
+top_srcdir		?= ../../../..
 
-SRCS    := $(wildcard *.c)
-TARGETS := $(SRCS:%.c=%)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-HAS_UNSHARE ?= $(shell ../check_for_unshare && echo y)
-ifneq ($(HAS_UNSHARE),y)
-TARGETS :=
-endif
+LDLIBS			+= -lclone -lpthread -lrt
 
-all: $(TARGETS)
-
-clean:
-	rm -f $(TARGETS) *.o
-
-install:
-ifeq ($(HAS_UNSHARE),y)
-	@set -e; for i in $(TARGETS) runmqnstest.sh check_mqns_enabled; do ln -f $$i ../../../bin/$$i ; chmod +x runmqnstest.sh ; done
-endif
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/containers/mqns/check_mqns_enabled.c b/testcases/kernel/containers/mqns/check_mqns_enabled.c
deleted file mode 100644
index 169e8c9..0000000
--- a/testcases/kernel/containers/mqns/check_mqns_enabled.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Copyright (c) International Business Machines Corp., 2009
-* Copyright (c) Nadia Derbey, 2009
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
-* the GNU General Public License for more details.
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*
-* Author: Serge Hallyn <serue@us.ibm.com>
-***************************************************************************/
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include "../libclone/libclone.h"
-#include "test.h"
-#include "mqns.h"
-
-int dummy(void *v)
-{
-	return 0;
-}
-
-int main()
-{
-	int pid;
-	mqd_t mqd;
-
-        if (tst_kvercmp(2,6,30) < 0)  /* only in -mm so far actually */
-                return 1;
-
-	mq_unlink("/checkmqnsenabled");
-	mqd = mq_open("/checkmqnsenabled", O_RDWR|O_CREAT|O_EXCL, 0777, NULL);
-        if (mqd == -1) {
-		perror("mq_open");
-                return 3;
-	}
-	mq_close(mqd);
-	mq_unlink("/checkmqnsenabled");
-
-	pid = do_clone(CLONE_NEWIPC, dummy, NULL);
-
-	if (pid == -1)
-		return 5;
-
-        return 0;
-}
diff --git a/testcases/kernel/containers/netns/Makefile b/testcases/kernel/containers/netns/Makefile
index f12fa2d..dae6490 100644
--- a/testcases/kernel/containers/netns/Makefile
+++ b/testcases/kernel/containers/netns/Makefile
@@ -19,33 +19,16 @@
 ## Author:      Veerendra <veeren@linux.vnet.ibm.com>                         ##
 ################################################################################
 
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include -I../libclone
-LDLIBS += -L../../../../lib -L../libclone ../libclone/libnetns.a -lltp
-SCRIPTS = initialize.sh parentns.sh childns.sh                  \
-parent.sh child.sh                                              \
-parent_view.sh parent_share.sh  child_propagate.sh              \
-parent_1.sh parent_2.sh child_1.sh child_2.sh                   \
-delchild.sh rename_net.sh                                       \
-paripv6.sh childipv6.sh                                         \
-par_ftp.sh ch_ftp.sh container_ftp.pl                           \
-runnetnstest.sh nw_under_ns.sh
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(SRCS:%.c=%)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-HAS_UNSHARE ?= $(shell ../check_for_unshare && echo y)
-ifneq ($(HAS_UNSHARE),y)
-TARGETS :=
-endif
+INSTALL_TARGETS		:= *.sh
 
-all: $(TARGETS)
-	@chmod +x $(SCRIPTS)
+MAKE_TARGETS		:= create_container crtchild crtchild_delchild \
+			   par_chld_ftp par_chld_ipv6 sysfsview two_children_ns
 
-install:
-ifeq ($(HAS_UNSHARE),y)
-	@set -e; for i in $(TARGETS) $(SCRIPTS) runnetnstest.sh check_netns_enabled; do ln -f $$i ../../../bin/$$i ; chmod +x runnetnstest.sh ; done
-endif
+$(MAKE_TARGETS): %: common.o %.o
 
-clean:
-	rm -f $(TARGETS) *.o
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/containers/libclone/libnetns.c b/testcases/kernel/containers/netns/common.c
similarity index 67%
rename from testcases/kernel/containers/libclone/libnetns.c
rename to testcases/kernel/containers/netns/common.c
index 821fec1..c4fd086 100644
--- a/testcases/kernel/containers/libclone/libnetns.c
+++ b/testcases/kernel/containers/netns/common.c
@@ -21,7 +21,7 @@
 *
 * Scripts Used: parentns.sh childns.sh
 *
-* Author:      Veerendra <veeren@linux.vnet.ibm.com>
+* Author:	  Veerendra <veeren@linux.vnet.ibm.com>
 =========================================================================*/
 
 #include <sys/utsname.h>
@@ -39,21 +39,17 @@
 #include <sys/wait.h>
 #include "libclone.h"
 #include "test.h"
+#include "config.h"
 
-
-int TST_TOTAL = 1;
-
-extern pid_t getpgid(pid_t pid);
-extern pid_t getsid(pid_t pid);
 static int child_fn(void *c1);
 
 int crtchild(char *s1 , char *s2)
 {
-    char *cmd[] = { "--", s1, s2, (char *)0 };
-    execve("/bin/bash", cmd, __environ);
-    printf("The code would not reach here on success\n");
-    perror("execve");
-    return 1;
+	char *cmd[] = { "--", s1, s2, (char *)0 };
+	execve("/bin/sh", cmd, __environ);
+	printf("The code would not reach here on success\n");
+	perror("execve");
+	return 1;
 }
 
 int create_net_namespace(char *p1, char *c1)
@@ -88,46 +84,46 @@
 #endif
 
 	if (pid == -1) {
-		perror("Failled to do clone...");
+		perror("Failed to do clone...");
 		free(stack);
 		return -1;
 	}
 
-/* This code will be executed in parent */
-    ltproot = getenv("LTPROOT");
+	/* This code will be executed in parent */
+	ltproot = getenv("LTPROOT");
 
-    if ( !ltproot) {
-        printf("LTPROOT env variable is not set\n");
-        printf("Please set LTPROOT and re-run the test.. Thankyou\n");
-        return -1;
-    }
+	if ( !ltproot) {
+		printf("LTPROOT env variable is not set\n");
+		printf("Please set LTPROOT and re-run the test.. Thankyou\n");
+		return -1;
+	}
 
-    par = malloc(FILENAME_MAX);
+	par = malloc(FILENAME_MAX);
 
-    if (par == NULL) {
-                printf("FAIL: error while allocating memory");
-                exit(1);
-        }
+	if (par == NULL) {
+		printf("FAIL: error while allocating memory");
+		exit(1);
+	}
 
 	/* We need to pass the child pid to the parentns.sh script */
-    sprintf(par, "%s/testcases/kernel/containers/netns/parentns.sh %s %u",
-							ltproot, p1, pid);
+	sprintf(par, "parentns.sh %s %u", ltproot, p1, pid);
 
-        ret = system(par);
-        status = WEXITSTATUS(ret);
-        if ( ret == -1 || status != 0) {
-            printf("Error while running the script\n");
-            fflush(stdout);
-            exit(1);
-        }
-        fflush(stdout);
+	ret = system(par);
+	status = WEXITSTATUS(ret);
+	if ( ret == -1 || status != 0) {
+		printf("Error while running the script\n");
+		fflush(stdout);
+		exit(1);
+	}
+	fflush(stdout);
 
-        ret = waitpid(pid, &status, __WALL);
-        status = WEXITSTATUS(status);
-        if ( ret  == -1 || status != 0)
-            printf("Error: waitpid() returns %d, status %d\n", ret, status);
+	ret = waitpid(pid, &status, __WALL);
+	status = WEXITSTATUS(status);
+	if ( ret  == -1 || status != 0) {
+		printf("Error: waitpid() returns %d, status %d\n", ret, status);
+	}
 
-    return status;
+	return status;
 }
 
 /* The function to be executed in the child namespace */
@@ -135,9 +131,11 @@
 {
 	char *ltproot, *child;
 	unsigned long flags = 0;
+#if HAVE_UNSHARE
 	int ret;
-
-/* Flags to unshare different Namespaces */
+#endif
+	
+	/* Flags to unshare different Namespaces */
 	flags |= CLONE_NEWNS;
 	flags |= CLONE_NEWNET;
 	flags |= CLONE_NEWUTS;
@@ -147,7 +145,7 @@
 
 	if (!ltproot) {
 		printf("LTPROOT env variable is not set\n");
-		printf("Please set LTPROOT and re-run the test.. Thankyou\n");
+		printf("Please set LTPROOT and re-run the test..\n");
 		return -1;
 	}
 
@@ -157,14 +155,18 @@
 		exit(1);
 	}
 
-	sprintf(child, "%s/testcases/kernel/containers/netns/childns.sh",
-								 ltproot);
+	sprintf(child, "childns.sh", ltproot);
 
 	/* Unshare the network namespace in the child */
+#if HAVE_UNSHARE
 	ret = unshare(flags);
 	if (ret < 0) {
-		perror("Failled to unshare for netns...");
+		perror("Failed to unshare for netns...");
 		return 1;
 	}
 	return crtchild(child, c1);
+#else
+	printf("System doesn't support unshare.\n");
+	return -1;
+#endif
 }
diff --git a/testcases/kernel/containers/netns/create_container.c b/testcases/kernel/containers/netns/create_container.c
index 6ba4d0e..f73d196 100644
--- a/testcases/kernel/containers/netns/create_container.c
+++ b/testcases/kernel/containers/netns/create_container.c
@@ -27,7 +27,7 @@
 * Author: Sudhir Kumar <skumar@linux.vnet.ibm.com>   26/08/2008
 * ============================================================================*/
 
-#include<../libclone/libclone.h>
+#include "libclone.h"
 
 int main()
 {
diff --git a/testcases/kernel/containers/netns/crtchild.c b/testcases/kernel/containers/netns/crtchild.c
index c566371..338ad7d 100644
--- a/testcases/kernel/containers/netns/crtchild.c
+++ b/testcases/kernel/containers/netns/crtchild.c
@@ -26,7 +26,7 @@
 *                      31/07/2008
 * =============================================================================*/
 
-#include "../libclone/libclone.h"
+#include "libclone.h"
 
 int main()
 {
diff --git a/testcases/kernel/containers/netns/crtchild_delchild.c b/testcases/kernel/containers/netns/crtchild_delchild.c
index da415d6..9d96452 100644
--- a/testcases/kernel/containers/netns/crtchild_delchild.c
+++ b/testcases/kernel/containers/netns/crtchild_delchild.c
@@ -29,7 +29,7 @@
 *                      31/07/2008
 * =========================================================================*/
 
-#include "../libclone/libclone.h"
+#include "libclone.h"
 
 int main()
 {
diff --git a/testcases/kernel/containers/netns/par_chld_ftp.c b/testcases/kernel/containers/netns/par_chld_ftp.c
index 1737110..ac36a43 100644
--- a/testcases/kernel/containers/netns/par_chld_ftp.c
+++ b/testcases/kernel/containers/netns/par_chld_ftp.c
@@ -26,7 +26,7 @@
 *                      31/07/2008
 * =============================================================================*/
 
-#include "../libclone/libclone.h"
+#include "libclone.h"
 
 int main()
 {
diff --git a/testcases/kernel/containers/netns/par_chld_ipv6.c b/testcases/kernel/containers/netns/par_chld_ipv6.c
index 9f30932..b869352 100644
--- a/testcases/kernel/containers/netns/par_chld_ipv6.c
+++ b/testcases/kernel/containers/netns/par_chld_ipv6.c
@@ -29,7 +29,7 @@
 #include <sched.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include "../libclone/libclone.h"
+#include "libclone.h"
 #include <sched.h>
 #include <sys/syscall.h>
 #include <unistd.h>
@@ -41,21 +41,10 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <test.h>
+#include "config.h"
 
 char *TCID = "netns_ipv6";
-int TST_TOTAL=1;
-
-extern pid_t getpgid(pid_t pid);
-extern pid_t getsid(pid_t pid);
-
-int crtchild(char *s1)
-{
-    char *cmd[] = { "/bin/bash", s1, (char *)0 };
-    execve("/bin/bash", cmd, __environ);
-    tst_resm(TFAIL, "The code would not reach here on success\n");
-    perror("execve");
-    return 1;
-}
+int TST_TOTAL = 1;
 
 int main()
 {
@@ -81,7 +70,7 @@
     par = malloc (FILENAME_MAX);
     child = malloc (FILENAME_MAX);
 
-    if (par == NULL || child == NULL ) {
+    if (par == NULL || child == NULL) {
         tst_resm(TFAIL, "error while allocating mem");
         exit(1);
     }
@@ -93,12 +82,16 @@
     if ((pid = fork()) == 0) {
 
         // Child.
+#if HAVE_UNSHARE
         ret = unshare(flags);
         if (ret < 0) {
             perror("unshare");
 	    tst_resm(TFAIL, "Error:Unshare syscall failed for network namespace\n");
             return 1;
         }
+#else
+	tst_resm(TCONF, "System doesn't have unshare support");
+#endif
     return crtchild(child);
     }
     else{
diff --git a/testcases/kernel/containers/netns/sysfsview.c b/testcases/kernel/containers/netns/sysfsview.c
index 894ddec..a786373 100644
--- a/testcases/kernel/containers/netns/sysfsview.c
+++ b/testcases/kernel/containers/netns/sysfsview.c
@@ -36,7 +36,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include "../libclone/libclone.h"
+#include "libclone.h"
 
 int main()
 {
diff --git a/testcases/kernel/containers/netns/two_children_ns.c b/testcases/kernel/containers/netns/two_children_ns.c
index 63990bf..48c65f4 100644
--- a/testcases/kernel/containers/netns/two_children_ns.c
+++ b/testcases/kernel/containers/netns/two_children_ns.c
@@ -42,21 +42,11 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <test.h>
-#include "../libclone/libclone.h"
+#include "libclone.h"
+#include "config.h"
 
 char *TCID = "netns_2children";
-int TST_TOTAL=1;
-
-/* Creating Network Namespace */
-int crtchild(char *s)
-{
-    char *cmd[] = { "/bin/bash", s, (char *)0 };
-   
-    execve("/bin/bash", cmd, __environ);
-    tst_resm(TINFO, "The code never reaches here on success\n");
-    perror("execve");
-    return 1;
-}
+int TST_TOTAL = 1;
 
 int main()
 {
@@ -68,9 +58,14 @@
     flags |= CLONE_NEWNS;
     flags |= CLONE_NEWNET;
 
+#if ! HAVE_UNSHARE
+    tst_resm(TCONF, "System doesn't support unshare.");
+    tst_exit();
+#endif
+    
     /* Checking for Kernel Version */
-	if (tst_kvercmp(2,6,19) < 0)
-		return 1;
+    if (tst_kvercmp(2,6,19) < 0)
+	return 1;
 
     ltproot = getenv("LTPROOT");
     if (! ltproot) {
@@ -99,15 +94,17 @@
     for(i=0;i<2;i++) {
 
         if ((pid[i] = fork()) == 0) {
-            // Child1 and Child2 based on the iteration.
+		/* Child1 and Child2 based on the iteration. */
 
-            ret = unshare(flags);
-            if (ret < 0) {
-                perror("Unshare");
-	        tst_resm(TFAIL, "Error:Unshare syscall failed for network namespace\n");
-                return ret;
-            }
-        return crtchild(child[i]);
+#if HAVE_UNSHARE
+		ret = unshare(flags);
+		if (ret < 0) {
+			perror("Unshare");
+			tst_resm(TFAIL, "Error:Unshare syscall failed for network namespace\n");
+			return ret;
+		}
+#endif
+	    return crtchild(child[i]);
         }
         else{
             //Parent
diff --git a/testcases/kernel/containers/pidns/Makefile b/testcases/kernel/containers/pidns/Makefile
index 14f49da..9c46fae 100644
--- a/testcases/kernel/containers/pidns/Makefile
+++ b/testcases/kernel/containers/pidns/Makefile
@@ -18,24 +18,11 @@
 ##                                                                            ##
 ################################################################################
 
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include -I../libclone
-LDLIBS += -L../../../../lib -L../libclone ../libclone/libclone.a -lltp -lrt -lpthread
+top_srcdir		?= ../../../..
 
-SRCS    := $(wildcard *.c)
-TARGETS := $(SRCS:%.c=%)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-HAS_UNSHARE ?= $(shell ../check_for_unshare && echo y)
-ifneq ($(HAS_UNSHARE),y)
-TARGETS :=
-endif
+LDLIBS			+= -lclone -lpthread -lrt
 
-all: $(TARGETS)
-
-clean:
-	rm -f $(TARGETS) *.o
-
-install:
-ifeq ($(HAS_UNSHARE),y)
-	@set -e; for i in $(TARGETS) runpidnstest.sh check_pidns_enabled; do ln -f $$i ../../../bin/$$i ; chmod +x runpidnstest.sh ; done
-endif
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/containers/pidns/check_pidns_enabled.c b/testcases/kernel/containers/pidns/check_pidns_enabled.c
deleted file mode 100644
index 209dbb3..0000000
--- a/testcases/kernel/containers/pidns/check_pidns_enabled.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* Copyright (c) International Business Machines Corp., 2007
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
-* the GNU General Public License for more details.
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*
-***************************************************************************
-
-* File: check_pidns_enabled.c
-*
-* Description:
-*  This testcase builds into the ltp framework to verify that kernel is
-* PID NS enabled or not.
-*
-* Verify that:
-* 1. Verify that the kernel version is 2.6.24.
-* 2. Verify that clone() function return value.
-*
-* Test Name: check_pidns_enabled
-*
-* Test Assertion & Strategy:
-* Check that the kernel version is 2.6.24 and clone returns no failure after passing
-* the clone falg as CLONE_NEWPID.
-*
-* History:
-*
-* FLAG DATE     	NAME           		DESCRIPTION
-* 27/12/07  RISHIKESH K RAJAK <risrajak@in.ibm.com> Created this test
-*
-*******************************************************************************************/
-#include <sched.h>
-#include <stdio.h>
-#include "../libclone/libclone.h"
-#include "test.h"
-
-int dummy(void *v)
-{
-	/* Simply return from the child */
-        return 0;
-}
-
-/* MAIN */
-int main()
-{
-        int pid;
-
-	/* Test for the running kernel version
-	 * provided by LTP library API
-	 */
-        if (tst_kvercmp(2,6,24) < 0)
-                return 1;
-
-        pid = do_clone(CLONE_NEWPID, dummy, NULL);
-
-	/* Check for the clone function return value */
-        if (pid == -1)
-                return 3;
-        return 0;
-}
-
diff --git a/testcases/kernel/containers/sysvipc/Makefile b/testcases/kernel/containers/sysvipc/Makefile
index 94e6aea..709642b 100644
--- a/testcases/kernel/containers/sysvipc/Makefile
+++ b/testcases/kernel/containers/sysvipc/Makefile
@@ -18,23 +18,11 @@
 ##                                                                            ##
 ################################################################################
 
-CFLAGS += -I../../../../include -I../libclone -Wall
-LDLIBS += -L../../../../lib -L../libclone ../libclone/libclone.a -lltp
+top_srcdir		?= ../../../..
 
-SRCS    := $(wildcard *.c)
-TARGETS := $(SRCS:%.c=%)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-HAS_UNSHARE ?= $(shell ../check_for_unshare && echo y)
-ifneq ($(HAS_UNSHARE),y)
-TARGETS :=
-endif
+LDLIBS			+= -lclone
 
-all: $(TARGETS)
-
-clean:
-	rm -f $(TARGETS) *.o
-
-install:
-ifeq ($(HAS_UNSHARE),y)
-	@set -e; for i in $(TARGETS) runipcnstest.sh check_ipcns_enabled ; do ln -f $$i ../../../bin/$$i ; chmod +x runipcnstest.sh ; done
-endif
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/containers/utsname/Makefile b/testcases/kernel/containers/utsname/Makefile
index b65d15a..9c46fae 100755
--- a/testcases/kernel/containers/utsname/Makefile
+++ b/testcases/kernel/containers/utsname/Makefile
@@ -18,24 +18,11 @@
 ##                                                                            ##
 ################################################################################
 
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include -I../libclone
-LDLIBS += -L../../../../lib -L../libclone ../libclone/libclone.a -lltp
+top_srcdir		?= ../../../..
 
-SRCS    := $(wildcard *.c)
-TARGETS := $(SRCS:%.c=%)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-HAS_UNSHARE ?= $(shell ../check_for_unshare && echo y)
-ifneq ($(HAS_UNSHARE),y)
-TARGETS :=
-endif
+LDLIBS			+= -lclone -lpthread -lrt
 
-all: $(TARGETS)
-
-clean:
-	rm -f $(TARGETS) *.o
-
-install:
-ifeq ($(HAS_UNSHARE),y)
-	@set -e; for i in $(TARGETS) runutstest.sh check_utsns_enabled; do ln -f $$i ../../../bin/$$i ; chmod +x runutstest.sh ; done
-endif
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/Makefile b/testcases/kernel/controllers/Makefile
index 12b246e..0b2f1f4 100644
--- a/testcases/kernel/controllers/Makefile
+++ b/testcases/kernel/controllers/Makefile
@@ -1,90 +1,47 @@
-ifdef CROSS_COMPILE
-CHECK_CGROUP := $(shell test -f $(TARGET_DIR)/usr/include/linux/cgroupstats.h && echo 'cgroup')
-else
-CHECK_CGROUP := $(shell test -f /proc/cgroups && echo 'cgroup')
-CHECK_CPUCTL := $(shell grep -w cpu /proc/cgroups 2>/dev/null|cut -f1)
-CHECK_MEMCTL := $(shell grep -w memory /proc/cgroups 2>/dev/null|cut -f1)
-CHECK_BLOCKIOCTL := $(shell grep -w blockio /proc/cgroups 2>/dev/null|cut -f1)
-CHECK_FREEZER := $(shell grep -w freezer /proc/cgroups 2>/dev/null| cut -f1)
-CHECK_CPUSETCTL = $(shell grep -w cpuset /proc/cgroups 2>/dev/null|cut -f1)
-CHECK_CPUACCTCTL := $(shell grep -w cpuacct /proc/cgroups 2>/dev/null|cut -f1)
-endif
+#
+#    kernel/controllers test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-ifdef CROSS_COMPILE
-ifeq ($(CHECK_CGROUP),cgroup)
-SUBDIRS += cgroup
-SUBDIRS += cgroup_fj
-SUBDIRS += cpuctl
-SUBDIRS += cpuctl_fj
-SUBDIRS += memctl
-SUBDIRS += io-throttle
-SUBDIRS += freezer
-SUBDIRS += cpuset
-SUBDIRS += cpuacct
-else
-$(info "Kernel is not compiled with control cgroup support")
-endif
-else
-ifeq ($(CHECK_CGROUP),cgroup)
-SUBDIRS += cgroup
-SUBDIRS += cgroup_fj
-else
-$(info "Kernel is not compiled with control cgroup support")
-endif
+top_srcdir		?= ../../..
 
-ifeq ($(CHECK_MEMCTL),memory)
-SUBDIRS += memcg
-else
-$(info "Kernel is not compiled with memory resource controller support")
-endif
+include $(top_srcdir)/include/mk/env_pre.mk
 
-ifeq ($(CHECK_CPUCTL),cpu)
-SUBDIRS += cpuctl
-SUBDIRS += cpuctl_fj
-else
-$(info "Kernel is not compiled with cpu controller support")
-endif
-ifeq ($(CHECK_MEMCTL),memory)
-SUBDIRS += memctl
-else
-$(info "Kernel is not compiled with memory resource controller support")
-endif
-ifeq ($(CHECK_BLOCKIOCTL),blockio)
-SUBDIRS += io-throttle
-else
-$(info "Kernel is not compiled with blockio resource controller support")
-endif
-ifeq ($(CHECK_FREEZER),freezer)
-SUBDIRS += freezer
-else
-$(info "Kernel is not compiled with cgroup freezer support")
-endif
-ifeq ($(CHECK_CPUSETCTL),cpuset)
-SUBDIRS += cpuset
-else
-$(info "Kernel is not compiled with cpuset resource controller support")
-endif
-ifeq ($(CHECK_CPUACCTCTL),cpuacct)
-SUBDIRS += cpuacct
-else
-$(info "Kernel is not compiled with cpuacct resource controller support")
-endif
-endif
+INSTALL_TARGETS		:= *.sh
+LIB			:= $(DESTDIR)/$(libdir)/libcontrollers.a
+LIBDIR			:= libcontrollers
+FILTER_OUT_DIRS		:= $(LIBDIR)
 
-# If at least one of the controllers is available then build libcontrollers.
-ifneq ($(SUBDIRS),)
-SUBDIRS := libcontrollers $(SUBDIRS)
-endif
+$(LIBDIR):
+	mkdir -p "$@"
 
-.PHONY: all install clean
+$(LIB): $(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done
+trunk-all: $(LIB)
 
-install: test_controllers.sh
-	@chmod ugo+x test_controllers.sh
-	@ln -f test_controllers.sh ../../bin/test_controllers.sh
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done
+trunk-clean:: | lib-clean
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done
+lib-clean:: $(LIBDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/controllers/Makefile.inc b/testcases/kernel/controllers/Makefile.inc
new file mode 100644
index 0000000..728c8f5
--- /dev/null
+++ b/testcases/kernel/controllers/Makefile.inc
@@ -0,0 +1,44 @@
+#
+#    kernel/controllers test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# DO NOT USE THIS FILE FOR controllers / libcontrollers!!!
+
+LIB			:= $(DESTDIR)/$(libdir)/libcontrollers.a
+LIBDIR			:= libcontrollers
+
+../$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): ../$(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
+
+all: | $(LIB)
+
+CPPFLAGS		+= -I$(abs_srcdir)/../$(LIBDIR)
+
+LDLIBS			+= -lcontrollers
+
+INSTALL_TARGETS		?= *.sh
+
+# vim: syntax=make
diff --git a/testcases/kernel/controllers/cgroup/Makefile b/testcases/kernel/controllers/cgroup/Makefile
index 62d1ace..88aa7bb 100644
--- a/testcases/kernel/controllers/cgroup/Makefile
+++ b/testcases/kernel/controllers/cgroup/Makefile
@@ -1,16 +1,29 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include -I../libcontrollers
-LDLIBS += -L../../../../lib/ -lltp
+#
+#    kernel/controllers/cgroup test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS    = $(wildcard *.c)
+top_srcdir		?= ../../../..
 
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all:    $(TARGETS)
+INSTALL_TARGETS		:= *.sh
 
-clean:
-	rm -f $(TARGETS) *.o
-
-install:
-	@set -e; for i in $(TARGETS) *.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cgroup/getdelays.c b/testcases/kernel/controllers/cgroup/getdelays.c
index 9bdd879..474985d 100644
--- a/testcases/kernel/controllers/cgroup/getdelays.c
+++ b/testcases/kernel/controllers/cgroup/getdelays.c
@@ -22,16 +22,20 @@
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <signal.h>
-
+#include <linux/types.h>
 #include "config.h"
 
+#if HAVE_LINUX_GENETLINK_H
 #include <linux/genetlink.h>
+#endif
+#if HAVE_LINUX_TASKSTATS_H
 #include <linux/taskstats.h>
-
+#endif
 #ifdef HAVE_LINUX_CGROUPSTATS_H
 #include <linux/cgroupstats.h>
 #endif
 
+#if HAVE_LINUX_GENETLINK_H
 /*
  * Generic macros for dealing with netlink sockets. Might be duplicated
  * elsewhere. It is recommended that commercial grade applications use
@@ -47,6 +51,7 @@
 		fprintf(stderr, fmt, ##arg);	\
 		exit(code);			\
 	} while (0)
+#endif
 
 int done;
 int rcvbufsz;
@@ -68,11 +73,13 @@
 /* Maximum number of cpus expected to be specified in a cpumask */
 #define MAX_CPUS	32
 
+#if HAVE_LINUX_GENETLINK_H
 struct msgtemplate {
 	struct nlmsghdr n;
 	struct genlmsghdr g;
 	char buf[MAX_MSG_SIZE];
 };
+#endif
 
 char cpumask[100+6*MAX_CPUS];
 
@@ -87,6 +94,7 @@
 	fprintf(stderr, "  -C: container path\n");
 }
 
+#if HAVE_LINUX_GENETLINK_H
 /*
  * Create a raw netlink socket and bind
  */
@@ -120,7 +128,6 @@
 	return -1;
 }
 
-
 int send_cmd(int sd, __u16 nlmsg_type, __u32 nlmsg_pid,
 	     __u8 genl_cmd, __u16 nla_type,
 	     void *nla_data, int nla_len)
@@ -160,7 +167,6 @@
 	return 0;
 }
 
-
 /*
  * Probe the controller in genetlink to find the family id
  * for the TASKSTATS family
@@ -194,7 +200,9 @@
 	}
 	return id;
 }
+#endif
 
+#if HAVE_LINUX_TASKSTATS_H
 void print_delayacct(struct taskstats *t)
 {
 	printf("\n\nCPU   %15s%15s%15s%15s\n"
@@ -260,9 +268,12 @@
 		(unsigned long long)t->cancelled_write_bytes);
 #endif
 }
+#endif
 
 int main(int argc, char *argv[])
 {
+
+#if HAVE_LINUX_GENETLINK_H
 	int c, rc, rep_len, aggr_len, len2, cmd_type;
 	__u16 id;
 	__u32 mypid;
@@ -525,5 +536,8 @@
 	if (cfd)
 		close(cfd);
 	return 0;
+#else
+	printf("System doesn't have netlink support.\n");
+	return 1;
+#endif
 }
-
diff --git a/testcases/kernel/controllers/cgroup_fj/Makefile b/testcases/kernel/controllers/cgroup_fj/Makefile
index 620b09f..a9c6f94 100644
--- a/testcases/kernel/controllers/cgroup_fj/Makefile
+++ b/testcases/kernel/controllers/cgroup_fj/Makefile
@@ -1,19 +1,32 @@
-CFLAGS += -Wall -O2 -Wextra
+#
+#    kernel/controllers/cgroup_fj test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all:	$(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-install:
+CPPFLAGS		+= -Wall -O2 -Wextra
 
-test:
-	@./run_cgroup_test_fj.sh
+INSTALL_TARGETS		:= *.sh
 
-clean:
-	rm -f $(TARGETS) *.o
-
-install:
-	@set -e; for i in $(TARGETS) *.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done
-	ln -f cgroup_fj_release_agent ../../../bin/cgroup_fj_release_agent
-	ln -f cgroup_fj_testcases ../../../bin/cgroup_fj_testcases 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuacct/Makefile b/testcases/kernel/controllers/cpuacct/Makefile
index 70b8e49..8b63496 100644
--- a/testcases/kernel/controllers/cpuacct/Makefile
+++ b/testcases/kernel/controllers/cpuacct/Makefile
@@ -1,16 +1,32 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include -I../libcontrollers
-LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp
+#
+#    kernel/controllers/cpuacct test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS    = $(wildcard *.c)
+top_srcdir		?= ../../../..
 
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-all:	$(TARGETS)
+CPPFLAGS		+= -Wall
 
-clean:
-	rm -f $(TARGETS) *.o
+INSTALL_TARGETS		:= *.sh
 
-install:
-	@set -e; for i in $(TARGETS) run_cpuacct_test.sh cpuacct_setup.sh cpuacct_task01 ; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuctl/Makefile b/testcases/kernel/controllers/cpuctl/Makefile
index 03b8fee..8dd5804 100644
--- a/testcases/kernel/controllers/cpuctl/Makefile
+++ b/testcases/kernel/controllers/cpuctl/Makefile
@@ -1,18 +1,31 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include -I../libcontrollers
-LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp
+#
+#    kernel/controllers/cpuctl test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS    = $(wildcard *.c)
+top_srcdir		?= ../../../..
 
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all:	$(TARGETS)
+INSTALL_TARGETS		:= run_cpuctl_test.sh run_cpuctl_stress_test.sh parameters.sh run_cpuctl_latency_test.sh
 
-clean:
-	rm -f $(TARGETS) *.o
+LDLIBS			+= -lm -lcontrollers
 
-install:
-	@set -e; for i in $(TARGETS) run_cpuctl_test.sh \
-	run_cpuctl_stress_test.sh parameters.sh run_cpuctl_latency_test.sh; \
-	do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuctl_fj/Makefile b/testcases/kernel/controllers/cpuctl_fj/Makefile
index 7e68688..41cbeb4 100644
--- a/testcases/kernel/controllers/cpuctl_fj/Makefile
+++ b/testcases/kernel/controllers/cpuctl_fj/Makefile
@@ -1,21 +1,34 @@
-CFLAGS += -Wall -O2 -Wextra
-LOADLIBES+= -lm
-CPPFLAGS += -I../../../../include -I../libcontrollers
-LDLIBS += -L../../../../lib/ -lltp
+#
+#    kernel/controllers/cpuctl_fj test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-OBJECTS=$(patsubst %.c,%.o,$(SRCS))
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-$(TARGETS): %: %.o
+CPPFLAGS		+= -Wall -O2 -Wextra
 
-test:
-	@./runtest.sh
+INSTALL_TARGETS		:= *.sh
 
-clean:
-	rm -f $(TARGETS) $(OBJECTS)
+LDLIBS			+= -lm
 
-install:
-	@set -e; for i in $(TARGETS) *.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/Makefile b/testcases/kernel/controllers/cpuset/Makefile
index 6621667..0fbf4a3 100644
--- a/testcases/kernel/controllers/cpuset/Makefile
+++ b/testcases/kernel/controllers/cpuset/Makefile
@@ -1,17 +1,47 @@
-SUBDIRS = cpuset_base_ops_test cpuset_lib cpuset_inherit_test
-SUBDIRS += cpuset_exclusive_test cpuset_hierarchy_test cpuset_syscall_test
-SUBDIRS += cpuset_hotplug_test cpuset_load_balance_test
-SUBDIRS += cpuset_memory_pressure_test cpuset_memory_spread_test
-SUBDIRS += cpuset_memory_test
-all:
-	@set -e; \
-	for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ;done;
+#
+#    kernel/controllers/cpuset testcase suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@set -e; \
-	for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done;
-	ln -f run_cpuset_test.sh ../../../bin/run_cpuset_test.sh;
-	chmod +x run_cpuset_test.sh;
+top_srcdir		?= ../../../..
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+LIB			:= $(DESTDIR)/$(libdir)/libcpu_set.a
+LIBDIR			:= cpuset_lib
+FILTER_OUT_DIRS		:= $(LIBDIR)
+
+$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): $(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
+
+trunk-all: $(LIB)
+
+trunk-clean:: | lib-clean
+
+lib-clean:: $(LIBDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/controllers/cpuset/Makefile.inc b/testcases/kernel/controllers/cpuset/Makefile.inc
new file mode 100644
index 0000000..3921352
--- /dev/null
+++ b/testcases/kernel/controllers/cpuset/Makefile.inc
@@ -0,0 +1,40 @@
+#
+#    kernel/controllers/cpuset testcase suite common definitions Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+LIB			:= $(DESTDIR)/$(libdir)/libcpu_set.a
+LIBDIR			:= cpuset_lib
+
+../$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): ../$(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
+
+all: | $(LIB)
+
+LDLIBS			+= -lcpu_set
+
+INSTALL_TARGETS		?= *.sh
+
+# vim: syntax=make
diff --git a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/Makefile
index 70d1bc2..9ff9f8d 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/Makefile
@@ -1,12 +1,30 @@
-SRCS = $(wildcard *.sh)
+#
+#    kernel/controllers/cpuset/cpuset_base_ops_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@true
+top_srcdir              ?= ../../../../..
 
-clean:
-	@true
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-install:
-	@set -e; \
-	for i in $(SRCS); do ln -f $$i ../../../../bin/$$i; chmod +x $$i; done
+MAKE_TARGETS		:=
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/Makefile
index 70d1bc2..c430a15 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/Makefile
@@ -1,12 +1,30 @@
-SRCS = $(wildcard *.sh)
+#
+#    kernel/controllers/cpuset/cpuset_exclusive_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@true
+top_srcdir              ?= ../../../../..
 
-clean:
-	@true
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-install:
-	@set -e; \
-	for i in $(SRCS); do ln -f $$i ../../../../bin/$$i; chmod +x $$i; done
+MAKE_TARGETS		:=
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
new file mode 100755
index 0000000..aca0aaf
--- /dev/null
+++ b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
@@ -0,0 +1,265 @@
+#!/bin/sh
+# usage: . cpuset_funcs.sh
+# functions for cpuset test
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## This program is free software;  you can redistribute it and#or modify      ##
+## it under the terms of the GNU General Public License as published by       ##
+## the Free Software Foundation; either version 2 of the License, or          ##
+## (at your option) any later version.                                        ##
+##                                                                            ##
+## This program is distributed in the hope that it will be useful, but        ##
+## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
+## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
+## for more details.                                                          ##
+##                                                                            ##
+## You should have received a copy of the GNU General Public License          ##
+## along with this program;  if not, write to the Free Software               ##
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    ##
+##                                                                            ##
+## Author: Miao Xie <miaox@cn.fujitsu.com>                                    ##
+##                                                                            ##
+################################################################################
+
+NR_CPUS="`cat /proc/cpuinfo | grep "processor" | wc -l`"
+if [ -f "/sys/devices/system/node/has_high_memory" ]; then
+	N_NODES="`cat /sys/devices/system/node/has_high_memory`"
+else
+	N_NODES="`cat /sys/devices/system/node/has_normal_memory`"
+fi
+N_NODES=${N_NODES#*-*}
+: $((N_NODES++))
+
+CPUSET="/dev/cpuset"
+CPUSET_TMP="/tmp/cpuset_tmp"
+
+HOTPLUG_CPU="1"
+
+cpuset_log()
+{
+	tst_resm TINFO "$*"
+}
+
+# cpuset_log_error <error_file>
+cpuset_log_error()
+{
+	local error_message=
+
+	while read error_message
+	do
+		cpuset_log "$error_message"
+	done < "$1"
+}
+
+version_check()
+{
+	tst_kvercmp 2 6 28
+	if [ $? -eq 0 ]; then
+		tst_brkm TCONF ignored "kernel is below 2.6.28"
+		return 1
+	fi
+}
+
+ncpus_check()
+{
+	if [ $NR_CPUS -lt 4 ]; then
+		tst_brkm TCONF ignored "The total of CPUs is less than 4"
+		return 1
+	fi
+}
+
+nnodes_check()
+{
+	if [ $N_NODES -lt 3 ]; then
+		tst_brkm TCONF ignored "The total of nodes is less than 3"
+		return 1
+	fi
+}
+
+user_check()
+{
+	if [ "$USER" != root ]; then
+		tst_brkm TCONF ignored "Test must be run as root"
+		return 1
+	fi
+}
+
+cpuset_check()
+{
+	grep cpuset /proc/cgroups > /dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		tst_brkm TCONF ignored "Cpuset is not supported"
+		return 1
+	fi
+}
+
+check()
+{
+	user_check
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
+
+	cpuset_check
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
+
+	version_check
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
+
+	ncpus_check
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
+
+	nnodes_check
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
+
+}
+
+# Create /dev/cpuset & mount the cgroup file system with cpuset
+# clean any group created eralier (if any)
+setup()
+{
+	if [ -e "$CPUSET" ]
+	then
+		tst_resm TWARN "$CPUSET already exist.. overwriting"
+		cleanup || {
+			tst_brkm TFAIL ignored "Can't cleanup... Exiting"
+			return 1
+		}
+	fi
+
+	mkdir -p "$CPUSET_TMP"
+	mkdir "$CPUSET"
+	mount -t cpuset cpuset "$CPUSET" 2> /dev/null
+	if [ $? -ne 0 ]; then
+		tst_brkm TFAIL ignored "Could not mount cgroup filesystem with"\
+					" cpuset on $CPUSET..Exiting test"
+		cleanup
+		return 1
+	fi
+}
+
+# Write the cleanup function
+cleanup()
+{
+	mount | grep "$CPUSET" >/dev/null 2>&1 || {
+		rm -rf "$CPUSET" >/dev/null 2>&1
+		return 0
+	}
+
+	find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read subdir
+	do
+		while read pid
+		do
+			/bin/kill $pid > /dev/null 2>&1
+			if [ $? -ne 0 ]; then
+				tst_brkm TFAIL ignored "Couldn't kill task - "\
+							"$pid in the cpuset"
+				return 1
+			fi
+		done < "$subdir/tasks"
+		rmdir "$subdir"
+		if [ $? -ne 0 ]; then
+			tst_brkm TFAIL ignored "Couldn't remove subdir - "
+						"$subdir in the cpuset"
+			return 1
+		fi
+	done
+
+	umount "$CPUSET"
+	if [ $? -ne 0 ]; then
+		tst_brkm TFAIL ignored "Couldn't umount cgroup filesystem with"\
+					" cpuset on $CPUSET..Exiting test"
+		return 1
+	fi
+	rmdir "$CPUSET" > /dev/null 2>&1
+	rm -rf "$CPUSET_TMP" > /dev/null 2>&1
+}
+
+# set the cpuset's parameter
+# cpuset_set <cpusetpath> <cpus> <mems> <load_balance>
+cpuset_set()
+{
+	local path="$1"
+	mkdir -p "$path"
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
+
+	local cpus="$2"
+	local mems="$3"
+	local load_balance="$4"
+
+	if [ "$path" != "$CPUSET" ]; then
+		if [ "$cpus" != "-" ]; then
+			/bin/echo $cpus > $path/cpus
+			if [ $? -ne 0 ]; then
+				return 1
+			fi
+		fi
+
+		/bin/echo $mems > $path/mems
+		if [ $? -ne 0 ]; then
+			return 1
+		fi
+	fi
+
+	/bin/echo $load_balance > $path/sched_load_balance
+	if [ $? -ne 0 ]; then
+		return 1
+	fi
+}
+
+# cpu_hotplug cpu_id offline/online
+cpu_hotplug()
+{
+	if [ "$2" = "online" ]; then
+		/bin/echo 1 > "/sys/devices/system/cpu/cpu$1/online"
+		if [ $? -ne 0 ]; then
+			return 1
+		fi
+	elif [ "$2" = "offline" ]; then
+		/bin/echo 0 > "/sys/devices/system/cpu/cpu$1/online"
+		if [ $? -ne 0 ]; then
+			return 1
+		fi
+	fi
+}
+
+# setup_test_environment <online | offline>
+#   online  - online a CPU in testing, so we must offline a CPU first
+#   offline - offline a CPU in testing, we needn't do anything
+setup_test_environment()
+{
+	if [ "$1" = "online" ]; then
+		cpu_hotplug $HOTPLUG_CPU offline
+		if [ $? -ne 0 ]; then
+			return 1
+		fi
+	fi
+}
+
+cpu_hotplug_cleanup()
+{
+	local cpus_array="$(seq -s' ' 1 $((NR_CPUS-1)))"
+	local cpuid=
+	for cpuid in $cpus_array
+	do
+		local file="/sys/devices/system/cpu/cpu$cpuid/online"
+		local offline="$(cat $file)"
+		if [ $offline -eq 0 ]; then
+			cpu_hotplug $cpuid "online"
+		fi
+	done
+}
+
diff --git a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/Makefile
index 70d1bc2..10c29b2 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/Makefile
@@ -1,12 +1,30 @@
-SRCS = $(wildcard *.sh)
+#
+#    kernel/controllers/cpuset/cpuset_hierarchy_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@true
+top_srcdir              ?= ../../../../..
 
-clean:
-	@true
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-install:
-	@set -e; \
-	for i in $(SRCS); do ln -f $$i ../../../../bin/$$i; chmod +x $$i; done
+MAKE_TARGETS		:=
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/Makefile
index c4b6bba..e5029a1 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/Makefile
@@ -1,22 +1,30 @@
-CFLAGS += -Wall -g -Wextra
-LDLIBS := -lm
+#
+#    kernel/controllers/cpuset/cpuset_hotplug_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-LIBSRCS=$(wildcard ../cpuset_lib/*.c)
-LIBOBJECTS=$(patsubst %.c,%.o,$(LIBSRCS))
+top_srcdir              ?= ../../../../..
 
-SRCS=$(wildcard *.c)
-OBJECTS=$(patsubst %.c,%.o,$(SRCS))
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-all: $(TARGETS)
+MAKE_TARGETS		:=
 
-$(TARGETS): %: %.o $(LIBOBJECTS)
-
-clean:
-	rm -f $(TARGETS) $(OBJECTS) $(LIBOBJECTS)
-
-install:
-	@set -e; \
-	for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i; chmod +x $$i; done
-	ln -f cpuset_hotplug_test.sh ../../../../bin/cpuset_hotplug_test.sh;
-	chmod +x cpuset_hotplug_test.sh;
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/Makefile
index 70d1bc2..5848ee0 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/Makefile
@@ -1,12 +1,30 @@
-SRCS = $(wildcard *.sh)
+#
+#    kernel/controllers/cpuset/cpuset_inherit_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@true
+top_srcdir              ?= ../../../../..
 
-clean:
-	@true
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-install:
-	@set -e; \
-	for i in $(SRCS); do ln -f $$i ../../../../bin/$$i; chmod +x $$i; done
+MAKE_TARGETS		:=
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile b/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile
index 43df1bc..dbe62e9 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile
@@ -1,16 +1,31 @@
-CFLAGS += -Wall -g -Wextra
-CPPFLAGS += -I../../../../include
-LDLIBS += -lm -L../../../../lib/ -lcontrollers -lltp
+#
+#    kernel/controllers/cpuset/cpuset_lib library Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%.o,$(SRCS))
+top_srcdir 		?= ../../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lm -lcontrollers
 
-install:
-	@set -e; \
-	ln -f cpuset_funcs.sh ../../../../bin/cpuset_funcs.sh;
-	chmod +x cpuset_funcs.sh;
+LIB			:= libcpu_set.a
+
+include	$(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/Makefile
index 923d065..de88688 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/Makefile
@@ -1,24 +1,30 @@
-CFLAGS += -Wall -g -Wextra
-LDLIBS := -lm
+#
+#    kernel/controllers/cpuset/cpuset_load_balance_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-LIBSRCS=$(wildcard ../cpuset_lib/*.c)
-LIBOBJECTS=$(patsubst %.c,%.o,$(LIBSRCS))
+top_srcdir              ?= ../../../../..
 
-SRCS=$(wildcard *.c)
-OBJECTS=$(patsubst %.c,%.o,$(SRCS))
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-all: $(TARGETS)
+LDLIBS			+= -lm
 
-$(TARGETS): %: %.o $(LIBOBJECTS)
-
-clean:
-	rm -f $(TARGETS) $(OBJECTS) $(LIBOBJECTS)
-
-install:
-	@set -e; \
-	for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i; chmod +x $$i; done
-	ln -f cpuset_load_balance_test.sh ../../../../bin/cpuset_load_balance_test.sh;
-	ln -f cpuset_sched_domains_test.sh ../../../../bin/cpuset_sched_domains_test.sh;
-	chmod +x cpuset_load_balance_test.sh;
-	chmod +x cpuset_sched_domains_test.sh;
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/Makefile
index db21c20..f7fd3f2 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/Makefile
@@ -1,16 +1,27 @@
-CFLAGS += -Wall -g -Wextra
+#
+#    kernel/controllers/cpuset/cpuset_memory_pressure_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: cpuset_memory_pressure
+top_srcdir              ?= ../../../../..
 
-cpuset_memory_pressure: cpuset_memory_pressure.o
-	cc cpuset_memory_pressure.o -o cpuset_memory_pressure
-
-clean:
-	rm -f cpuset_memory_pressure.o cpuset_memory_pressure
-
-install:
-	@set -e;
-	ln -f cpuset_memory_pressure ../../../../bin/cpuset_memory_pressure;
-	ln -f cpuset_memory_pressure_testset.sh ../../../../bin/cpuset_memory_pressure_testset.sh;
-	chmod +x cpuset_memory_pressure;
-	chmod +x cpuset_memory_pressure_testset.sh;
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/Makefile
index 4ff812f..9345f3c 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/Makefile
@@ -1,16 +1,27 @@
-CFLAGS += -Wall -g -Wextra
+#
+#    kernel/controllers/cpuset/cpuset_memory_spread_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: cpuset_mem_hog
+top_srcdir              ?= ../../../../..
 
-cpuset_mem_hog: cpuset_mem_hog.o
-	cc cpuset_mem_hog.o -o cpuset_mem_hog
-
-clean:
-	rm -f cpuset_mem_hog.o cpuset_mem_hog
-
-install:
-	@set -e;
-	ln -f cpuset_mem_hog ../../../../bin/cpuset_mem_hog;
-	ln -f cpuset_memory_spread_testset.sh ../../../../bin/cpuset_memory_spread_testset.sh;
-	chmod +x cpuset_mem_hog;
-	chmod +x cpuset_memory_spread_testset.sh;
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_memory_test/Makefile
index dbdbde2..e5bb082 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_test/Makefile
@@ -1,20 +1,30 @@
-CFLAGS += -Wall -g -Wextra
+#
+#    kernel/controllers/cpuset/cpuset_memory_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-LIBSRCS=$(wildcard ../cpuset_lib/*.c)
-LIBOBJECTS=$(patsubst %.c,%.o,$(LIBSRCS))
+top_srcdir              ?= ../../../../..
 
-all: cpuset_memory_test
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-cpuset_memory_test: cpuset_memory_test.o $(LIBOBJECTS)
-	cc cpuset_memory_test.o $(LIBOBJECTS) -o cpuset_memory_test -lpthread
+LDLIBS		+= -lpthread
 
-clean:
-	rm -f cpuset_memory_test cpuset_memory_test.o
-	rm -f $(LIBOBJECTS)
-
-install:
-	@set -e;
-	ln -f cpuset_memory_test ../../../../bin/cpuset_memory_test;
-	ln -f cpuset_memory_testset.sh ../../../../bin/cpuset_memory_testset.sh;
-	chmod +x cpuset_memory_test;
-	chmod +x cpuset_memory_testset.sh;
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
index 1757f83..edc6265 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
@@ -1,18 +1,27 @@
-SRCS = $(wildcard *.c)
+#
+#    kernel/controllers/cpuset/cpuset_syscall_test testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-OBJECTS = $(SRCS:.c=.o)
+top_srcdir              ?= ../../../../..
 
-LIBSRCS=$(wildcard ../cpuset_lib/*.c)
-LIBOBJECTS=$(patsubst %.c,%.o,$(LIBSRCS))
-
-all: cpuset_syscall_test
-
-cpuset_syscall_test: %: %.o $(LIBOBJECTS)
-
-clean:
-	rm -rf cpuset_syscall_test $(OBJECTS) $(LIBOBJECTS)
-
-install:
-	@set -e; \
-	for i in *.sh; do ln -f $$i ../../../../bin/$$i; chmod +x $$i; done
-	ln -f cpuset_syscall_test ../../../../bin/cpuset_syscall_test;
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
index c5939cb..2e06828 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
@@ -37,7 +37,10 @@
 #include <sys/mman.h>
 #include <sys/shm.h>
 #include <syscall.h>
+#include "config.h"
+#if HAVE_LINUX_MEMPOLICY_H
 #include <linux/mempolicy.h>
+#endif
 
 #include "../cpuset_lib/cpuset.h"
 #include "../cpuset_lib/bitmask.h"
diff --git a/testcases/kernel/controllers/freezer/Makefile b/testcases/kernel/controllers/freezer/Makefile
index f215b0e..b9ca22d 100644
--- a/testcases/kernel/controllers/freezer/Makefile
+++ b/testcases/kernel/controllers/freezer/Makefile
@@ -1,32 +1,29 @@
-# Copyright (c) International Business Machines  Corp., 2008
-# Author: Matt Helsley <matthltc@us.ibm.com>
 #
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
+#    kernel/controllers/freezer testcase suite Makefile.
 #
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-CFLAGS := -Wall -O3
-PROGS := timed_forkbomb #  vfork fork_exec_loop
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-.PHONY: all install clean
+top_srcdir		?= ../../../..
 
-all: $(PROGS)
-	chmod u+x *.sh
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
+INSTALL_TARGETS		:= *.sh libcgroup_freezer
 
-$(PROGS): %: %.c
-	gcc $(CFLAGS) -o $@ $^
-
-clean:
-	rm -f $(PROGS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/freezer/run.sh b/testcases/kernel/controllers/freezer/run_freezer.sh
similarity index 97%
rename from testcases/kernel/controllers/freezer/run.sh
rename to testcases/kernel/controllers/freezer/run_freezer.sh
index a25c564..3baf968 100755
--- a/testcases/kernel/controllers/freezer/run.sh
+++ b/testcases/kernel/controllers/freezer/run_freezer.sh
@@ -54,7 +54,7 @@
 		CGROUPS_TESTROOT="$(pwd)"
 		. libltp
 	else
-		CGROUPS_TESTROOT="${LTPROOT}/testcases/kernel/controllers/freezer"
+		CGROUPS_TESTROOT="${LTPROOT}/testcases/bin"
 	fi
 
 	#######################################################################
diff --git a/testcases/kernel/controllers/freezer/vfork.c b/testcases/kernel/controllers/freezer/vfork.c
index ec2994a..63e44ed 100644
--- a/testcases/kernel/controllers/freezer/vfork.c
+++ b/testcases/kernel/controllers/freezer/vfork.c
@@ -38,15 +38,11 @@
 
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <sys/ptrace.h>
-#ifndef PTRACE_O_TRACEVFORK
-/* from #include <linux/ptrace.h> except we don't want to trash defines from
- * sys/ptrace.h */
-#define PTRACE_O_TRACEVFORK	0x00000004
-#endif
 #include <sys/socket.h>
+#include "config.h"
 
-/*#define _GNU_SOURCE*/
+#include <sys/ptrace.h>
+#include <linux/ptrace.h>
 
 #define str_expand(s) str(s)
 #define str(s) #s
@@ -80,55 +76,6 @@
 	return EXIT_SUCCESS;
 }
 
-#if 0
-void dump_siginfo(pid_t child, siginfo_t *info)
-{
-	printf("%d:\n\tsi_code: %#0x\n\tsi_signo: %#0x\n",
-	       child, info->si_code, info->si_signo);
-}
-
-void dump_status(pid_t child, int status)
-{
-	if (WIFEXITED(status))
-		printf("exited: %d (with status: %d)\n", child,
-		       WEXITSTATUS(status));
-	if (WIFSIGNALED(status))
-		printf("killed: %d (by signal: %s)\n", child,
-		       sys_siglist[WTERMSIG(status)]);
-	if (WIFSTOPPED(status))
-		printf("stopped: %d (by signal: %s)\n", child,
-		       sys_siglist[WSTOPSIG(status)]);
-}
-
-#define SI_CODE_TRAP (SIGTRAP|(PTRACE_EVENT_VFORK << 8))
-
-/* This function is for debug only.
- * return the number of new children to wait for */
-int trace_child(pid_t child)
-{
-	unsigned long data;
-	pid_t grandchild = -1;
-	siginfo_t info;
-
-	if (ptrace(PTRACE_GETSIGINFO, child, NULL, &info) == -1) {
-		debug("ptrace(): ");
-		return 0;
-	}
-	/*dump_siginfo(child, &info);*/
-	if (!((info.si_code == SI_CODE_TRAP) && (info.si_signo == SIGTRAP)))
-		return 0;
-
-	printf("%d: vfork()\n", child);
-	if (ptrace(PTRACE_GETEVENTMSG, child, NULL, &data) == -1) {
-		debug("ptrace(): ");
-		return 0;
-	}
-	grandchild = (pid_t)data;
-	printf("%d: vfork() child: %d\n", child, grandchild);
-	return 1;
-}
-#endif
-
 /* Options */
 int num_vforks = 1;
 int do_pause = 0;
@@ -215,6 +162,7 @@
 
 int trace_grandchild(pid_t gchild)
 {
+#if HAVE_DECL_PTRACE_GETSIGINFO
 	siginfo_t info;
 
 	if (ptrace(PTRACE_GETSIGINFO, gchild, NULL, &info) == -1) {
@@ -234,6 +182,7 @@
 	if (ptrace(PTRACE_DETACH, gchild, NULL, NULL) == -1)
 		debug("ptrace(): ");
 	return -1; /* don't wait for gchild */
+#endif
 }
 
 int do_trace(pid_t child, int num_children)
@@ -306,8 +255,11 @@
 	} while(1);
 }
 
-int main(int argc, char** argv)
+int
+main(int argc, char** argv)
 {
+
+#if HAVE_DECL_PTRACE_SETOPTIONS && HAVE_DECL_PTRACE_O_VTRACEFORK
 	pid_t child;
 	int psync[2];
 
@@ -356,4 +308,8 @@
 		printf("%d\n", child);
 		exit(do_trace(child, ++num_vforks));
 	}
+#else
+	printf("System doesn't support have required ptrace capabilities\n.");
+	return 1;
+#endif
 }
diff --git a/testcases/kernel/controllers/io-throttle/Makefile b/testcases/kernel/controllers/io-throttle/Makefile
index 5b3e370..43b4ab2 100644
--- a/testcases/kernel/controllers/io-throttle/Makefile
+++ b/testcases/kernel/controllers/io-throttle/Makefile
@@ -1,16 +1,31 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include -I../libcontrollers
-LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp
+#
+#    kernel/controllers/io-throttle testcase suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS    = $(wildcard *.c)
+top_srcdir		?= ../../../..
 
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all:	$(TARGETS)
+INSTALL_TARGETS		:=  run_io_throttle_test.sh myfunctions-io.sh
 
-clean:
-	rm -f $(TARGETS) *.o
+LDLIBS			+= -lm -lcontrollers
 
-install:
-	@set -e; for i in $(TARGETS) run_io_throttle_test.sh myfunctions-io.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/libcontrollers/Makefile b/testcases/kernel/controllers/libcontrollers/Makefile
index d604844..7762ce0 100644
--- a/testcases/kernel/controllers/libcontrollers/Makefile
+++ b/testcases/kernel/controllers/libcontrollers/Makefile
@@ -1,15 +1,29 @@
-TARGET=libcontrollers.a
-SRCS=$(wildcard *.c)
-OBJS=$(patsubst %.c,%.o,$(SRCS))
+#
+#    testcases/kernel/controllers library Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all : $(TARGET)
+top_srcdir		?= ../../../..
 
-$(TARGET): $(OBJS)
-	$(AR) -cr $@ $^
+include $(top_srcdir)/include/mk/testcases.mk
 
-clean:
-	rm -f $(TARGET) $(OBJS)
+LIB			:= libcontrollers.a
 
-install:
-
-
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/kernel/controllers/memcg/Makefile b/testcases/kernel/controllers/memcg/Makefile
index 9535f73..df1c98a 100644
--- a/testcases/kernel/controllers/memcg/Makefile
+++ b/testcases/kernel/controllers/memcg/Makefile
@@ -1,10 +1,29 @@
-SUBDIRS = functional regression stress
+#
+#    kernel/controllers/memcg testcase suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/testcases.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/controllers/memcg/functional/Makefile b/testcases/kernel/controllers/memcg/functional/Makefile
index 74143fa..0a25029 100644
--- a/testcases/kernel/controllers/memcg/functional/Makefile
+++ b/testcases/kernel/controllers/memcg/functional/Makefile
@@ -1,23 +1,31 @@
-CFLAGS += -Wall -O2 -g -Wextra
-LDLIBS += -lm
+#
+#    kernel/controllers/memcg/functional testcase suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-SRCS=$(wildcard *.c)
-OBJECTS=$(patsubst %.c,%.o,$(SRCS))
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-$(TARGETS): %: %.o
+INSTALL_TARGETS		:= *.sh
 
-install:
-	@set -e; for i in $(TARGETS) *.sh; do ln -f $$i ../../../../bin/$$i ; chmod +x $$i ; done
+LDLIBS			+= -lm
 
-test:
-	@./memcgroup_function_test.sh
-
-clean:
-	rm -f $(TARGETS) $(OBJECTS)
-
-uninstall:
-
-.DEFAULT: ;
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/memcg/regression/Makefile b/testcases/kernel/controllers/memcg/regression/Makefile
index b0a4975..8399c3f 100644
--- a/testcases/kernel/controllers/memcg/regression/Makefile
+++ b/testcases/kernel/controllers/memcg/regression/Makefile
@@ -1,16 +1,33 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../../include -I../../libcontrollers
-LDLIBS += -L../../../../../lib/ -lltp
+#
+#    kernel/controllers/memcg/regression testcase suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-SRCS    = $(wildcard *.c)
+top_srcdir		?= ../../../../..
 
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all:    $(TARGETS)
+CPPFLAGS		+= -I$(abs_srcdir)/../../libcontrollers
 
-clean:
-	rm -f $(TARGETS) *.o
+INSTALL_TARGETS		:= *.sh
 
-install:
-	@set -e; for i in $(TARGETS) *.sh; do ln -f $$i ../../../../bin/$$i ; chmod +x $$i ; done
+LDLIBS			+= -lm
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/memcg/stress/Makefile b/testcases/kernel/controllers/memcg/stress/Makefile
index 8c0d8b7..0dbc994 100644
--- a/testcases/kernel/controllers/memcg/stress/Makefile
+++ b/testcases/kernel/controllers/memcg/stress/Makefile
@@ -1,23 +1,33 @@
-CFLAGS += -Wall -O2 -g -Wextra
-LDLIBS += -lm
+#
+#    kernel/controllers/memcg/stress testcase suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-SRCS=$(wildcard *.c)
-OBJECTS=$(patsubst %.c,%.o,$(SRCS))
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-$(TARGETS): %: %.o
+CPPFLAGS		+= -I$(abs_srcdir)/../../libcontrollers
 
-install:
-	@set -e; for i in $(TARGETS) *.sh; do ln -f $$i ../../../../bin/$$i ; chmod +x $$i ; done
+INSTALL_TARGETS		:= *.sh
 
-test:
-	@./memcgroup_stress_test.sh
+LDLIBS			+= -lm
 
-clean:
-	rm -f $(TARGETS) $(OBJECTS)
-
-uninstall:
-
-.DEFAULT: ;
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/memctl/Makefile b/testcases/kernel/controllers/memctl/Makefile
index a55f9a0..4267057 100644
--- a/testcases/kernel/controllers/memctl/Makefile
+++ b/testcases/kernel/controllers/memctl/Makefile
@@ -1,16 +1,30 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include -I../libcontrollers
-LDLIBS += -lm -L../../../../lib/ -L../libcontrollers -lcontrollers -lltp
+#
+#    kernel/controllers/memctl testcase suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS    = $(wildcard *.c)
+top_srcdir		?= ../../../..
 
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-all:	$(TARGETS)
+INSTALL_TARGETS		:= *.sh
 
-clean:
-	rm -f $(TARGETS) *.o
-
-install:
-	@set -e; for i in $(TARGETS) run_memctl_test.sh myfunctions.sh; do ln -f $$i ../../../bin/$$i ; chmod +x $$i ; done
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/controllers/test_controllers.sh b/testcases/kernel/controllers/test_controllers.sh
index f8e8458..f3a1daa 100755
--- a/testcases/kernel/controllers/test_controllers.sh
+++ b/testcases/kernel/controllers/test_controllers.sh
@@ -90,9 +90,7 @@
 
 	if [ "$FREEZER" = "freezer" ]
 	then
-		pushd $LTPROOT/testcases/kernel/controllers/freezer
-		./run.sh
-		popd
+		"$LTPROOT/testcases/bin/run_freezer.sh"
 	else
 		echo "CONTROLLERS TESTCASES: WARNING";
 		echo "Kernel does not support freezer controller";
diff --git a/testcases/kernel/fs/Makefile b/testcases/kernel/fs/Makefile
index 0881714..12e2f48 100644
--- a/testcases/kernel/fs/Makefile
+++ b/testcases/kernel/fs/Makefile
@@ -1,12 +1,30 @@
-SUBDIRS = acls doio fs_inod fsstress fs_perms fsx-linux ftest inode lftest linktest openfile proc stream fs_di fs_bind racer quota_remount
+#
+#    kernel/fs testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+# XXX (garrcoop): Need to add autoconf checks for JFS.
+FILTER_OUT_DIRS		:= dmapi
 
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/fs/acls/Makefile b/testcases/kernel/fs/acls/Makefile
index 6610db2..d684254 100644
--- a/testcases/kernel/fs/acls/Makefile
+++ b/testcases/kernel/fs/acls/Makefile
@@ -1,24 +1,40 @@
+#
+#    kernel/fs/acls testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
 check_header = $(shell \
 	if echo "\#include <$(1)>" | $(CC) -E - > /dev/null 2>&1 ; \
 	then echo yes ; \
 	else echo no ; fi)
 
-ifeq ($(call check_header,sys/xattr.h),yes)
-TARGETS := acl_file_test acl_link_test
-else
-TARGETS :=
+INSTALL_TARGETS		:= acl_test01
+
+RESULT			:= $(call check_header,sys/xattr.h)
+
+ifneq ($(RESULT),yes)
+MAKE_TARGETS		:=
 endif
 
-all: $(TARGETS)
-
-acl_file_test: acl_file_test.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o acl_file_test acl_file_test.c
-acl_link_test: acl_link_test.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o acl_link_test acl_link_test.c
-
-install:
-	chmod 755 acl_test01
-	@set -e; for i in $(TARGETS) acl_test01 ; do ln -f $$i ../../../bin/ ; done
-
-clean:
-	rm -f acl_file_test acl_link_test
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/dmapi/Makefile b/testcases/kernel/fs/dmapi/Makefile
index 643b4b4..9961b36 100644
--- a/testcases/kernel/fs/dmapi/Makefile
+++ b/testcases/kernel/fs/dmapi/Makefile
@@ -16,16 +16,17 @@
 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-#
-#	Makefile
-#
+top_srcdir		?= ../../../..
+
+include	$(top_srcdir)/include/mk/testcases.mk
 
 # dmapi_imp is platform for DMAPI implementation (currently supported: JFS)
-dmapi_imp = JFS
-# dmapi_lib is path of user space library for DMAPI implementation
-dmapi_lib = /usr/lib/libjfsdm.a
+dmapi_imp		:= JFS
 
-std_cflags = -I. -g -Wall -D$(dmapi_imp)
+# dmapi_lib is path of user space library for DMAPI implementation
+LDLIBS			+= -ljfsdm
+
+CFLAGS			+= -g -Wall -D$(dmapi_imp)
 
 #	Define USER_SPACE_FAULTS if DMAPI implementation handles user space
 #	  faults (JFS has plenty of handle code in user space, which causes
@@ -42,88 +43,20 @@
 #extra_cflags = -DDIRECTORY_LINKS
 #extra_cflags = -DINTERIOR_HOLES
 #extra_cflags = -DMULTIPLE_REGIONS
-extra_cflags = -DINTERIOR_HOLES -DMULTIPLE_REGIONS
+CFLAGS			+= -DINTERIOR_HOLES -DMULTIPLE_REGIONS
 
 cflags = $(std_cflags) $(extra_cflags)
 
 lflags = $(dmapi_lib)
 lflags_thd = $(dmapi_lib) -lpthread
 
-progs = handle session event_sn event_sd event_an pmr_pre pmr_post event_am \
-	  hole invis attr event_us disp config objref mount token right mmap \
-	  mmapfile event
+# Establish the original set of programs to compile.
+MAKE_TARGETS		:= $(patsubst %.c,%,$(wildcard $(abs_srcdir)/*.c))
+# Toss the chaff and normalize to the object directory.
+MAKE_TARGETS		:= $(filter-out %dm_test,$(MAKE_TARGETS))
 
-all	: $(progs)
+$(MAKE_TARGETS): %: %.o dm_test.o dm_test.h
 
-dm_test.h	: dm_vars.h Makefile
-	touch dm_test.h
+dm_test.o: dm_test.c dm_impl.h
 
-dm_test.o	: dm_test.c dm_test.h dm_impl.h Makefile
-	cc -c $(cflags) dm_test.c
-
-handle	: handle.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o handle handle.c dm_test.o $(lflags)
-
-session	: session.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o session session.c dm_test.o $(lflags)
-
-event_sn: event_sn.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o event_sn event_sn.c dm_test.o $(lflags_thd)
-
-event_sd: event_sd.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o event_sd event_sd.c dm_test.o $(lflags_thd)
-
-event_an: event_an.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o event_an event_an.c dm_test.o $(lflags_thd)
-
-pmr_pre : pmr_pre.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o pmr_pre pmr_pre.c dm_test.o $(lflags_thd)
-
-pmr_post: pmr_post.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o pmr_post pmr_post.c dm_test.o $(lflags_thd)
-
-event_am: event_am.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o event_am event_am.c dm_test.o $(lflags_thd)
-
-hole	: hole.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o hole hole.c dm_test.o $(lflags)
-
-invis	: invis.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o invis invis.c dm_test.o $(lflags_thd)
-
-attr	: attr.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o attr attr.c dm_test.o $(lflags)
-
-event_us: event_us.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o event_us event_us.c dm_test.o $(lflags_thd)
-
-disp	: disp.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o disp disp.c dm_test.o $(lflags_thd)
-
-config	: config.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o config config.c dm_test.o $(lflags)
-
-objref	: objref.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o objref objref.c dm_test.o $(lflags_thd)
-
-mount	: mount.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o mount mount.c dm_test.o $(lflags_thd)
-
-token	: token.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o token token.c dm_test.o $(lflags_thd)
-
-right	: right.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o right right.c dm_test.o $(lflags_thd)
-
-mmap	: mmap.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o mmap mmap.c dm_test.o $(lflags_thd)
-
-mmapfile: mmapfile.c dm_test.h Makefile
-	cc $(cflags) -o mmapfile mmapfile.c $(lflags)
-
-event	: event.c dm_test.h Makefile dm_test.o
-	cc $(cflags) -o event event.c dm_test.o $(lflags_thd)
-
-clean	: 
-	rm -f *.o
-	rm -f $(progs)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/dmapi/dm_test.h b/testcases/kernel/fs/dmapi/dm_test.h
index d6cafff..bcb3d27 100644
--- a/testcases/kernel/fs/dmapi/dm_test.h
+++ b/testcases/kernel/fs/dmapi/dm_test.h
@@ -23,7 +23,9 @@
  */
 
 #include <stdlib.h>
+#if HAVE_SYS_JFSDMAPI_H
 #include <sys/jfsdmapi.h>
+#endif
 #include "dm_vars.h"
 
 /* The following constants are implementation-independent */
@@ -130,6 +132,7 @@
 void dm_SkipVariation(void);
 void dm_EndVariation_SuccessExpected(char *funcname, int expectedRC, int actualRC);
 void dm_EndVariation_FailureExpected(char *funcname, int expectedRC, int actualRC, int expectedErrno);
+#if HAVE_SYS_JFSDMAPI_H
 int dm_CheckVariation_SuccessExpected(int expectedRC, int actualRC, dm_eventtype_t expectedEvent, dm_eventtype_t actualEvent);
 int dm_CheckVariation_FailureExpected(int expectedRC, int actualRC, int expectedErrno, dm_eventtype_t expectedEvent, dm_eventtype_t actualEvent);
 void dm_LogHandle(char *hdl, int len);
@@ -165,3 +168,4 @@
 extern configResult_t dmimpl_expectedResults[];
 extern eventValidity_t dmimpl_validEvents[];
 extern dm_eventset_t dmimpl_eventset;
+#endif
diff --git a/testcases/kernel/fs/doio/Makefile b/testcases/kernel/fs/doio/Makefile
index 6e8f2de..2e5df15 100644
--- a/testcases/kernel/fs/doio/Makefile
+++ b/testcases/kernel/fs/doio/Makefile
@@ -1,28 +1,32 @@
+#
+#    kernel/fs/doio testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-CFLAGS+= -Wall -I../../../../include -D_LARGEFILE64_SOURCE
-LDLIBS+= -L../../../../lib -lltp -lrt -lpthread
+top_srcdir		?= ../../../..
 
-TARGETS=doio growfiles rwtest iogen
-SRCS=$(wildcard *.c)
-OBJS=$(patsubst %.c,%.o,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CFLAGS			+= -D_LARGEFILE64_SOURCE
+LDLIBS			+= -lrt -lpthread
 
-doio: doio.o
-		 $(CC) -o $@ $^ -I. $(CFLAGS) $(LDFLAGS) $(LDLIBS)
+INSTALL_TARGETS		:= rwtest.sh
 
-growfiles: growfiles.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
-
-iogen: iogen.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
-
-rwtest: rwtest.sh doio iogen
-	cp rwtest.sh rwtest
-	chmod a+rx rwtest
-
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(OBJS) $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/doio/rwtest.sh b/testcases/kernel/fs/doio/rwtest.sh
index 29aff01..6afebed 100644
--- a/testcases/kernel/fs/doio/rwtest.sh
+++ b/testcases/kernel/fs/doio/rwtest.sh
@@ -36,7 +36,7 @@
 
 trap "exit 0" INT  # Until the smarter signal handler is engaged, below.
 
-Prog=$(basename $0)
+Prog=${0##*/}
 
 iOpts=""
 dOpts=""
@@ -289,7 +289,7 @@
 # 1,000,000 blocks if no limit is specified
 #
 
-case $(uname -s) in
+case "$(uname -s)" in
 	IRIX | IRIX64 )		dfOpts="-Pb"	;;
 	Linux)			dfOpts="-P"	;;
 	*)			dfOpts="-PB"	;;
diff --git a/testcases/kernel/fs/fs-bench/Makefile b/testcases/kernel/fs/fs-bench/Makefile
index 66b82a8..728cb70 100644
--- a/testcases/kernel/fs/fs-bench/Makefile
+++ b/testcases/kernel/fs/fs-bench/Makefile
@@ -1,25 +1,41 @@
-UTILS=boxmuler.o
-EXECS=cr ra radc 
-SCRIPTS=modaltr.sh test.sh test2.sh
-CFLAGS=-O3 
-all: ${EXECS}
-	@echo done
+#
+#    kernel/fs/fs-bench testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-cr: create-files.o ${UTILS}
-	${CC} ${UTILS} create-files.o -lm -o cr
+top_srcdir			?= ../../../..
 
-ra: random-access.o
-	${CC} random-access.o -o ra
+include $(top_srcdir)/include/mk/env_pre.mk
 
-radc: random-del-create.o ${UTILS}
-	${CC}  ${UTILS} random-del-create.o -lm -o radc
+INSTALL_TARGETS			:= modaltr.sh test.sh test2.sh
 
-install:
-	 @set -e; for i in $(EXECS) $(SCRIPTS); do ln -f $$i ../../../bin/$$i ; done
+LDLIBS				+= -lm
 
-dist:
-	(make clean ; cd .. ; tar zcvf fs-bench.tar.gz  fs-bench) 
+create-files: boxmuler.o create-files.o
 
-clean: 
-	rm ${EXECS} *.o 
+random-access-del-create: boxmuler.o random-access-del-create.o
 
+MAKE_TARGETS			:= create-files random-access\
+				   random-access-del-create
+
+dist: clean
+	(cd $(abs_srcdir); tar zcvf fs-bench.tar.gz $(abs_srcdir)) 
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/fs-bench/random-access-del-create.c b/testcases/kernel/fs/fs-bench/random-access-del-create.c
new file mode 100644
index 0000000..3322d92
--- /dev/null
+++ b/testcases/kernel/fs/fs-bench/random-access-del-create.c
@@ -0,0 +1,135 @@
+/* random-del-create.c (GPL)*/
+/* Hironobu SUZUKI <hironobu@h2np.net> */
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <time.h>
+#include <stdlib.h>
+#define FAIL 0
+#define SUCCESS 1
+
+int openlog[2]={0,0};
+
+#define MAXNUM 0x100000
+
+#define  MAXERROR 1024
+
+extern int box_muler(int, int);
+extern void create_or_delete(char *);
+
+int cfilecount=0;
+int dfilecount=0;
+int errorcount=0;
+
+int
+main(int ac, char **av)
+{
+  int r;
+  char fname[1024];
+  time_t t;
+  int i;
+  int m;
+
+  if ( ac != 2 ) {
+    printf("%s hex-style-filename \n", av[0]);
+    printf("ex) %s 00022300\n", av[0]);
+    exit(1);
+  }
+  sscanf(av[1],"%x",&m);
+  if ( m < 1 || m > MAXNUM ) {
+    printf("out of size %d\n",m);
+    exit(1);
+  }
+
+  time(&t);
+  srandom((unsigned int)getpid()^(((unsigned int)t<<16)| (unsigned int)t>>16));
+
+
+  /* 00/00/00/00 */
+  for ( i = 0 ; i < m ; i++) {
+    r = random() % m;
+    sprintf(fname,"00/%2.2x/%2.2x/00%2.2x%2.2x%2.2x",
+	   ((r>>16)&0xFF),
+	   ((r>>8)&0xFF),
+	   ((r>>16)&0xFF),
+	   ((r>>8)&0xFF),
+	   (r&0xFF));
+    create_or_delete(fname);
+  }
+  fprintf(stderr,"Total create files: %d\n",cfilecount);
+  fprintf(stderr,"Total delete files: %d\n",dfilecount);
+  fprintf(stderr,"Total error       : %d\n",errorcount);
+  exit(0);
+}
+
+#define MAXFSIZE (192*1024)
+#define AVEFSIZE (MAXFSIZE/2)
+#define POOLDISKSPACE (AVEFSIZE*128)
+
+static int disk_space_pool=0;
+void create_or_delete(char *fname)
+{
+  int r;
+  int fsize;
+
+  r = (random() & 1);
+  if ( r && disk_space_pool > POOLDISKSPACE) {
+    /* create */
+    create_file(fname) ;
+  }
+  else {
+    delete_file(fname);
+  }
+  if ( (errorcount > dfilecount ||  errorcount > cfilecount) && (errorcount > MAXERROR)) {
+    fprintf(stderr,"too much error -- stop\n");
+    fprintf(stderr,"Total create files: %d\n",cfilecount);
+    fprintf(stderr,"Total delete files: %d\n",dfilecount);
+    fprintf(stderr,"Total error       : %d\n",errorcount);
+    exit(1);
+  }
+}
+
+create_file(char *filename)
+{
+  int fd;
+  int randomsize;
+  char wbuf[MAXFSIZE];
+  if ( (fd=creat(filename, S_IRWXU)) < 0) {
+    errorcount++;
+    return(-1);
+  }
+  if ((randomsize=box_muler(0,MAXFSIZE)) < 0) {
+    randomsize = MAXFSIZE;
+  }
+  if (write(fd,wbuf,randomsize) < 0 ) {
+    errorcount++;
+    close(fd);
+    return(-1);
+  }
+  cfilecount++;
+  disk_space_pool -= randomsize;
+  close(fd);
+}
+
+#include <sys/stat.h>
+#include <unistd.h>
+
+delete_file(char *filename)
+{
+  struct stat buf;
+  int st;
+  st = stat(filename, &buf);
+  if ( st < 0 ) {
+    errorcount++;
+    return (-1);
+  }
+  disk_space_pool += buf.st_size;
+  if ( unlink(filename) < 0 ) {
+    errorcount++;
+    return(-1);
+  }
+  dfilecount++;
+}
diff --git a/testcases/kernel/fs/fs_bind/Makefile b/testcases/kernel/fs/fs_bind/Makefile
index 34e7538..dccb027 100644
--- a/testcases/kernel/fs/fs_bind/Makefile
+++ b/testcases/kernel/fs/fs_bind/Makefile
@@ -1,11 +1,29 @@
-# Propagate make "commands" (TARGETS) to subdirs
-TARGETS=all clean install uninstall
-SUBDIRS=bin
+#
+#    kernel/fs/fs_bind testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-.PHONY: $(TARGETS)
+top_srcdir			?= ../../../..
 
-$(TARGETS):%:
-	@set -e ; \
-	for dir in $(SUBDIRS); do \
-		$(MAKE) -C $$dir $@ ; \
-	done
+include $(top_srcdir)/include/mk/env_pre.mk
+
+RECURSIVE_TARGETS		:= all install uninstall
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/fs/fs_bind/bin/Makefile b/testcases/kernel/fs/fs_bind/bin/Makefile
index 0fac9d6..b4b75b0 100644
--- a/testcases/kernel/fs/fs_bind/bin/Makefile
+++ b/testcases/kernel/fs/fs_bind/bin/Makefile
@@ -1,28 +1,27 @@
-.PHONY: all clean install
+#
+#    testcases/kernel/fs/fs_bind/bin Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-LTP_SRC_ROOT=../../../../..
-LTP_BIN=$(LTP_SRC_ROOT)/testcases/bin
-#CFLAGS+= -I$(LTP_SRC_ROOT)/include -Wall -g
-CFLAGS+= -Wall -g
-#LIBS+= -L$(LTP_SRC_ROOT)/lib -lltp
-LIBS+=
+top_srcdir		?= ../../../../..
 
-all: smount nsclone
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install: all
-	#@ln -f nsclone $(LTP_BIN)/nsclone
-	#@ln -f smount $(LTP_BIN)/smount
-	@/bin/true
-
-uninstall:
-	#rm -f $(LTP_BIN)/nsclone $(LTP_BIN)/smount
-	@/bin/true
-
-nsclone: nsclone.c
-	$(CC) $(CFLAGS) $(LIBS) -o nsclone nsclone.c
-
-smount: smount.c
-	$(CC) $(CFLAGS) $(LIBS) -o smount smount.c
-
-clean:
-	rm -f smount nsclone
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/fs_di/Makefile b/testcases/kernel/fs/fs_di/Makefile
index 1cd2689..2082a6e 100644
--- a/testcases/kernel/fs/fs_di/Makefile
+++ b/testcases/kernel/fs/fs_di/Makefile
@@ -1,11 +1,31 @@
-CFLAGS+= -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+#
+#    kernel/fs/fs_bind testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir			?= ../../../..
 
-install:
-	@set -e; for i in $(TARGETS) fs_di; do ln -f $$i ../../../bin/$$i ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	rm -f $(TARGETS)
+CFLAGS				+= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+
+INSTALL_TARGETS			:= fs_di
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/fs_inod/Makefile b/testcases/kernel/fs/fs_inod/Makefile
index 7bfbbf0..abc0079 100644
--- a/testcases/kernel/fs/fs_inod/Makefile
+++ b/testcases/kernel/fs/fs_inod/Makefile
@@ -1,8 +1,31 @@
-TARGETS=fs_inod
+#
+#    kernel/fs/fs_inod testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done
+top_srcdir			?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS			:= fs_inod
+
+MAKE_TARGETS			:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/fs_perms/Makefile b/testcases/kernel/fs/fs_perms/Makefile
index 8ccf6ec..48aa7d6 100644
--- a/testcases/kernel/fs/fs_perms/Makefile
+++ b/testcases/kernel/fs/fs_perms/Makefile
@@ -1,15 +1,29 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include
-LDLIBS += -lltp
-LDFLAGS += -L../../../../lib
+#
+#    kernel/fs/fs_perms testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-TARGETS = fs_perms testx
+top_srcdir			?= ../../../..
 
-all: fs_perms testx
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done
-	cp fs_perms_simpletest.sh ../../../bin/
+INSTALL_TARGETS			:= fs_perms_simpletest.sh
 
-clean:
-	rm -f *.o fs_perms testx
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/fsstress/Makefile b/testcases/kernel/fs/fsstress/Makefile
index 5a73ebc..5949888 100644
--- a/testcases/kernel/fs/fsstress/Makefile
+++ b/testcases/kernel/fs/fsstress/Makefile
@@ -1,15 +1,30 @@
-CFLAGS += -Wall -g -DNO_XFS -I. -D_LARGEFILE64_SOURCE -D_GNU_SOURCE
-LDFLAGS += 
+#
+#    kernel/fs/fsstress testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir			?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f fsstress ../../../bin
+CPPFLAGS			+= -DNO_XFS -I$(abs_srcdir) \
+				   -D_LARGEFILE64_SOURCE -D_GNU_SOURCE
 
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/fsx-linux/Makefile b/testcases/kernel/fs/fsx-linux/Makefile
index 214ac96..f55ec53 100644
--- a/testcases/kernel/fs/fsx-linux/Makefile
+++ b/testcases/kernel/fs/fsx-linux/Makefile
@@ -1,17 +1,34 @@
-CFLAGS += -w -O
-LDFLAGS += 
+#
+#    kernel/fs/fsx-linux testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir			?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f fsxtest02 ../../../bin
-	ln -f fsxtest ../../../bin
-	ln -f fsx-linux ../../../bin
+CPPFLAGS			+= -DNO_XFS -I$(abs_srcdir) \
+				   -D_LARGEFILE64_SOURCE -D_GNU_SOURCE
 
-clean:
-	rm -f $(TARGETS)
+WCFLAGS				+= -w
 
+INSTALL_TARGETS			:= fsxtest*
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/ftest/Makefile b/testcases/kernel/fs/ftest/Makefile
index fe896cc..09b7a05 100644
--- a/testcases/kernel/fs/ftest/Makefile
+++ b/testcases/kernel/fs/ftest/Makefile
@@ -1,38 +1,31 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
-#  Copyright (c) Cyril Hrubis chrubis@suse.cz 2009
+#    kernel/fs/ftest testcases Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-# description	: make(1) description file for the send(2) tests.	  #
-###########################################################################
-CFLAGS+=	-I../../../../include -W -Wall -g
-LOADLIBES+=	-L../../../../lib -lltp
+top_srcdir			?= ../../../..
 
-SRCS=$(wildcard ftest*.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+MAKE_TARGETS			:= $(patsubst $(abs_srcdir)/%.c,%,$(filter-out %/libftest.c,$(wildcard $(abs_srcdir)/*.c)))
 
-$(TARGETS): libftest.o
+$(MAKE_TARGETS): %: %.o libftest.o
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS) libftest.o
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/inode/Makefile b/testcases/kernel/fs/inode/Makefile
index 8241d8f..1c0c44b 100644
--- a/testcases/kernel/fs/inode/Makefile
+++ b/testcases/kernel/fs/inode/Makefile
@@ -1,36 +1,29 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
+#    kernel/fs/inode testcases Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-###########################################################################
-CFLAGS+=	-I../../../../include -g -O -Wall -DLINUX
-LOADLIBES+=	-L../../../../lib -lltp 
+top_srcdir			?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CPPFLAGS			+= -DLINUX
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/lftest/Makefile b/testcases/kernel/fs/lftest/Makefile
index 05817dc..4c42caa 100644
--- a/testcases/kernel/fs/lftest/Makefile
+++ b/testcases/kernel/fs/lftest/Makefile
@@ -1,11 +1,29 @@
-CFLAGS+= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+#
+#    kernel/fs/lftest testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir			?= ../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+include $(top_srcdir)/include/mk/testcases.mk
 
-clean:
-	rm -f $(TARGETS)
+CPPFLAGS			+= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/linktest/Makefile b/testcases/kernel/fs/linktest/Makefile
index e023d04..7e402c0 100644
--- a/testcases/kernel/fs/linktest/Makefile
+++ b/testcases/kernel/fs/linktest/Makefile
@@ -1,8 +1,29 @@
-TARGETS=linktest.pl
+#
+#    kernel/fs/linktest testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done
+top_srcdir			?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS			:= linktest.pl
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/openfile/Makefile b/testcases/kernel/fs/openfile/Makefile
index 75c6d28..9b8a162 100644
--- a/testcases/kernel/fs/openfile/Makefile
+++ b/testcases/kernel/fs/openfile/Makefile
@@ -1,13 +1,29 @@
-CFLAGS += -Wall
-LOADLIBES += -lpthread
+#
+#    kernel/fs/openfile testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir			?= ../../../..
 
-all: $(TARGETS)
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done
+include $(top_srcdir)/include/mk/testcases.mk
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS				+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/proc/Makefile b/testcases/kernel/fs/proc/Makefile
index 7a2b2cf..131c21e 100644
--- a/testcases/kernel/fs/proc/Makefile
+++ b/testcases/kernel/fs/proc/Makefile
@@ -16,18 +16,10 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-include ../../../../config.mk
+top_srcdir		?= ../../../..
 
-CFLAGS+=	-I../../../../include
-LDLIBS+=	-L../../../../lib -lltp $(SELINUX_LIBS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+LDLIBS			+= $(SELINUX_LIBS)
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/quota_remount/Makefile b/testcases/kernel/fs/quota_remount/Makefile
index 4bb3bcc..a63b36f 100644
--- a/testcases/kernel/fs/quota_remount/Makefile
+++ b/testcases/kernel/fs/quota_remount/Makefile
@@ -1,26 +1,25 @@
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2009                 ##
-##                                                                            ##
-## This program is free software;  you can redistribute it and#or modify      ##
-## it under the terms of the GNU General Public License as published by       ##
-## the Free Software Foundation; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    ##
-##                                                                            ##
-################################################################################
+#
+#  Copyright (c) International Business Machines  Corp., 2001
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
 
-all: 
+top_srcdir		?= ../../../..
 
-install: 
-	@ln -f quota_remount_test01.sh ../../../bin/;
+include $(top_srcdir)/include/mk/testcases.mk
 
-clean:
+INSTALL_TARGETS		:= quota_remount_test01.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/racer/Makefile b/testcases/kernel/fs/racer/Makefile
index b39782b..81b88e4 100644
--- a/testcases/kernel/fs/racer/Makefile
+++ b/testcases/kernel/fs/racer/Makefile
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2008
+#  Copyright (c) International Business Machines  Corp., 2001
 #
 #  This program is free software;  you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -16,12 +16,10 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
+top_srcdir		?= ../../../..
 
-all:
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	cp -r *.sh ../../../bin/
+INSTALL_TARGETS		:= *.sh
 
-clean:
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/fs/scsi/ltpscsi/Makefile b/testcases/kernel/fs/scsi/ltpscsi/Makefile
index c635c67..e404ce0 100644
--- a/testcases/kernel/fs/scsi/ltpscsi/Makefile
+++ b/testcases/kernel/fs/scsi/ltpscsi/Makefile
@@ -1,10 +1,5 @@
 SHELL = /bin/sh
 
-PREFIX=/usr/local
-INSTDIR=$(DESTDIR)/$(PREFIX)/bin
-MANDIR=$(DESTDIR)/$(PREFIX)/man
-
-
 EXECS = scsimain
 
 LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
diff --git a/testcases/kernel/fs/stream/Makefile b/testcases/kernel/fs/stream/Makefile
index c9a8283..23dd7e1 100644
--- a/testcases/kernel/fs/stream/Makefile
+++ b/testcases/kernel/fs/stream/Makefile
@@ -16,22 +16,8 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-# description	: make(1) description file for the send(2) tests.	  #
-###########################################################################
-CFLAGS+=	-I../../../../include -Wall -g
-LOADLIBES+=	-L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/include/Makefile b/testcases/kernel/include/Makefile
index b58a043..4c20863 100644
--- a/testcases/kernel/include/Makefile
+++ b/testcases/kernel/include/Makefile
@@ -1,19 +1,34 @@
-all uclinux: ../../../include/linux_syscall_numbers.h
+#
+#    kernel test suite include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-../../../include/linux_syscall_numbers.h: linux_syscall_numbers.h
-	ln -sf ../testcases/kernel/include/linux_syscall_numbers.h ../../../include/
+top_srcdir		?= ../../..
 
-clean distclean:
-	rm -f linux_syscall_numbers.h
-	rm -f ../../../include/linux_syscall_numbers.h
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install uclinux_install:
-	@true
+INSTALL_DIR		:= $(includedir)
 
-linux_syscall_numbers.h: *.in regen.sh
-	$(MAKE) regen
+MAKE_TARGETS		:= linux_syscall_numbers.h
 
-regen:
-	./regen.sh
+linux_syscall_numbers.h:
+	@set -e; $(SHELL) $(abs_srcdir)/regen.sh
 
-.PHONY: all clean distclean install regen
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/include/order b/testcases/kernel/include/order
index 8c1a489..3e2bd96 100644
--- a/testcases/kernel/include/order
+++ b/testcases/kernel/include/order
@@ -2,7 +2,6 @@
 hppa
 i386
 ia64
-microblaze
 powerpc64
 powerpc
 s390x
diff --git a/testcases/kernel/include/regen.sh b/testcases/kernel/include/regen.sh
index 0ea9bbc..4baffeb 100755
--- a/testcases/kernel/include/regen.sh
+++ b/testcases/kernel/include/regen.sh
@@ -2,6 +2,8 @@
 
 output="linux_syscall_numbers.h"
 
+srcdir=${0%/*}
+
 rm -f ${output}
 
 cat << EOF > ${output}
@@ -37,7 +39,7 @@
 })
 EOF
 
-for arch in `cat order` ; do
+for arch in $(cat ${srcdir}/order) ; do
 	echo -n "Generating data for arch $arch ... "
 
 	echo "" >> ${output}
@@ -55,7 +57,7 @@
 		#  define $nr $*
 		# endif
 		EOF
-	done < ${arch}.in
+	done < ${srcdir}/${arch}.in
 	echo "#endif" >> ${output}
 	echo "" >> ${output}
 
@@ -65,7 +67,7 @@
 echo -n "Generating stub list ... "
 echo "" >> ${output}
 echo "/* Common stubs */" >> ${output}
-for nr in $(awk '{print $1}' *.in | sort -u) ; do
+for nr in $(awk '{print $1}' ${srcdir}/*.in | sort -u) ; do
 	nr="__NR_$nr"
 	cat <<-EOF >> ${output}
 	# ifndef $nr
diff --git a/testcases/kernel/io/Makefile b/testcases/kernel/io/Makefile
index e3c394f..196be9f 100644
--- a/testcases/kernel/io/Makefile
+++ b/testcases/kernel/io/Makefile
@@ -1,10 +1,29 @@
-SUBDIRS = direct_io disktest stress_cd stress_floppy writetest aio
+#
+#    kernel/io test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+FILTER_OUT_DIRS		:= $(if $(AIO_LIBS),,aio ltp-aiodio)
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/io/aio/Makefile b/testcases/kernel/io/aio/Makefile
index 4b2c3d7..1b55ab0 100644
--- a/testcases/kernel/io/aio/Makefile
+++ b/testcases/kernel/io/aio/Makefile
@@ -1,13 +1,27 @@
-SUBDIRS = `ls */Makefile | sed "s/Makefile//g"`
+#
+#  Copyright (c) International Business Machines  Corp., 2001
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../../..
 
-install:
-	mkdir -p bin
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/testcases.mk
 
-clean:
-	rm -rf bin/
-	@set -e; for i in $(SUBDIRS) ; do $(MAKE) -C $$i clean ; done
+# XXX (garrcoop): Causing me grief with linker errors due to whacky source
+# design.
+FILTER_OUT_DIRS		:= aio02
 
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/io/aio/aio01/Makefile b/testcases/kernel/io/aio/aio01/Makefile
index 23b3f0f..8f57f9b 100644
--- a/testcases/kernel/io/aio/aio01/Makefile
+++ b/testcases/kernel/io/aio/aio01/Makefile
@@ -20,20 +20,11 @@
 # name of file	: Makefile						  #
 # description	: make(1) description file                                #
 ###########################################################################
-include ../../../../../config.mk
 
-CFLAGS+=	-I../../../../../include -Wall
-LOADLIBES+=	$(AIO_LIBS) -L../../../../../lib -lltp
+top_srcdir		?= ../../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= $(AIO_LIBS)
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/io/aio/aio02/Makefile b/testcases/kernel/io/aio/aio02/Makefile
index 6ab7d46..a2620d5 100644
--- a/testcases/kernel/io/aio/aio02/Makefile
+++ b/testcases/kernel/io/aio/aio02/Makefile
@@ -1,20 +1,38 @@
-include ../../../../../config.mk
-# foo.
-TEST_SRCS:=$(shell find cases/ -name \*.c | sort -n -t/ -k2)
-PROGS:=$(patsubst %.c,%,$(TEST_SRCS))
-HARNESS_SRCS:=main.c
-# io_queue.c
+#
+#    kernel/io/aio/aio2 testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-CFLAGS+=-Wall  -g -O -I../../../../../include -Wall
-LDFLAGS+=-L../../../../../lib -lltp $(AIO_LIBS)
-#-lpthread -lrt
-all: $(PROGS)
+top_srcdir		?= ../../../../..
 
-$(PROGS): %: %.c $(HARNESS_SRCS) Makefile
-	$(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c $(LDFLAGS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-clean:
-	rm -f $(PROGS) *.o runtests.out rofile wofile rwfile
+# Needed for common.h...
+CPPFLAGS		+= -D_GNU_SOURCE
 
-install:
+INSTALL_TARGETS		:= runfstests.sh
 
+LDLIBS			+= $(AIO_LIBS)
+
+MAKE_TARGETS		:= $(filter-out main,$(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)))
+
+$(MAKE_TARGETS): %: %.o main.o
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/io/aio/aio02/aio_tio.c b/testcases/kernel/io/aio/aio02/aio_tio.c
new file mode 100644
index 0000000..3239a28
--- /dev/null
+++ b/testcases/kernel/io/aio/aio02/aio_tio.c
@@ -0,0 +1,285 @@
+/*************************************************************************************
+*
+*  Copyright (c) International Business Machines  Corp., 2003
+*
+*  This program is free software;  you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  This program is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+*  the GNU General Public License for more details.
+*
+*  You should have received a copy of the GNU General Public License
+*  along with this program;  if not, write to the Free Software
+*  Foundation,
+*
+*  FILE        : aio_tio
+*  USAGE       : runfstest case/aio_tio
+*
+*  DESCRIPTION : This program will test Asynchronous I/O for 2.5 Kernel infrastructure
+*  REQUIREMENTS:
+*                1) libaio-0.3.92 or up for 2.5 kernal
+*                2) glibc 2.1.91 or up
+*  HISTORY     :
+*      11/03/2003 Kai Zhao (ltcd3@cn.ibm.com)
+*
+*  CODE COVERAGE:
+*                 68.3% - fs/aio.c
+*
+************************************************************************************/
+
+#include "common.h"
+
+#if HAVE_LIBAIO_H
+
+#define AIO_MAXIO 32
+#define AIO_BLKSIZE (64*1024)
+static int alignment = 512;
+static int wait_count = 0;
+
+
+/*
+ * write work done
+ *
+ */
+static void work_done(io_context_t ctx, struct iocb *iocb, long res, long res2)
+{
+
+	if (res2 != 0) {
+		io_error("aio write", res2);
+	}
+
+	if (res != iocb->u.c.nbytes) {
+		fprintf(stderr, "write missed bytes expect %lu got %ld\n",
+			iocb->u.c.nbytes, res2);
+		exit(1);
+	}
+	wait_count --;
+}
+
+/*
+ * io_wait_run() - wait for an io_event and then call the callback.
+ */
+int io_wait_run(io_context_t ctx, struct timespec *to)
+{
+	struct io_event events[AIO_MAXIO];
+	struct io_event *ep;
+	int ret, n;
+
+	/*
+	 * get up to aio_maxio events at a time.
+	 */
+	ret = n = io_getevents( ctx, 1, AIO_MAXIO, events, to );
+
+	/*
+	 * Call the callback functions for each event.
+	 */
+	for ( ep = events ; n-- > 0 ; ep++ ) {
+		io_callback_t cb = ( io_callback_t)ep->data ; struct iocb *iocb = ep->obj ; cb(ctx, iocb, ep->res, ep->res2);
+	}
+	return ret;
+}
+
+
+int io_tio(char *pathname , int flag , int n , int operation)
+{
+	int res , fd = 0 , i = 0;
+	void * bufptr = NULL;
+	off_t offset = 0;
+	struct timespec timeout;
+
+	io_context_t myctx;
+	struct iocb iocb_array[AIO_MAXIO];
+	struct iocb *iocbps[AIO_MAXIO];
+
+	fd = open ( pathname , flag, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+	if ( fd <= 0 ) {
+		perror ( " open : file " );
+		return -1;
+	}
+
+	res = io_queue_init(n, &myctx);
+	//printf ( " res = %d \n", res);
+
+	for ( i = 0 ; i < AIO_MAXIO ; i ++ ) {
+	
+		switch (operation) {
+			case IO_CMD_FSYNC :
+			case IO_CMD_FDSYNC :
+			case IO_CMD_PWRITE :
+			  {
+				if ( posix_memalign ( &bufptr , alignment , AIO_BLKSIZE )) {
+					perror ( " posix_memalign failed " );
+					return -1;
+				}
+				memset ( bufptr , 0 , AIO_BLKSIZE );
+			
+				io_prep_pwrite ( &iocb_array[i] , fd , bufptr , AIO_BLKSIZE , offset );
+				io_set_callback( &iocb_array[i] , work_done );
+				iocbps[i] = &iocb_array[i];
+				offset += AIO_BLKSIZE;
+			  }
+			  break;
+			case IO_CMD_PREAD :
+			  {
+				if ( posix_memalign ( &bufptr , alignment , AIO_BLKSIZE )) {
+					perror ( " posix_memalign failed " );
+					return -1;
+				}
+				memset ( bufptr , 0 , AIO_BLKSIZE );
+			
+				io_prep_pread ( &iocb_array[i] , fd , bufptr , AIO_BLKSIZE , offset );
+				io_set_callback( &iocb_array[i] , work_done );
+				iocbps[i] = &iocb_array[i];
+				offset += AIO_BLKSIZE;
+			  }
+			  break;
+			case IO_CMD_POLL :
+			  {
+			 
+			  }
+			  break;
+			case IO_CMD_NOOP :
+			  {
+			 
+			  }
+			  break;
+			default:
+			  {
+			  	fprintf ( stderr , "CMD Failed \n" );
+			  	return -1;
+			  }
+			  break;
+		}
+	}
+
+	do {
+		res = io_submit(myctx , AIO_MAXIO , iocbps);
+	} while (res == -EAGAIN);
+	if (res < 0 ) {
+		io_error("io_submit tio", res);
+	}
+
+	/*
+	 * We have submitted all the i/o requests. Wait for at least one to complete
+	 * and call the callbacks.
+	 */
+	wait_count = AIO_MAXIO;
+
+	timeout.tv_sec = 30;
+	timeout.tv_nsec = 0;
+
+	switch ( operation ) {
+		case IO_CMD_PREAD :
+		case IO_CMD_PWRITE :
+		  {
+			while ( wait_count ) {
+				res = io_wait_run( myctx , &timeout );
+				if ( res < 0 )
+					io_error("io_wait_run", res);
+			}
+		  }
+		  break;
+		case IO_CMD_FSYNC :
+		  {
+			for ( i = 0 ; i < AIO_MAXIO ; i ++ ) {
+				res = io_fsync( myctx , iocbps[i] , work_done , fd);
+				if ( res  < 0 ) {
+					io_error("io_fsync write", res);
+				}
+			}
+		  }
+		  break;
+		case IO_CMD_FDSYNC :
+		  {
+			for ( i = 0 ; i < AIO_MAXIO ; i ++ ) {
+				res = io_fdsync( myctx , iocbps[i] , work_done , fd);
+				if ( res  < 0 ) {
+					io_error("io_fsync write", res);
+				}
+			}
+		  }
+		  break;
+		default :
+		  {
+		 
+		  }
+		  break;
+	}
+
+
+	close ( fd );
+
+	for ( i = 0 ; i < AIO_MAXIO ; i ++ ) {
+		if ( iocb_array[i].u.c.buf != NULL ) {
+			free ( iocb_array[i].u.c.buf );
+		}
+	}
+
+	io_queue_release ( myctx );
+
+	return 0;
+}
+
+int test_main(void)
+{
+	int	status = 0 ;
+	//char *filepath = "testdir/file1";
+
+    printf("running test 1 \n");
+	status = io_tio( "testdir/file1" , O_TRUNC | O_DIRECT | O_WRONLY | O_CREAT | O_LARGEFILE , AIO_MAXIO , IO_CMD_PWRITE);
+	if ( status ) {
+		return status;
+	}
+
+    printf("running test 2 \n");
+	status = io_tio( "testdir/file1" , O_RDONLY | O_DIRECT | O_LARGEFILE , AIO_MAXIO , IO_CMD_PREAD);
+	if ( status ) {
+		return status;
+	}
+
+    printf("running test 3 \n");
+	status = io_tio( "testdir/file1" , O_TRUNC | O_RDWR , AIO_MAXIO , IO_CMD_PWRITE );
+	if ( status ) {
+		return status;
+	}
+
+    printf("running test 4 \n");
+	status = io_tio( "testdir/file1" , O_RDWR , AIO_MAXIO , IO_CMD_PREAD );
+	if ( status ) {
+		return status;
+	}
+	
+    printf("running test 5 \n");
+	status = io_tio( "testdir/file1" , O_TRUNC | O_WRONLY , AIO_MAXIO , IO_CMD_PWRITE );
+	if ( status ) {
+		return status;
+	}
+
+    printf("running test 6 \n");
+	status = io_tio( "testdir/file1" , O_RDONLY , AIO_MAXIO , IO_CMD_PREAD );
+	if ( status ) {
+		return status;
+	}
+
+    printf("running test 7 \n");
+	status = io_tio( "testdir/file2" , O_TRUNC | O_DIRECT | O_WRONLY | O_CREAT | O_LARGEFILE ,
+				AIO_MAXIO , IO_CMD_FSYNC);
+	if ( status ) {
+		return status;
+	}
+
+    printf("running test 8 \n");
+	status = io_tio( "testdir/file2" , O_TRUNC | O_DIRECT | O_WRONLY | O_CREAT | O_LARGEFILE ,
+				AIO_MAXIO , IO_CMD_FDSYNC);
+	if ( status ) {
+		return status;
+	}
+
+	return status;
+}
+
+#endif
diff --git a/testcases/kernel/io/aio/aio02/cases/aio_tio.c b/testcases/kernel/io/aio/aio02/cases/aio_tio.c
index 3986258..3ca1cb2 100644
--- a/testcases/kernel/io/aio/aio02/cases/aio_tio.c
+++ b/testcases/kernel/io/aio/aio02/cases/aio_tio.c
@@ -16,18 +16,18 @@
 *  along with this program;  if not, write to the Free Software
 *  Foundation,
 *
-*  FILE        : aio_tio
-*  USAGE       : runfstest case/aio_tio
+*  FILE		: aio_tio
+*  USAGE	   : runfstest case/aio_tio
 *
 *  DESCRIPTION : This program will test Asynchronous I/O for 2.5 Kernel infrastructure
 *  REQUIREMENTS:
-*                1) libaio-0.3.92 or up for 2.5 kernal
-*                2) glibc 2.1.91 or up
-*  HISTORY     :
-*      11/03/2003 Kai Zhao (ltcd3@cn.ibm.com)
+*				1) libaio-0.3.92 or up for 2.5 kernal
+*				2) glibc 2.1.91 or up
+*  HISTORY	 :
+*	  11/03/2003 Kai Zhao (ltcd3@cn.ibm.com)
 *
 *  CODE COVERAGE:
-*                 68.3% - fs/aio.c
+*				 68.3% - fs/aio.c
 *
 ************************************************************************************/
 
@@ -69,21 +69,21 @@
 	/*
 	 * get up to aio_maxio events at a time.
 	 */
-	ret = n = io_getevents( ctx, 1, AIO_MAXIO, events, to );
+	ret = n = io_getevents(ctx, 1, AIO_MAXIO, events, to);
 
 	/*
 	 * Call the callback functions for each event.
 	 */
-	for ( ep = events ; n-- > 0 ; ep++ ) {
-		io_callback_t cb = ( io_callback_t)ep->data ; struct iocb *iocb = ep->obj ; cb(ctx, iocb, ep->res, ep->res2);
+	for (ep = events ; n-- > 0 ; ep++) {
+		io_callback_t cb = (io_callback_t)ep->data ; struct iocb *iocb = ep->obj ; cb(ctx, iocb, ep->res, ep->res2);
 	}
 	return ret;
 }
 
 
-int io_tio(char *pathname , int flag , int n , int operation)
+int io_tio(char *pathname, int flag, int n, int operation)
 {
-	int res , fd = 0 , i = 0;
+	int res, fd = 0, i = 0;
 	void * bufptr = NULL;
 	off_t offset = 0;
 	struct timespec timeout;
@@ -92,71 +92,63 @@
 	struct iocb iocb_array[AIO_MAXIO];
 	struct iocb *iocbps[AIO_MAXIO];
 
-	fd = open ( pathname , flag, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-	if ( fd <= 0 ) {
-		perror ( " open : file " );
+	fd = open (pathname, flag, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+	if (fd <= 0) {
+		perror (" open : file ");
 		return -1;
 	}
 
 	res = io_queue_init(n, &myctx);
-	//printf ( " res = %d \n", res);
+	//printf (" res = %d \n", res);
 
-	for ( i = 0 ; i < AIO_MAXIO ; i ++ ) {
+	for (i = 0 ; i < AIO_MAXIO ; i ++) {
 	
 		switch (operation) {
-			case IO_CMD_FSYNC :
-			case IO_CMD_FDSYNC :
-			case IO_CMD_PWRITE :
-			  {
-				if ( posix_memalign ( &bufptr , alignment , AIO_BLKSIZE )) {
-					perror ( " posix_memalign failed " );
-					return -1;
-				}
-				memset ( bufptr , 0 , AIO_BLKSIZE );
+		case IO_CMD_FSYNC :
+		case IO_CMD_FDSYNC :
+		case IO_CMD_PWRITE :
+			if (posix_memalign (&bufptr, alignment, AIO_BLKSIZE)) {
+				perror (" posix_memalign failed ");
+				return -1;
+			}
+			memset (bufptr, 0, AIO_BLKSIZE);
+
+			io_prep_pwrite (&iocb_array[i], fd, bufptr ,
+					 AIO_BLKSIZE, offset);
+			io_set_callback(&iocb_array[i], work_done);
+			iocbps[i] = &iocb_array[i];
+			offset += AIO_BLKSIZE;
 			
-				io_prep_pwrite ( &iocb_array[i] , fd , bufptr , AIO_BLKSIZE , offset );
-				io_set_callback( &iocb_array[i] , work_done );
-				iocbps[i] = &iocb_array[i];
-				offset += AIO_BLKSIZE;
-			  }
-			  break;
-			case IO_CMD_PREAD :
-			  {
-				if ( posix_memalign ( &bufptr , alignment , AIO_BLKSIZE )) {
-					perror ( " posix_memalign failed " );
-					return -1;
-				}
-				memset ( bufptr , 0 , AIO_BLKSIZE );
-			
-				io_prep_pread ( &iocb_array[i] , fd , bufptr , AIO_BLKSIZE , offset );
-				io_set_callback( &iocb_array[i] , work_done );
-				iocbps[i] = &iocb_array[i];
-				offset += AIO_BLKSIZE;
-			  }
-			  break;
-			case IO_CMD_POLL :
-			  {
-			 
-			  }
-			  break;
-			case IO_CMD_NOOP :
-			  {
-			 
-			  }
-			  break;
-			default:
-			  {
-			  	fprintf ( stderr , "CMD Failed \n" );
-			  	return -1;
-			  }
-			  break;
+			break;
+		case IO_CMD_PREAD :
+			if (posix_memalign (&bufptr, alignment, AIO_BLKSIZE)) {
+				perror (" posix_memalign failed ");
+				return -1;
+			}
+			memset (bufptr, 0, AIO_BLKSIZE);
+
+			io_prep_pread (&iocb_array[i], fd, bufptr ,
+					AIO_BLKSIZE, offset);
+			io_set_callback(&iocb_array[i], work_done);
+			iocbps[i] = &iocb_array[i];
+			offset += AIO_BLKSIZE;
+			break;
+		case IO_CMD_POLL :
+		case IO_CMD_NOOP :
+			break;
+		default:
+			tst_resm (TFAIL,
+				  "Command failed; opcode returned: %d\n",
+				  operation);
+		  	return -1;
+			break;
 		}
 	}
 
 	do {
-		res = io_submit(myctx , AIO_MAXIO , iocbps);
+		res = io_submit(myctx, AIO_MAXIO, iocbps);
 	} while (res == -EAGAIN);
-	if (res < 0 ) {
+	if (res < 0) {
 		io_error("io_submit tio", res);
 	}
 
@@ -169,22 +161,22 @@
 	timeout.tv_sec = 30;
 	timeout.tv_nsec = 0;
 
-	switch ( operation ) {
+	switch (operation) {
 		case IO_CMD_PREAD :
 		case IO_CMD_PWRITE :
 		  {
-			while ( wait_count ) {
-				res = io_wait_run( myctx , &timeout );
-				if ( res < 0 )
+			while (wait_count) {
+				res = io_wait_run(myctx, &timeout);
+				if (res < 0)
 					io_error("io_wait_run", res);
 			}
 		  }
 		  break;
 		case IO_CMD_FSYNC :
 		  {
-			for ( i = 0 ; i < AIO_MAXIO ; i ++ ) {
-				res = io_fsync( myctx , iocbps[i] , work_done , fd);
-				if ( res  < 0 ) {
+			for (i = 0 ; i < AIO_MAXIO ; i ++) {
+				res = io_fsync(myctx, iocbps[i], work_done, fd);
+				if (res  < 0) {
 					io_error("io_fsync write", res);
 				}
 			}
@@ -192,9 +184,9 @@
 		  break;
 		case IO_CMD_FDSYNC :
 		  {
-			for ( i = 0 ; i < AIO_MAXIO ; i ++ ) {
-				res = io_fdsync( myctx , iocbps[i] , work_done , fd);
-				if ( res  < 0 ) {
+			for (i = 0 ; i < AIO_MAXIO ; i ++) {
+				res = io_fdsync(myctx, iocbps[i], work_done, fd);
+				if (res  < 0) {
 					io_error("io_fsync write", res);
 				}
 			}
@@ -208,15 +200,15 @@
 	}
 
 
-	close ( fd );
+	close (fd);
 
-	for ( i = 0 ; i < AIO_MAXIO ; i ++ ) {
-		if ( iocb_array[i].u.c.buf != NULL ) {
-			free ( iocb_array[i].u.c.buf );
+	for (i = 0 ; i < AIO_MAXIO ; i ++) {
+		if (iocb_array[i].u.c.buf != NULL) {
+			free (iocb_array[i].u.c.buf);
 		}
 	}
 
-	io_queue_release ( myctx );
+	io_queue_release (myctx);
 
 	return 0;
 }
@@ -226,53 +218,62 @@
 	int	status = 0 ;
 	//char *filepath = "testdir/file1";
 
-    printf("running test 1 \n");
-	status = io_tio( "testdir/file1" , O_TRUNC | O_DIRECT | O_WRONLY | O_CREAT | O_LARGEFILE , AIO_MAXIO , IO_CMD_PWRITE);
-	if ( status ) {
+	tst_resm(TINFO, "Running test 1\n");
+	status = io_tio("testdir/file1",
+			O_TRUNC | O_DIRECT | O_WRONLY | O_CREAT | O_LARGEFILE,
+			AIO_MAXIO, IO_CMD_PWRITE);
+	if (status) {
 		return status;
 	}
 
-    printf("running test 2 \n");
-	status = io_tio( "testdir/file1" , O_RDONLY | O_DIRECT | O_LARGEFILE , AIO_MAXIO , IO_CMD_PREAD);
-	if ( status ) {
+	tst_resm(TINFO, "Running test 2\n");
+	status = io_tio("testdir/file1", O_RDONLY | O_DIRECT | O_LARGEFILE,
+			AIO_MAXIO, IO_CMD_PREAD);
+	if (status) {
 		return status;
 	}
 
-    printf("running test 3 \n");
-	status = io_tio( "testdir/file1" , O_TRUNC | O_RDWR , AIO_MAXIO , IO_CMD_PWRITE );
-	if ( status ) {
+	tst_resm(TINFO, "Running test 3\n");
+	status = io_tio("testdir/file1", O_TRUNC | O_RDWR,
+			AIO_MAXIO, IO_CMD_PWRITE);
+	if (status) {
 		return status;
 	}
 
-    printf("running test 4 \n");
-	status = io_tio( "testdir/file1" , O_RDWR , AIO_MAXIO , IO_CMD_PREAD );
-	if ( status ) {
+	tst_resm(TINFO, "Running test 4\n");
+	status = io_tio("testdir/file1", O_RDWR,
+			AIO_MAXIO, IO_CMD_PREAD);
+	if (status) {
 		return status;
 	}
 	
-    printf("running test 5 \n");
-	status = io_tio( "testdir/file1" , O_TRUNC | O_WRONLY , AIO_MAXIO , IO_CMD_PWRITE );
-	if ( status ) {
+	tst_resm(TINFO, "Running test 5\n");
+	status = io_tio("testdir/file1", O_TRUNC | O_WRONLY,
+			AIO_MAXIO, IO_CMD_PWRITE);
+	if (status) {
 		return status;
 	}
 
-    printf("running test 6 \n");
-	status = io_tio( "testdir/file1" , O_RDONLY , AIO_MAXIO , IO_CMD_PREAD );
-	if ( status ) {
+	tst_resm(TINFO, "Running test 6 \n");
+	status = io_tio("testdir/file1", O_RDONLY,
+			AIO_MAXIO, IO_CMD_PREAD);
+	if (status) {
 		return status;
 	}
 
-    printf("running test 7 \n");
-	status = io_tio( "testdir/file2" , O_TRUNC | O_DIRECT | O_WRONLY | O_CREAT | O_LARGEFILE ,
-				AIO_MAXIO , IO_CMD_FSYNC);
-	if ( status ) {
+	tst_resm(TINFO, "Running test 7 \n");
+	status = io_tio("testdir/file2",
+			O_TRUNC | O_DIRECT | O_WRONLY | O_CREAT | O_LARGEFILE,
+			AIO_MAXIO, IO_CMD_FSYNC);
+	if (status) {
 		return status;
 	}
 
-    printf("running test 8 \n");
-	status = io_tio( "testdir/file2" , O_TRUNC | O_DIRECT | O_WRONLY | O_CREAT | O_LARGEFILE ,
-				AIO_MAXIO , IO_CMD_FDSYNC);
-	if ( status ) {
+	tst_resm(TINFO, "Running test 8 \n");
+	status = io_tio("testdir/file2",
+			O_TRUNC | O_DIRECT | O_WRONLY | O_CREAT | O_LARGEFILE,
+			AIO_MAXIO, IO_CMD_FDSYNC);
+	if (status) {
 		return status;
 	}
 
diff --git a/testcases/kernel/io/aio/aio02/cases/common.h b/testcases/kernel/io/aio/aio02/cases/common.h
index 2f586f6..fd8d921 100644
--- a/testcases/kernel/io/aio/aio02/cases/common.h
+++ b/testcases/kernel/io/aio/aio02/cases/common.h
@@ -2,13 +2,19 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <fcntl.h>
 #include <sys/param.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <sys/select.h>
+#if HAVE_LIBAIO_H
 #include <libaio.h>
+#endif
 #include <sys/uio.h>
 #include <assert.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
 
 /* Fatal error handler */
 static void io_error(const char *func, int rc)
diff --git a/testcases/kernel/io/aio/aio02/common.h b/testcases/kernel/io/aio/aio02/common.h
new file mode 100644
index 0000000..6962e90
--- /dev/null
+++ b/testcases/kernel/io/aio/aio02/common.h
@@ -0,0 +1,28 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/param.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/select.h>
+#if HAVE_LIBAIO_H
+#include <libaio.h>
+#endif
+#include <sys/uio.h>
+#include <assert.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Fatal error handler */
+static void io_error(const char *func, int rc)
+{
+	if (rc == -ENOSYS)
+		fprintf(stderr, "AIO not in this kernel\n");
+	else if (rc < 0)
+		fprintf(stderr, "%s: %s\n", func, strerror(-rc));
+	else
+		fprintf(stderr, "%s: error %d\n", func, rc);
+	
+	exit(1);
+}
diff --git a/testcases/kernel/io/aio/aio02/main.c b/testcases/kernel/io/aio/aio02/main.c
index 5dae3e8..08017ca 100644
--- a/testcases/kernel/io/aio/aio02/main.c
+++ b/testcases/kernel/io/aio/aio02/main.c
@@ -1,4 +1,3 @@
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <errno.h>
 #include <assert.h>
@@ -8,35 +7,30 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include "test.h"
+#include "usctest.h"
 #include "config.h"
 
+#define TEST_NAME "aio_tio"
+
+char *TCID = "aio02/" TEST_NAME;
+int TST_TOTAL = 0;
+
 #ifdef HAVE_LIBAIO_H
 
 #include <libaio.h>
 
-char test_name[] = TEST_NAME;
-
-#include TEST_NAME
+int test_main(void);
 
 int main(void)
 {
-	int res;
-
-	res = test_main();
-	printf("test %s completed %s.\n", test_name,
-		res ? "FAILED" : "PASSED"
-		);
-	fflush(stdout);
-	return res ? 1 : 0;
+	test_main();
+	tst_exit();
 }
 #else
-char *TCID = "aio02/" TEST_NAME;
-int TST_TOTAL=0;
-
 int main(void)
 {
-  tst_brkm(TCONF, tst_exit, "libaio missing");
-  return 0;
+	tst_brkm(TCONF, tst_exit, "libaio missing");
+	/* NOTREACHED */
+	return 0;
 }
-
 #endif
diff --git a/testcases/kernel/io/direct_io/Makefile b/testcases/kernel/io/direct_io/Makefile
index 8c6598a..7d62cdd 100644
--- a/testcases/kernel/io/direct_io/Makefile
+++ b/testcases/kernel/io/direct_io/Makefile
@@ -1,58 +1,33 @@
 #
-# Makefile for diotests
+#  Copyright (c) International Business Machines  Corp., 2001
 #
-# History:
-# 04/10/2002	nsharoff	nsharoff@us.ibm.com
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
+top_srcdir		?= ../../../..
 
-CFLAGS+=		 -O -Wall -DSHARED_OFILE -D_GNU_SOURCE -I../../../../include -L../../../../lib 
-LOADLIBES+= -lltp
+include $(top_srcdir)/include/mk/testcases.mk
 
-SRCS=	diotest1.c diotest2.c diotest3.c diotest4.c diotest5.c \
-	diotest6.c dma_thread_diotest7.c
+CFLAGS			+= -DSHARED_OFILE -D_GNU_SOURCE 
 
-BINS=	diotest1 diotest2 diotest3 diotest4 diotest5 \
-	diotest6 dma_thread_diotest7  
+LDLIBS			+= -lpthread
 
-all:	diotest_routines.o bins
+MAKE_TARGETS		:= $(filter-out diotest_routines,$(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)))
 
-bins: $& $(BINS)
+$(MAKE_TARGETS): %: %.o diotest_routines.o
 
-diotest_routines.o: diotest_routines.c
-		 $(CC) -c diotest_routines.c $(CFLAGS) 
+INSTALL_TARGETS		:= test_dma_thread_diotest7.sh
 
-diotest1: diotest1.c diotest_routines.o
-	$(CC) -o diotest1 diotest_routines.o diotest1.c  $(CFLAGS) $(LDFLAGS) $(LOADLIBES)
-	rm -f diotest1.o
-
-diotest2: diotest2.c diotest_routines.o
-	$(CC) -o diotest2 diotest_routines.o diotest2.c $(CFLAGS) $(LDFLAGS) $(LOADLIBES)
-	rm -f diotest2.o
-
-diotest3: diotest3.c diotest_routines.o 
-	$(CC) -o diotest3 diotest_routines.o diotest3.c $(CFLAGS) $(LDFLAGS) $(LOADLIBES)
-	rm -f diotest3.o
-
-diotest4: diotest4.c diotest_routines.o
-	$(CC) -o diotest4 diotest_routines.o diotest4.c $(CFLAGS) $(LDFLAGS) $(LOADLIBES)
-	rm -f diotest4.o
-
-diotest5: diotest5.c diotest_routines.o
-	$(CC) -o diotest5 diotest_routines.o diotest5.c $(CFLAGS) $(LDFLAGS) $(LOADLIBES)
-	rm -f diotest5.o
-
-diotest6: diotest6.c diotest_routines.o
-	$(CC) -o diotest6 diotest_routines.o diotest6.c $(CFLAGS) $(LDFLAGS) $(LOADLIBES)
-	rm -f diotest6.o
-
-dma_thread_diotest7: dma_thread_diotest7.c
-	$(CC) -g -o dma_thread_diotest7 dma_thread_diotest7.c -lpthread
-
-clean:	
-	rm -f $(BINS) diotest_routines.o
-
-install:
-	ln -f $(BINS) ../../../bin
-	ln -f test_dma_thread_diotest7.sh ../../../bin/
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/io/direct_io/test_dma_thread_diotest7.sh b/testcases/kernel/io/direct_io/test_dma_thread_diotest7.sh
index 6f89710..858a7c7 100755
--- a/testcases/kernel/io/direct_io/test_dma_thread_diotest7.sh
+++ b/testcases/kernel/io/direct_io/test_dma_thread_diotest7.sh
@@ -20,6 +20,10 @@
 ##                                                                            ##
 ################################################################################
 
+export TCID=dma_thread_diotest7
+export TST_TOTAL=3
+export TST_COUNT=3
+
 tst_resm TINFO "Generating Test Files"
 ./dma_thread_diotest7
 
diff --git a/testcases/kernel/io/disktest/Makefile b/testcases/kernel/io/disktest/Makefile
index b47417b..171b033 100644
--- a/testcases/kernel/io/disktest/Makefile
+++ b/testcases/kernel/io/disktest/Makefile
@@ -23,8 +23,24 @@
 #  Project Website:  TBD
 #
 #
-# $Id: Makefile,v 1.11 2008/02/14 08:22:22 subrata_modak Exp $
+# $Id: Makefile,v 1.12 2009/10/09 17:55:48 yaberauneya Exp $
 # $Log: Makefile,v $
+# Revision 1.12  2009/10/09 17:55:48  yaberauneya
+# 1. Please see README.mk-devel for a full description of the changes
+# from a Make perspective.
+# 2. Several files were changed to accomodate correct installation
+# practices, most notably ones in testcases/network/{ipv6,tcp_cmds},
+# testcases/kernel/sched/hyperthreading/ht_enabled/..., and some items
+# in tools/..., and also to avoid collisions as far as installed
+# testcases (scripts, compiled C apps) were concerned.
+# 3. Several apps weren't autoconf safe and some autoconf tests and
+# conditional statements have been placed in sourcecode and in Makefiles
+# to either a) prevent the tests from being built / installed or b) turn
+# the tests into dummy apps which print out TCONF messages due to
+# lack-of-build support.
+#
+# Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
+#
 # Revision 1.11  2008/02/14 08:22:22  subrata_modak
 # Disktest application update to version 1.4.2, by, Brent Yardley <yardleyb@us.ibm.com>
 #
@@ -157,56 +173,45 @@
 # Made signal handler one function. code cleanup.
 #
 
-# -D "_LARGE_FILES" is used in AIX to support 64bit functions and data types
-# -D"_LARGEFILE64_SOURCE" -D"_FILE_OFFSET_BITS=64" is used in Linux to support 64bit functions and data types. -D"_GNU_SOURCE" is to support Linux O_DIRECT
-# These are typically taken from rpm, but, if not, defined here.
-bindir=/usr/bin
-libdir=/usr/lib
-sysconfdir=/etc
-mandir=/usr/share/man
+# 1. -D_LARGE_FILES is used in AIX to support 64bit functions and data types.
+# 2. For Linux:
+#     i.  -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 is used in to support
+#         64-bit functions and data types.
+#     ii. -D_GNU_SOURCE is to support Linux O_DIRECT.
+#
+#    i. and ii. are typically taken from rpm, but, if not, are defined here.
+#
 
-VER=`grep VER_STR main.h | awk -F\" '{print $$2}'`
-GBLHDRS=main.h globals.h defs.h
-ALLHDRS=$(wildcard *.h)
-SRCS=$(wildcard *.c)
-OBJS=$(SRCS:.c=.o)
+top_srcdir	?= ../../../..
 
-CFLAGS += -g -Wall -O -D"LINUX" -D"_THREAD_SAFE" -D"_GNU_SOURCE" -D"_LARGE_FILES" -D"_LARGEFILE64_SOURCE" -D"_FILE_OFFSET_BITS=64" $(RPM_OPT_FLAGS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: $(OBJS) disktest
+VER		:= `grep VER_STR $(abs_srcdir)/main.h | awk -F\" '{print $$2}'`
 
-disktest: $(OBJS) $(SRCS) $(ALLHDRS)
-	$(CC) $(CFLAGS) -o disktest $(OBJS) $(LDFLAGS) -lpthread
+CPPFLAGS	+= -g -Wall -O -DLINUX -D_THREAD_SAFE -D_GNU_SOURCE -D_LARGE_FILES -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $(RPM_OPT_FLAGS)
 
-main.o: main.c $(ALLHDRS)
-sfunc.o: sfunc.c sfunc.h $(GBLHDRS)
-parse.o: parse.c parse.h sfunc.h $(GBLHDRS)
-childmain.o: childmain.c childmain.h sfunc.h parse.h threading.h $(GBLHDRS)
-threading.o: threading.c threading.h childmain.h sfunc.h $(GBLHDRS)
-globals.o: globals.c threading.h $(GBLHDRS)
-usage.o: usage.c usage.h
-Getopt.o: Getopt.c Getopt.h
-io.o: io.c io.h $(GBLHDRS)
-dump.o: dump.c dump.h $(GBLHDRS)
-timer.o: timer.c timer.h $(GBLHDRS)
-stats.o: stats.c stats.h $(GBLHDRS)
-signals.o: signals.c signals.h threading.h $(GBLHDRS)
+DISTRO_FILES	:= Makefile* *.[ch] LICENSE README CHANGELOG
 
-install: disktest
-	ln -f disktest ../../../bin
+LDLIBS		+= -lpthread
 
-clean:
-	rm -f disktest $(OBJS)
+MAKE_TARGETS	:= disktest
+
+OBJS		:= $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c))
+
+disktest-$(VER):
+	mkdir -p "$@"
+
+disktest: $(OBJS)
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
 
 all-clean: clean
-	rm -f *~ *tar* *zip*
+	$(RM) -rf *~ *tar* *zip* disktest-$(VER)
 
-distro: all-clean
+distro: all-clean | disktest-$(VER)
 	mkdir -p disktest-$(VER)/man1
-	cp ./Makefile* ./*.[ch] ./LICENSE ./README ./CHANGELOG disktest-$(VER)
-	cp ./man1/disktest.1 disktest-$(VER)/man1
-	chmod 444 disktest-$(VER)/man1/disktest.1
+	cp $(addprefix $(abs_srcdir)/,$(DISTRO_FILES)) disktest-$(VER)/.
+	install -m 00444 $(abs_srcdir)/man1/disktest.1 disktest-$(VER)/man1
 	gzip disktest-$(VER)/man1/disktest.1
-	tar cvf ./disktest-$(VER).tar disktest-$(VER)
-	rm -rf disktest-$(VER)
-	gzip ./disktest-$(VER).tar
+	tar -cvzf disktest-$(VER).tar.gz disktest-$(VER)
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/io/ltp-aiodio/Makefile b/testcases/kernel/io/ltp-aiodio/Makefile
index 1e3bf79..4d68c6d 100644
--- a/testcases/kernel/io/ltp-aiodio/Makefile
+++ b/testcases/kernel/io/ltp-aiodio/Makefile
@@ -1,44 +1,30 @@
-CFLAGS+= -Wall -O -g -DAIO -I../../../../include
-LDLIBS+= -L../../../../lib -laio -lltp
+#
+#    kernel/io/ltp-aiodio testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 
-TARGETS=ltp-diorh aiocp aiodio_append aiodio_sparse dio_append dio_sparse dio_truncate dirty read_checkzero aio-stress
-SRCS=$(wildcard *.c)
-OBJS=$(patsubst %.c,%.o,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-ltp-diorh: ltp-diorh.o
-		 $(CC) -o $@ $^ -I. $(CFLAGS) $(LDLIBS)
+CPPFLAGS		+= -DAIO -D_GNU_SOURCE
 
-aiocp: aiocp.o
-		 $(CC) -o $@ $^ -I. $(CFLAGS) $(LDLIBS)
+LDLIBS			+= -lpthread $(AIO_LIBS)
 
-aiodio_append: aiodio_append.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
-
-aiodio_sparse: aiodio_sparse.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
-
-dio_append: dio_append.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
-
-dio_sparse: dio_sparse.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
-
-dio_truncate: dio_truncate.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
-
-dirty: dirty.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
-
-read_checkzero: read_checkzero.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
-
-aio-stress: aio-stress.o
-		 $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) -lpthread
-
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(OBJS) $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
index cc91e6d..037fcaf 100644
--- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
+++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
@@ -66,10 +66,6 @@
 #define IO_PENDING 1
 #define RUN_FOREVER -1
 
-#ifndef O_DIRECT
-#define O_DIRECT         040000 /* direct disk access hint */
-#endif
-
 enum {
     WRITE,
     READ,
diff --git a/testcases/kernel/io/ltp-aiodio/aiocp.c b/testcases/kernel/io/ltp-aiodio/aiocp.c
index 3ab4752..0a54e65 100644
--- a/testcases/kernel/io/ltp-aiodio/aiocp.c
+++ b/testcases/kernel/io/ltp-aiodio/aiocp.c
@@ -23,7 +23,6 @@
 
 #define _GNU_SOURCE
 
-
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -33,6 +32,9 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <sys/select.h>
+#include "config.h"
+
+#if HAVE_LIBAIO_H
 
 #include <libaio.h>
 
@@ -510,3 +512,13 @@
  * rrrwwwwwwwrrrrwwrrrrrrrrrrrrwrwrrrrwwwwwwwwwwwwwwrwrrrrwwwwrwrrrrwrwwwrrrwww
  * rwwrrrrrrrwrrrrrrrrrrrrwwwwrrrwwwrwrrwwwwwwwwwwwwwwwwwwwwwrrrrrrrwwwwwwwrw
  */
+
+#else
+
+int
+main(void) {
+	fprintf(stderr, "System doesn't have libaio support.\n");
+	return 1;
+}
+
+#endif
diff --git a/testcases/kernel/io/stress_cd/Makefile b/testcases/kernel/io/stress_cd/Makefile
index 9caf72c..af1e561 100644
--- a/testcases/kernel/io/stress_cd/Makefile
+++ b/testcases/kernel/io/stress_cd/Makefile
@@ -1,14 +1,25 @@
-CFLAGS += -Wall -O -g
-LDLIBS := -lpthread
+#
+#  Copyright (c) International Business Machines  Corp., 2001
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	ln -f $(TARGETS) ../../../bin
+LDLIBS			+= -lpthread
 
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/io/stress_floppy/Makefile b/testcases/kernel/io/stress_floppy/Makefile
index 8b940a1..0a590b3 100644
--- a/testcases/kernel/io/stress_floppy/Makefile
+++ b/testcases/kernel/io/stress_floppy/Makefile
@@ -1,13 +1,36 @@
-all: 
+#
+#  Copyright (c) International Business Machines  Corp., 2001
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
 
-install: generate
-	ln -f stress_floppy ../../../bin
-	ln -f *_file ../../../bin
-	cp -rf dumpdir ../../../bin
+top_srcdir		?= ../../../..
 
+include $(top_srcdir)/include/mk/testcases.mk
 
-generate:
-	./generate.sh
+CLEAN_TARGETS		:= 10*K_file dumpdir
 
-clean:
-	rm -rf 10*K_file dumpdir
+INSTALL_DEPS		:= dumpdir 
+
+MAKE_TARGETS		:=
+
+# dumpdir's a directory.
+RM			+= -r
+
+dumpdir:
+	@mkdir -p "$@"
+	@$(SHELL) "$(abs_srcdir)/generate.sh"
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/io/stress_floppy/generate.sh b/testcases/kernel/io/stress_floppy/generate.sh
index 1fce03f..f89ce13 100755
--- a/testcases/kernel/io/stress_floppy/generate.sh
+++ b/testcases/kernel/io/stress_floppy/generate.sh
@@ -1,35 +1,26 @@
 #!/bin/sh
 
 COUNT=0
+
 FILE=1K_file
-for the_file in `echo 10K_file 100K_file 1000K_file`
-do
-  if [ -e $the_file ]; then continue; fi
-  echo "Creating $the_file"
-  while [ $COUNT -le 10 ]
-  do
-    cat $FILE >> $the_file
-    COUNT=$(( $COUNT + 1 ))
-  done
-  COUNT=0
-  FILE=$the_file
+
+for i in 10K_file 100K_file 1000K_file; do
+
+	[ -e "$i" ] && continue
+
+	echo "Creating \`$i'"
+
+	COUNT=0
+
+	while [ $COUNT -le 10 ]; do
+		cat "$FILE" >> "$i"
+		COUNT=$(( $COUNT + 1 ))
+	done
+
+	FILE=$i
+
 done
 
-if [ ! -d dumpdir ]; then
-   mkdir dumpdir
-fi
-
-`diff --brief 1K_file dumpdir/1K_file > /dev/null 2>&1`
-if [ $? ]; then
-   cp 1K_file dumpdir
-fi
-
-`diff --brief 10K_file dumpdir/10K_file > /dev/null 2>&1`
-if [ $? ]; then
-   cp 10K_file dumpdir
-fi
-
-`diff --brief 100K_file dumpdir/100K_file > /dev/null 2>&1`
-if [ $? ]; then
-   cp 100K_file dumpdir
-fi
+for i in 1K_file 10K_file 100K_file 1000K_file; do
+	diff --brief $i "dumpdir/$i" > /dev/null 2>&1 || cp "$i" dumpdir
+done
diff --git a/testcases/kernel/io/writetest/Makefile b/testcases/kernel/io/writetest/Makefile
index eda9d63..87166a3 100644
--- a/testcases/kernel/io/writetest/Makefile
+++ b/testcases/kernel/io/writetest/Makefile
@@ -1,12 +1,27 @@
-CFLAGS+=-Wall -O2 -g  `getconf LFS_CFLAGS` -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+#
+#  Copyright (c) International Business Machines  Corp., 2001
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
 
-all: writetest
+top_srcdir		?= ../../../..
 
-writetest: writetest.c
-	$(CC) $(CFLAGS) $(LDFLAGS) writetest.c -o writetest
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	ln -f writetest ../../../bin
+CFLAGS			+= `getconf LFS_CFLAGS` -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
 
-clean:
-	$(RM) -f writetest
+LDLIBS			+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/ipc/Makefile b/testcases/kernel/ipc/Makefile
index 5d7c05d..10ae0e9 100644
--- a/testcases/kernel/ipc/Makefile
+++ b/testcases/kernel/ipc/Makefile
@@ -1,10 +1,27 @@
-SUBDIRS = semaphore pipeio ipc_stress
+#
+#    kernel/ipc test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/ipc/ipc_stress/Makefile b/testcases/kernel/ipc/ipc_stress/Makefile
index 9920532..c7a2a15 100644
--- a/testcases/kernel/ipc/ipc_stress/Makefile
+++ b/testcases/kernel/ipc/ipc_stress/Makefile
@@ -1,14 +1,32 @@
-CFLAGS += -O -g -D_LINUX_ -Wall 
-LOADLIBES += -lpthread
+#
+#    testcases/kernel/ipc/ipc_stress Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
+top_srcdir		?= ../../../..
 
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CPPFLAGS		+= -D_LINUX_
+LDLIBS			+= -lpthread
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
-	cp run_semaphore_test_01.sh ../../../bin/run_semaphore_test_01.sh
-clean:
-	rm -f $(TARGETS)
+INSTALL_TARGETS		:= run_semaphore_test_01.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/ipc/pipeio/Makefile b/testcases/kernel/ipc/pipeio/Makefile
index d2a1d5f..8e79d6b 100644
--- a/testcases/kernel/ipc/pipeio/Makefile
+++ b/testcases/kernel/ipc/pipeio/Makefile
@@ -20,17 +20,11 @@
 # name of file	: Makefile						  #
 # description	: make(1) description file for the send(2) tests.	  #
 ###########################################################################
-CFLAGS   += -Wall
-CPPFLAGS += -I../../../../include
-LDLIBS   += -L../../../../lib -lltp -lrt -lpthread
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+LDLIBS   		+= -lpthread -lrt
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/ipc/semaphore/Makefile b/testcases/kernel/ipc/semaphore/Makefile
index 0063c49..7ee6189 100644
--- a/testcases/kernel/ipc/semaphore/Makefile
+++ b/testcases/kernel/ipc/semaphore/Makefile
@@ -1,14 +1,30 @@
-CFLAGS += -Wall -I ../../../../include -I ../include
-LDLIBS := -L ../../../../lib -lpthread -lltp
+#
+#    testcases/kernel/ipc/semaphore Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
+CPPFLAGS 		+= -I../include
+LDLIBS			+= -lpthread
 
-install:
-	set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/Makefile b/testcases/kernel/mem/Makefile
index 097874e..2f59074 100644
--- a/testcases/kernel/mem/Makefile
+++ b/testcases/kernel/mem/Makefile
@@ -1,10 +1,46 @@
-SUBDIRS = hugetlb mem mmapstress mtest01 mtest05 mtest06 mtest07 page shmt vmtests
+#
+#    kernel/mem test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+LIB			:= $(DESTDIR)/$(libdir)/libmm.a
+LIBDIR			:= libmm
+FILTER_OUT_DIRS		:= $(LIBDIR)
+
+$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): $(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
+
+trunk-all: $(LIB)
+
+trunk-clean:: | lib-clean
+
+lib-clean:: $(LIBDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/mem/Makefile.inc b/testcases/kernel/mem/Makefile.inc
new file mode 100644
index 0000000..a5a922a
--- /dev/null
+++ b/testcases/kernel/mem/Makefile.inc
@@ -0,0 +1,39 @@
+#
+#    kernel/mem testcase suite common definitions Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# DO NOT USE THIS FILE FOR mem / libmm!!!
+
+LDLIBS			+= -lmm
+LIB			:= $(DESTDIR)/$(libdir)/libmm.a
+LIBDIR			:= libmm
+
+../$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): ../$(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
+
+all: | $(LIB)
+
+# vim: syntax=make
diff --git a/testcases/kernel/mem/hugetlb/Makefile b/testcases/kernel/mem/hugetlb/Makefile
index ca604d3..64cbc1b 100644
--- a/testcases/kernel/mem/hugetlb/Makefile
+++ b/testcases/kernel/mem/hugetlb/Makefile
@@ -16,26 +16,28 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-#########################################################################
-# name of file	: Makefile						#
-# description	: make(1) description file                           	#
-#########################################################################
-CFLAGS+=-I../../../../../include -g -Wall
-LOADLIBES+=-L../../../../lib -lltp
-TESTS=hugeshmget hugeshmat hugeshmdt hugeshmctl hugemmap
+top_srcdir		?= ../../../..
 
-all: $& $(TESTS)
-	@set -e; for i in lib $(TESTS); do \
-		$(MAKE) -C $$i  all; \
+include	$(top_srcdir)/include/mk/env_pre.mk
+
+LDLIBS			+= -lmm
+LIB			:= $(DESTDIR)/$(libdir)/libipc_hugetlb.a
+LIBDIR			:= lib
+FILTER_OUT_DIRS		:= $(LIBDIR)
+
+$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): $(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
 	done
 
-clean:
-	@set -e; for i in lib $(TESTS); do \
-		$(MAKE) -C $$i  clean; \
-	done
+trunk-all: $(LIB)
 
-install:
-	@set -e; for i in lib $(TESTS); do \
-		$(MAKE) -C $$i  install; \
-	done
+trunk-clean:: | lib-clean
 
+lib-clean:: $(LIBDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean 
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/mem/hugetlb/Makefile.inc b/testcases/kernel/mem/hugetlb/Makefile.inc
new file mode 100644
index 0000000..eb76fac
--- /dev/null
+++ b/testcases/kernel/mem/hugetlb/Makefile.inc
@@ -0,0 +1,42 @@
+#
+#    kernel/mem/hugetlb testcase suite common definitions Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# DO NOT USE THIS FILE FOR hugetlb / lib!!!
+
+CPPFLAGS		+= -I$(abs_srcdir)/../lib
+LIB			:= $(DESTDIR)/$(libdir)/libipc_hugetlb.a
+LIBDIR			:= lib
+
+../$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): ../$(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -I "$(abs_srcdir)" -C "$^" -f "$(abs_srcdir)/$^/Makefile" \
+	    $$i; \
+	done
+
+LDLIBS			+= -lmm -lipc_hugetlb
+
+all: | $(LIB)
+
+# vim: syntax=make
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
index 034491b..a1ba46e 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
@@ -1,13 +1,27 @@
-CFLAGS += -I../../../../../include -g -Wall
-LOADLIBES += -L../../../../../lib -lltp 
+#
+#    kernel/mem/hugetlb/hugemmap testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir              ?= ../../../../..
 
-all: $(TARGETS)
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/Makefile b/testcases/kernel/mem/hugetlb/hugeshmat/Makefile
index f3cc1b1..a1ba46e 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/Makefile
@@ -1,13 +1,27 @@
-CFLAGS += -I../lib -I../../../../../include -g -Wall
-LOADLIBES += -L../../../../../lib -lltp -L../lib -lipc
+#
+#    kernel/mem/hugetlb/hugemmap testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir              ?= ../../../../..
 
-all: $(TARGETS)
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/Makefile b/testcases/kernel/mem/hugetlb/hugeshmctl/Makefile
index f3cc1b1..2f5b160 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/Makefile
@@ -1,13 +1,27 @@
-CFLAGS += -I../lib -I../../../../../include -g -Wall
-LOADLIBES += -L../../../../../lib -lltp -L../lib -lipc
+#
+#    kernel/mem/hugetlb/hugeshmctl testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir              ?= ../../../../..
 
-all: $(TARGETS)
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/hugetlb/hugeshmdt/Makefile b/testcases/kernel/mem/hugetlb/hugeshmdt/Makefile
index f3cc1b1..cea6939 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmdt/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugeshmdt/Makefile
@@ -1,13 +1,27 @@
-CFLAGS += -I../lib -I../../../../../include -g -Wall
-LOADLIBES += -L../../../../../lib -lltp -L../lib -lipc
+#
+#    kernel/mem/hugetlb/hugeshmdt testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir              ?= ../../../../..
 
-all: $(TARGETS)
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/Makefile b/testcases/kernel/mem/hugetlb/hugeshmget/Makefile
index f3cc1b1..54b5709 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/Makefile
@@ -1,13 +1,23 @@
-CFLAGS += -I../lib -I../../../../../include -g -Wall
-LOADLIBES += -L../../../../../lib -lltp -L../lib -lipc
+#
+#  Copyright (c) International Business Machines  Corp., 2001
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir              ?= ../../../../..
 
-all: $(TARGETS)
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/hugetlb/lib/Makefile b/testcases/kernel/mem/hugetlb/lib/Makefile
index eafa10b..edfb7ff 100644
--- a/testcases/kernel/mem/hugetlb/lib/Makefile
+++ b/testcases/kernel/mem/hugetlb/lib/Makefile
@@ -16,27 +16,10 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-#########################################################################
-# name of file	: Makefile						#
-# description	: make(1) description file to build a library for the 	#
-#		  common routines in the ipc(2) tests.			#
-#########################################################################
-SRCS=libipc.c
-OBJS=$(SRCS:.c=.o)
-MAINS=libipc.a
-CFLAGS+=-I../../../../../include -g -Wall
-CFLAGS+=-D_USC_LIB_
+top_srcdir		?= ../../../../..
 
-all: libipc.a
+include $(top_srcdir)/include/mk/env_pre.mk
 
-libipc.a: $(OBJS)
-	$(AR) -rc $@ $(OBJS)
+LIB			:= libipc_hugetlb.a
 
-$(OBJS):
-	$(CC) -c $(SRCS) $(CFLAGS)
-
-install:
-
-clean:
-	/bin/rm -rf $(OBJS) libipc.a
-
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/kernel/mem/libmm/Makefile b/testcases/kernel/mem/libmm/Makefile
index 28ad780..2849686 100644
--- a/testcases/kernel/mem/libmm/Makefile
+++ b/testcases/kernel/mem/libmm/Makefile
@@ -16,22 +16,10 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-# description	: make(1) description file for the send(2) tests.	  #
-###########################################################################
-CFLAGS+=	-I../../../../include -Wall
-LOADLIBES+=	-L../../../../lib -lltp -lmm
+top_srcdir		?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: $(TARGETS)
+LIB			:= libmm.a
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/kernel/mem/libmm/mm_core_apis.c b/testcases/kernel/mem/libmm/mm_core_apis.c
index 3f04547..0bf14c5 100644
--- a/testcases/kernel/mem/libmm/mm_core_apis.c
+++ b/testcases/kernel/mem/libmm/mm_core_apis.c
@@ -41,10 +41,12 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <signal.h>
-#include <mm.h>
 #include "test.h"
 #include "usctest.h"
 
+#if HAVE_MM_H
+#include <mm.h>
+
 #if !defined(TRUE) && !defined(FALSE)
 #define TRUE 1
 #define FALSE 0
@@ -402,3 +404,9 @@
     }
     exit(ret);
 }
+#else
+int main(void) {
+    tst_resm(TCONF, "System doesn't have libmm support\n");
+    tst_exit();
+}
+#endif
diff --git a/testcases/kernel/mem/mem/Makefile b/testcases/kernel/mem/mem/Makefile
index e92d4a3..d3eb6ef 100644
--- a/testcases/kernel/mem/mem/Makefile
+++ b/testcases/kernel/mem/mem/Makefile
@@ -16,22 +16,7 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-# description	: make(1) description file for the send(2) tests.	  #
-###########################################################################
-CFLAGS+=	-Wall -I../../../../include
-LOADLIBES+=	-L../../../../lib -lltp
+top_srcdir              ?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/mmapstress/Makefile b/testcases/kernel/mem/mmapstress/Makefile
index 46d66ea..e2ab4b2 100644
--- a/testcases/kernel/mem/mmapstress/Makefile
+++ b/testcases/kernel/mem/mmapstress/Makefile
@@ -16,23 +16,8 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-###########################################################################
-CFLAGS+=	-I../../../../include -O -g -Wall
-#LARGEFILE support
-#CFLAGS+=	-I../../../../include -O -g -Wall -DLARGE_FILE
-LOADLIBES+=	-L../../../../lib -lltp 
+top_srcdir              ?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/mtest01/Makefile b/testcases/kernel/mem/mtest01/Makefile
index 87a1d55..5333ddc 100644
--- a/testcases/kernel/mem/mtest01/Makefile
+++ b/testcases/kernel/mem/mtest01/Makefile
@@ -1,13 +1,27 @@
-CFLAGS += -Wall -I../../../../include
-LOADLIBES+=	-L../../../../lib -lltp
+#
+#    kernel/mem/mtest01 testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS:=$(wildcard *.c)
-TARGETS:=$(patsubst %.c,%,$(SRCS))
+top_srcdir              ?= ../../../..
 
-all: $(TARGETS)
- 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/mtest05/Makefile b/testcases/kernel/mem/mtest05/Makefile
index acae09b..a44bc94 100644
--- a/testcases/kernel/mem/mtest05/Makefile
+++ b/testcases/kernel/mem/mtest05/Makefile
@@ -1,14 +1,30 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include
-LDLIBS += -lpthread -L../../../../lib -lltp
+#
+#    kernel/mem/mtest05 testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir              ?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+LDLIBS			+= -lpthread
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/mtest06/Makefile b/testcases/kernel/mem/mtest06/Makefile
index acae09b..8c633ed 100644
--- a/testcases/kernel/mem/mtest06/Makefile
+++ b/testcases/kernel/mem/mtest06/Makefile
@@ -1,14 +1,30 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../../include
-LDLIBS += -lpthread -L../../../../lib -lltp
+#
+#    kernel/mem/mtest06 testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir              ?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+LDLIBS			+= -lpthread
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/mtest07/Makefile b/testcases/kernel/mem/mtest07/Makefile
index c4ab953..c411305 100644
--- a/testcases/kernel/mem/mtest07/Makefile
+++ b/testcases/kernel/mem/mtest07/Makefile
@@ -1,13 +1,30 @@
-CFLAGS += -Wall -g
-LDLIBS := -lpthread -lm
+#
+#    kernel/mem/mtest07 testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir              ?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+LDLIBS			+= -lm -lpthread
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/page/Makefile b/testcases/kernel/mem/page/Makefile
index 8241d8f..dfa79e7 100644
--- a/testcases/kernel/mem/page/Makefile
+++ b/testcases/kernel/mem/page/Makefile
@@ -1,36 +1,30 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
+#    kernel/mem/page testcase Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-###########################################################################
-CFLAGS+=	-I../../../../include -g -O -Wall -DLINUX
-LOADLIBES+=	-L../../../../lib -lltp 
+top_srcdir              ?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-all: $(TARGETS)
+CPPFLAGS		+= -DLINUX
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/shmt/Makefile b/testcases/kernel/mem/shmt/Makefile
index 1f34d6d..f61d463 100644
--- a/testcases/kernel/mem/shmt/Makefile
+++ b/testcases/kernel/mem/shmt/Makefile
@@ -1,34 +1,27 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
+#    kernel/mem/shmt testcase Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-###########################################################################
-CFLAGS+=	-I../../../../include -Wall
-LOADLIBES+=	-L../../../../lib -lltp 
+top_srcdir              ?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/vmtests/Makefile b/testcases/kernel/mem/vmtests/Makefile
index 50d2d77..e2ab4b2 100644
--- a/testcases/kernel/mem/vmtests/Makefile
+++ b/testcases/kernel/mem/vmtests/Makefile
@@ -16,21 +16,8 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-###########################################################################
-CFLAGS+=	-I../../../../include -Wall
-LDLIBS+=	-L../../../../lib -lltp 
+top_srcdir              ?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-.PHONY: all clean install
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/module/Makefile b/testcases/kernel/module/Makefile
index 80bb330..4e03b7a 100644
--- a/testcases/kernel/module/Makefile
+++ b/testcases/kernel/module/Makefile
@@ -1,11 +1,30 @@
-SUBDIRS = delete_module
+#
+#    kernel/module test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir	?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+# Only delete_module works at this time...
+SUBDIRS		:= delete_module
 
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/module/delete_module/Makefile b/testcases/kernel/module/delete_module/Makefile
index e651cb5..abd796b 100644
--- a/testcases/kernel/module/delete_module/Makefile
+++ b/testcases/kernel/module/delete_module/Makefile
@@ -14,40 +14,40 @@
 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
 #
 ###########################################################################
-# name of file		 : Makefile		 		 		 		 		 		   #
-# description		 : make file for the delete_module(2) testcases		 		   #
+# name of file		 : Makefile		 		 	  #
+# description		 : make file for the delete_module(2) testcases	  #
 ###########################################################################
 
-EXTRA_CFLAGS+=		 -I../../../../include -Wall
-MODCFLAGS+=		 /lib/modules/`uname -r`/build
-LOADLIBES+=		 -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-obj-m := dummy_del_mod.o dummy_del_mod_dep.o
-TARGETS=delete_module01 delete_module02 delete_module03
-MODULES=dummy_del_mod.ko dummy_del_mod_dep.ko
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-		 make -C $(MODCFLAGS) SUBDIRS=`pwd` modules
-#		 chmod 755 $(OBJS)
+CFLAGS			+= -D_GNU_SOURCE
 
-delete_module01: delete_module01.c
-		 $(CC) $(EXTRA_CFLAGS) delete_module01.c $(LOADLIBES) -o $@
+LOCALVERSION		?= $(shell uname -r)
 
-delete_module02: delete_module02.c
-		 $(CC) $(EXTRA_CFLAGS) delete_module02.c $(LOADLIBES) -o $@
+MODULEDIR		:= $(DESTDIR)/lib/modules/$(LOCALVERSION)/build
 
-delete_module03: delete_module03.c
-		 $(CC) $(EXTRA_CFLAGS) delete_module03.c $(LOADLIBES) -o $@
+# KBuild make variables...
+MODCFLAGS		+= $(MODULEDIR)
 
-install:
-		 @set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-		 @set -e; for i in $(MODULES); do cp -f $$i /tmp/$$i ; done
+export EXTRA_CFLAGS	:= $(CFLAGS)
+export EXTRA_CPPFLAGS	:= $(CPPFLAGS)
+export EXTRA_LDFLAGS	:= $(LDFLAGS)
 
-clean:
-		 rm -f $(TARGETS)
-		 rm -rf .tmp_versions
-		 rm -f /tmp/dummy*.ko
-		 rm -f .dummy*
-		 rm -f *.o
-		 rm -f *.ko
-		 rm -f *.mod.c
+obj-m			:= dummy_del_mod.o dummy_del_mod_dep.o
+MODULES			:= dummy_del_mod.ko dummy_del_mod_dep.ko
+
+# New make infra variables...
+CLEAN_TARGETS		:= .dummy* *.mod.c .tmp_version *.ko
+INSTALL_TARGETS		:= $(MODULES)
+MAKE_TARGETS		:= delete_module01 delete_module02 delete_module03
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+$(MAKE_TARGETS): | make-module
+
+# KBuild will gripe because we redefine CFLAGS if KBUILD_NOPEDANTIC isn't set.
+.PHONY: make-module
+make-module:
+	make -C $(MODULEDIR) KBUILD_NOPEDANTIC=1 SUBDIRS=$(abs_srcdir) modules
diff --git a/testcases/kernel/module/delete_module/delete_module01.c b/testcases/kernel/module/delete_module/delete_module01.c
index 62dfc9d..7b5da56 100644
--- a/testcases/kernel/module/delete_module/delete_module01.c
+++ b/testcases/kernel/module/delete_module/delete_module01.c
@@ -32,7 +32,7 @@
  *
  *    DESCRIPTION
  *		 This is a Phase I test for the delete_module(2) system call.
- *		 It is intended to provide a limited exposure of the system call.
+ *		 It is intended to provide limited exposure of the system call.
  *
  *		 Setup:
  *		   Setup signal handling.
@@ -44,8 +44,8 @@
  *		  Loop if the proper options are given.
  *		   Create module entry
  *		   Execute system call
- *		   Check return code, if system call failed (return=-1)
- *		 		 Issue FAIL message with errno.
+ *		   Check return code, if system call failed (return=-1),
+ *		   	issue a FAIL message with the errno.
  *		   Otherwise, Issue PASS message.
  *
  *		 Cleanup:
@@ -54,128 +54,132 @@
  * USAGE:  <for command-line>
  *  delete_module01 [-c n] [-e] [-f] [-h] [-i n] [-I x] [-p] [-P x] [-t]
  *		 		 where,  -c n : Run n copies concurrently.
- *		 		 		 -e   : Turn on errno logging.
- *		 		 		 -f   : Turn off functional testing
- *		 		 		 -h   : Show help screen
- *		 		 		 -i n : Execute test n times.
- *		 		 		 -I x : Execute test for x seconds.
- *		 		 		 -p   : Pause for SIGUSR1 before starting
- *		 		 		 -P x : Pause for x seconds between iterations.
- *		 		 		 -t   : Turn on syscall timing.
+ *			 		 -e   : Turn on errno logging.
+ *		 	 		 -f   : Turn off functional testing
+ *		 	 		 -h   : Show help screen
+ *		 	 		 -i n : Execute test n times.
+ *		 	 		 -I x : Execute test for x seconds.
+ *		 	 		 -p   : Pause for SIGUSR1 before
+ *		 	 		 	starting test.
+ *		 	 		 -P x : Pause for x seconds between
+ *		 	 		 	iterations.
+ *		 	 		 -t   : Turn on syscall timing.
  *
  ****************************************************************/
+
+#include <libgen.h>
 #include <errno.h>
-//#include <linux/module.h>
 #include "test.h"
 #include "usctest.h"
 
-extern int Tst_count;		 		 /* Test Case counter for tst_* routines */
+extern int Tst_count;			/* TC counter for tst_* routines */
 
 static void setup(void);
 static void cleanup(void);
 
 char *TCID = "delete_module01";		 /* Test program identifier.    */
-int TST_TOTAL=1;		 		 /* Total number of test cases. */
-//static char modname[20];		 /* Name of the module */
-	
+int TST_TOTAL = 1;			/* Total number of test cases. */
 
 int
 main(int argc, char **argv)
 {
-		 int lc;		 		 		 /* loop counter */
-		 char *msg;		 		 /* message returned from parse_opts */
-		 char cmd[PATH_MAX];
-		 char *module_name = "dummy_del_mod";
+	int lc;				/* loop counter */
+	char *msg;			/* message returned from parse_opts */
+	char cmd[PATH_MAX];
+	char *module_name = "dummy_del_mod";
 
-		 /* parse standard options */
-		 if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) !=
-		 		 		 (char *)NULL) {
-		 		 tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
-		 }
+	/* parse standard options */
+	if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) !=
+		(char *) NULL) {
+		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
+	}
 
-		 /* perform global setup for test */
-		 setup();
+	/* perform global setup for test */
+	setup();
 
-		 /* check looping state if -i option is given */
-		 for (lc = 0; TEST_LOOPING(lc); lc++) {
+	/* check looping state if -i option is given */
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
 
-		 		 /* reset Tst_count in case we are looping */
-		 		 Tst_count = 0;
+		/* reset Tst_count in case we are looping */
+		Tst_count = 0;
 
-		 		 // Execute system call
-		 		 sprintf(cmd, "/sbin/insmod /tmp/%s.ko", module_name);
-                                                                             
-		 		 // Insmod the module
-		 		 if ( (system( cmd )) != 0 ) {
-						 tst_resm(TBROK, "Failed to load %s module", module_name);
-		 		 		 printf("system() failed; cannot test init_module: errno=%i\n",
-                                errno);
-		 		 		 goto EXIT;
-		 		 }
+		/* Execute system call */
+		sprintf(cmd, "/sbin/insmod %s/%s.ko", dirname(argv[0]),
+			module_name);
 
-		 		 /* Test the system call */
-		 		 TEST(delete_module(module_name));
+		/* Insmod the module */
+ 		if ( (system( cmd )) != 0 ) {
+			tst_resm(TBROK, "Failed to load %s module",
+					module_name);
+			printf("system() failed; cannot test init_module: "
+			       "errno=%i\n", errno);
+			goto EXIT;
+		}
 
-		 		 /* check return code */
-		 		 if (TEST_RETURN == -1) {
-		 		 		 tst_resm(TFAIL, "delete_module() failed to remove"
-		 		 		 		 " module entry for %s, errno=%d : %s",
-		 		 		 		 module_name, TEST_ERRNO, strerror(TEST_ERRNO));
-		 		 } else {
-		 		 		 tst_resm(TPASS, "delete_module() successful, returned"
-		 		 		 		 " %d", TEST_RETURN);
-		 		 }
-		 }
+		/* Test the system call */
+		TEST(delete_module(module_name));
 
-		 /* perform global cleanup and exit */
+		/* check return code */
+		if (TEST_RETURN == -1) {
+			tst_resm(TFAIL, "delete_module() failed to remove"
+		 			" module entry for %s, errno=%d : %s",
+		 		 	module_name, TEST_ERRNO,
+					strerror(TEST_ERRNO));
+		} else {
+			tst_resm(TPASS, "delete_module() successful, returned"
+	 				" %d", TEST_RETURN);
+	 	}
+
+	}
+
+	/* perform global cleanup and exit */
 EXIT:
-		 cleanup();
+	cleanup();
+	/*NOTREACHED*/
+	return 0;
 
-		 /*NOTREACHED*/
-		 return 0;
-
-}		 /* End main */
+}		/* End main */
 
 /* setup() - performs all ONE TIME setup for this test */
 void
 setup(void)
 {
-		 /* capture signals */
-		 tst_sig(FORK, DEF_HANDLER, cleanup);
+	/* capture signals */
+	tst_sig(FORK, DEF_HANDLER, cleanup);
 
-		 /* Check whether we are root  */
-		 if (geteuid() != 0) {
-		 		 tst_brkm(TBROK, tst_exit, "Must be root for this test!");
-		 		 /*NOTREACHED*/
-		 }
+	/* Check whether we are root  */
+	if (geteuid() != 0) {
+		tst_brkm(TBROK, tst_exit, "Must be root for this test!");
+		/*NOTREACHED*/
+	}
 
-		 //if (tst_kvercmp(2,5,48) >= 0)
-		 		 //tst_brkm(TCONF, tst_exit, "This test will not work on "
-		 		 		 		 //"kernels after 2.5.48");
-
-		 /* Pause if that option was specified
-		  * TEST_PAUSE contains the code to fork the test with the -c option.
-		  */
-		 TEST_PAUSE;
+	/*
+	 * if (tst_kvercmp(2,5,48) >= 0)
+	 * tst_brkm(TCONF, tst_exit, "This test will not work on "
+	 *				"kernels after 2.5.48");
+	 */
+	/* Pause if that option was specified
+	 * TEST_PAUSE contains the code to fork the test with the -c option.
+	 */
+	TEST_PAUSE;
 
 }
 
 /*
  * cleanup()
- *		 performs all ONE TIME cleanup for this test at
- *		 completion or premature exit
+ *	performs all ONE TIME cleanup for this test at
+ *	completion or premature exit
  */
 void
 cleanup(void)
 {
-		 /*
-		  * print timing stats if that option was specified.
-		  * print errno log if that option was specified.
-		  */
-		 TEST_CLEANUP;
+	/*
+	 * print timing stats if that option was specified.
+	 * print errno log if that option was specified.
+	 */
+	TEST_CLEANUP;
 
-		 /* exit with return code appropriate for results */
-		 tst_exit();
-		 /*NOTREACHED*/
+	/* exit with return code appropriate for results */
+	tst_exit();
+	/*NOTREACHED*/
 }
-
diff --git a/testcases/kernel/module/delete_module/delete_module02.c b/testcases/kernel/module/delete_module/delete_module02.c
index 5fd5c7c..5de7cd7 100644
--- a/testcases/kernel/module/delete_module/delete_module02.c
+++ b/testcases/kernel/module/delete_module/delete_module02.c
@@ -32,8 +32,8 @@
  *
  *    DESCRIPTION
  *      Verify that,
- *      1. delete_module(2) returns -1 and sets errno to ENOENT for non-existing
- *		    module entry.
+ *      1. delete_module(2) returns -1 and sets errno to ENOENT for nonexistent
+ *	   module entry.
  *      2. delete_module(2) returns -1 and sets errno to EINVAL, if module
  *         name parameter is null terminated (zero length) string.
  *      3. delete_module(2) returns -1 and sets errno to EFAULT, if
@@ -68,14 +68,16 @@
  * USAGE:  <for command-line>
  *  delete_module02 [-c n] [-e] [-f] [-h] [-i n] [-I x] [-p] [-P x] [-t]
  *		 		 where,  -c n : Run n copies concurrently.
- *		 		 		 -e   : Turn on errno logging.
- *		 		 		 -f   : Turn off functional testing
- *		 		 		 -h   : Show help screen
- *		 		 		 -i n : Execute test n times.
- *		 		 		 -I x : Execute test for x seconds.
- *		 		 		 -p   : Pause for SIGUSR1 before starting
- *		 		 		 -P x : Pause for x seconds between iterations.
- *		 		 		 -t   : Turn on syscall timing.
+ *	 		 		 -e   : Turn on errno logging.
+ *	 		 		 -f   : Turn off functional testing
+ *	 		 		 -h   : Show help screen
+ *	 		 		 -i n : Execute test n times.
+ *	 		 		 -I x : Execute test for x seconds.
+ *	 		 		 -p   : Pause for SIGUSR1 before
+ *	 		 		 	starting test.
+ *	 		 		 -P x : Pause for x seconds between
+ *	 		 		 	iterations.
+ *	 		 		 -t   : Turn on syscall timing.
  *
  ****************************************************************/
 
@@ -84,38 +86,43 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <limits.h>
-//#include <linux/module.h>
+#if HAVE_LINUX_MODULE_H
+#include <linux/module.h>
+#else
+/* As per http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/include/linux/moduleparam.h?a=ppc#L17 ... */
+#define MODULE_NAME_LEN	( 64 - sizeof(unsigned long) )
+#endif
 #include <sys/mman.h>
 #include "test.h"
 #include "usctest.h"
 
-#ifndef PAGE_SIZE
-#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
-#endif
-
 extern int Tst_count;
 
 #define NULLMODNAME ""
 #define BASEMODNAME "dummy"
-#define LONGMODNAMECHAR 'm'		 		 /* Arbitrarily selected */
-#define MODNAMEMAX (PAGE_SIZE + 1)
+#define LONGMODNAMECHAR 'm'			/* Arbitrarily selected */
 #define EXP_RET_VAL -1
 
-struct test_case_t {		 		 		 /* test case structure */
-		 char 		 *modname;
-		 int		 experrno;		 		 /* expected errno */
-		 char		 *desc;
-		 int		 (*setup)(void);		 		 /* Individual setup routine */
-		 void		 (*cleanup)(void);		 /* Individual cleanup routine */
+/* Test case structure */
+struct test_case_t {
+	char 		 *modname;
+	/* Expected errno. */
+	int		 experrno;
+	char		 *desc;
+	/* Individual setup routine. */
+	int		 (*setup)(void);
+	/* Individual cleanup routine */
+	void		 (*cleanup)(void);
 };
 
 char *TCID = "delete_module02";
-static int exp_enos[] = {EPERM, EINVAL, ENOENT, EFAULT, ENAMETOOLONG, 0};
+static int exp_enos[] = { EPERM, EINVAL, ENOENT, EFAULT, ENAMETOOLONG, 0 };
 static char nobody_uid[] = "nobody";
 struct passwd *ltpuser;
-static char longmodname[MODNAMEMAX];
+static char longmodname[MODULE_NAME_LEN];
 static int testno;
-static char modname[20];		 		 /* Name of the module */
+/* Name of the module */
+static char modname[20];
 
 char * bad_addr = 0;
 
@@ -124,17 +131,20 @@
 static int setup1(void);
 static void cleanup1(void);
 
+struct test_case_t;
+
 static struct test_case_t  tdat[] = {
 		 { modname, ENOENT,
-		 		 "non-existing module", NULL, NULL},
+		 	"nonexistent module", NULL, NULL},
 		 { NULLMODNAME, ENOENT,
-		 		 "null terminated module name", NULL, NULL},
-		 { (char *) -1, EFAULT, "module name outside program's "
-		 		 "accessible address space", NULL, NULL},
+		 	"null terminated module name", NULL, NULL},
+		 { (char *) -1, EFAULT,
+			"module name outside program's "
+			"accessible address space", NULL, NULL},
 		 { longmodname, ENOENT,
-		 		 "long module name", NULL, NULL},
+		 	"long module name", NULL, NULL},
 		 { modname, EPERM,
-		 		 "non-superuser", setup1, cleanup1},
+		 	"non-superuser", setup1, cleanup1},
 };
 
 int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]);
@@ -142,145 +152,146 @@
 int
 main(int argc, char **argv)
 {
-		 int lc;		 		 		 		 /* loop counter */
-		 char *msg;		 		 		 /* message returned from parse_opts */
+	int lc; 		 /* loop counter */
+	char *msg; 		 /* message returned from parse_opts */
 
-		 /* parse standard options */
-		 if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) !=
-		     (char *)NULL) {
-		 		 tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
-		 }
+	/* parse standard options */
+	if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) !=
+	     (char *)NULL) {
+		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
+	}
 
-		 setup();
+	setup();
 
-		 /* check looping state if -i option is given */
-		 for (lc = 0; TEST_LOOPING(lc); lc++) {
-		 		 /* reset Tst_count in case we are looping */
-		 		 Tst_count = 0;
+	/* check looping state if -i option is given */
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		/* reset Tst_count in case we are looping */
+		Tst_count = 0;
 
-		 		 for (testno = 0; testno < TST_TOTAL; ++testno) {
-		 		 		 if( (tdat[testno].setup) && (tdat[testno].setup()) ) {
-		 		 		 		 /* setup() failed, skip this test */
-		 		 		 		 continue;
-		 		 		 }
+		for (testno = 0; testno < TST_TOTAL; ++testno) {
+			if( (tdat[testno].setup) && (tdat[testno].setup()) ) {
+		 		/* setup() failed, skip this test */
+		 		continue;
+		 	}
+			/* Test the system call */
+		 	TEST(delete_module(tdat[testno].modname));
+		 	TEST_ERROR_LOG(TEST_ERRNO);
+		 	printf("TEST_RETURN is %d, TEST_ERRNO is %d\n",
+				TEST_RETURN, TEST_ERRNO);
+		 	if ( (TEST_RETURN == EXP_RET_VAL) &&
+		 	     (TEST_ERRNO == tdat[testno].experrno) ) {
+		 		tst_resm(TPASS, "Expected results for %s, "
+		 				"errno: %d", tdat[testno].desc,
+		 		 		TEST_ERRNO);
+		 	} else {
+				tst_resm(TFAIL, "Unexpected results for %s ; "
+						"returned %d (expected %d), "
+						"errno %d (expected %d)",
+						tdat[testno].desc,
+						TEST_RETURN, EXP_RET_VAL,
+						TEST_ERRNO,
+						tdat[testno].experrno);
+			}
+			if(tdat[testno].cleanup) {
+				tdat[testno].cleanup();
+			}
+		}
+	}
+	cleanup();
 
-		 		 		 /* Test the system call */
-		 		 		 TEST(delete_module(tdat[testno].modname));
-		 		 		 TEST_ERROR_LOG(TEST_ERRNO);
-		 		 		 printf("TEST_RETURN is %d, TEST_ERRNO is %d\n", TEST_RETURN, TEST_ERRNO);
-		 		 		 if ( (TEST_RETURN == EXP_RET_VAL) &&
-		 		 		 		 (TEST_ERRNO == tdat[testno].experrno) ) {
-		 		 		 		 tst_resm(TPASS, "Expected results for %s, "
-		 		 		 		 		 "errno: %d", tdat[testno].desc,
-		 		 		 		 		 TEST_ERRNO);
-		 		 		 } else {
-		 		 		 		 tst_resm(TFAIL, "Unexpected results for %s ; "
-		 		 		 		 		 "returned %d (expected %d), errno %d "
-		 		 		 		 		 "(expected %d)", tdat[testno].desc,
-		 		 		 		 		 TEST_RETURN, EXP_RET_VAL,
-		 		 		 		 		 TEST_ERRNO, tdat[testno].experrno);
-		 		 		 }
-		 		 		 if(tdat[testno].cleanup) {
-		 		 		 		 tdat[testno].cleanup();
-		 		 		 }
-		 		 }
-		 }
-		 cleanup();
-
-		 /*NOTREACHED*/
-		 return 0;
+	/*NOTREACHED*/
+	return 0;
 }
 
 int
 setup1(void)
 {
-		 /* Change effective user id to nodody */
-		 if (seteuid(ltpuser->pw_uid) == -1) {
-		 		 tst_resm(TBROK, "seteuid failed to set the effective"
-		 		 		 		 " uid to %d", ltpuser->pw_uid);
-		 		 return 1;
-		 }
-		 return 0;
+	/* Change effective user id to nodody */
+	if (seteuid(ltpuser->pw_uid) == -1) {
+		tst_resm(TBROK, "seteuid failed to set the effective"
+				" uid to %d", ltpuser->pw_uid);
+		return 1;
+	}
+	return 0;
 }
 
 void
 cleanup1(void)
 {
-		  /* Change effective user id to root */
-         if (seteuid(0) == -1) {
-		 		 tst_brkm(TBROK, tst_exit, "seteuid failed to set the effective"
-		 		 		 " uid to root");
-         }
+	/* Change effective user id to root */
+	if (seteuid(0) == -1) {
+		tst_brkm(TBROK, tst_exit, "seteuid failed to set the effective"
+					  " uid to root");
+	}
 }
 
 
 /*
  * setup()
- *		 performs all ONE TIME setup for this test
+ *	performs all ONE TIME setup for this test
  */
 void
 setup(void)
 {
-		 /* capture signals */
-		 tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	/* capture signals */
+	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
-		 /* Check whether it is root  */
-		 if (geteuid() != 0) {
-		 		 tst_brkm(TBROK, tst_exit, "Must be root for this test!");
-		 		 /*NOTREACHED*/
-		 }
+	/* Check whether it is root  */
+	if (geteuid() != 0) {
+		tst_brkm(TBROK, tst_exit, "Must be root for this test!");
+		/*NOTREACHED*/
+	}
 
-		 /*if (tst_kvercmp(2,5,48) >= 0)
-		 		 tst_brkm(TCONF, tst_exit, "This test will not work on "
-		 		 		 		 "kernels after 2.5.48");
-		 */
+	/*if (tst_kvercmp(2,5,48) >= 0)
+		tst_brkm(TCONF, tst_exit, "This test will not work on "
+					  "kernels after 2.5.48");
+	 */
 
-        /* Check for nobody_uid user id */
-		  if( (ltpuser = getpwnam(nobody_uid)) == NULL) {
-		 		 tst_brkm(TBROK, tst_exit, "Required user %s doesn't exists",
-		 		 		 		 nobody_uid);
-		 		 /*NOTREACHED*/
-		  }
+	/* Check for nobody_uid user id */
+	if( (ltpuser = getpwnam(nobody_uid)) == NULL) {
+		tst_brkm(TBROK, tst_exit, "Required user %s doesn't exists",
+			 nobody_uid);
+		/*NOTREACHED*/
+	}
 
-		 /* Initialize longmodname to LONGMODNAMECHAR character */
-		 memset(longmodname, LONGMODNAMECHAR, MODNAMEMAX - 1);
+	/* Initialize longmodname to LONGMODNAMECHAR character */
+	memset(longmodname, LONGMODNAMECHAR, MODULE_NAME_LEN - 1);
 
-		 /* set the expected errnos... */
-		 TEST_EXP_ENOS(exp_enos);
+	/* set the expected errnos... */
+	TEST_EXP_ENOS(exp_enos);
 
-		 /* Pause if that option was specified
-		  * TEST_PAUSE contains the code to fork the test with the -c option.
-		  */
-		 TEST_PAUSE;
+	/* Pause if that option was specified
+	 * TEST_PAUSE contains the code to fork the test with the -c option.
+	 */
+	TEST_PAUSE;
 
-		 /* Get unique module name for each child process */
-		 if( sprintf(modname, "%s_%d",BASEMODNAME, getpid()) <= 0) {
-		 		 tst_brkm(TBROK, tst_exit, "Failed to initialize module name");
-		 }
-        bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+	/* Get unique module name for each child process */
+	if( sprintf(modname, "%s_%d", BASEMODNAME, getpid()) <= 0) {
+		tst_brkm(TBROK, tst_exit, "Failed to initialize module name");
+	}
+        bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
         if (bad_addr == MAP_FAILED) {
-                tst_brkm(TBROK, cleanup, "mmap failed");
-    		 }
-		 tdat[2].modname = bad_addr;
+		tst_brkm(TBROK, cleanup, "mmap failed");
+	}
+	tdat[2].modname = bad_addr;
 
 }
 
 /*
  * cleanup()
- *		 performs all ONE TIME cleanup for this test at
- *		 completion or premature exit
+ *	performs all ONE TIME cleanup for this test at
+ *	completion or premature exit
  */
 void
 cleanup(void)
 {
-		 /*
-		  * print timing stats if that option was specified.
-		  * print errno log if that option was specified.
-		  */
-		 TEST_CLEANUP;
+	/*
+	 * print timing stats if that option was specified.
+	 * print errno log if that option was specified.
+	 */
+	TEST_CLEANUP;
 
-		 /* exit with return code appropriate for results */
-		 tst_exit();
-		 /*NOTREACHED*/
+	/* exit with return code appropriate for results */
+	tst_exit();
+	/*NOTREACHED*/
 }
-
diff --git a/testcases/kernel/module/delete_module/delete_module03.c b/testcases/kernel/module/delete_module/delete_module03.c
index b35730e..e498010 100644
--- a/testcases/kernel/module/delete_module/delete_module03.c
+++ b/testcases/kernel/module/delete_module/delete_module03.c
@@ -54,32 +54,35 @@
  *
  * USAGE:  <for command-line>
  *  delete_module03 [-c n] [-e] [-f] [-h] [-i n] [-I x] [-p] [-P x] [-t]
- *		 		 where,  -c n : Run n copies concurrently. (no effect)
- *		 		 		 -e   : Turn on errno logging.
- *		 		 		 -f   : Turn off functional testing
- *		 		 		 -h   : Show help screen
- *		 		 		 -i n : Execute test n times.
- *		 		 		 -I x : Execute test for x seconds.
- *		 		 		 -p   : Pause for SIGUSR1 before starting
- *		 		 		 -P x : Pause for x seconds between iterations.
- *		 		 		 -t   : Turn on syscall timing.
+ *		 		 where,  -c n : Run n copies concurrently. (no
+ *		 		 		effect)
+ *	 		 		 -e   : Turn on errno logging.
+ *	 		 		 -f   : Turn off functional testing
+ *	 		 		 -h   : Show help screen
+ *	 		 		 -i n : Execute test n times.
+ *	 		 		 -I x : Execute test for x seconds.
+ *	 		 		 -p   : Pause for SIGUSR1 before
+ *	 		 		 	starting
+ *	 		 		 -P x : Pause for x seconds between
+ *	 		 		 	iterations.
+ *	 		 		 -t   : Turn on syscall timing.
  *
  * RESTRICTIONS
- *		 -c option has no effect for this testcase, even if used allows only
- *		 one instance to run at a time.
+ *		 -c option has no effect for this testcase, even if used allows
+ *		 only one instance to run at a time.
  *
  * CHANGELOG
  *   
- *  11/22/02 - Added "--force" to insmod options and redirected output to /dev/null.
- *             This was done to allow kernel mismatches, b/c it doesn't matter in
- *             this case.
- *           Robbie Williamson <robbiew@us.ibm.com>
+ *  11/22/02 -	Added "--force" to insmod options and redirected output to
+ *  		/dev/null. This was done to allow kernel mismatches, b/c it
+ *  		doesn't matter in this case.
+ *		Robbie Williamson <robbiew@us.ibm.com>
  *
  ****************************************************************/
 
+#include <libgen.h>
 #include <errno.h>
 #include <pwd.h>
-//#include <linux/module.h>
 #include "test.h"
 #include "usctest.h"
 
@@ -89,10 +92,10 @@
 #define DUMMY_MOD_DEP		 "dummy_del_mod_dep"
 #define EXP_RET_VAL		 -1
 #define EXP_ERRNO		 EWOULDBLOCK
-//#define EXP_ERRNO		 EBUSY
+/*#define EXP_ERRNO		 EBUSY */
 
 char *TCID = "delete_module03";
-//static int exp_enos[] = {EBUSY, 0};
+/*static int exp_enos[] = {EBUSY, 0}; */
 static int exp_enos[] = {EWOULDBLOCK, 0};
 int TST_TOTAL = 1;
 
@@ -102,137 +105,138 @@
 int
 main(int argc, char **argv)
 {
-		 int lc;		 		 		 		 /* loop counter */
-		 char *msg;		 		 		 /* message returned from parse_opts */
-		 char cmd[50];
+	int lc;		 		 /* loop counter */
+	char *msg;	 		 /* message returned from parse_opts */
+	char cmd[50];
 
-		 /* parse standard options */
-		 if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) !=
-		     (char *)NULL) {
-		 		 tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
-		 }
+	/* parse standard options */
+	if ((msg = parse_opts(argc, argv, (option_t*) NULL, NULL)) !=
+	    (char *) NULL) {
+		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
+	}
 
-		 if(STD_COPIES != 1) {
-		 		 tst_resm(TINFO, "-c option has no effect for this testcase - "
-		 		 		 "doesn't allow running more than one instance "
-		 		 		 "at a time");
-		 		 STD_COPIES = 1;
-		 }
+	if(STD_COPIES != 1) {
+		tst_resm(TINFO, "-c option has no effect for this testcase - "
+				"doesn't allow running more than one instance "
+		 		"at a time");
+		STD_COPIES = 1;
+	}
 
-		 /* Load first kernel module */
-        if( sprintf(cmd, "/sbin/insmod /tmp/%s.ko", DUMMY_MOD) <= 0) {
-                tst_resm(TBROK, "sprintf failed");
-                return 1;
-        }
+	/* Load first kernel module */
+	if( sprintf(cmd, "/sbin/insmod %s/%s.ko", dirname(argv[0]),
+		DUMMY_MOD) <= 0) {
+		tst_resm(TBROK, "sprintf failed");
+		return 1;
+	}
+	if( (system(cmd)) != 0 ) {
+		tst_resm(TBROK, "Failed to load %s module", DUMMY_MOD);
+		return 1;
+	}
+
+	/* Load dependant kernel module */
+        if( sprintf(cmd, "/sbin/insmod %s/%s.ko", dirname(argv[0]),
+		DUMMY_MOD_DEP) <= 0) {
+		tst_resm(TBROK, "sprintf failed");
+		goto END;
+	}
         if( (system(cmd)) != 0 ) {
-                tst_resm(TBROK, "Failed to load %s module", DUMMY_MOD);
-                return 1;
+		tst_resm(TBROK, "Failed to load %s module", DUMMY_MOD_DEP);
+		goto END;
         }
 
-		 /* Load dependant kernel module */
-        if( sprintf(cmd, "/sbin/insmod /tmp/%s.ko", DUMMY_MOD_DEP) <= 0) {
-                tst_resm(TBROK, "sprintf failed");
-                goto END;
-        }
-        if( (system(cmd)) != 0 ) {
-                tst_resm(TBROK, "Failed to load %s module", DUMMY_MOD_DEP);
-                goto END;
-        }
+	tst_tmpdir();
+	if(setup() != 0) {
+		return 1;
+	}
 
-		 tst_tmpdir();
-		 if(setup() != 0) {
-		 		 return 1;
-		 }
+	/* check looping state if -i option is given */
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		/* reset Tst_count in case we are looping */
+		Tst_count = 0;
 
-		 /* check looping state if -i option is given */
-		 for (lc = 0; TEST_LOOPING(lc); lc++) {
-		 		 /* reset Tst_count in case we are looping */
-		 		 Tst_count = 0;
+		/* Test the system call */
+		TEST(delete_module(DUMMY_MOD));
 
-		 		 /* Test the system call */
-		 		 TEST(delete_module(DUMMY_MOD));
-
-		 		 TEST_ERROR_LOG(TEST_ERRNO);
-		 		 if ( (TEST_RETURN == (int) EXP_RET_VAL ) &&
-		 		 		 		 (TEST_ERRNO == EXP_ERRNO) ) {
-		 		 		 tst_resm(TPASS, "Expected failure for module in-use, "
-		 		 		 		 "errno: %d", TEST_ERRNO);
-		 		 } else {
-		 		 		 tst_resm(TFAIL, "Unexpected results for module in-use; "
-		 		 		 		 "returned %d (expected %d), errno %d "
-		 		 		 		 "(expected %d)", TEST_RETURN, EXP_RET_VAL,
-		 		 		 		 TEST_ERRNO, EXP_ERRNO);
-		 		 }
-		 }
-		 cleanup();
+		TEST_ERROR_LOG(TEST_ERRNO);
+		if ( (TEST_RETURN == (int) EXP_RET_VAL ) &&
+		     (TEST_ERRNO == EXP_ERRNO) ) {
+			tst_resm(TPASS, "Expected failure for module in-use, "
+		 			"errno: %d", TEST_ERRNO);
+		} else {
+			tst_resm(TFAIL, "Unexpected results for module in-use; "
+		 			"returned %d (expected %d), errno %d "
+					"(expected %d)", TEST_RETURN,
+					EXP_RET_VAL, TEST_ERRNO, EXP_ERRNO);
+		}
+	}
+	cleanup();
 END:
-		 if(system("rmmod "DUMMY_MOD) != 0) {
-		 		 tst_resm(TBROK, "Failed to unload %s module", DUMMY_MOD);
-		 		 return 1;
-		 }
+	if(system("rmmod "DUMMY_MOD) != 0) {
+		tst_resm(TBROK, "Failed to unload %s module", DUMMY_MOD);
+		return 1;
+	}
 
-		 /*NOTREACHED*/
-		 return 0;
+	/*NOTREACHED*/
+	return 0;
 }
 
 /*
  * setup()
- *		 performs all ONE TIME setup for this test
+ *	performs all ONE TIME setup for this test
  */
 int
 setup(void)
 {
-		 /* capture signals */
-		 tst_sig(FORK, DEF_HANDLER, cleanup);
+	/* capture signals */
+	tst_sig(FORK, DEF_HANDLER, cleanup);
 
-		 /* Check whether it is root  */
-		 if (geteuid() != 0) {
-		 		 tst_resm(TBROK, "Must be root for this test!");
-		 		 return 1;
-		 }
+	/* Check whether it is root  */
+	if (geteuid() != 0) {
+		tst_resm(TBROK, "Must be root for this test!");
+		return 1;
+	}
 
-		 /*
-		 if (tst_kvercmp(2,5,48) >= 0)
-		 		 tst_brkm(TCONF, tst_exit, "This test will not work on "
-		 		 		 		 "kernels after 2.5.48");
-		 */
+	/*
+	if (tst_kvercmp(2,5,48) >= 0)
+		tst_brkm(TCONF, tst_exit, "This test will not work on "
+					  "kernels after 2.5.48");
+	*/
 
-		 /* set the expected errnos... */
-		 TEST_EXP_ENOS(exp_enos);
+	/* set the expected errnos... */
+	TEST_EXP_ENOS(exp_enos);
 
-		 /* Pause if that option was specified
-		  * TEST_PAUSE contains the code to fork the test with the -c option.
-		  */
-		 TEST_PAUSE;
-		 return 0;
+	/* Pause if that option was specified
+	 * TEST_PAUSE contains the code to fork the test with the -c option.
+	 */
+	TEST_PAUSE;
+	return 0;
 
 }
 
 /*
  * cleanup()
- *		 performs all ONE TIME cleanup for this test at
- *		 completion or premature exit
+ *	performs all ONE TIME cleanup for this test at
+ *	completion or premature exit
  */
 void
 cleanup(void)
 {
-		 /* Unload dependent kernel module */
-		 if(system("rmmod "DUMMY_MOD_DEP) != 0) {
-		 		 tst_resm(TBROK, "Failed to unload %s module",
-		 		 		 DUMMY_MOD_DEP);
-		 }
-		 /* Unload first kernel module */
-		 if(system("rmmod "DUMMY_MOD) != 0) {
-		 		 tst_resm(TBROK, "Failed to unload %s module",
-		 		 		 DUMMY_MOD);
-		 }
-		 /*
-		  * print timing stats if that option was specified.
-		  * print errno log if that option was specified.
-		  */
-		 TEST_CLEANUP;
-		 tst_rmdir();
-		 /* exit with return code appropriate for results */
-		 tst_exit();
-		 /*NOTREACHED*/
+	/* Unload dependent kernel module */
+	if(system("rmmod "DUMMY_MOD_DEP) != 0) {
+		tst_resm(TBROK, "Failed to unload %s module", DUMMY_MOD_DEP);
+	}
+	/* Unload first kernel module */
+	if(system("rmmod "DUMMY_MOD) != 0) {
+		tst_resm(TBROK, "Failed to unload %s module",
+		DUMMY_MOD);
+	}
+	/*
+	 * print timing stats if that option was specified.
+	 * print errno log if that option was specified.
+	 */
+	TEST_CLEANUP;
+	tst_rmdir();
+	/* exit with return code appropriate for results */
+	tst_exit();
+	/*NOTREACHED*/
 }
diff --git a/testcases/kernel/module/delete_module/dummy_del_mod.c b/testcases/kernel/module/delete_module/dummy_del_mod.c
index 5328834..ce5f993 100644
--- a/testcases/kernel/module/delete_module/dummy_del_mod.c
+++ b/testcases/kernel/module/delete_module/dummy_del_mod.c
@@ -20,7 +20,10 @@
  *		setup.
  *************************************************************************/
 
+#ifndef MODULE
 #define MODULE
+#endif
+
 /* #define __KERNEL__    Commented this line out b/c it causes errors with
  *			 module.h when it calls /usr/include/linux/version.h
  *			 -11/22/02 Robbie Williamson <robbiew@us.ibm.com>
diff --git a/testcases/kernel/module/delete_module/dummy_del_mod_dep.c b/testcases/kernel/module/delete_module/dummy_del_mod_dep.c
index 8d25509..b6595ac 100644
--- a/testcases/kernel/module/delete_module/dummy_del_mod_dep.c
+++ b/testcases/kernel/module/delete_module/dummy_del_mod_dep.c
@@ -21,7 +21,9 @@
  *		(calls function of dummy_del_mod during initialization).
  *************************************************************************/
 
+#ifndef MODULE
 #define MODULE
+#endif
 /* #define __KERNEL__    Commented this line out b/c it causes errors with
  *                       module.h when it calls /usr/include/linux/version.h
  *                       -11/22/02 Robbie Williamson <robbiew@us.ibm.com>
diff --git a/testcases/kernel/numa/Makefile b/testcases/kernel/numa/Makefile
index a903d63..f5e1881 100644
--- a/testcases/kernel/numa/Makefile
+++ b/testcases/kernel/numa/Makefile
@@ -16,25 +16,14 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../include -Wall -DNUMA_VERSION1_COMPATIBILITY
+top_srcdir		:= ../../..
 
-LDLIBS += -L../../../lib -lltp 
+include $(top_srcdir)/include/mk/testcases.mk
 
-ifeq ($(HAS_NUMA),yes)    #its a numa machine
-LDLIBS += -L../../../lib  -lnuma
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-else                                    #its not a numa machine
-SRCS    = support_numa.c
-TARGETS = $(patsubst %.c,%,$(SRCS))
-endif
+CPPFLAGS		+= -D_GNU_SOURCE -DNUMA_VERSION1_COMPATIBILITY
 
-all: $(TARGETS) 
+LDLIBS 			+= $(NUMA_LIBS)
 
+INSTALL_TARGETS		:= numa01.sh
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../bin/$$i ; done
-	chmod 755 numa01.sh; cp numa01.sh ../../bin/.
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/numa/numa_node_size.c b/testcases/kernel/numa/numa_node_size.c
index a47742f..e9b16bb 100644
--- a/testcases/kernel/numa/numa_node_size.c
+++ b/testcases/kernel/numa/numa_node_size.c
@@ -31,48 +31,56 @@
 /*                                                                            */
 /******************************************************************************/
 
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
-#include "numa.h"
+#if HAS_NUMA_H
+#include <numa.h>
+#endif
+
 int numa_exit_on_error = 0;
 char *fmt_mem(unsigned long long mem, char *buf)
 {
         if (mem == -1L)
-                sprintf(buf, "<not available>");
+            sprintf(buf, "<not available>");
         else
-                sprintf(buf, "%Lu MB", mem >> 20);
+            sprintf(buf, "%Lu MB", mem >> 20);
         return buf;
 }
 void hardware(void)
 {
+#if HAS_NUMA_H
         int i;
         int maxnode = numa_max_node();
         printf("available: %d nodes (0-%d)\n", 1+maxnode, maxnode);
         for (i = 0; i <= maxnode; i++) {
-                char buf[64];
-                long fr;
-                unsigned long sz = numa_node_size(i, &fr);
-                printf("node %d cpus:", i);
-                printf("node %d size: %s\n", i, fmt_mem(sz, buf));
-                printf("node %d free: %s\n", i, fmt_mem(fr, buf));
+            char buf[64];
+            long fr;
+            unsigned long sz = numa_node_size(i, &fr);
+            printf("node %d cpus:", i);
+            printf("node %d size: %s\n", i, fmt_mem(sz, buf));
+            printf("node %d free: %s\n", i, fmt_mem(fr, buf));
         }
+#endif
 }
 int main()
 {
-         nodemask_t nodemask;
-	 void hardware();
-	 if (numa_available() < 0)
-	 {
-         	printf("This system does not support NUMA policy");
-		numa_error("numa_available");
-		numa_exit_on_error = 1;
-		exit(numa_exit_on_error);
-    	 }
-	nodemask_zero(&nodemask);
-	nodemask_set(&nodemask,1);
-	numa_bind(&nodemask);
-	hardware();
-	return numa_exit_on_error;
+#if HAS_NUMA_H
+        nodemask_t nodemask;
+        void hardware();
+        if (numa_available() < 0)
+        {
+            printf("This system does not support NUMA policy\n");
+            numa_error("numa_available");
+            numa_exit_on_error = 1;
+            exit(numa_exit_on_error);
+        }
+        nodemask_zero(&nodemask);
+        nodemask_set(&nodemask,1);
+        numa_bind(&nodemask);
+        hardware();
+        return numa_exit_on_error;
+#else
+        printf("NUMA is not available\n");
+        return 1;
+#endif
 }
-                  
diff --git a/testcases/kernel/performance_counters/Makefile b/testcases/kernel/performance_counters/Makefile
index f9724d0..9c72fa3 100644
--- a/testcases/kernel/performance_counters/Makefile
+++ b/testcases/kernel/performance_counters/Makefile
@@ -1,31 +1,27 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2009
+#    kernel/performance_counters testcases Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-CFLAGS += -I../../../include -Wall
-LDLIBS += -L../../../lib -lltp
+top_srcdir	?= ../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/performance_counters/performance_counter01.c b/testcases/kernel/performance_counters/performance_counter01.c
index 841a98f..7f0118b 100644
--- a/testcases/kernel/performance_counters/performance_counter01.c
+++ b/testcases/kernel/performance_counters/performance_counter01.c
@@ -50,7 +50,7 @@
 char *TCID     = "performance_counter01"; /* test program identifier.          */
 int  TST_TOTAL = 1; 
 
-#define cleanup tst_exit /* for now... */
+static void cleanup(void) { /* Stub function. */ }
 
 int perf_counter_open(int		hw_event_type,
                       unsigned int	hw_event_period,
@@ -71,7 +71,8 @@
 	PERF_COUNT_BRANCH_MISSES,
 };
 
-int main(void) {
+int
+main(void) {
 	unsigned long long count1, count2;
 	int fd1, fd2, ret;
 	fd1 = perf_counter_open(PERF_COUNT_INSTRUCTIONS, 0, 0, 0, -1);
diff --git a/testcases/kernel/performance_counters/performance_counter02.c b/testcases/kernel/performance_counters/performance_counter02.c
index 9c14b7f..37e62f0 100644
--- a/testcases/kernel/performance_counters/performance_counter02.c
+++ b/testcases/kernel/performance_counters/performance_counter02.c
@@ -62,6 +62,8 @@
 #include <poll.h>
 #include <unistd.h>
 #include <errno.h>
+#include "config.h"
+#include <sys/prctl.h>
 #include <sys/types.h>
 #include <linux/types.h>
 #include <syscall.h>
@@ -82,7 +84,7 @@
 char *TCID     = "performance_counter02"; /* test program identifier.          */
 int  TST_TOTAL = 1;                  /* total number of tests in this file.   */
 
-#define cleanup tst_exit /* for now... */
+static void cleanup(void) { /* Stub function. */ }
 
 typedef unsigned int u32;
 typedef unsigned long long u64;
@@ -141,6 +143,7 @@
 		asm volatile("" : : "g" (i));
 }
 
+int
 main(int ac, char **av)
 {
 	int tsk0;
@@ -238,5 +241,5 @@
 	}
 
 	fprintf(stderr, "test passed\n");
-	exit(0);
+	tst_exit();
 }
diff --git a/testcases/kernel/power_management/Makefile b/testcases/kernel/power_management/Makefile
index 71ae13d..5e79074 100644
--- a/testcases/kernel/power_management/Makefile
+++ b/testcases/kernel/power_management/Makefile
@@ -18,40 +18,14 @@
 ##                                                                            ##
 ################################################################################
 
-SUBDIRS := 
+top_srcdir		?= ../../..
 
-all: 
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done;
-	$(MAKE) check_kv_arch ;
-	$(MAKE) get_sched_values ;
+include $(top_srcdir)/include/mk/testcases.mk
 
-check_kv_arch: check_kv_arch.c 
-	$(CC) -o $@ $< ../../../lib/tst_kvercmp.c -I../../../include
-get_sched_values: get_sched_values.c
-	$(CC) -o $@ $< ../../../lib/tst_kvercmp.c -I../../../include
+$(eval $(call generate_vpath_rule,c,$(srcdir):$(top_srcdir)/lib))
 
-install:
-	@set -e; ln -f check_kv_arch ../../bin/check_kv_arch; \
-	ln -f get_sched_values ../../bin/get_sched_values; \
-	ln -f  change_freq.sh ../../bin/change_freq.sh; \
-	ln -f  change_govr.sh ../../bin/change_govr.sh; \
-	ln -f  check_cpufreq_sysfs_files.sh ../../bin/check_cpufreq_sysfs_files.sh; \
-	ln -f  check_config.sh ../../bin/check_config.sh; \
-	ln -f  pwkm_load_unload.sh ../../bin/pwkm_load_unload.sh; \
-	ln -f  pm_include.sh ../../bin/pm_include.sh; \
-	ln -f  runpwtests.sh ../../bin/runpwtests.sh; \
-	ln -f  test_sched_mc.sh ../../bin/test_sched_mc.sh; \
-	ln -f  test_sched_mc.sh ../../bin/test_sched_smt.sh; \
-	ln -f  test_sched_mc.sh ../../bin/test_timer_migration.sh; \
-	ln -f  config_cpu_freq ../../bin/config_cpu_freq; \
-	ln -f  config_cpu_idle ../../bin/config_cpu_idle; \
-	ln -f  config_sched_mc ../../bin/config_sched_mc;
-	ln -f  check_cpuidle_sysfs_files.sh ../../bin/check_cpuidle_sysfs_files.sh;
-	ln -f  cpu_consolidation.py ../../bin/cpu_consolidation.py
-	ln -f  sched_domain.py ../../bin/sched_domain.py
-	ln -f  ilb_test.py ../../bin/ilb_test.py
-	chmod ugo+x *.sh
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done
-	rm -f check_kv_arch
-	rm -f get_sched_values
+INSTALL_TARGETS		:= lib/*.py *.py *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/power_management/cpu_consolidation.py b/testcases/kernel/power_management/cpu_consolidation.py
index 7ca8646..b305fea 100755
--- a/testcases/kernel/power_management/cpu_consolidation.py
+++ b/testcases/kernel/power_management/cpu_consolidation.py
@@ -6,7 +6,7 @@
 import os
 import sys
 import time
-LIB_DIR = "%s/testcases/kernel/power_management/lib" % os.environ['LTPROOT']
+LIB_DIR = "%s/lib" % os.path.dirname(__file__)
 sys.path.append(LIB_DIR)
 from optparse import OptionParser
 from sched_mc import *
diff --git a/testcases/kernel/power_management/ilb_test.py b/testcases/kernel/power_management/ilb_test.py
index 9798929..d5c3f49 100755
--- a/testcases/kernel/power_management/ilb_test.py
+++ b/testcases/kernel/power_management/ilb_test.py
@@ -5,7 +5,7 @@
 
 import os
 import sys
-LIB_DIR = "%s/testcases/kernel/power_management/lib" % os.environ['LTPROOT']
+LIB_DIR = "%s/lib" % os.path.dirname(__file__)
 sys.path.append(LIB_DIR)
 from optparse import OptionParser
 from sched_mc import *
diff --git a/testcases/kernel/power_management/sched_domain.py b/testcases/kernel/power_management/sched_domain.py
index 086606a..808e16f 100755
--- a/testcases/kernel/power_management/sched_domain.py
+++ b/testcases/kernel/power_management/sched_domain.py
@@ -5,7 +5,7 @@
 
 import os
 import sys
-LIB_DIR = "%s/testcases/kernel/power_management/lib" % os.environ['LTPROOT']
+LIB_DIR = "%s/lib" % os.path.dirname(__file__)
 sys.path.append(LIB_DIR)
 from sched_mc import *
 from optparse import OptionParser
diff --git a/testcases/kernel/pty/Makefile b/testcases/kernel/pty/Makefile
index 64ad66a..8ab09bf 100644
--- a/testcases/kernel/pty/Makefile
+++ b/testcases/kernel/pty/Makefile
@@ -1,24 +1,29 @@
+#
+#    kernel/pty testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-CFLAGS+= -O -Wall -g -D_GNU_SOURCE -I../../../include
-LDLIBS+= -L../../../lib -lltp
+top_srcdir		?= ../../..
 
-BIN= hangup01 ptem01 pty01
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(BIN)
+CPPFLAGS		+= -D_GNU_SOURCE 
 
-clean:	FRC
-	rm -f $(BIN)
-
-install:  FRC
-	@set -e; for i in $(BIN); do ln -f $$i ../../bin/$$i ; done
-
-hangup01: hangup01.c
-	$(CC) $(CFLAGS) -o hangup01 hangup01.c $(LDFLAGS) $(LDLIBS)
-
-ptem01: ptem01.c
-	$(CC) $(CFLAGS) -o ptem01 ptem01.c $(LDFLAGS) $(LDLIBS)
-
-pty01: pty01.c	
-	$(CC) $(CFLAGS) -o pty01 pty01.c $(LDFLAGS) $(LDLIBS)
-
-FRC:
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/Makefile b/testcases/kernel/sched/Makefile
index 62a916c..6245ed0 100644
--- a/testcases/kernel/sched/Makefile
+++ b/testcases/kernel/sched/Makefile
@@ -1,12 +1,27 @@
-SUBDIRS = cfs-scheduler clisrv hyperthreading nptl process_stress pthreads sched_stress tool 
+#
+#    kernel/sched test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/sched/cfs-scheduler/Makefile b/testcases/kernel/sched/cfs-scheduler/Makefile
index 678cf7c..aa3bf84 100644
--- a/testcases/kernel/sched/cfs-scheduler/Makefile
+++ b/testcases/kernel/sched/cfs-scheduler/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -lpthread
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lpthread
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/clisrv/Makefile b/testcases/kernel/sched/clisrv/Makefile
index 15cccda..0c293d3 100644
--- a/testcases/kernel/sched/clisrv/Makefile
+++ b/testcases/kernel/sched/clisrv/Makefile
@@ -1,21 +1,36 @@
-CFLAGS+= -Wall -O -D_LINUX
-CFILES=pthcli.c pthserv.c readline.c writen.c
-OFILES=$(CFILES:.c=.o)
-LOADLIBES+= -lpthread
-TESTS = pthcli pthserv
+#
+#    kernel/sched/cliserv test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TESTS)
+top_srcdir		?= ../../../..
 
-pthcli: pthcli.o readline.o writen.o
-	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LOADLIBES)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-pthserv: pthserv.o readline.o writen.o 
-	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LOADLIBES)
+CPPFLAGS		+= -D_LINUX
+LDLIBS			+= -lpthread
 
-install:
-	@set -e; for i in $(TESTS) ; do ln -f $$i ../../../bin/$$i ; done ;
-	ln -f run_sched_cliserv.sh ../../../bin/
-	ln -f data ../../../bin/
+INSTALL_TARGETS		:= data run_sched_cliserv.sh
 
-clean:
-	rm -fr $(OFILES) $(TESTS)
+MAKE_TARGETS		:= pthcli pthserv
+
+$(MAKE_TARGETS): %: %.o readline.o writen.o
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/hyperthreading/Makefile b/testcases/kernel/sched/hyperthreading/Makefile
index 2e0d64a..44d94f2 100644
--- a/testcases/kernel/sched/hyperthreading/Makefile
+++ b/testcases/kernel/sched/hyperthreading/Makefile
@@ -1,10 +1,27 @@
-SUBDIRS = ht_enabled ht_affinity ht_interrupt
+#
+#    kernel/sched/hyperthreading test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/sched/hyperthreading/ht_affinity/Makefile b/testcases/kernel/sched/hyperthreading/ht_affinity/Makefile
index 2bb09d8..e6c1abf 100644
--- a/testcases/kernel/sched/hyperthreading/ht_affinity/Makefile
+++ b/testcases/kernel/sched/hyperthreading/ht_affinity/Makefile
@@ -1,20 +1,33 @@
-# Check that the definitions below are correct for your system
+#
+#    sched/hyperthreading/ht_affinity testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-CFLAGS    += -I../../../../../include -Wall
-LOADLIBES += -L../../../../../lib -lltp
-TARGETS   := ht_affinity
+top_srcdir		?= ../../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-#ht_affinity: HTaffinity.o HTutils.o
-#	gcc -o ht_affinity HTaffinity.o HTutils.o $(CFLAGS) $(LOADLIBES)
-ht_affinity:
-	${CC} -o ht_affinity HTaffinity.c HTutils.c $(CFLAGS) $(LOADLIBES)
+INSTALL_TARGETS		:= smt_smp_affinity.sh
 
-install:
-	@chmod 755 smt_smp_affinity.sh
-	@ln -f smt_smp_affinity.sh ../../../../bin/
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../../bin/$$i ; done
+MAKE_TARGETS		:= ht_affinity
 
-clean:
-	rm -f $(TARGETS)
+$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c))
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/hyperthreading/ht_affinity/HTaffinity.c b/testcases/kernel/sched/hyperthreading/ht_affinity/ht_affinity.c
similarity index 99%
rename from testcases/kernel/sched/hyperthreading/ht_affinity/HTaffinity.c
rename to testcases/kernel/sched/hyperthreading/ht_affinity/ht_affinity.c
index fa2d254..e931940 100644
--- a/testcases/kernel/sched/hyperthreading/ht_affinity/HTaffinity.c
+++ b/testcases/kernel/sched/hyperthreading/ht_affinity/ht_affinity.c
@@ -12,7 +12,7 @@
  *   (at your option) any later version.                                   *
  *                                                                         *
  ***************************************************************************/
-#include "HTutils.h"
+#include "ht_utils.h"
 #include <sys/syscall.h>
 #include <sys/types.h>
 #include <unistd.h>
diff --git a/testcases/kernel/sched/hyperthreading/ht_affinity/HTutils.c b/testcases/kernel/sched/hyperthreading/ht_affinity/ht_utils.c
similarity index 98%
rename from testcases/kernel/sched/hyperthreading/ht_affinity/HTutils.c
rename to testcases/kernel/sched/hyperthreading/ht_affinity/ht_utils.c
index 8c2a850..0e581d8 100644
--- a/testcases/kernel/sched/hyperthreading/ht_affinity/HTutils.c
+++ b/testcases/kernel/sched/hyperthreading/ht_affinity/ht_utils.c
@@ -1,5 +1,5 @@
 
-#include "HTutils.h"
+#include "ht_utils.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/testcases/kernel/sched/hyperthreading/ht_affinity/HTutils.h b/testcases/kernel/sched/hyperthreading/ht_affinity/ht_utils.h
similarity index 100%
rename from testcases/kernel/sched/hyperthreading/ht_affinity/HTutils.h
rename to testcases/kernel/sched/hyperthreading/ht_affinity/ht_utils.h
diff --git a/testcases/kernel/sched/hyperthreading/ht_enabled/Makefile b/testcases/kernel/sched/hyperthreading/ht_enabled/Makefile
index 460e530..76be88f 100644
--- a/testcases/kernel/sched/hyperthreading/ht_enabled/Makefile
+++ b/testcases/kernel/sched/hyperthreading/ht_enabled/Makefile
@@ -1,20 +1,33 @@
-# Check that the definitions below are correct for your system
+#
+#    sched/hyperthreading/ht_enabled testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-CFLAGS   +=	-I../../../../../include -Wall
-LOADLIBES+=	-L../../../../../lib -lltp
-TARGETS  := ht_enabled
+top_srcdir		?= ../../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-ht_enabled:
-	${CC} -o ht_enabled HTenabled.c HTutils.c $(CFLAGS) $(LOADLIBES)
+INSTALL_TARGETS		:= smt_smp_enabled.sh
 
-install:
-	@chmod 755 smt_smp_enabled.sh
-	@ln -f smt_smp_enabled.sh ../../../../bin/
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../../bin/$$i ; done
+MAKE_TARGETS		:= ht_enabled
 
-clean:
-	rm -f $(TARGETS)
+$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c))
 
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/hyperthreading/ht_enabled/HTenabled.c b/testcases/kernel/sched/hyperthreading/ht_enabled/ht_enabled.c
similarity index 98%
rename from testcases/kernel/sched/hyperthreading/ht_enabled/HTenabled.c
rename to testcases/kernel/sched/hyperthreading/ht_enabled/ht_enabled.c
index 8cbb13c..2099dc9 100644
--- a/testcases/kernel/sched/hyperthreading/ht_enabled/HTenabled.c
+++ b/testcases/kernel/sched/hyperthreading/ht_enabled/ht_enabled.c
@@ -14,7 +14,7 @@
  ***************************************************************************/
 
 #include "test.h"
-#include "HTutils.h"
+#include "ht_utils.h"
 
 char *TCID = "smt_smp_enabled";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/sched/hyperthreading/ht_enabled/HTutils.c b/testcases/kernel/sched/hyperthreading/ht_enabled/ht_utils.c
similarity index 98%
rename from testcases/kernel/sched/hyperthreading/ht_enabled/HTutils.c
rename to testcases/kernel/sched/hyperthreading/ht_enabled/ht_utils.c
index b185961..3b2cae8 100644
--- a/testcases/kernel/sched/hyperthreading/ht_enabled/HTutils.c
+++ b/testcases/kernel/sched/hyperthreading/ht_enabled/ht_utils.c
@@ -1,5 +1,5 @@
 
-#include "HTutils.h"
+#include "ht_utils.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/testcases/kernel/sched/hyperthreading/ht_enabled/HTutils.h b/testcases/kernel/sched/hyperthreading/ht_enabled/ht_utils.h
similarity index 100%
rename from testcases/kernel/sched/hyperthreading/ht_enabled/HTutils.h
rename to testcases/kernel/sched/hyperthreading/ht_enabled/ht_utils.h
diff --git a/testcases/kernel/sched/hyperthreading/ht_interrupt/Makefile b/testcases/kernel/sched/hyperthreading/ht_interrupt/Makefile
index f3faa8d..bc84e51 100644
--- a/testcases/kernel/sched/hyperthreading/ht_interrupt/Makefile
+++ b/testcases/kernel/sched/hyperthreading/ht_interrupt/Makefile
@@ -1,18 +1,31 @@
-# Check that the definitions below are correct for your system
+#
+#    sched/hyperthreading/ht_interrupt testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-CFLAGS+=	-I../../../../../include -Wall
-LOADLIBES+=	-L../../../../../lib -lltp
-TARGETS = ht_interrupt
+top_srcdir		?= ../../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-ht_interrupt:
-	${CC} -o ht_interrupt HTinterrupt.c HTutils.c $(CFLAGS) $(LOADLIBES) 
+MAKE_TARGETS		:= ht_interrupt
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../../bin/$$i ; done
+$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c))
 
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/hyperthreading/ht_interrupt/HTinterrupt.c b/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_interrupt.c
similarity index 99%
rename from testcases/kernel/sched/hyperthreading/ht_interrupt/HTinterrupt.c
rename to testcases/kernel/sched/hyperthreading/ht_interrupt/ht_interrupt.c
index a09fffd..c006306 100644
--- a/testcases/kernel/sched/hyperthreading/ht_interrupt/HTinterrupt.c
+++ b/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_interrupt.c
@@ -12,7 +12,7 @@
  *   (at your option) any later version.                                   *
  *                                                                         *
  ***************************************************************************/
-#include "HTutils.h"
+#include "ht_utils.h"
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/testcases/kernel/sched/hyperthreading/ht_interrupt/HTutils.c b/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c
similarity index 99%
rename from testcases/kernel/sched/hyperthreading/ht_interrupt/HTutils.c
rename to testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c
index 9d6e1c0..eb8a6d0 100644
--- a/testcases/kernel/sched/hyperthreading/ht_interrupt/HTutils.c
+++ b/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.c
@@ -1,5 +1,5 @@
 
-#include "HTutils.h"
+#include "ht_utils.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/testcases/kernel/sched/hyperthreading/ht_interrupt/HTutils.h b/testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.h
similarity index 100%
rename from testcases/kernel/sched/hyperthreading/ht_interrupt/HTutils.h
rename to testcases/kernel/sched/hyperthreading/ht_interrupt/ht_utils.h
diff --git a/testcases/kernel/sched/nptl/Makefile b/testcases/kernel/sched/nptl/Makefile
index 26ecce8..eca7f59 100644
--- a/testcases/kernel/sched/nptl/Makefile
+++ b/testcases/kernel/sched/nptl/Makefile
@@ -16,27 +16,17 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-###########################################################################
-NPTL:=$(shell getconf GNU_LIBPTHREAD_VERSION 2>/dev/null| grep NPTL; echo $?)
-ifeq ($(NPTL),)
-CFLAGS+=	-I../../../../include -g -Wall 
-else
-CFLAGS+=	-I../../../../include -g -Wall -DUSING_NPTL
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+# XXX (garrcoop): Integrate in autoconf check for nptl.
+HAS_NPTL		?= $(shell getconf GNU_LIBPTHREAD_VERSION 2>/dev/null| grep -q NPTL && echo yes)
+
+ifeq ($(HAS_NPTL),yes)
+CPPFLAGS		+= -DUSING_NPTL
 endif
 
-LOADLIBES+=	-L../../../../lib -lltp -lpthread
+LDLIBS			+= -lpthread
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/process_stress/Makefile b/testcases/kernel/sched/process_stress/Makefile
index b9264b3..8719939 100644
--- a/testcases/kernel/sched/process_stress/Makefile
+++ b/testcases/kernel/sched/process_stress/Makefile
@@ -1,12 +1,29 @@
-CFLAGS += -O -w -g -D_LINUX
+#
+#    kernel/sched/process_test testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+CPPFLAGS		+= -D_LINUX
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/pthreads/Makefile b/testcases/kernel/sched/pthreads/Makefile
index 748c5e6..c9932c7 100644
--- a/testcases/kernel/sched/pthreads/Makefile
+++ b/testcases/kernel/sched/pthreads/Makefile
@@ -1,14 +1,29 @@
-CPPFLAGS += -I../../../../include
-CFLAGS += -Wall
-LDLIBS += -lpthread -L../../../../lib -lltp
+#
+#    kernel/sched/pthreads testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+LDLIBS			+= -lpthread
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/sched_stress/Makefile b/testcases/kernel/sched/sched_stress/Makefile
index 7273922..9986265 100644
--- a/testcases/kernel/sched/sched_stress/Makefile
+++ b/testcases/kernel/sched/sched_stress/Makefile
@@ -1,19 +1,41 @@
-CFLAGS += -Wall
+#
+#    kernel/sched/sched_stress testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *_tc*.c)
-TARGETS=sched_driver sched_tc0 sched_tc1 sched_tc2 sched_tc3 sched_tc4 sched_tc5 sched_tc6 
+top_srcdir		?= ../../../..
 
-all: $(TARGETS) sched_datafile
+include $(top_srcdir)/include/mk/testcases.mk
+
+INSTALL_TARGETS		:= sched_stress.sh
+
+LDLIBS			+= -lpthread
+
+MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%,$(filter-out %sched.c,$(wildcard $(abs_srcdir)/*.c))) \
+			   sched_datafile
+
+RM			+= -r
+
+$(filter-out sched_datafile,$(MAKE_TARGETS)): %: %.o sched.o
 
 sched_datafile:
-	../../../../tools/make-file.sh sched_datafile 1200010
+	"$(top_srcdir)/tools/make-file.sh" "$@" 1200010
 
-sched.o: sched.h sched.c
-
-$(TARGETS): sched.o
-
-install:
-	@set -e; for i in $(TARGETS) sched_datafile ; do ln -f $$i ../../../bin/$$i ; done ;
-	ln -f sched_stress.sh ../../../bin/sched_stress.sh
-clean:
-	rm -f $(TARGETS) sched.o sched_datafile
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/sched/tool/Makefile b/testcases/kernel/sched/tool/Makefile
index 46c3e99..76936ba 100644
--- a/testcases/kernel/sched/tool/Makefile
+++ b/testcases/kernel/sched/tool/Makefile
@@ -1,13 +1,29 @@
-CFLAGS += -Wall -O -g
-LDLIBS := -lpthread
+#
+#    kernel/sched/tool testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+LDLIBS			+= -lpthread
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/Makefile b/testcases/kernel/security/Makefile
index 3a26b22..6a85eb2 100644
--- a/testcases/kernel/security/Makefile
+++ b/testcases/kernel/security/Makefile
@@ -1,12 +1,40 @@
-SUBDIRS = mmc_security filecaps integrity cap_bound p9auth
+#
+#    kernel/security test suite Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include	$(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+# For broken compilers and toolchains, like Montavista, that improperly detect
+# system headers when running autoconf -_-... bleh.
+ifeq ($(strip $(CAP_LIBS)),)
+FILTER_OUT_DIRS		:= cap_bound filecaps
+endif
 
+# selinux-testsuite doesn't compile cleanly, so let the user manually compile
+# the testcases for it.
+FILTER_OUT_DIRS		+= selinux-testsuite
 
+OPT_CFLAGS		+= -O
+DEBUG_LDFLAGS		+= -s
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/security/cap_bound/Makefile b/testcases/kernel/security/cap_bound/Makefile
index 5d0ae8b..65f813b 100644
--- a/testcases/kernel/security/cap_bound/Makefile
+++ b/testcases/kernel/security/cap_bound/Makefile
@@ -18,41 +18,12 @@
 ##                                                                            ##
 ################################################################################
 
-HAVE_LIBCAP := $(shell sh check_for_libcap.sh yesno)
+top_srcdir		?= ../../../..
 
-SCRIPTS = run_capbounds.sh
-TARGETS = checkforlibcap
+include $(top_srcdir)/include/mk/testcases.mk
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -lcap
+INSTALL_TARGETS		:= run_capbounds.sh
 
-ifeq ($(HAVE_LIBCAP),yes)
-SRCS    = $(wildcard *.c)
-TARGETS+= $(patsubst %.c,%,$(SRCS))
-endif
+LDLIBS			+= $(CAP_LIBS)
 
-all: $(TARGETS)
-
-ifeq ($(HAVE_LIBCAP),yes)
-checkforlibcap:
-	echo "#!/bin/sh" > $@
-	echo true >> $@
-	chmod a+rx $@
-else
-	@echo "libcap is not installed.  Please install libcap from"; \
-	echo "ftp://ftp.kernel.org/pub/linux/libs/security/linux-privs/libcap2."; \
-	echo "You must use libcap-2.11 or newer."; \
-	echo "Then make clean in ltp or ltp/testcases/kernel/security/filecaps, and recompile ltp."
-checkforlibcap:
-	echo "#!/bin/sh" > $@
-	echo false >> $@
-	chmod a+rx $@
-endif
-
-
-INSTALLTARGETS = $(TARGETS) $(SCRIPTS) checkforlibcap
-install: $(INSTALLTARGETS)
-	@set -e; for i in $(INSTALLTARGETS); do ln -f $$i ../../../bin/$$i ; chmod +x ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *.o checkforlibcap
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/cap_bound/cap_bounds_r.c b/testcases/kernel/security/cap_bound/cap_bounds_r.c
index 09cd590..917d889 100644
--- a/testcases/kernel/security/cap_bound/cap_bounds_r.c
+++ b/testcases/kernel/security/cap_bound/cap_bounds_r.c
@@ -25,7 +25,10 @@
  */
 
 #include <errno.h>
+#include "config.h"
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
 #include <sys/prctl.h>
 #include <test.h>
 
@@ -51,6 +54,7 @@
 
 int main(int argc, char *argv[])
 {
+#if HAVE_SYS_CAPABILITY_H
 	int ret = 1;
 	int i;
 
@@ -82,5 +86,8 @@
 		tst_exit();
 	}
 	tst_resm(TPASS, "CAP_BSET_READ tests passed\n");
+#else
+	tst_resm(TCONF, "System doesn't have POSIX capabilities.");
+#endif
 	tst_exit();
 }
diff --git a/testcases/kernel/security/cap_bound/cap_bounds_rw.c b/testcases/kernel/security/cap_bound/cap_bounds_rw.c
index 164175d..9129c4e 100644
--- a/testcases/kernel/security/cap_bound/cap_bounds_rw.c
+++ b/testcases/kernel/security/cap_bound/cap_bounds_rw.c
@@ -24,7 +24,10 @@
  */
 
 #include <errno.h>
+#include "config.h"
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
 #include <sys/prctl.h>
 #include <test.h>
 
diff --git a/testcases/kernel/security/cap_bound/cap_bset_inh_bounds.c b/testcases/kernel/security/cap_bound/cap_bset_inh_bounds.c
index 6b7eddf..894e0a5 100644
--- a/testcases/kernel/security/cap_bound/cap_bset_inh_bounds.c
+++ b/testcases/kernel/security/cap_bound/cap_bset_inh_bounds.c
@@ -27,25 +27,13 @@
  */
 
 #include <errno.h>
+#include "config.h"
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
 #include <sys/prctl.h>
 #include <test.h>
 
-#ifndef CAP_LAST_CAP
-#warning out-of-date capability.h does not define CAP_LAST_CAP
-#define CAP_LAST_CAP 28  /* be ultra-conservative */
-#endif
-
-#ifndef CAP_BSET_READ
-#warning CAP_BSET_READ not defined
-#define CAP_BSET_READ 23
-#endif
-
-#ifndef CAP_BSET_DROP
-#warning CAP_BSET_DROP not defined
-#define CAP_BSET_DROP 24
-#endif
-
 char *TCID = "cap_bounds_r";
 int TST_TOTAL=2;
 
@@ -53,6 +41,7 @@
 
 int main(int argc, char *argv[])
 {
+#if HAVE_SYS_CAPABILITY_H
 	int ret = 1;
 	cap_value_t v[1];
 	cap_flag_value_t f;
@@ -60,7 +49,12 @@
 
 	/* We pick a random capability... let's use CAP_SYS_ADMIN */
 	/* make sure we have the capability now */
+#if HAVE_DECL_CAP_BSET_READ
 	ret = prctl(CAP_BSET_READ, CAP_SYS_ADMIN);
+#else
+	errno = ENOSYS;
+	ret = -1;
+#endif
 	if (ret != 1) {
 		tst_resm(TBROK, "Not starting with CAP_SYS_ADMIN\n");
 		tst_exit();
@@ -72,23 +66,47 @@
 		tst_resm(TBROK, "Failed to create cap_sys_admin+i cap_t (errno %d)\n", errno);
 		tst_exit();
 	}
+#if HAVE_DECL_CAP_SET_PROC
 	ret = cap_set_proc(cur);
+#else
+	errno = ENOSYS;
+	ret = -1;
+#endif
 	if (ret) {
 		tst_resm(TBROK, "Failed to cap_set_proc with cap_sys_admin+i (ret %d errno %d)\n",
 			ret, errno);
 		tst_exit();
 	}
+#if HAVE_DECL_CAP_FREE
 	cap_free(cur);
+#endif
+#if HAVE_DECL_CAP_GET_FLAG
+#if HAVE_DECL_CAP_GET_PROC
 	cur = cap_get_proc();
 	ret = cap_get_flag(cur, CAP_SYS_ADMIN, CAP_INHERITABLE, &f);
+#else
+	errno = ENOSYS;
+	ret = -1;
+#endif
+#else
+	errno = ENOSYS;
+	ret = -1;
+#endif
 	if (ret || f != CAP_SET) {
 		tst_resm(TBROK, "Failed to add CAP_SYS_ADMIN to pI\n");
 		tst_exit();
 	}
+#if HAVE_DECL_CAP_FREE
 	cap_free(cur);
+#endif
 
 	/* drop the capability from bounding set */
+#if HAVE_DECL_CAP_BSET_DROP
 	ret = prctl(CAP_BSET_DROP, CAP_SYS_ADMIN);
+#else
+	errno = ENOSYS;
+	ret = -1;
+#endif
 	if (ret) {
 		tst_resm(TFAIL, "Failed to drop CAP_SYS_ADMIN from bounding set.\n");
 		tst_resm(TINFO, "(ret=%d, errno %d)\n", ret, errno);
@@ -96,8 +114,18 @@
 	}
 
 	/* test 1: is CAP_SYS_ADMIN still in pI? */
+#if HAVE_DECL_CAP_GET_FLAG
+#if HAVE_DECL_CAP_GET_PROC
 	cur = cap_get_proc();
 	ret = cap_get_flag(cur, CAP_SYS_ADMIN, CAP_INHERITABLE, &f);
+#else
+	errno = ENOSYS;
+	ret = -1;
+#endif
+#else
+	errno = ENOSYS;
+	ret = -1;
+#endif
 	if (ret || f != CAP_SET) {
 		tst_resm(TFAIL, "CAP_SYS_ADMIN not in pI after dropping from bounding set\n");
 		tst_exit();
@@ -116,16 +144,24 @@
 		tst_resm(TFAIL, "Failed to drop CAP_SYS_ADMIN from pI\n");
 		tst_exit();
 	}
+#if HAVE_DECL_CAP_FREE
 	cap_free(tmpcap);
-
+#endif
 	/* test 2: can we put it back in pI? */
+#if HAVE_DECL_CAP_SET_PROC
 	ret = cap_set_proc(cur);
+#endif
 	if (ret == 0) { /* success means pI was not bounded by X */
 		tst_resm(TFAIL, "Managed to put CAP_SYS_ADMIN back into pI though not in X\n");
 		tst_exit();
 	}
+#if HAVE_DECL_CAP_FREE
 	cap_free(cur);
+#endif
 
 	tst_resm(TPASS, "Couldn't put CAP_SYS_ADMIN back into pI when not in bounding set\n");
+#else
+	tst_resm(TCONF, "System doesn't have POSIX capabilities.");
+#endif
 	tst_exit();
 }
diff --git a/testcases/kernel/security/cap_bound/check_pe.c b/testcases/kernel/security/cap_bound/check_pe.c
index 060d58d..2e0451a 100644
--- a/testcases/kernel/security/cap_bound/check_pe.c
+++ b/testcases/kernel/security/cap_bound/check_pe.c
@@ -28,7 +28,10 @@
  */
 
 #include <errno.h>
+#include "config.h"
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
 #include <sys/prctl.h>
 #include <test.h>
 
@@ -39,6 +42,7 @@
 
 int main(int argc, char *argv[])
 {
+#if HAVE_SYS_CAPABILITY_H
 	int ret = 1;
 	cap_flag_value_t f;
 	cap_t cur;
@@ -54,14 +58,26 @@
 		tst_exit();
 	}
 
+#if HAVE_DECL_CAP_GET_FLAG
+#if HAVE_DECL_CAP_GET_PROC
 	cur = cap_get_proc();
 	ret = cap_get_flag(cur, CAP_SYS_ADMIN, CAP_EFFECTIVE, &f);
+#else
+	ret = -1;
+	errno = ENOSYS;
+#endif
+#else
+	ret = -1;
+	errno = ENOSYS;
+#endif
 	if (ret) {
 		tst_resm(TBROK, "cap_get_flag failed (errno %d)\n", errno);
 		tst_exit();
 	}
-	
+
+#if HAVE_DECL_CAP_FREE
 	cap_free(cur);
+#endif
 	if (n == 1) {
 		if (f == CAP_SET) {
 			tst_resm(TPASS, "cap is in pE\n");
@@ -75,6 +91,8 @@
 		tst_exit();
 	}
 	tst_resm(TFAIL, "Cap is in pE\n");
+#else
+	tst_resm(TCONF, "System doesn't have POSIX capabilities.");
+#endif
 	tst_exit();
-
 }
diff --git a/testcases/kernel/security/cap_bound/dummy.c b/testcases/kernel/security/cap_bound/dummy.c
index cfb8a4d..ad65007 100644
--- a/testcases/kernel/security/cap_bound/dummy.c
+++ b/testcases/kernel/security/cap_bound/dummy.c
@@ -1,9 +1,35 @@
+#include <stdio.h>
+#include "config.h"
+
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
+
+#define END \
+	printf("System doesn't support POSIX capabilities.\n"); \
+	return 1
 
 int main()
 {
+#if HAVE_SYS_CAPABILITY_H
 	cap_t cur;
+#if HAVE_DECL_CAP_SET_PROC
+#if HAVE_DECL_CAP_FROM_TEXT
 	cur = cap_from_text("all=eip");
 	cap_set_proc(cur);
+#else
+	END;
+#endif
+#else
+	END;
+#endif
+#if HAVE_DECL_CAP_FREE
 	cap_free(cur);
+#else
+	END;
+#endif
+#else
+	END;
+#endif
+	return 0;
 }
diff --git a/testcases/kernel/security/cap_bound/exec_with_inh.c b/testcases/kernel/security/cap_bound/exec_with_inh.c
index a415cfa..21c60fd 100644
--- a/testcases/kernel/security/cap_bound/exec_with_inh.c
+++ b/testcases/kernel/security/cap_bound/exec_with_inh.c
@@ -27,25 +27,13 @@
  */
 
 #include <errno.h>
+#include "config.h"
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
 #include <sys/prctl.h>
 #include <test.h>
 
-#ifndef CAP_LAST_CAP
-#warning out-of-date capability.h does not define CAP_LAST_CAP
-#define CAP_LAST_CAP 28  /* be ultra-conservative */
-#endif
-
-#ifndef CAP_BSET_READ
-#warning CAP_BSET_READ not defined
-#define CAP_BSET_READ 23
-#endif
-
-#ifndef CAP_BSET_DROP
-#warning CAP_BSET_DROP not defined
-#define CAP_BSET_DROP 24
-#endif
-
 char *TCID = "exec_with_inh";
 int TST_TOTAL=1;
 
@@ -53,33 +41,60 @@
 
 int main(int argc, char *argv[])
 {
+#if HAVE_SYS_CAPABILITY_H
 	int ret = 1;
 	cap_flag_value_t f;
-	cap_t cur;
+	cap_t cur = 0;
 
 	/* Make sure CAP_SYS_ADMIN is in pI */
+#if HAVE_DECL_CAP_FROM_TEXT
 	cur = cap_from_text("all=eip");
+#endif
 	if (!cur) {
 		tst_resm(TBROK, "Failed to create cap_sys_admin+i cap_t (errno %d)\n", errno);
 		tst_exit();
 	}
+#if HAVE_DECL_CAP_SET_PROC
 	ret = cap_set_proc(cur);
+#else
+	ret = -1;
+	errno = ENOSYS;
+#endif
 	if (ret) {
 		tst_resm(TBROK, "Failed to cap_set_proc with cap_sys_admin+i (ret %d errno %d)\n",
 			ret, errno);
 		tst_exit();
 	}
+#if HAVE_DECL_CAP_FREE
 	cap_free(cur);
+#endif
+#if HAVE_DECL_CAP_GET_FLAG
+#if HAVE_DECL_CAP_GET_PROC
 	cur = cap_get_proc();
 	ret = cap_get_flag(cur, CAP_SYS_ADMIN, CAP_INHERITABLE, &f);
+#else
+	ret = -1;
+	errno = ENOSYS;
+#endif
+#else
+	ret = -1;
+	errno = ENOSYS;
+#endif
 	if (ret || f != CAP_SET) {
 		tst_resm(TBROK, "Failed to add CAP_SYS_ADMIN to pI\n");
 		tst_exit();
 	}
+#if HAVE_DECL_CAP_FREE
 	cap_free(cur);
+#endif
 
 	/* drop the capability from bounding set */
+#if HAVE_DECL_CAP_BSET_DROP
 	ret = prctl(CAP_BSET_DROP, CAP_SYS_ADMIN);
+#else
+	errno = ENOSYS;
+	ret = -1;
+#endif
 	if (ret) {
 		tst_resm(TFAIL, "Failed to drop CAP_SYS_ADMIN from bounding set.\n");
 		tst_resm(TINFO, "(ret=%d, errno %d)\n", ret, errno);
@@ -89,5 +104,8 @@
 	/* execute "check_pe 1" */
 	execl("check_pe", "check_pe", "1", NULL);
 	tst_resm(TBROK, "Failed to execute check_pe (errno %d)\n", errno);
+#else
+	tst_resm(TCONF, "System doesn't have POSIX capabilities.");
+#endif
 	tst_exit();
 }
diff --git a/testcases/kernel/security/cap_bound/exec_without_inh.c b/testcases/kernel/security/cap_bound/exec_without_inh.c
index b1a01af..f28cb7f 100644
--- a/testcases/kernel/security/cap_bound/exec_without_inh.c
+++ b/testcases/kernel/security/cap_bound/exec_without_inh.c
@@ -27,25 +27,13 @@
  */
 
 #include <errno.h>
+#include "config.h"
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
 #include <sys/prctl.h>
 #include <test.h>
 
-#ifndef CAP_LAST_CAP
-#warning out-of-date capability.h does not define CAP_LAST_CAP
-#define CAP_LAST_CAP 28  /* be ultra-conservative */
-#endif
-
-#ifndef CAP_BSET_READ
-#warning CAP_BSET_READ not defined
-#define CAP_BSET_READ 23
-#endif
-
-#ifndef CAP_BSET_DROP
-#warning CAP_BSET_DROP not defined
-#define CAP_BSET_DROP 24
-#endif
-
 char *TCID = "exec_without_inh";
 int TST_TOTAL=1;
 
@@ -53,28 +41,56 @@
 
 int main(int argc, char *argv[])
 {
+#if HAVE_SYS_CAPABILITY_H
 	int ret = 1;
 	cap_flag_value_t f;
 	cap_value_t v[1];
 	cap_t cur;
 
 	/* Make sure CAP_SYS_ADMIN is not in pI */
+#if HAVE_DECL_CAP_GET_FLAG
+#if HAVE_DECL_CAP_GET_PROC
 	cur = cap_get_proc();
 	ret = cap_get_flag(cur, CAP_SYS_ADMIN, CAP_INHERITABLE, &f);
+#else
+	ret = -1;
+	errno = ENOSYS;
+#endif
+#else
+	ret = -1;
+	errno = ENOSYS;
+#endif
 	if (f == CAP_SET) {
 		v[0] = CAP_SYS_ADMIN;
+#if HAVE_DECL_CAP_SET_FLAG
 		ret = cap_set_flag(cur, CAP_INHERITABLE, 1, v, CAP_CLEAR);
+#else
+		ret = -1;
+		errno = ENOSYS;
+#endif
+#if HAVE_DECL_CAP_SET_PROC
 		if (!ret)
 			ret = cap_set_proc(cur);
+#else
+		ret = -1;
+		errno = ENOSYS;
+#endif
 		if (ret) {
 			tst_resm(TBROK, "Failed to drop cap_sys_admin from pI\n");
 			tst_exit();
 		}
 	}
+#if HAVE_DECL_CAP_FREE
 	cap_free(cur);
+#endif
 
 	/* drop the capability from bounding set */
+#if HAVE_DECL_CAP_BSET_DROP
 	ret = prctl(CAP_BSET_DROP, CAP_SYS_ADMIN);
+#else
+	errno = ENOSYS;
+	ret = -1;
+#endif
 	if (ret) {
 		tst_resm(TFAIL, "Failed to drop CAP_SYS_ADMIN from bounding set.\n");
 		tst_resm(TINFO, "(ret=%d, errno %d)\n", ret, errno);
@@ -84,5 +100,8 @@
 	/* execute "check_pe 0" */
 	execl("check_pe", "check_pe", "0", NULL);
 	tst_resm(TBROK, "Failed to execute check_pe (errno %d)\n", errno);
+#else
+	tst_resm(TCONF, "System doesn't have POSIX capabilities.");
+#endif
 	tst_exit();
 }
diff --git a/testcases/kernel/security/filecaps/Makefile b/testcases/kernel/security/filecaps/Makefile
index ab8a0e6..acad441 100644
--- a/testcases/kernel/security/filecaps/Makefile
+++ b/testcases/kernel/security/filecaps/Makefile
@@ -18,45 +18,14 @@
 ##                                                                            ##
 ################################################################################
 
-HAVE_LIBCAP := $(shell sh checkforlibcap.sh yesno)
+top_srcdir		?= ../../../..
 
-SCRIPTS = filecapstest.sh checkforlibcap.sh checkforfilecaps.sh
-TARGETS = checkforlibcap
+include $(top_srcdir)/include/mk/testcases.mk
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -lcap
+INSTALL_TARGETS		:= filecapstest.sh
 
-ifeq ($(HAVE_LIBCAP),yes)
-SRCS    = $(wildcard *.c)
-TARGETS+= $(patsubst %.c,%,$(SRCS))
-endif
+CPPFLAGS		+= -D_GNU_SOURCE
+DEBUG_CPPFLAGS		+= -DDEBUG=1
+LDLIBS			+= $(CAP_LIBS)
 
-all: $(TARGETS)
-ifeq ($(HAVE_LIBCAP),yes)
-checkforlibcap:
-	echo "#!/bin/sh" > $@
-	echo true >> $@
-	chmod a+rx $@
-else
-	@echo "setcap or xattr headers not installed.  Please install libcap from"; \
-	echo "ftp://ftp.kernel.org/pub/linux/libs/security/linux-privs/libcap2."; \
-	echo "You must use libcap-2.11 or newer."; \
-	echo "Then make clean in ltp or ltp/testcases/kernel/security/filecaps, and recompile ltp."
-checkforlibcap:
-	echo "#!/bin/sh" > $@
-	echo false >> $@
-	chmod a+rx $@
-endif
-
-numcaps.h: makenumcapsh.c
-	$(CC) -o makenumcapsh makenumcapsh.c
-	./makenumcapsh > numcaps.h
-
-verify_caps_exec: verify_caps_exec.c numcaps.h
-
-INSTALLTARGETS = $(TARGETS) $(SCRIPTS) checkforlibcap
-install: $(INSTALLTARGETS)
-	@set -e; for i in $(INSTALLTARGETS); do ln -f $$i ../../../bin/$$i ; chmod +x ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *.o caps_fifo checkforlibcap numcaps.h makenumcapsh
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/filecaps/check_simple_capset.c b/testcases/kernel/security/filecaps/check_simple_capset.c
index 74f7b1a..7851e01 100644
--- a/testcases/kernel/security/filecaps/check_simple_capset.c
+++ b/testcases/kernel/security/filecaps/check_simple_capset.c
@@ -20,20 +20,35 @@
 
 
 #include <stdio.h>
+#include "config.h"
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
 
 int main()
 {
+#if HAVE_SYS_CAPABILITY_H
 	cap_t caps, caps2;
 	int ret;
 
+#if HAVE_DECL_CAP_FROM_TEXT && HAVE_DECL_CAP_SET_PROC && HAVE_DECL_CAP_COMPARE
 	caps = cap_from_text("cap_setpcap+ep");
 	caps2 = cap_from_text("cap_setpcap+ep");
 	ret = cap_set_proc(caps);
 	ret = cap_compare(caps, caps2);
-	printf("Caps were %s the same\n", ret ? "not" : "");
+#else
+	printf("System doesn't support full POSIX capabilities.\n");
+	return 1;
+#endif
+	printf("Caps were %sthe same\n", ret ? "not " : "");
 
+#if HAVE_DECL_CAP_FREE
 	cap_free(caps);
 	cap_free(caps2);
+#endif
 	return ret;
+#else
+	printf("System doesn't support POSIX capabilities.\n");
+	return 1;
+#endif
 }
diff --git a/testcases/kernel/security/filecaps/check_xattr.c b/testcases/kernel/security/filecaps/check_xattr.c
deleted file mode 100644
index 96ebc66..0000000
--- a/testcases/kernel/security/filecaps/check_xattr.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stdio.h>
-#include <sys/capability.h>
-#include <attr/xattr.h>
-
-int main()
-{
-       printf("Hello, world\n");
-       return 0;
-}
diff --git a/testcases/kernel/security/filecaps/checkforfilecaps.sh b/testcases/kernel/security/filecaps/checkforfilecaps.sh
index 20f97f5..757d409 100755
--- a/testcases/kernel/security/filecaps/checkforfilecaps.sh
+++ b/testcases/kernel/security/filecaps/checkforfilecaps.sh
@@ -19,9 +19,7 @@
 ##                                                                            ##
 ################################################################################
 
-check_simple_capset
-ret=$?
-if [ $ret -ne 0 ]; then
+if ! check_simple_capset; then
 	echo Posix capabilities not compiled into the kernel.  Please
 	echo modprobe capability or recompile your kernel with
 	echo CONFIG_SECURITY_CAPABILITIES=y.
diff --git a/testcases/kernel/security/filecaps/inh_capped.c b/testcases/kernel/security/filecaps/inh_capped.c
index ec6c299..513fcb9 100644
--- a/testcases/kernel/security/filecaps/inh_capped.c
+++ b/testcases/kernel/security/filecaps/inh_capped.c
@@ -24,28 +24,31 @@
  * Uses no command line arguments.
  */
 
-#define _GNU_SOURCE
 #include <stdio.h>
+#include "config.h"
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
 #include <test.h>
 
 char *TCID = "filecaps";
 int TST_TOTAL=1;
 
-#define DEBUG 1
-
 void debug_print_caps(char *when)
 {
 #ifdef DEBUG
 	char buf[2000];
 	tst_resm(TINFO, "%s", when);
+#if HAVE_DECL_SET_CAP_TO_TEXT
 	snprintf(buf, 2000, "%s", cap_to_text(cap_get_proc(), NULL));
+#endif
 	tst_resm(TINFO, "%s", buf);
 #endif
 }
 
 int set_caps_from_text(char *capstr)
 {
+#if HAVE_SYS_CAPABILITY_H && HAVE_DECL_SET_CAP_SET_PROC && HAVE_DECL_SET_CAP_FREE
 	cap_t caps = cap_from_text(capstr);
 	int ret;
 
@@ -56,10 +59,14 @@
 	ret = cap_set_proc(caps);
 	cap_free(caps);
 	return ret;
+#else
+	return -1;
+#endif
 }
 
 int main()
 {
+#if HAVE_SYS_CAPABILITY_H && HAVE_DECL_SET_CAPS_FROM_TEXT
 	int ret;
 
 	debug_print_caps("start");
@@ -109,5 +116,8 @@
 
 	tst_resm(TFAIL, "succeeded raising capsysadmin in pI "
 			"without having setpcap");
+#else
+	tst_resm(TCONF, "System doesn't have POSIX capabilities support.");
+#endif
 	tst_exit();
 }
diff --git a/testcases/kernel/security/filecaps/makenumcapsh.c b/testcases/kernel/security/filecaps/makenumcapsh.c
deleted file mode 100644
index 6676176..0000000
--- a/testcases/kernel/security/filecaps/makenumcapsh.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-#include <sys/capability.h>
-#include <sys/prctl.h>
-
-#ifndef PR_CAPBSET_READ
-#define PR_CAPBSET_READ 23
-#endif
-
-int main(int argc, char *argv[])
-{
-	int i, ret = 0;
-
-	for (i=0; ret != -1; i++) {
-		ret = prctl(PR_CAPBSET_READ, i);
-		if (ret == -1)
-			break;
-	}
-	printf("#define NUM_CAPS %d\n", i);
-	return 0;
-}
diff --git a/testcases/kernel/security/filecaps/print_caps.c b/testcases/kernel/security/filecaps/print_caps.c
index 9bfbcd6..188856e 100644
--- a/testcases/kernel/security/filecaps/print_caps.c
+++ b/testcases/kernel/security/filecaps/print_caps.c
@@ -26,16 +26,21 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/capability.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include "config.h"
+
+#if HAVE_SYS_CAPABILITY_H
+#include <sys/capability.h>
+#endif
 
 #define FIFOFILE "caps_fifo"
 
 int main(int argc, char *argv[])
 {
+#if HAVE_SYS_CAPABILITY_H && HAVE_DECL_CAP_FREE && HAVE_DECL_CAP_GET_PROC && HAVE_DECL_CAP_TO_TEXT
 	cap_t cap = cap_get_proc();
 	int fd;
 	int seqno = 0;
@@ -60,6 +65,7 @@
 	close(fd);
 
 	cap_free(cap);
-
+#else
 	return 0;
+#endif
 }
diff --git a/testcases/kernel/security/filecaps/verify_caps_exec.c b/testcases/kernel/security/filecaps/verify_caps_exec.c
index 397c844..16fcc0f 100644
--- a/testcases/kernel/security/filecaps/verify_caps_exec.c
+++ b/testcases/kernel/security/filecaps/verify_caps_exec.c
@@ -27,7 +27,6 @@
  *     make sure we get the rights
  */
 
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <unistd.h>
 #include <endian.h>
@@ -37,12 +36,13 @@
 #include <sys/wait.h>
 #include <errno.h>
 #include <fcntl.h>
+#include "config.h"
+#if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
+#endif
 #include <sys/prctl.h>
 #include <test.h>
 
-#include "numcaps.h"
-
 #define TSTPATH "./print_caps"
 char *TCID = "filecaps";
 int TST_TOTAL=1;
@@ -62,15 +62,18 @@
 
 void print_my_caps()
 {
+#if HAVE_SYS_CAPABILITY_H && HAVE_DECL_CAP_FREE && HAVE_DECL_CAP_GET_PROC && HAVE_DECL_CAP_TO_TEXT
 	cap_t cap = cap_get_proc();
 	char *txt = cap_to_text(cap, NULL);
 	tst_resm(TINFO, "\ncaps are %s\n", txt);
 	cap_free(cap);
 	cap_free(txt);
+#endif
 }
 
 int drop_root(int keep_perms)
 {
+#if HAVE_SYS_CAPABILITY_H && HAVE_DECL_CAP_FREE && HAVE_DECL_CAP_FROM_TEXT && HAVE_DECL_CAP_SET_PROC
 	int ret;
 
 	if (keep_perms)
@@ -86,12 +89,15 @@
 		cap_set_proc(cap);
 		cap_free(cap);
 	}
-
-	return 1;
+#else
+	tst_resm(TCONF, "System doesn't have full POSIX capabilities support.\n");
+#endif
+	tst_exit();
 }
 
 int perms_test(void)
 {
+#if HAVE_SYS_CAPABILITY_H && HAVE_DECL_CAP_FREE && HAVE_DECL_CAP_SET_FILE
 	int ret;
 	cap_t cap;
 
@@ -112,6 +118,9 @@
 
 	cap_free(cap);
 	return ret;
+#else
+	return -1;
+#endif
 }
 
 #define FIFOFILE "caps_fifo"
@@ -151,8 +160,10 @@
 	close(fd);
 }
 
+#if HAVE_SYS_CAPABILITY_H && HAVE_DECL_CAP_COMPARE && HAVE_DECL_CAP_FREE && HAVE_DECL_CAP_TO_TEXT
 int fork_drop_and_exec(int keepperms, cap_t expected_caps)
 {
+
 	int pid;
 	int ret = 0;
 	char buf[200], *p;
@@ -208,9 +219,12 @@
 	}
 	return ret;
 }
+#endif
 
 int caps_actually_set_test(void)
 {
+
+#if HAVE_SYS_CAPABILITY_H && HAVE_DECL_PR_CAPBSET_READ
 	int  whichcap, finalret = 0, ret;
 	cap_t fcap, pcap, cap_fullpi;
 	cap_value_t capvalue[1];
@@ -225,8 +239,20 @@
 
 	create_fifo();
 
+	int num_caps;
+
+	for (num_caps=0; ; num_caps++) {
+		ret = prctl(PR_CAPBSET_READ, num_caps);
+		/*
+		 * Break from the loop in this manner to avoid incrementing,
+		 * then having to decrement value.
+		 */
+		if (ret == -1)
+			break;
+	}
+
 	/* first, try each bit in fP (forced) with fE on and off. */
-	for (whichcap=0; whichcap < NUM_CAPS; whichcap++) {
+	for (whichcap=0; whichcap < num_caps; whichcap++) {
 		/*
 		 * fP=whichcap, fE=fI=0
 		 * pP'=whichcap, pI'=pE'=0
@@ -271,7 +297,7 @@
 	cap_free(pcap);
 	cap_free(fcap);
 	cap_fullpi = cap_init();
-	for (i=0; i<NUM_CAPS; i++) {
+	for (i=0; i<num_caps; i++) {
 		capvalue[0] = i;
 		cap_set_flag(cap_fullpi, CAP_INHERITABLE, 1, capvalue, CAP_SET);
 	}
@@ -293,7 +319,7 @@
 	 *     This should result in empty capability, as there were
 	 *     no bits to be inherited from the original process.
 	 */
-	for (whichcap=0; whichcap < NUM_CAPS; whichcap++) {
+	for (whichcap=0; whichcap < num_caps; whichcap++) {
 		cap_t cmpcap;
 		capvalue[0] = whichcap;
 
@@ -373,15 +399,19 @@
 	cap_free(cap_fullpi);
 
 	return finalret;
+#else
+	return -1;
+#endif
 }
 
 int main(int argc, char *argv[])
 {
-	int ret = 0;
-
 	if (argc < 2)
 		usage(argv[0]);
 
+#if HAVE_SYS_CAPABILITY_H
+	int ret = 0;
+
 	switch(atoi(argv[1])) {
 		case 0:
 			ret = perms_test();
@@ -395,6 +425,9 @@
 			break;
 		default: usage(argv[0]);
 	}
+#else
+	tst_resm(TCONF, "System doesn't have POSIX capabilities support.");
+#endif
 
 	tst_exit();
 }
diff --git a/testcases/kernel/security/integrity/Makefile b/testcases/kernel/security/integrity/Makefile
index 51f0fe9..14a97a8 100644
--- a/testcases/kernel/security/integrity/Makefile
+++ b/testcases/kernel/security/integrity/Makefile
@@ -1,11 +1,22 @@
-SUBDIRS = ima
+#
+#  Copyright (c) International Business Machines  Corp., 2001
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-
+include	$(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/security/integrity/ima/Makefile b/testcases/kernel/security/integrity/ima/Makefile
index 6f401c4..b3ec226 100644
--- a/testcases/kernel/security/integrity/ima/Makefile
+++ b/testcases/kernel/security/integrity/ima/Makefile
@@ -1,11 +1,29 @@
-SUBDIRS = src tests policy
+#
+#    kernel/security/integrity/ima testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+SUBDIRS			:= policy src tests
 
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/security/integrity/ima/policy/Makefile b/testcases/kernel/security/integrity/ima/policy/Makefile
index 294efe3..c16302d 100644
--- a/testcases/kernel/security/integrity/ima/policy/Makefile
+++ b/testcases/kernel/security/integrity/ima/policy/Makefile
@@ -1,6 +1,31 @@
-all:
-install:
-	mkdir -p ../../../../../policy; cp measure* ../../../../../policy/
+#
+#    testcases/kernel/security/integrity/ima/policy testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-clean:
+top_srcdir		?= ../../../../../..
 
+include	$(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_DIR		:= testcases/bin/policy
+
+INSTALL_TARGETS		:= measure*
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/integrity/ima/src/Makefile b/testcases/kernel/security/integrity/ima/src/Makefile
index b93fda5..7a97773 100644
--- a/testcases/kernel/security/integrity/ima/src/Makefile
+++ b/testcases/kernel/security/integrity/ima/src/Makefile
@@ -1,16 +1,29 @@
-include ../../../../../../config.mk
+#
+#    kernel/security/integrity/ima/src testcase Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-ifeq ($(CRYPTO_LIB),-lcrypto)
-	TARGETS=ima_mmap ima_measure ima_boot_aggregate
-	LDLIBS += $(CRYPTO_LIB)
-else
-	TARGETS=ima_mmap
-endif
+top_srcdir		?= ../../../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
+LDLIBS			+= $(CRYPTO_LIBS)
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c b/testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c
index 65a6b10..7c17c63 100644
--- a/testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c
+++ b/testcases/kernel/security/integrity/ima/src/ima_boot_aggregate.c
@@ -23,14 +23,21 @@
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
+#include "config.h"
+#include "test.h"
+#if HAVE_OPENSSL_SHA_H
 #include <openssl/sha.h>
+#endif
 
 #define MAX_EVENT_SIZE 500
 #define EVENT_HEADER_SIZE 32
 #define MAX_EVENT_DATA_SIZE (MAX_EVENT_SIZE - EVENT_HEADER_SIZE)
 #define NUM_PCRS 8	/*  PCR registers 0-7 in boot aggregate */
 
-static void *display_sha1_digest(char *pcr)
+char *TCID = "ima_boot_aggregate";
+int TST_TOTAL = 1;
+
+static void display_sha1_digest(unsigned char *pcr)
 {
 	int i;
 
@@ -39,8 +46,10 @@
 	printf("\n");
 }
 
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
+#if HAVE_OPENSSL_SHA_H
 	unsigned char boot_aggregate[SHA_DIGEST_LENGTH];
 	struct {
 		struct {
@@ -74,7 +83,7 @@
 		memset(&pcr[i].digest, 0, SHA_DIGEST_LENGTH);
 
 	/* Extend the pseudo PCRs with the event digest */
-	while (fread(&event, sizeof event.header, 1, fp)) {
+	while (fread(&event, sizeof(event.header), 1, fp)) {
 		if (debug) {
 			printf("%03u ", event.header.pcr);
 			display_sha1_digest(event.header.digest);
@@ -105,6 +114,8 @@
 
 	printf("boot_aggregate:");
 	display_sha1_digest(boot_aggregate);
-
-	return 0;
+#else
+	tst_resm(TCONF, "System doesn't have openssl/sha.h");
+#endif
+	tst_exit();
 }
diff --git a/testcases/kernel/security/integrity/ima/src/ima_measure.c b/testcases/kernel/security/integrity/ima/src/ima_measure.c
index 0025144..dd6b1d0 100644
--- a/testcases/kernel/security/integrity/ima/src/ima_measure.c
+++ b/testcases/kernel/security/integrity/ima/src/ima_measure.c
@@ -22,18 +22,23 @@
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
+//#include "config.h"
+#include "test.h"
+#if HAVE_OPENSSL_SHA_H
 #include <openssl/sha.h>
+#endif
 
 #define TCG_EVENT_NAME_LEN_MAX	255
 
-static int verbose = 0;
-static int validate = 0;
-static int verify = 0;
+char *TCID = "ima_measure";
+int TST_TOTAL = 1;
 
 #define print_info(format, arg...) \
 	if (verbose) \
 		printf(format, ##arg)
 
+#if HAVE_OPENSSL_SHA_H
+
 static u_int8_t zero[SHA_DIGEST_LENGTH];
 static u_int8_t fox[SHA_DIGEST_LENGTH];
 
@@ -90,6 +95,8 @@
 	return 0;
 }
 
+#endif
+
 /*
  * ima_measurements.c - calculate the SHA1 aggregate-pcr value based
  * on the IMA runtime binary measurements.
@@ -120,13 +127,19 @@
  * Return code: if verification enabled, returns number of verification
  * 		errors.
  */
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
+
+#if HAVE_OPENSSL_SHA_H
 	FILE *fp;
 	struct event template;
 	u_int8_t pcr[SHA_DIGEST_LENGTH];
 	int i, count = 0, len;
-	int failed_count = 0;	/* number of template verifications failed */
+
+	int verbose = 0;
+	int validate = 0;
+	int verify = 0;
 
 	if (argc < 2) {
 		printf("format: %s binary_runtime_measurements" \
@@ -191,12 +204,17 @@
 		print_info(" %s\n", template.ima_data.filename);
 
 		if (verify)
-			failed_count += verify_template_hash(&template);
+			if (verify_template_hash(&template) != 0) {
+				tst_resm(TFAIL, "Hash failed");
+			}
 	}
 	fclose(fp);
 
 	verbose=1;
 	print_info("PCRAggr (re-calculated):");
 	display_sha1_digest(pcr);
-	return failed_count;
+#else
+	tst_resm(TCONF, "System doesn't have openssl/sha.h");
+#endif
+	tst_exit();
 }
diff --git a/testcases/kernel/security/integrity/ima/src/ima_mmap.c b/testcases/kernel/security/integrity/ima/src/ima_mmap.c
index fb89a09..4907a34 100644
--- a/testcases/kernel/security/integrity/ima/src/ima_mmap.c
+++ b/testcases/kernel/security/integrity/ima/src/ima_mmap.c
@@ -16,16 +16,20 @@
  */
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <fcntl.h>
+#include "test.h"
+
+char *TCID = "ima_mmap";
+int TST_TOTAL = 1;
 
 int main(int argc, char *argv[])
 {
 	int fd;
 	void *file;
 	char *filename;
-	int rc;
 
 	if (argc != 2)
 		printf("%s: filename\n", argv[1]);
@@ -48,6 +52,5 @@
 		perror("unmap");
 		return(-1);
 	}
-
-	return 0;
+	tst_exit();
 }
diff --git a/testcases/kernel/security/integrity/ima/tests/Makefile b/testcases/kernel/security/integrity/ima/tests/Makefile
index f3fbc7b..18038af 100644
--- a/testcases/kernel/security/integrity/ima/tests/Makefile
+++ b/testcases/kernel/security/integrity/ima/tests/Makefile
@@ -1,6 +1,29 @@
-all:
-install:
-	chmod 755 *.sh; cp *.sh ../../../../../bin/
+#
+#    testcases/kernel/security/integrity/ima/tests testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-clean:
+top_srcdir		?= ../../../../../..
 
+include	$(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/mmc_security/Makefile b/testcases/kernel/security/mmc_security/Makefile
index 307232e..72d5fce 100644
--- a/testcases/kernel/security/mmc_security/Makefile
+++ b/testcases/kernel/security/mmc_security/Makefile
@@ -1,8 +1,29 @@
-SCRIPTS=ask_password.sh  assign_password.sh  change_password.sh  force_erase.sh  remove_password.sh
+#
+#    kernel/security/mmc_security test suite Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
- 
-install:
-	@set -e; for i in $(SCRIPTS) ; do ln -f $$i ../../../bin/$$i ; done
+top_srcdir		?= ../../../..
 
-clean:
+include	$(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/p9auth/Makefile b/testcases/kernel/security/p9auth/Makefile
index 1c03e5b..0f2251a 100644
--- a/testcases/kernel/security/p9auth/Makefile
+++ b/testcases/kernel/security/p9auth/Makefile
@@ -18,23 +18,10 @@
 ##                                                                            ##
 ################################################################################
 
-HAVE_P9AUTH := $(shell sh checkp9auth.sh yesno)
+top_srcdir		?= ../../../..
 
-SCRIPTS = runp9auth.sh checkp9auth.sh p9priv.sh p9unpriv.sh
+include	$(top_srcdir)/include/mk/testcases.mk
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -lcap
+INSTALL_TARGETS		:= *.sh
 
-ifeq ($(HAVE_P9AUTH),yes)
-SRCS    = $(wildcard *.c)
-TARGETS+= $(patsubst %.c,%,$(SRCS))
-endif
-
-all: $(TARGETS)
-
-INSTALLTARGETS = $(TARGETS) $(SCRIPTS)
-install: $(INSTALLTARGETS)
-	@set -e; for i in $(INSTALLTARGETS); do ln -f $$i ../../../bin/$$i ; chmod +x ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *.o unhex
+include	$(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/p9auth/checkp9auth.sh b/testcases/kernel/security/p9auth/checkp9auth.sh
deleted file mode 100755
index 4365427..0000000
--- a/testcases/kernel/security/p9auth/checkp9auth.sh
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/sh
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2009                 ##
-##                                                                            ##
-## This program is free software;  you can redistribute it and#or modify      ##
-## it under the terms of the GNU General Public License as published by       ##
-## the Free Software Foundation; either version 2 of the License, or          ##
-## (at your option) any later version.                                        ##
-##                                                                            ##
-## This program is distributed in the hope that it will be useful, but        ##
-## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
-## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
-## for more details.                                                          ##
-##                                                                            ##
-## You should have received a copy of the GNU General Public License          ##
-## along with this program;  if not, write to the Free Software               ##
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    ##
-##                                                                            ##
-################################################################################
-
-yesno=0
-if [ "$1" = "yesno" ]; then
-	yesno=1
-fi
-
-# check for openssl
-OPENSSL=`which openssl`
-if [ $? -ne 0 ]; then
-	if [ $yesno -eq 1 ]; then echo
-		echo "no"
-	else
-		echo "Openssl not installed.  Skipping p9auth tests."
-	fi
-	exit 1
-fi
-# and make sure openssl understands -hmac
-echo -n "501@0" > plain
-$OPENSSL sha1 -hmac ab plain > hexed
-if [ $? -ne 0 ]; then
-	if [ $yesno -eq 1 ]; then echo
-		echo "no"
-	else
-		echo "Openssl too old (no -hmac).  Skipping p9auth tests."
-	fi
-	exit 1
-fi
-
-majfile=/sys/module/p9auth/parameters/cap_major
-minfile=/sys/module/p9auth/parameters/cap_minor
-if [ ! -f "$majfile" ]; then
-	if [ $yesno -eq 1 ]; then echo
-		echo "no"
-	else
-		echo "p9auth not detected.  Skipping p9auth tests."
-	fi
-	exit 1
-fi
-
-if [ ! -c "/dev/caphash" ]; then
-	rm -f /dev/caphash
-	maj=`cat $majfile`
-	mknod /dev/caphash c $maj 0
-fi
-
-if [ ! -c "/dev/capuse" ]; then
-	rm -f /dev/capuse
-	min=`cat $minfile`
-	mknod /dev/capuse c $maj 1
-fi
-chmod ugo+w /dev/capuse
-
-if [ $yesno -eq 1 ]; then
-	echo "yes"
-else
-	echo "p9auth ready for testing"
-fi
-exit 0
diff --git a/testcases/kernel/security/selinux-testsuite/Makefile b/testcases/kernel/security/selinux-testsuite/Makefile
index 02a964e..1e715da 100644
--- a/testcases/kernel/security/selinux-testsuite/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/Makefile
@@ -1,12 +1,27 @@
-SUBDIRS = tests 
+#
+#    kernel/security/selinux-testsuite test suite Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../../..
 
-install:
-	mkdir -p ../../../bin
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include	$(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/policy/Makefile b/testcases/kernel/security/selinux-testsuite/policy/Makefile
index 3af7731..dd81e21 100644
--- a/testcases/kernel/security/selinux-testsuite/policy/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/policy/Makefile
@@ -1,18 +1,52 @@
-include /etc/selinux/config
-SELINUX_SRC=/etc/selinux/$(SELINUXTYPE)/src/policy
+#
+#    kernel/security/selinux-testsuite/policy Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, August 2009
+#
 
-# for Fedora Core 2
-# SELINUX_SRC=/etc/security/selinux/src/policy
+top_srcdir		?= ../../../../..
 
-load:
-	@if [ -d $(SELINUX_SRC) ]; then \
-		cp test_* $(SELINUX_SRC)/domains/misc/; \
-		$(MAKE) -C $(SELINUX_SRC) -W users load; \
-	else \
-		echo "ERROR: You must have selinux-policy-targeted-sources installed."; \
-	fi
+include	$(top_srcdir)/include/mk/env_pre.mk
+include $(DESTDIR)/etc/selinux/config
+
+SELINUX_SRC		?= $(DESTDIR)/etc/selinux/$(SELINUXTYPE)/src/policy
+
+# cleanup and load remain for backwards compatibility...
+.PHONY: all clean cleanup install load
+
+all: load
+
+clean: | cleanup
 
 cleanup:
-	rm -f $(SELINUX_SRC)/domains/misc/test_*
-	$(MAKE) -C $(SELINUX_SRC) -W users load
+	$(RM) -f $(SELINUX_SRC)/domains/misc/test_*
+	@if [ -d "$(SELINUX_SRC)" ]; then \
+	    $(MAKE) -C $(SELINUX_SRC) -W users load; \
+	fi
 
+install: all
+
+load:
+	@if [ -d "$(SELINUX_SRC)" ]; then \
+	    cp -p $(abs_srcdir)/test_* "$(SELINUX_SRC)/domains/misc/"; \
+	    $(MAKE) -C "$(SELINUX_SRC)" -W users $@; \
+	else \
+	    echo "ERROR: You must have selinux-policy-targeted-sources " \
+	         "installed."; \
+	fi
diff --git a/testcases/kernel/security/selinux-testsuite/refpolicy/Makefile b/testcases/kernel/security/selinux-testsuite/refpolicy/Makefile
index dec5f1f..4f9df3c 100644
--- a/testcases/kernel/security/selinux-testsuite/refpolicy/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/refpolicy/Makefile
@@ -1,41 +1,73 @@
-REDHAT_RELEASE=$(shell rpm -q redhat-release)
-REDHAT_VERS=$(shell echo $(REDHAT_RELEASE) | cut -f3 -d"-" | sed -e "s/[^0-9]*//g")
-POLICYDEVEL = /usr/share/selinux/devel
-SEMODULE = /usr/sbin/semodule
-CHECKPOLICY = /usr/bin/checkpolicy
-VERS := $(shell $(CHECKPOLICY) -V |cut -f 1 -d ' ')
+#
+#    kernel/security/selinux-testsuite/refpolicy Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, August 2009
+#
 
-TARGETS=test_global.te test_capable_file.te test_capable_net.te \
-test_capable_sys.te test_dyntrace.te test_dyntrans.te test_entrypoint.te \
-test_execshare.te test_exectrace.te test_execute_no_trans.te \
-test_fdreceive.te test_file.te test_inherit.te test_ioctl.te test_ipc.te \
-test_link.te test_mkdir.te test_open.te test_ptrace.te test_readlink.te \
-test_relabel.te test_rename.te test_rxdir.te test_setattr.te test_setnice.te \
-test_sigkill.te test_stat.te test_sysctl.te test_task_create.te \
-test_task_getpgid.te test_task_getsched.te test_task_getsid.te \
-test_task_setpgid.te test_task_setsched.te test_transition.te test_wait.te 
+top_srcdir		?= ../../../../..
 
+include	$(top_srcdir)/include/mk/env_pre.mk
 
-ifeq ($(VERS),24)
-TARGETS+= test_bounds.te
+REDHAT_RELEASE		?= $(shell rpm -q redhat-release)
+REDHAT_VERS		?= $(shell echo $(REDHAT_RELEASE) | cut -f3 -d- | sed -e "s/[^0-9]*//g")
+POLICYDEVEL		?= $(DESTDIR)/usr/share/selinux/devel
+SEMODULE		?= $(DESTDIR)/usr/sbin/semodule
+CHECKPOLICY		?= $(DESTDIR)/usr/bin/checkpolicy
+CHECKPOLICY_VERS	?= $(shell $(CHECKPOLICY) -V |cut -f 1 -d ' ')
+
+CLEAN_TARGETS		:= test_policy.te
+
+INSTALL_TARGETS		:= *.te
+
+ifeq ($(CHECKPOLICY_VERS),24)
+TARGETS			:= $(filter-out %/test_bounds.te,$(INSTALL_TARGETS))
 endif
 
-load:
+TE_SRCDIR		:= $(abs_srcdir)
+
 ifeq (redhat-release-, $(findstring redhat-release-, $(REDHAT_RELEASE)))
-	$(MAKE) -C redhat/$(REDHAT_VERS)
-else
-	@if [ -d $(POLICYDEVEL) ]; then \
-		set -e; rm -f test_policy.te; for i in $(TARGETS); do cat $$i >> test_policy.te; done; \
-		cp test_policy.* $(POLICYDEVEL); \
-		$(MAKE) -C $(POLICYDEVEL) clean test_policy.pp; \
-		$(SEMODULE) -i $(POLICYDEVEL)/test_policy.pp; \
-	else \
-		echo "ERROR: You must have selinux-policy-devel installed."; \
-	fi
+ifneq ($(wildcard $(abs_srcdir)/redhat/$(REDHAT_VER)),)
+TE_SRCDIR		:= $(abs_srcdir)/redhat/$(REDHAT_VER)
 endif
-	
-cleanup:
-	$(SEMODULE) -r test_policy
-	rm -f $(POLICYDEVEL)/test_policy.* 
-	rm -f test_policy.te 
+endif
 
+.PHONY: all clean cleanup install load
+
+all: load
+
+clean: cleanup
+
+cleanup:
+	-$(SEMODULE) -r test_policy
+	$(RM) -f $(POLICYDEVEL)/test_policy.* $(builddir)/test_policy.te 
+
+install: all
+
+# load remains for backwards compatibility...
+load: $(builddir)/test_policy.te
+	@if [ -d "$(POLICYDEVEL)" ]; then \
+	    cp -p $(builddir)/test_policy.* $(INSTALL_TARGETS) $(POLICY_DEVEL); \
+	    $(MAKE) -C $(POLICYDEVEL) clean test_policy.pp; \
+	    $(SEMODULE) -i $(POLICYDEVEL)/test_policy.pp; \
+	else \
+            echo "ERROR: You must have selinux-policy-devel installed."; \
+	fi
+
+$(builddir)/test_policy.te:
+	(cd "$(TE_SRCDIR)" && cat $(INSTALL_TARGETS)) > "$@";
diff --git a/testcases/kernel/security/selinux-testsuite/tests/Makefile b/testcases/kernel/security/selinux-testsuite/tests/Makefile
index 775ae4f..fe9ace7 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/Makefile
@@ -1,29 +1,34 @@
-REDHAT_RELEASE=$(shell rpm -q redhat-release)
+#
+#    kernel/security/selinux-testsuite/tests Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, August 2009
+#
 
-SUBDIRS=domain_trans entrypoint execshare exectrace execute_no_trans fdreceive inherit link mkdir msg open ptrace readlink relabel rename rxdir sem setattr setnice shm sigkill stat sysctl task_create task_setnice task_setscheduler task_getscheduler task_getsid task_getpgid task_setpgid wait file ioctl capable_file capable_net capable_sys dyntrace dyntrans bounds
+top_srcdir		?= ../../../../..
 
-ifeq (redhat-release-4, $(findstring redhat-release-4, $(REDHAT_RELEASE)))
-    SUBDIRS=domain_trans entrypoint execshare exectrace execute_no_trans fdreceive inherit link mkdir msg open ptrace readlink relabel rename rxdir sem setattr setnice shm sigkill stat sysctl task_create task_setnice task_setscheduler task_getscheduler task_getsid task_getpgid task_setpgid wait file ioctl capable_file capable_net capable_sys
-endif
+include	$(top_srcdir)/include/mk/env_pre.mk
 
-ifeq (redhat-release-5, $(findstring redhat-release-5, $(REDHAT_RELEASE)))
-    SUBDIRS=domain_trans entrypoint execshare exectrace execute_no_trans fdreceive inherit link mkdir msg open ptrace readlink relabel rename rxdir sem setattr setnice shm sigkill stat sysctl task_create task_setnice task_setscheduler task_getscheduler task_getsid task_getpgid task_setpgid wait file ioctl capable_file capable_net capable_sys dyntrace dyntrans
-endif
+RECURSIVE_TARGETS	:= install
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
 
 all: 
 	@set -e; for i in $(SUBDIRS); do \
-		$(MAKE) -C $$i  all; \
-	chcon -R -t test_file_t . ; \
+	    $(MAKE) -C $$i $@; \
 	done
-
-install: all
-	mkdir -p ../../../../bin ; 
-	@set -e; for i in $(SUBDIRS); do \
-		$(MAKE) -C $$i  install; \
-	done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do \
-		$(MAKE) -C $$i  clean; \
-	done
-
diff --git a/testcases/kernel/security/selinux-testsuite/tests/Makefile.inc b/testcases/kernel/security/selinux-testsuite/tests/Makefile.inc
new file mode 100644
index 0000000..29653c8
--- /dev/null
+++ b/testcases/kernel/security/selinux-testsuite/tests/Makefile.inc
@@ -0,0 +1,35 @@
+#
+#    kernel/security/selinux-testsuite include Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, August 2009
+#
+
+CURDIR_DIRNAME		:= $(lastword $(subst /, ,$(abs_srcdir)))
+
+LDLIBS			+= -lselinux -lpthread
+
+# This is a soft error because it won't work if you're not root and doing a
+# cross-compilation based install.
+define INSTALL_POST
+	-chcon -t test_file_t $@
+endef
+
+INSTALL_TARGETS		:= selinux_$(CURDIR_DIRNAME)*.sh
+
+# vim: syntax=make
diff --git a/testcases/kernel/security/selinux-testsuite/tests/bounds/Makefile b/testcases/kernel/security/selinux-testsuite/tests/bounds/Makefile
index d5c5e53..f0f0abe 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/bounds/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/bounds/Makefile
@@ -1,11 +1,30 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
-LDLIBS += -lselinux -lpthread
+#
+#    kernel/security/selinux-testsuite/tests/bounds test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_bounds.sh ../../../../../bin/
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -f $(TARGETS)
\ No newline at end of file
+LDLIBS			+= -lselinux -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/capable_file/Makefile b/testcases/kernel/security/selinux-testsuite/tests/capable_file/Makefile
index 22bc9f1..4d4dea2 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/capable_file/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/capable_file/Makefile
@@ -1,11 +1,30 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/capable_file test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install: 
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_capable_file.sh ../../../../../bin/
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lselinux -lpthread
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/capable_net/Makefile b/testcases/kernel/security/selinux-testsuite/tests/capable_net/Makefile
index 3ce5965..26e443e 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/capable_net/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/capable_net/Makefile
@@ -1,10 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/capable_net test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install: 
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_capable_net.sh ../../../../../bin/
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/capable_sys/Makefile b/testcases/kernel/security/selinux-testsuite/tests/capable_sys/Makefile
index 2223cb2..2567c92 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/capable_sys/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/capable_sys/Makefile
@@ -1,9 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/capable_sys test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
-install: 
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_capable_sys.sh ../../../../../bin/
-clean:
-	rm -f $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/domain_trans/Makefile b/testcases/kernel/security/selinux-testsuite/tests/domain_trans/Makefile
index 00b3e38..5a483de 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/domain_trans/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/domain_trans/Makefile
@@ -1,4 +1,27 @@
-all:
-install:
-	ln -f selinux_domain_trans.sh ../../../../../bin/
-clean:
+#
+#    kernel/security/selinux-testsuite/tests/domain_trans test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/dyntrace/Makefile b/testcases/kernel/security/selinux-testsuite/tests/dyntrace/Makefile
index 49132b4..f88ae4c 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/dyntrace/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/dyntrace/Makefile
@@ -1,11 +1,30 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
-LDLIBS += -lselinux
+#
+#    kernel/security/selinux-testsuite/tests/dyntrace test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_dyntrace.sh ../../../../../bin/
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lselinux
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/dyntrans/Makefile b/testcases/kernel/security/selinux-testsuite/tests/dyntrans/Makefile
index 42ae872..11b3f51 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/dyntrans/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/dyntrans/Makefile
@@ -1,11 +1,30 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
-LDLIBS += -lselinux
+#
+#    kernel/security/selinux-testsuite/tests/dyntrans test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_dyntrans.sh ../../../../../bin/
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lselinux
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/entrypoint/Makefile b/testcases/kernel/security/selinux-testsuite/tests/entrypoint/Makefile
index 1af4688..0d7d99c 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/entrypoint/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/entrypoint/Makefile
@@ -1,4 +1,27 @@
-all:
-install:
-	ln -f selinux_entrypoint.sh ../../../../../bin/
-clean:
+#
+#    kernel/security/selinux-testsuite/tests/entrypoint test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/execshare/Makefile b/testcases/kernel/security/selinux-testsuite/tests/execshare/Makefile
index 499ca08..b55e86b 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/execshare/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/execshare/Makefile
@@ -1,12 +1,30 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
-LDLIBS += -lselinux
+#
+#    kernel/security/selinux-testsuite/tests/execshare test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install: 
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i ; done
-	ln -f selinux_execshare.sh ../../../../../bin/
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lselinux
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/exectrace/Makefile b/testcases/kernel/security/selinux-testsuite/tests/exectrace/Makefile
index 8e2243a..077b6f0 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/exectrace/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/exectrace/Makefile
@@ -1,12 +1,30 @@
-TARGETS=selinux_exectrace_parent selinux_exectrace_child
-LDLIBS += -lselinux
+#
+#    kernel/security/selinux-testsuite/tests/exectrace test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install: 
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_exectrace.sh ../../../../../bin/
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lselinux
 
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/execute_no_trans/Makefile b/testcases/kernel/security/selinux-testsuite/tests/execute_no_trans/Makefile
index 6fb9b96..444f926 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/execute_no_trans/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/execute_no_trans/Makefile
@@ -1,4 +1,27 @@
-all:
-install:
-	ln -f selinux_execute_no_trans.sh ../../../../../bin/
-clean:
+#
+#    kernel/security/selinux-testsuite/tests/execute_no_trans test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/fdreceive/Makefile b/testcases/kernel/security/selinux-testsuite/tests/fdreceive/Makefile
index a697254..6f7f1f2 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/fdreceive/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/fdreceive/Makefile
@@ -1,10 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/fdreceive test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_fdreceive.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/file/Makefile b/testcases/kernel/security/selinux-testsuite/tests/file/Makefile
index 6e281e7..6c49acb 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/file/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/file/Makefile
@@ -1,11 +1,30 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
-LDLIBS += -lselinux
+#
+#    kernel/security/selinux-testsuite/tests/file test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install: 
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_file.sh ../../../../../bin/ 
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lselinux
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/inherit/Makefile b/testcases/kernel/security/selinux-testsuite/tests/inherit/Makefile
index d30e3d3..ebca306 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/inherit/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/inherit/Makefile
@@ -1,14 +1,32 @@
-TARGETS=selinux_inherit_child selinux_inherit_parent
+#
+#    kernel/security/selinux-testsuite/tests/inherit test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-LDFLAGS +=-static
+top_srcdir              ?= ../../../../../..
 
-LDLIBS += -lselinux
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
 
-all: $(TARGETS)
+LDFLAGS			+= -static
 
-install: 
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_inherit.sh ../../../../../bin/
+LDLIBS			+= -lselinux
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/ioctl/Makefile b/testcases/kernel/security/selinux-testsuite/tests/ioctl/Makefile
index 02fd5ad..280b5da 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/ioctl/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/ioctl/Makefile
@@ -1,10 +1,27 @@
-TARGETS=selinux_ioctl selinux_noioctl
+#
+#    kernel/security/selinux-testsuite/tests/ioctl test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install: 
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_ioctl.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/link/Makefile b/testcases/kernel/security/selinux-testsuite/tests/link/Makefile
index 1bb44ee..5385193 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/link/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/link/Makefile
@@ -1,4 +1,27 @@
-all:
-install:
-	ln -f selinux_link.sh ../../../../../bin/
-clean:
+#
+#    kernel/security/selinux-testsuite/tests/link test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/mkdir/Makefile b/testcases/kernel/security/selinux-testsuite/tests/mkdir/Makefile
index 195c133..c439bf5 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/mkdir/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/mkdir/Makefile
@@ -1,4 +1,27 @@
-all:
-install:
-	ln -f selinux_mkdir.sh ../../../../../bin/
-clean:
+#
+#    kernel/security/selinux-testsuite/tests/mkdir test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/msg/Makefile b/testcases/kernel/security/selinux-testsuite/tests/msg/Makefile
index 6d499e2..595dc2d 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/msg/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/msg/Makefile
@@ -1,10 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/msg test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_msg.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/open/Makefile b/testcases/kernel/security/selinux-testsuite/tests/open/Makefile
index d94d57a..5a193bd 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/open/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/open/Makefile
@@ -1,10 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/open test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_open.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/ptrace/Makefile b/testcases/kernel/security/selinux-testsuite/tests/ptrace/Makefile
index d63938f..ea4f92b 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/ptrace/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/ptrace/Makefile
@@ -1,11 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/ptrace test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_ptrace.sh ../../../../../bin/
-	ln -f selinux_ptrace_wait.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/readlink/Makefile b/testcases/kernel/security/selinux-testsuite/tests/readlink/Makefile
index 643c43c..fda9920 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/readlink/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/readlink/Makefile
@@ -1,5 +1,27 @@
-all:
-install:
-	ln -f selinux_readlink.sh ../../../../../bin/
+#
+#    kernel/security/selinux-testsuite/tests/readlink test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-clean:
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/relabel/Makefile b/testcases/kernel/security/selinux-testsuite/tests/relabel/Makefile
index 30e81b9..24eae54 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/relabel/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/relabel/Makefile
@@ -1,5 +1,27 @@
-all:
-install:
-	ln -f selinux_relabel.sh ../../../../../bin/
+#
+#    kernel/security/selinux-testsuite/tests/relabel test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-clean:
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/rename/Makefile b/testcases/kernel/security/selinux-testsuite/tests/rename/Makefile
index 417e80f..a4cf228 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/rename/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/rename/Makefile
@@ -1,5 +1,27 @@
-all:
-install:
-	ln -f selinux_rename.sh ../../../../../bin/
+#
+#    kernel/security/selinux-testsuite/tests/rename test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-clean:
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/rxdir/Makefile b/testcases/kernel/security/selinux-testsuite/tests/rxdir/Makefile
index 1d0f29e..4dbb5b4 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/rxdir/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/rxdir/Makefile
@@ -1,5 +1,27 @@
-all:
-install:
-	ln -f selinux_rxdir.sh ../../../../../bin/
+#
+#    kernel/security/selinux-testsuite/tests/rxdir test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-clean:
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/sem/Makefile b/testcases/kernel/security/selinux-testsuite/tests/sem/Makefile
index b1960c1..c6b2a83 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/sem/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/sem/Makefile
@@ -1,10 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/sem test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_sem.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/setattr/Makefile b/testcases/kernel/security/selinux-testsuite/tests/setattr/Makefile
index ae97ffe..6dc0bbc 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/setattr/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/setattr/Makefile
@@ -1,6 +1,27 @@
-all:
+#
+#    kernel/security/selinux-testsuite/tests/setattr test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f selinux_setattr.sh ../../../../../bin/
+top_srcdir              ?= ../../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/setnice/Makefile b/testcases/kernel/security/selinux-testsuite/tests/setnice/Makefile
index 87890e3..453ccdd 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/setnice/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/setnice/Makefile
@@ -1,11 +1,30 @@
-TARGETS=selinux_setnice_parent selinux_setnice_child
+#
+#    kernel/security/selinux-testsuite/tests/setattr test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-LDLIBS += -lselinux
+top_srcdir              ?= ../../../../../..
 
-all: $(TARGETS)
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_setnice.sh ../../../../../bin/
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			:= -lselinux
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/shm/Makefile b/testcases/kernel/security/selinux-testsuite/tests/shm/Makefile
index 086233d..428e846 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/shm/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/shm/Makefile
@@ -1,10 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/shm test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_shm.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/sigkill/Makefile b/testcases/kernel/security/selinux-testsuite/tests/sigkill/Makefile
index 7d89946..0014107 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/sigkill/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/sigkill/Makefile
@@ -1,10 +1,27 @@
-TARGETS=selinux_sigkill_server
+#
+#    kernel/security/selinux-testsuite/tests/sigkill test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_sigkill.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS) 
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/stat/Makefile b/testcases/kernel/security/selinux-testsuite/tests/stat/Makefile
index a08fe0a..04e40c7 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/stat/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/stat/Makefile
@@ -1,6 +1,27 @@
-all:
-install:
-	ln -f selinux_stat.sh ../../../../../bin/
+#
+#    kernel/security/selinux-testsuite/tests/stat test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-clean:
+top_srcdir              ?= ../../../../../..
 
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/sysctl/Makefile b/testcases/kernel/security/selinux-testsuite/tests/sysctl/Makefile
index c25ebb1..1a0b712 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/sysctl/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/sysctl/Makefile
@@ -1,5 +1,27 @@
-all:
-install:
-	ln -f selinux_sysctl.sh ../../../../../bin/
+#
+#    kernel/security/selinux-testsuite/tests/sysctl test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-clean:
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/task_create/Makefile b/testcases/kernel/security/selinux-testsuite/tests/task_create/Makefile
index 5267fa8..6501788 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/task_create/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/task_create/Makefile
@@ -1,9 +1,27 @@
-TARGETS=selinux_task_create_parent
+#
+#    kernel/security/selinux-testsuite/tests/task_create test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_task_create.sh ../../../../../bin/
+top_srcdir              ?= ../../../../../..
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/task_getpgid/Makefile b/testcases/kernel/security/selinux-testsuite/tests/task_getpgid/Makefile
index 18adf14..48c574f 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/task_getpgid/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/task_getpgid/Makefile
@@ -1,10 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/task_getpgid test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_task_getpgid.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/task_getscheduler/Makefile b/testcases/kernel/security/selinux-testsuite/tests/task_getscheduler/Makefile
index 831b054..c7b1e72 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/task_getscheduler/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/task_getscheduler/Makefile
@@ -1,11 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/task_getscheduler test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_task_getscheduler.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/task_getsid/Makefile b/testcases/kernel/security/selinux-testsuite/tests/task_getsid/Makefile
index 1660405..1c8c65e 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/task_getsid/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/task_getsid/Makefile
@@ -1,10 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/task_getsid test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_task_getsid.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/task_setnice/Makefile b/testcases/kernel/security/selinux-testsuite/tests/task_setnice/Makefile
index 847335c..e7fe28a 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/task_setnice/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/task_setnice/Makefile
@@ -1,10 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/task_setnice test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_task_setnice.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/task_setpgid/Makefile b/testcases/kernel/security/selinux-testsuite/tests/task_setpgid/Makefile
index d2be734..b085d70 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/task_setpgid/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/task_setpgid/Makefile
@@ -1,8 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
-all: $(TARGETS)
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_task_setpgid.sh ../../../../../bin/
+#
+#    kernel/security/selinux-testsuite/tests/task_setpgid test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-clean:
-	rm -f $(TARGETS)
+top_srcdir              ?= ../../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/task_setscheduler/Makefile b/testcases/kernel/security/selinux-testsuite/tests/task_setscheduler/Makefile
index 7648b3c..71b2ed3 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/task_setscheduler/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/task_setscheduler/Makefile
@@ -1,11 +1,27 @@
-TARGETS=$(patsubst %.c,%,$(wildcard *.c))
+#
+#    kernel/security/selinux-testsuite/tests/task_setscheduler test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir              ?= ../../../../../..
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_task_setscheduler.sh ../../../../../bin/
-
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/selinux-testsuite/tests/wait/Makefile b/testcases/kernel/security/selinux-testsuite/tests/wait/Makefile
index 90bf935..dc6152a 100644
--- a/testcases/kernel/security/selinux-testsuite/tests/wait/Makefile
+++ b/testcases/kernel/security/selinux-testsuite/tests/wait/Makefile
@@ -1,10 +1,30 @@
-TARGETS=selinux_wait_parent selinux_wait_child
-LDLIBS += -lselinux
+#
+#    kernel/security/selinux-testsuite/tests/wait test Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
-	ln -f selinux_wait.sh ../../../../../bin/
+top_srcdir              ?= ../../../../../..
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../Makefile.inc
+
+LDLIBS			+= -lselinux
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/smack/Makefile b/testcases/kernel/security/smack/Makefile
index 09d238b..e114998 100644
--- a/testcases/kernel/security/smack/Makefile
+++ b/testcases/kernel/security/smack/Makefile
@@ -6,25 +6,10 @@
 # published by the Free Software Foundation.
 #
 
-SCRIPTS = \
-	smack_set_ambient.sh \
-	smack_set_cipso.sh \
-	smack_set_current.sh \
-	smack_set_direct.sh \
-	smack_set_doi.sh \
-	smack_set_load.sh \
-	smack_set_netlabel.sh \
-	smack_set_onlycap.sh \
-	smack_file_access.sh
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-INSTALLTARGETS = $(TARGETS) $(SCRIPTS)
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALLTARGETS = $(TARGETS) $(SCRIPTS)
-install: $(INSTALLTARGETS)
-	@set -e; for i in $(INSTALLTARGETS); do ln -f $$i ../../../bin/$$i ; chmod +x ../../../bin/$$i; done
+INSTALL_TARGETS		:= *.sh
 
-clean:
-	rm -f $(TARGETS) *.o
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/smack/smack_common.sh b/testcases/kernel/security/smack/smack_common.sh
new file mode 100755
index 0000000..eb339f3
--- /dev/null
+++ b/testcases/kernel/security/smack/smack_common.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+#    testcases/security/smack/smack_common.sh
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+# This file serves the sole purpose of executing every common piece of
+# prerequisite code for all of the smack tests, s.t. a lot of duplicate shell
+# code isn't laying around all over the place.
+#
+
+smackfsdir=${smackfsdir:=/smack}
+
+check_mounted() {
+	if [ ! -d "$smackfsdir" ]; then
+		echo "smackfs not mounted at $smackfsdir"
+		exit 1
+	fi
+}
+
+check_onlycap() {
+	onlycap=`cat "$smackfsdir/onlycap" 2>/dev/null`
+	if [ -z "$onlycap" ]; then
+		cat <<EOM
+The smack label reported for $smackfsdir/onlycap is "$onlycap", not the expected "".
+EOM
+		exit 1
+	fi
+}
+
+check_mounted
+check_onlycap
diff --git a/testcases/kernel/security/smack/smack_file_access.sh b/testcases/kernel/security/smack/smack_file_access.sh
index 45fd906..61db065 100755
--- a/testcases/kernel/security/smack/smack_file_access.sh
+++ b/testcases/kernel/security/smack/smack_file_access.sh
@@ -13,43 +13,38 @@
 #
 #               1         2         3         4         5         6
 #      123456789012345678901234567890123456789012345678901234567890123456789
+
+source smack_common.sh
+
 RuleA="TheOne                  TheOther                r---"
 RuleB="TheOne                  TheOther                rw--"
 
 Where="./testdir"
 What="testfile"
-TestFile="$Where"/"$What"
+TestFile="$Where/$What"
 CAT=/bin/cat
 
-onlycap=`cat /smack/onlycap`
-if [ "$onlycap" != "" ]; then
-	echo The smack label reported for /smack/onlycap is \"$label\",
-	echo not the expected \"\".
-	exit 1
-fi
-
 if [ ! -d "$Where" ]; then
 	if [ -e "$Where" ]; then
-		echo Test directory \"$Where\" exists but is not a directory.
+		echo "Test directory \"$Where\" exists but is not a directory."
 		exit 1
 	fi
-	mkdir "$Where"
+	mkdir -m 777 "$Where"
 	if [ ! -d "$Where" ]; then
-		echo Test directory \"$Where\" can not be created.
+		echo "Test directory \"$Where\" can not be created."
 		exit 1
 	fi
-	chmod 777 "$Where"
 fi
 
 if [ ! -f "$TestFile" ]; then
 	if [ -e "$TestFile" ]; then
-		echo Test file \"$TestFile\" exists but is not a file.
+		echo "Test file \"$TestFile\" exists but is not a file."
 		rm -rf "$Where"
 		exit 1
 	fi
-	./notroot /bin/sh -c "echo InitialData > $TestFile"
+	./notroot /bin/sh -c "echo InitialData 2>/dev/null > $TestFile"
 	if [ ! -d "$TestFile" ]; then
-		echo Test file \"$TestFile\" can not be created.
+		echo "Test file \"$TestFile\" can not be created."
 		rm -rf "$Where"
 		exit 1
 	fi
@@ -60,65 +55,65 @@
 SetTo=`echo $SetTo`
 
 if [ "TheOther" != "$SetTo" ]; then
-	echo Test file \"$TestFile\" labeled \"$SetTo\" incorrectly.
+	echo "Test file \"$TestFile\" labeled \"$SetTo\" incorrectly."
 	rm -rf "$Where"
 	exit 1
 fi
 
-OldRule=`grep "^TheOne" /smack/load | grep ' TheOther '`
+OldRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
 
-echo -n "$RuleA" > /smack/load
-NewRule=`grep "^TheOne" /smack/load | grep ' TheOther '`
-if [ "$NewRule" == "" ]; then
-	echo Rule did not get set.
+echo -n "$RuleA" > "$smackfsdir/load"
+NewRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
+if [ "$NewRule" = "" ]; then
+	echo "Rule did not get set."
 	rm -rf "$Where"
 	exit 1
 fi
 Mode=`echo $NewRule | sed -e 's/.* //'`
 if [ "$Mode" != "r" ]; then
-	echo Rule \"$NewRule\" is not set correctly.
+	echo "Rule \"$NewRule\" is not set correctly."
 	rm -rf "$Where"
 	exit 1
 fi
 
-OldProc=`cat /proc/self/attr/current`
+OldProc=`cat /proc/self/attr/current 2>/dev/null`
 
-echo TheOne > /proc/self/attr/current
+echo TheOne 2>/dev/null > /proc/self/attr/current
 GotRead=`./notroot $CAT "$TestFile"`
 
 if [ "$GotRead" != "InitialData" ]; then
-	echo Read failed for \"$TestFile\" labeled \"TheOther\".
+	echo "Read failed for \"$TestFile\" labeled \"TheOther\"."
 	rm -rf "$Where"
 	exit 1
 fi
 
-echo NotTheOne > /proc/self/attr/current
+echo NotTheOne 2>/dev/null > /proc/self/attr/current
 GotRead=`./notroot $CAT "$TestFile"`
 
-if [ "$GotRead" == "InitialData" ]; then
-	echo Read should have failed for \"$TestFile\" labeled \"TheOther\".
+if [ "$GotRead" = "InitialData" ]; then
+	echo "Read should have failed for \"$TestFile\" labeled \"TheOther\"."
 	rm -rf "$Where"
 	exit 1
 fi
 
-echo -n "$RuleB" > /smack/load
-NewRule=`grep "^TheOne" /smack/load | grep ' TheOther '`
-if [ "$NewRule" == "" ]; then
-	echo Rule did not get set.
+echo -n "$RuleB" 2>/dev/null > "$smackfsdir/load"
+NewRule=`grep "^TheOne" $smackfsdir/load 2>/dev/null | grep ' TheOther '`
+if [ "$NewRule" = "" ]; then
+	echo "Rule did not get set."
 	rm -rf "$Where"
 	exit 1
 fi
 Mode=`echo $NewRule | sed -e 's/.* //'`
 if [ "$Mode" != "rw" ]; then
-	echo Rule \"$NewRule\" is not set correctly.
+	echo "Rule \"$NewRule\" is not set correctly."
 	rm -rf "$Where"
 	exit 1
 fi
 
 if [ "$OldRule" != "$NewRule" ]; then
-	echo Notice: Test access rule changed from
-	echo \"$OldRule\" to \"$NewRule\".
+	cat <<EOM
+Notice: Test access rule changed from "$OldRule" to "$NewRule".
+EOM
 fi
 
 rm -rf "$Where"
-exit 0
diff --git a/testcases/kernel/security/smack/smack_set_ambient.sh b/testcases/kernel/security/smack/smack_set_ambient.sh
index 63eaf79..aa48b62 100755
--- a/testcases/kernel/security/smack/smack_set_ambient.sh
+++ b/testcases/kernel/security/smack/smack_set_ambient.sh
@@ -9,32 +9,29 @@
 # Environment:
 #	CAP_MAC_ADMIN
 #
+
+source smack_common.sh
+
 NotTheFloorLabel="XYZZY"
-StartLabel=`cat /smack/ambient`
+StartLabel=`cat "$smackfsdir/ambient" 2>/dev/null`
 
-onlycap=`cat /smack/onlycap`
-if [ "$onlycap" != "" ]; then
-	echo The smack label reported for /smack/onlycap is \"$label\",
-	echo not the expected \"\".
-	exit 1
-fi
+echo "$NotTheFloorLabel" 2>/dev/null > "$smackfsdir/ambient"
 
-echo $NotTheFloorLabel > /smack/ambient
-
-label=`cat /smack/ambient`
+label=`cat "$smackfsdir/ambient" 2>/dev/null`
 if [ "$label" != "$NotTheFloorLabel" ]; then
-	echo The smack label reported for the current process is \"$label\",
-	echo not the expected \"$NotTheFloorLabel\".
+	cat <<EOM
+The smack label reported for the current process is "$label", not the expected 
+"$NotTheFloorLabel".
+EOM
 	exit 1
 fi
 
-echo "$StartLabel" > /smack/ambient
+echo "$StartLabel" 2>/dev/null > "$smackfsdir/ambient"
 
-label=`cat /smack/ambient`
+label=`cat "$smackfsdir/ambient" 2>/dev/null`
 if [ "$label" != "$StartLabel" ]; then
-	echo The smack label reported for the current process is \"$label\",
-	echo not the expected \"$StartLabel\".
+	cat <<EOM
+The smack label reported for the current process is "$label",  not the expected "$StartLabel".
+EOM
 	exit 1
 fi
-
-exit 0
diff --git a/testcases/kernel/security/smack/smack_set_cipso.sh b/testcases/kernel/security/smack/smack_set_cipso.sh
index d42b861..1c7321f 100755
--- a/testcases/kernel/security/smack/smack_set_cipso.sh
+++ b/testcases/kernel/security/smack/smack_set_cipso.sh
@@ -13,58 +13,53 @@
 #
 #               1         2    llllCCCCccccCCCCcccc     5         6
 #      123456789012345678901234567890123456789012345678901234567890123456789
+
+source smack_common.sh
+
 RuleA="TheOne                  2   0   "
 RuleB="TheOne                  3   1   55  "
 RuleC="TheOne                  4   2   17  33  "
 
-onlycap=`cat /smack/onlycap`
-if [ "$onlycap" != "" ]; then
-	echo The smack label reported for /smack/onlycap is \"$label\",
-	echo not the expected \"\".
+OldRule=`grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null`
+
+echo -n "$RuleA" 2>/dev/null > "$smackfsdir/cipso"
+NewRule=`grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null`
+if [ "$NewRule" = "" ]; then
+	echo "Rule did not get set."
+	exit 1
+fi
+Right=`echo "$NewRule" | grep ' 2'`
+if [ "$Right" = "" ]; then
+	echo "Rule \"$NewRule\" is not set correctly."
 	exit 1
 fi
 
-OldRule=`grep "^TheOne" /smack/cipso`
-
-echo -n "$RuleA" > /smack/cipso
-NewRule=`grep "^TheOne" /smack/cipso`
-if [ "$NewRule" == "" ]; then
-	echo Rule did not get set.
-	exit 1
-fi
-Right=`echo $NewRule | grep ' 2'`
-if [ "$Right" == "" ]; then
-	echo Rule \"$NewRule\" is not set correctly.
-	exit 1
-fi
-
-echo -n "$RuleB" > /smack/cipso
-NewRule=`grep "^TheOne" /smack/cipso`
-if [ "$NewRule" == "" ]; then
-	echo Rule did not get set.
+echo -n "$RuleB" 2>/dev/null > "$smackfsdir/cipso"
+NewRule=`grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null`
+if [ "$NewRule" = "" ]; then
+	echo "Rule did not get set."
 	exit 1
 fi
 Right=`echo $NewRule | grep '/55'`
-if [ "$Right" == "" ]; then
-	echo Rule \"$NewRule\" is not set correctly.
+if [ "$Right" = "" ]; then
+	echo "Rule \"$NewRule\" is not set correctly."
 	exit 1
 fi
 
-echo -n "$RuleC" > /smack/cipso
-NewRule=`grep "^TheOne" /smack/cipso`
-if [ "$NewRule" == "" ]; then
-	echo Rule did not get set.
+echo -n "$RuleC" 2>/dev/null > "$smackfsdir/cipso"
+NewRule=`grep "^TheOne" "$smackfsdir/cipso" 2>/dev/null`
+if [ "$NewRule" = "" ]; then
+	echo "Rule did not get set."
 	exit 1
 fi
-Right=`echo $NewRule | grep '/17,33'`
-if [ "$Right" == "" ]; then
-	echo Rule \"$NewRule\" is not set correctly.
+Right=`echo "$NewRule" | grep '/17,33'`
+if [ "$Right" = "" ]; then
+	echo "Rule \"$NewRule\" is not set correctly."
 	exit 1
 fi
 
-
 if [ "$OldRule" != "$NewRule" ]; then
-	echo Notice: Test access rule changed from \"$OldRule\" to \"$NewRule\".
+	cat <<EOM
+Notice: Test access rule changed from "$OldRule" to "$NewRule".
+EOM
 fi
-
-exit 0
diff --git a/testcases/kernel/security/smack/smack_set_current.sh b/testcases/kernel/security/smack/smack_set_current.sh
index d6307a2..28a1b1b 100755
--- a/testcases/kernel/security/smack/smack_set_current.sh
+++ b/testcases/kernel/security/smack/smack_set_current.sh
@@ -10,32 +10,30 @@
 #	CAP_MAC_ADMIN
 #	/smack/onlycap unset
 #
+
+source smack_common.sh
+
 NotTheFloorLabel="XYZZY"
-StartLabel=`cat /proc/self/attr/current`
+StartLabel=`cat /proc/self/attr/current 2>/dev/null`
 
-onlycap=`cat /smack/onlycap`
-if [ "$onlycap" != "" ]; then
-	echo The smack label reported for /smack/onlycap is \"$label\",
-	echo not the expected \"\".
-	exit 1
-fi
+echo "$NotTheFloorLabel" 2>/dev/null > /proc/self/attr/current
 
-echo $NotTheFloorLabel > /proc/self/attr/current
-
-label=`cat /proc/self/attr/current`
+label=`cat /proc/self/attr/current 2>/dev/null`
 if [ "$label" != "$NotTheFloorLabel" ]; then
-	echo The smack label reported for the current process is \"$label\",
-	echo not the expected \"$NotTheFloorLabel\".
+	cat <<EOM
+The smack label reported for the current process is "$label",
+not the expected "$NotTheFloorLabel".
+EOM
 	exit 1
 fi
 
-echo "$StartLabel" > /proc/self/attr/current
+echo "$StartLabel" 2>/dev/null > /proc/self/attr/current
 
-label=`cat /proc/self/attr/current`
+label=`cat /proc/self/attr/current > /dev/null`
 if [ "$label" != "$StartLabel" ]; then
-	echo The smack label reported for the current process is \"$label\",
-	echo not the expected \"$StartLabel\".
+	cat <<EOM
+The smack label reported for the current process is "$label",
+not the expected "$StartLabel".
+EOM
 	exit 1
 fi
-
-exit 0
diff --git a/testcases/kernel/security/smack/smack_set_direct.sh b/testcases/kernel/security/smack/smack_set_direct.sh
index d9d347a..84135f5 100755
--- a/testcases/kernel/security/smack/smack_set_direct.sh
+++ b/testcases/kernel/security/smack/smack_set_direct.sh
@@ -9,32 +9,30 @@
 # Environment:
 #	CAP_MAC_ADMIN
 #
+
+source smack_common.sh
+
 NotTheStartValue="17"
-StartValue=`cat /smack/direct`
+StartValue=`cat "$smackfsdir/direct" 2>/dev/null`
 
-onlycap=`cat /smack/onlycap`
-if [ "$onlycap" != "" ]; then
-	echo The smack label reported for /smack/onlycap is \"$onlycap\",
-	echo not the expected \"\".
-	exit 1
-fi
+echo "$NotTheStartValue" 2>/dev/null > "$smackfsdir/direct"
 
-echo $NotTheStartValue > /smack/direct
-
-DirectValue=`cat /smack/direct`
+DirectValue=`cat "$smackfsdir/direct" 2>/dev/null`
 if [ "$DirectValue" != "$NotTheStartValue" ]; then
-	echo The CIPSO direct level reported is \"$DirectValue\",
-	echo not the expected \"$NotTheStartValue\".
+	cat <<EOM
+The CIPSO direct level reported is "$DirectValue",
+not the expected "$NotTheStartValue".
+EOM
 	exit 1
 fi
 
-echo "$StartValue" > /smack/direct
+echo "$StartValue" 2>/dev/null> "$smackfsdir/direct"
 
-DirectValue=`cat /smack/direct`
+DirectValue=`cat "$smackfsdir/direct" 2>/dev/null`
 if [ "$DirectValue" != "$StartValue" ]; then
-	echo The CIPSO direct level reported is \"$DirectValue\",
-	echo not the expected \"$StartValue\".
+	cat <<EOM
+The CIPSO direct level reported is "$DirectValue",
+not the expected "$StartValue".
+EOM
 	exit 1
 fi
-
-exit 0
diff --git a/testcases/kernel/security/smack/smack_set_doi.sh b/testcases/kernel/security/smack/smack_set_doi.sh
index 4e5561b..8aca7d0 100755
--- a/testcases/kernel/security/smack/smack_set_doi.sh
+++ b/testcases/kernel/security/smack/smack_set_doi.sh
@@ -9,31 +9,31 @@
 # Environment:
 #	CAP_MAC_ADMIN
 #
+
+source smack_common.sh
+
 NotTheStartValue="17"
-StartValue=`cat /smack/doi`
+StartValue=`cat "$smackfsdir/doi" 2>/dev/null`
 
-onlycap=`cat /smack/onlycap`
-if [ "$onlycap" != "" ]; then
-	echo The smack label reported for /smack/onlycap is \"$onlycap\",
-	echo not the expected \"\".
-	exit 1
-fi
+echo "$NotTheStartValue" 2>/dev/null > "$smackfsdir/doi"
 
-echo $NotTheStartValue > /smack/doi
-
-DirectValue=`cat /smack/doi`
+DirectValue=`cat "$smackfsdir/doi" 2>/dev/null`
 if [ "$DirectValue" != "$NotTheStartValue" ]; then
-	echo The CIPSO doi reported is \"$DirectValue\",
-	echo not the expected \"$NotTheStartValue\".
+	cat <<EOM
+The CIPSO doi reported is "$DirectValue",
+not the expected "$NotTheStartValue".
+EOM
 	exit 1
 fi
 
-echo "$StartValue" > /smack/doi
+echo "$StartValue" 2>/dev/null > "$smackfsdir/doi"
 
-DirectValue=`cat /smack/doi`
+DirectValue=`cat "$smackfsdir/doi" 2>/dev/null`
 if [ "$DirectValue" != "$StartValue" ]; then
-	echo The CIPSO doi reported is \"$DirectValue\",
-	echo not the expected \"$StartValue\".
+	cat <<EOM
+The CIPSO doi reported is "$DirectValue",
+not the expected "$StartValue".
+EOM
 	exit 1
 fi
 
diff --git a/testcases/kernel/security/smack/smack_set_load.sh b/testcases/kernel/security/smack/smack_set_load.sh
index 1eb5f04..2dd4fbb 100755
--- a/testcases/kernel/security/smack/smack_set_load.sh
+++ b/testcases/kernel/security/smack/smack_set_load.sh
@@ -13,45 +13,41 @@
 #
 #               1         2         3         4         5         6
 #      123456789012345678901234567890123456789012345678901234567890123456789
+
+source smack_common.sh
+
 RuleA="TheOne                  TheOther                rwxa"
 RuleB="TheOne                  TheOther                r---"
 
-onlycap=`cat /smack/onlycap`
-if [ "$onlycap" != "" ]; then
-	echo The smack label reported for /smack/onlycap is \"$label\",
-	echo not the expected \"\".
+OldRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
+
+echo -n "$RuleA" 2>/dev/null > "$smackfsdir/load"
+NewRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
+if [ "$NewRule" = "" ]; then
+	echo "Rule did not get set."
 	exit 1
 fi
-
-OldRule=`grep "^TheOne" /smack/load | grep ' TheOther '`
-
-echo -n "$RuleA" > /smack/load
-NewRule=`grep "^TheOne" /smack/load | grep ' TheOther '`
-if [ "$NewRule" == "" ]; then
-	echo Rule did not get set.
-	exit 1
-fi
-Mode=`echo $NewRule | sed -e 's/.* //'`
+Mode=`echo "$NewRule" | sed -e 's/.* //'`
 if [ "$Mode" != "rwxa" ]; then
-	echo Rule \"$NewRule\" is not set correctly.
+	echo "Rule \"$NewRule\" is not set correctly."
 	exit 1
 fi
 
-echo -n "$RuleB" > /smack/load
-NewRule=`grep "^TheOne" /smack/load | grep ' TheOther '`
-if [ "$NewRule" == "" ]; then
-	echo Rule did not get set.
+echo -n "$RuleB" 2>/dev/null > "$smackfsdir/load"
+NewRule=`grep "^TheOne" "$smackfsdir/load" 2>/dev/null | grep ' TheOther '`
+if [ "$NewRule" = "" ]; then
+	echo "Rule did not get set."
 	exit 1
 fi
-Mode=`echo $NewRule | sed -e 's/.* //'`
+Mode=`echo "$NewRule" | sed -e 's/.* //'`
 if [ "$Mode" != "r" ]; then
-	echo Rule \"$NewRule\" is not set correctly.
+	echo "Rule \"$NewRule\" is not set correctly."
 	exit 1
 fi
 
 if [ "$OldRule" != "$NewRule" ]; then
-	echo Notice: Test access rule changed from
-	echo \"$OldRule\" to \"$NewRule\".
+	cat <<EOM
+Notice: Test access rule changed from
+"$OldRule" to "$NewRule".
+EOM
 fi
-
-exit 0
diff --git a/testcases/kernel/security/smack/smack_set_netlabel.sh b/testcases/kernel/security/smack/smack_set_netlabel.sh
index a7d224e..4c4a384 100755
--- a/testcases/kernel/security/smack/smack_set_netlabel.sh
+++ b/testcases/kernel/security/smack/smack_set_netlabel.sh
@@ -9,41 +9,40 @@
 # Environment:
 #	CAP_MAC_ADMIN
 #
+
+source smack_common.sh
+
 RuleA="191.191.191.191 TheOne"
 RuleA1="191.191.191.191/32 TheOne"
 RuleB="191.190.190.0/24 TheOne"
 
-onlycap=`cat /smack/onlycap`
-if [ "$onlycap" != "" ]; then
-	echo The smack label reported for /smack/onlycap is \"$label\",
-	echo not the expected \"\".
-	exit 1
-fi
+Old32=`grep "^191.191.191.191/32" "$smackfsdir/netlabel" 2>/dev/null`
+Old24=`grep "^191.190.190.0/24" "$smackfsdir/netlabel" 2>/dev/null`
 
-Old32=`grep "^191.191.191.191/32" /smack/netlabel`
-Old24=`grep "^191.190.190.0/24" /smack/netlabel`
-
-echo -n "$RuleA" > /smack/netlabel
-New32=`grep "$RuleA1" /smack/netlabel`
+echo -n "$RuleA" 2>/dev/null > "$smackfsdir/netlabel"
+New32=`grep "$RuleA1" $smackfsdir/netlabel 2>/dev/null`
 if [ "$New32" != "$RuleA1" ]; then
-	echo Rule \"$RuleA\" did not get set.
+	echo "Rule \"$RuleA\" did not get set."
 	exit 1
 fi
 
-echo -n "$RuleB" > /smack/netlabel
-New24=`grep "$RuleB" /smack/netlabel`
+echo -n "$RuleB" 2>/dev/null > "$smackfsdir/netlabel"
+New24=`grep "$RuleB" "$smackfsdir/netlabel" 2>/dev/null`
 if [ "$New24" != "$RuleB" ]; then
-	echo Rule \"$RuleB\" did not get set.
+	echo "Rule \"$RuleB\" did not get set."
 	exit 1
 fi
 
 if [ "$Old24" != "$New24" ]; then
-	echo Notice: Test access rule changed from
-	echo \"$Old24\" to \"$New24\".
-fi
-if [ "$Old32" != "$New32" ]; then
-	echo Notice: Test access rule changed from
-	echo \"$Old32\" to \"$New32\".
+	cat <<EOM
+Notice: Test access rule changed from
+"$Old24" to "$New24".
+EOM
 fi
 
-exit 0
+if [ "$Old32" != "$New32" ]; then
+	cat <<EOM
+Notice: Test access rule changed from
+"$Old32" to "$New32".
+EOM
+fi
diff --git a/testcases/kernel/security/smack/smack_set_onlycap.sh b/testcases/kernel/security/smack/smack_set_onlycap.sh
index c8aff38..4b7b53a 100755
--- a/testcases/kernel/security/smack/smack_set_onlycap.sh
+++ b/testcases/kernel/security/smack/smack_set_onlycap.sh
@@ -9,31 +9,30 @@
 # Environment:
 #	CAP_MAC_ADMIN
 #
-MyLabel=`cat /proc/self/attr/current`
-StartLabel=`cat /smack/onlycap`
 
-if [ "$StartLabel" != "" ]; then
-	echo The smack label reported for /smack/onlycap is \"$StartLabel\",
-	echo not the expected \"\".
-	exit 1
-fi
+source smack_common.sh
 
-echo $MyLabel > /smack/onlycap
+MyLabel=`cat /proc/self/attr/current 2>/dev/null`
+StartLabel=`cat "$smackfsdir/onlycap" 2>/dev/null`
 
-label=`cat /smack/onlycap`
+echo "$MyLabel" 2>/dev/null > "$smackfsdir/onlycap"
+
+label=`cat "$smackfsdir/onlycap" 2>/dev/null`
 if [ "$label" != "$MyLabel" ]; then
-	echo The smack label reported for /smack/onlycap is \"$label\",
-	echo not the expected \"$MyLabel\".
+	cat <<EOM
+The smack label reported for $smackfsdir/onlycap is "$label",
+not the expected "$MyLabel".
+EOM
 	exit 1
 fi
 
-echo "$StartLabel" > /smack/onlycap
+echo "$StartLabel" 2>/dev/null > "$smackfsdir/onlycap"
 
-label=`cat /smack/onlycap`
+label=`cat "$smackfsdir/onlycap" 2>/dev/null`
 if [ "$label" != "$StartLabel" ]; then
-	echo The smack label reported for the current process is \"$label\",
-	echo not the expected \"$StartLabel\".
+	cat <<EOM
+The smack label reported for the current process is "$label",
+not the expected "$StartLabel".
+EOM
 	exit 1
 fi
-
-exit 0
diff --git a/testcases/kernel/security/tomoyo/Makefile b/testcases/kernel/security/tomoyo/Makefile
index 4f4f9e9..4bb57fd 100644
--- a/testcases/kernel/security/tomoyo/Makefile
+++ b/testcases/kernel/security/tomoyo/Makefile
@@ -1,23 +1,29 @@
-ALL_FILES = tomoyo_file_test newns
-
-all: $(ALL_FILES)
-	chmod 755 testall.sh
-
-CC=gcc
-
-CFLAGS=-Wall -O2 ${shell $(CC) -Wno-pointer-sign -S -o /dev/null -x c - < /dev/null > /dev/null 2>&1 && echo "-Wno-pointer-sign"}
-
 #
-# Tools for kernel testing.
+#    kernel/security/smack testcase Makefile
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-.c:	include.h
-	$(CC) $(CFLAGS) -o $@ $<
-	chmod 700 $@
+top_srcdir		?= ../../../..
 
-#
-# Delete all tools in this package.
-#
+include	$(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	rm -f $(ALL_FILES)
+INSTALL_TARGETS		:= testall.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/tomoyo/include.h b/testcases/kernel/security/tomoyo/include.h
index bbde2ea..be83a5a 100644
--- a/testcases/kernel/security/tomoyo/include.h
+++ b/testcases/kernel/security/tomoyo/include.h
@@ -48,10 +48,22 @@
 #include <unistd.h>
 #include <utime.h>
 
+/* 
+ * Some architectures like mips n32 don't have __NR_uselib defined in the
+ * system headers.
+ */
+#ifdef __NR_uselib
 static inline int uselib(const char *library)
 {
 	return syscall(__NR_uselib, library);
 }
+#else
+static inline int uselib(const char *library)
+{
+	errno = ENOSYS;
+	return -1;
+}
+#endif
 
 #define proc_policy_dir              "/sys/kernel/security/tomoyo/"
 #define proc_policy_domain_policy    proc_policy_dir "domain_policy"
diff --git a/testcases/kernel/syscalls/Makefile b/testcases/kernel/syscalls/Makefile
index 15b5a56..ee677a1 100644
--- a/testcases/kernel/syscalls/Makefile
+++ b/testcases/kernel/syscalls/Makefile
@@ -1,55 +1,35 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
+#    testcases/kernel/timers Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-DEBUG_CFLAGS=-O
-DEBUG_LDFLAGS=-s
-CFLAGS+=-I../../include -g -Wall
-LDLIBS+=
-EXCLUDE_DIR=epoll
+top_srcdir		?= ../../..
 
-#
-# Commented this out since there are directories here we don't want built by default
-#
-SUBDIR = `ls */Makefile | sed "s/Makefile//g"` 
-UCLINUX_SUBDIR = `ls */Makefile | sed "s/Makefile//g" | grep -vE "^fork|epoll|capget|capset|chmod|chown|llseek|nftw|clone|profil|getcontext|remap_file_pages"`
+include	$(top_srcdir)/include/mk/env_pre.mk
 
-all:
-	@set -e; for i in $(SUBDIR); do \
-		$(MAKE) -C $$i  all; \
-	done
+# pcllib is busted as all heck because of libtool
+FILTER_OUT_DIRS		:= pcllib
 
-install:
-	@set -e; for i in $(SUBDIR); do \
-		$(MAKE) -C $$i  install; \
-	done
+ifeq ($(UCLINUX),1)
+FILTER_OUT_DIRS	+= capget capset chmod chown clone fork getcontext llseek \
+		   nftw profil remap_file_pages
+endif
 
-uclinux:  
-	@set -e; for i in $(UCLINUX_SUBDIR); do \
-		$(MAKE) -C $$i UCLINUX=1 all; \
-	done
-
-uclinux_install:
-	@set -e; for i in $(UCLINUX_SUBDIR); do \
-		$(MAKE) -C $$i UCLINUX=1 install; \
-	done
-
-clean:
-	@set -e; for i in $(SUBDIR); do \
-		$(MAKE) -C $$i  clean; \
-	done
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/syscalls/abort/Makefile b/testcases/kernel/syscalls/abort/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/abort/Makefile
+++ b/testcases/kernel/syscalls/abort/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/accept/Makefile b/testcases/kernel/syscalls/accept/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/accept/Makefile
+++ b/testcases/kernel/syscalls/accept/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/accept4/Makefile b/testcases/kernel/syscalls/accept4/Makefile
index 810f38c..504042e 100644
--- a/testcases/kernel/syscalls/accept4/Makefile
+++ b/testcases/kernel/syscalls/accept4/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/access/Makefile b/testcases/kernel/syscalls/access/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/access/Makefile
+++ b/testcases/kernel/syscalls/access/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/acct/Makefile b/testcases/kernel/syscalls/acct/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/acct/Makefile
+++ b/testcases/kernel/syscalls/acct/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/add_key/Makefile b/testcases/kernel/syscalls/add_key/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/add_key/Makefile
+++ b/testcases/kernel/syscalls/add_key/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/adjtimex/Makefile b/testcases/kernel/syscalls/adjtimex/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/adjtimex/Makefile
+++ b/testcases/kernel/syscalls/adjtimex/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/alarm/Makefile b/testcases/kernel/syscalls/alarm/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/alarm/Makefile
+++ b/testcases/kernel/syscalls/alarm/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/asyncio/Makefile b/testcases/kernel/syscalls/asyncio/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/asyncio/Makefile
+++ b/testcases/kernel/syscalls/asyncio/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/bdflush/Makefile b/testcases/kernel/syscalls/bdflush/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/bdflush/Makefile
+++ b/testcases/kernel/syscalls/bdflush/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/bind/Makefile b/testcases/kernel/syscalls/bind/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/bind/Makefile
+++ b/testcases/kernel/syscalls/bind/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/brk/Makefile b/testcases/kernel/syscalls/brk/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/brk/Makefile
+++ b/testcases/kernel/syscalls/brk/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/cacheflush/Makefile b/testcases/kernel/syscalls/cacheflush/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/cacheflush/Makefile
+++ b/testcases/kernel/syscalls/cacheflush/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/capget/Makefile b/testcases/kernel/syscalls/capget/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/capget/Makefile
+++ b/testcases/kernel/syscalls/capget/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/capset/Makefile b/testcases/kernel/syscalls/capset/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/capset/Makefile
+++ b/testcases/kernel/syscalls/capset/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/chdir/Makefile b/testcases/kernel/syscalls/chdir/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/chdir/Makefile
+++ b/testcases/kernel/syscalls/chdir/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/chmod/Makefile b/testcases/kernel/syscalls/chmod/Makefile
index c3f60c5..bd617d8 100644
--- a/testcases/kernel/syscalls/chmod/Makefile
+++ b/testcases/kernel/syscalls/chmod/Makefile
@@ -16,17 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/chown/Makefile b/testcases/kernel/syscalls/chown/Makefile
index 1ecc0ae..1260f44 100644
--- a/testcases/kernel/syscalls/chown/Makefile
+++ b/testcases/kernel/syscalls/chown/Makefile
@@ -16,19 +16,14 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
+include $(top_srcdir)/include/mk/testcases.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+SRCS			:= $(filter-out %/change_owner.c,$(wildcard $(abs_srcdir)/*.c))
 
-all: $(TARGETS)
+include $(abs_srcdir)/../utils/compat_16.mk
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+MAKE_TARGETS		+= change_owner
 
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/chroot/Makefile b/testcases/kernel/syscalls/chroot/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/chroot/Makefile
+++ b/testcases/kernel/syscalls/chroot/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/clock_getres/Makefile b/testcases/kernel/syscalls/clock_getres/Makefile
index e7168a7..4e1b612 100644
--- a/testcases/kernel/syscalls/clock_getres/Makefile
+++ b/testcases/kernel/syscalls/clock_getres/Makefile
@@ -16,16 +16,12 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2
-LDLIBS += -L../../../../lib -lltp -lrt
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+LDLIBS			+= -lpthread -lrt
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/clock_getres/clock_getres01.c b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
index 1860e28..251d1da 100644
--- a/testcases/kernel/syscalls/clock_getres/clock_getres01.c
+++ b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
@@ -53,9 +53,8 @@
 #include <errno.h>
 #include <stdio.h>
 #include <time.h>
-
-
-#include "../utils/include_j_h.h"
+#include "config.h"
+#include "include_j_h.h"
 
 /* Harness Specific Include Files. */
 #include "test.h"
@@ -223,7 +222,7 @@
          * Execute system call
          */
         errno = 0;
-        if (tc->ttype == NULL_POINTER)
+	if (tc->ttype == NULL_POINTER)
                 TEST(sys_ret = clock_getres(tc->clk_id, NULL));
         else
                 TEST(sys_ret = clock_getres(tc->clk_id, &res));
diff --git a/testcases/kernel/syscalls/clock_nanosleep/Makefile b/testcases/kernel/syscalls/clock_nanosleep/Makefile
index e7168a7..71ebae9 100644
--- a/testcases/kernel/syscalls/clock_nanosleep/Makefile
+++ b/testcases/kernel/syscalls/clock_nanosleep/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2
-LDLIBS += -L../../../../lib -lltp -lrt
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lpthread -lrt
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/clock_nanosleep2/Makefile b/testcases/kernel/syscalls/clock_nanosleep2/Makefile
index 1ea8eca..71ebae9 100644
--- a/testcases/kernel/syscalls/clock_nanosleep2/Makefile
+++ b/testcases/kernel/syscalls/clock_nanosleep2/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -lrt
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lpthread -lrt
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/clone/Makefile b/testcases/kernel/syscalls/clone/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/clone/Makefile
+++ b/testcases/kernel/syscalls/clone/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/close/Makefile b/testcases/kernel/syscalls/close/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/close/Makefile
+++ b/testcases/kernel/syscalls/close/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/confstr/Makefile b/testcases/kernel/syscalls/confstr/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/confstr/Makefile
+++ b/testcases/kernel/syscalls/confstr/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/connect/Makefile b/testcases/kernel/syscalls/connect/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/connect/Makefile
+++ b/testcases/kernel/syscalls/connect/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/creat/Makefile b/testcases/kernel/syscalls/creat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/creat/Makefile
+++ b/testcases/kernel/syscalls/creat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/dup/Makefile b/testcases/kernel/syscalls/dup/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/dup/Makefile
+++ b/testcases/kernel/syscalls/dup/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/dup2/Makefile b/testcases/kernel/syscalls/dup2/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/dup2/Makefile
+++ b/testcases/kernel/syscalls/dup2/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/dup3/Makefile b/testcases/kernel/syscalls/dup3/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/dup3/Makefile
+++ b/testcases/kernel/syscalls/dup3/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/epoll/Makefile b/testcases/kernel/syscalls/epoll/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/epoll/Makefile
+++ b/testcases/kernel/syscalls/epoll/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/epoll_create1/Makefile b/testcases/kernel/syscalls/epoll_create1/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/epoll_create1/Makefile
+++ b/testcases/kernel/syscalls/epoll_create1/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/eventfd/Makefile b/testcases/kernel/syscalls/eventfd/Makefile
index 81913be..268d2e7 100644
--- a/testcases/kernel/syscalls/eventfd/Makefile
+++ b/testcases/kernel/syscalls/eventfd/Makefile
@@ -16,21 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+top_srcdir		?= ../../../..
 
-include ../../../../config.mk
+include $(top_srcdir)/include/mk/testcases.mk
 
+LDLIBS			+= $(AIO_LIBS)
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib $(AIO_LIBS) -lltp
-
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c, %, $(wildcard *.c))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS) a.out
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/eventfd2/Makefile b/testcases/kernel/syscalls/eventfd2/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/eventfd2/Makefile
+++ b/testcases/kernel/syscalls/eventfd2/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/execl/Makefile b/testcases/kernel/syscalls/execl/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/execl/Makefile
+++ b/testcases/kernel/syscalls/execl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/execle/Makefile b/testcases/kernel/syscalls/execle/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/execle/Makefile
+++ b/testcases/kernel/syscalls/execle/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/execlp/Makefile b/testcases/kernel/syscalls/execlp/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/execlp/Makefile
+++ b/testcases/kernel/syscalls/execlp/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/execv/Makefile b/testcases/kernel/syscalls/execv/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/execv/Makefile
+++ b/testcases/kernel/syscalls/execv/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/execve/Makefile b/testcases/kernel/syscalls/execve/Makefile
index af4706c..139875f 100644
--- a/testcases/kernel/syscalls/execve/Makefile
+++ b/testcases/kernel/syscalls/execve/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -I../lib -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CPPFLAGS		+= -I$(abs_srcdir)/../lib
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/execvp/Makefile b/testcases/kernel/syscalls/execvp/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/execvp/Makefile
+++ b/testcases/kernel/syscalls/execvp/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/exit/Makefile b/testcases/kernel/syscalls/exit/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/exit/Makefile
+++ b/testcases/kernel/syscalls/exit/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/exit_group/Makefile b/testcases/kernel/syscalls/exit_group/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/exit_group/Makefile
+++ b/testcases/kernel/syscalls/exit_group/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/faccessat/Makefile b/testcases/kernel/syscalls/faccessat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/faccessat/Makefile
+++ b/testcases/kernel/syscalls/faccessat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fadvise/Makefile b/testcases/kernel/syscalls/fadvise/Makefile
index 2b9eda2..13aa315 100644
--- a/testcases/kernel/syscalls/fadvise/Makefile
+++ b/testcases/kernel/syscalls/fadvise/Makefile
@@ -19,19 +19,12 @@
 #  along with this program;  if not, write to the Free Software
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+top_srcdir		?= ../../../..
 
-SRCS      = $(wildcard *.c)
-TARGETS   += $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-all: $(TARGETS)
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D$(DEF_64)=1
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fallocate/Makefile b/testcases/kernel/syscalls/fallocate/Makefile
index d6016be..bd617d8 100644
--- a/testcases/kernel/syscalls/fallocate/Makefile
+++ b/testcases/kernel/syscalls/fallocate/Makefile
@@ -1,4 +1,3 @@
-
 #
 #  Copyright (c) International Business Machines  Corp., 2001
 #
@@ -17,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fchdir/Makefile b/testcases/kernel/syscalls/fchdir/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/fchdir/Makefile
+++ b/testcases/kernel/syscalls/fchdir/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fchmod/Makefile b/testcases/kernel/syscalls/fchmod/Makefile
index c3f60c5..bd617d8 100644
--- a/testcases/kernel/syscalls/fchmod/Makefile
+++ b/testcases/kernel/syscalls/fchmod/Makefile
@@ -16,17 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fchmodat/Makefile b/testcases/kernel/syscalls/fchmodat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/fchmodat/Makefile
+++ b/testcases/kernel/syscalls/fchmodat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fchown/Makefile b/testcases/kernel/syscalls/fchown/Makefile
index 1ecc0ae..f3ab657 100644
--- a/testcases/kernel/syscalls/fchown/Makefile
+++ b/testcases/kernel/syscalls/fchown/Makefile
@@ -16,19 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fchownat/Makefile b/testcases/kernel/syscalls/fchownat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/fchownat/Makefile
+++ b/testcases/kernel/syscalls/fchownat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fcntl/Makefile b/testcases/kernel/syscalls/fcntl/Makefile
index 627e22b..ee876f1 100644
--- a/testcases/kernel/syscalls/fcntl/Makefile
+++ b/testcases/kernel/syscalls/fcntl/Makefile
@@ -16,20 +16,13 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-CPPFLAGS += -D_GNU_SOURCE
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
-all: $(TARGETS)
+CPPFLAGS		+= -D_GNU_SOURCE
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fdatasync/Makefile b/testcases/kernel/syscalls/fdatasync/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/fdatasync/Makefile
+++ b/testcases/kernel/syscalls/fdatasync/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/flock/Makefile b/testcases/kernel/syscalls/flock/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/flock/Makefile
+++ b/testcases/kernel/syscalls/flock/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fmtmsg/Makefile b/testcases/kernel/syscalls/fmtmsg/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/fmtmsg/Makefile
+++ b/testcases/kernel/syscalls/fmtmsg/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fork/Makefile b/testcases/kernel/syscalls/fork/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/fork/Makefile
+++ b/testcases/kernel/syscalls/fork/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fpathconf/Makefile b/testcases/kernel/syscalls/fpathconf/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/fpathconf/Makefile
+++ b/testcases/kernel/syscalls/fpathconf/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fstat/Makefile b/testcases/kernel/syscalls/fstat/Makefile
index 3c22a28..bf12010 100644
--- a/testcases/kernel/syscalls/fstat/Makefile
+++ b/testcases/kernel/syscalls/fstat/Makefile
@@ -16,19 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fstatat/Makefile b/testcases/kernel/syscalls/fstatat/Makefile
index 3c22a28..048f8ce 100644
--- a/testcases/kernel/syscalls/fstatat/Makefile
+++ b/testcases/kernel/syscalls/fstatat/Makefile
@@ -16,19 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fstatfs/Makefile b/testcases/kernel/syscalls/fstatfs/Makefile
index 3c22a28..bf12010 100644
--- a/testcases/kernel/syscalls/fstatfs/Makefile
+++ b/testcases/kernel/syscalls/fstatfs/Makefile
@@ -16,19 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/fsync/Makefile b/testcases/kernel/syscalls/fsync/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/fsync/Makefile
+++ b/testcases/kernel/syscalls/fsync/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ftruncate/Makefile b/testcases/kernel/syscalls/ftruncate/Makefile
index e3d1fcd..c31978a 100644
--- a/testcases/kernel/syscalls/ftruncate/Makefile
+++ b/testcases/kernel/syscalls/ftruncate/Makefile
@@ -16,23 +16,13 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
+INSTALL_TARGETS		:= ftruncate.sh ftruncate_64.sh
 
-all: $(TARGETS)
-
-install:
-	@set -e; \
-	ln -f ftruncate.sh ../../../bin/ftruncate.sh; \
-	ln -f ftruncate_64.sh ../../../bin/ftruncate_64.sh; \
-	for i in $(TARGETS); do install -m 755  $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/futimesat/Makefile b/testcases/kernel/syscalls/futimesat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/futimesat/Makefile
+++ b/testcases/kernel/syscalls/futimesat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/get_mempolicy/Makefile b/testcases/kernel/syscalls/get_mempolicy/Makefile
index 0d24c35..2ef86f0 100644
--- a/testcases/kernel/syscalls/get_mempolicy/Makefile
+++ b/testcases/kernel/syscalls/get_mempolicy/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2
-LDLIBS += -L../../../../lib -lltp 
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/get_robust_list/Makefile b/testcases/kernel/syscalls/get_robust_list/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/get_robust_list/Makefile
+++ b/testcases/kernel/syscalls/get_robust_list/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getcontext/Makefile b/testcases/kernel/syscalls/getcontext/Makefile
index 3f66038..bd617d8 100644
--- a/testcases/kernel/syscalls/getcontext/Makefile
+++ b/testcases/kernel/syscalls/getcontext/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getcpu/Makefile b/testcases/kernel/syscalls/getcpu/Makefile
index 76b3f69..b8bf68b 100644
--- a/testcases/kernel/syscalls/getcpu/Makefile
+++ b/testcases/kernel/syscalls/getcpu/Makefile
@@ -16,23 +16,21 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-ifeq ($(shell uname -r | grep -c "^2\.6\.*"), 1)
+ifneq ($(shell uname -r | grep -c "^2\.6\.*"), 1)
 
-all: $(TARGETS)
+MAKE_TARGETS		:=
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-else
+.PHONY: no-all-install
 
-all install:
+all install: no-all-install
+
+no-all-install:
 	@echo "Warning: Kernel doesn't support this test case"
+
 endif
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getcwd/Makefile b/testcases/kernel/syscalls/getcwd/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getcwd/Makefile
+++ b/testcases/kernel/syscalls/getcwd/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getdents/Makefile b/testcases/kernel/syscalls/getdents/Makefile
index fc9634f..df7b63f 100644
--- a/testcases/kernel/syscalls/getdents/Makefile
+++ b/testcases/kernel/syscalls/getdents/Makefile
@@ -16,19 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64 -DOFF_T=__off64_t
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64 -DOFF_T=__off64_t
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getdomainname/Makefile b/testcases/kernel/syscalls/getdomainname/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getdomainname/Makefile
+++ b/testcases/kernel/syscalls/getdomainname/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getdtablesize/Makefile b/testcases/kernel/syscalls/getdtablesize/Makefile
index 3f66038..bd617d8 100644
--- a/testcases/kernel/syscalls/getdtablesize/Makefile
+++ b/testcases/kernel/syscalls/getdtablesize/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getegid/Makefile b/testcases/kernel/syscalls/getegid/Makefile
index 2067f28..ad6b9f5 100644
--- a/testcases/kernel/syscalls/getegid/Makefile
+++ b/testcases/kernel/syscalls/getegid/Makefile
@@ -16,18 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -I../utils -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/geteuid/Makefile b/testcases/kernel/syscalls/geteuid/Makefile
index b59851c..f3ab657 100644
--- a/testcases/kernel/syscalls/geteuid/Makefile
+++ b/testcases/kernel/syscalls/geteuid/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getgid/Makefile b/testcases/kernel/syscalls/getgid/Makefile
index 2067f28..ad6b9f5 100644
--- a/testcases/kernel/syscalls/getgid/Makefile
+++ b/testcases/kernel/syscalls/getgid/Makefile
@@ -16,18 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -I../utils -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getgroups/Makefile b/testcases/kernel/syscalls/getgroups/Makefile
index 65b0d3f..f3ab657 100644
--- a/testcases/kernel/syscalls/getgroups/Makefile
+++ b/testcases/kernel/syscalls/getgroups/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS) *.o
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/gethostid/Makefile b/testcases/kernel/syscalls/gethostid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/gethostid/Makefile
+++ b/testcases/kernel/syscalls/gethostid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/gethostname/Makefile b/testcases/kernel/syscalls/gethostname/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/gethostname/Makefile
+++ b/testcases/kernel/syscalls/gethostname/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getitimer/Makefile b/testcases/kernel/syscalls/getitimer/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getitimer/Makefile
+++ b/testcases/kernel/syscalls/getitimer/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getpagesize/Makefile b/testcases/kernel/syscalls/getpagesize/Makefile
index 3f66038..bd617d8 100644
--- a/testcases/kernel/syscalls/getpagesize/Makefile
+++ b/testcases/kernel/syscalls/getpagesize/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getpeername/Makefile b/testcases/kernel/syscalls/getpeername/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getpeername/Makefile
+++ b/testcases/kernel/syscalls/getpeername/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getpgid/Makefile b/testcases/kernel/syscalls/getpgid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getpgid/Makefile
+++ b/testcases/kernel/syscalls/getpgid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getpgrp/Makefile b/testcases/kernel/syscalls/getpgrp/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getpgrp/Makefile
+++ b/testcases/kernel/syscalls/getpgrp/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getpid/Makefile b/testcases/kernel/syscalls/getpid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getpid/Makefile
+++ b/testcases/kernel/syscalls/getpid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getppid/Makefile b/testcases/kernel/syscalls/getppid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getppid/Makefile
+++ b/testcases/kernel/syscalls/getppid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getpriority/Makefile b/testcases/kernel/syscalls/getpriority/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getpriority/Makefile
+++ b/testcases/kernel/syscalls/getpriority/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getresgid/Makefile b/testcases/kernel/syscalls/getresgid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getresgid/Makefile
+++ b/testcases/kernel/syscalls/getresgid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getresuid/Makefile b/testcases/kernel/syscalls/getresuid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getresuid/Makefile
+++ b/testcases/kernel/syscalls/getresuid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getrlimit/Makefile b/testcases/kernel/syscalls/getrlimit/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getrlimit/Makefile
+++ b/testcases/kernel/syscalls/getrlimit/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getrusage/Makefile b/testcases/kernel/syscalls/getrusage/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getrusage/Makefile
+++ b/testcases/kernel/syscalls/getrusage/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getsid/Makefile b/testcases/kernel/syscalls/getsid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getsid/Makefile
+++ b/testcases/kernel/syscalls/getsid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getsockname/Makefile b/testcases/kernel/syscalls/getsockname/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getsockname/Makefile
+++ b/testcases/kernel/syscalls/getsockname/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getsockopt/Makefile b/testcases/kernel/syscalls/getsockopt/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/getsockopt/Makefile
+++ b/testcases/kernel/syscalls/getsockopt/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/gettid/Makefile b/testcases/kernel/syscalls/gettid/Makefile
index e086e79..77e928b 100644
--- a/testcases/kernel/syscalls/gettid/Makefile
+++ b/testcases/kernel/syscalls/gettid/Makefile
@@ -20,16 +20,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/gettimeofday/Makefile b/testcases/kernel/syscalls/gettimeofday/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/gettimeofday/Makefile
+++ b/testcases/kernel/syscalls/gettimeofday/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/getuid/Makefile b/testcases/kernel/syscalls/getuid/Makefile
index b59851c..f3ab657 100644
--- a/testcases/kernel/syscalls/getuid/Makefile
+++ b/testcases/kernel/syscalls/getuid/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/inotify/Makefile b/testcases/kernel/syscalls/inotify/Makefile
index 73eb227..91da9ff 100644
--- a/testcases/kernel/syscalls/inotify/Makefile
+++ b/testcases/kernel/syscalls/inotify/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/inotify_init/Makefile b/testcases/kernel/syscalls/inotify_init/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/inotify_init/Makefile
+++ b/testcases/kernel/syscalls/inotify_init/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/io_cancel/Makefile b/testcases/kernel/syscalls/io_cancel/Makefile
index bfca371..9b6eae8 100644
--- a/testcases/kernel/syscalls/io_cancel/Makefile
+++ b/testcases/kernel/syscalls/io_cancel/Makefile
@@ -1,8 +1,4 @@
 #
-# Copied from ../modify_ldt/Makefile by Masatake YAMATO 
-#
-###
-#
 #  Copyright (c) International Business Machines  Corp., 2001
 #
 #  This program is free software;  you can redistribute it and/or modify
@@ -20,19 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+top_srcdir		?= ../../../..
 
-include ../../../../config.mk
+include $(top_srcdir)/include/mk/testcases.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+LDFLAGS			+= $(AIO_LIBS)
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/io_destroy/Makefile b/testcases/kernel/syscalls/io_destroy/Makefile
index e984f60..9b6eae8 100644
--- a/testcases/kernel/syscalls/io_destroy/Makefile
+++ b/testcases/kernel/syscalls/io_destroy/Makefile
@@ -1,8 +1,4 @@
 #
-# Copied from ../modify_ldt/Makefile by Masatake YAMATO 
-#
-###
-#
 #  Copyright (c) International Business Machines  Corp., 2001
 #
 #  This program is free software;  you can redistribute it and/or modify
@@ -20,20 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+top_srcdir		?= ../../../..
 
-include ../../../../config.mk
+include $(top_srcdir)/include/mk/testcases.mk
 
+LDFLAGS			+= $(AIO_LIBS)
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/io_getevents/Makefile b/testcases/kernel/syscalls/io_getevents/Makefile
index e984f60..9b6eae8 100644
--- a/testcases/kernel/syscalls/io_getevents/Makefile
+++ b/testcases/kernel/syscalls/io_getevents/Makefile
@@ -1,8 +1,4 @@
 #
-# Copied from ../modify_ldt/Makefile by Masatake YAMATO 
-#
-###
-#
 #  Copyright (c) International Business Machines  Corp., 2001
 #
 #  This program is free software;  you can redistribute it and/or modify
@@ -20,20 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+top_srcdir		?= ../../../..
 
-include ../../../../config.mk
+include $(top_srcdir)/include/mk/testcases.mk
 
+LDFLAGS			+= $(AIO_LIBS)
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/io_setup/Makefile b/testcases/kernel/syscalls/io_setup/Makefile
index e984f60..9b6eae8 100644
--- a/testcases/kernel/syscalls/io_setup/Makefile
+++ b/testcases/kernel/syscalls/io_setup/Makefile
@@ -1,8 +1,4 @@
 #
-# Copied from ../modify_ldt/Makefile by Masatake YAMATO 
-#
-###
-#
 #  Copyright (c) International Business Machines  Corp., 2001
 #
 #  This program is free software;  you can redistribute it and/or modify
@@ -20,20 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+top_srcdir		?= ../../../..
 
-include ../../../../config.mk
+include $(top_srcdir)/include/mk/testcases.mk
 
+LDFLAGS			+= $(AIO_LIBS)
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/io_submit/Makefile b/testcases/kernel/syscalls/io_submit/Makefile
index 00fe37b..9b6eae8 100644
--- a/testcases/kernel/syscalls/io_submit/Makefile
+++ b/testcases/kernel/syscalls/io_submit/Makefile
@@ -1,8 +1,4 @@
 #
-# Copied from ../modify_ldt/Makefile by Masatake YAMATO 
-#
-###
-#
 #  Copyright (c) International Business Machines  Corp., 2001
 #
 #  This program is free software;  you can redistribute it and/or modify
@@ -20,21 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+top_srcdir		?= ../../../..
 
-include ../../../../config.mk
+include $(top_srcdir)/include/mk/testcases.mk
 
+LDFLAGS			+= $(AIO_LIBS)
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-SYSCALL = io_submit
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ioctl/Makefile b/testcases/kernel/syscalls/ioctl/Makefile
index 7bab8b3..a15afa7 100644
--- a/testcases/kernel/syscalls/ioctl/Makefile
+++ b/testcases/kernel/syscalls/ioctl/Makefile
@@ -16,17 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+INSTALL_TARGETS		+= test_ioctl
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-	ln -f test_ioctl ../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ioperm/Makefile b/testcases/kernel/syscalls/ioperm/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/ioperm/Makefile
+++ b/testcases/kernel/syscalls/ioperm/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/iopl/Makefile b/testcases/kernel/syscalls/iopl/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/iopl/Makefile
+++ b/testcases/kernel/syscalls/iopl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/Makefile b/testcases/kernel/syscalls/ipc/Makefile
index 377cc2a..a16a143 100644
--- a/testcases/kernel/syscalls/ipc/Makefile
+++ b/testcases/kernel/syscalls/ipc/Makefile
@@ -16,10 +16,27 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-SUBDIRS = $(patsubst %/Makefile,%,$(wildcard */Makefile))
+top_srcdir		?= ../../../..
 
-all %::
-	@set -e; \
-	for i in $(SUBDIRS); do \
-		$(MAKE) -C $$i $@; \
+include $(top_srcdir)/include/mk/env_pre.mk
+
+LIB			:= $(DESTDIR)/$(libdir)/libipc.a
+LIBDIR			:= lib
+FILTER_OUT_DIRS		:= $(LIBDIR)
+
+$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): $(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
 	done
+
+trunk-all: $(LIB)
+
+trunk-clean:: | lib-clean
+
+lib-clean:: $(LIBDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/syscalls/ipc/Makefile.inc b/testcases/kernel/syscalls/ipc/Makefile.inc
new file mode 100644
index 0000000..4918833
--- /dev/null
+++ b/testcases/kernel/syscalls/ipc/Makefile.inc
@@ -0,0 +1,40 @@
+#
+#    kernel/syscalls/ipc testcase suite common definitions Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# DO NOT USE THIS FILE FOR ipc / lib!!!
+
+CPPFLAGS		+= -I$(abs_srcdir)/../lib
+LDLIBS			+= -lipc
+LIB			:= $(DESTDIR)/$(libdir)/libipc.a
+LIBDIR			:= lib
+
+../$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIB): ../$(LIBDIR)
+	for i in all install; do \
+	    $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
+
+all: | $(LIB)
+
+# vim: syntax=make
diff --git a/testcases/kernel/syscalls/ipc/lib/Makefile b/testcases/kernel/syscalls/ipc/lib/Makefile
index 952665d..760f86b 100644
--- a/testcases/kernel/syscalls/ipc/lib/Makefile
+++ b/testcases/kernel/syscalls/ipc/lib/Makefile
@@ -16,22 +16,12 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-SRCS   = libipc.c
-OBJS   = $(SRCS:.c=.o)
-LIBIPC = ../libipc.a
-LIBIPC_HEADERS	= ipcmsg.h ipcsem.h
+top_srcdir		?= ../../../../..
 
-CFLAGS += -I../../../../../include -Wall
-CFLAGS += -D_USC_LIB_
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: $(LIBIPC)
+LIB			:= libipc.a
 
-$(LIBIPC): $(OBJS)
-	$(AR) -rc $@ $(OBJS)
+CFLAGS			+= -D_USC_LIB_
 
-$(OBJS): $(LIBIPC_HEADERS)
-
-install:
-
-clean:
-	rm -f $(OBJS) $(LIBIPC)
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/kernel/syscalls/ipc/msgctl/Makefile b/testcases/kernel/syscalls/ipc/msgctl/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgctl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/msgget/Makefile b/testcases/kernel/syscalls/ipc/msgget/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/msgget/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgget/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/Makefile b/testcases/kernel/syscalls/ipc/msgrcv/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgrcv/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/Makefile b/testcases/kernel/syscalls/ipc/msgsnd/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgsnd/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/semctl/Makefile b/testcases/kernel/syscalls/ipc/semctl/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/semctl/Makefile
+++ b/testcases/kernel/syscalls/ipc/semctl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/semget/Makefile b/testcases/kernel/syscalls/ipc/semget/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/semget/Makefile
+++ b/testcases/kernel/syscalls/ipc/semget/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/semop/Makefile b/testcases/kernel/syscalls/ipc/semop/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/semop/Makefile
+++ b/testcases/kernel/syscalls/ipc/semop/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/shmat/Makefile b/testcases/kernel/syscalls/ipc/shmat/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/shmat/Makefile
+++ b/testcases/kernel/syscalls/ipc/shmat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/shmctl/Makefile b/testcases/kernel/syscalls/ipc/shmctl/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/Makefile
+++ b/testcases/kernel/syscalls/ipc/shmctl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/shmdt/Makefile b/testcases/kernel/syscalls/ipc/shmdt/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/shmdt/Makefile
+++ b/testcases/kernel/syscalls/ipc/shmdt/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ipc/shmget/Makefile b/testcases/kernel/syscalls/ipc/shmget/Makefile
index 9071354..f467389 100644
--- a/testcases/kernel/syscalls/ipc/shmget/Makefile
+++ b/testcases/kernel/syscalls/ipc/shmget/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../lib -I../../../../../include -Wall
-LDLIBS += -L../../../../../lib -lltp -L.. -lipc
+top_srcdir              ?= ../../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/keyctl/Makefile b/testcases/kernel/syscalls/keyctl/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/keyctl/Makefile
+++ b/testcases/kernel/syscalls/keyctl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/kill/Makefile b/testcases/kernel/syscalls/kill/Makefile
index 28ebaaa..e998784 100644
--- a/testcases/kernel/syscalls/kill/Makefile
+++ b/testcases/kernel/syscalls/kill/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -L../ipc -lipc
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lipc
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/lchown/Makefile b/testcases/kernel/syscalls/lchown/Makefile
index 360f5df..f3ab657 100644
--- a/testcases/kernel/syscalls/lchown/Makefile
+++ b/testcases/kernel/syscalls/lchown/Makefile
@@ -16,23 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install: create_link.mode
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-create_link.mode: 
-	@/bin/sh ./create_link.mode.sh
-
-.PHONY: create_link.mode
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/lchown/create_link.mode.sh b/testcases/kernel/syscalls/lchown/create_link.mode.sh
deleted file mode 100644
index e9270e0..0000000
--- a/testcases/kernel/syscalls/lchown/create_link.mode.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-whoami | grep root > /dev/null
-if [ $? -eq 0 ];then
-  chown root create_link
-  chmod 04755 create_link
-else
- echo ""
- echo "		         ************** WARNING **************"
- echo "		Cannot change permission or ownership of \"create_link\"."
- echo "		           Tests in this directory will fail"$
- echo "                       Run "make install" as root."
- echo "		         *************************************"
- sleep 2
-fi
-
diff --git a/testcases/kernel/syscalls/lchown/lchown02.c b/testcases/kernel/syscalls/lchown/lchown02.c
index d91b7fc..7685bef 100644
--- a/testcases/kernel/syscalls/lchown/lchown02.c
+++ b/testcases/kernel/syscalls/lchown/lchown02.c
@@ -234,8 +234,10 @@
  */
 void setup()
 {
+	char file[PATH_MAX];
 	int ind;		/* counter for setup functions */
-
+	struct stat change_link_stat;
+	
 	/* Capture unexpected signals */
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
@@ -271,6 +273,22 @@
 			 "getcwd(3) fails to get working directory of process");
 	}
 
+	snprintf(file, PATH_MAX, "%schange_link", EXEC_DIR);
+	if (stat(file, &change_link_stat) < 0) {
+		tst_brkm(TBROK, cleanup, "stat for change_link failed");
+	} else {
+		if ((change_link_stat.st_uid || change_link_stat.st_gid) &&
+		     chown(file, 0, 0) < 0) {
+			tst_brkm(TBROK, cleanup,
+					"chown for change_link failed");
+		}
+		if (change_link_stat.st_mode != 04511 &&
+		    chmod(file, 04755) < 0) {
+			tst_brkm(TBROK, cleanup,
+					"setuid for change_link failed");
+		}
+	}
+
 	/* Make a temp dir and cd to it */
 	tst_tmpdir();
 
diff --git a/testcases/kernel/syscalls/link/Makefile b/testcases/kernel/syscalls/link/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/link/Makefile
+++ b/testcases/kernel/syscalls/link/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/linkat/Makefile b/testcases/kernel/syscalls/linkat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/linkat/Makefile
+++ b/testcases/kernel/syscalls/linkat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/listen/Makefile b/testcases/kernel/syscalls/listen/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/listen/Makefile
+++ b/testcases/kernel/syscalls/listen/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/llseek/Makefile b/testcases/kernel/syscalls/llseek/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/llseek/Makefile
+++ b/testcases/kernel/syscalls/llseek/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/lseek/Makefile b/testcases/kernel/syscalls/lseek/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/lseek/Makefile
+++ b/testcases/kernel/syscalls/lseek/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/lstat/Makefile b/testcases/kernel/syscalls/lstat/Makefile
index 3c22a28..bf12010 100644
--- a/testcases/kernel/syscalls/lstat/Makefile
+++ b/testcases/kernel/syscalls/lstat/Makefile
@@ -16,19 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/madvise/Makefile b/testcases/kernel/syscalls/madvise/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/madvise/Makefile
+++ b/testcases/kernel/syscalls/madvise/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mallopt/Makefile b/testcases/kernel/syscalls/mallopt/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mallopt/Makefile
+++ b/testcases/kernel/syscalls/mallopt/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mbind/Makefile b/testcases/kernel/syscalls/mbind/Makefile
index 66e1321..4a46571 100644
--- a/testcases/kernel/syscalls/mbind/Makefile
+++ b/testcases/kernel/syscalls/mbind/Makefile
@@ -16,16 +16,19 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -I../utils/ -Wall -O2
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+#
+# gcc complains about unused functions / variables when HAS_NUMA_H isn't
+# defined, so let's just skip the warning. It's nothing more than a few extra
+# variables and functions allocated on the stack, so meh... no harm, no foul.
+#
+ifeq ($(NUMA_LIBS),)
+CPPFLAGS		+= -Wno-unused
+endif
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+CPPFLAGS		+= -I$(abs_srcdir)/../utils/
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mbind/mbind01.c b/testcases/kernel/syscalls/mbind/mbind01.c
index 4afa71b..3cf7f97 100644
--- a/testcases/kernel/syscalls/mbind/mbind01.c
+++ b/testcases/kernel/syscalls/mbind/mbind01.c
@@ -55,7 +55,9 @@
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
-#include "numaif.h"
+#if HAS_NUMAIF_H
+#include <numaif.h>
+#endif
 #include "include_j_h.h"
 
 /* Harness Specific Include Files. */
@@ -174,6 +176,7 @@
  *                      (only we can do is simulate 1-node NUMA)
  */
 
+#if HAS_NUMA_H
 static struct test_case tcase[] = {
         { // case00
                 .policy         = MPOL_DEFAULT,
@@ -244,6 +247,9 @@
                 .err            = EFAULT,
         },
 };
+#else
+static struct test_case tcase[] = { };
+#endif
 
 #define MEM_LENGTH              (4 * 1024 * 1024)
 /*
@@ -255,6 +261,7 @@
  */
 
 static int do_test(struct test_case *tc) {
+#if HAS_NUMA_H
         int sys_ret;
         int sys_errno;
         int result = RESULT_OK;
@@ -270,6 +277,7 @@
         nodemask_set(&nodemask, 0);
         nodemask_zero(&getnodemask);
 
+
         /*
          * mmap memory
          */
@@ -326,6 +334,9 @@
         result |= ((sys_errno != tc->err) || (!cmp_ok));
         PRINT_RESULT_CMP(0, tc->ret, tc->err, sys_ret, sys_errno, cmp_ok);
         return result;
+#else
+	return -1;
+#endif
 }
 
 /*
@@ -346,8 +357,6 @@
 
 
 int main(int ac, char **av) {
-	int result = 0;
-	int lc, i;                 /* loop counter */
 	char *msg;              /* message returned from parse_opts */
 
 	struct option long_options[] = {
@@ -367,6 +376,10 @@
 	progname = strchr(av[0],'/');
 	progname = (progname ? progname + 1 : av[0]);
 
+#if HAS_NUMA_H
+	int result = 0;
+	int lc, i;                 /* loop counter */
+
         /* Check looping state if -i option given */
         for (lc = 0; TEST_LOOPING(lc); ++lc) {
                 Tst_count = 0;
@@ -416,8 +429,10 @@
 
 
                 }
-        }	
+        }
+#else
+	tst_resm(TCONF, "NUMA support not provided.");
+#endif
         cleanup();
 	tst_exit();
 }
-
diff --git a/testcases/kernel/syscalls/memcmp/Makefile b/testcases/kernel/syscalls/memcmp/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/memcmp/Makefile
+++ b/testcases/kernel/syscalls/memcmp/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/memcpy/Makefile b/testcases/kernel/syscalls/memcpy/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/memcpy/Makefile
+++ b/testcases/kernel/syscalls/memcpy/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/memmap/Makefile b/testcases/kernel/syscalls/memmap/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/memmap/Makefile
+++ b/testcases/kernel/syscalls/memmap/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/memset/Makefile b/testcases/kernel/syscalls/memset/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/memset/Makefile
+++ b/testcases/kernel/syscalls/memset/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mincore/Makefile b/testcases/kernel/syscalls/mincore/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mincore/Makefile
+++ b/testcases/kernel/syscalls/mincore/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mkdir/Makefile b/testcases/kernel/syscalls/mkdir/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mkdir/Makefile
+++ b/testcases/kernel/syscalls/mkdir/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mkdirat/Makefile b/testcases/kernel/syscalls/mkdirat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mkdirat/Makefile
+++ b/testcases/kernel/syscalls/mkdirat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mknod/Makefile b/testcases/kernel/syscalls/mknod/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mknod/Makefile
+++ b/testcases/kernel/syscalls/mknod/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mknodat/Makefile b/testcases/kernel/syscalls/mknodat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mknodat/Makefile
+++ b/testcases/kernel/syscalls/mknodat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mlock/Makefile b/testcases/kernel/syscalls/mlock/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mlock/Makefile
+++ b/testcases/kernel/syscalls/mlock/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mlockall/Makefile b/testcases/kernel/syscalls/mlockall/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mlockall/Makefile
+++ b/testcases/kernel/syscalls/mlockall/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mmap/Makefile b/testcases/kernel/syscalls/mmap/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mmap/Makefile
+++ b/testcases/kernel/syscalls/mmap/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/modify_ldt/Makefile b/testcases/kernel/syscalls/modify_ldt/Makefile
index 9cd92c5..bd617d8 100644
--- a/testcases/kernel/syscalls/modify_ldt/Makefile
+++ b/testcases/kernel/syscalls/modify_ldt/Makefile
@@ -15,17 +15,9 @@
 #  along with this program;  if not, write to the Free Software
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-CFLAGS += -I../../../../include -g -Wall -Wall
-LDLIBS += -L../../../../lib -lltp
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mount/Makefile b/testcases/kernel/syscalls/mount/Makefile
index bc5e3c1..4c6aa45 100644
--- a/testcases/kernel/syscalls/mount/Makefile
+++ b/testcases/kernel/syscalls/mount/Makefile
@@ -21,22 +21,12 @@
 #
 #############################################################################
 
-CFLAGS += -I../../../../include -Wall -D_GNU_SOURCE
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CFLAGS			+= -D_GNU_SOURCE
 
-install: setuid_test.mode
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-	ln -f test_mount ../../../bin/
+INSTALL_TARGETS		:= test_mount
 
-clean:
-	rm -f $(TARGETS)
-
-setuid_test.mode:
-	@/bin/sh ./setuid_test.mode.sh
-
-.PHONY: setuid_test.mode
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index 266af58..5d57287 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -159,7 +159,6 @@
 		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
 		tst_exit();
 	}
-
 	/* Check for mandatory option of the testcase */
 	if (!Dflag) {
 		tst_resm(TWARN, "You must specifiy the device used for "
@@ -259,7 +258,7 @@
 	case 0:
 		/* Validate MS_RDONLY flag of mount call */
 
-		sprintf(file, "%stmp", Path_name);
+		snprintf(file, PATH_MAX, "%stmp", Path_name);
 		if ((fd = open(file, O_CREAT | O_RDWR, S_IRWXU)) == -1) {
 			if (errno == EROFS) {
 				return 0;
@@ -275,7 +274,8 @@
 	case 1:
 		/* Validate MS_NODEV flag of mount call */
 
-		sprintf(file, "%smynod_%d_%d", Path_name, getpid(), cnt);
+		snprintf(file, PATH_MAX, "%smynod_%d_%d", Path_name, getpid(),
+			       cnt);
 		if (mknod(file, S_IFBLK | 0777, 0) == 0) {
 			if ((fd = open(file, O_RDWR, S_IRWXU)) == -1) {
 				if (errno == EACCES) {
@@ -298,7 +298,7 @@
 	case 2:
 		/* Validate MS_NOEXEC flag of mount call */
 
-		sprintf(file, "%stmp1", Path_name);
+		snprintf(file, PATH_MAX, "%stmp1", Path_name);
 		if ((fd = open(file, O_CREAT | O_RDWR, S_IRWXU)) == -1) {
 			tst_resm(TWARN,
 				 "open() of %s failed with error" " %d : %s",
@@ -321,7 +321,7 @@
 		strcpy(write_buffer, "abcdefghijklmnopqrstuvwxyz");
 
 		/* Creat a temporary file under above directory */
-		sprintf(file, "%s%s", Path_name, TEMP_FILE);
+		snprintf(file, PATH_MAX, "%s%s", Path_name, TEMP_FILE);
 		if ((fildes = open(file, O_RDWR | O_CREAT, FILE_MODE))
 		    == -1) {
 			tst_resm(TWARN, "open(%s, O_RDWR | O_CREAT,"
@@ -376,7 +376,7 @@
 				 strerror(TEST_ERRNO));
 			return 1;
 		} else {
-			sprintf(file, "%stmp2", Path_name);
+			snprintf(file, PATH_MAX, "%stmp2", Path_name);
 			if ((fd = open(file, O_CREAT | O_RDWR, S_IRWXU))
 			    == -1) {
 				tst_resm(TWARN, "open(%s) on readonly "
@@ -392,7 +392,7 @@
 
 		setup_uid();
 		if ((pid = fork()) == 0) {
-			sprintf(file, "%ssetuid_test", Path_name);
+			snprintf(file, PATH_MAX, "%ssetuid_test", Path_name);
 			if (chmod(file, SUID_MODE) != 0) {
 				tst_resm(TWARN, "chmod() failed to "
 					 "change mode  %d errno = %d : %s",
@@ -461,6 +461,7 @@
 void setup()
 {
 	char *test_home;	/* variable to hold TESTHOME env */
+	struct stat setuid_test_stat;
 
 	/* capture signals */
 	tst_sig(FORK, DEF_HANDLER, cleanup);
@@ -485,7 +486,6 @@
 			 "errno = %d: %s", mntpoint, DIR_MODE, errno,
 			 strerror(errno));
 	}
-
 	/* Get the current working directory of the process */
 	if (getcwd(Path_name, sizeof(Path_name)) == NULL) {
 		tst_brkm(TBROK, cleanup,
@@ -496,12 +496,27 @@
 			 "errno = %d : %s", DIR_MODE, TEST_ERRNO,
 			 strerror(TEST_ERRNO));
 	}
+	snprintf(file, PATH_MAX, "%ssetuid_test", Path_name);
+	if (stat(file, &setuid_test_stat) < 0) {
+		tst_brkm(TBROK, cleanup, "stat for setuid_test failed");
+	} else {
+		if ((setuid_test_stat.st_uid || setuid_test_stat.st_gid) &&
+		     chown(file, 0, 0) < 0) {
+			tst_brkm(TBROK, cleanup,
+					"chown for setuid_test failed");
+		}
+		if (setuid_test_stat.st_mode != 04511 &&
+		    chmod(file, 04511) < 0) {
+			tst_brkm(TBROK, cleanup,
+					"setuid for setuid_test failed");
+		}
+	}
 
 	/*
 	 * Get the complete path of TESTDIR created
 	 * under temporary directory
 	 */
-	sprintf(Path_name, "%s/%s/", Path_name, mntpoint);
+	snprintf(Path_name, PATH_MAX, "%s/%s/", Path_name, mntpoint);
 
 	strcpy(testhome_path, test_home);
 
diff --git a/testcases/kernel/syscalls/mount/setuid_test.mode.sh b/testcases/kernel/syscalls/mount/setuid_test.mode.sh
deleted file mode 100644
index 017a72c..0000000
--- a/testcases/kernel/syscalls/mount/setuid_test.mode.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-whoami | grep root > /dev/null
-if [ $? -eq 0 ];then
-	chown root:root setuid_test
-        chmod 04511 setuid_test
-else
- echo ""
- echo "		         ************** WARNING **************"
- echo "		Cannot change permission or ownership of \"setuid_test\"."
- echo "		           Tests in this directory will fail"$
- echo "                       Run "make install" as root."
- echo "		         *************************************"
- sleep 2
-fi
-
diff --git a/testcases/kernel/syscalls/move_pages/Makefile b/testcases/kernel/syscalls/move_pages/Makefile
index 3be37e4..cf87cd4 100644
--- a/testcases/kernel/syscalls/move_pages/Makefile
+++ b/testcases/kernel/syscalls/move_pages/Makefile
@@ -16,48 +16,21 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -lnuma -lrt
+top_srcdir		?= ../../../..
 
-check_numa_move_pages = $(shell \
-	if printf \
-	"\#include <numa.h>\n\
-	int main() \
-	{ \
-	numa_move_pages(0, 0, NULL, NULL, NULL, 0); \
-	return 0; \
-	}" | $(CC) -xc -lnuma - > /dev/null 2>&1 ; \
-	then echo yes ; \
-	else echo no ; fi)
+include $(top_srcdir)/include/mk/testcases.mk
 
-HAS_NUMA_MOVE_PAGES := $(call check_numa_move_pages)
+INSTALL_TARGETS		:= move_pages.sh
 
-ifeq ($(HAS_NUMA_MOVE_PAGES),yes)
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c, %, $(wildcard *[0-9].c))
-endif
+MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*[0-9].c))
 
-all: $(TARGETS)
-ifeq ($(HAS_NUMA_MOVE_PAGES),no)
-	@echo "Note: Libnuma with move_pages support is required for" \
-	"move_pages testcases.";
-endif
+# linux_syscall_numbers.h is forcing move_pages_support.o to complain about
+# cleanup being undefined [and when defined] unused. Let's just skip this
+# warning...
+move_pages_support.o: CFLAGS += -Wno-unused-function
 
-move_pages_support.o: move_pages_support.h move_pages_support.c
+$(MAKE_TARGETS): %: %.o move_pages_support.o
 
-$(TARGETS): move_pages_support.o
+LDLIBS			+= $(NUMA_LIBS) -lpthread -lrt
 
-install: move_page03.mode move_page11.mode
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-	chmod 755 move_pages.sh; cp move_pages.sh ../../../bin/.
-
-clean:
-	rm -f $(TARGETS) a.out move_pages_support.o
-
-move_page03.mode:
-	@/bin/sh ./move_pages03.mode.sh
-
-move_page11.mode:
-	@/bin/sh ./move_pages11.mode.sh
-
-.PHONY: move_pages03.mode
\ No newline at end of file
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/move_pages/move_pages01.c b/testcases/kernel/syscalls/move_pages/move_pages01.c
index 1c4d912..f805a3e 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages01.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages01.c
@@ -53,7 +53,9 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <errno.h>
+#if HAVE_NUMA_H 
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -72,7 +74,6 @@
 
 int main(int argc, char **argv)
 {
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
 
 	/* parse standard options */
@@ -85,6 +86,9 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	int lc;			/* loop counter */
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -100,6 +104,7 @@
 
 		ret = numa_move_pages(0, TEST_PAGES, pages, NULL, status, 0);
 		TEST_ERRNO = errno;
+
 		if (ret != 0) {
 			tst_resm(TFAIL, "retrieving NUMA nodes failed");
 			free_pages(pages, TEST_PAGES);
@@ -109,7 +114,11 @@
 		verify_pages_linear(pages, status, TEST_PAGES);
 
 		free_pages(pages, TEST_PAGES);
+
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages02.c b/testcases/kernel/syscalls/move_pages/move_pages02.c
index 6c89073..7ccd7af 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages02.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages02.c
@@ -54,7 +54,10 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -73,11 +76,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
-	unsigned int to_node = 1;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -89,6 +88,12 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+	unsigned int to_node = 1;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -123,6 +128,9 @@
 
 		free_pages(pages, TEST_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages03.c b/testcases/kernel/syscalls/move_pages/move_pages03.c
index 05be405..5c58a2c 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages03.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages03.c
@@ -58,7 +58,10 @@
 #include <signal.h>
 #include <semaphore.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -111,11 +114,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
-	unsigned int to_node = 1;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -127,6 +126,12 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+	unsigned int to_node = 1;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -192,6 +197,9 @@
 	      err_free_pages:
 		free_shared_pages(pages, TEST_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages03.mode.sh b/testcases/kernel/syscalls/move_pages/move_pages03.mode.sh
deleted file mode 100755
index c0edac6..0000000
--- a/testcases/kernel/syscalls/move_pages/move_pages03.mode.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-failed() {
-	echo ""
-	echo "             ************** WARNING **************"
-	echo "    Cannot change permission or ownership of \"move_pages03\"."
-	echo "                   Test move_pages03 will fail"
-	echo "                   Run "make install" as root."
-	echo "             *************************************"
-	sleep 2
-}
-
-if [ -f move_pages03 ]; then
-    chown root move_pages03 || failed
-    chmod 04755 move_pages03 || failed
-fi
-
-exit 0
diff --git a/testcases/kernel/syscalls/move_pages/move_pages04.c b/testcases/kernel/syscalls/move_pages/move_pages04.c
index 50e1f4a..3ae2e99 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages04.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages04.c
@@ -56,7 +56,10 @@
 #include <unistd.h>
 #include <signal.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -79,11 +82,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
-	unsigned int to_node = 1;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -95,6 +94,12 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+	unsigned int to_node = 1;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -137,12 +142,15 @@
 			tst_resm(TFAIL, "status[%d] is %d", UNTOUCHED_PAGE,
 				 status[UNTOUCHED_PAGE]);
 
-	      err_free_pages:
-		/* This is capable of freeing both the touched and
-		 * untouched pages.
-		 */
-		free_pages(pages, TEST_PAGES);
+		err_free_pages:
+		    /* This is capable of freeing both the touched and
+		     * untouched pages.
+		     */
+		    free_pages(pages, TEST_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages05.c b/testcases/kernel/syscalls/move_pages/move_pages05.c
index d7ccfd2..13051c9 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages05.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages05.c
@@ -56,7 +56,10 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -112,11 +115,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
-	unsigned int to_node = 1;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -128,6 +127,12 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+	unsigned int to_node = 1;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[N_TEST_PAGES] = { 0 };
@@ -206,6 +211,9 @@
 	      err_free_shared:
 		free_shared_pages(pages + SHARED_PAGE, N_SHARED_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages06.c b/testcases/kernel/syscalls/move_pages/move_pages06.c
index 4702fb1..285dcf3 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages06.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages06.c
@@ -54,7 +54,10 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -73,11 +76,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
-	unsigned int to_node;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -89,6 +88,12 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+	unsigned int to_node;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -119,6 +124,9 @@
 
 		free_pages(pages, TEST_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages07.c b/testcases/kernel/syscalls/move_pages/move_pages07.c
index 060a54e..3032fc9 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages07.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages07.c
@@ -54,7 +54,10 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -73,11 +76,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
-	unsigned int to_node = 1;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -89,6 +88,12 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+	unsigned int to_node = 1;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -130,6 +135,9 @@
 	      err_free_pages:
 		free_pages(pages, TEST_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages08.c b/testcases/kernel/syscalls/move_pages/move_pages08.c
index c285c4d..1b340ee 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages08.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages08.c
@@ -54,7 +54,10 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -73,11 +76,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
-	unsigned int to_node = 1;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -89,6 +88,12 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+	unsigned int to_node = 1;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -118,6 +123,9 @@
 
 		free_pages(pages, TEST_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages09.c b/testcases/kernel/syscalls/move_pages/move_pages09.c
index d53b69a..30c2915 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages09.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages09.c
@@ -54,7 +54,10 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -73,10 +76,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -88,6 +88,11 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -117,6 +122,9 @@
 
 		free_pages(pages, TEST_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages10.c b/testcases/kernel/syscalls/move_pages/move_pages10.c
index b0403e0..b693f03 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages10.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages10.c
@@ -54,7 +54,10 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 
 #include <test.h>
 #include <usctest.h>
@@ -73,11 +76,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
-	unsigned int to_node = 1;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -89,6 +88,12 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+	unsigned int to_node = 1;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -118,6 +123,9 @@
 
 		free_pages(pages, TEST_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages11.c b/testcases/kernel/syscalls/move_pages/move_pages11.c
index 3d6b366..5046a5b 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages11.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages11.c
@@ -57,7 +57,10 @@
 #include <signal.h>
 #include <semaphore.h>
 #include <errno.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
+#endif
 #include <pwd.h>
 
 #include <test.h>
@@ -111,11 +114,7 @@
 
 int main(int argc, char **argv)
 {
-	unsigned int i;
-	int lc;			/* loop counter */
 	char *msg;		/* message returned from parse_opts */
-	unsigned int from_node = 0;
-	unsigned int to_node = 1;
 
 	/* parse standard options */
 	msg = parse_opts(argc, argv, (option_t *) NULL, NULL);
@@ -127,6 +126,12 @@
 
 	setup();
 
+#if HAVE_NUMA_MOVE_PAGES
+	unsigned int i;
+	int lc;			/* loop counter */
+	unsigned int from_node = 0;
+	unsigned int to_node = 1;
+
 	/* check for looping state if -i option is given */
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		void *pages[TEST_PAGES] = { 0 };
@@ -191,6 +196,9 @@
 	      err_free_pages:
 		free_shared_pages(pages, TEST_PAGES);
 	}
+#else
+	tst_resm(TCONF, "move_pages support not found.");
+#endif
 
 	cleanup();
 	/* NOT REACHED */
diff --git a/testcases/kernel/syscalls/move_pages/move_pages11.mode.sh b/testcases/kernel/syscalls/move_pages/move_pages11.mode.sh
deleted file mode 100755
index 9975621..0000000
--- a/testcases/kernel/syscalls/move_pages/move_pages11.mode.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-failed() {
-	echo ""
-	echo "             ************** WARNING **************"
-	echo "    Cannot change permission or ownership of \"move_pages11\"."
-	echo "                   Test move_pages11 will fail"
-	echo "                   Run "make install" as root."
-	echo "             *************************************"
-	sleep 2
-}
-
-if [ -f move_pages11 ]; then
-    chown root move_pages11 || failed
-    chmod 04755 move_pages11 || failed
-fi
-
-exit 0
diff --git a/testcases/kernel/syscalls/move_pages/move_pages_support.c b/testcases/kernel/syscalls/move_pages/move_pages_support.c
index 0d3cfc7..05492d3 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages_support.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages_support.c
@@ -20,8 +20,15 @@
 #include <syscall.h>
 #include <unistd.h>
 #include <semaphore.h>
+#include "config.h"
+#if HAVE_NUMA_H
 #include <numa.h>
-#include <numaif.h>
+#endif
+/*
+ * #if HAVE_NUMAIF_H
+   #include <numaif.h>
+   #endif
+ */
 #include <errno.h>
 
 #include <test.h>
@@ -48,6 +55,8 @@
  */
 void free_pages(void **pages, unsigned int num)
 {
+
+#if HAS_NUMA_H
 	int i;
 	size_t onepage = get_page_size();
 
@@ -56,6 +65,7 @@
 			numa_free(pages[i], onepage);
 		}
 	}
+#endif
 }
 
 /*
@@ -73,7 +83,9 @@
 int alloc_pages_on_nodes(void **pages, unsigned int num, int *nodes)
 {
 	int i;
+#if HAVE_NUMA_ALLOC_ONNODE
 	size_t onepage = get_page_size();
+#endif
 
 	for (i = 0; i < num; i++) {
 		pages[i] = NULL;
@@ -82,7 +94,9 @@
 	for (i = 0; i < num; i++) {
 		char *page;
 
+#if HAVE_NUMA_ALLOC_ONNODE
 		pages[i] = numa_alloc_onnode(onepage, nodes[i]);
+#endif
 		if (pages[i] == NULL) {
 			tst_resm(TBROK, "allocation of page on node "
 				 "%d failed", nodes[i]);
@@ -115,9 +129,11 @@
  */
 int alloc_pages_linear(void **pages, unsigned int num)
 {
+	int nodes[num];
+
+#if HAS_NUMA_H
 	unsigned int i;
 	unsigned int n;
-	int nodes[num];
 
 	n = 0;
 	for (i = 0; i < num; i++) {
@@ -127,6 +143,7 @@
 		if (n > numa_max_node())
 			n = 0;
 	}
+#endif
 
 	return alloc_pages_on_nodes(pages, num, nodes);
 }
@@ -164,6 +181,7 @@
 void
 verify_pages_on_nodes(void **pages, int *status, unsigned int num, int *nodes)
 {
+#if HAVE_NUMA_H
 	unsigned int i;
 	int which_node;
 	int ret;
@@ -196,6 +214,9 @@
 	}
 
 	tst_resm(TPASS, "pages are present in expected nodes");
+#else
+	tst_resm(TCONF, "NUMA support not provided");
+#endif
 }
 
 /*
@@ -206,11 +227,13 @@
  */
 void verify_pages_linear(void **pages, int *status, unsigned int num)
 {
+#if HAS_NUMA_H
 	unsigned int i;
 	unsigned int n;
 	int nodes[num];
 
 	n = 0;
+
 	for (i = 0; i < num; i++) {
 		nodes[i] = i;
 
@@ -220,6 +243,7 @@
 	}
 
 	verify_pages_on_nodes(pages, status, num, nodes);
+#endif
 }
 
 /*
@@ -252,6 +276,7 @@
  */
 int alloc_shared_pages_on_node(void **pages, unsigned int num, int node)
 {
+#if HAS_NUMA_H
 	char *shared;
 	unsigned int i;
 	int nodes[num];
@@ -281,6 +306,9 @@
 	}
 
 	return 0;
+#else
+	return -1;
+#endif
 }
 
 /*
@@ -377,6 +405,7 @@
  */
 void check_config(unsigned int min_nodes)
 {
+#if HAS_NUMA_H
 	if (numa_available() < 0) {
 		tst_resm(TCONF, "NUMA support is not available");
 		tst_exit();
@@ -396,4 +425,8 @@
 		tst_resm(TCONF, "this arch does not support move_pages");
 		tst_exit();
 	}
+#else
+	tst_resm(TCONF, "NUMA support not provided");
+	tst_exit();
+#endif
 }
diff --git a/testcases/kernel/syscalls/move_pages/move_pages_support.h b/testcases/kernel/syscalls/move_pages/move_pages_support.h
index 70b26ab..f760730 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages_support.h
+++ b/testcases/kernel/syscalls/move_pages/move_pages_support.h
@@ -19,7 +19,9 @@
 #ifndef MOVE_PAGES_SUPPORT_H
 #define MOVE_PAGES_SUPPORT_H
 
+#if HAVE_NUMAIF_H
 #include <numaif.h>
+#endif
 #include <semaphore.h>
 
 long get_page_size();
diff --git a/testcases/kernel/syscalls/mprotect/Makefile b/testcases/kernel/syscalls/mprotect/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/mprotect/Makefile
+++ b/testcases/kernel/syscalls/mprotect/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mq_notify/Makefile b/testcases/kernel/syscalls/mq_notify/Makefile
index 8f836a0..2e1628e 100644
--- a/testcases/kernel/syscalls/mq_notify/Makefile
+++ b/testcases/kernel/syscalls/mq_notify/Makefile
@@ -16,16 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2 -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
-LDLIBS += -L../../../../lib -lltp -lrt
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CPPFLAGS		?= -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
+LDLIBS			+= -lpthread -lrt
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mq_open/Makefile b/testcases/kernel/syscalls/mq_open/Makefile
index e7168a7..71ebae9 100644
--- a/testcases/kernel/syscalls/mq_open/Makefile
+++ b/testcases/kernel/syscalls/mq_open/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2
-LDLIBS += -L../../../../lib -lltp -lrt
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lpthread -lrt
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mq_timedreceive/Makefile b/testcases/kernel/syscalls/mq_timedreceive/Makefile
index 8f836a0..2e1628e 100644
--- a/testcases/kernel/syscalls/mq_timedreceive/Makefile
+++ b/testcases/kernel/syscalls/mq_timedreceive/Makefile
@@ -16,16 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2 -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
-LDLIBS += -L../../../../lib -lltp -lrt
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CPPFLAGS		?= -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
+LDLIBS			+= -lpthread -lrt
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mq_timedsend/Makefile b/testcases/kernel/syscalls/mq_timedsend/Makefile
index e7168a7..71ebae9 100644
--- a/testcases/kernel/syscalls/mq_timedsend/Makefile
+++ b/testcases/kernel/syscalls/mq_timedsend/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2
-LDLIBS += -L../../../../lib -lltp -lrt
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lpthread -lrt
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mq_unlink/Makefile b/testcases/kernel/syscalls/mq_unlink/Makefile
index e7168a7..2e1628e 100644
--- a/testcases/kernel/syscalls/mq_unlink/Makefile
+++ b/testcases/kernel/syscalls/mq_unlink/Makefile
@@ -16,16 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2
-LDLIBS += -L../../../../lib -lltp -lrt
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CPPFLAGS		?= -D_POSIX_C_SOURCE=$(shell getconf _POSIX_MESSAGE_PASSING)L
+LDLIBS			+= -lpthread -lrt
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/mremap/Makefile b/testcases/kernel/syscalls/mremap/Makefile
index 28ebaaa..e998784 100644
--- a/testcases/kernel/syscalls/mremap/Makefile
+++ b/testcases/kernel/syscalls/mremap/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -L../ipc -lipc
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lipc
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/msync/Makefile b/testcases/kernel/syscalls/msync/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/msync/Makefile
+++ b/testcases/kernel/syscalls/msync/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/munlock/Makefile b/testcases/kernel/syscalls/munlock/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/munlock/Makefile
+++ b/testcases/kernel/syscalls/munlock/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/munlockall/Makefile b/testcases/kernel/syscalls/munlockall/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/munlockall/Makefile
+++ b/testcases/kernel/syscalls/munlockall/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/munmap/Makefile b/testcases/kernel/syscalls/munmap/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/munmap/Makefile
+++ b/testcases/kernel/syscalls/munmap/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/nanosleep/Makefile b/testcases/kernel/syscalls/nanosleep/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/nanosleep/Makefile
+++ b/testcases/kernel/syscalls/nanosleep/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/newuname/Makefile b/testcases/kernel/syscalls/newuname/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/newuname/Makefile
+++ b/testcases/kernel/syscalls/newuname/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/nftw/Makefile b/testcases/kernel/syscalls/nftw/Makefile
index 61b12ac..3873f37 100644
--- a/testcases/kernel/syscalls/nftw/Makefile
+++ b/testcases/kernel/syscalls/nftw/Makefile
@@ -14,34 +14,24 @@
 # other person.  No title to or ownership of the software is
 # hereby transferred.
 
-LINT =		lint
-CFLAGS+=        -Wall -g -ansi -O -DLINUX -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -I../../../../include 
-SRCS1 =		nftw.c tools.c test_func.c test.c lib.c
-OBJS1 =		nftw.o tools.o test_func.o test.o lib.o 
-SRCS2 =		nftw64.c tools64.c test_func64.c test64.c lib64.c
-OBJS2 =		nftw64.o tools64.o test_func64.o test64.o lib64.o 
-BINS= 		nftw01  nftw6401
+top_srcdir		?= ../../../..
 
-all:		nftw01 nftw6401
+include $(top_srcdir)/include/mk/testcases.mk
 
-nftw01:	$(&)	nftw.h $(OBJS1) ../../../../include/test.h ../../../../include/usctest.h ../../../../lib/libltp.a
-	$(CC) $(CFLAGS) -o nftw01 $(OBJS1) $(LDFLAGS) ../../../../lib/libltp.a
+CPPFLAGS		+= -ansi -DLINUX -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE
 
-nftw6401:$(&)	nftw64.h $(OBJS2) ../../../../include/test.h ../../../../include/usctest.h ../../../../lib/libltp.a
-	$(CC) $(CFLAGS) -o nftw6401 $(OBJS2) $(LDFLAGS) ../../../../lib/libltp.a
+MAKE_TARGETS		:= nftw01 nftw6401
 
-remove_bin:
-	rm -f $(BINS) $(OBJS1) $(OBJS2)
+nftw01: CPPFLAGS += -D_LARGEFILE_SOURCE
 
-remove_obj:
-	rm -f $(OBJS1)
-	rm -f $(OBJS2)
+nftw01: nftw.o tools.o test_func.o test.o lib.o 
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o "$@"
 
-clean:	remove_bin remove_obj 
+nftw64.o tools64.o test_func64.o test64.o lib64.o: %.o: %.c
 
-lint:
-	$(LINT) -mnuts $(SRCS1) 
-	$(LINT) -mnuts $(SRCS2) 
+%64.o: CPPFLAGS += -D_LARGEFILE64_SOURCE
 
-install: 
-	ln -f $(BINS) ../../../bin
+nftw6401: nftw64.o tools64.o test_func64.o test64.o lib64.o
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/nftw/nftw.c b/testcases/kernel/syscalls/nftw/nftw.c
index 2f4a9f6..801f5a3 100644
--- a/testcases/kernel/syscalls/nftw/nftw.c
+++ b/testcases/kernel/syscalls/nftw/nftw.c
@@ -17,8 +17,8 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
-/* 10/31/2002   Port to LTP	robbiew@us.ibm.com */
-/* 06/30/2001	Port to Linux	nsharoff@us.ibm.com */
+/* 10/31/2002   Port to LTP     robbiew@us.ibm.com */
+/* 06/30/2001   Port to Linux   nsharoff@us.ibm.com */
 
 /*
  * NAME
@@ -48,7 +48,6 @@
 extern int Tst_count;		/* Test Case counter for tst_* routines */
 
 struct passwd *ltpuser;		/* password struct for ltpuser */
-
 /**************/
 
 /* Used for error return for some library routines */
@@ -242,7 +241,7 @@
 	{"FTW_DNR", FTW_DNR},
 	{"FTW_NS", FTW_NS},
 	{"FTW_SL", FTW_SL},
-#ifndef LINUX
+#ifndef __linux__
 /* How do we define __USE_XOPEN_EXTENDED ? Following depends on that */
 	{"FTW_DP", FTW_DP},
 	{"FTW_SLN", FTW_SLN},
@@ -252,11 +251,7 @@
 int npathdats, ngoods, nbads, nmnem;
 
 /*--------------------------------------------------------------*/
-#ifdef LINUX
 int
-#else
-void
-#endif
 main(void)
 {
 	setup();		/* temp file is now open        */
diff --git a/testcases/kernel/syscalls/nftw/nftw64.c b/testcases/kernel/syscalls/nftw/nftw64.c
index 6689f4b..4941065 100644
--- a/testcases/kernel/syscalls/nftw/nftw64.c
+++ b/testcases/kernel/syscalls/nftw/nftw64.c
@@ -248,11 +248,7 @@
 int npathdats, ngoods, nbads, nmnem;
 
 /*--------------------------------------------------------------*/
-#ifdef LINUX
 int
-#else
-void
-#endif
 main(void)
 {
 	setup();		/* temp file is now open        */
diff --git a/testcases/kernel/syscalls/nice/Makefile b/testcases/kernel/syscalls/nice/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/nice/Makefile
+++ b/testcases/kernel/syscalls/nice/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/open/Makefile b/testcases/kernel/syscalls/open/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/open/Makefile
+++ b/testcases/kernel/syscalls/open/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/openat/Makefile b/testcases/kernel/syscalls/openat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/openat/Makefile
+++ b/testcases/kernel/syscalls/openat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/paging/Makefile b/testcases/kernel/syscalls/paging/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/paging/Makefile
+++ b/testcases/kernel/syscalls/paging/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/pathconf/Makefile b/testcases/kernel/syscalls/pathconf/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/pathconf/Makefile
+++ b/testcases/kernel/syscalls/pathconf/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/pause/Makefile b/testcases/kernel/syscalls/pause/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/pause/Makefile
+++ b/testcases/kernel/syscalls/pause/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/pcllib/Makefile.in b/testcases/kernel/syscalls/pcllib/Makefile.in
index ba2e751..6bb3748 100644
--- a/testcases/kernel/syscalls/pcllib/Makefile.in
+++ b/testcases/kernel/syscalls/pcllib/Makefile.in
@@ -66,18 +66,26 @@
 OBJEXT = @OBJEXT@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 AMTAR = @AMTAR@
+AR = @AR@
 AS = @AS@
 AWK = @AWK@
 CC = @CC@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
 DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 ECHO = @ECHO@
+EGREP = @EGREP@
+F77 = @F77@
+GCJ = @GCJ@
+GCJFLAGS = @GCJFLAGS@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
+RC = @RC@
 STRIP = @STRIP@
 VERSION = @VERSION@
 am__include = @am__include@
diff --git a/testcases/kernel/syscalls/pcllib/config.h.in b/testcases/kernel/syscalls/pcllib/config.h.in
index cdc46eb..cb7b78e 100644
--- a/testcases/kernel/syscalls/pcllib/config.h.in
+++ b/testcases/kernel/syscalls/pcllib/config.h.in
@@ -91,9 +91,11 @@
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
-/* Define as `__inline' if that's what the C compiler calls it, or to nothing
-   if it is not supported. */
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
 #undef inline
+#endif
 
 /* Define to empty if the keyword `volatile' does not work. Warning: valid
    code using `volatile' can become incorrect without. Disable with care. */
diff --git a/testcases/kernel/syscalls/pcllib/configure b/testcases/kernel/syscalls/pcllib/configure
index 3cf255b..82e26fa 100755
--- a/testcases/kernel/syscalls/pcllib/configure
+++ b/testcases/kernel/syscalls/pcllib/configure
Binary files differ
diff --git a/testcases/kernel/syscalls/pcllib/pcl/Makefile.in b/testcases/kernel/syscalls/pcllib/pcl/Makefile.in
index 2d73ba9..751823e 100644
--- a/testcases/kernel/syscalls/pcllib/pcl/Makefile.in
+++ b/testcases/kernel/syscalls/pcllib/pcl/Makefile.in
@@ -66,18 +66,26 @@
 OBJEXT = @OBJEXT@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 AMTAR = @AMTAR@
+AR = @AR@
 AS = @AS@
 AWK = @AWK@
 CC = @CC@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
 DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 ECHO = @ECHO@
+EGREP = @EGREP@
+F77 = @F77@
+GCJ = @GCJ@
+GCJFLAGS = @GCJFLAGS@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
+RC = @RC@
 STRIP = @STRIP@
 VERSION = @VERSION@
 am__include = @am__include@
diff --git a/testcases/kernel/syscalls/pcllib/test/Makefile.in b/testcases/kernel/syscalls/pcllib/test/Makefile.in
index 792f6b3..4b17caf 100644
--- a/testcases/kernel/syscalls/pcllib/test/Makefile.in
+++ b/testcases/kernel/syscalls/pcllib/test/Makefile.in
@@ -66,18 +66,26 @@
 OBJEXT = @OBJEXT@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 AMTAR = @AMTAR@
+AR = @AR@
 AS = @AS@
 AWK = @AWK@
 CC = @CC@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
 DEPDIR = @DEPDIR@
 DLLTOOL = @DLLTOOL@
 ECHO = @ECHO@
+EGREP = @EGREP@
+F77 = @F77@
+GCJ = @GCJ@
+GCJFLAGS = @GCJFLAGS@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
+RC = @RC@
 STRIP = @STRIP@
 VERSION = @VERSION@
 am__include = @am__include@
diff --git a/testcases/kernel/syscalls/personality/Makefile b/testcases/kernel/syscalls/personality/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/personality/Makefile
+++ b/testcases/kernel/syscalls/personality/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/pipe/Makefile b/testcases/kernel/syscalls/pipe/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/pipe/Makefile
+++ b/testcases/kernel/syscalls/pipe/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/pipe2/Makefile b/testcases/kernel/syscalls/pipe2/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/pipe2/Makefile
+++ b/testcases/kernel/syscalls/pipe2/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/poll/Makefile b/testcases/kernel/syscalls/poll/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/poll/Makefile
+++ b/testcases/kernel/syscalls/poll/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ppoll/Makefile b/testcases/kernel/syscalls/ppoll/Makefile
index 0d24c35..2ef86f0 100644
--- a/testcases/kernel/syscalls/ppoll/Makefile
+++ b/testcases/kernel/syscalls/ppoll/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2
-LDLIBS += -L../../../../lib -lltp 
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/prctl/Makefile b/testcases/kernel/syscalls/prctl/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/prctl/Makefile
+++ b/testcases/kernel/syscalls/prctl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/pread/Makefile b/testcases/kernel/syscalls/pread/Makefile
index 3c22a28..c006930 100644
--- a/testcases/kernel/syscalls/pread/Makefile
+++ b/testcases/kernel/syscalls/pread/Makefile
@@ -16,19 +16,12 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
diff --git a/testcases/kernel/syscalls/profil/Makefile b/testcases/kernel/syscalls/profil/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/profil/Makefile
+++ b/testcases/kernel/syscalls/profil/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/pselect/Makefile b/testcases/kernel/syscalls/pselect/Makefile
index 07248d4..c006930 100644
--- a/testcases/kernel/syscalls/pselect/Makefile
+++ b/testcases/kernel/syscalls/pselect/Makefile
@@ -16,21 +16,12 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
diff --git a/testcases/kernel/syscalls/ptrace/Makefile b/testcases/kernel/syscalls/ptrace/Makefile
index 57b05a6..062044f 100644
--- a/testcases/kernel/syscalls/ptrace/Makefile
+++ b/testcases/kernel/syscalls/ptrace/Makefile
@@ -16,16 +16,14 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *[^6].c)
-TARGETS = $(patsubst ptrace%.c,ptrace%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+# ptrace06 is a broken test ; it hangs the target consistently, chewing up CPU.
+# See: `Issue 3 - ptrace06 hung for 7 hours' --
+# http://sourceforge.net/mailarchive/forum.php?thread_name=364299f40910062300s65c43c93w9cccdfe8835c2334%40mail.gmail.com&forum_name=ltp-list
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+MAKE_TARGETS		:= $(filter-out ptrace06,$(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)))
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ptrace/ptrace06.c b/testcases/kernel/syscalls/ptrace/ptrace06.c
index f0a84e9..9df707f 100644
--- a/testcases/kernel/syscalls/ptrace/ptrace06.c
+++ b/testcases/kernel/syscalls/ptrace/ptrace06.c
@@ -23,6 +23,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "spawn_ptrace_child.h"
+#include "config.h"
 
 /* this should be sizeof(struct user), but that info is only found
  * in the kernel asm/user.h which is not exported to userspace.
@@ -140,6 +141,7 @@
 	{ PTRACE_SETFGREGS, .data = -4 },
 #endif
 
+#if HAVE_DECL_PTRACE_GETSIGINFO
 	{ PTRACE_GETSIGINFO, .data = 0 },
 	{ PTRACE_GETSIGINFO, .data = 1 },
 	{ PTRACE_GETSIGINFO, .data = 2 },
@@ -148,7 +150,9 @@
 	{ PTRACE_GETSIGINFO, .data = -2 },
 	{ PTRACE_GETSIGINFO, .data = -3 },
 	{ PTRACE_GETSIGINFO, .data = -4 },
-
+#endif
+	
+#if HAVE_DECL_PTRACE_SETSIGINFO
 	{ PTRACE_SETSIGINFO, .data = 0 },
 	{ PTRACE_SETSIGINFO, .data = 1 },
 	{ PTRACE_SETSIGINFO, .data = 2 },
@@ -157,6 +161,7 @@
 	{ PTRACE_SETSIGINFO, .data = -2 },
 	{ PTRACE_SETSIGINFO, .data = -3 },
 	{ PTRACE_SETSIGINFO, .data = -4 },
+#endif
 };
 
 int TST_TOTAL = ARRAY_SIZE(test_cases);
diff --git a/testcases/kernel/syscalls/pwrite/Makefile b/testcases/kernel/syscalls/pwrite/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/pwrite/Makefile
+++ b/testcases/kernel/syscalls/pwrite/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/quotactl/Makefile b/testcases/kernel/syscalls/quotactl/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/quotactl/Makefile
+++ b/testcases/kernel/syscalls/quotactl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index f410948..c175a83 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -43,9 +43,18 @@
 #include <stdio.h>
 #include <errno.h>
 #include <linux/fs.h>
-#include <sys/quota.h>
 #include <sys/types.h>
-
+#include "config.h"
+#if HAS_NEW_QUOTACTL
+#include <sys/quota.h>
+#elif HAS_OLD_QUOTACTL
+#include <linux/quota.h>
+#include <xfs/xqm.h>
+#include <linux/dqblk_v1.h>
+#include <linux/dqblk_v2.h>
+#else
+#define BROKEN_QUOTACTL 1
+#endif
 
 /* Harness Specific Include Files. */
 #include "test.h"
@@ -121,6 +130,14 @@
 * To use this testcase , the quota function must be turned on and the user must be * the super user
 */
 
+
+#if BROKEN_QUOTACTL
+int
+main(void) {
+	tst_resm(TBROK, "The copy of quotactl is broken/missing on this system");
+	tst_exit();
+}
+#else
 int cmd[] = {Q_QUOTAON, Q_QUOTAOFF, Q_GETQUOTA, Q_SETQUOTA, Q_GETINFO, Q_SETINFO, Q_GETFMT, Q_SYNC};
 int retval = 0, id = 0, i = 0;
 
@@ -165,4 +182,4 @@
         cleanup();
 	tst_exit();
 }
-
+#endif
diff --git a/testcases/kernel/syscalls/read/Makefile b/testcases/kernel/syscalls/read/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/read/Makefile
+++ b/testcases/kernel/syscalls/read/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/readdir/Makefile b/testcases/kernel/syscalls/readdir/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/readdir/Makefile
+++ b/testcases/kernel/syscalls/readdir/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/readlink/Makefile b/testcases/kernel/syscalls/readlink/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/readlink/Makefile
+++ b/testcases/kernel/syscalls/readlink/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/readlinkat/Makefile b/testcases/kernel/syscalls/readlinkat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/readlinkat/Makefile
+++ b/testcases/kernel/syscalls/readlinkat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/readv/Makefile b/testcases/kernel/syscalls/readv/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/readv/Makefile
+++ b/testcases/kernel/syscalls/readv/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/reboot/Makefile b/testcases/kernel/syscalls/reboot/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/reboot/Makefile
+++ b/testcases/kernel/syscalls/reboot/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/recv/Makefile b/testcases/kernel/syscalls/recv/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/recv/Makefile
+++ b/testcases/kernel/syscalls/recv/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/recvfrom/Makefile b/testcases/kernel/syscalls/recvfrom/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/recvfrom/Makefile
+++ b/testcases/kernel/syscalls/recvfrom/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/recvmsg/Makefile b/testcases/kernel/syscalls/recvmsg/Makefile
index 484a8e5..bd617d8 100644
--- a/testcases/kernel/syscalls/recvmsg/Makefile
+++ b/testcases/kernel/syscalls/recvmsg/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -g
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/remap_file_pages/Makefile b/testcases/kernel/syscalls/remap_file_pages/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/remap_file_pages/Makefile
+++ b/testcases/kernel/syscalls/remap_file_pages/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/rename/Makefile b/testcases/kernel/syscalls/rename/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/rename/Makefile
+++ b/testcases/kernel/syscalls/rename/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/renameat/Makefile b/testcases/kernel/syscalls/renameat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/renameat/Makefile
+++ b/testcases/kernel/syscalls/renameat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/rmdir/Makefile b/testcases/kernel/syscalls/rmdir/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/rmdir/Makefile
+++ b/testcases/kernel/syscalls/rmdir/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/rt_sigaction/Makefile b/testcases/kernel/syscalls/rt_sigaction/Makefile
index ecdce09..2ef86f0 100644
--- a/testcases/kernel/syscalls/rt_sigaction/Makefile
+++ b/testcases/kernel/syscalls/rt_sigaction/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2 -W
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/rt_sigprocmask/Makefile b/testcases/kernel/syscalls/rt_sigprocmask/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/rt_sigprocmask/Makefile
+++ b/testcases/kernel/syscalls/rt_sigprocmask/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/rt_sigqueueinfo/Makefile b/testcases/kernel/syscalls/rt_sigqueueinfo/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/rt_sigqueueinfo/Makefile
+++ b/testcases/kernel/syscalls/rt_sigqueueinfo/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/rt_sigsuspend/Makefile b/testcases/kernel/syscalls/rt_sigsuspend/Makefile
index 38c65f5..2ef86f0 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/Makefile
+++ b/testcases/kernel/syscalls/rt_sigsuspend/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -g
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sbrk/Makefile b/testcases/kernel/syscalls/sbrk/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sbrk/Makefile
+++ b/testcases/kernel/syscalls/sbrk/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sched_get_priority_max/Makefile b/testcases/kernel/syscalls/sched_get_priority_max/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sched_get_priority_max/Makefile
+++ b/testcases/kernel/syscalls/sched_get_priority_max/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sched_get_priority_min/Makefile b/testcases/kernel/syscalls/sched_get_priority_min/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sched_get_priority_min/Makefile
+++ b/testcases/kernel/syscalls/sched_get_priority_min/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sched_getaffinity/Makefile b/testcases/kernel/syscalls/sched_getaffinity/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/sched_getaffinity/Makefile
+++ b/testcases/kernel/syscalls/sched_getaffinity/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sched_getparam/Makefile b/testcases/kernel/syscalls/sched_getparam/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sched_getparam/Makefile
+++ b/testcases/kernel/syscalls/sched_getparam/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sched_getscheduler/Makefile b/testcases/kernel/syscalls/sched_getscheduler/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sched_getscheduler/Makefile
+++ b/testcases/kernel/syscalls/sched_getscheduler/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/Makefile b/testcases/kernel/syscalls/sched_rr_get_interval/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/Makefile
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sched_setparam/Makefile b/testcases/kernel/syscalls/sched_setparam/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sched_setparam/Makefile
+++ b/testcases/kernel/syscalls/sched_setparam/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sched_setscheduler/Makefile b/testcases/kernel/syscalls/sched_setscheduler/Makefile
index 9b3299f..bd617d8 100644
--- a/testcases/kernel/syscalls/sched_setscheduler/Makefile
+++ b/testcases/kernel/syscalls/sched_setscheduler/Makefile
@@ -16,17 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
+include $(top_srcdir)/include/mk/testcases.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sched_yield/Makefile b/testcases/kernel/syscalls/sched_yield/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sched_yield/Makefile
+++ b/testcases/kernel/syscalls/sched_yield/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/select/Makefile b/testcases/kernel/syscalls/select/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/select/Makefile
+++ b/testcases/kernel/syscalls/select/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/send/Makefile b/testcases/kernel/syscalls/send/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/send/Makefile
+++ b/testcases/kernel/syscalls/send/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sendfile/Makefile b/testcases/kernel/syscalls/sendfile/Makefile
index a324fda..df7b63f 100644
--- a/testcases/kernel/syscalls/sendfile/Makefile
+++ b/testcases/kernel/syscalls/sendfile/Makefile
@@ -16,20 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64 -DOFF_T=__off64_t
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64 -DOFF_T=__off64_t
 
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sendmsg/Makefile b/testcases/kernel/syscalls/sendmsg/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sendmsg/Makefile
+++ b/testcases/kernel/syscalls/sendmsg/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sendto/Makefile b/testcases/kernel/syscalls/sendto/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sendto/Makefile
+++ b/testcases/kernel/syscalls/sendto/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/set_robust_list/Makefile b/testcases/kernel/syscalls/set_robust_list/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/set_robust_list/Makefile
+++ b/testcases/kernel/syscalls/set_robust_list/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/set_thread_area/Makefile b/testcases/kernel/syscalls/set_thread_area/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/set_thread_area/Makefile
+++ b/testcases/kernel/syscalls/set_thread_area/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/set_tid_address/Makefile b/testcases/kernel/syscalls/set_tid_address/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/set_tid_address/Makefile
+++ b/testcases/kernel/syscalls/set_tid_address/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setdomainname/Makefile b/testcases/kernel/syscalls/setdomainname/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/setdomainname/Makefile
+++ b/testcases/kernel/syscalls/setdomainname/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setegid/Makefile b/testcases/kernel/syscalls/setegid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/setegid/Makefile
+++ b/testcases/kernel/syscalls/setegid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setfsgid/Makefile b/testcases/kernel/syscalls/setfsgid/Makefile
index b59851c..f3ab657 100644
--- a/testcases/kernel/syscalls/setfsgid/Makefile
+++ b/testcases/kernel/syscalls/setfsgid/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setfsuid/Makefile b/testcases/kernel/syscalls/setfsuid/Makefile
index b59851c..f3ab657 100644
--- a/testcases/kernel/syscalls/setfsuid/Makefile
+++ b/testcases/kernel/syscalls/setfsuid/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setgid/Makefile b/testcases/kernel/syscalls/setgid/Makefile
index dc7ac89..ad6b9f5 100644
--- a/testcases/kernel/syscalls/setgid/Makefile
+++ b/testcases/kernel/syscalls/setgid/Makefile
@@ -16,19 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -I../utils -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
 
-SRCS    = $(wildcard *.c) 
-TARGETS += $(patsubst %.c,%,$(SRCS))
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
 
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setgroups/Makefile b/testcases/kernel/syscalls/setgroups/Makefile
index 2067f28..ad6b9f5 100644
--- a/testcases/kernel/syscalls/setgroups/Makefile
+++ b/testcases/kernel/syscalls/setgroups/Makefile
@@ -16,18 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -I../utils -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+CPPFLAGS		+= -I$(abs_srcdir)/../utils
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sethostname/Makefile b/testcases/kernel/syscalls/sethostname/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sethostname/Makefile
+++ b/testcases/kernel/syscalls/sethostname/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setitimer/Makefile b/testcases/kernel/syscalls/setitimer/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/setitimer/Makefile
+++ b/testcases/kernel/syscalls/setitimer/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setpgid/Makefile b/testcases/kernel/syscalls/setpgid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/setpgid/Makefile
+++ b/testcases/kernel/syscalls/setpgid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setpgrp/Makefile b/testcases/kernel/syscalls/setpgrp/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/setpgrp/Makefile
+++ b/testcases/kernel/syscalls/setpgrp/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setpriority/Makefile b/testcases/kernel/syscalls/setpriority/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/setpriority/Makefile
+++ b/testcases/kernel/syscalls/setpriority/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setregid/Makefile b/testcases/kernel/syscalls/setregid/Makefile
index b59851c..f3ab657 100644
--- a/testcases/kernel/syscalls/setregid/Makefile
+++ b/testcases/kernel/syscalls/setregid/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setresgid/Makefile b/testcases/kernel/syscalls/setresgid/Makefile
index b59851c..f3ab657 100644
--- a/testcases/kernel/syscalls/setresgid/Makefile
+++ b/testcases/kernel/syscalls/setresgid/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setresuid/Makefile b/testcases/kernel/syscalls/setresuid/Makefile
index b59851c..f3ab657 100644
--- a/testcases/kernel/syscalls/setresuid/Makefile
+++ b/testcases/kernel/syscalls/setresuid/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setreuid/Makefile b/testcases/kernel/syscalls/setreuid/Makefile
index b59851c..f3ab657 100644
--- a/testcases/kernel/syscalls/setreuid/Makefile
+++ b/testcases/kernel/syscalls/setreuid/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setrlimit/Makefile b/testcases/kernel/syscalls/setrlimit/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/setrlimit/Makefile
+++ b/testcases/kernel/syscalls/setrlimit/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setsid/Makefile b/testcases/kernel/syscalls/setsid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/setsid/Makefile
+++ b/testcases/kernel/syscalls/setsid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setsockopt/Makefile b/testcases/kernel/syscalls/setsockopt/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/setsockopt/Makefile
+++ b/testcases/kernel/syscalls/setsockopt/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/settimeofday/Makefile b/testcases/kernel/syscalls/settimeofday/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/settimeofday/Makefile
+++ b/testcases/kernel/syscalls/settimeofday/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setuid/Makefile b/testcases/kernel/syscalls/setuid/Makefile
index b59851c..f3ab657 100644
--- a/testcases/kernel/syscalls/setuid/Makefile
+++ b/testcases/kernel/syscalls/setuid/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/compat_16.mk
-
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/compat_16.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sgetmask/Makefile b/testcases/kernel/syscalls/sgetmask/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/sgetmask/Makefile
+++ b/testcases/kernel/syscalls/sgetmask/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigaction/Makefile b/testcases/kernel/syscalls/sigaction/Makefile
index b6c34e2..d4924c4 100644
--- a/testcases/kernel/syscalls/sigaction/Makefile
+++ b/testcases/kernel/syscalls/sigaction/Makefile
@@ -16,20 +16,12 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
-CFLAGS += -DGLIBC_SIGACTION_BUG=1 -D_GNU_SOURCE
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CFLAGS			+= -DGLIBC_SIGACTION_BUG=1 -D_GNU_SOURCE
 
-sigaction01:
-	$(CC) -o sigaction01 sigaction01.c $(CFLAGS) $(LDFLAGS) $(LDLIBS) -lpthread $(LOADLIBES2)
+LDLIBS			+= -lpthread
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigaltstack/Makefile b/testcases/kernel/syscalls/sigaltstack/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sigaltstack/Makefile
+++ b/testcases/kernel/syscalls/sigaltstack/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sighold/Makefile b/testcases/kernel/syscalls/sighold/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sighold/Makefile
+++ b/testcases/kernel/syscalls/sighold/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/signal/Makefile b/testcases/kernel/syscalls/signal/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/signal/Makefile
+++ b/testcases/kernel/syscalls/signal/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/signalfd/Makefile b/testcases/kernel/syscalls/signalfd/Makefile
index cf5a156..bd617d8 100644
--- a/testcases/kernel/syscalls/signalfd/Makefile
+++ b/testcases/kernel/syscalls/signalfd/Makefile
@@ -15,16 +15,9 @@
 #  along with this program;  if not, write to the Free Software
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/signalfd4/Makefile b/testcases/kernel/syscalls/signalfd4/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/signalfd4/Makefile
+++ b/testcases/kernel/syscalls/signalfd4/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigpending/Makefile b/testcases/kernel/syscalls/sigpending/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sigpending/Makefile
+++ b/testcases/kernel/syscalls/sigpending/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigprocmask/Makefile b/testcases/kernel/syscalls/sigprocmask/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sigprocmask/Makefile
+++ b/testcases/kernel/syscalls/sigprocmask/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigrelse/Makefile b/testcases/kernel/syscalls/sigrelse/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sigrelse/Makefile
+++ b/testcases/kernel/syscalls/sigrelse/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigreturn/Makefile b/testcases/kernel/syscalls/sigreturn/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/sigreturn/Makefile
+++ b/testcases/kernel/syscalls/sigreturn/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigsuspend/Makefile b/testcases/kernel/syscalls/sigsuspend/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sigsuspend/Makefile
+++ b/testcases/kernel/syscalls/sigsuspend/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/socket/Makefile b/testcases/kernel/syscalls/socket/Makefile
index ad5008c..96d779a 100644
--- a/testcases/kernel/syscalls/socket/Makefile
+++ b/testcases/kernel/syscalls/socket/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -lpthread
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lpthread
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/socketcall/Makefile b/testcases/kernel/syscalls/socketcall/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/socketcall/Makefile
+++ b/testcases/kernel/syscalls/socketcall/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/socketpair/Makefile b/testcases/kernel/syscalls/socketpair/Makefile
index ad5008c..bd457ff 100644
--- a/testcases/kernel/syscalls/socketpair/Makefile
+++ b/testcases/kernel/syscalls/socketpair/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp -lpthread
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS 			+= -lpthread
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sockioctl/Makefile b/testcases/kernel/syscalls/sockioctl/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sockioctl/Makefile
+++ b/testcases/kernel/syscalls/sockioctl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/splice/Makefile b/testcases/kernel/syscalls/splice/Makefile
index 3f66038..bd617d8 100644
--- a/testcases/kernel/syscalls/splice/Makefile
+++ b/testcases/kernel/syscalls/splice/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ssetmask/Makefile b/testcases/kernel/syscalls/ssetmask/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/ssetmask/Makefile
+++ b/testcases/kernel/syscalls/ssetmask/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/stat/Makefile b/testcases/kernel/syscalls/stat/Makefile
index 3c22a28..bf12010 100644
--- a/testcases/kernel/syscalls/stat/Makefile
+++ b/testcases/kernel/syscalls/stat/Makefile
@@ -16,19 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/statfs/Makefile b/testcases/kernel/syscalls/statfs/Makefile
index 3c22a28..bf12010 100644
--- a/testcases/kernel/syscalls/statfs/Makefile
+++ b/testcases/kernel/syscalls/statfs/Makefile
@@ -16,19 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/statvfs/Makefile b/testcases/kernel/syscalls/statvfs/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/statvfs/Makefile
+++ b/testcases/kernel/syscalls/statvfs/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/stime/Makefile b/testcases/kernel/syscalls/stime/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/stime/Makefile
+++ b/testcases/kernel/syscalls/stime/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/string/Makefile b/testcases/kernel/syscalls/string/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/string/Makefile
+++ b/testcases/kernel/syscalls/string/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/swapoff/Makefile b/testcases/kernel/syscalls/swapoff/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/swapoff/Makefile
+++ b/testcases/kernel/syscalls/swapoff/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/swapon/Makefile b/testcases/kernel/syscalls/swapon/Makefile
index 42770f2..7ff50f1 100644
--- a/testcases/kernel/syscalls/swapon/Makefile
+++ b/testcases/kernel/syscalls/swapon/Makefile
@@ -16,22 +16,13 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-NEEDSPECIAL:=$(shell echo MAX_SWAPFILES | $(CC) -E -xc -include linux/swap.h 2>/dev/null - | tail -n 1 | grep 32; echo $?)
-ifeq ($(strip $(NEEDSPECIAL)),)
-export CFLAGS+=-I../../../../include -g -Wall
-else
-export CFLAGS+=-I../../../../include -g -Wall -DOLDER_DISTRO_RELEASE
+NEEDSPECIAL	:= $(shell echo MAX_SWAPFILES | $(CC) -E -xc -include linux/swap.h 2>/dev/null - | tail -n 1 | grep 32; echo $?)
+ifneq ($(strip $(NEEDSPECIAL)),)
+export CFLAGS	+= -DOLDER_DISTRO_RELEASE
 endif
 
-LDLIBS+=	-L../../../../lib -lltp 
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/switch/Makefile b/testcases/kernel/syscalls/switch/Makefile
index 9acf426..504042e 100644
--- a/testcases/kernel/syscalls/switch/Makefile
+++ b/testcases/kernel/syscalls/switch/Makefile
@@ -1,32 +1,23 @@
-#################################################################################
-#  Copyright (c) International Business Machines  Corp., 2008                   #
-#                                                                               #
-#  This program is free software;  you can redistribute it and/or modify        #
-#  it under the terms of the GNU General Public License as published by         #
-#  the Free Software Foundation; either version 2 of the License, or            #
-#  (at your option) any later version.                                          #
-#                                                                               #
-#  This program is distributed in the hope that it will be useful,              #
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of              #
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                    #
-#  the GNU General Public License for more details.                             #
-#                                                                               #
-#  You should have received a copy of the GNU General Public License            #
-#  along with this program;  if not, write to the Free Software                 #
-#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA   # 
-#################################################################################
+#
+#  Copyright (c) International Business Machines  Corp., 2008
+#
+#  This program is free software;  you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+#  the GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program;  if not, write to the Free Software
+#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
 
+top_srcdir		?= ../../../..
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS+=	-L../../../../lib -lltp 
+include $(top_srcdir)/include/mk/testcases.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/symlink/Makefile b/testcases/kernel/syscalls/symlink/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/symlink/Makefile
+++ b/testcases/kernel/syscalls/symlink/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/symlinkat/Makefile b/testcases/kernel/syscalls/symlinkat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/symlinkat/Makefile
+++ b/testcases/kernel/syscalls/symlinkat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sync/Makefile b/testcases/kernel/syscalls/sync/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sync/Makefile
+++ b/testcases/kernel/syscalls/sync/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sync_file_range/Makefile b/testcases/kernel/syscalls/sync_file_range/Makefile
index 0353bbf..bd617d8 100644
--- a/testcases/kernel/syscalls/sync_file_range/Makefile
+++ b/testcases/kernel/syscalls/sync_file_range/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)             
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/syscall/Makefile b/testcases/kernel/syscalls/syscall/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/syscall/Makefile
+++ b/testcases/kernel/syscalls/syscall/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sysconf/Makefile b/testcases/kernel/syscalls/sysconf/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sysconf/Makefile
+++ b/testcases/kernel/syscalls/sysconf/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sysctl/Makefile b/testcases/kernel/syscalls/sysctl/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sysctl/Makefile
+++ b/testcases/kernel/syscalls/sysctl/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sysfs/Makefile b/testcases/kernel/syscalls/sysfs/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sysfs/Makefile
+++ b/testcases/kernel/syscalls/sysfs/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sysinfo/Makefile b/testcases/kernel/syscalls/sysinfo/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/sysinfo/Makefile
+++ b/testcases/kernel/syscalls/sysinfo/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/syslog/Makefile b/testcases/kernel/syscalls/syslog/Makefile
index 932d419..eda3f38 100644
--- a/testcases/kernel/syscalls/syslog/Makefile
+++ b/testcases/kernel/syscalls/syslog/Makefile
@@ -16,17 +16,12 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-SCRIPTS = syslog01 syslog02 syslog03 syslog04 syslog05 syslog06 syslog07 syslog08 syslog09 syslog10
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+# Not all of the files are bourne shell scripts; hence, I removed the syslog*
+# glob to avoid overridden target command noise from make.
+INSTALL_TARGETS		:= syslog0* syslog10
 
-install:
-	@set -e; for i in $(TARGETS) $(SCRIPTS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/tee/Makefile b/testcases/kernel/syscalls/tee/Makefile
index 3f66038..bd617d8 100644
--- a/testcases/kernel/syscalls/tee/Makefile
+++ b/testcases/kernel/syscalls/tee/Makefile
@@ -16,18 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/time/Makefile b/testcases/kernel/syscalls/time/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/time/Makefile
+++ b/testcases/kernel/syscalls/time/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/timer_getoverrun/Makefile b/testcases/kernel/syscalls/timer_getoverrun/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/timer_getoverrun/Makefile
+++ b/testcases/kernel/syscalls/timer_getoverrun/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/timer_gettime/Makefile b/testcases/kernel/syscalls/timer_gettime/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/timer_gettime/Makefile
+++ b/testcases/kernel/syscalls/timer_gettime/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/timerfd/Makefile b/testcases/kernel/syscalls/timerfd/Makefile
index efbf280..3691a8c 100644
--- a/testcases/kernel/syscalls/timerfd/Makefile
+++ b/testcases/kernel/syscalls/timerfd/Makefile
@@ -16,16 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lrt -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lpthread -lrt
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/times/Makefile b/testcases/kernel/syscalls/times/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/times/Makefile
+++ b/testcases/kernel/syscalls/times/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/tkill/Makefile b/testcases/kernel/syscalls/tkill/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/tkill/Makefile
+++ b/testcases/kernel/syscalls/tkill/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/truncate/Makefile b/testcases/kernel/syscalls/truncate/Makefile
index fb02355..bf12010 100644
--- a/testcases/kernel/syscalls/truncate/Makefile
+++ b/testcases/kernel/syscalls/truncate/Makefile
@@ -16,20 +16,11 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-include ../utils/newer_64.mk
-%_64: CFLAGS += -D_FILE_OFFSET_BITS=64
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../utils/newer_64.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS += $(patsubst %.c,%,$(SRCS))
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ulimit/Makefile b/testcases/kernel/syscalls/ulimit/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/ulimit/Makefile
+++ b/testcases/kernel/syscalls/ulimit/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/umask/Makefile b/testcases/kernel/syscalls/umask/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/umask/Makefile
+++ b/testcases/kernel/syscalls/umask/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/umount/Makefile b/testcases/kernel/syscalls/umount/Makefile
index dc9c693..f1e48b3 100644
--- a/testcases/kernel/syscalls/umount/Makefile
+++ b/testcases/kernel/syscalls/umount/Makefile
@@ -16,17 +16,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+INSTALL_TARGETS		:= test_umount
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-	ln -f test_umount ../../../bin/
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/uname/Makefile b/testcases/kernel/syscalls/uname/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/uname/Makefile
+++ b/testcases/kernel/syscalls/uname/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/unlink/Makefile b/testcases/kernel/syscalls/unlink/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/unlink/Makefile
+++ b/testcases/kernel/syscalls/unlink/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/unlinkat/Makefile b/testcases/kernel/syscalls/unlinkat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/unlinkat/Makefile
+++ b/testcases/kernel/syscalls/unlinkat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/unshare/Makefile b/testcases/kernel/syscalls/unshare/Makefile
index b5289a9..2ef86f0 100644
--- a/testcases/kernel/syscalls/unshare/Makefile
+++ b/testcases/kernel/syscalls/unshare/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ustat/Makefile b/testcases/kernel/syscalls/ustat/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/ustat/Makefile
+++ b/testcases/kernel/syscalls/ustat/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/utils/compat_16.mk b/testcases/kernel/syscalls/utils/compat_16.mk
index de825e3..1d023c0 100644
--- a/testcases/kernel/syscalls/utils/compat_16.mk
+++ b/testcases/kernel/syscalls/utils/compat_16.mk
@@ -27,7 +27,7 @@
 # assume the source file name for fooN is fooN.c.
 # On the above assumption, this file does:
 # 
-# * adding fooN_16 as TARGETS, 
+# * adding fooN_16 as MAKE_TARGETS, 
 # * making *.c depend on compat_16.h if the header file exists,
 # * adding rules to build fooN_16 from fooN.c (and compat_16.h), and
 # * passing a cpp symbol TST_USE_COMPAT16_SYSCALL to 
@@ -44,29 +44,37 @@
 # 4. don't forget putting compat_16.h in all fooN.c
 #    if you introduced compat_16.h.
 # 5. include this file compat_16.mk in your Makefile.
-# 6. use `+=' instead of `=' as assignment operator for TARGETS.
+# 6. use `+=' instead of `=' as assignment operator for MAKE_TARGETS.
 # 7. Added extra definitions to CFLAGS in %_16 target if needed.
 #
 # See Makefile of setuid test case.
 #
-TARGETS_16 = $(patsubst %.c,%_16,$(SRCS))
+
+SRCS			?= $(wildcard $(abs_srcdir)/*.c)
+
+MAKE_TARGETS		:= $(notdir $(patsubst %.c,%,$(SRCS)))
+
 ifneq ($(TST_COMPAT_16_SYSCALL),no)
-TARGETS  +=  $(TARGETS_16)
+MAKE_TARGETS		+= $(addsuffix _16,$(MAKE_TARGETS))
 endif
 
-DEF_16 = TST_USE_COMPAT16_SYSCALL
-COMPAT_16_H = compat_16.h
-HAS_COMPAT_16 := $(shell if [ -f $(COMPAT_16_H) ]; then	\
-	  			echo yes;		\
-			else				\
-				echo no;		\
-			fi)
+# XXX (garrcoop): This code should be put in question as it cannot be applied
+# (no .h file, no TST_USE_NEWER64_SYSCALL def).
+DEF_16			:= TST_USE_COMPAT16_SYSCALL
 
+COMPAT_16_H		:= $(abs_srcdir)/../utils/compat_16.h
 
-ifeq ($(HAS_COMPAT_16),yes)
+ifneq ($(wildcard $(COMPAT_16_H)),)
+HAS_COMPAT_16		:= 1
+
 %.c: $(COMPAT_16_H)
+
+else
+HAS_COMPAT_16		:= 0
 endif
 
+%_16: CPPFLAGS += -D$(DEF_16)=1
+# XXX (garrcoop): End section of code in question..
+
 %_16.o: %.c
 	$(COMPILE.c) $(OUTPUT_OPTION) $<
-%_16: CFLAGS += -D$(DEF_16)=1
diff --git a/testcases/kernel/syscalls/utils/newer_64.mk b/testcases/kernel/syscalls/utils/newer_64.mk
index fd05063..5ea62a5 100644
--- a/testcases/kernel/syscalls/utils/newer_64.mk
+++ b/testcases/kernel/syscalls/utils/newer_64.mk
@@ -23,25 +23,31 @@
 # as compat_16.mk does on foo16. See both compat_16.mk
 # and Makefile for fadvise test case.
 
-TARGETS_64 = $(patsubst %.c,%_64,$(SRCS))
+SRCS			?= $(wildcard $(abs_srcdir)/*.c)
+
+MAKE_TARGETS		:= $(notdir $(patsubst %.c,%,$(SRCS)))
 
 ifneq ($(TST_NEWER_64_SYSCALL),no)
-TARGETS  +=  $(TARGETS_64)
+MAKE_TARGETS		+= $(addsuffix _64,$(MAKE_TARGETS))
 endif
 
-DEF_64 = TST_USE_NEWER64_SYSCALL
-NEWER_64_H = newer_64.h
-HAS_NEWER_64 := $(shell if [ -f $(NEWER_64_H) ]; then	\
-	  			echo yes;		\
-			else				\
-				echo no;		\
-			fi)
+# XXX (garrcoop): This code should be put in question as it cannot be applied
+# (no .h file, no TST_USE_NEWER64_SYSCALL def).
+DEF_64			:= TST_USE_NEWER64_SYSCALL
 
+NEWER_64_H		:= $(abs_srcdir)/../utils/newer_64.h
 
-ifeq ($(HAS_NEWER_64),yes)
+ifneq ($(wildcard $(NEWER_64_H)),)
+HAS_NEWER_64		:= 1
+
 %.c: $(NEWER_64_H)
+
+else
+HAS_NEWER_64		:= 0
 endif
 
+%_64: CFLAGS += -D$(DEF_64)=1
+# XXX (garrcoop): End section of code in question..
+
 %_64.o: %.c
 	$(COMPILE.c) $(OUTPUT_OPTION) $<
-%_64: CFLAGS += -D$(DEF_64)=1
diff --git a/testcases/kernel/syscalls/utime/Makefile b/testcases/kernel/syscalls/utime/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/utime/Makefile
+++ b/testcases/kernel/syscalls/utime/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/utimensat/Makefile b/testcases/kernel/syscalls/utimensat/Makefile
index 443265a..172a0ba 100644
--- a/testcases/kernel/syscalls/utimensat/Makefile
+++ b/testcases/kernel/syscalls/utimensat/Makefile
@@ -16,25 +16,12 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all:
-	@set -e; $(MAKE) check_for_utimensat_support;
-	$(MAKE) utimensat01;
+$(eval $(call generate_vpath_rule,c,$(srcdir):$(top_srcdir)/lib))
 
-check_for_utimensat_support: check_for_utimensat_support.c
-	$(CC) $(CFLAGS) -o $@ $< ../../../../lib/tst_kvercmp.c -I../../../../include
+INSTALL_TARGETS		:= utimensat_tests.sh
 
-install:
-	@set -e; \
-	chmod 755 utimensat_tests.sh; \
-	ln -f utimensat_tests.sh ../../../bin/utimensat_tests.sh; \
-	for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-	rm -rf check_for_utimensat_support
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/utimensat/check_for_utimensat_support.c b/testcases/kernel/syscalls/utimensat/check_for_utimensat_support.c
deleted file mode 100644
index 8b9f719..0000000
--- a/testcases/kernel/syscalls/utimensat/check_for_utimensat_support.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <stdio.h>
-#include <test.h>
-
-int kernel_support_available(void)
-{
-	if (tst_kvercmp(2, 6, 22) < 0)
-		return 1;
-	return 0;
-}
-
-int main()
-{
-	exit(kernel_support_available());
-}
diff --git a/testcases/kernel/syscalls/utimes/Makefile b/testcases/kernel/syscalls/utimes/Makefile
index 0d24c35..2ef86f0 100644
--- a/testcases/kernel/syscalls/utimes/Makefile
+++ b/testcases/kernel/syscalls/utimes/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -O2
-LDLIBS += -L../../../../lib -lltp 
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/vfork/Makefile b/testcases/kernel/syscalls/vfork/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/vfork/Makefile
+++ b/testcases/kernel/syscalls/vfork/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/vhangup/Makefile b/testcases/kernel/syscalls/vhangup/Makefile
index 9b3299f..bd617d8 100644
--- a/testcases/kernel/syscalls/vhangup/Makefile
+++ b/testcases/kernel/syscalls/vhangup/Makefile
@@ -16,17 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
+include $(top_srcdir)/include/mk/testcases.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/vmsplice/Makefile b/testcases/kernel/syscalls/vmsplice/Makefile
index dbc7de3..bd617d8 100644
--- a/testcases/kernel/syscalls/vmsplice/Makefile
+++ b/testcases/kernel/syscalls/vmsplice/Makefile
@@ -16,17 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS   += -Wall
-CPPFLAGS += -I../../../../include -I../../../kernel/include
-LDLIBS   += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/wait/Makefile b/testcases/kernel/syscalls/wait/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/wait/Makefile
+++ b/testcases/kernel/syscalls/wait/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/wait4/Makefile b/testcases/kernel/syscalls/wait4/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/wait4/Makefile
+++ b/testcases/kernel/syscalls/wait4/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/waitid/Makefile b/testcases/kernel/syscalls/waitid/Makefile
index 1ebe5d5..2ef86f0 100644
--- a/testcases/kernel/syscalls/waitid/Makefile
+++ b/testcases/kernel/syscalls/waitid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall 
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/waitpid/Makefile b/testcases/kernel/syscalls/waitpid/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/waitpid/Makefile
+++ b/testcases/kernel/syscalls/waitpid/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/write/Makefile b/testcases/kernel/syscalls/write/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/write/Makefile
+++ b/testcases/kernel/syscalls/write/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/writev/Makefile b/testcases/kernel/syscalls/writev/Makefile
index 6706403..bd617d8 100644
--- a/testcases/kernel/syscalls/writev/Makefile
+++ b/testcases/kernel/syscalls/writev/Makefile
@@ -16,16 +16,8 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/timers/Makefile b/testcases/kernel/timers/Makefile
index 377cc2a..69c4e85 100644
--- a/testcases/kernel/timers/Makefile
+++ b/testcases/kernel/timers/Makefile
@@ -1,25 +1,27 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
+#    testcases/kernel/timers Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems, Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-SUBDIRS = $(patsubst %/Makefile,%,$(wildcard */Makefile))
+top_srcdir		?= ../../..
 
-all %::
-	@set -e; \
-	for i in $(SUBDIRS); do \
-		$(MAKE) -C $$i $@; \
-	done
+include $(top_srcdir)/include/mk/env_pre.mk
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/timers/clock_gettime/Makefile b/testcases/kernel/timers/clock_gettime/Makefile
index 88a0802..173ce50 100644
--- a/testcases/kernel/timers/clock_gettime/Makefile
+++ b/testcases/kernel/timers/clock_gettime/Makefile
@@ -16,16 +16,14 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -I../include -D_GNU_SOURCE
-LDLIBS += -L ../../../../lib -lpthread -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CFLAGS			+= -D_GNU_SOURCE
 
-install:
-	set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+CPPFLAGS		+= -I$(abs_srcdir)/../include
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/timers/clock_settime/Makefile b/testcases/kernel/timers/clock_settime/Makefile
index 88a0802..173ce50 100644
--- a/testcases/kernel/timers/clock_settime/Makefile
+++ b/testcases/kernel/timers/clock_settime/Makefile
@@ -16,16 +16,14 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -I../include -D_GNU_SOURCE
-LDLIBS += -L ../../../../lib -lpthread -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CFLAGS			+= -D_GNU_SOURCE
 
-install:
-	set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+CPPFLAGS		+= -I$(abs_srcdir)/../include
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/timers/timer_create/Makefile b/testcases/kernel/timers/timer_create/Makefile
index 88a0802..173ce50 100644
--- a/testcases/kernel/timers/timer_create/Makefile
+++ b/testcases/kernel/timers/timer_create/Makefile
@@ -16,16 +16,14 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -I../include -D_GNU_SOURCE
-LDLIBS += -L ../../../../lib -lpthread -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CFLAGS			+= -D_GNU_SOURCE
 
-install:
-	set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+CPPFLAGS		+= -I$(abs_srcdir)/../include
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/timers/timer_delete/Makefile b/testcases/kernel/timers/timer_delete/Makefile
index 88a0802..173ce50 100644
--- a/testcases/kernel/timers/timer_delete/Makefile
+++ b/testcases/kernel/timers/timer_delete/Makefile
@@ -16,16 +16,14 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -I../include -D_GNU_SOURCE
-LDLIBS += -L ../../../../lib -lpthread -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CFLAGS			+= -D_GNU_SOURCE
 
-install:
-	set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+CPPFLAGS		+= -I$(abs_srcdir)/../include
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/timers/timer_settime/Makefile b/testcases/kernel/timers/timer_settime/Makefile
index 88a0802..173ce50 100644
--- a/testcases/kernel/timers/timer_settime/Makefile
+++ b/testcases/kernel/timers/timer_settime/Makefile
@@ -16,16 +16,14 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
-CFLAGS += -I../../../../include -Wall -I../include -D_GNU_SOURCE
-LDLIBS += -L ../../../../lib -lpthread -lltp
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CFLAGS			+= -D_GNU_SOURCE
 
-install:
-	set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
+CPPFLAGS		+= -I$(abs_srcdir)/../include
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS			+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile
new file mode 100644
index 0000000..88c7344
--- /dev/null
+++ b/testcases/lib/Makefile
@@ -0,0 +1,31 @@
+#
+#    testcases library Makefile (differs from lib/).
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, August 2009
+#
+
+top_srcdir		?= ../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/cmdlib.sh b/testcases/lib/cmdlib.sh
new file mode 100644
index 0000000..46f1262
--- /dev/null
+++ b/testcases/lib/cmdlib.sh
@@ -0,0 +1,144 @@
+#!/bin/sh
+#
+#    Command library that provides a boilerplate set of functions and variables
+#    required for all bourne shell based scripts.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, August 2009
+#
+
+set -u
+
+export SHELL_DEBUG=${SHELL_DEBUG:=0}
+if [ "$SHELL_DEBUG" = 1 ] ; then
+    set -x
+fi
+
+#=============================================================================
+# FUNCTION:   tst_cleanup
+# PURPOSE:    Clean up after a testcase.
+#=============================================================================
+tst_cleanup()
+{
+    # To ensure set -u passes...
+    TCtmp=${TCtmp:=}
+    tst_resm TINFO "Cleaning up."
+    # Nuke the testcase temporary directory if it exists.
+    [ -d "$TCtmp" ] && rm -rf "$TCtmp"
+}
+
+#=============================================================================
+# FUNCTION:  setup
+# PURPOSE:   Setup the test environment.
+#=============================================================================
+tst_setup() {
+
+    TST_COUNT=1
+    TST_TOTAL=${TST_TOTAL:=1}
+    export TCID TST_COUNT TST_TOTAL
+
+    for varname in TST_TOTAL; do
+        if eval "test -z \"\$${varname}\""; then
+            end_testcase "You must set ${varname} before calling setup()."
+        fi
+    done
+
+    LTPROOT=${LTPROOT:="../../../../"}
+    TEMPDIR=${TEMPDIR:=/tmp}
+
+    TCtmp=${TCtmp:=$TEMPDIR/$TC$$}
+    # User wants a temporary sandbox to play with.
+    if [ -n "$TCtmp" -a "$TCtmp" != "$TEMPDIR/$$" ] ; then
+        test -d "$TCtmp" || mkdir -p "$TCtmp"
+        # Clean up on exit.
+        trap tst_cleanup EXIT
+    fi
+
+}
+
+#=============================================================================
+# FUNCTION NAME:        end_testcase
+#
+# FUNCTION DESCRIPTION: Print out whether or not a test failed. Do not use
+#			this when TBROK messages should be applied.
+#
+# PARAMETERS:           Failure message, or "" / unset if passed.
+#
+# RETURNS:              None.
+#=============================================================================
+end_testcase()
+{
+    tst_cleanup
+    if [ $# -eq 0 ]; then
+        tst_resm TPASS "Test successful"
+    else
+        tst_resm TFAIL "Test broken: $*"
+        exit 1
+    fi
+}
+
+#=============================================================================
+# FUNCTION:  exists
+# PURPOSE:   Check if command(s) used by this test script exist.
+#=============================================================================
+exists()
+{
+    for cmd in "$@"; do
+        if ! which $cmd 2>&1 1>/dev/null; then
+            end_testcase "$cmd: command not found"
+            exit 1
+        fi
+    done
+}
+
+incr_tst_count()
+{
+    TST_COUNT=$(( $TST_COUNT + 1 ))
+}
+
+#
+# $0 is maintained by the caller script; tested on FreeBSD (ash) and Gentoo
+# GNU/Linux (bash) -- assuming you aren't calling this from another function
+# or command:
+#
+# foo.sh:
+# echo ${0##*/}
+# . ${$0%%*}/bar.sh
+# bar.sh:
+# echo ${0##*/}
+# echo $SHELL
+#
+# Gentoo:
+# gcooper@orangebox ~/Desktop $ ./foo.sh 
+# foo.sh
+# foo.sh
+# /bin/bash
+# gcooper@orangebox ~/Desktop $ uname -sr
+# Linux 2.6.29-gentoo-r5
+#
+# FreeBSD:
+# $ ./foo.sh
+# foo.sh
+# foo.sh
+# /bin/sh
+# $ uname -sr
+# FreeBSD 8.0-BETA2
+#
+TCID=${TCID:=}
+[ -z "$TCID" ] && TCID=${0##*/}
+TC=$(echo "$TCID" | awk '{ sub( /[0-9]+$/,""); print; }')
diff --git a/testcases/lib/net_cmdlib.sh b/testcases/lib/net_cmdlib.sh
new file mode 100644
index 0000000..d3488f9
--- /dev/null
+++ b/testcases/lib/net_cmdlib.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+#    An extension to cmdlib.sh, purely for networking based commands.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, August 2009
+#
+
+. cmdlib.sh
+
+# Blank for an IPV4 test; 6 for an IPV6 test.
+EXEC_SUFFIX=
+
+read_opts()
+{
+    while getopts "6" opt; do
+        case "$opt" in
+        6)
+            EXEC_SUFFIX=6;;
+        *)
+            echo "Setup  0  : FAIL Unknown option: $opt"
+            exit 1;;
+        esac
+    done
+}
diff --git a/testcases/misc/Makefile b/testcases/misc/Makefile
index 581e41a..3c70bd3 100644
--- a/testcases/misc/Makefile
+++ b/testcases/misc/Makefile
@@ -1,11 +1,27 @@
-SUBDIRS = crash f00f math tcore_patch_test_suites
+#
+#    misc test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/misc/crash/Makefile b/testcases/misc/crash/Makefile
index 0432f57..26350ea 100644
--- a/testcases/misc/crash/Makefile
+++ b/testcases/misc/crash/Makefile
@@ -1,37 +1,27 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
+#    misc/crash test suite Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-# description	: make(1) description file for the send(2) tests.	  #
-###########################################################################
-CFLAGS+=	-I../../../include
-LOADLIBES+=	-L../../../lib -lltp
+top_srcdir		?= ../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/crash/crash02.c b/testcases/misc/crash/crash02.c
index 9ade84c..1d13928 100644
--- a/testcases/misc/crash/crash02.c
+++ b/testcases/misc/crash/crash02.c
@@ -486,16 +486,31 @@
   int i;
   const list[] =
     {
-#ifdef __ia64__
+#if defined(__ia64__)
       SYS_clone2,
 #else
-      /* No SYS_fork(vfork) on IA-64. Instead, it uses,
-         clone(child_stack=0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD)
-         clone2() */
+      /*
+       * No SYS_fork(vfork) on IA-64. Instead, it uses,
+       * clone(child_stack=0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD)
+       * clone2()
+       */
+      
+      /*
+       * NOTE (garrcoop):
+       *  Could not find reference to SYS_fork(vfork) on mips32
+       *  with the Montavista / Octeon toolchain. Need to develop an
+       *  autoconf check for this item.
+       */   
+#if defined(__NR_vfork) && __NR_vfork
       SYS_vfork,
+#endif
+#if defined(__NR_fork) && __NR_fork
       SYS_fork,
+#endif
 #endif /* __ia64__ */
+#if defined(__NR_clone) && __NR_clone
       SYS_clone,
+#endif
       -1
     };
 
diff --git a/testcases/misc/f00f/Makefile b/testcases/misc/f00f/Makefile
index 0432f57..7645de4 100644
--- a/testcases/misc/f00f/Makefile
+++ b/testcases/misc/f00f/Makefile
@@ -1,37 +1,29 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
+#    misc/f00f test suite Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-# description	: make(1) description file for the send(2) tests.	  #
-###########################################################################
-CFLAGS+=	-I../../../include
-LOADLIBES+=	-L../../../lib -lltp
+top_srcdir		?= ../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lm
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/math/Makefile b/testcases/misc/math/Makefile
index e5ec0f4..991ff5a 100644
--- a/testcases/misc/math/Makefile
+++ b/testcases/misc/math/Makefile
@@ -1,11 +1,27 @@
-SUBDIRS = abs atof float fptests nextafter
+#
+#    misc/math test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/misc/math/abs/Makefile b/testcases/misc/math/abs/Makefile
index d654861..c1e4c19 100644
--- a/testcases/misc/math/abs/Makefile
+++ b/testcases/misc/math/abs/Makefile
@@ -16,21 +16,10 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-###########################################################################
-CFLAGS+=	-I../../../../include -O -g -Wall
-LOADLIBES+=	-lm -L../../../../lib -lltp 
+top_srcdir		?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lm
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/math/atof/Makefile b/testcases/misc/math/atof/Makefile
index d654861..c1e4c19 100644
--- a/testcases/misc/math/atof/Makefile
+++ b/testcases/misc/math/atof/Makefile
@@ -16,21 +16,10 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-###########################################################################
-CFLAGS+=	-I../../../../include -O -g -Wall
-LOADLIBES+=	-lm -L../../../../lib -lltp 
+top_srcdir		?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lm
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/math/float/Makefile b/testcases/misc/math/float/Makefile
index 9b46b79..f52f203 100644
--- a/testcases/misc/math/float/Makefile
+++ b/testcases/misc/math/float/Makefile
@@ -1,20 +1,32 @@
-CFLAGS+= -I../../../../include -Wall -g 
-LOADLIBES+= -lpthread -lm -L../../../../lib -lltp
+#
+#    misc/math/float test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard float*.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir	?= ../../../..
 
-SUBDIRS=bessel exp_log iperb power trigo
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+LDLIBS		+= -lpthread -lm
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
+# main.c doesn't compile...
+MAKE_TARGETS	:= $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/float*.c))
 
-clean: 
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-	rm -f $(TARGETS) 
-	@set -e; for i in $(TARGETS); do rm -rf ../../../bin/$$i ; done
-
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/misc/math/float/bessel/Makefile b/testcases/misc/math/float/bessel/Makefile
index 9c0d6d8..df31dc4 100644
--- a/testcases/misc/math/float/bessel/Makefile
+++ b/testcases/misc/math/float/bessel/Makefile
@@ -1,19 +1,31 @@
-CFLAGS += -Wall
-LOADLIBES = -lm 
-BIN = genj0 genj1 geny0 geny1 genlgamma genbessel
-REF = gamma_inp.ref  gamma_out.ref  gamma_sign.ref  j0_inp.ref  j1_inp.ref  y0_inp.ref  y1_inp.ref
-REF2 = j0_out.ref2  j1_out.ref2  y0_out.ref2  y1_out.ref2
+#
+#    testcases/misc/math/float/bessel test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-all:	$(BIN)
+top_srcdir		?= ../../../../..
 
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	rm -f $(BIN) 
-	@set -e; for i in $(BIN); do rm -f ../../../../bin/$$i ; done
-	rm -f *.ref
-	@set -e; for i in $(REF); do rm -f ../../../../bin/$$i ; done
-	rm -f *.ref2 
-	@set -e; for i in $(REF2); do rm -f ../../../../bin/$$i ; done
+CLEAN_TARGETS		:= *.ref*
 
-install:
-	@set -e; for i in $(BIN); do ln -f $$i ../../../../bin/$$i ; done
+LDLIBS			+= -lm
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/math/float/exp_log/Makefile b/testcases/misc/math/float/exp_log/Makefile
index 45fcd93..22386a3 100644
--- a/testcases/misc/math/float/exp_log/Makefile
+++ b/testcases/misc/math/float/exp_log/Makefile
@@ -1,20 +1,31 @@
-CFLAGS += -Wall
-LOADLIBES = -lm
+#
+#    testcases/misc/math/float/exp_log test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-BIN = genexp genlog genlog10 genfrexp genldexp genhypot genmodf genexp_log
-REF = exp_inp.ref frexp_inp.ref hypot_out.ref ldexp_out.ref log_inp.ref modf_out.ref exp_out.ref frexp_out.ref ildexp_inp.ref log10_inp.ref modf1_out.ref frexp1_out.ref hypot_inp.ref ldexp_inp.ref log10_out.ref modf_inp.ref
-REF2 = log_out.ref2
+top_srcdir		?= ../../../../..
 
-all:	$(BIN)
+include $(top_srcdir)/include/mk/env_pre.mk
 
+CLEAN_TARGETS		:= *.ref*
 
-clean:
-	rm -f $(BIN)
-	@set -e; for i in $(BIN); do rm -f ../../../../bin/$$i ; done
-	rm -f *.ref
-	@set -e; for i in $(REF); do rm -f ../../../../bin/$$i ; done
-	rm -f *.ref2
-	@set -e; for i in $(REF2); do rm -f ../../../../bin/$$i ; done
+LDLIBS			+= -lm
 
-install:
-	@set -e; for i in $(BIN); do ln -f $$i ../../../../bin/$$i ; done
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/math/float/iperb/Makefile b/testcases/misc/math/float/iperb/Makefile
index 30877c3..e7a6774 100644
--- a/testcases/misc/math/float/iperb/Makefile
+++ b/testcases/misc/math/float/iperb/Makefile
@@ -1,17 +1,31 @@
-CFLAGS += -Wall
-LOADLIBES = -lm
+#
+#    testcases/misc/math/float/iperb test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-BIN = gensinh gencosh gentanh geniperb
-DATA = dsinh rsinh dcosh rcosh dtanh rtanh
+top_srcdir		?= ../../../../..
 
-all:	$(BIN)
+include $(top_srcdir)/include/mk/env_pre.mk
 
+CLEAN_TARGETS		:= [dr]* *.ref*
 
-clean:
-	rm -f $(BIN)
-	@set -e; for i in $(BIN); do rm -f ../../../../bin/$$i ; done
-	rm -f $(DATA)
-	@set -e; for i in $(DATA); do rm -f ../../../../bin/$$i ; done
+LDLIBS			+= -lm
 
-install:
-	@set -e; for i in $(BIN); do ln -f $$i ../../../../bin/$$i ; done
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/math/float/power/Makefile b/testcases/misc/math/float/power/Makefile
index b12d70e..b489e69 100644
--- a/testcases/misc/math/float/power/Makefile
+++ b/testcases/misc/math/float/power/Makefile
@@ -1,17 +1,31 @@
-CFLAGS += -Wall
-LOADLIBES = -lm
+#
+#    testcases/misc/math/float/power test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-BIN = gensqrt genpow genceil genfabs genfloor genfmod genpower
-REF = 1fmod_inp.ref  ceil_inp.ref  fabs_inp.ref  floor_inp.ref  fmod_inp.ref  pow_inp.ref  sqrt_inp.ref 1pow_inp.ref   ceil_out.ref  fabs_out.ref  floor_out.ref  fmod_out.ref  pow_out.ref  sqrt_out.ref
+top_srcdir		?= ../../../../..
 
-all:	$(BIN)
+include $(top_srcdir)/include/mk/env_pre.mk
 
+CLEAN_TARGETS		:= *.ref*
 
-clean:
-	rm -f $(BIN)
-	@set -e; for i in $(BIN); do rm -f ../../../../bin/$$i ; done
-	rm -f *.ref
-	@set -e; for i in $(REF); do rm -f ../../../../bin/$$i ; done
+LDLIBS			+= -lm
 
-install:
-	@set -e; for i in $(BIN); do ln -f $$i ../../../../bin/$$i ; done
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/math/float/trigo/Makefile b/testcases/misc/math/float/trigo/Makefile
index faaffb4..c7390ff 100644
--- a/testcases/misc/math/float/trigo/Makefile
+++ b/testcases/misc/math/float/trigo/Makefile
@@ -1,17 +1,31 @@
-CFLAGS += -Wall
-LOADLIBES = -lm
+#
+#    testcases/misc/math/float/trigo test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-BIN = gensin gencos gentan genatan genatan2 genacos genasin gentrigo
-DATA = dtan rtan datan ratan dsin rsin datan2 ratan2 dcos rcos dasin rasin dacos racos
+top_srcdir		?= ../../../../..
 
-all:	$(BIN)
+include $(top_srcdir)/include/mk/env_pre.mk
 
+CLEAN_TARGETS		:= [dr]*
 
-clean:
-	rm -f $(BIN)
-	@set -e; for i in $(BIN); do rm -f ../../../../bin/$$i ; done
-	rm -f $(DATA)
-	@set -e; for i in $(DATA); do rm -f ../../../../bin/$$i ; done
+LDLIBS			+= -lm
 
-install:
-	@set -e; for i in $(BIN); do ln -f $$i ../../../../bin/$$i ; done
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/math/fptests/Makefile b/testcases/misc/math/fptests/Makefile
index 1d7fed5..f837a4a 100644
--- a/testcases/misc/math/fptests/Makefile
+++ b/testcases/misc/math/fptests/Makefile
@@ -19,18 +19,11 @@
 ###########################################################################
 # name of file	: Makefile						  #
 ###########################################################################
-CFLAGS   += -Wall
-CPPFLAGS += -I../../../../include
-LDFLAGS  += -L../../../../lib
-LDLIBS   += -lm -lltp 
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+LDLIBS			+= -lm
 
-clean:
-	rm -f $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/math/nextafter/Makefile b/testcases/misc/math/nextafter/Makefile
index d654861..c1e4c19 100644
--- a/testcases/misc/math/nextafter/Makefile
+++ b/testcases/misc/math/nextafter/Makefile
@@ -16,21 +16,10 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-###########################################################################
-CFLAGS+=	-I../../../../include -O -g -Wall
-LOADLIBES+=	-lm -L../../../../lib -lltp 
+top_srcdir		?= ../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+LDLIBS			+= -lm
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/tcore_patch_test_suites/Makefile b/testcases/misc/tcore_patch_test_suites/Makefile
index 10e1de3..85ec229 100644
--- a/testcases/misc/tcore_patch_test_suites/Makefile
+++ b/testcases/misc/tcore_patch_test_suites/Makefile
@@ -1,15 +1,36 @@
-CFLAGS += -Wall
-CPPFLAGS += -I../../../include
-LDFLAGS += -L../../../lib
-LDLIBS += -lltp -lm -lpthread
-MODCFLAGS := -Wall -DLINUX -I/usr/src/linux/include
-EXECS=tcore tcore.sh tcore.exp
+#
+#    misc/crash test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:		tcore
+top_srcdir		?= ../../..
 
-install: 
-		@set -e; for i in $(EXECS) ; do ln -f $$i ../../bin/$$i ; done ;	
+include $(top_srcdir)/include/mk/testcases.mk
 
-clean:
-	rm -f tcore
+INSTALL_TARGETS		:= tcore.exp tcore.sh
 
+LDLIBS			+= -lm -lpthread
+
+MAKE_TARGETS		:= tcore
+
+#MODCFLAGS		:= -DLINUX -I$(prefix)/usr/src/linux/include
+MODCFLAGS		:= -DLINUX
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/Makefile b/testcases/network/Makefile
index fc92b1e..e2fedc9 100644
--- a/testcases/network/Makefile
+++ b/testcases/network/Makefile
@@ -1,11 +1,48 @@
-SUBDIRS = `ls */Makefile | sed "s/Makefile//g"`
+#
+#    network test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+DIR			:= datafiles
 
+CLEAN_TARGETS		+= $(DIR)
+
+INSTALL_DIR		:= testcases/bin
+
+MAKE_TARGETS		:= $(addprefix $(DIR)/bin.,sm med lg jmb)
+
+RM			+= -r
+
+$(MAKE_TARGETS): | generate 
+
+.PHONY: generate
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
+
+$(DESTDIR)/$(INSTALL_DIR)/$(DIR) $(DIR): %:
+	mkdir -p "$@"
+
+generate: $(DIR) $(DESTDIR)/$(INSTALL_DIR)/$(DIR)
+	cd "$(DIR)" && \
+	abs_top_srcdir="$(abs_top_srcdir)" "$(abs_srcdir)/generate.sh"
diff --git a/testcases/network/dhcpd/Makefile b/testcases/network/dhcpd/Makefile
index e264b10..a963a45 100644
--- a/testcases/network/dhcpd/Makefile
+++ b/testcases/network/dhcpd/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    network/dhcpd testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f dhcpd_tests.sh ../../bin/dhcpd_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= dhcpd_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/generate.sh b/testcases/network/generate.sh
index dda80df..8cc773b 100755
--- a/testcases/network/generate.sh
+++ b/testcases/network/generate.sh
@@ -25,51 +25,49 @@
 #
 ############################################################################
 
-data_dir=datafiles
-small_file='ascii.sm'
-medium_file='ascii.med'
-large_file='ascii.lg'
-jumbo_file='ascii.jmb'
+small_file=ascii.sm
+medium_file=ascii.med
+large_file=ascii.lg
+jumbo_file=ascii.jmb
 jumbo_size=1600020
 large_size=80020
 medium_size=4020
 small_size=220
 
-if [ ! -d $data_dir ] ; then
-	mkdir $data_dir
-	chmod 777 $data_dir
+set -e
+
+if [ -z "$abs_top_srcdir" ] ; then
+	echo "The variable \`abs_top_srcdir', must be defined." >&2
+	exit 1
+else
+	make_file="$abs_top_srcdir/tools/make-file.sh"
+	if [ ! -x "$make_file" ] ; then
+		echo "$make_file isn't an executable file" >&2
+		exit 1
+	fi
 fi
 
-for m in .. ../.. ../../.. ../../../.. ; do
-	makeit=$m/tools/make-file.sh
-	if [ -e $makeit ] ; then
-		break
-	fi
-done
+"$make_file" "$small_file" $small_size
+"$make_file" "$medium_file" $medium_size
+"$make_file" "$large_file" $large_size
+"$make_file" "$jumbo_file" $jumbo_size
 
-$makeit $data_dir/$small_file $small_size
-$makeit $data_dir/$medium_file $medium_size
-$makeit $data_dir/$large_file $large_size
-$makeit $data_dir/$jumbo_file $jumbo_size
-
-if [ ! -e $data_dir/bin.sm ] ; then
-	cnt=5
-	while [ $cnt -ge 0 ] ; do
-		gzip -1 -c datafiles/ascii.sm >> $data_dir/bin.sm
-		cnt=$(($cnt-1))
+if [ ! -e "bin.sm" ] ; then
+	cnt=0
+	while [ $cnt -lt 5 ] ; do
+		gzip -1 -c ascii.sm >> "bin.sm"
+		cnt=$(($cnt + 1))
 	done
 fi
 
 genfile() {
-	local input=$data_dir/$1 output=$data_dir/$2
+	local input="$1" output="$2"
 	local cnt=19
 
-	if [ -e $output ] ; then
-		return 0
-	fi
+	[ -e "$output" ] && return $?
 
 	while [ $cnt -ge 0 ] ; do
-		cat $input >> $output
+		cat "$input" >> "$output"
 		cnt=$(($cnt-1))
 	done
 }
@@ -78,4 +76,4 @@
 genfile bin.med bin.lg
 genfile bin.lg bin.jmb
 
-chmod 666 $data_dir/bin.*
+chmod 666 bin.*
diff --git a/testcases/network/iproute/Makefile b/testcases/network/iproute/Makefile
index 8f5b38e..334ad02 100644
--- a/testcases/network/iproute/Makefile
+++ b/testcases/network/iproute/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    network/iproute testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f ip_tests.sh ../../bin/ip_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= ip_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/iptables/Makefile b/testcases/network/iptables/Makefile
index 77825dc..4849d91 100644
--- a/testcases/network/iptables/Makefile
+++ b/testcases/network/iptables/Makefile
@@ -1,6 +1,29 @@
-all:
+#
+#    network/iptables testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f iptables_tests.sh ../../bin/iptables_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= iptables_tests.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/ipv6/Makefile b/testcases/network/ipv6/Makefile
deleted file mode 100644
index b469c66..0000000
--- a/testcases/network/ipv6/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-SUBDIRS = `ls */Makefile | sed "s/Makefile//g"`
-
-all:
-	@set -e; rm -f ftp6 2>/dev/null;ln -fs ../tcp_cmds/ftp ftp6
-	@set -e; rm -f rcp6 2>/dev/null;ln -fs ../tcp_cmds/rcp rcp6
-	@set -e; rm -f rlogin6 2>/dev/null;ln -fs ../tcp_cmds/rlogin rlogin6
-	@set -e; rm -f rsh6 2> /dev/null;ln -fs ../tcp_cmds/rsh rsh6
-	@set -e; rm -f rwho6 2> /dev/null;ln -fs ../tcp_cmds/rwho rwho6
-	@set -e; rm -f telnet6 2> /dev/null;ln -fs ../tcp_cmds/telnet telnet6
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
-
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-	@rm -f ftp6
-	@rm -f rcp6
-	@rm -f rlogin6
-	@rm -f rsh6
-	@rm -f rwho6
-	@rm -f telnet6
-
diff --git a/testcases/network/ipv6/echo6/Makefile b/testcases/network/ipv6/echo6/Makefile
deleted file mode 100644
index 8b6e501..0000000
--- a/testcases/network/ipv6/echo6/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-CFLAGS += -w -O 
-LDLIBS += 
-
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	ln -f echo601 ../../../bin
-
-clean:
-	rm -f $(TARGETS)
-
-
diff --git a/testcases/network/ipv6/echo6/createfile.c b/testcases/network/ipv6/echo6/createfile.c
deleted file mode 100644
index d947c65..0000000
--- a/testcases/network/ipv6/echo6/createfile.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-@! # TESTCASE DESCRIPTION:
-@! # 	Purpose: to create an input file of any size
-@! # 	Command: none
-@! # 	Subcommand: none
-@! # 	Design: Write an array the size of BUFSIZ to created file until
-@! # 		the file size matches the file size required
-@! # SPEC. EXEC. REQS:  This  program is used by ctatcdt3.c and ctatcet3.c
-*/
-#include <stdio.h>
-#include <fcntl.h>
-main (int argc,char *argv[]) 
-{
-int	fd;
-int	fsize;
-int	count=0;
-int	n,remain;
-static	char buf[BUFSIZ];
-	for ( fsize=0;fsize<BUFSIZ;fsize) {
-		buf[fsize++]='U';
-		buf[fsize++]='\n';
-	}
-
-	fsize=atoi(argv[1]);
-	if ((fd=creat(argv[2],0644)) == -1 )
-		perror("createfile");
-	if (fsize >= BUFSIZ) {
-		count=fsize/BUFSIZ;
-		remain=fsize%BUFSIZ; 
-		}
-	else remain=fsize;
-	while (count-- !=0) 
-		if((n=write(fd,buf,BUFSIZ)) != BUFSIZ) 
-			perror("createfile");
-	if ((n=write(fd,buf,remain)) != remain)
-		perror("createfile");
-	close(fd);
-}
diff --git a/testcases/network/ipv6/echo6/echo601 b/testcases/network/ipv6/echo6/echo601
deleted file mode 100755
index ea8143e..0000000
--- a/testcases/network/ipv6/echo6/echo601
+++ /dev/null
@@ -1,154 +0,0 @@
-#!/bin/sh
-unset LIBPATH
-#
-#   Copyright (c) International Business Machines  Corp., 2000
-#
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#   the GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this pronram;  if not, write to the Free Software
-#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-#
-#
-#  FILE   : echo601
-#
-#  PURPOSE: Stresses the inetd/xinetd daemon using the `echo` service.
-#           
-#  SETUP: The echo service MUST be active on the RHOST machine. This is
-#         controlled by the inetd/xinetd daemon.
-#
-#  HISTORY:
-#    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TC=sine
-RHOST=${RHOST:-`hostname`}
-TCbin=${TCbin:-`pwd`}
-TCsrc=${TCsrc:-$TCbin}
-TCtmp=${TCtmp:-$TCsrc/echo6$$}
-CLEANUP=${CLEANUP:-ON}
-CREATFILE=createfile
-ECHOES=echoes6
-
-EXECUTABLES=${EXECUTABLES:-"$CREATFILE $ECHOES"}
-ECHOFILE=${ECHOFILE:-echofile}
-NUMLOOPS=${NUMLOOPS:-2}
-NUMPROCESSES=${NUMPROCESSES:-15}
-ECHOSIZE=${ECHOSIZE:-8192}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  do_test
-# PURPOSE:   Loop until interrupted creating the echo file and then
-#	     echoing it to RHOST.
-# INPUT:     None.
-# OUTPUT:    Informational messages are logged into the run log.
-#
-#-----------------------------------------------------------------------
-
-do_test() 
-{
-   $trace_logic
-   mkdir -p $TCtmp
-   echo  "Creating echo file $ECHOFILE"
-   $TCbin/$CREATFILE $ECHOSIZE $TCtmp/$ECHOFILE
-   [ $? = 0 ] || end_testcase "$ECHOFILE not created"
-
-   echo "Compute the checksum of this file"
-   csum1=`sum $TCtmp/$ECHOFILE |awk '{print $1}'`
-   [ $csum1 ] || end_testcase "initial checksum computation failed"
-
-   COUNT=1
-   while [ $COUNT -le $NUMLOOPS ]
-   do
-      $TCbin/$ECHOES $RHOST $TCtmp/$ECHOFILE $NUMPROCESSES
-      [ $? = 0 ] || end_testcase "Error in $ECHOES test in loop $COUNT"
-
-      NUM=0
-      while [ $NUM -lt $NUMPROCESSES ]
-      do
-         csum2=`sum $TCtmp/$ECHOFILE\$NUM |awk '{print $1}'`
-         [ "$csum1" -eq "$csum2" ] || end_testcase "Checksums differ in loop $COUNT"
-         NUM=`expr $NUM + 1`
-      done
-
-      echo "Successful execution for loop $COUNT" 
-      COUNT=`expr $COUNT + 1`
-      if [ $COUNT -le $NUMLOOPS ]; then
-  	echo "Sleeping 60 seconds to avoid hitting max. connections setting for service"
-	sleep 60
-      fi
-   done
-}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:	do_cleanup
-# PURPOSE:	Called when the testcase is interrupted by the user
-#		or by interrupt_testcase() when time limit expired
-# INPUT:	None.
-# OUTPUT:	None.
-#
-#-----------------------------------------------------------------------
-
-do_cleanup()
-{
-   $trace_logic
-
-   cd /
-   rm -rf $TCtmp
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-# 
-# FUNCTION DESCRIPTION: Clean up
-# 
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-# 
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{  
-   $trace_logic
-    
-   # Call other cleanup functions
-   [ $CLEANUP = "ON" ] && do_cleanup
-
-   [ $# -eq 0 ] && { echo "Test Successful"; exit 0; }
-   echo "Test Failed: $@"
-   echo""
-   echo "***NOTE***"
-   echo "Make sure the streamed echo is uncommented in inetd.conf"
-   echo "on the server. Also try increasing max connections from"
-   echo "default of 40, i.e. nowait.400"
-   exit 1
-}   
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  MAIN
-# PURPOSE:   To invoke functions that perform the tasks as described in
-#	     the design in the prolog above.
-# INPUT:     See SETUP in the prolog above.
-# OUTPUT:    Logged run results written to testcase run log
-#
-#-----------------------------------------------------------------------
-do_test
-end_testcase
diff --git a/testcases/network/ipv6/echo6/echoes6.c b/testcases/network/ipv6/echo6/echoes6.c
deleted file mode 100644
index 2bea83b..0000000
--- a/testcases/network/ipv6/echo6/echoes6.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
-@! # TEST TYPE(S): Concurrency, Load stress
-@! # TESTCASE DESCRIPTION:
-@! # 	Purpose: to send packets from the file to echo protocol on remote
-@! #		 machine and read the echoing packets back and compare them
-@! # 	Design: Connect to echo protocol on the remote machine
-@! #		read from the file and send the file to remote machine
-@! #		read the echoing  packets and store them in a file
-@! #		repeat until file exhausted.
-@! #		compare result
-@! #
-@! # SPEC. EXEC. REQS: May require multiple of this test to run
-@! #		       to target machines from multiple machine in order
-@! #		       to create stress condition
-@! # 			echoes <REMOTE HOST> <echofile> <number of process>
-*/
-#include <stdio.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-#define TRUE 1
-#define FALSE 0
-
-main (int argc,char *argv[],char *env[])
-{
-
-	int	i,j,k,wait_stat,pid,finish,gai;
-	struct	servent *sp;
-	struct 	addrinfo *hp;
-	struct	addrinfo hints;
-	struct  {
-		char	resultfile[35];
-		int	pid;
-		int	status;
-	}echo_struc[200];
-
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = PF_INET6;
-
-	if ((gai=getaddrinfo(argv[1], NULL, &hints, &hp))!=0) {
-		fprintf(stderr, "Unknown subject address %s: %s\n", argv[1], gai_strerror(gai));
-		exit(1);
-	}
-	if (!hp->ai_addr || hp->ai_addr->sa_family != AF_INET6) {
-		fprintf(stderr, "getaddrinfo failed");
-		exit(1);
-	}
-	if ((sp=getservbyname("echo","tcp"))==NULL) {
-		printf("ERROR service is not available\n");
-		perror("echo");
-		exit(1);
-	}
-	i=atoi(argv[3]);
-	j=0;
-	while ( i-- > 0 )  {
-		echo_struc[j].status=0;
-		switch (pid=fork())  {
-		case 0:
-			getfilename(argv[2],echo_struc[j].resultfile,j);
-			echofile(sp,hp,echo_struc[j].resultfile,argv[2]); 
-			break;
-		case -1:
-			printf("ERROR when forking a new process\n");
-			perror("echo");
-			exit(1);
-			break;
-		default:
-			echo_struc[j].pid=pid;
-			echo_struc[j].status=1;
-			j++;
-			break;
-		}
-	}
-	finish=atoi(argv[3]);
-	i=finish;
-	while (finish != 0) {
-		if ((pid=wait(&wait_stat)) == -1) {
-			printf("ERROR in wait process\n");
-			perror("echo");
-			exit(1);
-		}
-		if (wait_stat==0) 
-			for (j=0;j<i;j++) {
-				if(echo_struc[j].pid==pid) {
-					echo_struc[j].status=2;
-					finish--;
-					j=i;
-				}
-			}
-		else {
-			for (k=0;k < i;k++)
-				if (echo_struc[k].status==1) {
-					kill(echo_struc[k].pid,9);
-				}
-			exit(1);
-		}
-	}
-	exit(0);
-}
-
-echofile (struct servent *sp, struct addrinfo *hp, char *resultfile, char *orgfile)
-{
-	int	n;
-	int	port;
-	char	wr_buffer[BUFSIZ];
-	char	rd_buffer[BUFSIZ];
-	struct 	sockaddr_in6 sa;
-	int	s;
-	int	finish;
-	int	fdw,fdr;
-	int	nread,nwrite;
-	int	pid;
-	int	count;
-#ifdef 	DEBUG
-	printf("Create socket .....\n");
-#endif
-	pid=getpid();
-	if ((s=socket(AF_INET6,SOCK_STREAM,0)) < 0 ) {
-		printf("ERROR occured during socket operation(%d)\n",pid);
-		perror("echo:socket");
-		cleanup(s);
-		exit(1);
-	}
-	port=sp->s_port;
-	memcpy(&sa, hp->ai_addr, hp->ai_addrlen);
-	sa.sin6_port=port;
-
-#ifdef 	DEBUG
-	printf("port=%d\n", ntohs(port));
-	printf("Connect .......\n");
-#endif
-	if (connect(s,(struct sockaddr *) &sa,sizeof(sa))==-1) {
-		printf ("ERROR occured during connect socket operation(%d)\n",pid);
-		perror("echo:connect");
-		cleanup(s);
-		exit(1);
-	}
-#ifdef DEBUG
-	printf("hp->ai_addrlen=%d\n",hp->ai_addrlen);
-	printf("hp->ai_family=%d\n",hp->ai_family);
-	printf("hp->ai_socktype=%d\n",hp->ai_socktype);
-	printf("hp->ai_protocol=%d\n",hp->ai_protocol);
-#endif
-	if ((fdr=open(orgfile,O_RDONLY)) < 0 ) {
-		printf("ERROR when opening the input file(%d)\n",pid);
-		perror("echo:orginal file");
-		cleanup(s);
-		exit(1);
-	}
-	if ((fdw=creat(resultfile,0644)) < 0 ) {
-		printf("ERROR when opening the temporary temp file(%d)\n",pid);
-		perror("echo:resultfile");
-		cleanup(s);
-		exit(1);
-	}
-	finish=FALSE;
-	count=0;
-	while (!finish) {
-		if ((nwrite=read(fdr,wr_buffer,BUFSIZ))==-1) {
-			printf("ERROR when reading input file(%d)\n",pid);
-			perror("echo:orginal file");
-			cleanup(s);
-			exit(1);
-		}
-		if (nwrite==0)
-			finish=TRUE;
-		else {
-			count++;
-			if((n=write(s,wr_buffer,nwrite))!=nwrite) {
-				printf("ERROR during write to socket(%d)\n",pid);
-				perror("echo:socket write");
-				cleanup(s);
-				exit(1);
-			}
-#ifdef 	DEBUG
-/*
-			printf("Writing .......%d\n",count);
-*/
-#endif
-			while (nwrite!=0) {
-				if((nread=read(s,rd_buffer,BUFSIZ))==-1) {
-					printf("read size:%d\n",n);
-					printf("ERROR during read from socket(%d)\n",pid);
-					perror("echo:socket read");
-					cleanup(s);
-					exit(1);
-				}
-#ifdef 	DEBUG
-/*
-				printf("Reading .......    %d\n",count);
-*/
-#endif
-				if((n=write(fdw,rd_buffer,nread))!=nread) {
-					printf("read size:%d\n",n);
-					printf("ERROR during write to result file(%d)\n",pid);
-					perror("echo:result file");
-					cleanup(s);
-					exit(1);
-				}
-				nwrite-=nread;
-			}
-
-		}/* end of else */
-	} /* end of while */
-	if ((n=close(s)) == -1) {
-		printf("ERROR in closing socket(%d)\n",pid);
-		perror("echo");
-		exit(1);
-	}
-	if ((n=close(fdr)) == -1) {
-		printf("ERROR in closing input file(%d)\n",pid);
-		perror("echo");
-		exit(1);
-	}
-	if ((n=close(fdw) ) == -1) {
-		printf("ERROR in closing temp file(%d)\n",pid);
-		perror("echo");
-		exit(1);
-	}
-	if (checkfile(orgfile,resultfile)) {
-		printf("ERROR input file and output file are not equal(%d)\n",pid);
-		exit(1);
-	}
-	printf("Finish ....%d\n",pid);
-	exit(0);
-}
-
-getfilename(char *strptr, char* filename, int j)
-{
-	int 	i;
-	char	s[10],*sptr=&s[0];
-
-	strcpy(filename,strptr);
-	itoa(j,s);
-	strcat(filename,s);
-}
-
-checkfile(char *file1, char *file2)
-{
-	int	n;
-	struct	stat buffer,*bufptr=&buffer;
-	stat(file1,bufptr);
-	n=bufptr->st_size;
-#ifdef 	DEBUG
-	/*	printf("%s size= %d \n",file1,n);
-*/
-#endif
-	stat(file2,bufptr);
-#ifdef 	DEBUG
-	/*	printf("%s size= %d \n",file2,bufptr->st_size);
-*/
-#endif
-	if(n != buffer.st_size)
-		return(TRUE);
-	else return(FALSE);
-}
-
-itoa(int n, char s[])
-{
-	int i, sign;
-
-	if ((sign = n) < 0)
-		n = -n;
-	i = 0;
-	do {
-		s[i++] = n % 10 + '0';
-	} while ((n /= 10) > 0);
-	if (sign < 0)
-		s[i++] = '-';
-	s[i] = '\0';
-	reverse(s);
-}
-
-reverse(char s[])
-{
-	int c, i, j;
-
-	for (i=0, j=strlen(s)-1; i < j; i++, j--) {
-		c = s[i];
-		s[i] = s[j];
-		s[j] = c;
-	}
-}
-cleanup(int s) 
-{
-close(s);
-}
diff --git a/testcases/network/ipv6/finger6/Makefile b/testcases/network/ipv6/finger6/Makefile
deleted file mode 100644
index 72a19f5..0000000
--- a/testcases/network/ipv6/finger6/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
-
-install: 
-	ln -f finger601 ../../../bin
-
-clean:
-
diff --git a/testcases/network/ipv6/finger6/finger601 b/testcases/network/ipv6/finger6/finger601
deleted file mode 100755
index 67dc549..0000000
--- a/testcases/network/ipv6/finger6/finger601
+++ /dev/null
@@ -1,235 +0,0 @@
-#!/bin/sh
-#
-#   Copyright (c) International Business Machines  Corp., 2000
-#
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#   the GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this pronram;  if not, write to the Free Software
-#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-#
-#
-#  FILE   : finger6
-#
-#  PURPOSE: To test the basic functionality of the `finger6` command.
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed. Also, both machines MUST have
-#         the fingerd daemon active (see inetd or xinetd config file). 
-#
-#  HISTORY:
-#    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-#-----------------------------------------------------------------------
-# Uncomment line below for debugging information
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-RUSER=root
-RHOST=${RHOST:-`hostname`}
-LHOST=`hostname`
-SLEEPTIME=${SLEEPTIME:-1}
-LUSER=`id | tr -s '()' '  ' | awk '{print $2}'`
-
-this_file=${0##*/}
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  do_setup
-#
-#-----------------------------------------------------------------------
-
-do_setup ()
-{
-   $trace_logic
-
-   # Start fingerd locally and remotely.
-
-   [ "$LUSER" = "root" ] || end_testcase "MUST BE root to run the test!"
-
-   FINGER=`netstat -an | grep "::79" |awk '{print $6}'`
-   if [ $FINGER != "LISTEN" ]; then
-      end_testcase "Please start fingerd for IPv6 locally."
-   fi
-
-   FINGER=`rsh -n $RHOST netstat -an |grep "::79"|awk '{print $6}'`
-   if [ $FINGER != "LISTEN" ]; then
-      end_testcase "Please start fingerd for IPv6 on remote host."
-   fi
-}
-
-#-----------------------------------------------------------------------
-# FUNCTION: do_test1
-# PURPOSE: Run finger with no flags 
-# INPUT:    None.
-# OUTPUT:   Error messages are logged for all discrepancies found. 
-#-----------------------------------------------------------------------
-
-do_test1()
-{
-   $trace_logic
-
-   echo "finger: do_test1 started"
-
-   finger @$LHOST 
-   [ $? = 0 ] || end_testcase "finger @$LHOST"
-   finger @$RHOST 
-   [ $? = 0 ] || end_testcase "finger @$RHOST"
-	
-   # Testing finger command with user argument
-
-   finger $LUSER 
-   [ $? = 0 ] || end_testcase "finger $LUSER"
-   finger $LUSER@$LHOST 
-   [ $? = 0 ] || end_testcase "finger $LUSER@$LHOST"
-   finger $RUSER@$RHOST
-   [ $? = 0 ] || end_testcase "finger @$RUSER"
-}
-
-#-----------------------------------------------------------------------
-# FUNCTION: do_test2
-# PURPOSE:  To run the "finger User@host" commands and verify that the
-#           "finger" command is functioning properly.
-# INPUT:    None.
-# OUTPUT:   Error messages are logged for all discrepancies found.
-#-----------------------------------------------------------------------
-
-do_test2()
-{
-   $trace_logic
-
-   echo "do_test2 $TC finger -bad flag"
-   BADUSER="uuuu"
-   BADHOST="xxxx"
-
-   echo "finger -badflag default "
-   finger -x
-   [ $? = 0 ] && end_testcase "finger -x should fail"
-
-   echo "finger -bad user "
-   finger $BADUSER
-   [ $? = 0 ] || end_testcase "finger $BADUSER "
-   finger @$BADHOST
-   [ $? = 0 ] || end_testcase "finger @$BADHOST"
-   finger $BADUSER@$BADHOST
-   [ $? = 0 ] || end_testcase "finger $BADUSER@$BADHOST"
-}
-
-#-----------------------------------------------------------------------
-# FUNCTION: do_test3
-# PURPOSE:  To run the "finger -flag User@Host" commands and verify that the
-#           "finger" command is functioning properly.
-# INPUT:    None.
-# OUTPUT:   Error messages are logged for all discrepancies found. 
-#-----------------------------------------------------------------------
-
-do_test3()
-{
-   $trace_logic
-
-   echo "do_test3 $TC finger -f flag"
-
-   echo "finger -l : gives a long listing"
-   finger -l 
-   [ $? = 0 ] || end_testcase "finger -l"
-   finger -l $LUSER 
-   [ $? = 0 ] || end_testcase "finger -l $LUSER "
-   finger -l @$LHOST 
-   [ $? = 0 ] || end_testcase "finger -l @$LHOST"
-   finger -l $LUSER@$LHOST 
-   [ $? = 0 ] || end_testcase "finger -l $LUSER@$LHOST"
-   finger -l @$RHOST 
-   [ $? = 0 ] || end_testcase "finger -l @$RHOST"
-   finger -l $RUSER@$RHOST 
-   [ $? = 0 ] || end_testcase "finger -l $RUSER@$RHOST"
-
-   echo "finger -m : assures that user is a user ID discretionary"
-   finger -m 
-   [ $? = 0 ] || end_testcase "finger -m"
-   finger -m $LUSER 
-   [ $? = 0 ] || end_testcase "finger -m $LUSER "
-   finger -m @$LHOST 
-   [ $? = 0 ] || end_testcase "finger -m @$LHOST"
-   finger -m $LUSER@$LHOST 
-   [ $? = 0 ] || end_testcase "finger -m $LUSER@$LHOST"
-   finger -m @$RHOST 
-   [ $? = 0 ] || end_testcase "finger -m @$RHOST"
-   finger -m $RUSER@$RHOST 
-   [ $? = 0 ] || end_testcase "finger -m $RUSER@$RHOST"
-
-   echo "finger -p:suppresses printing of .plan files on long and brief long formats"
-   finger -p 
-   [ $? = 0 ] || end_testcase "finger -p"
-   finger -p $LUSER 
-   [ $? = 0 ] || end_testcase "finger -p $LUSER "
-   finger -p @$LHOST 
-   [ $? = 0 ] || end_testcase "finger -p @$LHOST"
-   finger -p $LUSER@$LHOST 
-   [ $? = 0 ] || end_testcase "finger -p $LUSER@$LHOST"
-   finger -p @$RHOST 
-   [ $? = 0 ] || end_testcase "finger -p @$RHOST"
-   finger -p $RUSER@$RHOST 
-   [ $? = 0 ] || end_testcase "finger -p $RUSER@$RHOST"
-
-   echo "finger -s : gives a short format list"
-   finger -s 
-   [ $? = 0 ] || end_testcase "finger -s"
-   finger -s $LUSER 
-   [ $? = 0 ] || end_testcase "finger -s $LUSER "
-   finger -s @$LHOST 
-   [ $? = 0 ] || end_testcase "finger -s @$LHOST"
-   finger -s $LUSER@$LHOST 
-   [ $? = 0 ] || end_testcase "finger -s $LUSER@$LHOST"
-   finger -s @$RHOST 
-   [ $? = 0 ] || end_testcase "finger -s @$RHOST"
-   finger -s $RUSER@$RHOST 
-   [ $? = 0 ] || end_testcase "finger -s $RUSER@$RHOST"
-
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-
-   [ $# = 0 ] && { echo "Test Successful"; exit 0; }
-   echo "test failed: $@"
-   exit 1
-}
-
-#-----------------------------------------------------------------------
-# FUNCTION: MAIN
-# PURPOSE:  To invoke the functions to perform the tasks outlined in the
-#           prologue.
-# INPUT:    None.
-# OUTPUT:   None.
-#-----------------------------------------------------------------------
-do_setup
-do_test1
-sleep $SLEEPTIME
-do_test2
-sleep $SLEEPTIME
-do_test3
-sleep $SLEEPTIME
-end_testcase
diff --git a/testcases/network/ipv6/perf_lan6/Makefile b/testcases/network/ipv6/perf_lan6/Makefile
deleted file mode 100644
index e5b657f..0000000
--- a/testcases/network/ipv6/perf_lan6/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-CFLAGS += -w -O
-LDLIBS += 
-
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-install:
-	ln -f perf_lan6 ../../../bin
-
-clean:
-	rm -f $(TARGETS)
-
-
diff --git a/testcases/network/ipv6/perf_lan6/perf_lan6 b/testcases/network/ipv6/perf_lan6/perf_lan6
deleted file mode 100755
index f8eff78..0000000
--- a/testcases/network/ipv6/perf_lan6/perf_lan6
+++ /dev/null
@@ -1,166 +0,0 @@
-#! /bin/sh
-unset LIBPATH
-#
-#   Copyright (c) International Business Machines  Corp., 2000
-#
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#   the GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this pronram;  if not, write to the Free Software
-#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-#
-#
-#  FILE   : perf_lan
-#
-#  PURPOSE: Generates LAN traffic using ICMP echo packets.
-#           
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the client 
-#         machine, where the test is executed. 
-#
-#  HISTORY:
-#    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TC=slan
-RHOST=${RHOST:-`hostname`}
-TCbin=${TCbin:-`pwd`}
-TCsrc=${TCsrc:-$TCbin}
-TCtmp=${TCtmp:-$TCsrc}
-CLEANUP=${CLEANUP:-ON}
-
-PACKETSIZE=${PACKETSIZE:-512}
-NUMPACKETS=${NUMPACKETS:-5}
-NUMLOOPS=${NUMLOOPS:-5}
-EXECUTABLES="pingpong6"
-
-trap "interrupt_testcase" 2 15 16 30
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  do_test
-# INPUT:     None.
-# OUTPUT:    Informational messages are logged into the run log.
-#
-#-----------------------------------------------------------------------
-
-do_test() 
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-
-   TLOOP=1
-   COUNT=1
-   [ $NUMLOOPS -gt 0 ] || TLOOP=$NUMLOOPS
-   while [ $TLOOP -le $NUMLOOPS ]
-   do
-      $TCbin/$EXECUTABLES $RHOST $PACKETSIZE $NUMPACKETS
-      RETVALUE=$?
-
-      case "$RETVALUE" in
-         0) echo "Successful execution for loop $COUNT" ;;
-         1) end_testcase "Error trying to send to host" ;;
-         2) end_testcase "Error - Data length is too long";;
-         3) end_testcase "Usage error ";;
-         5) end_testcase "Error - Socket setting" ;;
-         6) end_testcase "Error - Pipe broken";;
-         7) end_testcase "Error - Fork fail";;
-         10)end_testcase "Error - wrong Protocol" ;;
-         *) end_testcase "Return code from $EXECUTABLES is $RETVALUE" ;;
-      esac
-      if [ $NUMLOOPS -gt 0 ] ; then TLOOP=$(( $TLOOP + 1 )); fi
-      COUNT=$(( $COUNT + 1 ))
-   done
-}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:     do_cleanup
-# PURPOSE:      Called when the testcase is interrupted by the user
-#               or by interrupt_testcase() when time limit expired
-# INPUT:        None.
-# OUTPUT:       None.
-#
-#-----------------------------------------------------------------------
-
-do_cleanup()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-
-   cd /
-   if [ $TCtmp != $TCsrc ]; then
-      rm -rf $TCtmp
-   fi
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-# 
-# FUNCTION DESCRIPTION: Clean up
-# 
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-# 
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{  
-   $trace_logic
-   echo "$this_file: doing $0."
-   
-   # Call other cleanup functions
-   [ $CLEANUP = "ON" ] && do_cleanup
-   
-   [ $# -eq 0 ] && { echo "Test Successful"; exit 0; }
-   echo "Test Failed: $@"
-   exit 1
-}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:     interrupt_testcase
-# PURPOSE:      Finish up the testcase - called when the time has expired
-# INPUT:        None.
-# OUTPUT:       None.
-#
-#-----------------------------------------------------------------------
-
-interrupt_testcase()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-
-   echo "Testcase interrupted - cleaning up"
-   echo "Killing background process if it is still running"
-   kill -9 $CHILDPID
-   end_testcase
-}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  MAIN
-# PURPOSE:   To invoke functions that perform the tasks as described in
-#	     the design in the prolog above.
-# INPUT:     See SETUP in the prolog above.
-# OUTPUT:    Logged run results written to testcase run log
-#
-#-----------------------------------------------------------------------
-do_test
-end_testcase
diff --git a/testcases/network/ipv6/ping6/Makefile b/testcases/network/ipv6/ping6/Makefile
deleted file mode 100644
index 2f7258a..0000000
--- a/testcases/network/ipv6/ping6/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
-
-install:
-	ln -f ping601 ../../../bin
-
-clean:
-
diff --git a/testcases/network/ipv6/ping6/ping601 b/testcases/network/ipv6/ping6/ping601
deleted file mode 100755
index a722507..0000000
--- a/testcases/network/ipv6/ping6/ping601
+++ /dev/null
@@ -1,90 +0,0 @@
-#! /bin/sh
-#***********************************************************************
-#
-#   Copyright (c) International Business Machines  Corp., 2000
-#
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#   the GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this pronram;  if not, write to the Free Software
-#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-#
-#
-#  FILE   : ping6
-#
-#  PURPOSE: To test the basic functionality of the `ping6` command.
-#  
-#  SETUP: If "RHOST" is not exported, then the local hostname is used.
-#
-#  HISTORY:
-#    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-#***********************************************************************
-# Uncomment line below for debug output
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TC=ping6
-
-
-RHOST=${RHOST:-`hostname`}
-COUNT=${COUNT:-5}
-SLEEPTIME=${SLEEPTIME:-1}
-PACKETSIZES=${PACKETSIZES:-"8 16 32 64 128 256 512 1024 2048 4064"}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  do_test
-# PURPOSE:   Executes the testcases.
-#
-#-----------------------------------------------------------------------
-
-do_test() 
-{
-   $trace_logic
-
-   for packetsize in $PACKETSIZES
-   do
-      ping6 -c $COUNT -s $packetsize $RHOST 
-      [ $? -eq 0 ] || end_testcase "failed: ping6 -c $COUNT -s $packetsize $RHOST"
-      sleep $SLEEPTIME
-   done
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-
-   [ $# -eq 0 ] && { echo "Test Successful"; exit 0; }
-   echo "Test Failed: $@"
-   exit 1
-}
-
-#*******************************************************************************
-#
-# FUNCTION:  MAIN
-#
-#*******************************************************************************
-do_test
-end_testcase
diff --git a/testcases/network/ipv6/sendfile6/Makefile b/testcases/network/ipv6/sendfile6/Makefile
deleted file mode 100644
index 3582f82..0000000
--- a/testcases/network/ipv6/sendfile6/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-CFLAGS += -w -O
-LDLIBS += 
-
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
-generate:
-	../../generate.sh
-
-install: generate
-	ln -f sendfile601 ../../../bin
-
-clean:
-	rm -f $(TARGETS)
-	rm -rf datafiles
-
diff --git a/testcases/network/ipv6/sendfile6/SF_Server6 b/testcases/network/ipv6/sendfile6/SF_Server6
deleted file mode 100755
index ec0f57e..0000000
--- a/testcases/network/ipv6/sendfile6/SF_Server6
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-#set -x
-cd $3
-exec 1< /dev/null       # open descriptor 1
-exec 2< /dev/null       # open descriptor 2
-nohup ./testsf_s6 $1 $2 &
diff --git a/testcases/network/ipv6/sendfile6/sendfile601 b/testcases/network/ipv6/sendfile6/sendfile601
deleted file mode 100755
index 39bbb7c..0000000
--- a/testcases/network/ipv6/sendfile6/sendfile601
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/bin/sh
-#
-#   Copyright (c) International Business Machines  Corp., 2000
-#
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#   the GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this pronram;  if not, write to the Free Software
-#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-#
-#
-#  FILE   : sendfile
-#
-#  PURPOSE: Copy files from server to client using the sendfile()
-#           function.
-#           
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the client 
-#         machine, where the test is executed. 
-#
-#  HISTORY:
-#    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TC=sendfile6
-RHOST=${RHOST:-`hostname`}
-TCbin=${TCbin:-`pwd`}
-TCsrc=${TCsrc:-$TCbin}
-TCdat=${TCdat:-$TCsrc/datafiles}
-TCtmp=${TCtmp:-$TCsrc/$TC$$}
-CLEANUP=${CLEANUP:-ON}
-EXECUTABLES="testsf_c6"
-REMOTE_EXEC="testsf_s6"
-
-FILES=${FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"}
-
-
-
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
-do_test()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-  
-   mkdir -p $TCtmp
-   PORT=$$ 
-   rsh -n -l root $RHOST "$TCsrc/SF_Server6 $RHOST $PORT $TCsrc"
-   sleep 10
-   PID=$(rsh -n -l root $RHOST "ps -ef "|grep $REMOTE_EXEC | grep $PORT | grep -v grep|awk '{print $2}')
-   [ "$PID" ] || end_testcase "Could not start server"
-
-   for clnt_fname in $FILES
-      do
-	 serv_fname=$TCdat/$clnt_fname
-	 SIZE=`ls -l $serv_fname|awk '{print $5}'`
-	 echo "Starting $EXECUTABLES $RHOST $PORT Client_filename Server_filename Size "
-  
-	 $TCsrc/$EXECUTABLES $RHOST $PORT $TCtmp/$clnt_fname $serv_fname $SIZE 
-	 RetVal=$?
-  
-         [ $RetVal -eq 0 ] || end_testcase "$EXECUTABLES returned error $RetVal"
-
-	 diff $serv_fname $TCtmp/$clnt_fname
-	 DiffVal=$?
-	 [ $DiffVal -gt 1 ] && end_testcase "ERROR: Cannot compare files"
-	 [ $DiffVal -eq 1 ] && end_testcase "The file copied differs from the original"
-      done
-}
-
-#=============================================================================
-# FUNCTION NAME:        do_cleanup
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
-
-do_cleanup()
-{
-   $trace_logic
-   PID=$(rsh -n -l root $RHOST "ps -ef|grep \"$REMOTE_EXEC $RHOST\""| grep $PORT|
-      grep -v grep|grep -v vi|awk '{print $2}')
-   [ "$PID" ] && rsh -n -l root $RHOST kill -9 $PID
-      
-   rm -rf $TCtmp
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-# 
-# FUNCTION DESCRIPTION: Clean up
-# 
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-# 
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{  
-   $trace_logic
-   echo "$this_file: doing $0."
-
-   
-   # Call other cleanup functions
-   [ $CLEANUP = "ON" ] && do_cleanup
-   
-   [ $# -eq 0 ] && { echo "Test Successful"; exit 0; }
-   echo "Test Failed: $@"
-   exit 1
-}
-
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
-do_test
-end_testcase
diff --git a/testcases/network/ipv6/sendfile6/testsf_c6.c b/testcases/network/ipv6/sendfile6/testsf_c6.c
deleted file mode 100644
index 64c48bf..0000000
--- a/testcases/network/ipv6/sendfile6/testsf_c6.c
+++ /dev/null
@@ -1,112 +0,0 @@
- 
-/*
- * Client for the send_file test program
- * Syntax: testsf_c <server IP addr> <client_filename> <server_filename> <file length> 
- */
-
-#include <stdio.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/file.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <errno.h>
-
-main(argc, argv)
-int argc;
-char *argv[];
-
-{
-  struct sockaddr_in6 sa;
-  int s, fd;
-  char *lp, *sp;
-  int i;
-  int nbyte;
-  char *serv_fname;
-  char *clnt_fname;
-  char rbuf[81];
-  int flen, nlen;
-  int gai;
-  struct  addrinfo *hp;
-  struct  addrinfo hints;
-  int port;
-
-  /* open socket to server */
-  if ((s = socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
-	printf("socket error = %d\n", errno);
-	exit(1);
-  }
-
-  clnt_fname = argv[3]; /* filename to create */
-  serv_fname = argv[4]; /* filename to request */
-
-  /* prepare to copy file from server to local machine */
-  if ((fd = open(clnt_fname, O_CREAT | O_TRUNC | O_WRONLY, 0777)) < 0) {
-	printf("file open error = %d\n", errno);
-	close(s);
-	exit(1);
-  }
-
-  lp = argv[5]; /* get file size */
-  flen = strtol(lp,(char **)NULL,10);
-	
-
-  /* initialize request info: */
-  rbuf[0] = '\0';
-  sp = &rbuf[0];
-  sp = strcat(sp, argv[5]); /* file size */
-  sp = strcat(sp, "=");
-  sp = strcat(sp, serv_fname); /* requested file */
-
-  memset(&hints, 0, sizeof(hints));
-  hints.ai_family = PF_INET6;
-  if ((gai=getaddrinfo(argv[1], NULL, &hints, &hp))!=0)
-  		 fprintf(stderr, "Unknown subject address %s: %s\n",argv[1], gai_strerror(gai));
-  if (!hp->ai_addr || hp->ai_addr->sa_family != AF_INET6)
-  		 fprintf(stderr, "getaddrinfo failed");
-
-
-  /* initialize server info to make the connection */
-  memcpy(&sa, hp->ai_addr, hp->ai_addrlen);
-  port=atoi(argv[2]);
-  sa.sin6_port = htons(port);
-
-  if ( connect(s, (struct sockaddr*) &sa, sizeof(sa) ) < 0 ) {
-        printf("connect error = %d\n", errno);
-	close(s);
-	exit(1);
-  }
- 
-  /* send request info to server */
-  if ((nbyte = write(s, rbuf, strlen(rbuf))) <= 0) {
-        printf("socket write  error = %d\n", errno);
-	close(s);
-	exit(1);
-  }
-
-printf("client write %d bytes to server with contents %s\n", nbyte, rbuf);
-
-  nlen = 0; /* init size of info received */
-  rbuf[0] = '\0';
-  while ((nbyte = read(s, rbuf, 80)) >0) { /* receive info until EOF */
-    nlen += nbyte;
-    if (write(fd, rbuf, nbyte) != nbyte) {
-      printf("Error writing to file %s on client\n",clnt_fname);
-      exit(1);
-    }
-  }
-
-  printf("Asking for %s\n",serv_fname);
-  if (nlen != flen) { /* compare expected size with current size */
-    printf("WRONG!!! nlen = %d, should be %d\n", nlen, flen);
-    exit (1);
-  }
-  else
-    printf("File %s received\n", serv_fname);
-
-  close(s);
-  close(fd);
-  exit(0);
-}
diff --git a/testcases/network/ipv6/sendfile6/testsf_s6.c b/testcases/network/ipv6/sendfile6/testsf_s6.c
deleted file mode 100644
index a7ae05c..0000000
--- a/testcases/network/ipv6/sendfile6/testsf_s6.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Server for the sendfile test program
- * Syntax: testsf_s <own IP addr>
- */
-
-#include <stdio.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/file.h>
-#include <errno.h>
-#include <sys/signal.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-
-#define LISTEN_BACKLOG	10
-
-
-void *
-test_sig(sig)
-int sig;
-{
-  
-  int status;
-
-  wait(&status);
-
-
-}
-
-
-main(argc, argv)
-int argc;
-char *argv[];
-
-{
-  struct sockaddr_in6 sa, *ap;
-  struct sockaddr_in6 from;
-  struct  addrinfo *hp;
-  struct  addrinfo hints;
-  int s, fd, as, rc;
-  char *lp;
-  char *number;
-  int i, clen, pid;
-  int flags, nonblocking;
-  int nbytes, flen,gai,count;
-  char rbuf[81];
-  int chunks=0;
-  off_t *offset; 
-  char nbuf[81];
-  int port;
- 
-  /* open socket */
-  if ((s = socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
-	printf("socket error = %d\n", errno);
-	exit(1);
-  }
-
-  signal(SIGCHLD, SIG_IGN); /* ignore signals from children */
-
-  memset(&hints, 0, sizeof(hints));
-  hints.ai_family = PF_INET6;
-  if ((gai=getaddrinfo(argv[1], NULL, &hints, &hp))!=0) {
-        fprintf(stderr, "Unknown subject address %s: %s\n",argv[1], gai_strerror(gai));
-        exit(1);
-  }
-  if (!hp || !hp->ai_addr || hp->ai_addr->sa_family != AF_INET6) {
-        fprintf(stderr, "getaddrinfo failed");
-        exit(1);
-  }
-
-
-  /* server IP and port */
-  memcpy(&sa, hp->ai_addr, hp->ai_addrlen);
-  port=atoi(argv[2]);
-  sa.sin6_port = htons(port);
-
-  /* bind IP and port to socket */
-  if ( bind(s, (struct sockaddr_in6*) &sa, sizeof(sa) ) < 0 ) {
-        printf("bind error = %d\n", errno);
-	close(s);
-	exit(1);
-  }
- 
-  /* start to listen socket */
-  if ( listen(s, LISTEN_BACKLOG ) < 0 ) {
-        printf("listen error = %d\n", errno);
-	close(s);
-	exit(1);
-  }
-
-  /* process connections */
-  while(1) {
-	/* accept a connection from a client */
-  	clen = sizeof(from);
-  	if ((as = accept(s, &from, &clen )) < 0 ) {
-	  printf("accept error = %d\n", errno);
-	  if (errno == EINTR)
-		continue;
-	  close(s);
-	  exit(1);
-  	}
-
-	ap = (struct sockaddr_in6 *)&from;
-
-	/* create a process to manage the connection */
-	if ((pid = fork()) < 0) {
-	  printf("fork error = %d\n", errno);
-	  close(as);
-	  exit(1);
-  	}
-	if (pid > 0) {	/* parent, go back to accept */
-	  close(as);
-	  continue;
-	}
-
-
-
-	/* child process to manage a connection */
-  
-	close(s); /* close service socket */
-
-	/* get client request information */
-	if ((nbytes = read(as, rbuf, 80)) <= 0) {
-	  printf("socket read error = %d\n", errno);
-	  close(as);
-	  exit(1);
-  	}
-	rbuf[nbytes] = '\0'; /* null terminate the info */
-	lp = &rbuf[0];
-
-	/* start with file length, '=' will start the filename */
-	flen = 0;
-	count = 0;
-	number = &nbuf[0];
-	while (*lp != '=') { /* convert ascii to integer */
-	  nbuf[count] = *lp;
-	  count++;
-	  lp++;
-	}
-	 nbuf[count] = '\0';
-	 flen = strtol(number, (char **)NULL, 10); 
-	 printf("flen is %d.\n",flen);
-
-	/* the file name */
-	lp++;
-
-        printf("The file to send is %s\n", lp);
-  	/* open requested file to send */
-	if ((fd = open(lp, O_RDONLY)) < 0) {
-	  printf("file open error = %d\n", errno);
-	  close(as);
-	  exit(1);
-  	}
-	offset=NULL;
-	errno=0;
-        do { /* send file parts until EOF */
-           if ((rc = sendfile(as, fd, offset, flen)) != flen) {
-                if ((errno != EWOULDBLOCK) && (errno != EAGAIN)) {
-                        printf("sendfile error = %d, rc = %d\n", errno, rc);
-                        close(as);
-                        close(fd);
-                        exit(-1);
-                }
-          }
-	  chunks++;
-        } while (rc != 0);
-	printf("File %s sent in %d parts\n", lp, chunks);
-
-
-	close(as); /* close connection */
-	close(fd); /* close requested file */
-	exit(0);
-
-  }
-
-
-  close(s); /* close parent socket (never reached because of the while(1)) */
-
-
-
-
-}
-
diff --git a/testcases/network/ipv6/tcpdump6/Makefile b/testcases/network/ipv6/tcpdump6/Makefile
deleted file mode 100644
index 409f598..0000000
--- a/testcases/network/ipv6/tcpdump6/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
-
-install: 
-	ln -f tcpdump601 ../../../bin
-
-clean:
-
diff --git a/testcases/network/ipv6/tcpdump6/tcpdump601 b/testcases/network/ipv6/tcpdump6/tcpdump601
deleted file mode 100755
index 502f973..0000000
--- a/testcases/network/ipv6/tcpdump6/tcpdump601
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/bin/sh
-#******************************************************************************
-#   Copyright (c) International Business Machines  Corp., 2000
-#
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
-#
-#   This program is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#   the GNU General Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License
-#   along with this pronram;  if not, write to the Free Software
-#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-#
-#
-#  FILE   : tcpdump
-#
-#  PURPOSE: To test the basic functionality of `tcpdump`.
-#
-#  SETUP: The "RHOST" setting should be exported to be the hostname of
-#         another machine on the same subnet.  Otherwise, the hostname
-#         of the tested machine will be used.
-#
-#  HISTORY:
-#    04/17/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-#-----------------------------------------------------------------------
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TC=tcpdump
-TCtmp=${TCtmp:-/tmp/$TC$$}
-RHOST=${RHOST:-`hostname`}
-NUMLOOPS=${NUMLOOPS:-20}
-OUTFILE=$TCtmp/tcpdump_out
-
-#******************************************************************************
-#
-# FUNCTION:  do_test
-# PURPOSE:   Invoke tcpdump
-# INPUT:     None
-#
-#******************************************************************************
-
-do_test()
-{
-   $trace_logic
-
-   mkdir -p $TCtmp
-   [ $? -eq 0 ] || end_testcase "mkdir -p $TCtmp failed"
-   ping6 -f $RHOST > /dev/null 2>&1 &
-   /usr/sbin/tcpdump -c $NUMLOOPS > $OUTFILE
-   [ $? -eq 0 ] || end_testcase "Problems trying to launch tcpdump"
-   grep "$RHOST\>" $OUTFILE 
-   [ $? -eq 0 ] || end_testcase "$RHOST was not listed in network traffic"
-   PID=`ps -ef | grep "ping6 -f $RHOST" | grep -v grep | awk '{print $2}'`
-   kill -9 $PID
-   rm -rf $OUTFILE
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-   rm -rf $TCtmp
-   [ $# -eq 0 ] && { echo "Test Successful"; exit 0; }
-   echo "Test Failed: $@"
-   exit 1
-}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  MAIN
-# PURPOSE:   To invoke functions that perform the tasks as described in
-#	     the design in the prolog above.
-# INPUT:     See SETUP in the prolog above.
-# OUTPUT:    Logged run results written to testcase run log
-#
-#-----------------------------------------------------------------------
-do_test
-end_testcase
diff --git a/testcases/network/lib6/Makefile b/testcases/network/lib6/Makefile
index 387e28c..c881c96 100644
--- a/testcases/network/lib6/Makefile
+++ b/testcases/network/lib6/Makefile
@@ -20,25 +20,26 @@
 # name of file	: Makefile						  #
 # description	: make(1) description file for lib6 tests.	  	  #
 ###########################################################################
-CFLAGS+=	-I../../../include -g -D_GNU_SOURCE
-LOADLIBES+=	-L../../../lib runcc.a -lltp -lpthread
 
-RANLIB		?= ranlib
+top_srcdir		?= ../../..
 
-SRCS=$(wildcard *.c)
-TARGETS= asapi_01 asapi_02 asapi_03 asapi_04 asapi_05 asapi_06 asapi_07 \
-	getaddrinfo_01 in6_01 in6_02
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
+CPPFLAGS		+= -D_GNU_SOURCE
+LDLIBS			+= -lpthread
 
-$(TARGETS): %: %.c runcc.a
+LIB			:= $(DESTDIR)/$(libdir)/libruncc.a
 
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../bin/$$i ; done
+MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%,$(filter-out %/runcc.c,$(wildcard $(abs_srcdir)/*.c)))
 
-clean:
-	rm -f $(TARGETS) *.a *.o
+$(MAKE_TARGETS): | $(LIB)
 
-runcc.a: runcc.o
-	$(AR) cr $@ $^
-	$(RANLIB) $@
+$(MAKE_TARGETS): LDLIBS	+= -lruncc
+
+$(LIB): $(builddir)/runcc.o
+	$(AR) cr "$@" $^
+	$(RANLIB) "$@"
+
+CLEAN_TARGETS		+= $(LIB)
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/lib6/runcc.c b/testcases/network/lib6/runcc.c
index 3cc7129..bf74bdc 100644
--- a/testcases/network/lib6/runcc.c
+++ b/testcases/network/lib6/runcc.c
@@ -96,7 +96,7 @@
 		cflags, filename0, filename);
 	es = system(cmd);
 	if (WEXITSTATUS(es) == 127) {
-		tst_resm(TBROK, "%s: can't run C compiler: \"%s\"", cmd);
+		tst_resm(TBROK, "can't run C compiler: \"%s\"", cmd);
 		if (unlink(filename) < 0)
 			tst_resm(TWARN, "%s; unlink \"%s\" failed: %s", tname,
 				filename, strerror(errno));
diff --git a/testcases/network/multicast/Makefile b/testcases/network/multicast/Makefile
index 29d44de..ce28018 100644
--- a/testcases/network/multicast/Makefile
+++ b/testcases/network/multicast/Makefile
@@ -1,11 +1,26 @@
-SUBDIRS = mc_cmds mc_commo mc_member mc_opts
+#
+#    network/multicast test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/multicast/mc_cmds/Makefile b/testcases/network/multicast/mc_cmds/Makefile
index 8c9e51c..6579ad1 100644
--- a/testcases/network/multicast/mc_cmds/Makefile
+++ b/testcases/network/multicast/mc_cmds/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/multicast/mc_cmds testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f mc_cmds ../../../bin
+top_srcdir	?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS	:= mc_cmds
+
+MAKE_TARGETS	:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/multicast/mc_cmds/mc_cmds b/testcases/network/multicast/mc_cmds/mc_cmds
index a4d48fc..f4f1973 100755
--- a/testcases/network/multicast/mc_cmds/mc_cmds
+++ b/testcases/network/multicast/mc_cmds/mc_cmds
@@ -63,7 +63,7 @@
 
    IFNAME=${IFNAME:-$(netstat -i -n | grep "^[b-z]\{2,4\}[0-9][^*]"|\
       awk '{print $1}')}
-   INTERFACE=${INTERFACE:-$($LTPROOT/tools/gethost `hostname` | grep addresses: | awk '{print $2}')}
+   INTERFACE=${INTERFACE:-$($LTPROOT/testcases/bin/gethost `hostname` | grep addresses: | awk '{print $2}')}
 
    echo "Testing ifconfig and netstat"
 
diff --git a/testcases/network/multicast/mc_commo/Makefile b/testcases/network/multicast/mc_commo/Makefile
index 3abf439..dac2fb8 100644
--- a/testcases/network/multicast/mc_commo/Makefile
+++ b/testcases/network/multicast/mc_commo/Makefile
@@ -1,17 +1,29 @@
-CFLAGS += -O -Wall
-LDLIBS += 
+#
+#    network/multicast/mc_commo testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir	?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f mc_commo ../../../bin
-	ln -f mc_recv ../../../bin
-	ln -f mc_send ../../../bin
+INSTALL_TARGETS	:= mc_commo
 
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/multicast/mc_commo/mc_commo b/testcases/network/multicast/mc_commo/mc_commo
index e18a10e..fbbcd22 100755
--- a/testcases/network/multicast/mc_commo/mc_commo
+++ b/testcases/network/multicast/mc_commo/mc_commo
@@ -39,7 +39,6 @@
 
 
 TC=mc_commo
-TCsrc=${TCsrc:-`pwd`}
 TCtmp=${TCtmp:-"/tmp/mc_commo.$$"}
 CLEANUP=${CLEANUP:-ON}
 EXECUTABLES="mc_recv"
@@ -50,7 +49,7 @@
 RHOST=${RHOST:-`hostname`}
 OUTFILE=$TCtmp/mc_commo_out
 NUMLOOPS=${NUMLOOPS:-2}
-INTERFACE=${INTERFACE:-$($LTPROOT/tools/gethost `hostname` | grep addresses: | awk '{print $2}')}
+INTERFACE=${INTERFACE:-$($LTPROOT/testcases/bin/gethost `hostname` | grep addresses: | awk '{print $2}')}
 
 this_file=${0##*/}
 trap "interrupt_test" 2
@@ -86,7 +85,8 @@
       # Start up the recv on local host
       echo "Starting mc_recv on $GROUP_ADDR $INTERFACE $PORT"
 
-      $TCsrc/$EXECUTABLES $GROUP_ADDR $INTERFACE $PORT >> $OUTFILE &
+      "$LTPROOT/testcases/bin/$EXECUTABLES" $GROUP_ADDR $INTERFACE $PORT \
+	>> $OUTFILE &
       SERVER_PID=$!
       sleep 5
       ps -ewf | grep mc_recv | grep -v grep
@@ -128,7 +128,8 @@
       do
          echo "Running on $HOST mc_send $GROUP_ADDR $HOST $PORT $TTL"
 
-         rsh -n -l root $HOST $TCsrc/$REMOTE_EXEC $GROUP_ADDR $HOST $PORT $TTL >/dev/null &
+         rsh -n -l root $HOST "$LTPROOT/testcases/bin$REMOTE_EXEC" $GROUP_ADDR \
+	 $HOST $PORT $TTL >/dev/null &
          sleep 10
 	rsh -n -l root $HOST "ps -ewf | grep mc_send | grep -v grep"
           [ $? = 0 ] || end_testcase "Could NOT start mc_send on $HOST"
diff --git a/testcases/network/multicast/mc_member/Makefile b/testcases/network/multicast/mc_member/Makefile
index 8b6b093..afd1114 100644
--- a/testcases/network/multicast/mc_member/Makefile
+++ b/testcases/network/multicast/mc_member/Makefile
@@ -1,18 +1,29 @@
-CFLAGS += -w -O
-LDLIBS += 
+#
+#    network/multicast/mc_member testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f mc_member ../../../bin
-	ln -f member ../../../bin
-	ln -f ManyGroups ../../../bin
-	ln -f TooManyGroups ../../../bin
+INSTALL_TARGETS		:= mc_member *ManyGroups
 
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/multicast/mc_member/mc_member b/testcases/network/multicast/mc_member/mc_member
index 1c917bc..89c6b9d 100755
--- a/testcases/network/multicast/mc_member/mc_member
+++ b/testcases/network/multicast/mc_member/mc_member
@@ -45,7 +45,7 @@
 LTPROOT=${LTPROOT:-"../../../../"}
 EXECUTABLES=${EXECUTABLES:-"member"}
 NUMLOOPS=${NUMLOOPS:-2}
-INTERFACE=${INTERFACE:-$($LTPROOT/tools/gethost `hostname`| grep address |awk '{ print $2 }')}
+INTERFACE=${INTERFACE:-$($LTPROOT/testcases/bin/gethost `hostname`| grep address |awk '{ print $2 }')}
 GLIST=${GLIST:-$TCsrc/ManyGroups}
 TooManyGLIST=${TooManyGLIST:-$TCsrc/TooManyGroups}
 ERRFILE=${ERRFILE:-$TCtmp/errors}
diff --git a/testcases/network/multicast/mc_opts/Makefile b/testcases/network/multicast/mc_opts/Makefile
index 7623c22..e00dedd 100644
--- a/testcases/network/multicast/mc_opts/Makefile
+++ b/testcases/network/multicast/mc_opts/Makefile
@@ -1,17 +1,29 @@
-CFLAGS += -Wall -g 
-LDLIBS += 
+#
+#    network/multicast/mc_opts testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	@set -e;ln -f mc_opts ../../../bin
-	@set -e;ln -f opts ../../../bin
-	@set -e;ln -f opts_e ../../../bin
+INSTALL_TARGETS		:= mc_opts
 
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/multicast/mc_opts/mc_opts b/testcases/network/multicast/mc_opts/mc_opts
index ffd25ea..3ed08fc 100755
--- a/testcases/network/multicast/mc_opts/mc_opts
+++ b/testcases/network/multicast/mc_opts/mc_opts
@@ -43,8 +43,7 @@
   PATH=../../../bin/:./:$PATH
 fi
 TC=mc_opts
-TCsrc=${TCsrc:-`pwd`}
-TCtmp=${TCtmp:-$TCsrc/$TC$$}
+TCtmp=${TCtmp:-$LTPROOT/bin/$TC$$}
 CLEANUP=${CLEANUP:-ON}
 EXECUTABLES=${EXECUTABLES:-"opts opts_e"}
 NUMLOOPS=${NUMLOOPS:-10}
@@ -58,8 +57,7 @@
   mkdir -p $TCtmp
   for i in $EXECUTABLES
   do
-    cp $TCsrc/$i $TCtmp
-    chmod 755 $TCtmp/$i
+    install -m 0755 "$LTPROOT/$i" "$TCtmp/."
   done
 }
 
@@ -117,7 +115,7 @@
    echo "$this_file: doing $0."
 
    cd /
-   if [ $TCtmp != $TCsrc ]; then
+   if [ "x$TCtmp" != "x$TCsrc" ]; then
       rm -rf $TCtmp
    fi
 }
diff --git a/testcases/network/nfs/Makefile b/testcases/network/nfs/Makefile
index 21a3571..c9dd3bf 100644
--- a/testcases/network/nfs/Makefile
+++ b/testcases/network/nfs/Makefile
@@ -1,10 +1,26 @@
-SUBDIRS = `ls */Makefile | sed "s/Makefile//g" `
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+#
+#    network/nfs test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+top_srcdir		?= ../../..
 
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/nfs/fsx-linux/Makefile b/testcases/network/nfs/fsx-linux/Makefile
index 6bc2523..eaf88a8 100644
--- a/testcases/network/nfs/fsx-linux/Makefile
+++ b/testcases/network/nfs/fsx-linux/Makefile
@@ -1,15 +1,29 @@
-CFLAGS += -w -O
-LDLIBS += 
+#
+#    network/nfs/fsx-linux testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f fsx.sh ../../../bin
+INSTALL_TARGETS		:= fsx.sh
 
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfs01/Makefile b/testcases/network/nfs/nfs01/Makefile
index 44748b5..64d9819 100644
--- a/testcases/network/nfs/nfs01/Makefile
+++ b/testcases/network/nfs/nfs01/Makefile
@@ -1,15 +1,29 @@
-CFLAGS += -w -O
-LDLIBS += 
+#
+#    network/nfs/nfs01 testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f nfs01 ../../../bin; ln -f open_files ../../../bin
+INSTALL_TARGETS		:= nfs01
 
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfs02/Makefile b/testcases/network/nfs/nfs02/Makefile
index c549b89..226c481 100644
--- a/testcases/network/nfs/nfs02/Makefile
+++ b/testcases/network/nfs/nfs02/Makefile
@@ -1,11 +1,31 @@
-all:
+#
+#    network/nfs/nfs02 testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install: generate
-	ln -f nfs02 ../../../bin
+top_srcdir		?= ../../../..
 
-generate:
-	../../generate.sh
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	rm -rf datafiles
-	rm -f ../../../bin/nfs02
+INSTALL_TARGETS		:= nfs02
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfs03/Makefile b/testcases/network/nfs/nfs03/Makefile
index af9d241..33464f5 100644
--- a/testcases/network/nfs/nfs03/Makefile
+++ b/testcases/network/nfs/nfs03/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/nfs/nfs03 testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f nfs03 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
-	rm -f ../../../bin/nfs03
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= nfs03
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfs04/Makefile b/testcases/network/nfs/nfs04/Makefile
index cdd6e7f..9676a57 100644
--- a/testcases/network/nfs/nfs04/Makefile
+++ b/testcases/network/nfs/nfs04/Makefile
@@ -1,11 +1,31 @@
-CFLAGS+= -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+#
+#    network/nfs/nfs04 testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(TARGETS) nfs04; do ln -f $$i ../../../bin/$$i ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	rm -f $(TARGETS)
+CPPFLAGS		+= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
+
+INSTALL_TARGETS		:= nfs04
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfs_fsstress/Makefile b/testcases/network/nfs/nfs_fsstress/Makefile
index d2c6903..7865346 100644
--- a/testcases/network/nfs/nfs_fsstress/Makefile
+++ b/testcases/network/nfs/nfs_fsstress/Makefile
@@ -1,16 +1,32 @@
-CFLAGS += -Wall -g -DNO_XFS -I. -D_LARGEFILE64_SOURCE -D_GNU_SOURCE
-LDFLAGS += 
+#
+#    network/nfs/nfs_fsstress testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f nfs_fsstress.sh ../../../bin
-	ln -f fsstress ../../../bin
+CPPFLAGS		+= -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DNO_XFS \
+			   -I$(abs_srcdir)
 
-clean:
-	rm -f $(TARGETS)
+INSTALL_TARGETS		:= nfs_fsstress.sh 
 
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfslock01/Makefile b/testcases/network/nfs/nfslock01/Makefile
index 8cc80ed..7cdb4b5 100644
--- a/testcases/network/nfs/nfslock01/Makefile
+++ b/testcases/network/nfs/nfslock01/Makefile
@@ -1,22 +1,33 @@
-CFLAGS += -w -O
-TESTS	= nfs_flock nfs_flock_dgen nfs_flock_frk
+#
+#    network/nfs/nfslock01 testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TESTS)
+top_srcdir		?= ../../../..
 
-install:
-	ln -f nfslock01 ../../../bin
-	ln -f $(TESTS) ../../../bin
+include $(top_srcdir)/include/mk/env_pre.mk
 
-nfs_flock:
-	$(CC) $(CFLAGS) $(LDFLAGS) -o nfs_flock nfs_flock.c nfs_flock_func.c
+INSTALL_TARGETS		:= nfslock01
 
-nfs_flock_frk:
-	$(CC) $(CFLAGS) $(LDFLAGS) -o nfs_flock_frk nfs_flock_frk.c
+MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%,$(filter-out %nfs_flock_func.c,$(wildcard $(abs_srcdir)/*.c)))
 
-nfs_flock_dgen:
-	$(CC) $(CFLAGS) $(LDFLAGS) -o nfs_flock_dgen nfs_flock_dgen.c
+$(MAKE_TARGETS): %: %.o nfs_flock_func.o
 
-clean:
-	rm -f $(TESTS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfslock01/nfs_flock.c b/testcases/network/nfs/nfslock01/nfs_flock.c
index 9c98679..2e92c0c 100644
--- a/testcases/network/nfs/nfslock01/nfs_flock.c
+++ b/testcases/network/nfs/nfslock01/nfs_flock.c
@@ -13,8 +13,6 @@
 #define BYTES 64
 #define LINES 16384
 
-int lock_reg(int, int, int, int, int, int);
-
 int 
 main(argc, argv)
    int argc;
diff --git a/testcases/network/nfs/nfslock01/nfs_flock.h b/testcases/network/nfs/nfslock01/nfs_flock.h
index 390f8f5..09e3845 100644
--- a/testcases/network/nfs/nfslock01/nfs_flock.h
+++ b/testcases/network/nfs/nfslock01/nfs_flock.h
@@ -3,6 +3,9 @@
 #include <errno.h>
 #include <sys/types.h>
 #include <fcntl.h>
+#include <unistd.h>
+
+int		lock_reg(int, int, off_t, int, off_t, int);
 
 #define read_lock(fd, offset, whence, len) \
 			lock_reg(fd, F_RDLCK, offset, whence, len, F_SETLK)
diff --git a/testcases/network/nfs/nfslock01/nfs_flock_dgen.c b/testcases/network/nfs/nfslock01/nfs_flock_dgen.c
index d9e7143..af34653 100644
--- a/testcases/network/nfs/nfslock01/nfs_flock_dgen.c
+++ b/testcases/network/nfs/nfslock01/nfs_flock_dgen.c
@@ -6,54 +6,52 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-int main(argc, argv)
-int argc;
-char **argv;
+int
+main (int argc, char **argv)
 {
-   int i, j, k, nlines, nchars, ctype;
-   char c, buf[BUFSIZ];
-   FILE *fp;
+	int i, j, k, nlines, nchars, ctype;
+	char c, buf[BUFSIZ];
+	FILE *fp;
 
-   if (argc != 5) {
-      printf("Usage:<nfs_flock_dgen > <file> <char/line> <lines> <ctype>\n");
-      exit(2);
-   }
+	if (argc != 5) {
+		printf("usage: <nfs_flock_dgen> <file> <char/line> <lines> <ctype>\n");
+		exit(2);
+	}
 
-   fp = fopen(argv[1], "w");
+	fp = fopen(argv[1], "w");
 
-   nchars = atoi(argv[2]);
-   if (nchars > BUFSIZ) {
-      printf("Exceeded the maximum limit of the buffer (4096)\n");
-      exit(3);
-   }
-   nlines = atoi(argv[3]);
-   ctype = atoi(argv[4]);
+	nchars = atoi(argv[2]);
+	if (nchars > BUFSIZ) {
+		printf("Exceeded the maximum limit of the buffer (%d)\n", BUFSIZ);
+		exit(3);
+	}
+	nlines = atoi(argv[3]);
+	ctype = atoi(argv[4]);
 
-   k = 0;
-   for(i = 1; i <= nlines; i++) {
-      if (ctype) {
-         if ((i%2) == 0)
-            c = '0';
-         else
-            c = '1';
-      }
-      else
-         c = 'A' + k;
+	k = 0;
+	for (i = 1; i <= nlines; i++) {
 
-      for(j=0; j < nchars; j++)
-         buf[j] = c;
+		if (ctype)
+			c = ((i % 2) ? '1' : '0');
+		else
+			c = 'A' + k;
 
-      fprintf(fp,"%s\n",buf);
+	for (j = 0; j < nchars; j++)
 
-      if (!ctype) {
-         if (i != 1 && i%26 == 0) {
-            k = 0;
-         } else
-            k++;
-      }
-   }
+		buf[j] = c;
 
-   fclose(fp);
-   return(0);
+		fprintf(fp, "%s\n", buf);
+
+		if (!ctype) {
+			if (i != 1 && i % 26 == 0)
+				k = 0;
+			else
+				k++;
+		}
+
+	}
+
+	fclose(fp);
+	return(0);
 }
 
diff --git a/testcases/network/nfs/nfslock01/nfs_flock_frk.c b/testcases/network/nfs/nfslock01/nfs_flock_frk.c
index 7a0054c..42de78b 100644
--- a/testcases/network/nfs/nfslock01/nfs_flock_frk.c
+++ b/testcases/network/nfs/nfslock01/nfs_flock_frk.c
@@ -11,9 +11,7 @@
 #include <sys/wait.h>
 
 int
-main(argc, argv)
-   int argc;
-   char **argv;
+main (int argc, char **argv)
 {
    pid_t pid;
    char *Prog;
diff --git a/testcases/network/nfs/nfslock01/nfs_flock_func.c b/testcases/network/nfs/nfslock01/nfs_flock_func.c
index f6d27d7..5a99499 100644
--- a/testcases/network/nfs/nfslock01/nfs_flock_func.c
+++ b/testcases/network/nfs/nfslock01/nfs_flock_func.c
@@ -4,9 +4,7 @@
 #include "nfs_flock.h"
 
 int
-lock_reg(fd, type, offset, whence, len, cmd)
-   int fd, type, offset;
-   int whence, len, cmd;
+lock_reg(int fd, int type, off_t offset, int whence, off_t len, int cmd)
 {
    struct flock lock;
 
@@ -19,9 +17,7 @@
 }
 
 int 
-lock_test(fd, type, offset, whence, len)
-   int fd, type, offset;
-   int whence, len;
+lock_test(int fd, int type, off_t offset, int whence, int len)
 {
    struct flock lock;
 
diff --git a/testcases/network/nfs/nfsstat01/Makefile b/testcases/network/nfs/nfsstat01/Makefile
index 1ab947a..8723dd7 100644
--- a/testcases/network/nfs/nfsstat01/Makefile
+++ b/testcases/network/nfs/nfsstat01/Makefile
@@ -1,7 +1,31 @@
-all: 
+#
+#    network/nfs/nfsstat01 test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f nfsstat01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
-	rm -f ../../bin/nfsstat01
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= nfsstat01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfsstress/Makefile b/testcases/network/nfs/nfsstress/Makefile
index ff16391..f24bdb9 100644
--- a/testcases/network/nfs/nfsstress/Makefile
+++ b/testcases/network/nfs/nfsstress/Makefile
@@ -1,14 +1,31 @@
-CFLAGS += -O -w -g
-LDLIBS := -lpthread
+#
+#    network/nfs/nfsstress test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f nfsstress ../../../bin
-	ln -f $(TARGETS) ../../../bin
+INSTALL_TARGETS		:= nfsstress
 
-clean:
-	rm -f $(TARGETS)
+LDLIBS 			+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfsv4/Makefile b/testcases/network/nfsv4/Makefile
index db546e3..02a01d0 100644
--- a/testcases/network/nfsv4/Makefile
+++ b/testcases/network/nfsv4/Makefile
@@ -1,4 +1,26 @@
-SUBDIRS := $(patsubst %/Makefile,%,$(wildcard */Makefile))
+#
+#    network/nfsv4 test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all clean install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/nfsv4/acl/Makefile b/testcases/network/nfsv4/acl/Makefile
index 51e17e4..e482605 100644
--- a/testcases/network/nfsv4/acl/Makefile
+++ b/testcases/network/nfsv4/acl/Makefile
@@ -1,25 +1,29 @@
 #
-#       @(#)Makefile	ACL Basic tests
+#    network/nfsv4/acl testcases Makefile.
 #
-# to make tests, use 'make'
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-ifeq ($(shell echo | $(CC) $(CFLAGS) -E -include sys/acl.h - 1>/dev/null 2>/dev/null && echo yes),yes)
-ACLTESTS := acl1 
-else
-ACLTESTS :=
-endif
+top_srcdir		?= ../../../..
 
-#include ../tests.init
-LIBS := -lacl
+include $(top_srcdir)/include/mk/env_post.mk
 
-all: $(ACLTESTS)
-	@chmod a+x runtest
+LDLIBS			+= -lacl
 
-acl1: acl1.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o acl1 acl1.c $(LIBS)
-
-install: $(ACLTESTS)
-	@set -e; for i in $(ACLTESTS); do ln -f $$i ../../../bin ; done
-
-clean:
-	rm -f $(ACLTESTS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfsv4/locks/Makefile b/testcases/network/nfsv4/locks/Makefile
index 24adbe0..1cffdf2 100644
--- a/testcases/network/nfsv4/locks/Makefile
+++ b/testcases/network/nfsv4/locks/Makefile
@@ -1,12 +1,33 @@
-TARGETS := locktests
+#
+#    network/nfsv4/locks testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all: $(TARGETS)
+top_srcdir		?= ../../../..
 
-locktests: locktests.c netsync.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -lpthread
+include $(top_srcdir)/include/mk/testcases.mk
 
-install: $(TARGETS)
-	ln -f locktests ../../../bin/locktests
+MAKE_TARGETS		:= locktests
 
-clean:
-	$(RM) locktests
+LDLIBS			+= -lpthread
+
+$(MAKE_TARGETS): $(patsubst $(abs_srcdir)/%.c,%.o,$(wildcard $(abs_srcdir)/*.c))
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/Makefile b/testcases/network/rpc/Makefile
index 9f0b42c..b783654 100644
--- a/testcases/network/rpc/Makefile
+++ b/testcases/network/rpc/Makefile
@@ -1,17 +1,29 @@
-SUBDIRS = basic_tests
+#
+#    network/rpc test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-	chmod +x rpc-tirpc-full-test-suite/run_tirpc_tests.sh
-	ln -f rpc-tirpc-full-test-suite/run_tirpc_tests.sh ../../bin
-	chmod +x rpc-tirpc-full-test-suite/run_rpc_tests.sh
-	ln -f rpc-tirpc-full-test-suite/run_rpc_tests.sh ../../bin
-	chmod +x rpc-tirpc-full-test-suite/rpc_ts_wizard.sh
-	ln -f rpc-tirpc-full-test-suite/rpc_ts_wizard.sh ../../bin
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+INSTALL_TARGETS		:= *.sh
 
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/rpc/basic_tests/Makefile b/testcases/network/rpc/basic_tests/Makefile
index 4894970..3160813 100644
--- a/testcases/network/rpc/basic_tests/Makefile
+++ b/testcases/network/rpc/basic_tests/Makefile
@@ -1,10 +1,26 @@
-SUBDIRS = rpc01 rpcinfo rup rusers
+#
+#    network/rpc/basic_tests test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/rpc/basic_tests/rpc01/Makefile b/testcases/network/rpc/basic_tests/rpc01/Makefile
index 3c3ad4d..cae4c2e 100644
--- a/testcases/network/rpc/basic_tests/rpc01/Makefile
+++ b/testcases/network/rpc/basic_tests/rpc01/Makefile
@@ -1,17 +1,29 @@
-CFLAGS += -w -O
-LDLIBS += 
+#
+#    network/rpc/basic_tests/rpc01 test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-install:
-	ln -f rpc01 ../../../../bin
-	ln -f rpc1 ../../../../bin
-	ln -f rpc_server ../../../../bin
+INSTALL_TARGETS		:= rpc01
 
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/basic_tests/rpc01/rpc01 b/testcases/network/rpc/basic_tests/rpc01/rpc01
index fd5a7d3..be87e94 100755
--- a/testcases/network/rpc/basic_tests/rpc01/rpc01
+++ b/testcases/network/rpc/basic_tests/rpc01/rpc01
@@ -38,8 +38,7 @@
 TC=${TC:=rpc01}
 TCbin=${TCbin:=`pwd`}
 TCdat=${TCdat:=$TCbin/datafiles}
-TCsrc=${TCsrc:=$TCbin}
-TCtmp=${TCtmp:=$TCsrc}
+TCtmp=${TCtmp:=$LTPROOT/testcases/bin}
 NUMLOOPS=${NUMLOOPS:=3}
 RHOST=${RHOST:=`hostname`}
 CLEANUP=${CLEANUP:="ON"}
diff --git a/testcases/network/rpc/basic_tests/rpc01/rpc1.c b/testcases/network/rpc/basic_tests/rpc01/rpc1.c
index 9c00b15..0bd259b 100644
--- a/testcases/network/rpc/basic_tests/rpc01/rpc1.c
+++ b/testcases/network/rpc/basic_tests/rpc01/rpc1.c
@@ -23,16 +23,13 @@
     char *data;
 };
 
-
 int xdr_receive_data(XDR *, struct data **);
 int xdr_send_data(XDR *, struct data *);
 void do_compare(int, char *, struct data *, char *);
+void usage_error(char *program_name);
 
-
-
-main(argc, argv)
-int argc;
-char *argv[];
+int
+main(int argc, char *argv[])
 {
     struct hostent *hp;
     struct data buffer, *return_buffer;
@@ -170,8 +167,6 @@
     exit(0);
 }
 
-
-
 void
 do_compare(int rpc_rc, char *msg, struct data *buffer, char *ret_data)
 {
@@ -190,11 +185,8 @@
     }
 }
 
-
-
-xdr_receive_data(xdrs, buffer)
-XDR *xdrs;
-struct data **buffer;
+int
+xdr_receive_data(XDR *xdrs, struct data **buffer)
 {
     struct data *bp;
     int i, rc;
@@ -210,10 +202,8 @@
     return(rc);
 }
 
-
-xdr_send_data(xdrs, buffer)
-XDR *xdrs;
-struct data *buffer;
+int
+xdr_send_data(XDR *xdrs, struct data *buffer)
 {
     int i, rc;
     char *p;
@@ -226,12 +216,10 @@
     return(rc);
 }
 
-
-usage_error(program_name)
-char *program_name;
+void
+usage_error(char *program_name)
 {
     fprintf(stderr, "Usage: %s -s server -f file [-p program-number] [-v version]\n",
 	    program_name);
     exit(2);
 }
-
diff --git a/testcases/network/rpc/basic_tests/rpc01/rpc_server.c b/testcases/network/rpc/basic_tests/rpc01/rpc_server.c
index 855db36..fb600a9 100644
--- a/testcases/network/rpc/basic_tests/rpc01/rpc_server.c
+++ b/testcases/network/rpc/basic_tests/rpc01/rpc_server.c
@@ -1,10 +1,11 @@
+#include <sys/ioctl.h>
 #include <stdio.h>
-#include <rpc/rpc.h>
 #include <netdb.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <sys/ioctl.h>
 #include <stdlib.h>
+#include <unistd.h>
+#include <rpc/rpc.h>
 
 int debug = 0;
 int program = 2000333;
@@ -19,16 +20,13 @@
     char *data;
 };
 
+void breakpoint(void);
+void service_request(struct svc_req *rqstp, SVCXPRT *transp);
+int xdr_receive_data(XDR *xdrs, struct data **buffer);
+int xdr_send_data(XDR *xdrs, struct data *buffer);
 
-
-void service_request();
-int xdr_receive_data();
-int xdr_send_data();
-
-
-main(argc, argv)
-int argc;
-char *argv[];
+int
+main (int argc, char *argv[])
 {
     SVCXPRT *transp;
     struct hostent *hp;
@@ -98,16 +96,9 @@
     exit(1);
 }
 
-
-
-
 void
-service_request(rqstp, transp)
-struct svc_req *rqstp;
-SVCXPRT *transp;
+service_request(struct svc_req *rqstp, SVCXPRT *transp)
 {
-    char *s;
-    int ret;
     struct data *buffer;
 
     switch (rqstp->rq_proc) {
@@ -132,11 +123,8 @@
     }
 }
 
-
-
-xdr_receive_data(xdrs, buffer)
-XDR *xdrs;
-struct data **buffer;
+int
+xdr_receive_data(XDR *xdrs, struct data **buffer)
 {
     struct data *bp;
     int i, rc;
@@ -152,10 +140,8 @@
     return(rc);
 }
 
-
-xdr_send_data(xdrs, buffer)
-XDR *xdrs;
-struct data *buffer;
+int
+xdr_send_data(XDR *xdrs, struct data *buffer)
 {
     int i, rc;
     char *p;
@@ -168,12 +154,7 @@
     return(rc);
 }
 
-
-
-
-
-
-breakpoint()
+void breakpoint(void)
 {
     if (debug)
 	printf("breakpoint\n");
diff --git a/testcases/network/rpc/basic_tests/rpcinfo/Makefile b/testcases/network/rpc/basic_tests/rpcinfo/Makefile
index 8d75bf1..5ef5951 100644
--- a/testcases/network/rpc/basic_tests/rpcinfo/Makefile
+++ b/testcases/network/rpc/basic_tests/rpcinfo/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/rpc/basic_tests/rpcinfo test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f rpcinfo01 ../../../../bin
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= rpcinfo01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/basic_tests/rup/Makefile b/testcases/network/rpc/basic_tests/rup/Makefile
index ef3f89f..567c3d8 100644
--- a/testcases/network/rpc/basic_tests/rup/Makefile
+++ b/testcases/network/rpc/basic_tests/rup/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/rpc/basic_tests/rup test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f rup01 ../../../../bin
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= rup01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/basic_tests/rusers/Makefile b/testcases/network/rpc/basic_tests/rusers/Makefile
index fef7e59..6d7ea41 100644
--- a/testcases/network/rpc/basic_tests/rusers/Makefile
+++ b/testcases/network/rpc/basic_tests/rusers/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/rpc/basic_tests/rusers01 test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f rusers01 ../../../../bin
+top_srcdir		?= ../../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= rusers01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/sctp/Makefile b/testcases/network/sctp/Makefile
index 0d4d115..9d45ac1 100644
--- a/testcases/network/sctp/Makefile
+++ b/testcases/network/sctp/Makefile
@@ -1,11 +1,57 @@
-SUBDIRS =  lib testlib func_tests 
+#
+#    network/sctp test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+LIBSCTP			:= $(DESTDIR)/$(libdir)/libsctp.a
+LIBSCTPUTIL		:= $(DESTDIR)/$(libdir)/libsctputil.a
+LIBSCTPDIR		:= lib
+LIBSCTPUTILDIR		:= testlib
 
+FILTER_OUT_DIRS		:= $(LIBSCTPDIR) $(LIBSCTPUTILDIR)
+
+$(LIBSCTPDIR) $(LIBSCTPUTILDIR):
+	mkdir -p "$@"
+
+lib-clean:: $(LIBSCTPDIR) $(LIBSCTPUTILDIR)
+	for i in $^; do \
+	    $(MAKE) -C "$$i" -f "$(abs_srcdir)/$$i/Makefile" clean; \
+	done
+
+
+$(LIBSCTP): $(LIBSCTPDIR)
+	set -e; for i in all install; do \
+	    $(MAKE) -C "$^" -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
+
+$(LIBSCTPUTIL): $(LIBSCTPUTILDIR)
+	set -e; for i in all install; do \
+	    $(MAKE) -C "$^" -f "$(abs_srcdir)/$^/Makefile" $$i; \
+	done
+
+trunk-all: $(LIBSCTP) $(LIBSCTPUTIL)
+
+trunk-clean:: | lib-clean
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/sctp/func_tests/Makefile b/testcases/network/sctp/func_tests/Makefile
index ff7dd7c..bb0187d 100644
--- a/testcases/network/sctp/func_tests/Makefile
+++ b/testcases/network/sctp/func_tests/Makefile
@@ -19,130 +19,53 @@
 ###########################################################################
 # name of file	: Makefile						  #
 ###########################################################################
-INCLUDES += -I../../../../include -I../include -I../testlib
-LIBS += -L../../../../lib -L../lib -L../testlib
 
-CFLAGS += -g $(INCLUDES) -DLTP -Wall
+top_srcdir	?= ../../../..
 
-LOADLIBES += $(LIBS) -lltp -lsctputil -lsctp -lpthread
+include $(top_srcdir)/include/mk/testcases.mk
 
-V6FLAGS = -DTEST_V6=1 $(CFLAGS)
+CPPFLAGS	+= -I$(abs_srcdir)/../include -I$(abs_srcdir)/../testlib -DLTP
 
-SRCS = $(wildcard *.c)
+LDLIBS		+= -lsctputil -lsctp -lpthread
 
-V4_TARGETS = test_1_to_1_accept_close test_1_to_1_addrs test_1_to_1_connect \
-             test_1_to_1_events test_1_to_1_initmsg_connect \
-             test_1_to_1_nonblock test_1_to_1_recvfrom test_1_to_1_recvmsg \
-             test_1_to_1_rtoinfo test_1_to_1_send test_1_to_1_sendmsg \
-             test_1_to_1_sendto test_1_to_1_shutdown \
-             test_1_to_1_socket_bind_listen test_1_to_1_sockopt \
-             test_1_to_1_threads test_assoc_abort test_assoc_shutdown \
-             test_autoclose test_basic test_connect test_fragments \
-             test_getname test_inaddr_any test_peeloff test_recvmsg \
-             test_sctp_sendrecvmsg test_sockopt test_tcp_style \
-             test_timetolive test_1_to_1_connectx test_connectx
+V4_TARGETS	:= $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c))
 
-V6_TARGETS = test_basic_v6 test_fragments_v6 test_getname_v6 \
-             test_inaddr_any_v6 test_peeloff_v6 test_sctp_sendrecvmsg_v6 \
-             test_sockopt_v6 test_tcp_style_v6 test_timetolive_v6
+V6_TARGETS	:= test_basic_v6 test_fragments_v6 test_getname_v6 \
+		   test_inaddr_any_v6 test_peeloff_v6 \
+		   test_sctp_sendrecvmsg_v6 test_sockopt_v6 \
+		   test_tcp_style_v6 test_timetolive_v6
 
-all: $(V4_TARGETS) $(V6_TARGETS)
+$(V6_TARGETS): CPPFLAGS += -DTEST_V6=1
 
-test_1_to_1_accept_close: test_1_to_1_accept_close.c
-test_1_to_1_addrs: test_1_to_1_addrs.c
-test_1_to_1_connect: test_1_to_1_connect.c
-test_1_to_1_events: test_1_to_1_events.c
-test_1_to_1_initmsg_connect: test_1_to_1_initmsg_connect.c
-test_1_to_1_nonblock: test_1_to_1_nonblock.c
-test_1_to_1_recvfrom: test_1_to_1_recvfrom.c
-test_1_to_1_recvmsg: test_1_to_1_recvmsg.c
-test_1_to_1_rtoinfo: test_1_to_1_rtoinfo.c
-test_1_to_1_send: test_1_to_1_send.c
-test_1_to_1_sendmsg: test_1_to_1_sendmsg.c
-test_1_to_1_sendto: test_1_to_1_sendto.c
-test_1_to_1_shutdown: test_1_to_1_shutdown.c
-test_1_to_1_socket_bind_listen: test_1_to_1_socket_bind_listen.c
-test_1_to_1_sockopt: test_1_to_1_sockopt.c
-test_1_to_1_threads: test_1_to_1_threads.c
-test_assoc_abort: test_assoc_abort.c
-test_assoc_shutdown: test_assoc_shutdown.c
-test_autoclose: test_autoclose.c
-test_basic: test_basic.c
-test_basic_v6: test_basic_v6.o
-test_connect: test_connect.c
-test_fragments: test_fragments.c
-test_fragments_v6: test_fragments_v6.o
-test_getname: test_getname.c
-test_getname_v6: test_getname_v6.o
-test_inaddr_any: test_inaddr_any.c
-test_inaddr_any_v6: test_inaddr_any_v6.o
-test_peeloff: test_peeloff.c
-test_peeloff_v6: test_peeloff_v6.o
-test_recvmsg: test_recvmsg.c
-test_sctp_sendrecvmsg: test_sctp_sendrecvmsg.c
-test_sctp_sendrecvmsg_v6: test_sctp_sendrecvmsg_v6.o
-test_sockopt: test_sockopt.c
-test_sockopt_v6: test_sockopt_v6.o
-test_tcp_style: test_tcp_style.c
-test_tcp_style_v6: test_tcp_style_v6.o
-test_timetolive: test_timetolive.c
-test_timetolive_v6: test_timetolive_v6.o
-test_1_to_1_connectx: test_1_to_1_connectx.c
-test_connectx: test_connectx.c
+%_v6.o: %.c
+	$(COMPILE.c) $(OUTPUT_OPTION) $<
 
-test_basic_v6.o: test_basic.c
-	$(CC) -c $(V6FLAGS) -o $@ $^
-test_fragments_v6.o: test_fragments.c
-	$(CC) -c $(V6FLAGS) -o $@ $^
-test_getname_v6.o: test_getname.c
-	$(CC) -c $(V6FLAGS) -o $@ $^
-test_inaddr_any_v6.o: test_inaddr_any.c
-	$(CC) -c $(V6FLAGS) -o $@ $^
-test_peeloff_v6.o: test_peeloff.c
-	$(CC) -c $(V6FLAGS) -o $@ $^
-test_sctp_sendrecvmsg_v6.o: test_sctp_sendrecvmsg.c
-	$(CC) -c $(V6FLAGS) -o $@ $^
-test_sockopt_v6.o: test_sockopt.c
-	$(CC) -c $(V6FLAGS) -o $@ $^
-test_tcp_style_v6.o: test_tcp_style.c
-	$(CC) -c $(V6FLAGS) -o $@ $^
-test_timetolive_v6.o: test_timetolive.c
-	$(CC) -c $(V6FLAGS) -o $@ $^
+MAKE_TARGETS	:= $(V4_TARGETS) $(V6_TARGETS)
 
-v4test: ${V4_TARGETS}
+v4test: $(V4_TARGETS)
 	@for a in $^;                           \
 	do                                      \
 		echo "./$$a";                   \
-		if ./$$a;                       \
-		then                            \
-			echo "$$a passes";      \
+		if ./$$a; then                  \
+			echo "$$a - passed";    \
 			echo "";                \
 		else                            \
-			echo "$$a fails";       \
+			echo "$$a - failed";    \
 			exit 1;                 \
 		fi;                             \
 	done
 
-v6test: ${V6_TARGETS}
+v6test: $(V6_TARGETS)
 	@for a in $^;                           \
 	do                                      \
 		echo "./$$a";                   \
-		if ./$$a;                       \
-		then                            \
-			echo "$$a passes";      \
+		if ./$$a; then                  \
+			echo "$$a - passed";    \
 			echo "";                \
 		else                            \
-			echo "$$a fails";       \
+			echo "$$a - failed";    \
 			exit 1;                 \
 		fi;                             \
 	done
 
-install:
-	ln -f $(V4_TARGETS) ../../../bin
-	ln -f $(V6_TARGETS) ../../../bin
-
-clean:
-	rm -f $(V4_TARGETS)
-	rm -f $(V6_TARGETS)
-	rm -f ../../../bin/$(V6_TARGETS)
-	rm -f *.o
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/sctp/lib/Makefile b/testcases/network/sctp/lib/Makefile
index 0f767bc..f0d0b6f 100644
--- a/testcases/network/sctp/lib/Makefile
+++ b/testcases/network/sctp/lib/Makefile
@@ -1,42 +1,31 @@
 #
-# (C) Copyright IBM Corp. 2003
+#    testcases/network/sctp/lib Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-#########################################################################
-# name of file	: Makefile						#
-# description	: make(1) description file to build SCTP library        #
-#		                                                        # 
-#########################################################################
-INCLUDES+=-I../include
+top_srcdir		?= ../../../..
 
-CFLAGS += -g $(INCLUDES)
-SRCS=addrs.c bindx.c opt_info.c peeloff.c recvmsg.c sendmsg.c connectx.c
-OBJS=$(SRCS:.c=.o)
-MAINS=libsctp.a
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: libsctp.a
+CPPFLAGS		+= -I$(abs_srcdir)/../include
 
-libsctp.a: $(OBJS)
-	$(AR) -rc $@ $(OBJS)
+LIB			:= libsctp.a
 
-$(OBJS): $(SRCS) ../include/netinet/sctp.h 
-	$(CC) -c $(SRCS) $(CFLAGS)
-
-install:
-
-clean:
-	/bin/rm -rf $(OBJS) libsctp.a
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/network/sctp/testlib/Makefile b/testcases/network/sctp/testlib/Makefile
index 2f00fa6..289e6af 100644
--- a/testcases/network/sctp/testlib/Makefile
+++ b/testcases/network/sctp/testlib/Makefile
@@ -1,44 +1,40 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
+#    testcases/network/sctp/testlib Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-#########################################################################
-# name of file	: Makefile						#
-# description	: make(1) description file to build a library for the 	#
-#		  common routines in the sctp tests.			#
-#########################################################################
-INCLUDES+=-I../../../../include -I../include -I.
-LIBS+=-L../../../../lib -L../lib
+top_srcdir		?= ../../../..
 
-CFLAGS += -g $(INCLUDES) -DLTP -D_USC_LIB_
-LOADLIBES += $(LIBS) -lltp -lsctp
-SRCS=sctputil.c
-OBJS=$(SRCS:.c=.o)
-MAINS=libsctputil.a
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: libsctputil.a
+CPPFLAGS		+= -DLTP -D_USC_LIB_ -I$(abs_srcdir)/../include
 
-libsctputil.a: $(OBJS)
-	$(AR) -rc $@ $(OBJS)
+LDLIBS			+= -lltp -lsctp
 
-$(OBJS): $(SRCS) ../include/netinet/sctp.h
-	$(CC) -c $(SRCS) $(CFLAGS)
+LIB			:= libsctputil.a
 
-install:
+$(eval $(lib_target))
 
-clean:
-	/bin/rm -rf $(OBJS) libsctputil.a
+$(MAKE_TARGETS): | $(libdir)/libsctp.a
+
+$(libdir)/libsctp.a:
+	$(MAKE) -C $(builddir)/../lib
+
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/network/sctp/testlib/sctputil.c b/testcases/network/sctp/testlib/sctputil.c
index e8cbdfd..05c4d70 100644
--- a/testcases/network/sctp/testlib/sctputil.c
+++ b/testcases/network/sctp/testlib/sctputil.c
@@ -50,8 +50,8 @@
 #include <sys/uio.h>
 #include <netinet/in.h> 
 #include <malloc.h>
-#include <netinet/sctp.h>
-#include <sctputil.h>
+#include "netinet/sctp.h"
+#include "sctputil.h"
 
 /* This function prints the cmsg data. */
 void
diff --git a/testcases/network/sockets/Makefile b/testcases/network/sockets/Makefile
index 77a8b41..763d72e 100644
--- a/testcases/network/sockets/Makefile
+++ b/testcases/network/sockets/Makefile
@@ -1,37 +1,31 @@
 #
-#  Copyright (c) International Business Machines  Corp., 2001
+#    network/sockets testcases Makefile.
 #
-#  This program is free software;  you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version.
+#    Copyright (C) 2009, Cisco Systems Inc.
 #
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-#  You should have received a copy of the GNU General Public License
-#  along with this program;  if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
 #
 
-###########################################################################
-# name of file	: Makefile						  #
-# description	: make(2) erver & client for socket tests        	  #
-###########################################################################
-CFLAGS+=	-I../../../../include -Wall -g
-LOADLIBES+=     -lpthread
+top_srcdir		?= ../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: $(TARGETS)
+INSTALL_TARGETS		:= ltpSockets.sh
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../bin/$$i ; done ;
+LDLIBS			+= -lpthread
 
-clean:
-	rm -f $(TARGETS)
-
-
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/Makefile b/testcases/network/stress/Makefile
index 70576a2..673392e 100644
--- a/testcases/network/stress/Makefile
+++ b/testcases/network/stress/Makefile
@@ -1,10 +1,26 @@
-SUBDIRS = `ls */Makefile | sed "s/Makefile//g"`
+#
+#    network/stress test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/stress/broken_ip/Makefile b/testcases/network/stress/broken_ip/Makefile
index f7e072c..af5b54d 100644
--- a/testcases/network/stress/broken_ip/Makefile
+++ b/testcases/network/stress/broken_ip/Makefile
@@ -1,14 +1,31 @@
-SCRIPTS = broken_ip4-version broken_ip4-ihl broken_ip4-totlen \
-	  broken_ip4-fragment broken_ip4-protcol \
-	  broken_ip4-checksum broken_ip4-dstaddr \
-	  broken_ip6-version broken_ip6-plen \
-	  broken_ip6-nexthdr broken_ip6-dstaddr
+#
+#    network/stress/broken_ip test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../bin/$$i ; done
+INSTALL_TARGETS		:= broken_ip*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/dns/Makefile b/testcases/network/stress/dns/Makefile
index 459f411..a627839 100644
--- a/testcases/network/stress/dns/Makefile
+++ b/testcases/network/stress/dns/Makefile
@@ -1,11 +1,31 @@
-SCRIPTS = dns4-stress dns6-stress \
-	  dns-stress01-rmt dns-stress02-rmt
+#
+#    network/stress/dns test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../bin/$$i ; done
+INSTALL_TARGETS		:= dns-*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/ftp/Makefile b/testcases/network/stress/ftp/Makefile
index fb9c290..a1a5224 100644
--- a/testcases/network/stress/ftp/Makefile
+++ b/testcases/network/stress/ftp/Makefile
@@ -1,13 +1,31 @@
-SCRIPTS = ftp4-download-stress ftp6-download-stress \
-	  ftp-download-stress01-rmt ftp-download-stress02-rmt \
-	  ftp4-upload-stress ftp6-upload-stress \
-	  ftp-upload-stress01-rmt ftp-upload-stress02-rmt
+#
+#    network/stress/ftp test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../bin/$$i ; done
+INSTALL_TARGETS		:= ftp-*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/http/Makefile b/testcases/network/stress/http/Makefile
index 6c49c87..35d9e5f 100644
--- a/testcases/network/stress/http/Makefile
+++ b/testcases/network/stress/http/Makefile
@@ -1,11 +1,31 @@
-SCRIPTS = http4-stress http6-stress \
-	  http-stress01-rmt http-stress02-rmt
+#
+#    network/stress/http test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../bin/$$i ; done
+INSTALL_TARGETS		:= http-*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/icmp/Makefile b/testcases/network/stress/icmp/Makefile
index 70576a2..0dad1d1 100644
--- a/testcases/network/stress/icmp/Makefile
+++ b/testcases/network/stress/icmp/Makefile
@@ -1,10 +1,26 @@
-SUBDIRS = `ls */Makefile | sed "s/Makefile//g"`
+#
+#    network/stress/icmp test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, October 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/stress/icmp/multi-diffip/Makefile b/testcases/network/stress/icmp/multi-diffip/Makefile
index 03031dc..d114c45 100644
--- a/testcases/network/stress/icmp/multi-diffip/Makefile
+++ b/testcases/network/stress/icmp/multi-diffip/Makefile
@@ -1,17 +1,31 @@
-SCRIPTS = icmp4-multi-diffip01 \
-	  icmp4-multi-diffip02 icmp4-multi-diffip03 \
-	  icmp4-multi-diffip04 icmp4-multi-diffip05 \
-	  icmp4-multi-diffip06 icmp4-multi-diffip07 \
-	  icmp6-multi-diffip01 \
-	  icmp6-multi-diffip02 icmp6-multi-diffip03 \
-	  icmp6-multi-diffip04 icmp6-multi-diffip05 \
-	  icmp6-multi-diffip06 icmp6-multi-diffip07
+#
+#    network/stress/icmp/multi-diffip testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, October 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../../bin/$$i ; done
+INSTALL_TARGETS		:= icmp*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/icmp/multi-diffnic/Makefile b/testcases/network/stress/icmp/multi-diffnic/Makefile
index 0ea07f5..4746e87 100644
--- a/testcases/network/stress/icmp/multi-diffnic/Makefile
+++ b/testcases/network/stress/icmp/multi-diffnic/Makefile
@@ -1,17 +1,31 @@
-SCRIPTS = icmp4-multi-diffnic01 \
-	  icmp4-multi-diffnic02 icmp4-multi-diffnic03 \
-	  icmp4-multi-diffnic04 icmp4-multi-diffnic05 \
-	  icmp4-multi-diffnic06 icmp4-multi-diffnic07 \
-	  icmp6-multi-diffnic01 \
-	  icmp6-multi-diffnic02 icmp6-multi-diffnic03 \
-	  icmp6-multi-diffnic04 icmp6-multi-diffnic05 \
-	  icmp6-multi-diffnic06 icmp6-multi-diffnic07
+#
+#    network/stress/icmp/multi-diffnic testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, October 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../../bin/$$i ; done
+INSTALL_TARGETS		:= icmp*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/icmp/uni-basic/Makefile b/testcases/network/stress/icmp/uni-basic/Makefile
index dcf1c66..d5d15eb 100644
--- a/testcases/network/stress/icmp/uni-basic/Makefile
+++ b/testcases/network/stress/icmp/uni-basic/Makefile
@@ -1,17 +1,31 @@
-SCRIPTS = icmp4-uni-basic01 \
-	  icmp4-uni-basic02 icmp4-uni-basic03 \
-	  icmp4-uni-basic04 icmp4-uni-basic05 \
-	  icmp4-uni-basic06 icmp4-uni-basic07 \
-	  icmp6-uni-basic01 \
-	  icmp6-uni-basic02 icmp6-uni-basic03 \
-	  icmp6-uni-basic04 icmp6-uni-basic05 \
-	  icmp6-uni-basic06 icmp6-uni-basic07
+#
+#    network/stress/icmp/uni-basic testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, October 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../../bin/$$i ; done
+INSTALL_TARGETS		:= icmp*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/interface/Makefile b/testcases/network/stress/interface/Makefile
index 702c168..f4fda67 100644
--- a/testcases/network/stress/interface/Makefile
+++ b/testcases/network/stress/interface/Makefile
@@ -1,18 +1,31 @@
-SCRIPTS = if4-updown \
-	  if4-addr-change \
-	  if4-alias-adddel if4-alias-addlarge \
-	  if4-route-adddel if4-route-addlarge \
-	  if4-mtu-change \
-	  if6-updown \
-	  if6-addr-adddel if6-addr-addlarge \
-	  if6-route-adddel if6-route-addlarge \
-	  if6-mtu-change
+#
+#    network/stress/interface test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../bin/$$i ; done
+INSTALL_TARGETS		:= if*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/multicast/Makefile b/testcases/network/stress/multicast/Makefile
index 70576a2..79286a8 100644
--- a/testcases/network/stress/multicast/Makefile
+++ b/testcases/network/stress/multicast/Makefile
@@ -1,10 +1,26 @@
-SUBDIRS = `ls */Makefile | sed "s/Makefile//g"`
+#
+#    network/stress/multicast test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, October 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/stress/multicast/grp-operation/Makefile b/testcases/network/stress/multicast/grp-operation/Makefile
index 0ff7f05..37d28f0 100644
--- a/testcases/network/stress/multicast/grp-operation/Makefile
+++ b/testcases/network/stress/multicast/grp-operation/Makefile
@@ -1,11 +1,31 @@
-SCRIPTS = mcast4-grpope01 mcast4-grpope02 mcast4-grpope03 mcast4-grpope04 \
-	  mcast6-grpope01 mcast6-grpope02 mcast6-grpope03 mcast6-grpope04
+#
+#    network/stress/grp-operation testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, October 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../../bin/$$i ; done
+INSTALL_TARGETS		:= mcast*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/multicast/packet-flood/Makefile b/testcases/network/stress/multicast/packet-flood/Makefile
index 1585717..53b5361 100644
--- a/testcases/network/stress/multicast/packet-flood/Makefile
+++ b/testcases/network/stress/multicast/packet-flood/Makefile
@@ -1,11 +1,31 @@
-SCRIPTS = mcast4-pktfld01 mcast4-pktfld02 \
-	  mcast6-pktfld01 mcast6-pktfld02
+#
+#    network/stress/packet-flood testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, October 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../../bin/$$i ; done
+INSTALL_TARGETS		:= mcast*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/multicast/query-flood/Makefile b/testcases/network/stress/multicast/query-flood/Makefile
index 68bfb0c..e499955 100644
--- a/testcases/network/stress/multicast/query-flood/Makefile
+++ b/testcases/network/stress/multicast/query-flood/Makefile
@@ -1,13 +1,31 @@
-SCRIPTS = mcast4-queryfld01 mcast4-queryfld02 mcast4-queryfld03 \
-	  mcast4-queryfld04 mcast4-queryfld05 mcast4-queryfld06 \
-	  mcast6-queryfld01 mcast6-queryfld02 mcast6-queryfld03 \
-	  mcast6-queryfld04 mcast6-queryfld05 mcast6-queryfld06
+#
+#    network/stress/query-flood testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, October 2009
+#
 
-all:
-	@chmod +x $(SCRIPTS)
+top_srcdir		?= ../../../../..
 
-install:
-	@set -e; for i in $(SCRIPTS); do ln -f $$i ../../../../bin ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SCRIPTS); do rm -f ../../../../bin/$$i ; done
+INSTALL_TARGETS		:= mcast*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/ns-tools/Makefile b/testcases/network/stress/ns-tools/Makefile
index ca5f173..f0925b2 100644
--- a/testcases/network/stress/ns-tools/Makefile
+++ b/testcases/network/stress/ns-tools/Makefile
@@ -1,62 +1,38 @@
-SCRIPTS=check_envval \
-	get_ifname initialize_if set_ipv4addr add_ipv6addr \
-	check_icmpv4_connectivity check_icmpv6_connectivity \
-	check_netem check_setkey \
-	create_file \
-	find_portbundle \
-	bg_tcp_traffic \
-	killall_icmp_traffic killall_tcp_traffic killall_udp_traffic \
-	output_ipsec_conf \
-	ns-echoclient
+#
+#    network/stress/ns-tools test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-BINS=ns-tcpserver ns-tcpclient ns-udpserver ns-udpclient \
-     ns-icmpv4_sender ns-icmpv6_sender \
-     ns-udpsender \
-     ns-icmp_redirector \
-     ns-mcast_receiver ns-igmp_querier \
-     ns-mcast_join 
+top_srcdir		?= ../../../..
 
-TARGETS=$(SCRIPTS) $(BINS)
+include $(top_srcdir)/include/mk/env_pre.mk
 
-#CC=gcc
-#CFLAGS=-g -Wall
-#CFLAGS=-O2
-CFLAGS += -Wall
+INSTALL_TARGETS	:= check_envval get_ifname initialize_if set_ipv4addr \
+		   add_ipv6addr check_icmpv4_connectivity \
+		   check_icmpv6_connectivity check_netem check_setkey \
+		   create_file find_portbundle bg_tcp_traffic \
+		   killall_icmp_traffic killall_tcp_traffic \
+		   killall_udp_traffic output_ipsec_conf ns-echoclient
 
-all:	scripts $(BINS)
+MAKE_TARGETS	:= $(patsubst $(abs_srcdir)/%.c,%,$(filter-out %ns-common.c,$(wildcard $(abs_srcdir)/*.c)))
 
-ns-tcpserver:	ns-common.o ns-tcpserver.o
-ns-tcpclient:	ns-common.o ns-tcpclient.o
-ns-udpserver:	ns-common.o ns-udpserver.o
-ns-udpclient:	ns-common.o ns-udpclient.o
-ns-icmpv4_sender:	ns-common.o ns-icmpv4_sender.o
-ns-icmpv6_sender:	ns-common.o ns-icmpv6_sender.o
-ns-udpsender:	ns-common.o ns-udpsender.o
-ns-icmp_redirector:	ns-common.o ns-icmp_redirector.o
-ns-mcast_receiver:	ns-common.o ns-mcast_receiver.o
-ns-igmp_querier:	ns-common.o ns-igmp_querier.o
-ns-mcast_join:	ns-common.o ns-mcast_join.o
+$(MAKE_TARGETS): %: %.o ns-common.o
 
-ns-common.o: 	ns-traffic.h ns-common.c 
-ns-tcpserver.o:	ns-traffic.h ns-tcpserver.c
-ns-tcpclient.o:	ns-traffic.h ns-tcpclient.c
-ns-udpserver.o:	ns-traffic.h ns-udpserver.c
-ns-udpclient.o:	ns-traffic.h ns-udpclient.c
-ns-icmpv4_sender.o:	ns-traffic.h ns-icmpv4_sender.c
-ns-icmpv6_sender.o:	ns-traffic.h ns-icmpv6_sender.c
-ns-udpsender.o:	ns-traffic.h ns-udpsender.c
-ns-icmp_redirector.o:	ns-traffic.h ns-icmp_redirector.c
-ns-mcast_receiver.o:	ns-traffic.h ns-mcast.h ns-mcast_receiver.c
-ns-igmp_querier.o:	ns-traffic.h ns-mcast.h ns-igmp_querier.c
-ns-mcast_join.o:	ns-traffic.h ns-mcast.h ns-mcast_join.c
-
-scripts:
-	@chmod +x $(SCRIPTS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
-
-clean:
-	@set -e; for i in $(TARGETS); do rm -f ../../../bin/$$i ; done
-	rm -f $(BINS) *.o
-	@true
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/Makefile b/testcases/network/tcp_cmds/Makefile
index 3feb71f..f2bac24 100644
--- a/testcases/network/tcp_cmds/Makefile
+++ b/testcases/network/tcp_cmds/Makefile
@@ -1,12 +1,32 @@
-SUBDIRS = `ls */Makefile | sed "s/Makefile//g"`
+#
+#    network/tcp_cmds test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+top_srcdir		?= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(top_srcdir)/include/mk/env_pre.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+trunk-all: | ../datafiles/bin.sm
 
+../datafiles/bin.sm:
+	$(MAKE) -C .. -f "$(abs_srcdir)/../Makefile" generate
 
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/tcp_cmds/Makefile.inc b/testcases/network/tcp_cmds/Makefile.inc
new file mode 100644
index 0000000..427b41e
--- /dev/null
+++ b/testcases/network/tcp_cmds/Makefile.inc
@@ -0,0 +1,30 @@
+#
+#    network/tcp_cmds datafiles dependent include Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
+
+all: | ../../datafiles/bin.sm
+
+../../datafiles/bin.sm:
+	$(MAKE) -C ../.. -f "$(abs_srcdir)/../../Makefile" generate
+
+.PHONY: generate
+
+# vim: syntax=make
diff --git a/testcases/network/tcp_cmds/arp/Makefile b/testcases/network/tcp_cmds/arp/Makefile
index 390e4ef..bfaba19 100644
--- a/testcases/network/tcp_cmds/arp/Makefile
+++ b/testcases/network/tcp_cmds/arp/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/tcp_cmds/arp testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f arp01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= arp01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/arp/arp01 b/testcases/network/tcp_cmds/arp/arp01
index 8939b20..11edc26 100755
--- a/testcases/network/tcp_cmds/arp/arp01
+++ b/testcases/network/tcp_cmds/arp/arp01
@@ -34,32 +34,6 @@
 #      -Ported
 #
 #-----------------------------------------------------------------------
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-RHOST=${RHOST:-`hostname`}
-SLEEPTIME=${SLEEPTIME:-1}
-NUMLOOPS=${NUMLOOPS:-20}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-#
-#-----------------------------------------------------------------------
-
-exists()
-{
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
-}
 
 #-----------------------------------------------------------------------
 #
@@ -69,15 +43,19 @@
 
 do_setup()
 {
-   $trace_logic
-   export TCID="arp01"
-   export TST_TOTAL=1
-   export TST_COUNT=1
 
-   exists "arp tr awk ping sleep"
+    NUMLOOPS=${NUMLOOPS:-20}
+    TST_TOTAL=$(( $NUMLOOPS * 2 ))
 
-   LUSER=`id | tr -s '()' '  ' | awk '{print $2}'`
-   [ "$LUSER" = "root" ] || end_testcase "Must be root to run this test!"
+    tst_setup
+    exists arp grep hostname ping sleep whoami
+
+    RHOST=${RHOST:-$(hostname)}
+    SLEEPTIME=${SLEEPTIME:-1}
+    LUSER=$(whoami)
+
+    [ "$LUSER" = "root" ] || end_testcase "Must be root to run this test!"
+
 }
 
 #-----------------------------------------------------------------------
@@ -88,52 +66,34 @@
 
 do_test()
 {
-   $trace_logic
+    while [ $TST_COUNT -le $NUMLOOPS ]; do
+        arp -a 2>&1 1>/dev/null || end_testcase "arp -a failed"
+        incr_tst_count
+    done
 
-   COUNT=1
-   while [ $COUNT -le $NUMLOOPS ]
-   do
-      arp -a 2>&1 1>/dev/null
-      [ $? -eq 0 ] || end_testcase "arp -a failed"
-      COUNT=`expr $COUNT + 1`
-   done
+    sleep $SLEEPTIME
 
-   sleep $SLEEPTIME
+    # PURPOSE:  stress the automatic creation of arp entries by pinging a host 
+    #           and deleting the arp entry again.
 
-   # PURPOSE:  stress the automatic creation of arp entries by pinging a host 
-   #           and deleting the arp entry again.
+    while [ $TST_COUNT -le $TST_TOTAL ]; do
 
-   COUNT=1
-   while [ $COUNT -le $NUMLOOPS ]
-   do
-      ping -c1 $RHOST 2>&1 1>/dev/null
-      [ $? = 0 ] || end_testcase "ping $RHOST failed"
-      arp -a | grep "$RHOST\>" 2>&1 1>/dev/null
-      [ $? = 0 ] || end_testcase "arp -a failed"
-      arp -d $RHOST 2>&1 1>/dev/null
-      [ $? = 0 ] || end_testcase "arp -d $RHOST failed"
-      COUNT=`expr $COUNT + 1`
-      sleep $SLEEPTIME
-   done
-}
+        ping -c1 $RHOST 2>&1 1>/dev/null || end_testcase "ping $RHOST failed"
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
+        if ! arp -a | grep "$RHOST\>" 2>&1 1>/dev/null; then
+            end_testcase "arp -a failed"
+        fi
 
-end_testcase()
-{
-   $trace_logic
+        if ! arp -d $RHOST 2>&1 1>/dev/null; then
+            end_testcase "arp -d $RHOST failed"
+        fi
 
-   [ $# = 0 ] && { echo "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+        incr_tst_count
+
+        sleep $SLEEPTIME
+
+    done
+
 }
 
 #-----------------------------------------------------------------------
@@ -143,6 +103,10 @@
 # INPUT:    None.
 # OUTPUT:   None.
 #-----------------------------------------------------------------------
+
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/echo/Makefile b/testcases/network/tcp_cmds/echo/Makefile
index 169f714..15fb84e 100644
--- a/testcases/network/tcp_cmds/echo/Makefile
+++ b/testcases/network/tcp_cmds/echo/Makefile
@@ -1,15 +1,38 @@
-CFLAGS += -w -O 
-LDLIBS += 
+#
+#    network/tcp_cmds/echo testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	ln -f echo01 ../../../bin
+CPPFLAGS		+= -DDEBUG -I$(abs_srcdir)/../include
 
-clean:
-	rm -f $(TARGETS)
+INSTALL_TARGETS		:= echo01
 
+MAKE_TARGETS		:= echoes echoes6
 
+%6: CPPFLAGS += -DINET6
+
+%6.o: %.c
+	$(COMPILE.c) $(OUTPUT_OPTION) $<
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/echo/createfile.c b/testcases/network/tcp_cmds/echo/createfile.c
index d3e26a5..35e89e8 100644
--- a/testcases/network/tcp_cmds/echo/createfile.c
+++ b/testcases/network/tcp_cmds/echo/createfile.c
@@ -7,35 +7,46 @@
 @! # 		the file size matches the file size required
 @! # SPEC. EXEC. REQS:  This  program is used by ctatcdt3.c and ctatcet3.c
 */
+
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-int main (int argc,char *argv[]) 
+
+int
+main (int argc, char *argv[])
 {
-int	fd;
-int	fsize;
-int	count=0;
-int	n,remain;
-static	char buf[BUFSIZ];
-	for ( fsize=0;fsize<BUFSIZ;) {
-		buf[fsize++]='U';
-		buf[fsize++]='\n';
+
+	int		fd;
+	int		fsize;
+	int		count = 0;
+	int		n, remain;
+	static	char	buf[BUFSIZ];
+
+	for ( fsize = 0; fsize < BUFSIZ; ) {
+		buf[fsize++] = 'U';
+		buf[fsize++] = '\n';
 	}
 
-	fsize=atoi(argv[1]);
-	if ((fd=creat(argv[2],0644)) == -1)
+	fsize = strtol(argv[1], (char **) NULL, 10);
+
+	if ((fd = creat(argv[2], 0644)) == -1)
 		perror("createfile");
 	if (fsize >= BUFSIZ) {
-		count=fsize/BUFSIZ;
-		remain=fsize%BUFSIZ; 
-	}
-	else remain=fsize;
-	while (count-- !=0) 
-		if((n=write(fd,buf,BUFSIZ)) != BUFSIZ) 
+		count = fsize / BUFSIZ;
+		remain = fsize % BUFSIZ; 
+	} else
+		remain = fsize;
+	while (count-- !=0) {
+		if((n = write(fd, buf, BUFSIZ)) != BUFSIZ) 
 			perror("createfile");
-	if ((n=write(fd,buf,remain)) != remain)
+	}
+	if ((n = write(fd, buf, remain)) != remain)
 		perror("createfile");
 	close(fd);
+
 	return 0;
+
 }
diff --git a/testcases/network/tcp_cmds/echo/echo01 b/testcases/network/tcp_cmds/echo/echo01
index 5d0a250..eb798ae 100755
--- a/testcases/network/tcp_cmds/echo/echo01
+++ b/testcases/network/tcp_cmds/echo/echo01
@@ -32,24 +32,36 @@
 #
 #
 #***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
 
-TC=sine
-RHOST=${RHOST:-`hostname`}
-TCbin=${TCbin:-`pwd`}
-TCsrc=${TCsrc:-$TCbin}
-TCtmp=${TCtmp:-$TCsrc/echo$$}
-CLEANUP=${CLEANUP:-ON}
-CREATFILE=createfile
-ECHOES=echoes
+#-----------------------------------------------------------------------
+#
+# FUNCTION:  do_setup
+#
+#-----------------------------------------------------------------------
 
-EXECUTABLES=${EXECUTABLES:-"$CREATFILE $ECHOES"}
-ECHOFILE=${ECHOFILE:-echofile}
-ECHOSIZE=${ECHOSIZE:-8192}
-NUMLOOPS=${NUMLOOPS:-2}
-NUMPROCESSES=${NUMPROCESSES:-10}
+do_setup()
+{
+
+    NUMLOOPS=${NUMLOOPS:-2}
+    TST_TOTAL=$NUMLOOPS
+
+    export TST_COUNT TST_TOTAL
+
+    exists hostname sum
+    tst_setup
+
+    TC=sine
+    RHOST=${RHOST:-`hostname`}
+    TCtmp=${TCtmp:-$LTPROOT/testcases/bin/echo$$}
+    CLEANUP=${CLEANUP:-ON}
+    CREATEFILE=createfile
+    ECHOES=echoes${EXEC_SUFFIX}
+
+    ECHOFILE=${ECHOFILE:-echofile${EXEC_SUFFIX}}
+    ECHOSIZE=${ECHOSIZE:-8192}
+    NUMPROCESSES=${NUMPROCESSES:-10}
+
+}
 
 #-----------------------------------------------------------------------
 #
@@ -63,90 +75,44 @@
 
 do_test() 
 {
-   $trace_logic
-   mkdir $TCtmp 
-   echo  "Creating echo file $ECHOFILE"
-   $TCbin/$CREATFILE $ECHOSIZE $TCtmp/$ECHOFILE
-   [ $? = 0 ] || end_testcase "$ECHOFILE not created"
+    mkdir $TCtmp 
+    echo  "Creating echo file $ECHOFILE"
+    if ! "$LTPROOT/testcases/bin/$CREATEFILE" $ECHOSIZE "$TCtmp/$ECHOFILE"; then
+        end_testcase "$ECHOFILE not created"
+    fi
 
-   echo "Compute the checksum of this file"
-   csum1=`sum $TCtmp/$ECHOFILE |awk '{print $1}'`
-   [ $csum1 ] || end_testcase "initial checksum computation failed"
+    echo "Compute the checksum of this file"
+    csum1=$(sum $TCtmp/$ECHOFILE | awk '{print $1}')
+    [ $csum1 ] || end_testcase "initial checksum computation failed"
 
-   COUNT=1
-   while [ $COUNT -le $NUMLOOPS ]
-   do
-      $TCbin/$ECHOES $RHOST $TCtmp/$ECHOFILE $NUMPROCESSES
-      [ $? = 0 ] || end_testcase "Error in $ECHOES test in loop $COUNT"
+    while [ $TST_COUNT -le $NUMLOOPS ]; do
 
-      NUM=0
-      while [ $NUM -lt $NUMPROCESSES ]
-      do
-         csum2=`sum $TCtmp/$ECHOFILE\$NUM |awk '{print $1}'`
-         [ "$csum1" -eq "$csum2" ] || end_testcase "Checksums differ in loop $COUNT"
-         NUM=`expr $NUM + 1`
-      done
+        if ! $ECHOES $RHOST "$TCtmp/$ECHOFILE" $NUMPROCESSES; then
+            end_testcase "Error in $ECHOES test in loop $TST_COUNT"
+        fi
 
-      echo "Successful execution for loop $COUNT" 
-      COUNT=`expr $COUNT + 1`
-      if [ $COUNT -le $NUMLOOPS ]; then
-        echo "Sleeping 60 seconds to avoid hitting max. connections setting for service"
-        sleep 60
-      fi
-   done
+        NUM=0
+        while [ $NUM -lt $NUMPROCESSES ]
+        do
+            csum2=$(sum "$TCtmp/${ECHOFILE}${NUM}" | awk '{print $1}')
+            if [ "$csum1" = "$csum2" ]; then
+                end_testcase "Checksums differ in loop $TST_COUNT"
+            fi
+            NUM=$(( $NUM + 1 ))
+        done
+
+        tst_resm TINFO "Execution $TST_COUNT passed."
+
+        incr_tst_count
+        if [ $TST_COUNT -le $NUMLOOPS ]; then
+            tst_resm TINFO "Sleeping 60 seconds to avoid hitting max. connections setting for service"
+            sleep 60
+        fi
+    done
 }
 
 #-----------------------------------------------------------------------
 #
-# FUNCTION:	do_cleanup
-# PURPOSE:	Called when the testcase is interrupted by the user
-#		or by interrupt_testcase() when time limit expired
-# INPUT:	None.
-# OUTPUT:	None.
-#
-#-----------------------------------------------------------------------
-
-do_cleanup()
-{
-   $trace_logic
-
-   cd /
-   if [ $TCtmp = $TCsrc ]; then
-      rm -f $TCtmp/echofile*
-   else
-      rm -rf $TCtmp
-   fi
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-# 
-# FUNCTION DESCRIPTION: Clean up
-# 
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-# 
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{  
-   $trace_logic
-    
-   # Call other cleanup functions
-   [ $CLEANUP = "ON" ] && do_cleanup
-
-   [ $# -eq 0 ] && { echo "Test Successful"; exit 0; }
-   echo "Test Failed: $@"
-   echo""
-   echo "***NOTE***"
-   echo "Make sure the streamed echo is uncommented in inetd.conf"
-   echo "on the server. Also try increasing max connections from"
-   echo "default of 40, i.e. nowait.400"
-   exit 1
-}   
-
-#-----------------------------------------------------------------------
-#
 # FUNCTION:  MAIN
 # PURPOSE:   To invoke functions that perform the tasks as described in
 #	     the design in the prolog above.
@@ -154,5 +120,10 @@
 # OUTPUT:    Logged run results written to testcase run log
 #
 #-----------------------------------------------------------------------
+
+. net_cmdlib.sh
+
+read_opts $*
+do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/echo/echoes.c b/testcases/network/tcp_cmds/echo/echoes.c
index b9dd244..2563e06 100644
--- a/testcases/network/tcp_cmds/echo/echoes.c
+++ b/testcases/network/tcp_cmds/echo/echoes.c
@@ -12,310 +12,393 @@
 @! # SPEC. EXEC. REQS: May require multiple of this test to run
 @! #		       to target machines from multiple machine in order
 @! #		       to create stress condition
-@! # 			echoes <REMOTE HOST> <echofile> <number of process>
+@! # 			echoes <REMOTE HOST> <echofile> <number of processes>
 */
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <libgen.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
 #include <netinet/in.h>
 #include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <unistd.h>
+#include "test.h"
+#include "netdefs.h"
 
-#define TRUE 1
-#define FALSE 0
+#if INET6
+char *TCID = "echoes6";
+#else
+char *TCID = "echoes";
+#endif
 
-void echofile (struct servent *, struct hostent *, char *, char *);
-void getfilename(char *, char*, int);
-int checkfile(char *, char *);
-void itoa(int, char []);
-void reverse(char []);
-void cleanup(int);
+int	TST_TOTAL = 1;
+
+void	echofile (struct servent *, struct addrinfo *, char *, char *);
+int	checkfile(char *, char *);
+void	cleanup(int);
 
 
-int main (int argc,char *argv[],char *env[])
+int
+main (int argc, char *argv[], char *env[])
 {
 
-	int	i,j,k,wait_stat,pid,finish;
-	struct	servent *sp;
-	struct 	hostent *hp;
+	unsigned int	finish, i, j, k;
+	int		gai, wait_stat;
+	pid_t		pid;
+	struct addrinfo hints, *hp;
+	struct		servent *sp;
 	struct  {
-		char	resultfile[35];
-		int	pid;
-		int	status;
-	}echo_struc[200];
+		char	resultfile[FILENAME_MAX+1];
+		pid_t	pid;
+	} echo_struc[200];
 
-	hp = gethostbyname(argv[1]);
-	if ((sp=getservbyname("echo","tcp"))==NULL) {
-		printf("ERROR service is not available\n");
-		perror("echo");
-		exit(1);
+	memset(&hints, 0, sizeof(hints));
+	hints.ai_family = PFI;
+	hints.ai_socktype = SOCK_STREAM;
+
+	if (argc != 4) {
+		tst_resm(TBROK, "usage: remote-addr file num-procs");
+		tst_exit();
 	}
-	i=atoi(argv[3]);
-	j=0;
-	while ( i-- > 0 )  {
-		echo_struc[j].status=0;
-		switch (pid=fork())  {
+
+	if ((sp = getservbyname("echo", "tcp")) == NULL) {
+		tst_resm(TBROK, "echo service not found (check "
+				"/etc/services?)");
+		tst_exit();
+	}
+
+	if ((gai = getaddrinfo(argv[1], NULL, &hints, &hp)) != 0) {
+		tst_resm(TBROK, "Unknown subject address %s: %s\n",
+				argv[1], gai_strerror(gai));
+		tst_exit();
+	}
+	if (!hp || !hp->ai_addr || hp->ai_addr->sa_family != AFI) {
+		tst_resm(TBROK, "getaddrinfo failed");
+		tst_exit();
+	}
+	i = (unsigned int) strtol(argv[3], (char**) NULL, 10);
+	j = 0;
+	while (i-- > 0)  {
+		switch (pid = fork()) {
 		case 0:
-			getfilename(argv[2],echo_struc[j].resultfile,j);
-			echofile(sp,hp,echo_struc[j].resultfile,argv[2]); 
+			snprintf(echo_struc[j].resultfile,
+				 FILENAME_MAX, "%s%u", argv[2], j);
+			echofile(sp, hp, echo_struc[j].resultfile, argv[2]);
 			break;
 		case -1:
-			printf("ERROR when forking a new process\n");
-			perror("echo");
-			exit(1);
+			tst_resm(TFAIL, "Failed to fork a new process: %s",
+					strerror(errno));
+			tst_exit();
 			break;
 		default:
-			echo_struc[j].pid=pid;
-			echo_struc[j].status=1;
+			echo_struc[j].pid = pid;
 			j++;
 			break;
 		}
 	}
-	finish=atoi(argv[3]);
-	i=finish;
+	finish = (unsigned int) strtol(argv[3], (char**) NULL, 10);
+	i = finish;
+	/* Consume all operating threads until we're done... */
 	while (finish != 0) {
-		if ((pid=wait(&wait_stat)) == -1) {
-			printf("ERROR in wait process\n");
-			perror("echo");
-			exit(1);
+
+		if ((pid = wait(&wait_stat)) == -1) {
+			tst_resm(TFAIL, "ERROR in wait process");
+			tst_exit();
 		}
-		if (wait_stat==0) 
-			for (j=0;j<i;j++) {
-				if(echo_struc[j].pid==pid) {
-					echo_struc[j].status=2;
+		if (wait_stat == 0) {
+			for (j = 0; j < i; j++) {
+				if (echo_struc[j].pid == pid) {
 					finish--;
-					j=i;
+					j = i;
 				}
 			}
-		else {
-			for (k=0;k < i;k++)
-				if (echo_struc[k].status==1) {
-					kill(echo_struc[k].pid,9);
+		} else {
+
+			tst_resm(TFAIL, "wait(2) status was non-zero");
+
+			if (WIFEXITED(wait_stat)) {
+				tst_resm(TINFO, "exit status: %d",
+						WEXITSTATUS(wait_stat));
+			} else if (WIFSIGNALED(wait_stat)) {
+				tst_resm(TINFO, "signaled: %d",
+						WTERMSIG(wait_stat));
+			}
+
+			for (k = 0; k < i; k++) {
+				if (kill(echo_struc[k].pid, 0) == 0) {
+					kill(echo_struc[k].pid, 9);
 				}
-			exit(1);
+			}
+
+			tst_exit();
+
 		}
+
 	}
-	exit(0);
+
+	return 0;
 }
 
-void echofile (struct servent *sp, struct hostent *hp, char *resultfile, char *orgfile)
+void
+echofile (struct servent *sp, struct addrinfo *ai, char *resultfile,
+		char *srcfile)
 {
-	int	n;
-	int	port;
-	char	wr_buffer[BUFSIZ];
-	char	rd_buffer[BUFSIZ];
-	struct	in_addr	hostaddr;
-	struct sockaddr_in sa;
+	int		n;
+	int		port;
+	char		wr_buffer[BUFSIZ];
+	char		rd_buffer[BUFSIZ];
+	sai_t		sa;
 #ifdef DEBUG
-	struct	sockaddr_in address;
-	u_short	addrlen;
-	u_short	portnum;
+	sa_t		address;
+	socklen_t	addrlen;
 #endif
-	int	s;
-	int	finish;
-	int	fdw,fdr;
-	int	nread,nwrite;
-	int	pid;
-	int	count;
-#ifdef 	DEBUG
-	printf("Create socket .....\n");
-#endif
-	pid=getpid();
-	if ((s=socket(AF_INET,SOCK_STREAM,0)) < 0 ) {
-		printf("ERROR occured during socket operation(%d)\n",pid);
-		perror("echo:socket");
-		cleanup(s);
-		exit(1);
-	}
-	port=sp->s_port;
-	memcpy(&hostaddr,hp->h_addr_list[0],sizeof(struct in_addr));
-	memset((char *)&sa,0x00,sizeof (sa));
-	sa.sin_port=port;
-	sa.sin_family=AF_INET;
-	sa.sin_addr=hostaddr;
+	int		s;
+	int		finish;
+	int		fdw, fdr;
+	int		nread, nwrite;
+	int		count;
+	pid_t		pid;
 
 #ifdef 	DEBUG
-	printf("sizeof (hostaddr)=%d\n",sizeof (hostaddr));
-	printf("port=%d hostaddr=%x", ntohs(port), hostaddr);
-	printf("Connect .......\n");
+	printf("Creating socket .....\n");
 #endif
-	if (connect(s,(struct sockaddr *) &sa,sizeof(sa))==-1) {
-		printf ("ERROR occured during connect socket operation(%d)\n",pid);
+
+	pid = getpid();
+	if ((s = socket(AFI, SOCK_STREAM, 0)) < 0 ) {
+		tst_resm(TBROK, "Failed to create listener socket (pid=%d)",
+				pid);
+		perror("echo:socket");
+		cleanup(s);
+		tst_exit();
+	}
+	port = sp->s_port;
+
+	/*
+	 * TODO: Old code did something of the form:
+	 *
+	 * struct hostent *hp;
+	 *
+	 * hp = gethostbyname(argv[1]);
+	 *
+	 * ...
+	 *
+	 * struct	in_addr	hostaddr;
+	 *
+	 * memcpy(&hostaddr,hp->h_addr_list[0],sizeof(struct in_addr));
+	 *
+	 * This is all fine and dandy, but gethostbyname has been deprecated
+	 * for some time, and doesn't work too well with IPV6 (from what I've
+	 * read), so I have to push it over to getaddrinfo. getaddrinfo isn't
+	 * a 1:1 mapping though, so I have to do some work to shoehorn the old
+	 * code to fit the new code.
+	 *
+	 * Some notes (from a test app)...
+	 *
+	 * (gdb) set args 127.0.0.1
+	 * (gdb) list
+	 * 33              for (int i = 1; i < argc; i++) {
+	 * 34
+	 * 35                      gai = getaddrinfo(argv[i], NULL, &hints, &ai);
+	 * 36                      hp = gethostbyname(argv[i]);
+	 * 37
+	 * 38                      if (gai != 0) {
+	 * 39                              printf("Error: %s\n", gai_strerror(gai));
+	 * 40                              error = 2;
+	 * 41                      } else {
+	 * 42                              printf("Host IP: 0x%x\n", ai->ai_addr);
+	 * (gdb) p *hp
+	 * $16 = {h_name = 0x1a60198 "127.0.0.1", h_aliases = 0x1a60190, h_addrtype = 2, 
+	 *   h_length = 4, h_addr_list = 0x1a60180}
+	 * (gdb) p *hp->h_addr_list
+	 * $14 = 0x1a60170 "\177"
+	 * (gdb) p *ai
+	 * $15 = {ai_flags = 0, ai_family = 2, ai_socktype = 1, ai_protocol = 6, 
+	 *   ai_addrlen = 16, ai_addr = 0x1a600b0, ai_canonname = 0x0, 
+	 *     ai_next = 0x1a600d0}
+	 *
+	 * If one continues down this path, SIGPIPE will get tossed at the first
+	 * write(2), as opposed to Connection refused (the old code). So I'm not
+	 * passing in the correct info to connect(2).
+	 *
+	 * That and using -DDEBUG with the getpeername(3) call below always fails
+	 * (that alone should be a sufficient to note that my sockaddr* data is
+	 * skewed).
+	 *
+	 * For now let's just mark it broken.
+	 *
+	 */
+	//tst_resm(TBROK, "FIX ME GARRETT!");
+	//tst_exit();
+
+	memset((char*) &sa, 0, sizeof(sa));
+	memcpy(&sa, ai->ai_addr, ai->ai_addrlen);
+
+#if INET6
+	sa.sin6_port = port;
+#else
+	sa.sin_port = port;
+#endif
+
+	if (connect(s, (sa_t*) &sa, sizeof(sa)) == -1) {
+		tst_resm(TBROK, "Failed to create connector socket (pid=%d)",
+				pid);
 		perror("echo:connect");
 		cleanup(s);
-		exit(1);
+		tst_exit();
 	}
+
 #ifdef DEBUG
-	addrlen=sizeof(address);
-	printf("addrlen=%d\n",addrlen);
-	printf("hp->h_length=%d\n",hp->h_length);
-	printf("hp->h_addrtype=%d\n",hp->h_addrtype);
-	printf("hp->h_addr=%d\n",inet_ntoa(hp->h_addr));
-	if (getsockname(s,&address,&addrlen) == -1 ) {
-		printf ("ERROR occured during getsockname(%d)\n",pid);
+	/* printf("addrlen=%d\n", addrlen); */
+	/* printf("ai->ai_addr=%s\n", inet_ntoa(ai->ai_addr)); */
+	if (getsockname(s, &address, &addrlen) == -1) {
+		tst_resm (TBROK, "getsockname call failed (pid=%d): %s",
+				 pid, strerror(errno));
 		perror("echo");
 		cleanup(s);
-		exit(1);
+		tst_exit();
 	}
-	portnum=ntohs(address.sin_port);
-	printf ("local port is: %d\n",portnum);
-	if (getpeername(s,&address,&addrlen) == -1) {
-		printf ("ERROR occured during getpeername(%d)\n",pid);
-		perror("echo");
+
+	printf ("local port is: %d\n", port);
+
+	if (getpeername(s, &address, &addrlen) == -1) {
+		tst_resm (TBROK, "getpeername call failed (pid=%d): %s",
+				 pid, strerror(errno));
 		cleanup(s);
-		exit(1);
+		tst_exit();
 	}
-	portnum=ntohs(address.sin_port);
-	/*	printf ("remote address is: %d\n",portnum);
-*/
+
+	tst_resm (TINFO, "The remote port is: %d\n", port);
 #endif
-	if ((fdr=open(orgfile,O_RDONLY)) < 0 ) {
-		printf("ERROR when opening the input file(%d)\n",pid);
+	if ((fdr = open(srcfile, O_RDONLY)) < 0) {
+		tst_resm(TBROK, "Failed to open input file (pid=%d)", pid);
 		perror("echo:orginal file");
 		cleanup(s);
-		exit(1);
+		tst_exit();
 	}
-	if ((fdw=creat(resultfile,0644)) < 0 ) {
-		printf("ERROR when opening the temporary temp file(%d)\n",pid);
+
+	if ((fdw = creat(resultfile, 0644)) < 0) {
+		tst_resm(TBROK, "Failed to create a temporary file (pid=%d)",
+				pid);
 		perror("echo:resultfile");
 		cleanup(s);
-		exit(1);
+		tst_exit();
 	}
-	finish=FALSE;
-	count=0;
-	while (!finish) {
-		if ((nwrite=read(fdr,wr_buffer,BUFSIZ))==-1) {
-			printf("ERROR when reading input file(%d)\n",pid);
-			perror("echo:orginal file");
+#if DEBUG
+	tst_resm (TINFO, "creat(resultfile,...) done.");
+#endif
+	finish = FALSE;
+	count = 0;
+	while (finish == FALSE) {
+
+		if ((nwrite = read(fdr, wr_buffer, BUFSIZ)) == -1) {
+			tst_resm(TFAIL, "Failed to read from file (pid=%d)",
+					pid);
 			cleanup(s);
-			exit(1);
+			perror("read srcfile");
 		}
-		if (nwrite==0)
-			finish=TRUE;
+#if DEBUG
+		tst_resm (TINFO, "Read %d bytes from file", nwrite);
+#endif
+		if (nwrite == 0)
+			finish = TRUE;
 		else {
 			count++;
-			if((n=write(s,wr_buffer,nwrite))!=nwrite) {
-				printf("ERROR during write to socket(%d)\n",pid);
-				perror("echo:socket write");
+			if((n = write(s, wr_buffer, nwrite)) != nwrite) {
+				tst_resm(TFAIL, "Failed to write to socket "
+						"(pid=%d)", pid);
 				cleanup(s);
-				exit(1);
+				perror("write");
 			}
 #ifdef 	DEBUG
-/*
-			printf("Writing .......%d\n",count);
-*/
+			tst_resm(TINFO, "Writing %d bytes to remote socket",
+					count);
 #endif
-			while (nwrite!=0) {
-				if((nread=read(s,rd_buffer,BUFSIZ))==-1) {
-					printf("read size:%d\n",n);
-					printf("ERROR during read from socket(%d)\n",pid);
-					perror("echo:socket read");
+			while (nwrite != 0) {
+
+				nread = read(s, rd_buffer, BUFSIZ);
+				if (nread == -1) {
+					printf("read size: %d\n", n);
+					tst_resm(TFAIL, "Failed to read from "
+							"socket [2nd time] "
+							"(pid=%d)", pid);
 					cleanup(s);
-					exit(1);
+					perror("socket read");
 				}
 #ifdef 	DEBUG
-/*
-				printf("Reading .......    %d\n",count);
-*/
+				printf("Reading ....... %d\n",count);
 #endif
-				if((n=write(fdw,rd_buffer,nread))!=nread) {
-					printf("read size:%d\n",n);
-					printf("ERROR during write to result file(%d)\n",pid);
-					perror("echo:result file");
+				n = write(fdw, rd_buffer, nread);
+				if (n != nread) {
+					tst_resm(TFAIL, "ERROR during write to "
+							"result file (pid=%d); "
+							"read amount: %d",
+							pid, n);
 					cleanup(s);
-					exit(1);
+					perror("write resultfile");
 				}
-				nwrite-=nread;
+
+				nwrite -= nread;
+
 			}
 
 		}/* end of else */
+
 	} /* end of while */
-	if ((n=close(s)) == -1) {
-		printf("ERROR in closing socket(%d)\n",pid);
-		perror("echo");
-		exit(1);
+
+	if ((n = close(s)) == -1) {
+		tst_resm(TBROK, "Failed to cleanly close socket (pid=%d)",
+				pid);
+		perror("close");
+		tst_exit();
 	}
-	if ((n=close(fdr)) == -1) {
-		printf("ERROR in closing input file(%d)\n",pid);
-		perror("echo");
-		exit(1);
+	if ((n = close(fdr)) == -1) {
+		tst_resm(TBROK, "Failed to cleanly close input file (pid=%d)",
+				pid);
+		perror("close srcfile");
+		tst_exit();
 	}
-	if ((n=close(fdw) ) == -1) {
-		printf("ERROR in closing temp file(%d)\n",pid);
-		perror("echo");
-		exit(1);
+	if ((n = close(fdw) ) == -1) {
+		tst_resm(TBROK, "Failed to cleanly close temp file (pid=%d)",
+				pid);
+		perror("close");
+		tst_exit();
 	}
-	if (checkfile(orgfile,resultfile)) {
-		printf("ERROR input file and output file are not equal(%d)\n",pid);
-		exit(1);
+	if (checkfile(srcfile, resultfile) != TRUE) {
+		tst_resm(TFAIL, "Input file and output file are not equal "
+				"(pid=%d)", pid);
+		tst_exit();
 	}
-	printf("Finish ....%d\n",pid);
+	tst_resm(TINFO, "Finish .... (pid=%d)", pid);
 	exit(0);
 }
 
-void getfilename(char *strptr, char* filename, int j)
+int
+checkfile(char *file1, char *file2)
 {
-	int 	i;
-	char	s[10],*sptr=&s[0];
-
-	strcpy(filename,strptr);
-	itoa(j,s);
-	strcat(filename,s);
-}
-
-int checkfile(char *file1, char *file2)
-{
-	int	n;
-	struct	stat buffer,*bufptr=&buffer;
-	stat(file1,bufptr);
-	n=bufptr->st_size;
+	off_t	n;
+	struct	stat buffer;
+	stat(file1, &buffer);
+	n = buffer.st_size;
 #ifdef 	DEBUG
-	/*	printf("%s size= %d \n",file1,n);
-*/
+	printf("%s size=%lu\n", file1, n);
 #endif
-	stat(file2,bufptr);
+	stat(file2, &buffer);
 #ifdef 	DEBUG
-	/*	printf("%s size= %d \n",file2,bufptr->st_size);
-*/
+	printf("%s size=%lu\n", file2, buffer.st_size);
 #endif
-	if(n != buffer.st_size)
-		return(TRUE);
-	else return(FALSE);
+	if (n != buffer.st_size)
+		return FALSE;
+	else
+		return TRUE;
 }
 
-void itoa(int n, char s[])
-{
-	int i, sign;
-
-	if ((sign = n) < 0)
-		n = -n;
-	i = 0;
-	do {
-		s[i++] = n % 10 + '0';
-	} while ((n /= 10) > 0);
-	if (sign < 0)
-		s[i++] = '-';
-	s[i] = '\0';
-	reverse(s);
-}
-
-void reverse(char s[])
-{
-	int c, i, j;
-
-	for (i=0, j=strlen(s)-1; i < j; i++, j--) {
-		c = s[i];
-		s[i] = s[j];
-		s[j] = c;
-	}
-}
-
-void cleanup(int s) 
+void
+cleanup(int s) 
 {
 	close(s);
 }
diff --git a/testcases/network/tcp_cmds/finger/Makefile b/testcases/network/tcp_cmds/finger/Makefile
index d4a07ac..025dfb6 100644
--- a/testcases/network/tcp_cmds/finger/Makefile
+++ b/testcases/network/tcp_cmds/finger/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/tcp_cmds/finger testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f finger01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= finger01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/finger/finger01 b/testcases/network/tcp_cmds/finger/finger01
index d90bca2..2a61d40 100755
--- a/testcases/network/tcp_cmds/finger/finger01
+++ b/testcases/network/tcp_cmds/finger/finger01
@@ -34,37 +34,6 @@
 #      -Ported
 #
 #-----------------------------------------------------------------------
-# Uncomment line below for debugging information
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-RUSER=root
-RHOST=${RHOST:-`hostname`}
-LHOST=`hostname`
-SLEEPTIME=${SLEEPTIME:-1}
-LUSER=`id | tr -s '()' '  ' | awk '{print $2}'`
-
-this_file=${0##*/}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-#
-#-----------------------------------------------------------------------
-
-exists()
-{
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
-}
-
 
 #-----------------------------------------------------------------------
 #
@@ -72,29 +41,35 @@
 #
 #-----------------------------------------------------------------------
 
-do_setup ()
+do_setup()
 {
-   $trace_logic
 
-   # Start fingerd locally and remotely.
+    # Start fingerd locally and remotely.
+    export TST_TOTAL=3
 
-   export TCID="finger01"
-   export TST_TOTAL=3
-   export TST_COUNT=1
+    tst_setup
 
-   exists "finger netstat awk rsh"
+    exists awk finger hostname netstat rsh whoami
 
-   [ "$LUSER" = "root" ] || end_testcase "MUST BE root to run the test!"
+    LHOST=$(hostname)
+    LUSER=$(whoami)
+    RUSER=root
+    RHOST=${RHOST:-$(hostname)}
+    SLEEPTIME=${SLEEPTIME:-1}
 
-   FINGER=`netstat -a | grep "*:finger" |awk '{print $6}'`
-   if [ "$FINGER" != "LISTEN" ]; then
-      end_testcase "Please start fingerd locally."
-   fi
+    exists awk finger netstat rsh whoami
 
-   FINGER=`rsh -n $RHOST netstat -a |grep "*:finger"|awk '{print $6}'`
-   if [ "$FINGER" != "LISTEN" ]; then
-      end_testcase "Please start fingerd on remote host."
-   fi
+    [ "$LUSER" = "root" ] || end_testcase "MUST BE root to run the test!"
+
+    FINGER=$(netstat -a | grep "*:finger" |awk '{print $6}')
+    if [ "$FINGER" != "LISTEN" ]; then
+        end_testcase "Please start fingerd locally."
+    fi
+
+    FINGER=$(rsh -n $RHOST netstat -a |grep "*:finger"|awk '{print $6}')
+    if [ "$FINGER" != "LISTEN" ]; then
+        end_testcase "Please start fingerd on remote host."
+    fi
 }
 
 #-----------------------------------------------------------------------
@@ -106,24 +81,20 @@
 
 do_test1()
 {
-   $trace_logic
-   TCID="finger01"
-   TST_COUNT=1
-   tst_resm TINFO "finger: do_test1 started"
+    tst_resm TINFO "finger: do_test1 started"
 
-   finger @$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger @$LHOST"
-   finger @$RHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger @$RHOST"
+    finger @$LHOST  2>&1 1>/dev/null
+    [ $? = 0 ] || end_testcase "finger @$LHOST"
+    finger @$RHOST  2>&1 1>/dev/null
+    [ $? = 0 ] || end_testcase "finger @$RHOST"
 	
-   # Testing finger command with user argument
+    # Testing finger command with user argument
 
-   finger $LUSER  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger $LUSER"
-   finger $LUSER@$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger $LUSER@$LHOST"
-   finger $RUSER@$RHOST 2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger @$RUSER"
+    finger $LUSER 2>&1 1>/dev/null || end_testcase "finger $LUSER"
+    if ! finger $LUSER@$LHOST  2>&1 1>/dev/null; then
+        end_testcase "finger $LUSER@$LHOST"
+    fi
+    finger $RUSER@$RHOST 2>&1 1>/dev/null || end_testcase "finger @$RUSER"
 }
 
 #-----------------------------------------------------------------------
@@ -136,25 +107,19 @@
 
 do_test2()
 {
-   $trace_logic
+    tst_resm TINFO "finger: do_test2 (-bad flag) started"
+    BADUSER="uuuu"
+    BADHOST="xxxx"
 
-   TCID="finger02"
-   TST_COUNT=2
-   tst_resm TINFO "do_test2 $TC finger -bad flag"
-   BADUSER="uuuu"
-   BADHOST="xxxx"
+    tst_resm TINFO "finger -badflag default "
+    finger -x 2>&1 1>/dev/null && end_testcase "finger -x should fail"
 
-   tst_resm TINFO "finger -badflag default "
-   finger -x 2>&1 1>/dev/null
-   [ $? = 0 ] && end_testcase "finger -x should fail"
-
-   tst_resm TINFO "finger -bad user "
-   finger $BADUSER 2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger $BADUSER "
-   finger @$BADHOST 2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger @$BADHOST"
-   finger $BADUSER@$BADHOST 2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger $BADUSER@$BADHOST"
+    tst_resm TINFO "finger -bad user "
+    finger $BADUSER 2>&1 1>/dev/null || end_testcase "finger $BADUSER"
+    finger @$BADHOST 2>&1 1>/dev/null || end_testcase "finger @$BADHOST"
+    if ! finger $BADUSER@$BADHOST 2>&1 1>/dev/null; then
+        end_testcase "finger $BADUSER@$BADHOST"
+    fi
 }
 
 #-----------------------------------------------------------------------
@@ -167,88 +132,56 @@
 
 do_test3()
 {
-   $trace_logic
+    tst_resm TINFO "finger: do_test3 (-f flag) started"
 
-   TCID="finger03"
-   TST_COUNT=3
-   tst_resm TINFO "do_test3 $TC finger -f flag"
+    tst_resm TINFO "finger -l : gives a long listing"
+    finger -l  2>&1 1>/dev/null || end_testcase "finger -l"
+    finger -l $LUSER 2>&1 1>/dev/null || end_testcase "finger -l $LUSER"
+    finger -l @$LHOST 2>&1 1>/dev/null || end_testcase "finger -l @$LHOST"
+    if ! finger -l $LUSER@$LHOST 2>&1 1>/dev/null; then
+        end_testcase "finger -l $LUSER@$LHOST"
+    fi
+    finger -l @$RHOST  2>&1 1>/dev/null || end_testcase "finger -l @$RHOST"
+    if ! finger -l $RUSER@$RHOST  2>&1 1>/dev/null; then
+        end_testcase "finger -l $RUSER@$RHOST"
+    fi
 
-   tst_resm TINFO "finger -l : gives a long listing"
-   finger -l  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -l"
-   finger -l $LUSER  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -l $LUSER "
-   finger -l @$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -l @$LHOST"
-   finger -l $LUSER@$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -l $LUSER@$LHOST"
-   finger -l @$RHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -l @$RHOST"
-   finger -l $RUSER@$RHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -l $RUSER@$RHOST"
+    tst_resm TINFO "finger -m : assures that user is a user ID discretionary"
+    finger -m 2>&1 1>/dev/null || end_testcase "finger -m"
+    finger -m $LUSER 2>&1 1>/dev/null || end_testcase "finger -m $LUSER"
+    finger -m @$LHOST 2>&1 1>/dev/null || end_testcase "finger -m @$LHOST"
+    if ! finger -m $LUSER@$LHOST 2>&1 1>/dev/null; then
+        end_testcase "finger -m $LUSER@$LHOST"
+    fi
+    finger -m @$RHOST 2>&1 1>/dev/null || end_testcase "finger -m @$RHOST"
+    if ! finger -m $RUSER@$RHOST  2>&1 1>/dev/null; then
+        end_testcase "finger -m $RUSER@$RHOST"
+    fi
 
-   tst_resm TINFO "finger -m : assures that user is a user ID discretionary"
-   finger -m  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -m"
-   finger -m $LUSER  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -m $LUSER "
-   finger -m @$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -m @$LHOST"
-   finger -m $LUSER@$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -m $LUSER@$LHOST"
-   finger -m @$RHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -m @$RHOST"
-   finger -m $RUSER@$RHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -m $RUSER@$RHOST"
+    tst_resm TINFO "finger -p : suppresses printing of .plan files on long and brief long formats"
+    finger -p  2>&1 1>/dev/null || end_testcase "finger -p"
+    finger -p $LUSER  2>&1 1>/dev/null || end_testcase "finger -p $LUSER"
+    finger -p @$LHOST  2>&1 1>/dev/null || end_testcase "finger -p @$LHOST"
+    if ! finger -p $LUSER@$LHOST  2>&1 1>/dev/null; then
+        end_testcase "finger -p $LUSER@$LHOST"
+    fi
+    finger -p @$RHOST  2>&1 1>/dev/null || end_testcase "finger -p @$RHOST"
+    if ! finger -p $RUSER@$RHOST 2>&1 1>/dev/null; then
+        end_testcase "finger -p $RUSER@$RHOST"
+    fi
 
-   tst_resm TINFO "finger -p:suppresses printing of .plan files on long and brief long formats"
-   finger -p  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -p"
-   finger -p $LUSER  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -p $LUSER "
-   finger -p @$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -p @$LHOST"
-   finger -p $LUSER@$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -p $LUSER@$LHOST"
-   finger -p @$RHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -p @$RHOST"
-   finger -p $RUSER@$RHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -p $RUSER@$RHOST"
+    tst_resm TINFO "finger -s : gives a short format list"
+    finger -s  2>&1 1>/dev/null || end_testcase "finger -s"
+    finger -s $LUSER 2>&1 1>/dev/null || end_testcase "finger -s $LUSER "
+    finger -s @$LHOST 2>&1 1>/dev/null || end_testcase "finger -s @$LHOST"
+    if ! finger -s $LUSER@$LHOST 2>&1 1>/dev/null; then
+        end_testcase "finger -s $LUSER@$LHOST"
+    fi
+    finger -s @$RHOST 2>&1 1>/dev/null || end_testcase "finger -s @$RHOST"
+    if ! finger -s $RUSER@$RHOST 2>&1 1>/dev/null; then
+        end_testcase "finger -s $RUSER@$RHOST"
+    fi
 
-   tst_resm TINFO "finger -s : gives a short format list"
-   finger -s  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -s"
-   finger -s $LUSER  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -s $LUSER "
-   finger -s @$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -s @$LHOST"
-   finger -s $LUSER@$LHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -s $LUSER@$LHOST"
-   finger -s @$RHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -s @$RHOST"
-   finger -s $RUSER@$RHOST  2>&1 1>/dev/null
-   [ $? = 0 ] || end_testcase "finger -s $RUSER@$RHOST"
-
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-   tst_resm TINFO "$this_file: doing $0."
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "test failed: $@"
-   exit 1
 }
 
 #-----------------------------------------------------------------------
@@ -258,11 +191,12 @@
 # INPUT:    None.
 # OUTPUT:   None.
 #-----------------------------------------------------------------------
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
-do_test1
-sleep $SLEEPTIME
-do_test2
-sleep $SLEEPTIME
-do_test3
-sleep $SLEEPTIME
+for TST_COUNT in 1 2 3; do
+    eval "do_test$TST_COUNT"
+    sleep $SLEEPTIME
+done
 end_testcase
diff --git a/testcases/network/tcp_cmds/ftp/Makefile b/testcases/network/tcp_cmds/ftp/Makefile
index d191c00..5b85618 100644
--- a/testcases/network/tcp_cmds/ftp/Makefile
+++ b/testcases/network/tcp_cmds/ftp/Makefile
@@ -1,17 +1,30 @@
-generate:
-	../../generate.sh
+#
+#    network/tcp_cmds/ftp testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-all: generate
+top_srcdir		?= ../../../..
 
-install: 
-	ln -f ftp01 ../../../bin
-	ln -f ftp02 ../../../bin
-	ln -f ftp02_s1 ../../../bin
-	ln -f ftp03 ../../../bin
-	ln -f ftp04 ../../../bin
-	ln -f ftp05 ../../../bin
-	ln -f ftp_set_passwd ../../../bin
-	ln -f ftp_setup_vsftp_conf ../../../bin
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -rf datafiles
+INSTALL_TARGETS		:= ftp*
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/ftp/ftp01 b/testcases/network/tcp_cmds/ftp/ftp01
index 290e575..5f32ecb 100755
--- a/testcases/network/tcp_cmds/ftp/ftp01
+++ b/testcases/network/tcp_cmds/ftp/ftp01
@@ -39,41 +39,6 @@
 #-----------------------------------------------------------------------
 #
 #----------------------------------------------------------------------
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-RHOST=${RHOST:-`hostname`}
-RUSER=${RUSER:-root}
-PASSWD=${PASSWD:-.pasroot}
-
-TC=ftp
-TCbin=${TCbin:-`pwd`}
-TCtmp=${TCtmp:-$TCbin/$TC$$}
-TCdat=${TCdat:-$TCbin/datafiles}
-SLEEPTIME=${SLEEPTIME:-0}
-ASCII_FILES=${ASCII_FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"}
-BIN_FILES=${BIN_FILES:-"bin.sm bin.med bin.lg bin.jmb"}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-#
-#-----------------------------------------------------------------------
-
-exists()
-{
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
-}
 
 #-----------------------------------------------------------------------
 #
@@ -83,19 +48,28 @@
 
 do_setup()
 {
-   $trace_logic
 
-   export TCID=ftp
-   export TST_TOTAL=1
-   export TST_COUNT=1
+    TC=ftp
+    TCtmp=${TCtmp:-$LTPROOT/$TC${EXEC_SUFFIX}$$}
+    TCdat=${TCdat:-$LTPROOT/datafiles}
+    SLEEPTIME=${SLEEPTIME:-0}
+    ASCII_FILES=${ASCII_FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"}
+    BIN_FILES=${BIN_FILES:-"bin.sm bin.med bin.lg bin.jmb"}
 
-   exists "rsh ftp awk"
-   mkdir -p $TCtmp
-   cd $TCtmp
+    RHOST=${RHOST:-`hostname`}
+    RUSER=${RUSER:-root}
+    PASSWD=${PASSWD:-.pasroot}
 
-   rsh -n -l root $RHOST mkdir -p $TCtmp
-   rsh -n -l root $RHOST chown -R ${RUSER} $TCtmp
-   [ $? = 0 ] || echo "Check .rhosts file on remote machine."
+    tst_setup
+
+    exists awk ftp rsh
+
+    cd "$TCtmp"
+
+    rsh -n -l root $RHOST mkdir -p "$TCtmp"
+    rsh -n -l root $RHOST chown -R ${RUSER} "$TCtmp"
+    [ $? = 0 ] || end_testcase "Check .rhosts file on remote machine."
+
 }
 
 #-----------------------------------------------------------------------
@@ -106,55 +80,53 @@
 
 do_test()
 {
-   $trace_logic
 
-   for i in binary ascii
-   do
-      if [ $i = "binary" ]; then
-         FILES=$BIN_FILES
-      fi
-      if [ $i = "ascii" ]; then
-	 FILES=$ASCII_FILES
-      fi
-      for j in $FILES
-      do
-         for a in get put
-         do
-            if [ $a = "get" ]; then
-               { 
-               echo user $RUSER $PASSWD
-               echo lcd $TCtmp
-               echo $i
-               echo cd $TCdat
-               echo $a $j
-               echo quit
-               } | ftp -nv $RHOST
-               SUM1=`ls -l $TCtmp/$j  | awk '{print $5}'`
-               SUM2=`ls -l $TCdat/$j | awk '{print $5}'` 
-               rm -f $TCtmp/$j 
-            else
-               {
-               echo user $RUSER $PASSWD
-               echo lcd $TCdat
-               echo $i
-               echo cd $TCtmp
-               echo $a $j
-               echo quit
-               } | ftp -nv $RHOST
-               SUM1=`rsh -n -l root $RHOST sum $TCtmp/$j  | awk '{print $1}'`
-               SUM2=`sum $TCdat/$j | awk '{print $1}'` 
-               rsh -n -l root $RHOST rm -f $TCtmp/$j
-            fi
+    for i in binary ascii; do
+
+        if [ $i = "binary" ]; then
+            FILES=$BIN_FILES
+        fi
+        if [ $i = "ascii" ]; then
+            FILES=$ASCII_FILES
+        fi
+        for j in $FILES; do
+
+            for a in get put; do
+                if [ $a = "get" ]; then
+                    { 
+                        echo user $RUSER $PASSWD
+                        echo lcd $TCtmp
+                        echo $i
+                        echo cd $TCdat
+                        echo $a $j
+                        echo quit
+                    } | ftp -nv $RHOST
+                    SUM1=`ls -l $TCtmp/$j  | awk '{print $5}'`
+                    SUM2=`ls -l $TCdat/$j | awk '{print $5}'` 
+                    rm -f $TCtmp/$j 
+                else
+                    {
+                        echo user $RUSER $PASSWD
+                        echo lcd $TCdat
+                        echo $i
+                        echo cd $TCtmp
+                        echo $a $j
+                        echo quit
+                    } | ftp -nv $RHOST
+                    SUM1=`rsh -n -l root $RHOST sum $TCtmp/$j | awk '{print $1}'`
+                    SUM2=`sum $TCdat/$j | awk '{print $1}'` 
+                    rsh -n -l root $RHOST rm -f $TCtmp/$j
+                fi
  
-            if [ $SUM1 = $SUM2 ]; then
-               tst_resm TINFO "Test Successful doing ftp $a $j $i"
-            else
-               end_testcase "Test Fail: Wrong sum while performing ftp $a $j $i"
-            fi
-            sleep $SLEEPTIME
-         done
-      done
-   done
+                if [ $SUM1 = $SUM2 ]; then
+                    tst_resm TINFO "Test Successful doing ftp $a $j $i"
+                else
+                    end_testcase "Test Fail: Wrong sum while performing ftp $a $j $i"
+                fi
+                sleep $SLEEPTIME
+            done
+        done
+    done
 }
 
 
@@ -166,32 +138,8 @@
 
 do_cleanup()
 {
-   $trace_logic
-
-   rm -rf $TCtmp
-
-   rsh -n -l root $RHOST rmdir $TCtmp
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-   do_cleanup
-   echo "$this_file: doing $0."
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+    rsh -n -l root $RHOST rmdir "$TCtmp"
+    tst_cleanup
 }
 
 #----------------------------------------------------------------------
@@ -202,6 +150,9 @@
 # OUTPUT:   A testcase run log with the results of the execution of this
 #           test.
 #----------------------------------------------------------------------
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/ftp/ftp02 b/testcases/network/tcp_cmds/ftp/ftp02
index 6b4a2ca..8a9002e 100755
--- a/testcases/network/tcp_cmds/ftp/ftp02
+++ b/testcases/network/tcp_cmds/ftp/ftp02
@@ -29,38 +29,45 @@
 #       This version is intended for EAL certification, it will need modification
 #       to conform with LTP standards in the offical LTP tree.
 
-export RHOST="localhost"
-export TEST_USER="ftpuser2"
-export TEST_USER_PASSWD="eal"
-export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
-export TEST_USER_HOMEDIR="/home/$TEST_USER"
-
 #-----------------------------------------------------------------------
 # FUNCTION:  do_setup
 #-----------------------------------------------------------------------
 
-do_setup(){
-	#erase user if he may exist , so we can have a clean env
-        rm -rf /home/$TEST_USER
-        userdel $TEST_USER 
-        sleep 1
+do_setup()
+{
 
-        useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER 
-        if [ $? != 0 ]
-        then {
-                echo "Could not add test user $TEST_USER to system $RHOST."
-                exit 1
-        }
-        fi
+    export RHOST="localhost"
+    export TEST_USER="ftpuser2"
+    export TEST_USER_PASSWD="eal"
+    export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
+    export TEST_USER_HOMEDIR="/home/$TEST_USER"
+
+    # erase user if he may exist, so we can have a clean env
+    TCtmp="/home/$TEST_USER"
+
+    tst_setup
+
+    exists expect ftp ftp02_s1 useradd userdel
+    
+    userdel $TEST_USER 
+    sleep 1
+
+    if ! useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER; then
+        end_testcase "Could not add test user $TEST_USER to system $RHOST."
+    fi
+
+    trap do_cleanup EXIT
+
 }
 
 #-----------------------------------------------------------------------
 # FUNCTION:  do_cleanup
 #-----------------------------------------------------------------------
 
-do_cleanup(){
-        rm -rf /home/$TEST_USER
-        userdel $TEST_USER
+do_cleanup()
+{
+    userdel $TEST_USER
+    tst_cleanup
 }
 
 #-----------------------------------------------------------------------
@@ -71,9 +78,9 @@
 #	       Cleanup Test User from system
 #              Exit with exit code of script called upon
 #-----------------------------------------------------------------------
-do_setup
-ftp02_s1
-EXIT_CODE=$?
-do_cleanup
-exit $EXIT_CODE
+. net_cmdlib.sh
 
+read_opts $*
+do_setup
+ftp02_s1 || end_testcase "Testcase failed."
+end_testcase
diff --git a/testcases/network/tcp_cmds/ftp/ftp02_s1 b/testcases/network/tcp_cmds/ftp/ftp02_s1
index 26efcb1..c49a561 100755
--- a/testcases/network/tcp_cmds/ftp/ftp02_s1
+++ b/testcases/network/tcp_cmds/ftp/ftp02_s1
@@ -47,8 +47,8 @@
 sleep 1
 # Check if connection succeeded.
 expect {
-   "Name" {}
-   timeout {send_user "\nConnection failed\n Test FAILED \n";exit 1}
+    "Name" {}
+    timeout {send_user "\nConnection failed; test FAILED\n";exit 1}
 }
 
 send "$RUSER\r"
@@ -58,15 +58,14 @@
 sleep 1
 
 expect {
-	# 530 - Login failed
-	"530" {send_user "Ftp invalid password, login test PASSED\n"}
-	# 230 - Login successful
-	"230" {send_user "Ftp invalid password, login test FAILED \n";exit 1}
+    # 530 - Login failed
+    "530" {send_user "Login failed as expected; test PASSED\n"}
+    # 230 - Login successful
+    "230" {send_user "Login succeeded unexpectedly; test FAILED\n"; exit 1}
 }
 
 expect "ftp>"
 send "exit\r"
 
-
 send_user "\nTest Successful\n\n"
 exit 0
diff --git a/testcases/network/tcp_cmds/ftp/ftp03 b/testcases/network/tcp_cmds/ftp/ftp03
index 45ee092..24e30e9 100755
--- a/testcases/network/tcp_cmds/ftp/ftp03
+++ b/testcases/network/tcp_cmds/ftp/ftp03
@@ -31,69 +31,66 @@
 #	This version is intended for EAL certification, it will need modification 
 #	to conform with LTP standards in the offical LTP tree.
 
-RHOST="localhost"
-TEST_USER="ftpuser1"
-TEST_USER_PASSWD="eal"
-TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
-TEST_USER_HOMEDIR="/home/$TEST_USER"
-tvar=${MACHTYPE%-*}
-tvar=${tvar#*-}
-
-if [ $tvar = "redhat" -o $tvar = "redhat-linux" ] 
-then
-ls /etc/vsftpd/vsftpd.conf
- if [ $? != 0 ]
-      then { 
-         echo "vsftpd.conf not found.  Possible cause: does not exist on WS."
-         echo "Test ftp03 FAIL."
-         EXIT_CODE=1
-         exit 1
-      } 
- fi
-LOCAL_ENABLE=`cat /etc/vsftpd/vsftpd.conf | grep "^local_enable=" | awk -F= '{print $2}'`
-else
-LOCAL_ENABLE=`cat /etc/vsftpd.conf | grep "^local_enable=" | awk -F= '{print $2}'`
-fi
-if [ "$LOCAL_ENABLE" != "YES" ]; then
-  LOCAL_ENABLE="NO"
-fi 
-
-EXIT_CODE=0
-
 #-----------------------------------------------------------------------
 # FUNCTION:  do_setup
 #-----------------------------------------------------------------------
 
-do_setup(){
+do_setup()
+{
 	
-	#erase user if he may exist , so we can have a clean env
-        rm -rf /home/$TEST_USER
-	userdel $TEST_USER
-        sleep 1
+    RHOST="localhost"
+    TCtmp=/home/$TEST_USER
+    TEST_USER="ftpuser1"
+    TEST_USER_PASSWD="eal"
+    TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
+    TEST_USER_HOMEDIR="/home/$TEST_USER"
+    VSFTP_CONF=
 
-	useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER 
-	if [ $? != 0 ] 
-	then { 
-		echo "Could not add test user $TEST_USER on system $RHOST."
-		exit 1
-	}
-	fi
+    tst_setup
 
-	#create users home diretory (SLES 8 does not do this, even when specified in adduser)
-	USER_UID=`id -u $TEST_USER`
-	USER_GID=`id -g $TEST_USER`
-	mkdir $TEST_USER_HOMEDIR
-	chown -R $USER_UID.$USER_GID $TEST_USER_HOMEDIR
-	
+    exists ftp useradd userdel vftpd
+
+    for vsftp_conf in /etc/vsftpd /etc; do
+
+        if [ -r "$vsftp_confdir/vsftp.conf" ]; then
+            VSFTP_CONF="$vsftp_confdir/vsftp.conf"
+            break
+        fi
+
+    done
+    if [ ! -r "$VSFTP_CONF" ] ; then
+        end_testcase "vsftpd.conf not found."
+    fi
+    LOCAL_ENABLE=$(awk -F= '/^local_enable=/ {print $2}' "$VSFTP_CONF")
+
+    [ "$LOCAL_ENABLE" != "YES" ] && LOCAL_ENABLE="NO"
+
+    userdel $TEST_USER
+    sleep 1
+
+    if ! useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER; then 
+        end_testcase "Could not add test user $TEST_USER on system $RHOST."
+    fi
+
+    trap do_cleanup QUIT
+
+    # create users home diretory (SLES 8 does not do this, even when specified
+    # in adduser)
+    USER_UID=$(id -u $TEST_USER)
+    USER_GID=$(id -g $TEST_USER)
+    mkdir -p "$TEST_USER_HOMEDIR"
+    chown -R $USER_UID:$USER_GID $TEST_USER_HOMEDIR
+
 }
 
 #-----------------------------------------------------------------------
 # FUNCTION:  do_cleanup
 #-----------------------------------------------------------------------
 
-do_cleanup(){
-        rm -rf /home/$TEST_USER
-	userdel $TEST_USER
+do_cleanup()
+{
+    userdel $TEST_USER
+    tst_cleanup
 }
 
 #-----------------------------------------------------------------------
@@ -105,51 +102,48 @@
 #-----------------------------------------------------------------------
 
 do_test(){
-	echo "TEST: Ftp into a remote host as a local user (other than root), LOCAL_ENABLE=$LOCAL_ENABLE"
+    tst_resm TINFO "TEST: Ftp into a remote host as a local user (other than root), LOCAL_ENABLE=$LOCAL_ENABLE"
 
-if [ "$LOCAL_ENABLE" = "YES" ]; then {
+    if [ "$LOCAL_ENABLE" = "YES" ]; then
 	expect -c "
-                   spawn ftp $RHOST
-                   sleep 1
-                   expect -re \": \"
-                   send \"$TEST_USER\r\"
-                   expect -re \"Password:\"
-                   send \"$TEST_USER_PASSWD\r\"
-                   expect {
-                     # 530 - Login failed
-                           \"530\" {send_user \"==> TEST \#$TEST : FAIL (ftp rejected login attempt)\n\";exit 1}
-                     # 230 - Login successful
-                           \"230\" {send_user \"==> TEST \#$TEST : PASS (ftp allowed login attempt)\n\";exit 0}
-                   }
-                   expect \"ftp> \"
-                   send \"quit\r\"
+            spawn ftp $RHOST
+            sleep 1
+            expect -re \": \"
+            send \"$TEST_USER\r\"
+            expect -re \"Password:\"
+            send \"$TEST_USER_PASSWD\r\"
+            expect {
+                # 530 - Login failed
+                \"530\" {send_user \"==> TEST \#$TEST : FAIL (ftp rejected login attempt)\n\";exit 1}
+                # 230 - Login successful
+                \"230\" {send_user \"==> TEST \#$TEST : PASS (ftp allowed login attempt)\n\";exit 0}
+            }
+            expect \"ftp> \"
+            send \"quit\r\"
 	"
-} else {
+    else
         expect -c "
-                   spawn ftp $RHOST
-                   sleep 1
-                   expect -re \": \"
-                   send \"$TEST_USER\r\"
-                   expect -re \"Password:\"
-                   send \"$TEST_USER_PASSWD\r\"
-                   expect {
-                     # 230 - Login successful
-                           \"230\" {send_user \"==> TEST \#$TEST : FAIL (ftp allowed login attempt)\n\";exit 1} 
-                     # 500 - Login failed
-                           \"500\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
-                     # 530 - Login failed
-                           \"530\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
-                   }
-                   expect \"ftp> \"
-                   send \"quit\r\"
+            spawn ftp $RHOST
+            sleep 1
+            expect -re \": \"
+            send \"$TEST_USER\r\"
+            expect -re \"Password:\"
+            send \"$TEST_USER_PASSWD\r\"
+            expect {
+                # 230 - Login successful
+                \"230\" {send_user \"==> TEST \#$TEST : FAIL (ftp allowed login attempt)\n\";exit 1} 
+                # 500 - Login failed
+                \"500\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
+                # 530 - Login failed
+                \"530\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
+            }
+            expect \"ftp> \"
+            send \"quit\r\"
         "
-} fi
+    fi
 
-
-    if [ $? != 0 ]
-        then {
-        EXIT_CODE=1 
-        }
+    if [ $? != 0 ]; then
+        end_testcase "Testcase failed"
     fi
 }	
 
@@ -158,7 +152,9 @@
 # PURPOSE:  To invoke the functions to perform the tasks described in
 #           the prologue.
 #----------------------------------------------------------------------
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
 do_test
-do_cleanup
-exit $EXIT_CODE
+end_testcase
diff --git a/testcases/network/tcp_cmds/ftp/ftp04 b/testcases/network/tcp_cmds/ftp/ftp04
index 910e087..405fba4 100755
--- a/testcases/network/tcp_cmds/ftp/ftp04
+++ b/testcases/network/tcp_cmds/ftp/ftp04
@@ -28,97 +28,77 @@
 #   03/04/03 Jerone Young (jeroney@us.ibm.com)
 #   09/21/05 Kris Wilson (krisw@us.ibm.com) Check if vsftpd is on system.
 
-
-RHOST=localhost
-TEST_USER=root
-
-if [ $PASSWD ]
-then
-	TEST_USER_PASSWORD=$PASSWD
-else	
-	echo "YOU MUST EXPORT PASSWD VARIABLE"
-	exit 1
-fi
-
-
-EXIT_CODE=0
-
 #-----------------------------------------------------------------------
-# FUNCTION:  verify_user_is_in_ftpusers_db
+# FUNCTION:  do_setup
 #-----------------------------------------------------------------------
                                                                                
-verify_user_is_in_ftpusers_db(){
+do_setup()
+{
 
-tvar=${MACHTYPE%-*}
-tvar=${tvar#*-}
+    tvar=${MACHTYPE%-*}
+    tvar=${tvar#*-}
 
-       if [ $tvar = "redhat" -o $tvar = "redhat-linux" ] 
-       then
-         # Check if vsftpd is on system.
-         which vsftpd
-         if [ $? != 0 ]
-         then { 
-            echo "vsftpd not found.  Possible cause: does not exist on WS."
-            echo "Test ftp04 FAIL."
-            EXIT_CODE=1
-            exit 1
-       } 
-       fi
+    RHOST=localhost
+    TEST_USER=root
+
+    tst_setup
+
+    if [ -n "$PASSWD" ]; then
+        TEST_USER_PASSWORD=$PASSWD
+    else	
+        end_testcase "You must set your password via the PASSWD variable."
+        exit 1
+    fi
+
+    exists awk expect ftp vsftpd
+
+    if [ $tvar = "redhat" -o $tvar = "redhat-linux" ]; then
         echo "Verifying test user $TEST_USER is in /etc/vsftpd.ftpusers database..."
-        FTPUSERS=`grep $TEST_USER /etc/vsftpd.ftpusers`
-       else
+        FTPUSERS=$(awk "/$TEST_USER/" /etc/vsftpd.ftpusers)
+    else
         echo "Verifying test user $TEST_USER is in /etc/ftpusers database..."
-        FTPUSERS=`grep $TEST_USER /etc/ftpusers`
-       fi
-        if [ "x$FTPUSERS" = "x" ]
-        then {
-            echo "Test user $TEST_USER not found in /etc/ftpusers unable to run TEST, exiting 0 ..."
-			exit 0
-         }
-		 fi
-	
+        FTPUSERS=$(awk "/$TEST_USER/" /etc/ftpusers)
+    fi
+    if [ -z "$FTPUSERS" ] ; then
+        end_testcase "Test user $TEST_USER not found in /etc/ftpusers unable to run TEST, exiting 0 ..."
+    fi
+
 }
 
 #-----------------------------------------------------------------------
 # FUNCTION:  do_test
 #-----------------------------------------------------------------------
-do_test() {
+do_test()
+{
 
-		echo "TEST: Ftp should reject $TEST_USER from loging in successfully"
-        expect -c "
-                   spawn ftp $RHOST
-                   sleep 1
-                   expect -re \": \"
-                   send \"$TEST_USER\r\"
-                   expect -re \"Password:\"
-                   send \"$TEST_USER_PASSWD\r\"
-                   expect {
-                     # 230 - Login successful
-                           \"230\" {send_user \"==> TEST \#$TEST : FAIL (ftp allowed login attempt)\n\";exit 1}
-                     # 530 - Login failed
-                           \"530\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
-                   }
-                   expect \"ftp> \"
-                   send \"quit\r\"
-        "
-
-    if [ $? != 0 ]
-        then {
-        EXIT_CODE=1
+    tst_resm TINFO "Ftp should reject $TEST_USER from loging in successfully"
+    expect -c "
+        spawn ftp $RHOST
+        sleep 1
+        expect -re \": \"
+        send \"$TEST_USER\r\"
+        expect -re \"Password:\"
+        send \"$TEST_USER_PASSWD\r\"
+        expect {
+            # 230 - Login successful
+            \"230\" {send_user \"==> TEST \#$TEST : FAIL (ftp allowed login attempt)\n\";exit 1}
+            # 530 - Login failed
+            \"530\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
         }
-    fi
+        expect \"ftp> \"
+        send \"quit\r\"
+    "
+
+    [ $? -eq 0 ] || end_testcase "Testcase failed."
 
 }
 
 #----------------------------------------------------------------------
 # FUNCTION: MAIN
 #----------------------------------------------------------------------
-verify_user_is_in_ftpusers_db
+. net_cmdlib.sh
+
+read_opts $*
+do_setup
 do_test
-exit $EXIT_CODE
-
-
-
-
-
-
+end_testcase
diff --git a/testcases/network/tcp_cmds/ftp/ftp05 b/testcases/network/tcp_cmds/ftp/ftp05
index f372bb3..ed133c00 100755
--- a/testcases/network/tcp_cmds/ftp/ftp05
+++ b/testcases/network/tcp_cmds/ftp/ftp05
@@ -31,90 +31,85 @@
 #	This version is intended for EAL certification, it will need modification 
 #	to conform with LTP standards in the offical LTP tree.
 
-RHOST="localhost"
-TEST_USER="anonymous"
-TEST_USER_PASSWD="noone@nowhere.com"
+do_setup()
+{
+    RHOST="localhost"
+    TEST_USER="anonymous"
+    TEST_USER_PASSWD="noone@nowhere.com"
+    VSFTP_CONF=
 
-tvar=${MACHTYPE%-*}
-tvar=${tvar#*-}
+    tst_setup
 
-if [ $tvar = "redhat" -o $tvar = "redhat-linux" ] 
-then
+    exists expect ftp vsftpd
 
-   # Check if vsftpd is on system.
-   which vsftpd
-   if [ $? != 0 ]
-   then {
-      echo "vsftpd not found.  Possible cause: does not exist on WS."
-      echo "Test ftp05 FAIL."
-      EXIT_CODE=1
-      exit 1
-   }
-   fi
+    for vsftp_conf in /etc/vsftpd /etc; do
 
-ANONYMOUS_ENABLE=`cat /etc/vsftpd/vsftpd.conf | grep "^anonymous_enable=" | awk -F= '{print $2}'`
-else
-ANONYMOUS_ENABLE=`cat /etc/vsftpd.conf | grep "^anonymous_enable=" | awk -F= '{print $2}'`
-fi
-if [ "$ANONYMOUS_ENABLE" != "NO" ]; then
-  ANONYMOUS_ENABLE="YES"
-fi 
+        if [ -r "$vsftp_confdir/vsftp.conf" ]; then
+            VSFTP_CONF="$vsftp_confdir/vsftp.conf"
+            break
+        fi
 
-EXIT_CODE=0
-
-#-----------------------------------------------------------------------
-# FUNCTION:  do_test
-#
-# DESCRIPTION: The anonymous user will ftp in and create a directory in his home directory on the remote host.
-#-----------------------------------------------------------------------
-
-do_test(){
-	echo "TEST: Ftp into a remote host as anonymous user, ANONYMOUS_ENABLE=$ANONYMOUS_ENABLE"
-
-if [ "$ANONYMOUS_ENABLE" = "YES" ]; then {
-	expect -c "
-                   spawn ftp $RHOST
-                   sleep 1
-                   expect -re \": \"
-                   send \"$TEST_USER\r\"
-                   expect -re \"Password:\"
-                   send \"$TEST_USER_PASSWD\r\"
-                   expect {
-                     # 530 - Login failed
-                           \"530\" {send_user \"==> TEST \#$TEST : FAIL (ftp rejected login attempt)\n\";exit 1}
-                     # 230 - Login successful
-                           \"230\" {send_user \"==> TEST \#$TEST : PASS (ftp allowed login attempt)\n\";exit 0}
-                   }
-                   expect \"ftp> \"
-                   send \"quit\r\"
-	"
-} else {
-        expect -c "
-                   spawn ftp $RHOST
-                   sleep 1
-                   expect -re \": \"
-                   send \"$TEST_USER\r\"
-                   expect -re \"Password:\"
-                   send \"$TEST_USER_PASSWD\r\"
-                   expect {
-                     # 230 - Login successful
-                           \"230\" {send_user \"==> TEST \#$TEST : FAIL (ftp allowed login attempt)\n\";exit 1} 
-                     # 500 - Login failed
-                           \"500\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
-                     # 530 - Login failed
-                           \"530\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
-                   }
-                   expect \"ftp> \"
-                   send \"quit\r\"
-        "
-} fi
-
-
-    if [ $? != 0 ]
-        then {
-        EXIT_CODE=1 
-        }
+    done
+    if [ ! -r "$VSFTP_CONF" ] ; then
+        end_testcase "vsftpd.conf not found."
     fi
+    ANONYMOUS_ENABLE=$(awk -F= '/^anonymous_enable=/ {print $2}' "$VSFTP_CONF")
+    if [ "$ANONYMOUS_ENABLE" != "NO" ]; then
+        ANONYMOUS_ENABLE="YES"
+    fi
+}
+
+#-----------------------------------------------------------------------
+# FUNCTION   : do_test
+#
+# DESCRIPTION: The anonymous user will ftp in and create a directory in his/her
+#              home directory on the remote host.
+#-----------------------------------------------------------------------
+
+do_test()
+{
+    tst_resm TINFO "Ftp into a remote host as anonymous user; ANONYMOUS_ENABLE=$ANONYMOUS_ENABLE"
+
+    if [ "$ANONYMOUS_ENABLE" = "YES" ]; then
+        expect -c "
+            spawn ftp $RHOST
+            sleep 1
+            expect -re \": \"
+            send \"$TEST_USER\r\"
+            expect -re \"Password:\"
+            send \"$TEST_USER_PASSWD\r\"
+            expect {
+                # 530 - Login failed
+                \"530\" {send_user \"==> TEST \#$TEST : FAIL (ftp rejected login attempt)\n\";exit 1}
+                # 230 - Login successful
+                \"230\" {send_user \"==> TEST \#$TEST : PASS (ftp allowed login attempt)\n\";exit 0}
+            }
+            expect \"ftp> \"
+            send \"quit\r\"
+	"
+    else
+        expect -c "
+            spawn ftp $RHOST
+            sleep 1
+            expect -re \": \"
+            send \"$TEST_USER\r\"
+            expect -re \"Password:\"
+            send \"$TEST_USER_PASSWD\r\"
+            expect {
+                # 230 - Login successful
+                \"230\" {send_user \"==> TEST \#$TEST : FAIL (ftp allowed login attempt)\n\";exit 1} 
+                # 500 - Login failed
+                \"500\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
+                # 530 - Login failed
+                \"530\" {send_user \"==> TEST \#$TEST : PASS (ftp rejected login attempt)\n\";exit 0}
+            }
+            expect \"ftp> \"
+            send \"quit\r\"
+        "
+    fi
+
+    [ $? -eq 0 ] || end_testcase "Testcase failed."
+
 }	
 
 #----------------------------------------------------------------------
@@ -122,5 +117,9 @@
 # PURPOSE:  To invoke the functions to perform the tasks described in
 #           the prologue.
 #----------------------------------------------------------------------
+. net_cmdlib.sh
+
+read_opts $*
+do_setup
 do_test
-exit $EXIT_CODE
+end_testcase
diff --git a/testcases/network/tcp_cmds/ftp/ftp_set_passwd b/testcases/network/tcp_cmds/ftp/ftp_set_passwd
index af56b3a..8e94033 100755
--- a/testcases/network/tcp_cmds/ftp/ftp_set_passwd
+++ b/testcases/network/tcp_cmds/ftp/ftp_set_passwd
@@ -8,7 +8,7 @@
 #
 
 if { [llength $argv] < 2} {
-	exit 1
+    exit 1
 }
  
 set USER [lindex $argv 0]
diff --git a/testcases/network/tcp_cmds/host/Makefile b/testcases/network/tcp_cmds/host/Makefile
index b7341c9..333047d 100644
--- a/testcases/network/tcp_cmds/host/Makefile
+++ b/testcases/network/tcp_cmds/host/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/tcp_cmds/host testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f host01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= host01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/host/host01 b/testcases/network/tcp_cmds/host/host01
index d6b7cae..78bcbb6 100755
--- a/testcases/network/tcp_cmds/host/host01
+++ b/testcases/network/tcp_cmds/host/host01
@@ -32,32 +32,18 @@
 #
 #
 #-----------------------------------------------------------------------
-# Uncomment line below for debug output
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
 
-RHOST=${RHOST:-`hostname`}
-NUMLOOPS=${NUMLOOPS:-20}
-SLEEPTIME=${SLEEPTIME:-0}
-
-this_file=${0##*/}
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-#
-#-----------------------------------------------------------------------
-
-exists()
+do_setup()
 {
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
+    NUMLOOPS=${NUMLOOPS:-1}
+    SLEEPTIME=${SLEEPTIME:-0}
+
+    tst_setup
+
+    exists awk host hostname
+
+    RHOST=${RHOST:-`hostname`}
+
 }
 
 #-----------------------------------------------------------------------
@@ -68,52 +54,34 @@
 
 do_test()
 {
-   $trace_logic
-   tst_resm TINFO "$this_file: test the basic functionality of the `host` command."
 
-   count=0
-   while [ $count -lt $NUMLOOPS ]
-   do
-      host $RHOST
-      if [ $? -eq 0 ]; then
-         rhost_addr=`host $RHOST | tr -s ',' ' ' | awk '{print $NF}'` 2>&1 \
-                     >/dev/null
-         host $rhost_addr  2>&1 >/dev/null
-         [ $? -eq 0 ] || end_testcase "host can not do a reverse lookup"
-      else 
-         end_testcase "host $RHOST on local machine failed"
-      fi
-      count=$(( $count + 1 ))
-      sleep $SLEEPTIME
-   done
-}
+    tst_resm TINFO "test basic functionality of the \`$TC' command."
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
+    while [ $TST_COUNT -lt $NUMLOOPS ]; do
 
-end_testcase()
-{
-   $trace_logic
-   tst_resm TINFO "$this_file: doing $0."
+        if rhost_addr=$(host $RHOST); then
+            rhost_addr=$(echo "$rhost_addr" | awk -F, '{print $NF}') 2>&1 >/dev/null
+            if ! host $rhost_addr 2>&1 >/dev/null; then
+                end_testcase "reverse lookup with host failed"
+            fi
 
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+        else 
+            end_testcase "host $RHOST on local machine failed"
+        fi
+
+        incr_tst_count
+        sleep $SLEEPTIME
+
+    done
+
 }
 
 #-----------------------------------------------------------------------
 # FUNCTION: MAIN
 #-----------------------------------------------------------------------
-export TCID="host01"
-export TST_TOTAL=1
-export TST_COUNT=1
-exists "host awk"
+. net_cmdlib.sh
+
+read_opts $*
+do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/include/netdefs.h b/testcases/network/tcp_cmds/include/netdefs.h
new file mode 100644
index 0000000..067f20a
--- /dev/null
+++ b/testcases/network/tcp_cmds/include/netdefs.h
@@ -0,0 +1,73 @@
+/*
+ *   tcpcmds common definitions header (designed for to maximize modularity
+ *   between IPv4 and IPv6 test code).
+ *
+ * Copyright (C) 2009, Cisco Systems Inc.
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License along
+ *   with this program; if not, write to the Free Software Foundation, Inc.,
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#ifndef __NETDEFS_H
+#define __NETDEFS_H
+
+#include <netdb.h>
+
+#if INET6
+
+#include <netinet/ip6.h>
+#include <netinet/icmp6.h>
+
+typedef struct icmp6_hdr	icmp_t;
+typedef struct sockaddr		sa_t;
+typedef struct sockaddr_in6	sai_t;
+
+#define AFI			AF_INET6
+#define IERP			ICMP6_ECHO_REPLY
+#define IERQ			ICMP6_ECHO_REQUEST
+#define ICMP_PROTO		"ipv6-imcp"
+#define PFI			PF_INET6
+
+#else
+
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+
+typedef struct icmp		icmp_t;
+typedef struct sockaddr		sa_t;
+typedef struct sockaddr_in	sai_t;
+
+#define AFI			AF_INET
+#define IERP			ICMP_ECHOREPLY
+#define IERQ			ICMP_ECHO
+#define ICMP_PROTO		"imcp"
+#define PFI			PF_INET
+
+#endif
+
+#define LISTEN_BACKLOG	10
+
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#endif
diff --git a/testcases/network/tcp_cmds/netstat/Makefile b/testcases/network/tcp_cmds/netstat/Makefile
index b61180f..87b6964 100644
--- a/testcases/network/tcp_cmds/netstat/Makefile
+++ b/testcases/network/tcp_cmds/netstat/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/tcp_cmds/netstat testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f netstat01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= netstat01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/netstat/netstat01 b/testcases/network/tcp_cmds/netstat/netstat01
index 1cf0d9d..6a197de 100755
--- a/testcases/network/tcp_cmds/netstat/netstat01
+++ b/testcases/network/tcp_cmds/netstat/netstat01
@@ -31,32 +31,16 @@
 #
 #
 #-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
 
-NUMLOOPS=${NUMLOOPS:-5}
-SLEEPTIME=${SLEEPTIME:-0}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-#
-#-----------------------------------------------------------------------
-
-exists()
+do_setup()
 {
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
-}
+    NUMLOOPS=${NUMLOOPS:-1}
+    SLEEPTIME=${SLEEPTIME:-0}
 
+    tst_setup
+
+    exists netstat
+}
 
 #-------------------------------------------------------------------------
 # FUNCTION:  do_test
@@ -70,39 +54,21 @@
 #-----------------------------------------------------------------------
 
 do_test() { 
-   $trace_logic
 
-   COUNT=1
-   while [ $COUNT -le $NUMLOOPS ]
-   do
-      for COMMAND in "netstat -s" "netstat -rn" "netstat -i" "netstat -gn" "netstat -apn"
-      do
-         $COMMAND 2>&1 1>/dev/null
-         [ $? -eq 0 ] || end_testcase "$COMMAND failed" 
-      done
+    while [ $TST_COUNT -le $NUMLOOPS ]; do
 
-      COUNT=$(( $COUNT + 1 ))
-      sleep $SLEEPTIME
+        for flag in "-s" "-rn" "-i" "-gn" "-apn"; do
+            if ! netstat $flag 2>&1 1>/dev/null; then
+                end_testcase "$COMMAND failed"
+            fi
+        done
+
+        incr_tst_count
+
+        sleep $SLEEPTIME
+
    done
-}
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
 }
 
 #-----------------------------------------------------------------------
@@ -114,9 +80,9 @@
 # OUTPUT:    Logged run results written to testcase run log
 #
 #-----------------------------------------------------------------------
-export TCID="netstat01"
-export TST_TOTAL=1
-export TST_COUNT=1
-exists "netstat"
+. net_cmdlib.sh
+
+read_opts $*
+do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/perf_lan/Makefile b/testcases/network/tcp_cmds/perf_lan/Makefile
index 58537b6..9990f5a 100644
--- a/testcases/network/tcp_cmds/perf_lan/Makefile
+++ b/testcases/network/tcp_cmds/perf_lan/Makefile
@@ -1,17 +1,44 @@
-CFLAGS+=    -I../../../../include -Wall -w -O
-LOADLIBES+= -L../../../../lib -lltp
-LDLIBS += 
+#
+#    network/tcp_cmds/perf_lan testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	ln -f perf_lan ../../../bin
-	ln -f pingpong ../../../bin
+CFLAGS			+= -g
 
-clean:
-	rm -f $(TARGETS)
+CPPFLAGS		+= -I$(abs_srcdir)/../include
 
+INSTALL_TARGETS		:= perf_lan
 
+# NOTE (garrcoop): Once everything compiles with the same sources using
+# pingpong.c, then the following commented code should be uncommented and
+# pingpong6.c should be nuked. Unfortunately that isn't quite yet...
+#
+#MAKE_TARGETS		:= pingpong pingpong6
+#
+#%6: CPPFLAGS += -DINET6
+#
+#%6.o: %.c
+#	$(COMPILE.c) $(OUTPUT_OPTION) $<
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/perf_lan/perf_lan b/testcases/network/tcp_cmds/perf_lan/perf_lan
index 4125fde..7fbc4ad 100755
--- a/testcases/network/tcp_cmds/perf_lan/perf_lan
+++ b/testcases/network/tcp_cmds/perf_lan/perf_lan
@@ -21,7 +21,7 @@
 #
 #  FILE   : perf_lan
 #
-#  PURPOSE: Generates LAN traffic using ICMP tst_resm TINFO packets.
+#  PURPOSE: Generates LAN traffic using ICMP echo packets.
 #           
 #
 #  SETUP: The home directory of root on the machine exported as "RHOST"
@@ -36,30 +36,20 @@
 #
 #
 #***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TC=slan
-RHOST=${RHOST:-`hostname`}
-TCbin=${TCbin:-`pwd`}
-TCsrc=${TCsrc:-$TCbin}
-TCtmp=${TCtmp:-$TCsrc/perf_lan$$}
-CLEANUP=${CLEANUP:-ON}
-
-PACKETSIZE=${PACKETSIZE:-512}
-NUMPACKETS=${NUMPACKETS:-1}
-NUMLOOPS=${NUMLOOPS:-10}
-EXECUTABLES="pingpong"
-
-trap "interrupt_testcase" 2 15 16 30
 
 do_setup()
 {
-  export TCID="perf_lan"
-  export TST_TOTAL=1
-  export TST_COUNT=1
-  mkdir -p $TCtmp
+    RHOST=${RHOST:-`hostname`}
+    TCtmp=${TCtmp:-$LTPROOT/testcases/bin/${TC}$$}
+
+    PACKETSIZE=${PACKETSIZE:-512}
+    NUMPACKETS=${NUMPACKETS:-1}
+    NUMLOOPS=${NUMLOOPS:-10}
+    PINGPONG="pingpong${EXEC_SUFFIX}"
+
+    tst_setup
+
+    trap interrupt_testcase INT TERM URG USR1
 }
 
 #-----------------------------------------------------------------------
@@ -72,75 +62,29 @@
 
 do_test() 
 {
-   $trace_logic
-   tst_resm TINFO "$this_file: doing $0."
+    tst_resm TINFO "Executing $0"
 
-   TLOOP=1
-   COUNT=1
-   [ $NUMLOOPS -gt 0 ] || TLOOP=$NUMLOOPS
-   while [ $TLOOP -le $NUMLOOPS ]
-   do
-      $TCbin/$EXECUTABLES $RHOST $PACKETSIZE $NUMPACKETS
-      RETVALUE=$?
+    while [ $TST_COUNT -le $NUMLOOPS ]; do
 
-      case "$RETVALUE" in
-         0) tst_resm TINFO "Successful execution for loop $COUNT" ;;
-         1) end_testcase "Error trying to send to host" ;;
-         2) end_testcase "Error - Data length is too long";;
-         3) end_testcase "Usage error ";;
-         5) end_testcase "Error - Socket setting" ;;
-         6) end_testcase "Error - Pipe broken";;
-         7) end_testcase "Error - Fork fail";;
-         10)end_testcase "Error - wrong Protocol" ;;
-         *) end_testcase "Return code from $EXECUTABLES is $RETVALUE" ;;
-      esac
-      if [ $NUMLOOPS -gt 0 ] ; then TLOOP=$(( $TLOOP + 1 )); fi
-      COUNT=$(( $COUNT + 1 ))
-   done
-}
+        $PINGPONG $RHOST $PACKETSIZE $NUMPACKETS
 
-#-----------------------------------------------------------------------
-#
-# FUNCTION:     do_cleanup
-# PURPOSE:      Called when the testcase is interrupted by the user
-#               or by interrupt_testcase() when time limit expired
-# INPUT:        None.
-# OUTPUT:       None.
-#
-#-----------------------------------------------------------------------
+        RETVALUE=$?
 
-do_cleanup()
-{
-   $trace_logic
-   tst_resm TINFO "$this_file: doing $0."
+        case "$RETVALUE" in
+            0)  tst_resm TINFO "Successful execution for loop $TST_COUNT";;
+            1)  end_testcase "Error trying to send to host";;
+            2)  end_testcase "Error - Data length is too long";;
+            3)  end_testcase "Usage error ";;
+            5)  end_testcase "Error - Socket setting";;
+            6)  end_testcase "Error - Pipe broken";;
+            7)  end_testcase "Error - Fork fail";;
+            10) end_testcase "Error - wrong Protocol";;
+            *)  end_testcase "Unexpected exit code from $PINGPONG: $RETVALUE";;
+       esac
+       incr_tst_count
 
-   cd /
-   if [ $TCtmp != $TCsrc ]; then
-      rm -rf $TCtmp
-   fi
-}
+    done
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-# 
-# FUNCTION DESCRIPTION: Clean up
-# 
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-# 
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{  
-   $trace_logic
-   tst_resm TINFO "$this_file: doing $0."
-   
-   # Call other cleanup functions
-   [ $CLEANUP = "ON" ] && do_cleanup
-   
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
 }
 
 #-----------------------------------------------------------------------
@@ -154,13 +98,10 @@
 
 interrupt_testcase()
 {
-   $trace_logic
-   tst_resm TINFO "$this_file: doing $0."
-
-   tst_resm TINFO "Testcase interrupted - cleaning up"
-   tst_resm TINFO "Killing background process if it is still running"
-   kill -9 $CHILDPID
-   end_testcase
+    tst_resm TINFO "Testcase interrupted - cleaning up"
+    tst_resm TINFO "Killing background process if it is still running"
+    kill -9 $CHILDPID
+    end_testcase
 }
 
 #-----------------------------------------------------------------------
@@ -172,6 +113,10 @@
 # OUTPUT:    Logged run results written to testcase run log
 #
 #-----------------------------------------------------------------------
+. tcpcmds.sh
+
+read_args $*
+
 do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/perf_lan/pingpong.c b/testcases/network/tcp_cmds/perf_lan/pingpong.c
index 0de6956..5e73ebf 100644
--- a/testcases/network/tcp_cmds/perf_lan/pingpong.c
+++ b/testcases/network/tcp_cmds/perf_lan/pingpong.c
@@ -1,7 +1,7 @@
 /*
 #
 #
-#                              Task Subprogram 
+#						      Task Subprogram 
 #
 #  SUBPROGRAM NAME: PINGPONG.C
 #
@@ -34,310 +34,317 @@
 #define PS2
 #include <stdio.h>
 #include <errno.h>
+#include <stdint.h>
 #include <string.h>
 #include <sys/time.h>
 #include <sys/types.h>
-
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/file.h>
 #include <sys/signal.h>
-
 #include <arpa/inet.h>
-
 #include <netinet/in_systm.h>
 #include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
 #include <netdb.h>
 #include "test.h"
 #include "usctest.h"
-
+#include "netdefs.h"
 
 #define	MAXPACKET	4096	/* max packet size */
 #ifndef MAXHOSTNAMELEN
 #define MAXHOSTNAMELEN	64
 #endif
 
-int	pfd[2];
-int	fdstr[10];
-int	verbose;
-int	count;
-u_char	packet[MAXPACKET];
-int	options;
-int s;			/* Socket file descriptor */
-struct hostent *hp;	/* Pointer to host info */
-struct timezone tz;	/* leftover */
+#if INET6
+char		*TCID = "perf_lan6";
+#else
+char		*TCID = "perf_lan";
+#endif
 
-struct sockaddr whereto;/* Who to pingpong */
-int datalen;		/* How much data */
+int		TST_TOTAL = 1;
 
+int		pfd[2];
+int		fdstr[10];
+int		verbose;
+int		count;
+uint8_t		packet[MAXPACKET];
+int		options;
+int		s;			/* Socket file descriptor */
+struct hostent	*hp;			/* Pointer to host info */
+struct timezone	tz;			/* leftover */
 
-char *hostname;
-char hnamebuf[MAXHOSTNAMELEN];
+sai_t		whereto;		/* Who to pingpong */
+int		datalen;		/* How much data */
 
-int npackets=1;
-int ntransmitted = 0;		/* sequence # for outbound packets = #sent */
-int ident;
+char		*hostname;
+char		hnamebuf[MAXHOSTNAMELEN];
 
-int nreceived = 0;		/* # of packets we got back */
-int timing = 0;
-void finish(int); 
-int nwrite;
-char *TCID = "perf_lan";
-int TST_TOTAL = 1;
-extern int Tst_count;
+int		npackets = 1;
+int		ntransmitted = 0;	/* sequence number for outbound
+					 * packets => amount sent */
+int		ident;
+int		nwrite;
 
-u_short in_cksum(u_short *, int);
-int ck_packet(char *, int, struct sockaddr_in *);
-int echopkt(int, int);
+int		nreceived = 0;		/* # of packets we got back */
+int		timing = 0;
 
+void		finish(int); 
+uint16_t	in_cksum(uint16_t*, int);
+int		ck_packet(uint8_t*, size_t, sai_t*);
+int		echopkt(int, int);
 
 /*
  * 			M A I N
  */
-int main(argc, argv)
-char *argv[];
+int
+main (int argc, char *argv[])
 {
-	struct sockaddr_in from;
-	char **av = argv;
-	struct sockaddr_in *to = (struct sockaddr_in *) &whereto;
+	sai_t from;
 	int rc = 0;
 	struct protoent *proto;
 
-	tst_resm (TINFO, "Starting pingpong - to send / receive packets from host \n");
+	tst_resm (TINFO, "Starting pingpong - to send / receive packets from "
+			 "host");
 
-        /* Get Host net address */
-        tst_resm (TINFO, "Get host net address for sending packets \n");
-	memset( (char *)&whereto, 0x00, sizeof(struct sockaddr) );
-	to->sin_family = AF_INET;
-	to->sin_addr.s_addr = inet_addr(av[1]);
-	if (to->sin_addr.s_addr != -1) {
-		strcpy(hnamebuf, av[1]);
+	/* Get Host net address */
+	tst_resm (TINFO, "Get host net address for sending packets");
+	memset( (char *)&whereto, 0, sizeof(sa_t) );
+#if INET6
+	whereto.sin6_family = AFI;
+	whereto.sin6_addr.s6_addr = inet_addr(argv[1]);
+	if (whereto.sin6_addr.s6_addr != -1) {
+#else
+	whereto.sin_family = AFI;
+	whereto.sin_addr.s_addr = inet_addr(argv[1]);
+	if (whereto.sin_addr.s_addr != -1) {
+#endif
+		strcpy(hnamebuf, argv[1]);
 		hostname = hnamebuf;
 	} else {
-		hp = gethostbyname(av[1]);
-		if (hp) {
-			to->sin_family = hp->h_addrtype;
-			memcpy((caddr_t)&to->sin_addr, hp->h_addr, hp->h_length);
+
+		if ((hp = gethostbyname(argv[1])) != NULL) {
+#if INET6
+			whereto.sin6_family = hp->h_addrtype;
+			memcpy((caddr_t) &whereto.sin6_addr, hp->h_addr, hp->h_length);
+#else
+			whereto.sin_family = hp->h_addrtype;
+			memcpy((caddr_t) &whereto.sin_addr, hp->h_addr, hp->h_length);
+#endif
 			hostname = hp->h_name;
 		} else {
-            tst_resm (TINFO, "%s: unknown host, couldn't get address\n",argv[0]);
-			exit(1);
+			tst_resm (TBROK, "%s: unknown host, couldn't get "
+					 "address", argv[0]);
+			tst_exit();
 		}
+
 	}
 
 
 
-    /*  Determine Packet Size - either use what was passed in or default */
-        tst_resm (TINFO, "Determine packet size \n");
-	if( argc >= 3 )
-		datalen = atoi( av[2] );
+	/*  Determine Packet Size - either use what was passed in or the default */
+	tst_resm (TINFO, "Determining packet size");
+
+	if (argc >= 3)
+		datalen = atoi(argv[2]);
+		if (datalen < 0) {
+			tst_resm (TBROK, "datalen must be an integer.");
+			tst_exit();
+		}
 	else
-		datalen = 64-8;
+		datalen = 64;
+
+	datalen -= 8;
+
 	if (datalen > MAXPACKET) {
-		tst_resm (TINFO, "Pingpong: packet size too large\n");
-		exit(1);
+		tst_resm (TBROK, "packet size too large");
+		tst_exit();
 	}
 	if (datalen >= sizeof(struct timeval))
 		timing = 1;
 
-
         /* Set number of packets to be sent */
-        tst_resm (TINFO, "Determine number of packets to send \n");
+	tst_resm (TINFO, "Determining number of packets to send");
 	if (argc >= 4)
-		npackets = atoi(av[3]);
+		npackets = atoi(argv[3]);
 
 
         /* Get PID of current process */
 	ident = getpid() & 0xFFFF;
 
 
-        /* Get network protocol to use (check /etc/protocol) */
-	if ((proto = getprotobyname("icmp")) == NULL) {
-		tst_resm (TINFO, "ICMP: unknown protocol\n");
-		exit(10);
+	/* Get network protocol to use (check /etc/protocol) */
+	if ((proto = getprotobyname(ICMP_PROTO)) == NULL) {
+		tst_resm (TINFO, "unknown protocol: %s", ICMP_PROTO);
+		tst_exit();
 	}
 
  
-        /* Create a socket endpoint for communications - returns a descriptor */
-	if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) {
-		tst_resm (TINFO, "Pingpong: socket - could not create link \n");
-		exit(5);
+	/* Create a socket endpoint for communications - returns a descriptor */
+	if ((s = socket(AFI, SOCK_RAW, proto->p_proto)) < 0) {
+		tst_resm (TINFO, "socket - could not create link");
+		tst_exit();
 	}
 
-	tst_resm (TINFO, "echoing %s: %d data bytes\n", hostname, datalen );
+	tst_resm (TINFO, "echoing %s: %d data bytes", hostname, datalen);
 
-	setlinebuf( stdout );
+	setlinebuf(stdout);
 
-        /* Setup traps */
-	signal( SIGINT, finish );
-	signal( SIGCLD, finish );
+	/* Setup traps */
+	signal(SIGINT, finish);
+	signal(SIGCLD, finish);
 
      
-        /* Fork a child process to continue sending packets */
-        tst_resm (TINFO, "Create a child process to continue to send packets \n");
+	/* Fork a child process to continue sending packets */
+	tst_resm (TINFO, "Create a child process to continue to send packets");
 	switch (fork()) {
 	case -1:
-		tst_resm (TINFO, "ERROR when forking a new process\n");
-		exit(1);
+		tst_resm (TINFO, "ERROR when forking a new process");
+		tst_exit();
 	case 0:
-                /* Child's work */
-		ntransmitted=echopkt(datalen,npackets);
-		tst_resm (TINFO, "%d packets transmitted, ",ntransmitted);
+		/* Child's work */
+		ntransmitted = echopkt(datalen, npackets);
+		tst_resm (TINFO, "%d packets transmitted", ntransmitted);
 		sleep(10);
 		break;
 	default:
-                tst_resm (TINFO, "Parent started - to  receive packets \n");
-                /* Parent's work - receive packets back from child */
-		for (;;) {
-			int len = sizeof (packet);
-			unsigned int fromlen = sizeof (from);
-#ifdef __64BIT__
-                        long cc;
-#else
-			int cc;
-#endif
+
+		tst_resm (TINFO, "Parent started - to  receive packets");
+		/* Parent's work - receive packets back from child */
+
+		size_t len;
+
+		while (1) {
+
+			len = sizeof (packet);
+			size_t cc;
+			socklen_t fromlen;
 
 			/* Receive packet from socket */
-			tst_resm (TINFO, "Receiving packet \n");
-			fromlen = sizeof (from);
-			if ( (cc=recvfrom(s, packet, len, 0, (struct sockaddr *)&from, &fromlen)) < 0) {
-				tst_resm (TINFO, "ERROR in recvfrom\n");
+			tst_resm (TINFO, "Receiving packet");
+			if ( (cc = recvfrom(s, packet, len, 0, (sa_t*) &from, &fromlen)) < 0) {
+				tst_resm (TINFO, "ERROR - recvfrom");
 			}
-                        /* Verify contents of packet */
-                        if ((rc = ck_packet (packet, cc, &from)) != 0) {
-                                tst_resm (TINFO, "ERROR - network garbled packet\n");
-			}
-                        else {
+			/* Verify contents of packet */
+			if ((rc = ck_packet (packet, cc, &from)) != 0) {
+				tst_resm (TINFO, "ERROR - network garbled packet");
+			} else {
 				nreceived++;
 			} 
+
 		}
+
 	}
+
 	return 0;
+
 }
 
-int echopkt(datalen,npackets)
-int datalen;
-int npackets;
+int
+echopkt (int datalen, int npackets)
 {
-	int count=0;
-	static u_char outpack[MAXPACKET];
-	register struct icmp *icp = (struct icmp *) outpack;
-        int i;
-#ifdef __64BIT__
-                        long cc;
-#else
-                        int cc;
-#endif
+	int count = 0;
+	static uint8_t outpack[MAXPACKET];
+	register icmp_t *icp = (icmp_t *) outpack;
+	int i;
+	size_t cc;
 
-	register struct timeval *tp = (struct timeval *) &outpack[8];
-	register u_char *datap = &outpack[8+sizeof(struct timeval)];
-
+	register u_char *datap = &outpack[8];
 
         /* Setup the packet structure */
-        tst_resm (TINFO, "Setup ICMP packet structure to send to host \n");
-	icp->icmp_type = ICMP_ECHO;
+        tst_resm (TINFO, "Setting up ICMP packet structure to send to host");
+
+#if INET6
+	icp->icmp6_type = IERQ;
+	icp->icmp6_code = 0;
+	icp->icmp6_id = ident;		/* ID */
+#else
+	icp->icmp_type = IERQ;
 	icp->icmp_code = 0;
-	icp->icmp_cksum = 0;
 	icp->icmp_id = ident;		/* ID */
+#endif
 
-	cc = datalen+8;			/* skips ICMP portion */
+	cc = datalen + 8;		/* skips ICMP portion */
 
-
-        /* Add time stamp and user data */
-        tst_resm (TINFO, "Add time stamp, user data, and check sum to packet. \n");
-	if (timing)
-		gettimeofday( tp, &tz );
-
-	for( i=8; i<datalen; i++) {	/* skip 8 for time */
+	for (i = 8; i < datalen; i++) {	/* skip 8 for time */
 		*datap++ = i;
 	}
 
 	/* Compute ICMP checksum here */
-	icp->icmp_cksum = in_cksum( (ushort *)icp, cc );
+#if INET6
+	icp->icmp6_cksum = in_cksum((uint16_t*) icp, cc);
+#else
+	icp->icmp_cksum = in_cksum((uint16_t*) icp, cc);
+#endif
 
 	/* cc = sendto(s, msg, len, flags, to, tolen) */
-	ntransmitted=0;
+	ntransmitted = 0;
+
 	while (count < npackets) {
 		count++;
-                /* Send packet through socket created */
-                tst_resm (TINFO, "Sending packet through created socket \n");
-		i = sendto( s, outpack, cc, 0, &whereto, sizeof(struct sockaddr) );
+		/* Send packet through socket created */
+		tst_resm (TINFO, "Sending packet through created socket");
+		i = sendto( s, outpack, cc, 0, (const sa_t*) &whereto, sizeof(whereto) );
 
-		if( i < 0 || i != cc )  {
-			if( i<0 )  perror("sendto");
-			tst_resm (TINFO, "pingpong: wrote %s %d chars, ret=%d\n",hostname,cc,i);
+		if (i < 0 || i != cc)  {
+			if (i < 0)
+				perror("sendto");
+			tst_resm(TINFO, "wrote %s %d chars, ret=%d",
+					hostname, cc, i);
 			fflush(stdout);
-			}
 		}
-		/* sleep(30); */
-		return(count);
+	}
+	/* sleep(30); */
+	return(count);
+
 }
 
-
-
 /*
  *			I N _ C K S U M
  *
  * Checksum routine for Internet Protocol family headers (C Version)
  *
  */
-u_short in_cksum(u_short *addr, int len)
+uint16_t
+in_cksum (uint16_t *addr, int len)
 {
-    register int nleft = len;
-    register u_short *w = addr, tmp;
-    register int sum = 0;
-    register u_short answer = 0;
+	register int nleft = len;
+	register uint16_t *w = addr, tmp;
+	register int sum = 0;
+	register uint16_t answer = 0;
 
-    /*
-     * Our algorithm is simple, using a 32 bit accumulator (sum), we add
-     * sequential 16 bit words to it, and at the end, fold back all the
-     * carry bits from the top 16 bits into the lower 16 bits.
-     */
-    while (nleft > 1)  {
-        sum += *w++;
-        nleft -= 2;
-    }
+	/*
+	 * Our algorithm is simple, using a 32 bit accumulator (sum), we add
+	 * sequential 16 bit words to it, and at the end, fold back all the
+	 * carry bits from the top 16 bits into the lower 16 bits.
+	 */
+	while (nleft > 1)  {
+		sum += *w++;
+		nleft -= 2;
+	}
 
-    /* mop up an odd byte, if necessary */
-    if (nleft == 1) {
-        tmp = *(u_char *)w;
-        sum += (tmp << 8);
-    }
-    /* add back carry outs from top 16 bits to low 16 bits */
-    sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
-    sum += (sum >> 16);         /* add carry */
-    answer = ~sum;              /* truncate to 16 bits */
-    return(answer);
+	/* mop up an odd byte, if necessary */
+	if (nleft == 1) {
+		tmp = *(u_char *)w;
+		sum += (tmp << 8);
+	}
+	/* add back carry outs from top 16 bits to low 16 bits */
+	sum = (sum >> 16) + (sum & 0xffff);	/* add hi 16 to low 16 */
+	sum += (sum >> 16);			/* add carry */
+	answer = ~sum;				/* truncate to 16 bits */
+
+	return answer;
+
 }
 
-
-/*
- * 			T V S U B
- * 
- * Subtract 2 timeval structs:  out = out - in.
- * 
- * Out is assumed to be >= in.
- *tvsub( out, in )
- *register struct timeval *out, *in;
- *{
- *	if( (out->tv_usec -= in->tv_usec) < 0 )   {
- *		out->tv_sec--;
- *		out->tv_usec += 1000000;
- *	}
- *	out->tv_sec -= in->tv_sec;
- *}
- */
-
 /*
  *			F I N I S H      
  *
  * Outputs packet information to confirm transmission and reception.
  */
-void finish(int n)
+void
+finish (int n)
 {
-	tst_resm (TINFO, "%d packets received, \n", nreceived );
+	tst_resm (TINFO, "%d packets received", nreceived);
 	exit(0);
 }
 
@@ -348,41 +355,53 @@
  * Checks contents of packet to verify information did not get destroyed
  */
 
-int ck_packet (buf, cc, from)
-char 	*buf;			/* pointer to start of IP header */
-int	cc;			/* total size of received packet */
-struct sockaddr_in *from; 	/* address of sender */
+/* 
+ * buf	- pointer to start of IP header
+ * cc	- total size of received packet
+ * from - address of sender
+ */
+int
+ck_packet (uint8_t *buf, size_t cc, sai_t *from)
 {
 	u_char 	i;
 	int 	iphdrlen;
-	struct 	ip *ip = (struct ip *) buf;          /* pointer to IP header */
-	register struct	icmp *icp;                   /* ptr to ICMP */
+	struct 	ip *ip = (struct ip *) buf;	/* pointer to IP header */
+	register icmp_t *icp;			/* ptr to ICMP */
   	u_char *datap ;
-	
-	from->sin_addr.s_addr = ntohl(from->sin_addr.s_addr);
 
-	iphdrlen = ip->ip_hl << 2;  /* Convert # 16-bit words to #bytes */
+#if INET6	
+	from->sin6_addr.s6_addr = ntohl(from->sin6_addr.s6_addr);
+#else
+	from->sin_addr.s_addr = ntohl(from->sin_addr.s_addr);
+#endif
+
+	iphdrlen = ip->ip_hl << 2;		/* Convert # 16-bit words to
+						 * number of bytes */
 	cc -= iphdrlen; 
-        icp = (struct icmp *) (buf + iphdrlen);
+	icp = (icmp_t*) (buf + iphdrlen);
 	datap = (u_char *)icp + sizeof(struct timeval) + 8;
-	if (icp->icmp_type != ICMP_ECHOREPLY) {
-		return(0);	 /* Not your packet 'cause not an echo */
+	if (icp->icmp_type != IERP) {
+		return 0;			/* Not your packet because it's
+						 * not an echo */
 	}
 	if (icp->icmp_id != ident) {
-		return(0);			/* Sent to us by someone else */
+		return 0;			/* Sent to us by someone
+						 * else */
 	}	
 
-        /* Verify data in packet */
-        tst_resm (TINFO, "Verify data in packet after returned from sender \n");
-	if ( datalen > 118 ) {
-		datalen=118;
+	/* Verify data in packet */
+	tst_resm (TINFO, "Verify data in packet after returned from sender");
+	if (datalen > 118) {
+		datalen = 118;
 	}
-	tst_resm (TINFO, "Checking Data.\n");
-        for( i=8; i<datalen; i++) {             /* skip 8 for time */
-                if ( i !=  (*datap)) {               
-                        tst_resm (TINFO, "Data cannot be validated. \n");
-                }
-                datap++; 
-        }
-	return(0);
+	tst_resm (TINFO, "Checking Data.");
+	for(i = 8; i < datalen; i++) {		/* skip 8 for time */
+		if (i !=  (*datap)) {		       
+			tst_resm (TINFO, "Data cannot be validated.");
+		}
+		datap++;
+	}
+
+	return 0;
+
 }
diff --git a/testcases/network/ipv6/perf_lan6/pingpong6.c b/testcases/network/tcp_cmds/perf_lan/pingpong6.c
similarity index 100%
rename from testcases/network/ipv6/perf_lan6/pingpong6.c
rename to testcases/network/tcp_cmds/perf_lan/pingpong6.c
diff --git a/testcases/network/tcp_cmds/ping/Makefile b/testcases/network/tcp_cmds/ping/Makefile
index de09a8f..3bfc37a 100644
--- a/testcases/network/tcp_cmds/ping/Makefile
+++ b/testcases/network/tcp_cmds/ping/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/tcp_cmds/ping testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f ping01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= ping01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/ping/ping01 b/testcases/network/tcp_cmds/ping/ping01
index 9148ecb..15888d9 100755
--- a/testcases/network/tcp_cmds/ping/ping01
+++ b/testcases/network/tcp_cmds/ping/ping01
@@ -33,35 +33,24 @@
 #
 #
 #***********************************************************************
-# Uncomment line below for debug output
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-
-TC=ping
-
-RHOST=${RHOST:-`hostname`}
-COUNT=${COUNT:-5}
-SLEEPTIME=${SLEEPTIME:-1}
-PACKETSIZES=${PACKETSIZES:-"8 16 32 64 128 256 512 1024 2048 4064"}
 
 #-----------------------------------------------------------------------
 #
-# FUNCTION:  exists
+# FUNCTION: do_setup
 #
 #-----------------------------------------------------------------------
 
-exists()
+do_setup()
 {
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-               tst_resm TBROK "Test broke: command $cmd not found"
-	       exit 1
-       fi
-   done
+    COUNT=${COUNT:-5}
+    SLEEPTIME=${SLEEPTIME:-1}
+    PACKETSIZES=${PACKETSIZES:-"8 16 32 64 128 256 512 1024 2048 4064"}
+
+    tst_setup
+
+    exists hostname ping
+
+    RHOST=${RHOST:-`hostname`}
 }
 
 
@@ -74,34 +63,14 @@
 
 do_test() 
 {
-   $trace_logic
-   tst_resm TINFO "ping with 8 16 32 64 128 256 512 1024 2048 4064 ICMP packets"
-   for packetsize in $PACKETSIZES
-   do
-          tst_resm TINFO "calling ping with packet size = $packetsize"
-      ping  -R -c $COUNT -s $packetsize $RHOST  2>&1 1>/dev/null
-      [ $? -eq 0 ] || end_testcase "failed: ping -c $COUNT -s $packetsize $RHOST"
-      sleep $SLEEPTIME
-   done
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+    tst_resm TINFO "ping with $PACKETSIZES ICMP packets"
+    for packetsize in $PACKETSIZES; do
+        tst_resm TINFO "calling ping with packet size = $packetsize"
+        if ! ping -R -c $COUNT -s $packetsize $RHOST 2>&1 1>/dev/null; then
+            end_testcase "failed: ping -c $COUNT -s $packetsize $RHOST"
+        fi
+        sleep $SLEEPTIME
+    done
 }
 
 #*******************************************************************************
@@ -109,9 +78,9 @@
 # FUNCTION:  MAIN
 #
 #*******************************************************************************
-export TCID="ping01"
-export TST_TOTAL=1
-export TST_COUNT=1
-exists "ping"
+. net_cmdlib.sh
+
+read_opts $*
+do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/rcp/Makefile b/testcases/network/tcp_cmds/rcp/Makefile
index 6da286b..1da03b6 100644
--- a/testcases/network/tcp_cmds/rcp/Makefile
+++ b/testcases/network/tcp_cmds/rcp/Makefile
@@ -1,10 +1,30 @@
-all:
+#
+#    network/tcp_cmds/rcp testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-generate:
-	../../generate.sh
+top_srcdir		?= ../../../..
 
-install: generate
-	ln -f rcp01 ../../../bin
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -rf datafiles
+INSTALL_TARGETS		:= rcp01
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/rcp/rcp01 b/testcases/network/tcp_cmds/rcp/rcp01
index 8f2931c..943bf1b 100755
--- a/testcases/network/tcp_cmds/rcp/rcp01
+++ b/testcases/network/tcp_cmds/rcp/rcp01
@@ -34,38 +34,6 @@
 #
 #
 #-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TC=rcp
-TCbin=${TCbin:-`pwd`}
-TCtmp=${TCtmp:-$TCbin/$TC$$}
-TCdat=${TCdat:-$TCbin/datafiles}
-LHOST=`hostname`
-RHOST=${RHOST:-$LHOST}
-SLEEPTIME=${SLEEPTIME:-0}
-FILES=${FILES:-"bin.sm bin.med bin.lg bin.jmb"}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-#
-#-----------------------------------------------------------------------
-
-exists()
-{
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
-}
 
 #-----------------------------------------------------------------------
 #
@@ -75,11 +43,24 @@
 
 do_setup()
 {
-   $trace_logic
 
-   exists "rcp rsh awk"
-   rsh -n -l root $RHOST mkdir -p $TCtmp 2>&1 1>/dev/null
-   mkdir -p $TCtmp
+    TCtmp=${TCtmp:-$LTPROOT/testcases/bin/$TC${EXEC_SUFFIX}$$}
+    TCdat=${TCdat:-$LTPROOT/testcases/bin/datafiles}
+    LHOST=`hostname`
+    RHOST=${RHOST:-$LHOST}
+    SLEEPTIME=${SLEEPTIME:-0}
+    FILES=${FILES:-"bin.sm bin.med bin.lg bin.jmb"}
+
+    tst_setup
+
+    exists awk rcp rsh sum
+
+    if ! rsh -n -l root $RHOST mkdir -p $TCtmp 2>&1 1>/dev/null; then
+        end_testcase "Remote mkdir failed"
+    fi
+
+    trap do_cleanup EXIT
+
 }
 
 #-----------------------------------------------------------------------
@@ -90,44 +71,49 @@
 
 do_test()
 {
-   $trace_logic
 
-   for j in $FILES
-   do
-      rcp $TCdat/$j $RHOST:$TCtmp/$j
+    for j in $FILES; do
 
-      SUM1=`sum $TCdat/$j | awk '{print $1}'`
-      SUM2=`rsh -n -l root $RHOST sum $TCtmp/$j | awk '{print $1}'`
-      rsh -n -l root $RHOST "rm -f $TCtmp/$j"
-      sleep $SLEEPTIME
+        if ! rcp $TCdat/$j $RHOST:$TCtmp/$j; then
+            end_testcase "Failed to rcp file."
+        fi
 
-      if [ $SUM1 = $SUM2 ]
-      then
-         tst_resm TINFO "rcp $TCdat/$j $RHOST:$TCtmp/$j successful"
-      else
-         end_testcase "FAILED: wrong sum in transfer to $RHOST"
-      fi
-      sleep $SLEEPTIME
-   done
+        SUM1=`sum $TCdat/$j | awk '{print $1}'`
+        SUM2=`rsh -n -l root $RHOST sum $TCtmp/$j | awk '{print $1}'`
+        rsh -n -l root $RHOST "rm -f $TCtmp/$j"
+        sleep $SLEEPTIME
 
-   for j in $FILES
-   do
-      tst_resm TINFO "remote coping  $RHOST:$TCdat/$j $TCtmp/$j "
-      rcp $RHOST:$TCdat/$j $TCtmp/$j 2>&1 1>/dev/null
+        if [ "$SUM1 = $SUM2" ]; then
+            tst_resm TINFO "rcp $TCdat/$j $RHOST:$TCtmp/$j successful"
+        else
+            end_testcase "FAILED: wrong sum in transfer to $RHOST"
+        fi
 
-      SUM1=`sum $TCtmp/$j | awk '{print $1}'`
-      SUM2=`rsh -n -l root $RHOST sum $TCdat/$j | awk '{print $1}'`
-      rm -f $TCtmp/$j
-      sleep $SLEEPTIME
+        sleep $SLEEPTIME
 
-      if [ $SUM1 = $SUM2 ]
-      then
-         tst_resm TINFO "rcp $RHOST:$TCdat/$j $TCtmp/$j successful"
-      else
-         end_testcase "FAILED: wrong sum in transfer to $LHOST from $RHOST"
-      fi
-      sleep $SLEEPTIME
-   done
+    done
+
+    for j in $FILES; do
+
+        tst_resm TINFO "remote copying $RHOST:$TCdat/$j to $TCtmp/$j"
+        if ! rcp $RHOST:$TCdat/$j $TCtmp/$j 2>&1 1>/dev/null; then
+            tst_resm TFAIL "Failed to rcp file."; continue
+        fi
+
+        SUM1=`sum $TCtmp/$j | awk '{print $1}'`
+        SUM2=`rsh -n -l root $RHOST sum $TCdat/$j | awk '{print $1}'`
+        rm -f $TCtmp/$j
+        sleep $SLEEPTIME
+
+        if [ "$SUM1" = "$SUM2" ]; then
+            tst_resm TINFO "rcp $RHOST:$TCdat/$j $TCtmp/$j successful"
+        else
+            end_testcase "FAILED: wrong sum in transfer to $LHOST from $RHOST"
+        fi
+        sleep $SLEEPTIME
+
+    done
+
 }
 
 #-----------------------------------------------------------------------
@@ -138,30 +124,8 @@
 
 do_cleanup()
 {
-   $trace_logic
-
-   rsh -n -l root $RHOST rmdir $TCtmp
-   rmdir $TCtmp
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-   do_cleanup
-
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+    rsh -n -l root $RHOST rmdir $TCtmp
+    tst_cleanup
 }
 
 #----------------------------------------------------------------------
@@ -172,9 +136,9 @@
 # OUTPUT:   A testcase run log with the results of the execution of this
 #           test.
 #----------------------------------------------------------------------
-export TCID=rcp01
-export TST_TOTAL=1
-export TST_COUNT=1
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/rdist/Makefile b/testcases/network/tcp_cmds/rdist/Makefile
index 5fda3b2..de95489 100644
--- a/testcases/network/tcp_cmds/rdist/Makefile
+++ b/testcases/network/tcp_cmds/rdist/Makefile
@@ -1,10 +1,30 @@
-all:
+#
+#    network/tcp_cmds/rdist testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-generate:
-	../../generate.sh
+top_srcdir		?= ../../../..
 
-install: generate
-	ln -f rdist01 ../../../bin
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-clean:
-	rm -rf datafiles
+INSTALL_TARGETS		:= rdist01
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/rdist/rdist01 b/testcases/network/tcp_cmds/rdist/rdist01
index 624fd12..33e8703 100755
--- a/testcases/network/tcp_cmds/rdist/rdist01
+++ b/testcases/network/tcp_cmds/rdist/rdist01
@@ -35,39 +35,6 @@
 #
 #
 #***********************************************************************
-# Uncomment line below for debug output.
-# trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-RHOST=${RHOST:-`hostname`}
-USER_LIST=${USER_LIST:-'root'}
-TCbin=${TCbin:-`pwd`}
-TCdat=${TCdat:-$TCbin}
-TCtmp=${TCtmp:-$TCbin/rdist$$}
-FILES=${FILES:-'bin.sm bin.med bin.lg bin.jmb file.dir/bin.sm file.dir/bin.med file.dir/bin.jmb'}
-SLEEPTIME=${SLEEPTIME:-10}
-CLEANUP=${CLEANUP:-ON}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-#
-#-----------------------------------------------------------------------
-
-exists()
-{
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
-}
-
 
 #-----------------------------------------------------------------------
 #
@@ -77,41 +44,43 @@
 
 do_setup()
 {
-   $trace_logic
 
-   export TCID=rdist01
-   export TST_TOTAL=1
-   export TST_COUNT=1
+    USER_LIST=${USER_LIST:-'root'}
+    TCdat=${TCdat:-$LTPROOT/testcases/bin/datafiles}
+    TCtmp=${TCtmp:-$LTPROOT/testcases/bin/$TC${EXEC_SUFFIX}$$}
+    FILES=${FILES:-'bin.sm bin.med bin.lg bin.jmb file.dir/bin.sm file.dir/bin.med file.dir/bin.jmb'}
+    SLEEPTIME=${SLEEPTIME:-10}
 
+    tst_setup
 
-   exists "dirname basename rdist"
+    exists awk hostname rdist
 
-   mkdir -p $TCtmp
-   cd $TCtmp
+    RHOST=${RHOST:-`hostname`}
 
-   # start with a clean LHOST
-   for i in $FILES
-   do
-     rm -rf $i
-   done
+    # start with a clean LHOST
+    for i in $FILES; do
+        rm -rf $i
+    done
 
-   for i in $FILES
-   do
-      BASE=`basename $i`
-      DIR=`dirname $i`
-      mkdir -p $DIR
-      cp $TCdat/datafiles/$BASE $DIR
-      [ $? -eq 0 ] || end_testcase "failed to cp $TCdat/datafiles/$BASE to $DIR"
-      chmod 764 $i
-   done
+    for i in $FILES; do
+        BASE=${i##*/}
+        DIR=${%%/*}
+        test -d "$DIR" || mkdir -p "$DIR"
+        if [ $? -ne 0 ] ; then
+            end_testcase "failed to create $DIR"
+        fi
+        if ! cp $TCdat/$BASE $DIR; then
+            end_testcase "failed to copy $TCdat/$BASE to $DIR"
+        fi
+        chmod 764 $i
+    done
 
-   # get the sum of all the files to rdist on the local machine
-   LSUM=0
-   SUM=`sum -s $FILES|awk '{ print $1 }'`
-   for i in $SUM
-   do
-      LSUM=$(( $LSUM + $i ))
-   done
+    # get the sum of all the files to rdist on the local machine
+    LSUM=0
+    SUM=`sum -s $FILES | awk '{ print $1 }'`
+    for i in $SUM; do
+        LSUM=$(( $LSUM + $i ))
+    done
 }
 
 #-----------------------------------------------------------------------
@@ -123,33 +92,29 @@
 
 create_distfile()
 {
-   $trace_logic
+    T_FILES="FILES = ( "
+    for i in $FILES; do
+        if [ "${i%%*/}" = "." ]; then
+            T_FILES="$T_FILES $i"
+        else
+            T_FILES="$T_FILES $DIR"
+        fi
+    done
+    T_FILES="$T_FILES )"
 
-   T_FILES="FILES = ( "
-   for i in $FILES
-   do
-      DIR=`dirname $i`
-      if [ $DIR = "." ]; then
-         T_FILES="$T_FILES $i"
-      else
-         T_FILES="$T_FILES $DIR"
-      fi
-   done
-   T_FILES="$T_FILES )"
-
-   T_HOST="HOSTS = ("
-   for c_ruser in $RUSERS
-   do
-      for c_rhost in $HOSTS
-      do
+    T_HOST="HOSTS = ("
+    for c_ruser in $RUSERS; do
+        for c_rhost in $HOSTS; do
          T_HOST=$T_HOST"$c_ruser@$c_rhost "
-      done
-   done
+        done
+    done
 
-   T_HOST=$T_HOST")"
-   echo "$T_HOST" > $TCtmp/distfile
-   echo "$T_FILES" >> $TCtmp/distfile
-   echo '${FILES} -> ${HOSTS}' >> $TCtmp/distfile
+    T_HOST="$T_HOST)"
+    cat <<EOF > "$TCtmp/distfile"
+$T_HOST
+$T_FILES
+${FILES} -> ${HOSTS}
+EOF
 }
 
 #-----------------------------------------------------------------------
@@ -162,26 +127,22 @@
 
 check_result()
 {
-   $trace_logic
-   cd $TCtmp
-   for c_rhost in $HOSTS
-   do
-      for c_ruser in $RUSERS
-      do
-         TOTAL_SUM=`rsh -n -l $c_ruser $c_rhost \
-            x=0;SUM=\$(sum -s $FILES|awk '{ print \$1 }')
-            for i in \$SUM
-            do
-               x=\$(( \$x + \$i ))
+    cd $TCtmp
+    for c_rhost in $HOSTS; do
+        for c_ruser in $RUSERS; do
+            TOTAL_SUM=`rsh -n -l $c_ruser $c_rhost \
+            x=0; SUM=\$(sum -s $FILES|awk '{ print \$1 }')
+            for i in \$SUM; do
+                x=\$(( \$x + \$i ))
             done
             echo \$x`
-         if [ $TOTAL_SUM = $LSUM ]; then 
-            tst_resm TINFO "Success rdist in $c_ruser@$c_rhost "
-  	    rsh -n -l $c_ruser $c_rhost "rm -rf $FILES $DIRECTORIES"
-         else
-            end_testcase "Wrong sum doing  rdist in $curr_ruser@$curr_rhost"
-         fi
-      done
+            if [ $TOTAL_SUM = $LSUM ]; then 
+                tst_resm TINFO "Success rdist in $c_ruser@$c_rhost "
+                rsh -n -l $c_ruser $c_rhost "rm -rf $FILES $DIRECTORIES"
+            else
+                end_testcase "Wrong sum doing  rdist in $curr_ruser@$curr_rhost"
+            fi
+       done
    done
 }
 
@@ -195,63 +156,21 @@
 
 do_test()
 {
-   $trace_logic
+    HOSTS=""
+    RUSERS=""
 
-   HOSTS=""
-   RUSERS=""
-
-   for cur_host in $RHOST
-   do
-      HOSTS=$HOSTS" $cur_host"
-      for cur_user in $USER_LIST
-      do
-         RUSERS=$RUSERS" $cur_user"
-         create_distfile
-         rdist -f $TCtmp/distfile
-         [ $? -eq 0 ] || end_testcase "error doing rdist -f $TCtmp/distfile"
-         check_result
-         sleep $SLEEPTIME
-      done
-   done
-}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:     do_cleanup
-# PURPOSE:      Called when the testcase is interrupted by the user
-#               or by interrupt_testcase() when time limit expired
-# INPUT:        None.
-# OUTPUT:       None.
-#
-#-----------------------------------------------------------------------
-
-do_cleanup()
-{
-   $trace_logic
-
-   rm -rf $TCtmp
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{
-   $trace_logic
-
-   # Call other cleanup functions
-   [ $CLEANUP = "ON" ] && do_cleanup
-
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+    for cur_host in $RHOST; do
+        HOSTS=$HOSTS" $cur_host"
+        for cur_user in $USER_LIST; do
+            RUSERS=$RUSERS" $cur_user"
+            create_distfile
+            if ! rdist -f $TCtmp/distfile; then
+                end_testcase "error doing rdist -f $TCtmp/distfile"
+            fi
+            check_result
+            sleep $SLEEPTIME
+        done
+    done
 }
 
 #----------------------------------------------------------------------
@@ -262,6 +181,9 @@
 # OUTPUT:   A testcase run log with the results of the execution of this
 #           test.
 #----------------------------------------------------------------------
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/rlogin/Makefile b/testcases/network/tcp_cmds/rlogin/Makefile
index 6f43237..ccc2884 100644
--- a/testcases/network/tcp_cmds/rlogin/Makefile
+++ b/testcases/network/tcp_cmds/rlogin/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/tcp_cmds/rlogin testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f rlogin01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= rlogin01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/rsh/Makefile b/testcases/network/tcp_cmds/rsh/Makefile
index 821318b..b408556 100644
--- a/testcases/network/tcp_cmds/rsh/Makefile
+++ b/testcases/network/tcp_cmds/rsh/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/tcp_cmds/rsh testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f rsh01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= rsh01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/rsh/rsh01 b/testcases/network/tcp_cmds/rsh/rsh01
index 30563ce..e87a6a0 100755
--- a/testcases/network/tcp_cmds/rsh/rsh01
+++ b/testcases/network/tcp_cmds/rsh/rsh01
@@ -33,32 +33,22 @@
 #
 #
 #----------------------------------------------------------------------
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
 
-RHOST=${RHOST:-`hostname`}
-SLEEPTIME=${SLEEPTIME:-0}
-NUMLOOPS=${NUMLOOPS:-25}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-#
-#-----------------------------------------------------------------------
-
-exists()
+do_setup()
 {
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
+
+    FAIL_IMMEDIATELY=${FAIL_IMMEDIATELY:-1}
+    SLEEPTIME=${SLEEPTIME:-0}
+    NUMLOOPS=${NUMLOOPS:-1}
+
+    export TST_TOTAL=$NUMLOOPS
+
+    tst_setup
+
+    exists awk hostname rsh
+
+    RHOST=${RHOST:-`hostname`}
+
 }
 
 #-----------------------------------------------------------------------
@@ -69,40 +59,44 @@
 
 do_test()
 {
-   $trace_logic
 
-   COUNT=1
-   while [ $COUNT -le $NUMLOOPS ]
-   do
-      CHECK=$(rsh -n -l root $RHOST "ls -l /etc/hosts | wc -w")
+    while [ $TST_COUNT -le $NUMLOOPS ]; do
 
-      if [ "$CHECK" -eq 9 ]; then 
-         tst_resm TINFO "rsh Test successful in loop $COUNT"
-      else
-         tst_resm TBROK "FAILED: rsh failed"
-      fi
-      sleep $SLEEPTIME
-      COUNT=$(( $COUNT + 1 ))
-   done
-}
+        PASSED=0
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPADDRTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
+        if OUT=$(rsh -n -l root $RHOST 'ls -l /etc/hosts'); then 
 
-end_testcase()
-{
-   $trace_logic
+            #
+            # Successful output would be something of the form:
+            #
+            # gcooper@orangebox ~ $ ls -l /etc/hosts         
+            # -rw-r--r-- 1 root root 463 Jul  5 09:26 /etc/hosts
+            #
+            echo "$OUT" | \
+                awk 'NF == 9 && $NF == "/etc/hosts" { exit 0 } END { exit 1 }' \
+                >& /dev/null
 
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+            if [ $? -eq 0 ] ; then
+                tst_resm TPASS "rsh to $RHOST test succeeded"
+                PASSED=1
+            fi
+
+        fi
+
+        if [ $PASSED -ne 1 ] ; then
+            tst_resm TFAIL "rsh to $RHOST failed"
+            # If the first rsh failed, the likelihood that the rest will
+            # succeed is low.
+            if [ "$FAIL_IMMEDIATELY" = "1" ] && [ $COUNT -eq 1 ]; then
+                exit 2
+            fi
+        fi
+
+        sleep $SLEEPTIME
+        incr_tst_count
+
+    done
+
 }
 
 #----------------------------------------------------------------------
@@ -113,9 +107,9 @@
 # OUTPUT:   A testcase run log with the results of the execution of this
 #           test.
 #----------------------------------------------------------------------
-export TCID=rsh01
-export TST_TOTAL=1
-export TST_COUNT=1
-exists "rsh wc"
+. net_cmdlib.sh
+
+read_opts $*
+do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/rwho/Makefile b/testcases/network/tcp_cmds/rwho/Makefile
index 06819d9..385bce2 100644
--- a/testcases/network/tcp_cmds/rwho/Makefile
+++ b/testcases/network/tcp_cmds/rwho/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/tcp_cmds/rwho testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f rwho01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= rwho01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/rwho/rwho01 b/testcases/network/tcp_cmds/rwho/rwho01
index 7d6a482..9967967 100755
--- a/testcases/network/tcp_cmds/rwho/rwho01
+++ b/testcases/network/tcp_cmds/rwho/rwho01
@@ -38,44 +38,9 @@
 #
 #==============================================================================
 # error codes:  0 rwho/ruptime successful
-# 	        1 rwho failed no local and remote host in file
-# 	        2 ruptime failed no local and remote host in file
+#             1 rwho failed no local and remote host in file
+#             2 ruptime failed no local and remote host in file
 #==============================================================================
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-LHOST=`hostname | cut -f1 -d.`
-RHOST=${RHOST:-$LHOST}
-TC=rwho
-TCtmp=${TCtmp:-/tmp/$TC}
-CLEANUP=${CLEANUP:-ON}
-
-PID=0
-RHOST_PID=0
-SLEEPTIME=${SLEEPTIME:-20}
-NUMLOOPS=${NUMLOOPS:-25}
-OUTFILE=${OUTFILE:-$TCtmp/rwho.out}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-#
-#-----------------------------------------------------------------------
-
-exists()
-{
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
-}
-
 
 #-----------------------------------------------------------------------
 #
@@ -85,44 +50,49 @@
 
 do_setup()
 {
-   $trace_logic
 
-   export TCID=rwho01
-   export TST_TOTAL=1
-   export TST_COUNT=1
+    TCtmp=${TCtmp:-$LTPROOT/testcases/bin/$TC${EXEC_SUFFIX}$$}
 
-   exists "rwho rsh killall grep awk cut"
+    PID=0
+    RHOST_PID=0
+    SLEEPTIME=${SLEEPTIME:-20}
+    NUMLOOPS=${NUMLOOPS:-25}
+    OUTFILE=${OUTFILE:-$TCtmp/${TC}.out}
 
-   ps -ef | grep rwhod | grep -v grep 
-   if [ $? -ne 0 ]; then
-      tst_resm TINFO "Starting rwhod on $LHOST"
-      /usr/sbin/rwhod  
-      [ $? -eq 0 ] || end_testcase "Unable to start rwhod on $LHOST"
-      PID=1
-      sleep $SLEEPTIME
-   fi
+    tst_setup
 
-   rsh -n -l root $RHOST ps -ef | grep rwhod
-   if [ $? -ne 0 ]; then
-      tst_resm TINFO "Starting rwhod on $RHOST"
-      rsh -n -l root $RHOST /usr/sbin/rwhod
-      if [ $? -ne 0 ]; then
-	  end_testcase "Unable to start rwhod on $RHOST"
-      fi
-      RHOST_PID=$(rsh -n -l root $RHOST ps -ef | grep rwhod | grep -v grep | awk '{print $2 ; exit}')
-      if [ -z "$RHOST_PID" ]; then
-	  RHOST_PID=0
-	  end_testcase "Unable to start rwhod on $RHOST"
-      fi
-      sleep $SLEEPTIME
-   fi
+    exists awk cut hostname killall ps rsh rwho
 
-   RHOSTNAME=`rsh -n -l root $RHOST hostname | cut -f1 -d.`
-   if [ -z "$RHOSTNAME" ]; then
-       end_testcase "Unable to determine RHOSTNAME"
-   fi
+    LHOST=`hostname | cut -f1 -d.`
+    RHOST=${RHOST:-$LHOST}
 
-   mkdir -p $TCtmp
+    trap do_cleanup EXIT
+
+    if ! ps -ef | awk '/rwhod/ && $0 !~ /awk/'; then
+        tst_resm TINFO "Starting rwhod on $LHOST"
+        rwhod || end_testcase "Unable to start rwhod on $LHOST"
+        PID=1
+        sleep $SLEEPTIME
+    fi
+
+    if ! rsh -n -l root $RHOST ps -ef | awk '/rwhod/ && $0 !~ /awk/'; then
+        tst_resm TINFO "Starting rwhod on $RHOST"
+        if ! rsh -n -l root $RHOST /usr/sbin/rwhod; then
+            end_testcase "Unable to start rwhod on $RHOST"
+        fi
+        RHOST_PID=$(rsh -n -l root $RHOST ps -ef | awk '/rwhod/ && $0 !~ /awk/ {print $2 ; exit}')
+        if [ -z "$RHOST_PID" ]; then
+            RHOST_PID=0
+            end_testcase "Unable to start rwhod on $RHOST"
+        fi
+        sleep $SLEEPTIME
+    fi
+
+    RHOSTNAME=`rsh -n -l root $RHOST hostname | cut -f1 -d.`
+    if [ -z "$RHOSTNAME" ]; then
+        end_testcase "Unable to determine RHOSTNAME"
+    fi
+
 }
 
 #-----------------------------------------------------------------------
@@ -133,26 +103,23 @@
 
 do_test()
 {
-   $trace_logic
 
-   COUNT=1
-   while [ $COUNT -le $NUMLOOPS ]
-   do
-      rwho -a > $OUTFILE
-      HOST=`awk '{print $2}' $OUTFILE|grep "$LHOST\>"|cut -f1 -d:|sort -u`
-      [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in rwho outfile"
-      HOST=`awk '{print $2}' $OUTFILE|grep "$RHOSTNAME\>"|cut -f1 -d:|sort -u`
-      [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in rwho outfile"
+    while [ $TST_COUNT -le $NUMLOOPS ]; do
+        rwho -a > $OUTFILE
+        HOST=`awk "\$2 ~ /$LHOST>/" $OUTFILE | cut -f1 -d: | sort -u`
+        [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in rwho outfile"
+        HOST=`awk "\$2 ~ /$RHOSTNAME>/" $OUTFILE | cut -f1 -d: | sort -u`
+        [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in rwho outfile"
 
-      ruptime -a > $OUTFILE
-      HOST=`awk '{print $1}' $OUTFILE|grep "$LHOST\>"|sort -u`
-      [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in ruptime outfile"
-      HOST=`awk '{print $1}' $OUTFILE|grep "$RHOSTNAME\>"|sort -u`
-      [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in ruptime outfile"
+        ruptime -a > $OUTFILE
+        HOST=`awk "\$1 ~ /$LHOST>/" $OUTFILE | sort -u`
+        [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in ruptime outfile"
+        HOST=`awk "\$1 ~ /$RHOSTNAME>/" $OUTFILE | sort -u`
+        [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in ruptime outfile"
 
-      tst_resm TINFO "Test $COUNT of $NUMLOOPS complete"
-      COUNT=$(( $COUNT + 1 ))
-   done
+        tst_resm TINFO "Test $COUNT of $NUMLOOPS complete"
+        incr_tst_count
+    done
 }
 
 #-----------------------------------------------------------------------
@@ -163,38 +130,18 @@
 
 do_cleanup()
 {
- rm -fr $TCtmp
- if [ $PID -ne 0 ]; then
-    tst_resm TINFO "Stopping rwhod on $LHOST"
-    killall rwhod 
- fi
+    if [ $PID -ne 0 ]; then
+        tst_resm TINFO "Stopping rwhod on $LHOST"
+        killall rwhod 
+    fi
 
- if [ $RHOST_PID -ne 0 ]; then
-    tst_resm TINFO "Stopping rwhod on $RHOST"
-    rsh -n -l root $RHOST "killall rwhod"
- fi
-}
- 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
+    if [ $RHOST_PID -ne 0 ]; then
+        tst_resm TINFO "Stopping rwhod on $RHOST"
+        rsh -n -l root $RHOST "killall rwhod"
+    fi
 
-end_testcase()
-{
-   $trace_logic
-   
-   if [ $CLEANUP = "ON" ]; then
-     do_cleanup
-   fi
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+    tst_cleanup
+
 }
 
 #-----------------------------------------------------------------------
@@ -202,6 +149,9 @@
 # FUNCTION:  MAIN
 #
 #-----------------------------------------------------------------------
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/sendfile/Makefile b/testcases/network/tcp_cmds/sendfile/Makefile
index 52b35cd..124ce5d 100644
--- a/testcases/network/tcp_cmds/sendfile/Makefile
+++ b/testcases/network/tcp_cmds/sendfile/Makefile
@@ -1,18 +1,39 @@
-CFLAGS+=    -I../../../../include -Wall -w -O
-LOADLIBES+= -L../../../../lib -lltp
-LDLIBS +=
+#
+#    network/tcp_cmds/sendfile testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+top_srcdir		?= ../../../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
+include $(abs_srcdir)/../Makefile.inc
 
-generate:
-	../../generate.sh
+CPPFLAGS		+= -I$(abs_srcdir)/../include
 
-install: generate
-	ln -f sendfile01 ../../../bin
+INSTALL_TARGETS		:= sendfile01
 
-clean:
-	rm -f $(TARGETS)
-	rm -rf datafiles
+MAKE_TARGETS		+= testsf_c testsf_s testsf_c6 testsf_s6
+
+testsf_c6.o testsf_s6.o: CPPFLAGS += -DINET6
+
+testsf_c6.o testsf_s6.o: %6.o: %.c
+	$(COMPILE.c) $(OUTPUT_OPTION) $<
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/sendfile/sendfile01 b/testcases/network/tcp_cmds/sendfile/sendfile01
index 6d08d56..4e93447 100755
--- a/testcases/network/tcp_cmds/sendfile/sendfile01
+++ b/testcases/network/tcp_cmds/sendfile/sendfile01
@@ -37,26 +37,6 @@
 #
 #
 #***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-this_file=${0##*/}
-
-TC=sendfile01
-RHOST=${RHOST:-`hostname`}
-TCbin=${TCbin:-`pwd`}
-TCsrc=${TCsrc:-$TCbin}
-TCdat=${TCdat:-$TCsrc/datafiles}
-TCtmp=${TCtmp:-$TCsrc/$TC$$}
-CLEANUP=${CLEANUP:-ON}
-EXECUTABLES="testsf_c"
-REMOTE_EXEC="testsf_s"
-LTPROOT=${LTPROOT:-../../../..}
-FILES=${FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"}
-
-IPADDR=$($LTPROOT/tools/gethost $RHOST | grep addresses: | awk '{print $2}')
-
 
 #-----------------------------------------------------------------------
 #
@@ -66,17 +46,23 @@
 #
 #-----------------------------------------------------------------------
 
-exists()
+do_setup()
 {
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
+    TC=sendfile01
+    RHOST=${RHOST:-`hostname`}
+    TCdat=${TCdat:-$LTPROOT/testcases/bin/datafiles}
+    TCtmp=${TCtmp:-$LTPROOT/testcases/bin/$TC${EXEC_SUFFIX}$$}
+    CLIENT="testsf_c${EXEC_SUFFIX}"
+    SERVER="testsf_s${EXEC_SUFFIX}"
+    LTPROOT=${LTPROOT:-../../../..}
+    FILES=${FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"}
+
+    tst_setup
+
+    exists awk diff gethost grep rsh stat
+
+    IPADDR=$(gethost $RHOST | awk '/addresses:/ {print $2}')
+
 }
 
 
@@ -85,38 +71,39 @@
 #
 # FUNCTION DESCRIPTION: Perform the test
 #
-# PARAMETERS:   	None.
+# PARAMETERS:       None.
 #
-# RETURNS:      	None.
+# RETURNS:          None.
 #=============================================================================
 do_test()
 {
-   $trace_logic
-   tst_resm TINFO "$this_file: doing $0."
+    tst_resm TINFO "Doing $0."
   
-   mkdir -p $TCtmp
-   PORT=$$ 
-   rsh -n -l root $IPADDR "$TCsrc/SF_Server $IPADDR $PORT $TCsrc"
-   sleep 10
-   PID=$(rsh -n -l root $IPADDR "ps -ef "|grep $REMOTE_EXEC | grep $PORT | grep -v grep|awk '{print $2}')
-   [ "$PID" ] || end_testcase "Could not start server"
+    mkdir -p $TCtmp
+    PORT=$$ 
+    if ! rsh -l root $IPADDR "$LTPROOT/testcases/bin/SF_Server $IPADDR $PORT $LTPROOT/testcases/bin"; then
+        end_testcase "rsh failed to $IPADDR as root failed"
+    fi
+    sleep 10
+    PID=$(rsh -l root $IPADDR "ps -ef" | awk "\$0 !~ /awk/ && /$SERVER/ && /$PORT/ {print \$1}")
+    [ -n "$PID" ] || end_testcase "Could not start server"
 
-   for clnt_fname in $FILES
-      do
-	 serv_fname=$TCdat/$clnt_fname
-	 SIZE=`ls -l $serv_fname|awk '{print $5}'`
-	 tst_resm TINFO "Starting $EXECUTABLES $IPADDR Client_filename Server_filename Size "
+    for clnt_fname in $FILES; do
+        serv_fname=$TCdat/$clnt_fname
+        SIZE=`stat -c '%s' $serv_fname`
+        tst_resm TINFO "Starting $SERVER $IPADDR Client_filename Server_filename Size "
   
-	 $TCsrc/$EXECUTABLES $IPADDR $PORT $TCtmp/$clnt_fname $serv_fname $SIZE 
-	 RetVal=$?
+        $CLIENT $IPADDR $PORT "$TCtmp/$clnt_fname" $serv_fname $SIZE 
+        RetVal=$?
   
-         [ $RetVal -eq 0 ] || end_testcase "$EXECUTABLES returned error $RetVal"
+        [ $RetVal -eq 0 ] || end_testcase "$CLIENT returned error $RetVal"
 
-	 diff $serv_fname $TCtmp/$clnt_fname
-	 DiffVal=$?
-	 [ $DiffVal -gt 1 ] && end_testcase "ERROR: Cannot compare files"
-	 [ $DiffVal -eq 1 ] && end_testcase "The file copied differs from the original"
-      done
+        diff $serv_fname $TCtmp/$clnt_fname
+        DiffVal=$?
+        [ $DiffVal -gt 1 ] && end_testcase "ERROR: Cannot compare files"
+        [ $DiffVal -eq 1 ] && end_testcase "The file copied differs from the original"
+    done
+
 }
 
 #=============================================================================
@@ -124,51 +111,24 @@
 #
 # FUNCTION DESCRIPTION: Clean up
 #
-# PARAMETERS:   	None.
+# PARAMETERS:       None.
 #
-# RETURNS:      	None.
+# RETURNS:          None.
 #=============================================================================
 
 do_cleanup()
 {
-   $trace_logic
-   PID=$(rsh -n -l root $RHOST "ps -ef|grep \"$REMOTE_EXEC $IPADDR\""| grep $PORT|
-      grep -v grep|grep -v vi|awk '{print $2}')
-   [ "$PID" ] && rsh -n -l root $RHOST kill -9 $PID
-      
-   rm -rf $TCtmp
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-# 
-# FUNCTION DESCRIPTION: Clean up
-# 
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-# 
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
-{  
-   $trace_logic
-   tst_resm TINFO "$this_file: doing $0."
-
-   
-   # Call other cleanup functions
-   [ $CLEANUP = "ON" ] && do_cleanup
-   
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+      PID=$(rsh -n -l root $RHOST "ps -ef" | awk "\$0 !~ /awk/ && /$SERVER/ && /$PORT/ {print \$1}")
+      [ -n "$PID" ] && rsh -n -l root $RHOST kill -9 $PID
+      tst_cleanup
 }
 
 #=============================================================================
 # MAIN PROCEDURE
 #=============================================================================
-export TCID="sendfile01"
-export TST_TOTAL=1
-export TST_COUNT=1
-exists "rsh diff awk grep"
+. net_cmdlib.sh
+
+read_opts $*
+do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/sendfile/testsf_c.c b/testcases/network/tcp_cmds/sendfile/testsf_c.c
index fe1be1a..52b9ecf 100644
--- a/testcases/network/tcp_cmds/sendfile/testsf_c.c
+++ b/testcases/network/tcp_cmds/sendfile/testsf_c.c
@@ -1,10 +1,12 @@
  
 /*
  * Client for the send_file test program
- * Syntax: testsf_c <server IP addr> <client_filename> <filename> <file length> 
+ * Syntax: testsf_c <server IP addr> <port> <client_filename> <server_filename> <file-length>
  */
 
 #include <stdio.h>
+#include <netdb.h>
+#include <sys/types.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/file.h>
@@ -14,98 +16,117 @@
 #include <errno.h>
 #include "test.h"
 #include "usctest.h"
+#include "netdefs.h"
 
-
-#ifndef PATH_MAX
-#define PATH_MAX 4096
-#endif
-
-char *TCID="sendfile";
-int TST_TOTAL=1;
+int TST_TOTAL = 1;
 extern int Tst_count;
 
-int main(argc, argv)
-int argc;
-char *argv[];
+#if INET6
+char *TCID = "sendfile6_client";
+#else
+char *TCID = "sendfile_client";
+#endif
 
+int
+main (int argc, char *argv[])
 {
-  struct sockaddr_in sa;
-  int s, fd;
-  char *lp, *sp;
-  int nbyte;
-  char *clnt_fname;
-  char rbuf[PATH_MAX];
-  int flen, nlen;
-  int port;
+	sai_t sai;
+	int s, fd;
+	int nbyte;
+	char *serv_fname, *clnt_fname;
+	char rbuf[PATH_MAX];
+	int nlen, gai;
+	struct  addrinfo *hp;
+	struct  addrinfo hints;
+	int port;
 
-  /* open socket to server */
-  if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-	tst_resm(TBROK, "socket error = %d\n", errno);
-	exit(1);
-  }
+	if (argc != 6) {
+		tst_resm(TBROK, "usage: server-ip port client-file server-file file-len");
+		tst_exit();
+	}
 
-  clnt_fname = argv[3]; /* filename to create */
-  
-  /* prepare to copy file from server to local machine */
-  if ((fd = open(clnt_fname, O_CREAT | O_TRUNC | O_WRONLY, 0777)) < 0) {
-	tst_resm(TBROK, "file open error = %d\n", errno);
+	int i;
+	for (i = 0;  i < argc; i++)
+		printf("i=%d: %s\n", i, *(argv+i));
+
+	/* open socket to server */
+	if ((s = socket(AFI, SOCK_STREAM, 0)) < 0) {
+		tst_resm(TBROK, "socket error = %d\n", errno);
+		tst_exit();
+	}
+
+	clnt_fname = argv[3]; /* filename to create */
+	serv_fname = argv[4]; /* filename to request */
+
+	/* prepare to copy file from server to local machine */
+	if ((fd = open(clnt_fname, O_CREAT | O_TRUNC | O_WRONLY, 0777)) < 0) {
+		tst_resm(TBROK, "file open error = %d\n", errno);
+		close(s);
+		tst_exit();
+	}
+
+	/* initialize request info: */
+	rbuf[0] = '\0';
+	/* The request will be done in the form: `file-size=requested-file'. */
+	snprintf(rbuf, PATH_MAX, "%s=%s", argv[5], serv_fname);
+
+	memset(&hints, 0, sizeof(hints));
+	hints.ai_family = PFI;
+	if ((gai = getaddrinfo(argv[1], NULL, &hints, &hp)) != 0) {
+		tst_resm(TBROK, "Unknown subject address %s: %s\n",
+				argv[1], gai_strerror(gai));
+	}
+	if (!hp || !hp->ai_addr || hp->ai_addr->sa_family != AFI) {
+		tst_resm(TBROK, "getaddrinfo failed");
+		tst_exit();
+	}
+
+	tst_resm(TINFO, "rbuf => %s\n", rbuf);
+	/* initialize server info to make the connection */
+	memcpy(&sai, hp->ai_addr, hp->ai_addrlen);
+	port = atoi(argv[2]);
+
+#if INET6
+	sai.sin6_port = htons(port);
+#else
+	sai.sin_port = htons(port);
+#endif
+
+	if (connect(s, (sa_t*) &sai, sizeof(sai) ) < 0) {
+		tst_resm(TBROK, "connect error = %d\n", errno);
+		close(s);
+		exit(1);
+	}
+
+	/* send request info to server */
+	if ((nbyte = write(s, rbuf, strlen(rbuf))) <= 0) {
+		tst_resm(TBROK, "socket write  error = %d\n", errno);
+		close(s);
+		exit(1);
+	}
+
+	tst_resm(TINFO, "client write %d bytes to server with contents %s\n",
+			nbyte, rbuf);
+
+	nlen = 0; /* init size of info received */
+	rbuf[0] = '\0';
+	/* read until an EOF is encountered. */
+	while ((nbyte = read(s, rbuf, PATH_MAX)) > 0) { 
+		nlen += nbyte;
+		if (write(fd, rbuf, nbyte) != nbyte) {
+			tst_resm(TBROK, "Error writing to file %s on client\n",
+					clnt_fname);
+			tst_exit();
+		}
+	}
+
+	tst_res(TINFO, "Asking for remote file: %s", serv_fname);
+
+	tst_resm(TINFO, "File %s received\n", argv[4]);
+
 	close(s);
-	exit(1);
-  }
+	close(fd);
 
-  lp = argv[5]; /* get file size */
-  flen = strtol(lp,(char **)NULL,10);
-	
+	return 0;
 
-  /* initialize request info: */
-  rbuf[0] = '\0';
-  sp = &rbuf[0];
-  sp = strcat(sp, argv[5]); /* file size */
-  sp = strcat(sp, "=");
-  sp = strcat(sp, argv[4]); /* requested file */
-
-  tst_resm(TINFO, "sp=%s\n",sp);
-  /* initialize server info to make the connection */
-  sa.sin_family = AF_INET;
-  sa.sin_addr.s_addr = inet_addr(argv[1]);
-  port=atoi(argv[2]);
-  sa.sin_port = htons(port);
-
-  if ( connect(s, (struct sockaddr*) &sa, sizeof(sa) ) < 0 ) {
-        tst_resm(TBROK, "connect error = %d\n", errno);
-	close(s);
-	exit(1);
-  }
- 
-  /* send request info to server */
-  if ((nbyte = write(s, rbuf, strlen(rbuf))) <= 0) {
-        tst_resm(TBROK, "socket write  error = %d\n", errno);
-	close(s);
-	exit(1);
-  }
-
-  tst_resm(TINFO, "client write %d bytes to server with contents %s\n",
-	   nbyte, rbuf);
-
-  nlen = 0; /* init size of info received */
-  rbuf[0] = '\0';
-  while ((nbyte = read(s, rbuf, PATH_MAX)) >0) { /* receive info until EOF */
-    nlen += nbyte;
-    if (write(fd, rbuf, nbyte) != nbyte) {
-      tst_resm(TBROK, "Error writing to file %s on client\n",clnt_fname);
-      exit(1);
-    }
-  }
-
-
-  if (nlen != flen) { /* compare expected size with current size */
-    tst_resm(TBROK, "WRONG!!! nlen = %d, should be %d\n", nlen, flen);
-    exit (1);
-  }
-  else
-    tst_resm(TINFO, "File %s received\n", argv[4]);
-
-  close(s);
-  close(fd);
-  exit(0);
 }
diff --git a/testcases/network/tcp_cmds/sendfile/testsf_s.c b/testcases/network/tcp_cmds/sendfile/testsf_s.c
index c07d5b8..bc77712 100644
--- a/testcases/network/tcp_cmds/sendfile/testsf_s.c
+++ b/testcases/network/tcp_cmds/sendfile/testsf_s.c
@@ -17,160 +17,167 @@
 #include <sys/wait.h>
 #include "test.h"
 #include "usctest.h"
+#include "netdefs.h"
 
-
-#define LISTEN_BACKLOG	10
-
-#ifndef PATH_MAX
-#define PATH_MAX 4096
-#endif
-
-char *TCID="sendfile";
-int TST_TOTAL=1;
+int TST_TOTAL = 1;
 extern int Tst_count;
 
+#if INET6
+char *TCID = "sendfile6_server";
+#else
+char *TCID = "sendfile_server";
+#endif
 
-void 
-test_sig(sig)
-int sig;
+int
+main(int argc, char *argv[])
 {
-  
-  int status;
+	sai_t sa, *ap;
+	sa_t from;
+	struct addrinfo *hp;
+	struct addrinfo hints;
+	int as, fd, gai, rc, s;
+	char *lp;
+	char *number;
+	int pid, nbytes, flen,count;
+	char rbuf[PATH_MAX];
+	int chunks=0;
+	off_t *offset; 
+	char nbuf[PATH_MAX];
+	int port;
 
-  wait(&status);
-
-
-}
-
-
-int main(argc, argv)
-int argc;
-char *argv[];
-
-{
-  struct sockaddr_in sa, *ap;
-  struct sockaddr from;
-  int s, fd, as, rc;
-  char *lp;
-  char *number;
-  int clen, pid;
-  int nbytes, flen,count;
-  char rbuf[PATH_MAX];
-  int chunks=0;
-  off_t *offset; 
-  char nbuf[PATH_MAX];
-  int port;
+	if (argc != 3) {
+		tst_resm(TBROK, "usage: listen-address listen-port");
+		tst_exit();
+	}
  
-  /* open socket */
-  if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-	tst_resm(TBROK, "socket error = %d\n", errno);
-	exit(-1);
-  }
-
-  signal(SIGCHLD, SIG_IGN); /* ignore signals from children */
-
-  /* server IP and port */
-  sa.sin_family = AF_INET;
-  sa.sin_addr.s_addr = inet_addr(argv[1]);
-  port=atoi(argv[2]);
-  sa.sin_port = htons(port);
-
-  /* bind IP and port to socket */
-  if ( bind(s, (struct sockaddr*) &sa, sizeof(sa) ) < 0 ) {
-        tst_resm(TBROK, "bind error = %d\n", errno);
-	close(s);
-	exit(-1); 
-  }
- 
-  /* start to listen socket */
-  if ( listen(s, LISTEN_BACKLOG ) < 0 ) {
-        tst_resm(TBROK, "listen error = %d\n", errno);
-	close(s);
-	exit(-1);
-  }
-
-  /* process connections */
-  while(1) {
-	/* accept a connection from a client */
-  	clen = sizeof(from);
-  	if ((as = accept(s, &from, &clen )) < 0 ) {
-	  tst_resm(TBROK, "accept error = %d\n", errno);
-	  if (errno == EINTR)
-		continue;
-	  close(s);
-	  exit(-1);
-  	}
-
-	ap = (struct sockaddr_in *)&from;
-
-	/* create a process to manage the connection */
-	if ((pid = fork()) < 0) {
-	  tst_resm(TBROK, "fork error = %d\n", errno);
-	  close(as);
-	  exit(-1);
-  	}
-	if (pid > 0) {	/* parent, go back to accept */
-	  close(as);
-	  continue;
+	/* open socket */
+	if ((s = socket(AFI, SOCK_STREAM, 0)) < 0) {
+		tst_resm(TBROK, "socket error = %d\n", errno);
+		tst_exit();
 	}
 
+	signal(SIGCHLD, SIG_IGN); /* ignore signals from children */
 
-
-	/* child process to manage a connection */
-  
-	close(s); /* close service socket */
-
-	/* get client request information */
-	if ((nbytes = read(as, rbuf, PATH_MAX)) <= 0) {
-	  tst_resm(TBROK, "socket read error = %d\n", errno);
-	  close(as);
-	  exit(-1);
-  	}
-	rbuf[nbytes] = '\0'; /* null terminate the info */
-	lp = &rbuf[0];
-
-	/* start with file length, '=' will start the filename */
-	flen = 0;
-	count = 0;
-	number = &nbuf[0];
-	while (*lp != '=') { /* convert ascii to integer */
-	  nbuf[count] = *lp;
-	  count++;
-	  lp++;
+	memset(&hints, 0, sizeof(hints));
+	hints.ai_family = PFI;
+	if ((gai = getaddrinfo(argv[1], NULL, &hints, &hp)) != 0) {
+		tst_resm(TBROK, "getaddrinfo failed");
+		tst_exit();
 	}
-	 nbuf[count] = '\0';
-	 flen = strtol(number, (char **)NULL, 10); 
+	if (!hp || !hp->ai_addr || hp->ai_addr->sa_family != AFI) {
+		tst_resm(TBROK, "getaddrinfo failed");
+		tst_exit();
+	}
 
-	/* the file name */
-	lp++;
+	/* server IP and port */
+	memcpy(&sa, hp->ai_addr, hp->ai_addrlen);
+	port = atoi(argv[2]);
+#if INET6
+	sa.sin6_port = htons(port);
+#else
+	sa.sin_port = htons(port);
+#endif
 
-        tst_resm(TINFO, "The file to send is %s\n", lp);
-  	/* open requested file to send */
-	if ((fd = open(lp, O_RDONLY)) < 0) {
-	  tst_resm(TBROK, "file open error = %d\n", errno);
-	  close(as);
-	  exit(-1);
-  	}
-	offset=NULL;
-	errno=0;
-        do { /* send file parts until EOF */
-           if ((rc = sendfile(as, fd, offset, flen)) != flen) {
-                if ((errno != EWOULDBLOCK) && (errno != EAGAIN)) {
-                        tst_resm(TBROK, "sendfile error = %d, rc = %d\n", errno, rc);
-                        close(as);
-                        close(fd);
-                        exit(-1);
-                }
-          }
-	  chunks++;
-        } while (rc != 0);
-	tst_resm(TINFO, "File %s sent in %d parts\n", lp, chunks);
+	/* bind IP and port to socket */
+	if (bind(s, (sa_t*) &sa, sizeof(sa) ) < 0) {
+		tst_resm(TBROK, "bind error = %d\n", errno);
+		close(s);
+		tst_exit();
+	}
+ 
+	/* start to listen socket */
+	if (listen(s, LISTEN_BACKLOG) < 0) {
+		tst_resm(TBROK, "listen error = %d\n", errno);
+		close(s);
+		tst_exit();
+	}
+
+	socklen_t fromlen;
+
+	/* process connections */
+	while (1) {
+
+		/* accept a connection from a client */
+		if ((as = accept(s, &from, &fromlen)) < 0 ) {
+			tst_resm(TBROK, "accept error = %d\n", errno);
+			if (errno == EINTR)
+				continue;
+			close(s);
+			tst_exit();
+		}
+
+		ap = (sai_t*) &from;
+
+		/* create a process to manage the connection */
+		if ((pid = fork()) < 0) {
+			tst_resm(TBROK, "fork error = %d\n", errno);
+			close(as);
+			tst_exit();
+		}
+		if (pid > 0) {	/* parent, go back to accept */
+			close(as);
+			continue;
+		}
+
+		/* child process to manage a connection */
+	
+		close(s); /* close service socket */
+
+		/* get client request information */
+		if ((nbytes = read(as, rbuf, PATH_MAX)) <= 0) {
+			tst_resm(TBROK, "socket read error = %d\n", errno);
+			close(as);
+			tst_exit();
+		}
+		rbuf[nbytes] = '\0'; /* null terminate the info */
+		lp = &rbuf[0];
+
+		/* start with file length, '=' will start the filename */
+		count = flen = 0;
+		number = &nbuf[0];
+		while (*lp != '=') { /* convert ascii to integer */
+			nbuf[count] = *lp;
+			count++;
+			lp++;
+		}
+		nbuf[count] = '\0';
+		flen = strtol(number, (char **)NULL, 10); 
+
+		/* the file name */
+		lp++;
+
+		tst_resm(TINFO, "The file to send is %s\n", lp);
+		/* open requested file to send */
+		if ((fd = open(lp, O_RDONLY)) < 0) {
+			tst_resm(TBROK, "file open error = %d\n", errno);
+			close(as);
+			tst_exit();
+		}
+		offset = NULL;
+		errno = 0;
+		do { /* send file parts until EOF */
+			if ((rc = sendfile(as, fd, offset, flen)) != flen) {
+				if ((errno != EWOULDBLOCK) && (errno != EAGAIN)) {
+					tst_resm(TBROK, "sendfile error = %d, rc = %d\n", errno, rc);
+					close(as);
+					close(fd);
+					tst_exit();
+				}
+			}
+			chunks++;
+		} while (rc != 0);
+		tst_resm(TINFO, "File %s sent in %d parts\n", lp, chunks);
 
 
-	close(as); /* close connection */
-	close(fd); /* close requested file */
-	return(0);
+		close(as); /* close connection */
+		close(fd); /* close requested file */
 
-  }
-  close(s); /* close parent socket (never reached because of the while(1)) */
+		exit(0);
+
+	}
+
+	close(s); /* close parent socket (never reached because of the while(1)) */
+
+	return 0;
+
 }
diff --git a/testcases/network/tcp_cmds/ssh/Makefile b/testcases/network/tcp_cmds/ssh/Makefile
index 731c9e2..9202eba 100644
--- a/testcases/network/tcp_cmds/ssh/Makefile
+++ b/testcases/network/tcp_cmds/ssh/Makefile
@@ -1,13 +1,31 @@
-all:
+#
+#    network/tcp_cmds/ssh testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f ssh01 ../../../bin
-	ln -f ssh01_s1 ../../../bin
-	ln -f ssh02 ../../../bin
-	ln -f ssh02_s1 ../../../bin
-	ln -f ssh03 ../../../bin
-	ln -f ssh03_s1 ../../../bin
-	ln -f ssh_set_passwd ../../../bin
-	
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= ssh*
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/ssh/ssh01 b/testcases/network/tcp_cmds/ssh/ssh01
index 288abf9..657449a 100755
--- a/testcases/network/tcp_cmds/ssh/ssh01
+++ b/testcases/network/tcp_cmds/ssh/ssh01
@@ -26,36 +26,43 @@
 #    03/03 Jerone Young (jeroney@us.ibm.com)
 #
 
-export RHOST="localhost"
-export TEST_USER="ssh_usr1"
-export TEST_USER_PASSWD="eal"
-export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
-export TEST_USER_HOMEDIR="/home/$TEST_USER"
-
 #-----------------------------------------------------------------------
 # FUNCTION:  do_setup
 #-----------------------------------------------------------------------
 
-do_setup(){
-	
-	#erase user if he may exist , so we can have a clean env
-        rm -rf /home/$TEST_USER
-        userdel $TEST_USER
-        sleep 1
+do_setup()
+{
 
-        useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER 
-        if [ $? != 0 ]
-        then {
-                echo "Could not add test user $TEST_USER to system $RHOST."
-                exit 1
-        }
-        fi
+    export RHOST="localhost"
+    export TEST_USER="ssh_usr1"
+    export TEST_USER_PASSWD="eal"
+    export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
+    export TEST_USER_HOMEDIR="/home/$TEST_USER"
 
-	#create users home diretory (SLES 8 does not do this, even when specified in adduser)
-        USER_UID=`id -u $TEST_USER`
-        USER_GID=`id -g $TEST_USER`
-        mkdir $TEST_USER_HOMEDIR
-        chown -R $USER_UID.$USER_GID $TEST_USER_HOMEDIR
+    #erase user if he may exist , so we can have a clean env
+    TCtmp=/home/$TEST_USER
+
+    tst_setup
+
+    exists expect ssh ssh01_s1 useradd userdel
+
+    userdel $TEST_USER
+    sleep 1
+
+    if ! useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER; then
+        end_testcase "Could not add test user $TEST_USER to system $RHOST."
+    fi
+
+    # create users home diretory (SLES 8 does not do this, even when specified
+    # in adduser)
+    USER_UID=$(id -u $TEST_USER)
+    USER_GID=$(id -g $TEST_USER)
+    if ! mkdir "$TEST_USER_HOMEDIR"; then
+        end_testcase "Failed to create $TEST_USER_HOMEDIR"
+    fi
+    chown -Rf $USER_UID.$USER_GID "$TEST_USER_HOMEDIR"
+
+    trap do_cleanup EXIT
 
 }
 
@@ -64,20 +71,21 @@
 #-----------------------------------------------------------------------
 
 do_cleanup(){
-        rm -rf /home/$TEST_USER
-        userdel $TEST_USER 
+    userdel $TEST_USER
+    tst_cleanup
 }
 
 #-----------------------------------------------------------------------
 # FUNCTION:  MAIN
 #
 # DESCRIPTION: Create Test User
-#              Call upon script to make sure test user cannont log in with invalid password
-#              Cleanup Test User from system
-#              Exit with exit code of script called upon
+#          Call upon script to make sure test user cannont log in with invalid password
+#          Cleanup Test User from system
+#          Exit with exit code of script called upon
 #-----------------------------------------------------------------------
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
-ssh01_s1
-EXIT_CODE=$?
+ssh01_s1 || end_testcase "Testcase failed"
 do_cleanup
-exit $EXIT_CODE
diff --git a/testcases/network/tcp_cmds/ssh/ssh02 b/testcases/network/tcp_cmds/ssh/ssh02
index 4109aad..84c3637 100755
--- a/testcases/network/tcp_cmds/ssh/ssh02
+++ b/testcases/network/tcp_cmds/ssh/ssh02
@@ -26,57 +26,69 @@
 #    03/03 Jerone Young (jeroney@us.ibm.com)
 #
 
-export RHOST="localhost"
-export TEST_USER="ssh_usr2"
-export TEST_USER_PASSWD="now_this_is_a_good_ltp_test_password"
-export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
-export TEST_USER_HOMEDIR="/home/$TEST_USER"
-
 #-----------------------------------------------------------------------
 # FUNCTION:  do_setup
 #-----------------------------------------------------------------------
 
-do_setup(){
-	#erase user if he may exist , so we can have a clean env
-        rm -rf /home/$TEST_USER
-        userdel $TEST_USER 
-        sleep 1
-	
-        useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER 
-        if [ $? != 0 ]
-        then {
-                echo "Could not add test user $TEST_USER to system $RHOST."
-                exit 1
-        }
-        fi
-	
-	#create users home diretory (SLES 8 does not do this, even when specified in adduser)
-        USER_UID=`id -u $TEST_USER`
-        USER_GID=`id -g $TEST_USER`
-        mkdir $TEST_USER_HOMEDIR
-        chown -R $USER_UID.$USER_GID $TEST_USER_HOMEDIR
-	
+do_setup()
+{
+
+    export RHOST="localhost"
+    export TEST_USER="ssh_usr2"
+    export TEST_USER_PASSWD="now_this_is_a_good_ltp_test_password"
+    export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
+    export TEST_USER_HOMEDIR="/home/$TEST_USER"
+
+    # erase user if he/she already exists, so we can have a clean env
+    TCtmp=/home/$TEST_USER
+
+    rm -Rf $TCtmp
+
+    tst_setup
+
+    exists expect ssh ssh02_s1 useradd userdel
+
+    userdel $TEST_USER 
+    sleep 1
+
+    if ! useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER; then
+        end_testcase "Could not add test user $TEST_USER to system $RHOST."
+    fi
+
+    # create users home diretory (SLES 8 does not do this, even when specified
+    # in adduser)
+    USER_UID=$(id -u $TEST_USER)
+    USER_GID=$(id -g $TEST_USER)
+    if ! mkdir "$TEST_USER_HOMEDIR"; then
+        end_testcase "Failed to create $TEST_USER_HOMEDIR"
+    fi
+    chown -R $USER_UID.$USER_GID "$TEST_USER_HOMEDIR"
+
+    trap do_cleanup EXIT
+
 }
 
 #-----------------------------------------------------------------------
 # FUNCTION:  do_cleanup
 #-----------------------------------------------------------------------
 
-do_cleanup(){
-        rm -rf /home/$TEST_USER
-        userdel $TEST_USER
+do_cleanup()
+{
+    userdel $TEST_USER
+    tst_cleanup
 }
 
 #-----------------------------------------------------------------------
 # FUNCTION:  MAIN
 #
 # DESCRIPTION: Create Test User
-#              Call upon script to make sure an invalid user can not have access 
-#              Cleanup Test User from system
-#              Exit with exit code of script called upon
+#          Call upon script to make sure an invalid user can not have access 
+#          Cleanup Test User from system
+#          Exit with exit code of script called upon
 #-----------------------------------------------------------------------
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
-ssh02_s1
-EXIT_CODE=$?
+ssh02_s1 || end_testcase "Testcase failed"
 do_cleanup
-exit $EXIT_CODE
diff --git a/testcases/network/tcp_cmds/ssh/ssh03 b/testcases/network/tcp_cmds/ssh/ssh03
index 7e5c3ae..5c7305e 100755
--- a/testcases/network/tcp_cmds/ssh/ssh03
+++ b/testcases/network/tcp_cmds/ssh/ssh03
@@ -26,35 +26,44 @@
 #    03/03 Jerone Young (jeroney@us.ibm.com)
 #
 
-export RHOST="localhost"
-export TEST_USER="ssh_usr3"
-export TEST_USER_PASSWD="eal"
-export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
-export TEST_USER_HOMEDIR="/home/$TEST_USER"
-
 #-----------------------------------------------------------------------
 # FUNCTION:  do_setup
 #-----------------------------------------------------------------------
 
-do_setup(){
-	#erase user if he may exist , so we can have a clean env
-        rm -rf /home/$TEST_USER
-        userdel $TEST_USER 
-        sleep 1
-	
-        useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER 
-        if [ $? != 0 ]
-        then {
-                echo "Could not add test user $TEST_USER to system $RHOST."
-                exit 1
-        }
-        fi
+do_setup()
+{
+    export RHOST="localhost"
+    export TEST_USER="ssh_usr3"
+    export TEST_USER_PASSWD="eal"
+    export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
+    export TEST_USER_HOMEDIR="/home/$TEST_USER"
 
-	#create users home diretory (SLES 8 does not do this, even when specified in adduser)
-        USER_UID=`id -u $TEST_USER`
-        USER_GID=`id -g $TEST_USER`
-        mkdir $TEST_USER_HOMEDIR
-        chown -R $USER_UID.$USER_GID $TEST_USER_HOMEDIR
+    # erase user if he/she already exists, so we can have a clean env
+    TCtmp=/home/$TEST_USER
+
+    rm -Rf $TCtmp
+
+    tst_setup
+
+    exists expect ssh ssh03_s1 useradd userdel
+
+    userdel $TEST_USER 
+    sleep 1
+
+    if ! useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER; then
+        end_testcase "Could not add test user $TEST_USER to system $RHOST."
+    fi
+
+    # create users home diretory (SLES 8 does not do this, even when specified
+    # in adduser)
+    USER_UID=$(id -u $TEST_USER)
+    USER_GID=$(id -g $TEST_USER)
+    if ! mkdir "$TEST_USER_HOMEDIR"; then
+        end_testcase "Failed to create $TEST_USER_HOMEDIR"
+    fi
+    chown -R $USER_UID.$USER_GID "$TEST_USER_HOMEDIR"
+
+    trap do_cleanup EXIT
 
 }
 
@@ -62,9 +71,10 @@
 # FUNCTION:  do_cleanup
 #-----------------------------------------------------------------------
 
-do_cleanup(){
-        rm -rf /home/$TEST_USER
-        userdel $TEST_USER
+do_cleanup()
+{
+    userdel $TEST_USER
+    tst_cleanup
 }
 
 #-----------------------------------------------------------------------
@@ -75,8 +85,9 @@
 #              Cleanup Test User from system
 #              Exit with exit code of script called upon
 #-----------------------------------------------------------------------
+. net_cmdlib.sh
+
+read_opts $*
 do_setup
-ssh03_s1
-EXIT_CODE=$?
+ssh03_s1 || end_testcase "Testcase failed"
 do_cleanup
-exit $EXIT_CODE
diff --git a/testcases/network/tcp_cmds/ssh/ssh03_s1 b/testcases/network/tcp_cmds/ssh/ssh03_s1
index d9cc5cb..2cb9c0e 100755
--- a/testcases/network/tcp_cmds/ssh/ssh03_s1
+++ b/testcases/network/tcp_cmds/ssh/ssh03_s1
@@ -59,5 +59,4 @@
     sleep 1
 }
 
-
 exit 0 
diff --git a/testcases/network/tcp_cmds/tcpdump/Makefile b/testcases/network/tcp_cmds/tcpdump/Makefile
index b52b476..43213b2 100644
--- a/testcases/network/tcp_cmds/tcpdump/Makefile
+++ b/testcases/network/tcp_cmds/tcpdump/Makefile
@@ -1,7 +1,31 @@
-all:
+#
+#    network/tcp_cmds/tcpdump testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f tcpdump01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= tcpdump01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/tcpdump/tcpdump01 b/testcases/network/tcp_cmds/tcpdump/tcpdump01
index 30d79a2..650e97e 100755
--- a/testcases/network/tcp_cmds/tcpdump/tcpdump01
+++ b/testcases/network/tcp_cmds/tcpdump/tcpdump01
@@ -32,49 +32,6 @@
 #      -Written
 #
 #-----------------------------------------------------------------------
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TC=tcpdump
-TCtmp=${TCtmp:-/tmp/$TC$$}
-RHOST=${RHOST:-`hostname`}
-IP=`host ${RHOST}|awk '{print $4}'`
-IFNUMS=`netstat -i|wc -l`
-IFNUMS=$(( $IFNUMS - 2 ))
-IFNAME=${IFNAME:-$(netstat -i|awk '{print $1}'|tail -n${IFNUMS})}
-for i in ${IFNAME}
-do
-    ifconfig ${i}|grep $IP
-    [ $? = 0 ] && IF=$i && break
-done
-[ -z "${IF}" ] && echo "Test broke: Could not identify interface" && exit 1
-IFNAME=${IF}
-NUMLOOPS=${NUMLOOPS:-20}
-OUTFILE=$TCtmp/tcpdump_out
-LTPROOT=${LTPROOT:-"../../../../"}
-
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  exists
-# PURPOSE:   Check if commands used by this testcase exists.
-#
-#-----------------------------------------------------------------------
-
-exists()
-{
-   for cmd in $1
-   do
-       which $cmd 2>&1 1>/dev/null
-	   if [ $? -ne 0 ]
-	   then
-	       tst_resm TBROK "Test broke: command $cmd not found"
-		   exit 1
-       fi
-   done
-}
-
 
 #******************************************************************************
 #
@@ -84,40 +41,45 @@
 #
 #******************************************************************************
 
-do_test()
+do_setup()
 {
-   $trace_logic
 
-   mkdir -p $TCtmp
-   [ $? -eq 0 ] || end_testcase "mkdir -p $TCtmp failed"
-   ping -f $RHOST > /dev/null 2>&1 &
-   /usr/sbin/tcpdump -i $IFNAME -c $NUMLOOPS > $OUTFILE
-   [ $? -eq 0 ] || end_testcase "Problems trying to launch tcpdump"
-   grep "$RHOST\>" $OUTFILE 
-   [ $? -eq 0 ] || end_testcase "$RHOST was not listed in network traffic"
-   PID=`ps -ef | grep "ping -f $RHOST" | grep -v grep | awk '{print $2}'`
-   kill -9 $PID
-   rm -rf $OUTFILE
+    tst_setup
+
+    exists awk grep host hostname ifconfig netstat ping tail tcpdump
+    RHOST=${RHOST:-`hostname`}
+    IP=`host ${RHOST} 2>/dev/null | awk '{print $4}'`
+    IFNUMS=`netstat -i|wc -l`
+    IFNUMS=$(( $IFNUMS - 2 ))
+    IFNAME=${IFNAME:-$(netstat -i | awk '{print $1}' | tail -n ${IFNUMS})}
+
+    for i in ${IFNAME}; do
+        if ifconfig ${i} | grep $IP; then
+            IF=$i
+            break
+        fi
+    done
+    if [ -z "${IF}" ]; then
+        end_testcase "Could not identify interface"
+        exit 1
+    fi
+    IFNAME=${IF}
+    NUMLOOPS=${NUMLOOPS:-20}
+    OUTFILE=$TCtmp/tcpdump_out
+
 }
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
+do_test()
 {
-   $trace_logic
-   tst_resm TINFO "$this_file: doing $0."
-   rm -rf $TCtmp
-   [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+    ping -f $RHOST > /dev/null 2>&1 &
+    if ! tcpdump -i $IFNAME -c $NUMLOOPS > $OUTFILE; then
+        end_testcase "Problems trying to launch tcpdump"
+    fi
+    if ! grep "$RHOST\>" $OUTFILE; then
+        end_testcase "$RHOST was not listed in network traffic"
+    fi
+    kill -15 %1
+    rm -rf $OUTFILE
 }
 
 #-----------------------------------------------------------------------
@@ -129,10 +91,9 @@
 # OUTPUT:    Logged run results written to testcase run log
 #
 #-----------------------------------------------------------------------
-export TCID="tcpdump01"
-export TST_TOTAL=1
-export TST_COUNT=1
+. net_cmdlib.sh
 
-exists "ping awk tcpdump"
+read_opts $*
+do_setup
 do_test
 end_testcase
diff --git a/testcases/network/tcp_cmds/telnet/Makefile b/testcases/network/tcp_cmds/telnet/Makefile
index 9636a6e..7d5f7c8 100644
--- a/testcases/network/tcp_cmds/telnet/Makefile
+++ b/testcases/network/tcp_cmds/telnet/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    network/tcp_cmds/telnet testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	ln -f telnet01 ../../../bin
+top_srcdir		?= ../../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= telnet01
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/traceroute/Makefile b/testcases/network/traceroute/Makefile
index e572922..eb5aefb 100644
--- a/testcases/network/traceroute/Makefile
+++ b/testcases/network/traceroute/Makefile
@@ -1,6 +1,29 @@
-all:
+#
+#    network/traceroute testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f traceroute_tests.sh ../../bin/traceroute_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= traceroute_tests.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/xinetd/Makefile b/testcases/network/xinetd/Makefile
index 3da5654..c3a8073 100644
--- a/testcases/network/xinetd/Makefile
+++ b/testcases/network/xinetd/Makefile
@@ -1,6 +1,31 @@
-all:
+#
+#    network/xinetd testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-install:
-	@ln -f xinetd_tests.sh ../../bin/xinetd_tests.sh
+top_srcdir		?= ../../..
 
-clean:
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= xinetd_tests.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/Makefile b/testcases/realtime/Makefile
index 60ea13c..1278214 100644
--- a/testcases/realtime/Makefile
+++ b/testcases/realtime/Makefile
@@ -1,15 +1,27 @@
+#
+#    realtime test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := .
-include $(srcdir)/config.mk
+top_srcdir		?= ../..
 
-SUBDIRS = lib func perf stress
-
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
-
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-	@rm .config
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/config.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/realtime/config.mk b/testcases/realtime/config.mk
index 23c390e..76acdb8 100644
--- a/testcases/realtime/config.mk
+++ b/testcases/realtime/config.mk
@@ -1,24 +1,28 @@
+#
+#    Default include definitions for realtime test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
 
-# Check kernel/glibc support for PI and Robust mutexes and cache
-# the result.
-ifeq ($(shell [ -e $(srcdir)/.config ] && echo yes), yes)
-	HAVE_PI_MUTEX := $(shell grep HAVE_PI_MUTEX $(srcdir)/.config | \
-				 awk '{print $$2}')
-	HAVE_ROBUST_MUTEX := $(shell grep HAVE_ROBUST_MUTEX $(srcdir)/.config | \
-				     awk '{print $$2}')
-else
-	HAVE_PI_MUTEX := $(shell sh $(srcdir)/scripts/check_pi.sh)
-	HAVE_ROBUST_MUTEX:= $(shell sh $(srcdir)/scripts/check_robust.sh)
-	dummy := $(shell echo "HAVE_PI_MUTEX $(HAVE_PI_MUTEX)" > $(srcdir)/.config; \
-		echo "HAVE_ROBUST_MUTEX $(HAVE_ROBUST_MUTEX)" >> $(srcdir)/.config)
-endif
-
 # Default stuff common to all testcases
-#
-CPPFLAGS += -I$(srcdir)/include -D_GNU_SOURCE
-CFLAGS   += -Wall
-LDLIBS   += $(srcdir)/lib/librttest.o \
-	    $(srcdir)/lib/libstats.o \
-	    -lpthread -lrt -lm
 
+CPPFLAGS += -I$(abs_top_srcdir)/testcases/realtime/include -D_GNU_SOURCE
+CFLAGS   += -Wall
+LDLIBS   += -lrealtime -lpthread -lrt -lm
diff --git a/testcases/realtime/func/Makefile b/testcases/realtime/func/Makefile
index e30233c..794bc9c 100644
--- a/testcases/realtime/func/Makefile
+++ b/testcases/realtime/func/Makefile
@@ -1,30 +1,27 @@
+#
+#    realtime/func test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../..
 
-SUBDIRS = \
-	async_handler \
-	gtod_latency \
-	hrtimer-prio \
-	matrix_mult \
-	measurement \
-	periodic_cpu_load \
-	pi-tests \
-	pi_perf \
-	prio-preempt \
-	prio-wake \
-	pthread_kill_latency \
-	sched_football \
-	sched_jitter \
-	sched_latency \
-	thread_clock \
-	rt-migrate
-
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
-
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../config.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/realtime/func/async_handler/Makefile b/testcases/realtime/func/async_handler/Makefile
index 0a813ac..faf4fa9 100644
--- a/testcases/realtime/func/async_handler/Makefile
+++ b/testcases/realtime/func/async_handler/Makefile
@@ -1,21 +1,27 @@
+#
+#    realtime/func/async_handler test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS = $(SRCS:%.c=%)
-else
-TARGETS =
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/gtod_latency/Makefile b/testcases/realtime/func/gtod_latency/Makefile
index 4039a6f..bd67ed6 100644
--- a/testcases/realtime/func/gtod_latency/Makefile
+++ b/testcases/realtime/func/gtod_latency/Makefile
@@ -1,17 +1,27 @@
+#
+#    realtime/func/gtod_latency test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-
-TARGETS = $(SRCS:%.c=%)
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/hrtimer-prio/Makefile b/testcases/realtime/func/hrtimer-prio/Makefile
index 4a583f8..0a1872c 100644
--- a/testcases/realtime/func/hrtimer-prio/Makefile
+++ b/testcases/realtime/func/hrtimer-prio/Makefile
@@ -1,20 +1,27 @@
-srcdir := ../..
-include $(srcdir)/config.mk
+#
+#    realtime/func/hrtimer-prio test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS = $(SRCS:%.c=%)
-else
-TARGETS =
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/matrix_mult/Makefile b/testcases/realtime/func/matrix_mult/Makefile
index 4a583f8..c19cad1 100644
--- a/testcases/realtime/func/matrix_mult/Makefile
+++ b/testcases/realtime/func/matrix_mult/Makefile
@@ -1,20 +1,27 @@
-srcdir := ../..
-include $(srcdir)/config.mk
+#
+#    realtime/func/matrix_mult test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
+top_srcdir		?= ../../../..
 
-SRCS    = $(wildcard *.c)
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS = $(SRCS:%.c=%)
-else
-TARGETS =
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/measurement/Makefile b/testcases/realtime/func/measurement/Makefile
index 67aa51e..fdad2c5 100644
--- a/testcases/realtime/func/measurement/Makefile
+++ b/testcases/realtime/func/measurement/Makefile
@@ -1,16 +1,27 @@
+#
+#    realtime/func/measurement test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-TARGETS = $(SRCS:%.c=%)
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/periodic_cpu_load/Makefile b/testcases/realtime/func/periodic_cpu_load/Makefile
index 4039a6f..275eb06 100644
--- a/testcases/realtime/func/periodic_cpu_load/Makefile
+++ b/testcases/realtime/func/periodic_cpu_load/Makefile
@@ -1,17 +1,27 @@
+#
+#    realtime/func/periodic_cpu_load test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-
-TARGETS = $(SRCS:%.c=%)
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/pi-tests/Makefile b/testcases/realtime/func/pi-tests/Makefile
index 1e1de91..45dca4e 100644
--- a/testcases/realtime/func/pi-tests/Makefile
+++ b/testcases/realtime/func/pi-tests/Makefile
@@ -1,25 +1,27 @@
+#
+#    realtime/func/pi-tests test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-ALL_TARGETS = testpi-0 testpi-1 testpi-2 testpi-4 testpi-5 testpi-6 testpi-7 \
-	      sbrk_mutex
-
-TARGETS = testpi-0
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS += testpi-1 testpi-2 testpi-4 testpi-5 testpi-7
-endif
-
-ifeq ($(HAVE_ROBUST_MUTEX), yes)
-TARGETS += testpi-6 sbrk_mutex
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(ALL_TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/pi_perf/Makefile b/testcases/realtime/func/pi_perf/Makefile
index 0a813ac..fbceaba 100644
--- a/testcases/realtime/func/pi_perf/Makefile
+++ b/testcases/realtime/func/pi_perf/Makefile
@@ -1,21 +1,27 @@
+#
+#    realtime/func/pi_perf test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS = $(SRCS:%.c=%)
-else
-TARGETS =
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/prio-preempt/Makefile b/testcases/realtime/func/prio-preempt/Makefile
index 0a813ac..6da3504 100644
--- a/testcases/realtime/func/prio-preempt/Makefile
+++ b/testcases/realtime/func/prio-preempt/Makefile
@@ -1,21 +1,27 @@
+#
+#    realtime/func/prio-preempt test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS = $(SRCS:%.c=%)
-else
-TARGETS =
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/prio-wake/Makefile b/testcases/realtime/func/prio-wake/Makefile
index 0a813ac..256f5fb 100644
--- a/testcases/realtime/func/prio-wake/Makefile
+++ b/testcases/realtime/func/prio-wake/Makefile
@@ -1,21 +1,27 @@
+#
+#    realtime/func/prio-wake test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS = $(SRCS:%.c=%)
-else
-TARGETS =
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/pthread_kill_latency/Makefile b/testcases/realtime/func/pthread_kill_latency/Makefile
index 0a813ac..b07d8de 100644
--- a/testcases/realtime/func/pthread_kill_latency/Makefile
+++ b/testcases/realtime/func/pthread_kill_latency/Makefile
@@ -1,21 +1,27 @@
+#
+#    realtime/func/pthread_kill_latency test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS = $(SRCS:%.c=%)
-else
-TARGETS =
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/rt-migrate/Makefile b/testcases/realtime/func/rt-migrate/Makefile
index 0a813ac..b48f48a 100644
--- a/testcases/realtime/func/rt-migrate/Makefile
+++ b/testcases/realtime/func/rt-migrate/Makefile
@@ -1,21 +1,27 @@
+#
+#    realtime/func/rt-migrate test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS = $(SRCS:%.c=%)
-else
-TARGETS =
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/sched_football/Makefile b/testcases/realtime/func/sched_football/Makefile
index 67aa51e..1b2a480 100644
--- a/testcases/realtime/func/sched_football/Makefile
+++ b/testcases/realtime/func/sched_football/Makefile
@@ -1,16 +1,27 @@
+#
+#    realtime/func/sched_football test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-TARGETS = $(SRCS:%.c=%)
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/sched_jitter/Makefile b/testcases/realtime/func/sched_jitter/Makefile
index 67aa51e..95bc9a9 100644
--- a/testcases/realtime/func/sched_jitter/Makefile
+++ b/testcases/realtime/func/sched_jitter/Makefile
@@ -1,16 +1,27 @@
+#
+#    realtime/func/sched_jitter test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-TARGETS = $(SRCS:%.c=%)
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/sched_latency/Makefile b/testcases/realtime/func/sched_latency/Makefile
index 0a813ac..564d42f 100644
--- a/testcases/realtime/func/sched_latency/Makefile
+++ b/testcases/realtime/func/sched_latency/Makefile
@@ -1,21 +1,27 @@
+#
+#    realtime/func/sched_latency test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-
-ifeq ($(HAVE_PI_MUTEX), yes)
-TARGETS = $(SRCS:%.c=%)
-else
-TARGETS =
-endif
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/func/thread_clock/Makefile b/testcases/realtime/func/thread_clock/Makefile
index 67aa51e..b94b897 100644
--- a/testcases/realtime/func/thread_clock/Makefile
+++ b/testcases/realtime/func/thread_clock/Makefile
@@ -1,16 +1,27 @@
+#
+#    realtime/func/thread_clock test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-TARGETS = $(SRCS:%.c=%)
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/lib/Makefile b/testcases/realtime/lib/Makefile
index 667b419..f064f09 100644
--- a/testcases/realtime/lib/Makefile
+++ b/testcases/realtime/lib/Makefile
@@ -1,14 +1,29 @@
+#
+#    realtime/lib Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../..
 
+include $(top_srcdir)/include/mk/env_pre.mk
 
-SRCS	= $(wildcard *.c)
-TARGETS	= $(SRCS:%.c=%.o)
+LIB			:= librealtime.a
 
-all: $(TARGETS)
-
-install:
-
-clean:
-	rm -f $(TARGETS) *~
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/perf/Makefile b/testcases/realtime/perf/Makefile
index 3418d47..c9310c3 100644
--- a/testcases/realtime/perf/Makefile
+++ b/testcases/realtime/perf/Makefile
@@ -1,14 +1,27 @@
+#
+#    realtime/perf Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-SUBDIRS = latency
-
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
-
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../config.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/realtime/perf/latency/Makefile b/testcases/realtime/perf/latency/Makefile
index 67aa51e..6b1ad58 100644
--- a/testcases/realtime/perf/latency/Makefile
+++ b/testcases/realtime/perf/latency/Makefile
@@ -1,16 +1,27 @@
+#
+#    realtime/latency test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-TARGETS = $(SRCS:%.c=%)
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/realtime/stress/Makefile b/testcases/realtime/stress/Makefile
index e03391f..e57b17b 100644
--- a/testcases/realtime/stress/Makefile
+++ b/testcases/realtime/stress/Makefile
@@ -1,14 +1,27 @@
+#
+#    realtime/stress Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-SUBDIRS = pi-tests
-
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
-
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install; done
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../config.mk
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/realtime/stress/pi-tests/Makefile b/testcases/realtime/stress/pi-tests/Makefile
index 67aa51e..5edc3b4 100644
--- a/testcases/realtime/stress/pi-tests/Makefile
+++ b/testcases/realtime/stress/pi-tests/Makefile
@@ -1,16 +1,27 @@
+#
+#    realtime/stress/pi-tests test suite Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, September 2009
+#
 
-srcdir := ../..
-include $(srcdir)/config.mk
+top_srcdir		?= ../../../..
 
-
-SRCS    = $(wildcard *.c)
-TARGETS = $(SRCS:%.c=%)
-
-all: $(TARGETS)
-
-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i; done
-
-clean:
-	rm -f $(TARGETS) *~
-
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(abs_srcdir)/../../config.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testscripts/default_runtest_set.awk b/testscripts/default_runtest_set.awk
new file mode 100755
index 0000000..38ea912
--- /dev/null
+++ b/testscripts/default_runtest_set.awk
@@ -0,0 +1,44 @@
+#!/usr/bin/awk -f
+#
+#    Script for determining default runtest set from runltp / runltplite.sh.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+# Invoke this awk script like:
+#
+# $0 /path/to/ltp/runltp
+#
+# e.g.
+#
+# $0 /opt/ltp/runltp
+#
+# NOTE: $0 corresponds to the script name.
+#
+
+BEGIN { RS="\n"; FS=" "; }
+# We only care about lines with \/runtest\/ strings in them -- skip the rest.
+/\/runtest\// {
+    split ($0,strs," ")
+    for (str in strs) {
+        if ($str ~ /\${LTPROOT}\/runtest\/([^[:space:]]+)/) {
+            sub (/\${LTPROOT}\/runtest\//, "", $str)
+            print $str
+        }
+    }
+}
diff --git a/testscripts/ltp-missing-install-files.py b/testscripts/ltp-missing-install-files.py
new file mode 100755
index 0000000..612ae5d
--- /dev/null
+++ b/testscripts/ltp-missing-install-files.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+#
+#    Script for determining items missing from LTP install based on the output
+#    log provided by runltp[lite.sh].
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+# Please invoke this script with --help to determine usage.
+#
+
+from optparse import OptionParser
+import os, re, sys
+
+parser = OptionParser(usage='usage: %prog [options] logfile ...')
+
+parser.add_option('-v', '--verbose', action='store_true', default=False,
+                  dest='verbose', help=('print out successful results as '
+                                        'well as failures'))
+
+opts, logfiles = parser.parse_args()
+
+if not len(logfiles):
+    parser.print_help()
+
+for logfile in logfiles:
+    if not os.access(logfile, os.R_OK):
+        sys.exit("%s not readable" % logfile)
+
+todo_res = [
+    re.compile("""initiation_status="pan\(\d+\): execvp of '(?P<app>.+)' \(tag (?P<tag>\w+)\) failed.+errno:2\s+No such file or directory"""),
+    re.compile("(?P<tag>\S+): line \d+: (?P<app>\S+): No such file or directory"),
+    re.compile("(?P<caller>\S+): (?P<app>\s+): No such file or directory"),
+    re.compile("""tag=(?P<tag>\w+) [\w=]+
+cmdline=.+
+contacts=.+
+analysis=.+
+<<<test_output>>>
+(\S+): (?P<app>\w+): command not found
+<<<execution_status>>>
+initiation_status=.+
+.+termination_id=127.+""")
+]
+
+for logfile in logfiles:
+    fd = open(logfile)
+
+    # Case 1:
+
+    # initiation_status="pan(9908): execvp of 'fs_perms_simpletest.sh' (tag fs_perms) failed.  errno:2  No such file or directory"
+
+    # Case 2:
+
+    # /scratch/ltp-install4/testcases/bin/test_controllers.sh: line 109: /scratch/ltp-install4/testcases/bin/run_cpuset_test.sh: No such file or directory
+
+    # Case 3:
+
+    # gcc: /scratch/ltp-install4/testcases/bin/nmfile2.c: No such file or directory
+
+    # Case 4:
+
+    # <<<test_start>>>
+    # tag=iogen01 stime=1248638309
+    # cmdline="export LTPROOT; rwtest -N iogen01 -i 120s -s read,write -Da -Dv -n 2 500b:doio.f1.$$ 1000b:doio.f2.$$"
+    # contacts=""
+    # analysis=exit
+    # <<<test_output>>>
+    # sh: rwtest: command not found
+    # <<<execution_status>>>
+    # initiation_status="ok"
+    # duration=0 termination_type=exited termination_id=127 corefile=no
+
+    missing_ents = []
+
+    try:
+
+        lines = fd.readlines()
+
+        for line in lines:
+
+            for todo_re in todo_res[:-1]:
+
+                m = todo_re.match(line)
+                if m:
+                    missing_ent = " ".join([m.group(1), m.group('app')])
+                    if missing_ent not in missing_ents:
+                        missing_ents.append(missing_ent)
+                    break
+
+        for m in todo_res[2].finditer("".join(lines)):
+            missing_ent = " ".join([m.group('tag'), m.group('app')])
+            if missing_ent not in missing_ents:
+                missing_ents.append(missing_ent)
+
+    finally:
+        fd.close()
+
+    if len(missing_ents):
+        print "\n".join(["%s: %s" % (os.path.basename(logfile), i) for i in ["Tag | App"] + missing_ents])
+    elif opts.verbose:
+        print "%s: CONGRATULATIONS -- no missing files found!" % os.path.basename(logfile)
diff --git a/tools/Makefile b/tools/Makefile
index 3f7d53b..6d1c387 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -1,18 +1,31 @@
-SUBDIRS = apicmds genload netpipe-2.4 netpipe-2.4-ipv6 #top-LTP
+#
+#    tools Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-CFLAGS+= -Wall -I../include
-LOADLIBES+= -L../lib -lltp
+top_srcdir		?= ..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/testcases.mk
 
-all: $(TARGETS)
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+# top-LTP is really broken, apparently, and netpipe needs some fixing and
+# reorganization..
+FILTER_OUT_DIRS		:= netpipe% top-LTP
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-	@set -e; ln -f gethost ../testcases/bin
-
-clean:
-	rm -f $(TARGETS)
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/tools/apicmds/Makefile b/tools/apicmds/Makefile
index 5d9c477..9596efa 100644
--- a/tools/apicmds/Makefile
+++ b/tools/apicmds/Makefile
@@ -1,22 +1,34 @@
-CFLAGS+=	-D_GNU_SOURCE -I../../include
-LOADLIBES+=	-L../../lib -lltp
+#
+#    Makefile for all tst_* API commands.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-CMDLIST=tst_brk tst_brkm tst_res tst_resm tst_exit tst_flush tst_brkloop tst_brkloopm tst_kvercmp
+top_srcdir		?= ../..
 
-all: $(TARGETS)
+include $(top_srcdir)/include/mk/testcases.mk
 
-install:
-	@ln -f $(TARGETS) ../../testcases/bin/tst_brk
-	@ln -f $(TARGETS) ../../testcases/bin/tst_brkm 
-	@ln -f $(TARGETS) ../../testcases/bin/tst_res
-	@ln -f $(TARGETS) ../../testcases/bin/tst_resm
-	@ln -f $(TARGETS) ../../testcases/bin/tst_exit
-	@ln -f $(TARGETS) ../../testcases/bin/tst_flush
-	@ln -f $(TARGETS) ../../testcases/bin/tst_brkloop
-	@ln -f $(TARGETS) ../../testcases/bin/tst_brkloopm
-	@ln -f $(TARGETS) ../../testcases/bin/tst_kvercmp
+CPPFLAGS		+= -D_GNU_SOURCE
 
-clean:
-	rm -f $(TARGETS)
+MAKE_TARGETS		:= $(addprefix tst_,brkloop brkloopm brk brkm exit flush kvercmp res resm)
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+$(MAKE_TARGETS): %: ltpapicmd.o
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
diff --git a/tools/genload/Makefile b/tools/genload/Makefile
index 9b06756..c00e64b 100644
--- a/tools/genload/Makefile
+++ b/tools/genload/Makefile
@@ -1,14 +1,31 @@
-CFLAGS+= -DPACKAGE=\"stress\" -DVERSION=\"0.17pre11\" 
+#
+#    tools/genload Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-LDLIBS+= -lm
+top_srcdir		?= ../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: $(TARGETS)
+CFLAGS			+= -DPACKAGE=\"stress\" -DVERSION=\"0.17pre11\" 
 
-install:
-	@ln -f $(TARGETS) ../../testcases/bin/genload
+LDLIBS			+= -lm
 
-clean:
-	rm -fr $(TARGETS)
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/tools/genload/genload.c b/tools/genload/genload.c
new file mode 100644
index 0000000..0b86760
--- /dev/null
+++ b/tools/genload/genload.c
@@ -0,0 +1,983 @@
+/* A program to put stress on a POSIX system (stress).
+ *
+ * Copyright (C) 2001, 2002 Amos Waterland <awaterl@yahoo.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <ctype.h>
+#include <errno.h>
+#include <libgen.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+/* By default, print all messages of severity info and above.  */
+static int global_debug = 2;
+
+/* By default, just print warning for non-critical errors.  */
+static int global_ignore = 1;
+
+/* By default, retry on non-critical errors every 50ms.  */
+static int global_retry = 50000;
+
+/* By default, use this as backoff coefficient for good fork throughput.  */
+static int global_backoff = 3000;
+
+/* By default, do not timeout.  */
+static int global_timeout = 0;
+
+/* Name of this program */
+static char *global_progname = PACKAGE;
+
+/* By default, do not hang after allocating memory.  */
+static int global_vmhang = 0;
+
+/* Implemention of runtime-selectable severity message printing.  */
+#define dbg if (global_debug >= 3) \
+            fprintf (stdout, "%s: debug: (%d) ", global_progname, __LINE__), \
+            fprintf
+#define out if (global_debug >= 2) \
+            fprintf (stdout, "%s: info: ", global_progname), \
+            fprintf
+#define wrn if (global_debug >= 1) \
+            fprintf (stderr, "%s: warn: (%d) ", global_progname, __LINE__), \
+            fprintf
+#define err if (global_debug >= 0) \
+            fprintf (stderr, "%s: error: (%d) ", global_progname, __LINE__), \
+            fprintf
+
+/* Implementation of check for option argument correctness.  */
+#define assert_arg(A) \
+          if (++i == argc || ((arg = argv[i])[0] == '-' && \
+              !isdigit ((int)arg[1]) )) \
+            { \
+              err (stderr, "missing argument to option '%s'\n", A); \
+              exit (1); \
+            }
+
+/* Prototypes for utility functions.  */
+int usage (int status);
+int version (int status);
+long long atoll_s (const char *nptr);
+long long atoll_b (const char *nptr);
+
+/* Prototypes for the worker functions.  */
+int hogcpu (long long forks);
+int hogio (long long forks);
+int hogvm (long long forks, long long chunks, long long bytes);
+int hoghdd (long long forks, int clean, long long files, long long bytes);
+
+int
+main (int argc, char **argv)
+{
+  int i, pid, children = 0, retval = 0;
+  long starttime, stoptime, runtime;
+
+  /* Variables that indicate which options have been selected.  */
+  int do_dryrun = 0;
+  int do_timeout = 0;
+  int do_cpu = 0;               /* Default to 1 fork. */
+  long long do_cpu_forks = 1;
+  int do_io = 0;                /* Default to 1 fork. */
+  long long do_io_forks = 1;
+  int do_vm = 0;                /* Default to 1 fork, 1 chunk of 256MB.  */
+  long long do_vm_forks = 1;
+  long long do_vm_chunks = 1;
+  long long do_vm_bytes = 256 * 1024 * 1024;
+  int do_hdd = 0;               /* Default to 1 fork, clean, 1 file of 1GB.  */
+  long long do_hdd_forks = 1;
+  int do_hdd_clean = 0;
+  long long do_hdd_files = 1;
+  long long do_hdd_bytes = 1024 * 1024 * 1024;
+
+  /* Record our start time.  */
+  if ((starttime = time (NULL)) == -1)
+    {
+      err (stderr, "failed to acquire current time\n");
+      exit (1);
+    }
+
+  /* SuSv3 does not define any error conditions for this function.  */
+  global_progname = basename (argv[0]);
+
+  /* For portability, parse command line options without getopt_long.  */
+  for (i = 1; i < argc; i++)
+    {
+      char *arg = argv[i];
+
+      if (strcmp (arg, "--help") == 0 || strcmp (arg, "-?") == 0)
+        {
+          usage (0);
+        }
+      else if (strcmp (arg, "--version") == 0)
+        {
+          version (0);
+        }
+      else if (strcmp (arg, "--verbose") == 0 || strcmp (arg, "-v") == 0)
+        {
+          global_debug = 3;
+        }
+      else if (strcmp (arg, "--quiet") == 0 || strcmp (arg, "-q") == 0)
+        {
+          global_debug = 0;
+        }
+      else if (strcmp (arg, "--dry-run") == 0 || strcmp (arg, "-n") == 0)
+        {
+          do_dryrun = 1;
+        }
+      else if (strcmp (arg, "--no-retry") == 0)
+        {
+          global_ignore = 0;
+          dbg (stdout, "turning off ignore of non-critical errors");
+        }
+      else if (strcmp (arg, "--retry-delay") == 0)
+        {
+          assert_arg ("--retry-delay");
+          global_retry = atoll (arg);
+          dbg (stdout, "setting retry delay to %dus\n", global_retry);
+        }
+      else if (strcmp (arg, "--backoff") == 0)
+        {
+          assert_arg ("--backoff");
+          global_backoff = atoll (arg);
+          if (global_backoff < 0)
+            {
+              err (stderr, "invalid backoff factor: %i\n", global_backoff);
+              exit (1);
+            }
+          dbg (stdout, "setting backoff coeffient to %dus\n", global_backoff);
+        }
+      else if (strcmp (arg, "--timeout") == 0 || strcmp (arg, "-t") == 0)
+        {
+          do_timeout = 1;
+          assert_arg ("--timeout");
+          global_timeout = atoll_s (arg);
+          dbg (stdout, "setting timeout to %ds\n", global_timeout);
+        }
+      else if (strcmp (arg, "--cpu") == 0 || strcmp (arg, "-c") == 0)
+        {
+          do_cpu = 1;
+          assert_arg ("--cpu");
+          do_cpu_forks = atoll_b (arg);
+        }
+      else if (strcmp (arg, "--io") == 0 || strcmp (arg, "-i") == 0)
+        {
+          do_io = 1;
+          assert_arg ("--io");
+          do_io_forks = atoll_b (arg);
+        }
+      else if (strcmp (arg, "--vm") == 0 || strcmp (arg, "-m") == 0)
+        {
+          do_vm = 1;
+          assert_arg ("--vm");
+          do_vm_forks = atoll_b (arg);
+        }
+      else if (strcmp (arg, "--vm-chunks") == 0)
+        {
+          assert_arg ("--vm-chunks");
+          do_vm_chunks = atoll_b (arg);
+        }
+      else if (strcmp (arg, "--vm-bytes") == 0)
+        {
+          assert_arg ("--vm-bytes");
+          do_vm_bytes = atoll_b (arg);
+        }
+      else if (strcmp (arg, "--vm-hang") == 0)
+        {
+          global_vmhang = 1;
+        }
+      else if (strcmp (arg, "--hdd") == 0 || strcmp (arg, "-d") == 0)
+        {
+          do_hdd = 1;
+          assert_arg ("--hdd");
+          do_hdd_forks = atoll_b (arg);
+        }
+      else if (strcmp (arg, "--hdd-noclean") == 0)
+        {
+          do_hdd_clean = 2;
+        }
+      else if (strcmp (arg, "--hdd-files") == 0)
+        {
+          assert_arg ("--hdd-files");
+          do_hdd_files = atoll_b (arg);
+        }
+      else if (strcmp (arg, "--hdd-bytes") == 0)
+        {
+          assert_arg ("--hdd-bytes");
+          do_hdd_bytes = atoll_b (arg);
+        }
+      else
+        {
+          err (stderr, "unrecognized option: %s\n", arg);
+          exit (1);
+        }
+    }
+
+  /* Hog CPU option.  */
+  if (do_cpu)
+    {
+      out (stdout, "dispatching %lli hogcpu forks\n", do_cpu_forks);
+
+      switch (pid = fork ())
+        {
+        case 0:                /* child */
+          if (do_dryrun)
+            exit (0);
+          exit (hogcpu (do_cpu_forks));
+        case -1:               /* error */
+          err (stderr, "hogcpu dispatcher fork failed\n");
+          exit (1);
+        default:               /* parent */
+          children++;
+          dbg (stdout, "--> hogcpu dispatcher forked (%i)\n", pid);
+        }
+    }
+
+  /* Hog I/O option.  */
+  if (do_io)
+    {
+      out (stdout, "dispatching %lli hogio forks\n", do_io_forks);
+
+      switch (pid = fork ())
+        {
+        case 0:                /* child */
+          if (do_dryrun)
+            exit (0);
+          exit (hogio (do_io_forks));
+        case -1:               /* error */
+          err (stderr, "hogio dispatcher fork failed\n");
+          exit (1);
+        default:               /* parent */
+          children++;
+          dbg (stdout, "--> hogio dispatcher forked (%i)\n", pid);
+        }
+    }
+
+  /* Hog VM option.  */
+  if (do_vm)
+    {
+      out (stdout,
+           "dispatching %lli hogvm forks, each %lli chunks of %lli bytes\n",
+           do_vm_forks, do_vm_chunks, do_vm_bytes);
+
+      switch (pid = fork ())
+        {
+        case 0:                /* child */
+          if (do_dryrun)
+            exit (0);
+          exit (hogvm (do_vm_forks, do_vm_chunks, do_vm_bytes));
+        case -1:               /* error */
+          err (stderr, "hogvm dispatcher fork failed\n");
+          exit (1);
+        default:               /* parent */
+          children++;
+          dbg (stdout, "--> hogvm dispatcher forked (%i)\n", pid);
+        }
+    }
+
+  /* Hog HDD option.  */
+  if (do_hdd)
+    {
+      out (stdout, "dispatching %lli hoghdd forks, each %lli files of "
+           "%lli bytes\n", do_hdd_forks, do_hdd_files, do_hdd_bytes);
+
+      switch (pid = fork ())
+        {
+        case 0:                /* child */
+          if (do_dryrun)
+            exit (0);
+          exit (hoghdd
+                (do_hdd_forks, do_hdd_clean, do_hdd_files, do_hdd_bytes));
+        case -1:               /* error */
+          err (stderr, "hoghdd dispatcher fork failed\n");
+          exit (1);
+        default:               /* parent */
+          children++;
+          dbg (stdout, "--> hoghdd dispatcher forked (%i)\n", pid);
+        }
+    }
+
+  /* We have no work to do, so bail out.  */
+  if (children == 0)
+    usage (0);
+
+  /* Wait for our children to exit.  */
+  while (children)
+    {
+      int status, ret;
+
+      if ((pid = wait (&status)) > 0)
+        {
+          if ((WIFEXITED (status)) != 0)
+            {
+              if ((ret = WEXITSTATUS (status)) != 0)
+                {
+                  err (stderr, "dispatcher %i returned error %i\n", pid, ret);
+                  retval += ret;
+                }
+              else
+                {
+                  dbg (stdout, "<-- dispatcher return (%i)\n", pid);
+                }
+            }
+          else
+            {
+              err (stderr, "dispatcher did not exit normally\n");
+              ++retval;
+            }
+
+          --children;
+        }
+      else
+        {
+          dbg (stdout, "wait() returned error: %s\n", strerror (errno));
+          err (stderr, "detected missing dispatcher children\n");
+          ++retval;
+          break;
+        }
+    }
+
+  /* Record our stop time.  */
+  if ((stoptime = time (NULL)) == -1)
+    {
+      err (stderr, "failed to acquire current time\n");
+      exit (1);
+    }
+
+  /* Calculate our runtime.  */
+  runtime = stoptime - starttime;
+
+  /* Print final status message.  */
+  if (retval)
+    {
+      err (stderr, "failed run completed in %lis\n", runtime);
+    }
+  else
+    {
+      out (stdout, "successful run completed in %lis\n", runtime);
+    }
+
+  exit (retval);
+}
+
+int
+usage (int status)
+{
+  char *mesg =
+    "`%s' imposes certain types of compute stress on your system\n\n"
+    "Usage: %s [OPTION [ARG]] ...\n\n"
+    " -?, --help            show this help statement\n"
+    "     --version         show version statement\n"
+    " -v, --verbose         be verbose\n"
+    " -q, --quiet           be quiet\n"
+    " -n, --dry-run         show what would have been done\n"
+    "     --no-retry        exit rather than retry non-critical errors\n"
+    "     --retry-delay n   wait n us before continuing past error\n"
+    " -t, --timeout n       timeout after n seconds\n"
+    "     --backoff n       wait for factor of n us before starting work\n"
+    " -c, --cpu n           spawn n procs spinning on sqrt()\n"
+    " -i, --io n            spawn n procs spinning on sync()\n"
+    " -m, --vm n            spawn n procs spinning on malloc()\n"
+    "     --vm-chunks c     malloc c chunks (default is 1)\n"
+    "     --vm-bytes b      malloc chunks of b bytes (default is 256MB)\n"
+    "     --vm-hang         hang in a sleep loop after memory allocated\n"
+    " -d, --hdd n           spawn n procs spinning on write()\n"
+    "     --hdd-noclean     do not unlink file to which random data written\n"
+    "     --hdd-files f     write to f files (default is 1)\n"
+    "     --hdd-bytes b     write b bytes (default is 1GB)\n\n"
+    "Infinity is denoted with 0.  For -m, -d: n=0 means infinite redo,\n"
+    "n<0 means redo abs(n) times. Valid suffixes are m,h,d,y for time;\n"
+    "k,m,g for size.\n\n";
+
+  fprintf (stdout, mesg, global_progname, global_progname);
+
+  if (status <= 0)
+    exit (-1 * status);
+
+  return 0;
+}
+
+int
+version (int status)
+{
+  char *mesg = "%s %s\n";
+
+  fprintf (stdout, mesg, global_progname, VERSION);
+
+  if (status <= 0)
+    exit (-1 * status);
+
+  return 0;
+}
+
+/* Convert a string representation of a number with an optional size suffix
+ * to a long long.
+ */
+long long
+atoll_b (const char *nptr)
+{
+  int pos;
+  char suffix;
+  long long factor = 1;
+
+  if ((pos = strlen (nptr) - 1) < 0)
+    {
+      err (stderr, "invalid string\n");
+      exit (1);
+    }
+
+  switch (suffix = nptr[pos])
+    {
+    case 'k':
+    case 'K':
+      factor = 1024;
+      break;
+    case 'm':
+    case 'M':
+      factor = 1024 * 1024;
+      break;
+    case 'g':
+    case 'G':
+      factor = 1024 * 1024 * 1024;
+      break;
+    default:
+      if (suffix < '0' || suffix > '9')
+        {
+          err (stderr, "unrecognized suffix: %c\n", suffix);
+          exit (1);
+        }
+    }
+
+  factor = atoll (nptr) * factor;
+
+  return factor;
+}
+
+/* Convert a string representation of a number with an optional time suffix
+ * to a long long.
+ */
+long long
+atoll_s (const char *nptr)
+{
+  int pos;
+  char suffix;
+  long long factor = 1;
+
+  if ((pos = strlen (nptr) - 1) < 0)
+    {
+      err (stderr, "invalid string\n");
+      exit (1);
+    }
+
+  switch (suffix = nptr[pos])
+    {
+    case 's':
+    case 'S':
+      factor = 1;
+      break;
+    case 'm':
+    case 'M':
+      factor = 60;
+      break;
+    case 'h':
+    case 'H':
+      factor = 60 * 60;
+      break;
+    case 'd':
+    case 'D':
+      factor = 60 * 60 * 24;
+      break;
+    case 'y':
+    case 'Y':
+      factor = 60 * 60 * 24 * 360;
+      break;
+    default:
+      if (suffix < '0' || suffix > '9')
+        {
+          err (stderr, "unrecognized suffix: %c\n", suffix);
+          exit (1);
+        }
+    }
+
+  factor = atoll (nptr) * factor;
+
+  return factor;
+}
+
+int
+hogcpu (long long forks)
+{
+  long long i;
+  double d;
+  int pid, retval = 0;
+
+  /* Make local copies of global variables.  */
+  int ignore = global_ignore;
+  int retry = global_retry;
+  int timeout = global_timeout;
+  long backoff = global_backoff * forks;
+
+  dbg (stdout, "using backoff sleep of %lius for hogcpu\n", backoff);
+
+  for (i = 0; forks == 0 || i < forks; i++)
+    {
+      switch (pid = fork ())
+        {
+        case 0:                /* child */
+          alarm (timeout);
+
+          /* Use a backoff sleep to ensure we get good fork throughput.  */
+          usleep (backoff);
+
+          while (1)
+            d = sqrt (rand ());
+
+          /* This case never falls through; alarm signal can cause exit.  */
+        case -1:               /* error */
+          if (ignore)
+            {
+              ++retval;
+              wrn (stderr, "hogcpu worker fork failed, continuing\n");
+              usleep (retry);
+              continue;
+            }
+
+          err (stderr, "hogcpu worker fork failed\n");
+          return 1;
+        default:               /* parent */
+          dbg (stdout, "--> hogcpu worker forked (%i)\n", pid);
+        }
+    }
+
+  /* Wait for our children to exit.  */
+  while (i)
+    {
+      int status, ret;
+
+      if ((pid = wait (&status)) > 0)
+        {
+          if ((WIFEXITED (status)) != 0)
+            {
+              if ((ret = WEXITSTATUS (status)) != 0)
+                {
+                  err (stderr, "hogcpu worker %i exited %i\n", pid, ret);
+                  retval += ret;
+                }
+              else
+                {
+                  dbg (stdout, "<-- hogcpu worker exited (%i)\n", pid);
+                }
+            }
+          else
+            {
+              dbg (stdout, "<-- hogcpu worker signalled (%i)\n", pid);
+            }
+
+          --i;
+        }
+      else
+        {
+          dbg (stdout, "wait() returned error: %s\n", strerror (errno));
+          err (stderr, "detected missing hogcpu worker children\n");
+          ++retval;
+          break;
+        }
+    }
+
+  return retval;
+}
+
+int
+hogio (long long forks)
+{
+  long long i;
+  int pid, retval = 0;
+
+  /* Make local copies of global variables.  */
+  int ignore = global_ignore;
+  int retry = global_retry;
+  int timeout = global_timeout;
+  long backoff = global_backoff * forks;
+
+  dbg (stdout, "using backoff sleep of %lius for hogio\n", backoff);
+
+  for (i = 0; forks == 0 || i < forks; i++)
+    {
+      switch (pid = fork ())
+        {
+        case 0:                /* child */
+          alarm (timeout);
+
+          /* Use a backoff sleep to ensure we get good fork throughput.  */
+          usleep (backoff);
+
+          while (1)
+            sync ();
+
+          /* This case never falls through; alarm signal can cause exit.  */
+        case -1:               /* error */
+          if (ignore)
+            {
+              ++retval;
+              wrn (stderr, "hogio worker fork failed, continuing\n");
+              usleep (retry);
+              continue;
+            }
+
+          err (stderr, "hogio worker fork failed\n");
+          return 1;
+        default:               /* parent */
+          dbg (stdout, "--> hogio worker forked (%i)\n", pid);
+        }
+    }
+
+  /* Wait for our children to exit.  */
+  while (i)
+    {
+      int status, ret;
+
+      if ((pid = wait (&status)) > 0)
+        {
+          if ((WIFEXITED (status)) != 0)
+            {
+              if ((ret = WEXITSTATUS (status)) != 0)
+                {
+                  err (stderr, "hogio worker %i exited %i\n", pid, ret);
+                  retval += ret;
+                }
+              else
+                {
+                  dbg (stdout, "<-- hogio worker exited (%i)\n", pid);
+                }
+            }
+          else
+            {
+              dbg (stdout, "<-- hogio worker signalled (%i)\n", pid);
+            }
+
+          --i;
+        }
+      else
+        {
+          dbg (stdout, "wait() returned error: %s\n", strerror (errno));
+          err (stderr, "detected missing hogio worker children\n");
+          ++retval;
+          break;
+        }
+    }
+
+  return retval;
+}
+
+int
+hogvm (long long forks, long long chunks, long long bytes)
+{
+  long long i, j, k;
+  int pid, retval = 0;
+  char **ptr;
+
+  /* Make local copies of global variables.  */
+  int ignore = global_ignore;
+  int retry = global_retry;
+  int timeout = global_timeout;
+  long backoff = global_backoff * forks;
+
+  dbg (stdout, "using backoff sleep of %lius for hogvm\n", backoff);
+
+  if (bytes == 0)
+    {
+      /* 512MB is guess at the largest value can than be malloced at once.  */
+      bytes = 512 * 1024 * 1024;
+    }
+
+  for (i = 0; forks == 0 || i < forks; i++)
+    {
+      switch (pid = fork ())
+        {
+        case 0:                /* child */
+          alarm (timeout);
+
+          /* Use a backoff sleep to ensure we get good fork throughput.  */
+          usleep (backoff);
+
+          while (1)
+            {
+              ptr = (char **) malloc ( chunks * 2);
+              for (j = 0; chunks == 0 || j < chunks; j++)
+                {
+                  if ((ptr[j] = (char *) malloc (bytes * sizeof (char))))
+                    {
+                      for (k = 0; k < bytes; k++)
+                        ptr[j][k] = 'Z';   /* Ensure that COW happens.  */
+                      dbg (stdout, "hogvm worker malloced %lli bytes\n", k);
+                    }
+                  else if (ignore)
+                    {
+                      ++retval;
+                      wrn (stderr, "hogvm malloc failed, continuing\n");
+                      usleep (retry);
+                      continue;
+                    }
+                  else
+                    {
+                      ++retval;
+                      err (stderr, "hogvm malloc failed\n");
+                      break;
+                    }
+                }
+              if (global_vmhang && retval == 0)
+                {
+                  dbg (stdout, "sleeping forever with allocated memory\n");
+                  while (1)
+                    sleep (1024);
+                }
+              if (retval == 0)
+                {
+                  dbg (stdout,
+                       "hogvm worker freeing memory and starting over\n");
+                  for (j = 0; chunks == 0 || j < chunks; j++) {
+                      free (ptr[j]);
+                  }
+                  free(ptr);
+                  continue;
+                }
+
+              exit (retval);
+            }
+
+          /* This case never falls through; alarm signal can cause exit.  */
+        case -1:               /* error */
+          if (ignore)
+            {
+              ++retval;
+              wrn (stderr, "hogvm worker fork failed, continuing\n");
+              usleep (retry);
+              continue;
+            }
+
+          err (stderr, "hogvm worker fork failed\n");
+          return 1;
+        default:               /* parent */
+          dbg (stdout, "--> hogvm worker forked (%i)\n", pid);
+        }
+    }
+
+  /* Wait for our children to exit.  */
+  while (i)
+    {
+      int status, ret;
+
+      if ((pid = wait (&status)) > 0)
+        {
+          if ((WIFEXITED (status)) != 0)
+            {
+              if ((ret = WEXITSTATUS (status)) != 0)
+                {
+                  err (stderr, "hogvm worker %i exited %i\n", pid, ret);
+                  retval += ret;
+                }
+              else
+                {
+                  dbg (stdout, "<-- hogvm worker exited (%i)\n", pid);
+                }
+            }
+          else
+            {
+              dbg (stdout, "<-- hogvm worker signalled (%i)\n", pid);
+            }
+
+          --i;
+        }
+      else
+        {
+          dbg (stdout, "wait() returned error: %s\n", strerror (errno));
+          err (stderr, "detected missing hogvm worker children\n");
+          ++retval;
+          break;
+        }
+    }
+
+  return retval;
+}
+
+int
+hoghdd (long long forks, int clean, long long files, long long bytes)
+{
+  long long i, j;
+  int fd, pid, retval = 0;
+  int chunk = (1024 * 1024) - 1;        /* Minimize slow writing.  */
+  char buff[chunk];
+
+  /* Make local copies of global variables.  */
+  int ignore = global_ignore;
+  int retry = global_retry;
+  int timeout = global_timeout;
+  long backoff = global_backoff * forks;
+
+  /* Initialize buffer with some random ASCII data.  */
+  dbg (stdout, "seeding buffer with random data\n");
+  for (i = 0; i < chunk - 1; i++)
+    {
+      j = rand ();
+      j = (j < 0) ? -j : j;
+      j %= 95;
+      j += 32;
+      buff[i] = j;
+    }
+  buff[i] = '\n';
+
+  dbg (stdout, "using backoff sleep of %lius for hoghdd\n", backoff);
+
+  for (i = 0; forks == 0 || i < forks; i++)
+    {
+      switch (pid = fork ())
+        {
+        case 0:                /* child */
+          alarm (timeout);
+
+          /* Use a backoff sleep to ensure we get good fork throughput.  */
+          usleep (backoff);
+
+          while (1)
+            {
+              for (i = 0; i < files; i++)
+                {
+                  char name[] = "./stress.XXXXXX";
+
+                  if ((fd = mkstemp (name)) < 0)
+                    {
+                      perror ("mkstemp");
+                      err (stderr, "mkstemp failed\n");
+                      exit (1);
+                    }
+
+                  if (clean == 0)
+                    {
+                      dbg (stdout, "unlinking %s\n", name);
+                      if (unlink (name))
+                        {
+                          err (stderr, "unlink failed\n");
+                          exit (1);
+                        }
+                    }
+
+                  dbg (stdout, "fast writing to %s\n", name);
+                  for (j = 0; bytes == 0 || j + chunk < bytes; j += chunk)
+                    {
+                      if (write (fd, buff, chunk) != chunk)
+                        {
+                          err (stderr, "write failed\n");
+                          exit (1);
+                        }
+                    }
+
+                  dbg (stdout, "slow writing to %s\n", name);
+                  for (; bytes == 0 || j < bytes - 1; j++)
+                    {
+                      if (write (fd, "Z", 1) != 1)
+                        {
+                          err (stderr, "write failed\n");
+                          exit (1);
+                        }
+                    }
+                  if (write (fd, "\n", 1) != 1)
+                    {
+                      err (stderr, "write failed\n");
+                      exit (1);
+                    }
+                  ++j;
+
+                  dbg (stdout, "closing %s after writing %lli bytes\n", name,
+                       j);
+                  close (fd);
+
+                  if (clean == 1)
+                    {
+                      if (unlink (name))
+                        {
+                          err (stderr, "unlink failed\n");
+                          exit (1);
+                        }
+                    }
+                }
+              if (retval == 0)
+                {
+                  dbg (stdout, "hoghdd worker starting over\n");
+                  continue;
+                }
+
+              exit (retval);
+            }
+
+          /* This case never falls through; alarm signal can cause exit.  */
+        case -1:               /* error */
+          if (ignore)
+            {
+              ++retval;
+              wrn (stderr, "hoghdd worker fork failed, continuing\n");
+              usleep (retry);
+              continue;
+            }
+
+          err (stderr, "hoghdd worker fork failed\n");
+          return 1;
+        default:               /* parent */
+          dbg (stdout, "--> hoghdd worker forked (%i)\n", pid);
+        }
+    }
+
+  /* Wait for our children to exit.  */
+  while (i)
+    {
+      int status, ret;
+
+      if ((pid = wait (&status)) > 0)
+        {
+          if ((WIFEXITED (status)) != 0)
+            {
+              if ((ret = WEXITSTATUS (status)) != 0)
+                {
+                  err (stderr, "hoghdd worker %i exited %i\n", pid, ret);
+                  retval += ret;
+                }
+              else
+                {
+                  dbg (stdout, "<-- hoghdd worker exited (%i)\n", pid);
+                }
+            }
+          else
+            {
+              dbg (stdout, "<-- hoghdd worker signalled (%i)\n", pid);
+            }
+
+          --i;
+        }
+      else
+        {
+          dbg (stdout, "wait() returned error: %s\n", strerror (errno));
+          err (stderr, "detected missing hoghdd worker children\n");
+          ++retval;
+          break;
+        }
+    }
+
+  return retval;
+}
diff --git a/tools/make-file.sh b/tools/make-file.sh
index 1fa5dd9..1f1f9d0 100755
--- a/tools/make-file.sh
+++ b/tools/make-file.sh
@@ -29,17 +29,15 @@
 size=$2
 
 if [ -z "$1" ] || [ -z "$2" ] ; then
-	echo "Usage: make-file.sh <file> <size in bytes>"
+	echo "usage: ${0##*/} <file> <size in bytes>"
 	exit 1
 fi
 
-if [ -e $file ] ; then
-	exit 0
-fi
+[ -e "$file" ] && exit 0
 
-if ! perl -e "print 'A' x $size" > $file 2> /dev/null ; then
-	if ! awk 'BEGIN { cnt='$size'; while (cnt--) printf "A" }' > $file 2> /dev/null ; then
-		( while ((size--)) ; do echo -n A ; done ) > $file
+if ! perl -e "print 'A' x $size" > "$file" 2> /dev/null ; then
+	if ! awk 'BEGIN { cnt='$size'; while (cnt--) printf "A" }' > "$file" 2> /dev/null ; then
+		( while ((size--)) ; do echo -n A ; done ) > "$file"
 	fi
 fi
 
diff --git a/utils/Makefile b/utils/Makefile
index 89d0c93..0898bb0 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -18,15 +18,10 @@
 ####
 ################################################################################
 
-SUBDIRS := benchmark
+top_srcdir		?= ..
 
-configure:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done;
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: configure
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done;
+RECURSIVE_TARGETS	:= all configure install
 
-install:
-
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done;
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/utils/benchmark/Makefile b/utils/benchmark/Makefile
index 74b253a..dd388f6 100644
--- a/utils/benchmark/Makefile
+++ b/utils/benchmark/Makefile
@@ -18,15 +18,13 @@
 ####
 ################################################################################
 
-SUBDIRS := ebizzy-0.3 kernbench-0.42
+top_srcdir		?= ../..
 
-configure:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done;
+include $(top_srcdir)/include/mk/env_pre.mk
 
-all: configure
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done;
+# XXX (garrcoop): kernbench needs fixing for out-of-build-tree support.
+FILTER_OUT_DIRS		:= $(if $(OUT_OF_BUILD_TREE),kernbench%)
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done;
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done;
+RECURSIVE_TARGETS	:= all configure install
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/utils/benchmark/ebizzy-0.3/Makefile b/utils/benchmark/ebizzy-0.3/Makefile
index b78542f..7485f7d 100644
--- a/utils/benchmark/ebizzy-0.3/Makefile
+++ b/utils/benchmark/ebizzy-0.3/Makefile
@@ -1,10 +1,34 @@
-all: ebizzy
+#
+#    utils/benchmarks/ebizzy Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
 
-configure:
-	./configure
-ebizzy: configure
-	gcc -Wall -Wshadow -lpthread  -o ebizzy ebizzy.c
-install:
-	
-clean:
-	rm -f ebizzy *~
+# IMPORT NOTE: Be careful when upgrading this component as running the
+# `configure' bourne shell script will overwrite this file!
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+WCPPFLAGS		+= -Wshadow
+
+LDLIBS			+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk