All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize autoconf logic
@ 2009-07-07  0:22 Garrett Cooper
  2009-07-08 23:53 ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Garrett Cooper @ 2009-07-07  0:22 UTC (permalink / raw)
  To: LTP list

[-- Attachment #1: Type: text/plain, Size: 957 bytes --]

Summary of changes:

1. Better modularize and separate out the top-level Makefile such that
automake logic and top-level targets are better partitioned out, and
thus the overall logic and flow is more intuitive.
2. Move help output to README.mk-user.
3. Make $(.DEFAULT_GOAL) vary depending on whether or not the system
has been configured, such that typing in make will no longer run all
and result in Make errors, but instead will punt back help, thus
making LTP more newbie friendly and reducing support requests because
people don't RTFM ;)...
4. Begin deprecation of the uclinux* rules, which can be communicated
using the UCLINUX=[0|1] make env var (like they should have been in
the beginning).
5. Add appropriate GPLv2 copyright headers wherever needed.

Notes:
1. Requires [PATCH 2/4].
2. Is an evolution of the commentary w.r.t. the config.mk not required
for clean patch submitted on Saturday.

Signed-off-by: Garrett Cooper <yanegomi@gmail.com>

[-- Attachment #2: top-level-Makefile-refactor+uclinux-remove.diff --]
[-- Type: application/octet-stream, Size: 48555 bytes --]

Index: Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/Makefile,v
retrieving revision 1.39
diff -u -r1.39 Makefile
--- Makefile	25 Mar 2009 06:17:48 -0000	1.39
+++ Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,147 +1,172 @@
-# 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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
+# See INSTALL for build info.
+#
 
-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 automatically when compiling.
+CREATE_ENTRIES		:= 0
+
+srcdir			?= $(CURDIR)
+
+include $(srcdir)/include/mk/automake.mk
+include $(srcdir)/include/mk/master_include.mk
+
+# Only check for numa when not cross-compiling.
+ifeq ($(strip $(CROSS_COMPILE)),1)
+# Disable all undetectable cross-compilation required items.
+HAS_NUMA		?= 0
+SKIP_IDCHECK		:= 1
+else
+# Only check for numa when not cross-compiling.
+HAS_NUMA		?= $(shell sh $(srcdir)/tools/scripts/numa_test.sh)
 endif
 
-HAS_NUMA=$(shell sh tools/scripts/numa_test.sh)
+# 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 config.h),)
+.DEFAULT_GOAL		:= help
+else
+.DEFAULT_GOAL		:= all
+endif
 
-export CFLAGS += -Wall $(CROSS_CFLAGS)
-export CC AR RANLIB CPPFLAGS LDFLAGS HAS_NUMA
+override CFLAGS		+= -Wall
+export AR CC CFLAGS CPPFLAGS HAS_NUMA LD LDLIBS LOADLIBES LDFLAGS RANLIB
 
--include config.mk
+vpath %.am		$(srcdir)/m4
+vpath %.default		$(srcdir)/include
+vpath %.h		$(srcdir)/include
+vpath %.in		$(srcdir)/include
+vpath %.m4		$(srcdir)/m4
+vpath %.mk		$(srcdir)/mk:$(srcdir)/mk/include
+
+# User wants uclinux binaries?
+UCLINUX			?= 0
+
+# 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)
+$(shell sleep 5)
+UCLINUX			:= 1
+endif
 
-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
-
-	@./IDcheck.sh
-
-libltp.a: config.h
-	@$(MAKE) -C lib $@
-
-uclinux: uclinux_libltp.a
-	#@$(MAKE) -C pan all
-	@$(MAKE) -C testcases uclinux
-	@$(MAKE) -C tools all
-	@echo
-	@echo "*******************************************************"
-	@echo "** You now need to do a make uclinux_install as root **"
-	@echo "*******************************************************"
-
-uclinux_install: uclinux
-	@$(MAKE) -C testcases uclinux_install
-	@$(MAKE) -C tools install
-	@./IDcheck.sh
+# 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).
+
+# We're not using uclinux based targets (default).
+ifneq ($(UCLINUX),1)
+COMMON_TARGETS		:= pan utils
+INSTALL_TARGETS		:= doc include m4
+endif
 
-uclinux_libltp.a:
-	@$(MAKE) -C lib UCLINUX=1 libltp.a
+COMMON_TARGETS		+= lib testcases tools
+INSTALL_TARGETS		+= $(COMMON_TARGETS)
+CLEAN_TARGETS		+= $(COMMON_TARGETS) include
 
-menuconfig:
-	@./ltpmenu
+CLEAN_TARGETS		:= $(addsuffix -clean,$(CLEAN_TARGETS))
+INSTALL_TARGETS		:= $(addsuffix -install,$(INSTALL_TARGETS))
+MAKE_TARGETS		:= $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))
 
-clean: ac-clean
-	@$(MAKE) -C lib $@
-	@$(MAKE) -C pan $@
-	@$(MAKE) -C tools $@
-	@$(MAKE) -C testcases $@
-	@$(MAKE) -C utils $@
+export AR CC CFLAGS CPPFLAGS HAS_NUMA LD LOADLIBES LDFLAGS RANLIB UCLINUX
 
-distclean: clean ac-distclean
-	@$(MAKE) -C include $@
+# 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))
 
-maintainer-clean: distclean ac-maintainer-clean
-	@$(MAKE) -C include $@
+$(MAKE_TARGETS): lib-all
 
-package: 
-	rpmbuild -ba ltp-devel.spec
+## Pattern based subtarget rules.
+lib-all: config.h $(srcdir)/include/mk/config.mk
 
+$(MAKE_TARGETS) lib-all: %-all:
+	$(MAKE) -C $* all
 
+# 
+# Let's not conflict with ac-clean, maintainer-clean, etc, so.
 #
-# Autotools related
+# Make sure the Makefile already exists before cd'ing to the directory to avoid
+# incomplete source trees / 
 #
-.PHONY: autotools
-autotools: aclocal autoconf autoheader automake
+$(CLEAN_TARGETS): %-clean: %/Makefile
+	$(MAKE) -C $* clean
 
-.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
+$(INSTALL_TARGETS): %-install:
+	$(MAKE) -C $* install
 
-#
-# Help
-#
+INSTALL_DIR		= $(DESTDIR)/$(prefix)
+
+clean: $(CLEAN_TARGETS)
+	if [ "$(INSTALL_DIR)" != "/" -a -d "$(INSTALL_DIR)" ] ; then \
+	    $(RM) -Rf "$(INSTALL_DIR)"; \
+	fi
+
+$(INSTALL_DIR):
+	mkdir -p $@
+
+RUNLTP			:= $(INSTALL_DIR)/runltp
+
+$(RUNLTP): runltp $(INSTALL_DIR)
+	install -m 00755 `basename "$@"` "$@"
+
+INSTALL_TARGETS		+= $(RUNLTP)
+
+$(INSTALL_TARGETS): all $(INSTALL_DIR)
+
+## Install
+install: $(INSTALL_TARGETS)
+	@set -e; \
+	if [ -n "$(SKIP_IDCHECK)" -o "$(SKIP_IDCHECK)" != "0" ] ; then \
+	    CREATE_ENTRIES=$(CREATE_ENTRIES) DESTDIR=$(DESTDIR) \
+	    $(srcdir)/IDcheck.sh; \
+	else \
+	    echo "*******************************************************"; \
+	    echo "** Will not run IDcheck.sh (SKIP_IDCHECK not set to 0)."; \
+	    echo "*******************************************************"; \
+	fi
+
+# The empty line above was intentional. Do _not_ delete.
+
+## Misc targets.
+
+## 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 $(srcdir)/README.mk-user
+
+## Menuconfig
+menuconfig:
+	@$(SHELL) $(srcdir)/ltpmenu
+
+## Package
+package: 
+	@$(RPMBUILD) -ba ltp-devel.spec
+
+## End misc targets.
Index: README.mk-user
===================================================================
RCS file: README.mk-user
diff -N README.mk-user
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ README.mk-user	7 Jul 2009 00:21:06 -0000
@@ -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
Index: include/mk/automake.mk
===================================================================
RCS file: include/mk/automake.mk
diff -N include/mk/automake.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ include/mk/automake.mk	7 Jul 2009 00:21:06 -0000
@@ -0,0 +1,77 @@
+#
+#    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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
+
+# 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)
+	$(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 $^ $@
+
+.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
+	$(RM) -f ltp-devel.spec README.ltp-devel include/mk/config.mk
+	$(RM) -f lib/ltp.pc m4/Makefile
+ac-distclean: ac-clean
+ac-maintainer-clean: ac-distclean
+	$(RM) -f aclocal.m4 configure $(AUTOMAKE_FILES) m4/Makefile.in
+	$(RM) -f config.h
+
+distclean: clean ac-distclean include-clean
+
+maintainer-clean: distclean ac-maintainer-clean
Index: lib/Makefile
===================================================================
RCS file: lib/Makefile
diff -N lib/Makefile
--- lib/Makefile	3 Apr 2009 06:58:18 -0000	1.16
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,26 +0,0 @@
-
-PREFIX=/opt/ltp
-
-CFLAGS+= -Wall
-CPPFLAGS+= -I../include 
-ifeq ($(shell uname -s),HP-UX)
-CFLAGS+=-Ae -D_LARGEFILE64_SOURCE +DA1.1
-endif
-ifeq ($(UCLINUX),1)
-CFLAGS+= -D_USC_LIB_ -D__UCLIBC__ -DUCLINUX
-endif
-LDFLAGS+=
-TARGET=libltp.a
-SRCS=$(wildcard *.c)
-OBJS=$(patsubst %.c,%.o,$(SRCS))
-
-$(TARGET): $(OBJS)
-	$(AR) -cr $@ $^
-
-clean:
-	rm -f $(TARGET) $(OBJS)
-
-install: $(TARGET)
-	install -D -m 644 $(TARGET) $(DESTDIR)/$(PREFIX)/lib$(LIBSUFFIX)/$(TARGET)
-	install -D -m 644 ltp.pc $(DESTDIR)/$(PREFIX)/share/pkgconfig/ltp.pc
-
Index: testcases/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/Makefile,v
retrieving revision 1.16
diff -u -r1.16 Makefile
--- testcases/Makefile	30 Sep 2008 13:32:59 -0000	1.16
+++ testcases/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,21 +1,63 @@
-	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` 
-UCLINUX_SUBDIRS = kernel
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
-
-install:
-	mkdir -p bin
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-uclinux:
-	@set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux; done
-
-uclinux_install:
-	mkdir -p bin
-	@set -e; for i in $(UCLINUX_SUBDIRS); \
-		do $(MAKE) -C $$i uclinux_install ; done
-
-clean:
-	rm -rf bin/
-	@set -e; for i in $(SUBDIRS) ; do $(MAKE) -C $$i clean ; 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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
 
+srcdir			?= ..
+
+include $(srcdir)/include/mk/master_include.mk
+
+.PHONY: bin-clean install-testcases-bin 
+
+ifeq ($(UCLINUX),1)
+FILTER_OUT_DIRS		:= audit-test DOTS kdump open% pounder realtime
+else
+SUBDIRS			:= kernel
+endif
+
+CLEAN_DEPS		:= bin-clean
+
+INSTALL_DIR		:= testcases/bin
+
+POSTINSTALL_DEPS	:= install-testcases-bin
+
+# 
+# bin, bin-clean, and install-testcases-bin are only here for compatibility
+# until all of the Makefiles properly install files in $(DESTDIR)/$(prefix)/...
+# using master_rules.mk, or until similar behavior is properly emulated in
+# the top-level Makefiles for larger components (ballista and
+# open_posix_testsuite for instance).
+#
+bin:
+	mkdir -p $@
+
+bin-clean:
+	$(RM) -Rf bin
+
+install-testcases-bin:
+	for i in bin/*; do \
+	    install -m 00755 $$i $(DESTDIR)/$(prefix)/$(INSTALL_DIR)/`basename \
+	        "$$i"`; \
+	done
+
+$(eval $(generic_trunk_target))
Index: testcases/kernel/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/Makefile,v
retrieving revision 1.19
diff -u -r1.19 Makefile
--- testcases/kernel/Makefile	26 Feb 2009 11:32:30 -0000	1.19
+++ testcases/kernel/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,17 +1,13 @@
-SUBDIRS = power_management numa containers controllers connectors include fs io ipc mem pty sched security syscalls timers
-UCLINUX_SUBDIRS = include syscalls
+.PHONY: all clean install
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+ifneq ($(UCLINUX),1)
+SUBDIRS		:= power_management numa containers controllers connectors \
+		   include fs io ipc mem pty sched security syscalls timers 
+else
+SUBDIRS		:= include syscalls
+endif
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-uclinux:
-	@set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux ; done
-
-uclinux_install:
-	@set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux_install ; done
-
-clean:
-	@set -e; for i in $(SUBDIRS) timers; do $(MAKE) -C $$i clean ; done
+all clean install: %:
+	@set -e; for i in $(SUBDIRS); do \
+		$(MAKE) -C $$i $@; \
+	done
Index: testcases/kernel/controllers/cpuset/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/controllers/cpuset/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/controllers/cpuset/Makefile	23 Jun 2009 14:18:16 -0000	1.3
+++ testcases/kernel/controllers/cpuset/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,17 +1,39 @@
-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;
-
-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;
+#
+#    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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+include Makefile.inc
+
+.PHONY: pre-install
+
+INSTALL_TARGETS			:= run_cpuset_test.sh
+
+install: pre-install
+
+pre-install:
+	@set -e; for i in $(INSTALL_TARGETS); do \
+	    install -D -m 00755 $$i $(DESTDIR)/$(prefix)/$(INSTALL_DIR)/$$i; \
+	done
+
+$(eval $(generic_dir_target))
Index: testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile	23 Jun 2009 14:18:17 -0000	1.3
+++ testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,16 +1,46 @@
-SRCS = $(wildcard *.sh)
+#
+#    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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
 
-LIBSRCS=$(wildcard ../cpuset_lib/*.c)
-LIBOBJECTS=$(patsubst %.c,%.o,$(LIBSRCS))
+srcdir			?= ../../../../..
 
-all:cpuset_syscall_test
+include ../Makefile.inc
 
-cpuset_syscall_test: %: %.o $(LIBOBJECTS)
+cpuset_dir		:= testcases/kernel/controllers/cpu_set
 
-clean:
-	rm -rf cpuset_syscall_test
+cputset_progdir		:= $(cpuset_basedir)/cpuset_syscall_test
 
-install:
-	@set -e; \
-	for i in $(SRCS); do ln -f $$i ../../../../bin/$$i; chmod +x $$i; done
-	ln -f cpuset_syscall_test ../../../../bin/cpuset_syscall_test;
+LIBOBJS			:= $(patsubst %.c,%.o,$(notdir $(wildcard $(srcdir)/$(libdir)/*.c)))
+
+MAKE_TARGETS		:= $(patsubst %.c,%,$(notdir $(wildcard $(srcdir)/$(progdir)/*.c)))
+
+CLEAN_TARGETS		:= $(addsuffix .o,$(MAKE_TARGETS))
+
+INSTALL_TARGETS		:= $(wildcard *.sh)
+
+$(MAKE_TARGETS): %: %.o $(LIBOBJS)
+
+vpath %.c 		$(srcdir)/$(cpuset_progdir):$(srcdir)/$(cpuset_libdir)
+
+$(eval $(generic_leaf_target))
Index: testcases/kernel/fs/proc/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/fs/proc/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- testcases/kernel/fs/proc/Makefile	5 Feb 2009 11:18:58 -0000	1.5
+++ testcases/kernel/fs/proc/Makefile	7 Jul 2009 00:21:06 -0000
@@ -16,18 +16,14 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-include ../../../../config.mk
+srcdir			?= ../../../..
 
-CFLAGS+=	-I../../../../include
-LDLIBS+=	-L../../../../lib -lltp $(SELINUX_LIBS)
+include $(srcdir)/include/mk/master_include.mk
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+CFLAGS			+= -I$(srcdir)/include
+LDFLAGS			+= -L$(srcdir)/lib
+LDLIBS			+= -lltp $(SELINUX_LIBS)
 
-all: $(TARGETS)
+MAKE_TARGETS		:= $(patsubst %.c,%,$(wildcard *.c))
 
-install:
-	@set -e; for i in $(TARGETS) ; do ln -f $$i ../../../bin/$$i ; done ;
-
-clean:
-	rm -f $(TARGETS)
+$(eval $(generic_leaf_target))
Index: testcases/kernel/fs/scsi/ltpscsi/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/fs/scsi/ltpscsi/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/fs/scsi/ltpscsi/Makefile	23 Jun 2009 14:18:17 -0000	1.3
+++ testcases/kernel/fs/scsi/ltpscsi/Makefile	7 Jul 2009 00:21:06 -0000
@@ -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
Index: testcases/kernel/include/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/include/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- testcases/kernel/include/Makefile	26 Feb 2009 11:32:31 -0000	1.7
+++ testcases/kernel/include/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,19 +1,20 @@
-all uclinux: ../../../include/linux_syscall_numbers.h
+.PHONY: all clean install regen
 
-../../../include/linux_syscall_numbers.h: linux_syscall_numbers.h
-	ln -sf ../testcases/kernel/include/linux_syscall_numbers.h ../../../include/
+srcdir			?= ../../..
 
-clean distclean:
-	rm -f linux_syscall_numbers.h
-	rm -f ../../../include/linux_syscall_numbers.h
+all: linux_syscall_numbers.h
 
-install uclinux_install:
-	@true
+clean:
+	for i in linux_syscall_numbers.h \
+		 $(srcdir)/include/linux_syscall_numbers.h; do \
+	    $(RM) -f $$i; \
+	done
 
-linux_syscall_numbers.h: *.in regen.sh
-	$(MAKE) regen
+# No-op.
+install: ;
 
 regen:
-	./regen.sh
+	@./regen.sh
 
-.PHONY: all clean distclean install regen
+linux_syscall_numbers.h: $(wildcard *.in) regen.sh regen
+	ln -sf ../testcases/kernel/include/$@ $(srcdir)/include/$@
Index: testcases/kernel/io/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/io/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/io/Makefile	29 Dec 2008 11:02:21 -0000	1.6
+++ testcases/kernel/io/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,10 +1,39 @@
-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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
 
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+srcdir			:= ../../..
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+include $(srcdir)/include/mk/master_include.mk
 
-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+SUBDIRS 		:= direct_io disktest stress_cd stress_floppy \
+			   writetest
+
+# Don't even bother traversing down aio because the system doesn't have -laio
+# support.
+ifneq ($(AIO_LIBS),)
+SUBDIRS			+= aio
+endif
+
+$(eval $(generic_trunk_target))
Index: testcases/kernel/io/aio/aio01/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/io/aio/aio01/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- testcases/kernel/io/aio/aio01/Makefile	28 Jan 2009 06:43:09 -0000	1.2
+++ testcases/kernel/io/aio/aio01/Makefile	7 Jul 2009 00:21:06 -0000
@@ -20,13 +20,16 @@
 # name of file	: Makefile						  #
 # description	: make(1) description file                                #
 ###########################################################################
-include ../../../../../config.mk
 
-CFLAGS+=	-I../../../../../include -Wall
-LOADLIBES+=	$(AIO_LIBS) -L../../../../../lib -lltp
+srcdir			?= ../../../../..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(srcdir)/include/mk/master_include.mk
+
+CFLAGS			+= -I$(srcdir)/include -Wall
+LDFLAGS			+= -L$(srcdir)/lib
+LDLIBS			+= $(AIO_LIBS) -lltp
+
+TARGETS			:= $(patsubst %.c,%,$(wildcard *.c))
 
 all: $(TARGETS)
 
@@ -35,5 +38,3 @@
 
 clean:
 	rm -f $(TARGETS)
-
-
Index: testcases/kernel/io/aio/aio02/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/io/aio/aio02/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/io/aio/aio02/Makefile	18 Jun 2009 17:06:59 -0000	1.6
+++ testcases/kernel/io/aio/aio02/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,20 +1,49 @@
-include ../../../../../config.mk
+#
+#    Makefile for: kernel/io/aio/aio2 testcase.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
+
+srcdir			?= ../../../../..
+
+include $(srcdir)/include/mk/master_include.mk
+
+CFLAGS			+= -Wall -g -O -I$(srcdir)/include -Wall
+LDFLAGS			+= -L$(srcdir)/lib
+LDLIBS			+= -lltp $(AIO_LIBS)
+
 # foo.
-TEST_SRCS:=$(shell find cases/ -name \*.c | sort -n -t/ -k2)
-PROGS:=$(patsubst %.c,%,$(TEST_SRCS))
-HARNESS_SRCS:=main.c
+PROGS			:= $(patsubst %.c,%,$(wildcard cases/*.c))
+HARNESS_SRCS		:= main.c
 # io_queue.c
 
-CFLAGS+=-Wall  -g -O -I../../../../../include -Wall
-LDFLAGS+=-L../../../../../lib -lltp $(AIO_LIBS)
 #-lpthread -lrt
 all: $(PROGS)
 
 $(PROGS): %: %.c $(HARNESS_SRCS) Makefile
-	$(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c $(LDFLAGS)
+$(PROGS): CFLAGS += -DTEST_NAME=\"$(patsubst %.c,%,$(notdir $<))\"
 
 clean:
 	rm -f $(PROGS) *.o runtests.out rofile wofile rwfile
 
-install:
+install: ;
 
Index: testcases/kernel/io/stress_floppy/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/io/stress_floppy/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- testcases/kernel/io/stress_floppy/Makefile	28 Mar 2003 18:27:48 -0000	1.8
+++ testcases/kernel/io/stress_floppy/Makefile	7 Jul 2009 00:21:06 -0000
@@ -5,7 +5,6 @@
 	ln -f *_file ../../../bin
 	cp -rf dumpdir ../../../bin
 
-
 generate:
 	./generate.sh
 
Index: testcases/kernel/security/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/security/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/security/Makefile	28 Apr 2009 07:04:38 -0000	1.6
+++ testcases/kernel/security/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,3 +1,35 @@
+#
+#  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
+#
+
+srcdir			?= ../../..
+
+include	$(srcdir)/include/mk/master_include.mk
+
+DEBUG_CFLAGS		:= -O
+DEBUG_LDFLAGS		:= -s
+CFLAGS			+= -I$(srcdir)/include -g -Wall
+FILTER_OUT_DIRS		:= epoll
+
+ifeq ($(UCLINUX),1)
+FILTER_OUT_DIRS		+= capget capset chmod chown clone fork getcontext \
+			   llseek nftw profil remap_file_pages
+endif
+
 SUBDIRS = mmc_security filecaps integrity cap_bound
 
 all:
Index: testcases/kernel/security/integrity/ima/src/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/security/integrity/ima/src/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- testcases/kernel/security/integrity/ima/src/Makefile	31 Mar 2009 13:58:14 -0000	1.1
+++ testcases/kernel/security/integrity/ima/src/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,12 +1,39 @@
-include ../../../../../../config.mk
+#
+#    Makefile for: kernel/security/integrity/ima testcase.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
+
+srcdir			?= ../../../../../..
+
+include $(srcdir)/include/mk/master_include.mk
 
 ifeq ($(CRYPTO_LIB),-lcrypto)
-	TARGETS=ima_mmap ima_measure ima_boot_aggregate
-	LDLIBS += $(CRYPTO_LIB)
-else
-	TARGETS=ima_mmap
+TARGETS			:= ima_measure ima_boot_aggregate
+LDLIBS			+= $(CRYPTO_LIB)
 endif
 
+TARGETS			+= ima_mmap
+
 all: $(TARGETS)
 
 install:
Index: testcases/kernel/syscalls/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/Makefile,v
retrieving revision 1.63
diff -u -r1.63 Makefile
--- testcases/kernel/syscalls/Makefile	26 Feb 2009 11:37:28 -0000	1.63
+++ testcases/kernel/syscalls/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,55 +1,40 @@
 #
-#  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.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
-#
-#  You should have 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) 2009, Cisco Systems Inc.
 #
-
-DEBUG_CFLAGS=-O
-DEBUG_LDFLAGS=-s
-CFLAGS+=-I../../include -g -Wall
-LDLIBS+=
-EXCLUDE_DIR=epoll
-
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-# Commented this out since there are directories here we don't want built by default
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
 #
-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"`
-
-all:
-	@set -e; for i in $(SUBDIR); do \
-		$(MAKE) -C $$i  all; \
-	done
 
-install:
-	@set -e; for i in $(SUBDIR); do \
-		$(MAKE) -C $$i  install; \
-	done
+srcdir			?= ../../..
 
-uclinux:  
-	@set -e; for i in $(UCLINUX_SUBDIR); do \
-		$(MAKE) -C $$i UCLINUX=1 all; \
-	done
+include	$(srcdir)/include/mk/master_include.mk
 
-uclinux_install:
-	@set -e; for i in $(UCLINUX_SUBDIR); do \
-		$(MAKE) -C $$i UCLINUX=1 install; \
-	done
+DEBUG_CFLAGS		:= -O
+DEBUG_LDFLAGS		:= -s
+CFLAGS			+= -I$(srcdir)/include -g -Wall
+FILTER_OUT_SUBDIRS	:= epoll
 
-clean:
-	@set -e; for i in $(SUBDIR); do \
-		$(MAKE) -C $$i  clean; \
-	done
+ifeq ($(UCLINUX),1)
+FILTER_OUT_SUBDIRS	+= capget capset chmod chown clone fork getcontext \
+			   llseek nftw profil remap_file_pages
+endif
 
+$(eval $(generic_dir_target))
Index: testcases/kernel/syscalls/eventfd/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/eventfd/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/syscalls/eventfd/Makefile	16 Jan 2009 09:03:14 -0000	1.6
+++ testcases/kernel/syscalls/eventfd/Makefile	7 Jul 2009 00:21:06 -0000
@@ -16,15 +16,15 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+srcdir			?= ../../../..
 
-include ../../../../config.mk
+include $(srcdir)/include/mk/master_include.mk
 
+CFLAGS			+= -I$(srcdir)/include -Wall
+LDFLAGS			+= -L$(srcdir)/lib
+LDLIBS			:= $(AIO_LIBS) -lltp
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += -L../../../../lib $(AIO_LIBS) -lltp
-
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c, %, $(wildcard *.c))
+TARGETS			:= $(patsubst %.c, %, $(wildcard *.c))
 
 all: $(TARGETS)
 
Index: testcases/kernel/syscalls/io_cancel/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_cancel/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- testcases/kernel/syscalls/io_cancel/Makefile	20 Jan 2009 10:48:41 -0000	1.4
+++ testcases/kernel/syscalls/io_cancel/Makefile	7 Jul 2009 00:21:06 -0000
@@ -20,14 +20,15 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+srcdir			?= ../../../..
 
-include ../../../../config.mk
+include $(srcdir)/include/mk/master_include.mk
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
+CFLAGS 			+= -I$(srcdir)/include -Wall
+LDFLAGS			+= $(AIO_LIBS) -L$(srcdir)/lib
+LDLIBS			+= -lltp
 
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
+TARGETS 		:= $(patsubst %.c,%,$(wildcard *.c))
 
 all: $(TARGETS)
 
Index: testcases/kernel/syscalls/io_destroy/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_destroy/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/syscalls/io_destroy/Makefile	20 Jan 2009 10:48:41 -0000	1.3
+++ testcases/kernel/syscalls/io_destroy/Makefile	7 Jul 2009 00:21:06 -0000
@@ -20,15 +20,15 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+srcdir			?= ../../../..
 
-include ../../../../config.mk
+include $(srcdir)/include/mk/master_include.mk
 
+CFLAGS 			+= -I$(srcdir)/include -Wall
+LDFLAGS			+= $(AIO_LIBS) -L$(srcdir)/lib
+LDLIBS			+= -lltp
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
+TARGETS 		:= $(patsubst %.c,%,$(wildcard *.c))
 
 all: $(TARGETS)
 
Index: testcases/kernel/syscalls/io_getevents/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_getevents/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/syscalls/io_getevents/Makefile	20 Jan 2009 10:48:41 -0000	1.3
+++ testcases/kernel/syscalls/io_getevents/Makefile	7 Jul 2009 00:21:06 -0000
@@ -20,15 +20,15 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+srcdir			?= ../../../..
 
-include ../../../../config.mk
+include $(srcdir)/include/mk/master_include.mk
 
+CFLAGS 			+= -I$(srcdir)/include -Wall
+LDFLAGS			+= $(AIO_LIBS) -L$(srcdir)/lib
+LDLIBS			+= -lltp
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
+TARGETS 		:= $(patsubst %.c,%,$(wildcard *.c))
 
 all: $(TARGETS)
 
Index: testcases/kernel/syscalls/io_setup/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_setup/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/syscalls/io_setup/Makefile	20 Jan 2009 10:48:42 -0000	1.3
+++ testcases/kernel/syscalls/io_setup/Makefile	7 Jul 2009 00:21:06 -0000
@@ -20,15 +20,15 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+srcdir			?= ../../../..
 
-include ../../../../config.mk
+include $(srcdir)/include/mk/master_include.mk
 
+CFLAGS 			+= -I$(srcdir)/include -Wall
+LDFLAGS			+= $(AIO_LIBS) -L$(srcdir)/lib
+LDLIBS			+= -lltp
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
+TARGETS 		:= $(patsubst %.c,%,$(wildcard *.c))
 
 all: $(TARGETS)
 
Index: testcases/kernel/syscalls/io_submit/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_submit/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/syscalls/io_submit/Makefile	20 Jan 2009 10:48:42 -0000	1.3
+++ testcases/kernel/syscalls/io_submit/Makefile	7 Jul 2009 00:21:06 -0000
@@ -20,16 +20,15 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 
+srcdir			?= ../../../..
 
-include ../../../../config.mk
+include $(srcdir)/include/mk/master_include.mk
 
+CFLAGS 			+= -I$(srcdir)/include -Wall
+LDFLAGS			+= $(AIO_LIBS) -L$(srcdir)/lib
+LDLIBS			+= -lltp
 
-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-SYSCALL = io_submit
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
+TARGETS 		:= $(patsubst %.c,%,$(wildcard *.c))
 
 all: $(TARGETS)
 
Index: testcases/kernel/timers/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/timers/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/timers/Makefile	22 Aug 2006 05:14:39 -0000	1.6
+++ testcases/kernel/timers/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,25 +1,30 @@
 #
-#  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.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
-#
-#  You should have 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) 2009, Cisco Systems, Inc.
 #
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
+
+srcdir				?= ../../..
 
-SUBDIRS = $(patsubst %/Makefile,%,$(wildcard */Makefile))
+include $(srcdir)/include/mk/master_include.mk
 
-all %::
-	@set -e; \
-	for i in $(SUBDIRS); do \
-		$(MAKE) -C $$i $@; \
-	done
+$(eval $(generic_dir_target))
Index: testcases/realtime/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/realtime/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- testcases/realtime/Makefile	24 Mar 2008 09:13:49 -0000	1.1
+++ testcases/realtime/Makefile	7 Jul 2009 00:21:06 -0000
@@ -12,4 +12,4 @@
 
 clean:
 	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-	@rm .config
+	@rm .config *.o
Index: tools/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/tools/Makefile,v
retrieving revision 1.11
diff -u -r1.11 Makefile
--- tools/Makefile	19 Aug 2003 14:30:20 -0000	1.11
+++ tools/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,18 +1,35 @@
-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
+#
+# Copyright (c) 2009 by Cisco Systems, Inc.
+# All rights reserved
+#
 
-CFLAGS+= -Wall -I../include
-LOADLIBES+= -L../lib -lltp
+srcdir			?= ..
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(srcdir)/include/mk/master_include.mk
 
-all: $(TARGETS)
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+CFLAGS			+= -Wall -I$(srcdir)/include
+LDLIBS			+= -L$(objdir)/lib -lltp
 
-install:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-	@set -e; ln -f gethost ../testcases/bin
+MAKE_TARGETS		:= $(patsubst %.c,%,$(wildcard *.c))
 
-clean:
-	rm -f $(TARGETS)
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+$(eval $(generic_trunk_target))
Index: tools/genload/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/tools/genload/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- tools/genload/Makefile	29 Sep 2008 16:22:14 -0000	1.4
+++ tools/genload/Makefile	7 Jul 2009 00:21:06 -0000
@@ -1,14 +1,15 @@
-CFLAGS+= -DPACKAGE=\"stress\" -DVERSION=\"0.17pre11\" 
+srcdir		?= ../..
 
-LDLIBS+= -lm
+include $(srcdir)/include/mk/master_include.mk
 
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+CFLAGS		+= -DPACKAGE=\"stress\" -DVERSION=\"0.17pre11\" 
 
-all: $(TARGETS)
+LDLIBS		+= -lm
 
-install:
-	@ln -f $(TARGETS) ../../testcases/bin/genload
+MAKE_TARGETS	:= genload
 
-clean:
-	rm -fr $(TARGETS)
+$(MAKE_TARGETS): stress.o
+
+CLEAN_TARGETS	:= stress.o
+
+$(eval $(generic_leaf_target))

[-- Attachment #3: Type: text/plain, Size: 390 bytes --]

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize autoconf logic
  2009-07-07  0:22 [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize autoconf logic Garrett Cooper
@ 2009-07-08 23:53 ` Mike Frysinger
  2009-07-09  0:21   ` Garrett Cooper
  2009-07-09  9:39   ` Garrett Cooper
  0 siblings, 2 replies; 10+ messages in thread
From: Mike Frysinger @ 2009-07-08 23:53 UTC (permalink / raw)
  To: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 2759 bytes --]

On Monday 06 July 2009 20:22:19 Garrett Cooper wrote:
> 1. Better modularize and separate out the top-level Makefile such that
> automake logic and top-level targets are better partitioned out, and
> thus the overall logic and flow is more intuitive.
> 2. Move help output to README.mk-user.
> 3. Make $(.DEFAULT_GOAL) vary depending on whether or not the system
> has been configured, such that typing in make will no longer run all
> and result in Make errors, but instead will punt back help, thus
> making LTP more newbie friendly and reducing support requests because
> people don't RTFM ;)...
> 4. Begin deprecation of the uclinux* rules, which can be communicated
> using the UCLINUX=[0|1] make env var (like they should have been in
> the beginning).
> 5. Add appropriate GPLv2 copyright headers wherever needed.
>
> Notes:
> 1. Requires [PATCH 2/4].
> 2. Is an evolution of the commentary w.r.t. the config.mk not required
> for clean patch submitted on Saturday.

you have duplicated copyright notices here too

please drop the sleep in the uclinux warning

you seem to export the variables twice

there is a $(basename ...) make function so you dont need to use `basename`

you check SKIP_IDCHECK in some targets ... this is a make var, so using 
ifeq(...) instead is better -- avoids @ and nesting and set -e and other crap

the if checking in the clean target seems unnecessary

please use "$" to indicate prompts in documentation, not "$$"

for pre/post install hooks, why not declare a common name and everyone use 
that rather than forcing people to declare it.  i.e. declare the target "post-
install-hook" as a .PHONY and always call/depend/etc... on it.

some of your for loops arent using set -e or checking the install exit status

why cant testcases/kernel/Makefile leverage these .mk files ?  the whole point 
was to get away from these custom written jobbies ...

you're mixing CFLAGS and CPPFLAGS.  -I/-D is for CPPFLAGS.

what's this business of every Makefile having to declare MAKE_TARGETS ?  this 
should be a common default.

rather than force everyone to hardcode the default ltp -I inc and -L lib 
paths, these should be added to the global defaults

doing a for loop on a `rm` command is silly.  call `rm` once.

debugging/optimization/warning/stripping flags shouldnt be added in any 
Makefile that is being converted to these common .mk files.  same for any 
DEBUG_XXX flags.

i dont see the point in declaring empty rules like "install: ;".  if they're 
declared .PHONY, there is no need to add explicit rules to sub Makefiles.

clean targets should always delete common things like "*.o".  forcing people 
to have to manually declare these is a waste.
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 389 bytes --]

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize  autoconf logic
  2009-07-08 23:53 ` Mike Frysinger
@ 2009-07-09  0:21   ` Garrett Cooper
  2009-07-09  0:42     ` Mike Frysinger
  2009-07-09  9:39   ` Garrett Cooper
  1 sibling, 1 reply; 10+ messages in thread
From: Garrett Cooper @ 2009-07-09  0:21 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list

On Wed, Jul 8, 2009 at 4:53 PM, Mike Frysinger<vapier@gentoo.org> wrote:
> On Monday 06 July 2009 20:22:19 Garrett Cooper wrote:
>> 1. Better modularize and separate out the top-level Makefile such that
>> automake logic and top-level targets are better partitioned out, and
>> thus the overall logic and flow is more intuitive.
>> 2. Move help output to README.mk-user.
>> 3. Make $(.DEFAULT_GOAL) vary depending on whether or not the system
>> has been configured, such that typing in make will no longer run all
>> and result in Make errors, but instead will punt back help, thus
>> making LTP more newbie friendly and reducing support requests because
>> people don't RTFM ;)...
>> 4. Begin deprecation of the uclinux* rules, which can be communicated
>> using the UCLINUX=[0|1] make env var (like they should have been in
>> the beginning).
>> 5. Add appropriate GPLv2 copyright headers wherever needed.
>>
>> Notes:
>> 1. Requires [PATCH 2/4].
>> 2. Is an evolution of the commentary w.r.t. the config.mk not required
>> for clean patch submitted on Saturday.
>
> you have duplicated copyright notices here too

The Cisco junk is just to pass by our in-house copyright checker, but
I suppose it really doesn't matter anyhow...

> please drop the sleep in the uclinux warning

Ok.

> you seem to export the variables twice

Yeah, I'll look into that.

> there is a $(basename ...) make function so you dont need to use `basename`

Whoops... forgot about that. Thanks.

> you check SKIP_IDCHECK in some targets ... this is a make var, so using
> ifeq(...) instead is better -- avoids @ and nesting and set -e and other crap

Yes, will do.

> the if checking in the clean target seems unnecessary

Uh, no. If someone's root and they specify $(INSTALL_DIR) := / (or
worse, empty), it'll nuke the host machine's entire rootfs. I ran the
build as a non-root user when I ran into that issue -- and quickly
quashed it :)...

> please use "$" to indicate prompts in documentation, not "$$"

Ok.

> for pre/post install hooks, why not declare a common name and everyone use
> that rather than forcing people to declare it.  i.e. declare the target "post-
> install-hook" as a .PHONY and always call/depend/etc... on it.

I'm a bit confused by this comment. Can you review to spots in the
patch (when I upload it tonight), so this can be resolved?

> some of your for loops arent using set -e or checking the install exit status

Ok. I'll review that again. Thanks.

> why cant testcases/kernel/Makefile leverage these .mk files ?  the whole point
> was to get away from these custom written jobbies ...

Some of these Makefiles get a bit ugly with the pre- and post- junk...
There are a small number of Makefiles that are haunted by this work,
but then again I did some more rework with the generic_trunk_target
define.

> you're mixing CFLAGS and CPPFLAGS.  -I/-D is for CPPFLAGS.

Ok. I thought it was the other way around. Whoops!

> what's this business of every Makefile having to declare MAKE_TARGETS ?  this
> should be a common default.

It defaults to a wildcard of the .c files in the directory -- hence
the `?='. If that's a bad default, please let me know.

> rather than force everyone to hardcode the default ltp -I inc and -L lib
> paths, these should be added to the global defaults

Agreed. This was just the first stage.

> doing a for loop on a `rm` command is silly.  call `rm` once.

Yeah. I should be applying xargs instead of a loop. Calling rm once
may overflow the command line though (like with testcases/bin if it
grows large enough).

> debugging/optimization/warning/stripping flags shouldnt be added in any
> Makefile that is being converted to these common .mk files.  same for any
> DEBUG_XXX flags.

Agreed. I was just duplicating what already existed, hoping that we
could sweep up this stuff after everything was in and the base
infrastructure was stable.

> i dont see the point in declaring empty rules like "install: ;".  if they're
> declared .PHONY, there is no need to add explicit rules to sub Makefiles.

They're there to avoid errors with targets not being found if I'm
running recursive Make rules over the entire directory tree. So, I
agree it's silly, but if you have a better idea, I'm all ears and I'll
get on it ASAP. I'm trying to avoid cramming more variables into the
Make system because it will only generate more confusion...

> clean targets should always delete common things like "*.o".  forcing people
> to have to manually declare these is a waste.

Ok. Once upon a time (~1 year ago) I found a testcase that generated a
.o file which was just as input for a testcase (it was under
testcases/kernel/io somewhere -- maybe the floppy test). Maybe that's
a bug then that should be solved...

Thanks!
-Garrett

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize autoconf logic
  2009-07-09  0:21   ` Garrett Cooper
@ 2009-07-09  0:42     ` Mike Frysinger
  2009-07-09  9:08       ` Garrett Cooper
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2009-07-09  0:42 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 4392 bytes --]

On Wednesday 08 July 2009 20:21:11 Garrett Cooper wrote:
> On Wed, Jul 8, 2009 at 4:53 PM, Mike Frysinger<vapier@gentoo.org> wrote:
> > you have duplicated copyright notices here too
>
> The Cisco junk is just to pass by our in-house copyright checker, but
> I suppose it really doesn't matter anyhow...

i also noticed the statements "all rights reserved" ... i dont think those 
have any business being in open source code

> > the if checking in the clean target seems unnecessary
>
> Uh, no. If someone's root and they specify $(INSTALL_DIR) := / (or
> worse, empty), it'll nuke the host machine's entire rootfs. I ran the
> build as a non-root user when I ran into that issue -- and quickly
> quashed it :)...

sorry, i meant the "-d" part.  besides, all recent distros will refuse to run 
something like `rm -rf /` -- the util itself rejects "/".

> > for pre/post install hooks, why not declare a common name and everyone
> > use that rather than forcing people to declare it.  i.e. declare the
> > target "post- install-hook" as a .PHONY and always call/depend/etc... on
> > it.
>
> I'm a bit confused by this comment. Can you review to spots in the
> patch (when I upload it tonight), so this can be resolved?

testcases/kernel/controllers/cpuset/Makefile:
why must "install" manually depend on pre-install ?  that dependency should 
always be there leaving the subdir to only have to define the pre-install 
target.

testcases/Makefile:
i dont get all these xxx_DEPS variables and the install-testcases-bin target

> > why cant testcases/kernel/Makefile leverage these .mk files ?  the whole
> > point was to get away from these custom written jobbies ...
>
> Some of these Makefiles get a bit ugly with the pre- and post- junk...
> There are a small number of Makefiles that are haunted by this work,
> but then again I did some more rework with the generic_trunk_target
> define.

so that means you'll fix the Makefile to use the .mk files

> > what's this business of every Makefile having to declare MAKE_TARGETS ?
> >  this should be a common default.
>
> It defaults to a wildcard of the .c files in the directory -- hence
> the `?='. If that's a bad default, please let me know.

i'm talking about the Makefiles that are setting this variable.  i.e.
testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
testcases/kernel/fs/proc/Makefile
tools/Makefile

> > doing a for loop on a `rm` command is silly.  call `rm` once.
>
> Yeah. I should be applying xargs instead of a loop. Calling rm once
> may overflow the command line though (like with testcases/bin if it
> grows large enough).

if you really want to go that far, but i was looking at 
testcases/kernel/include/Makefile.  there's no way that is going to overflow.  
besides, i guess there shouldnt be a clean target in there anyways -- it 
should be using the default one.

> > debugging/optimization/warning/stripping flags shouldnt be added in any
> > Makefile that is being converted to these common .mk files.  same for any
> > DEBUG_XXX flags.
>
> Agreed. I was just duplicating what already existed, hoping that we
> could sweep up this stuff after everything was in and the base
> infrastructure was stable.

i'd prefer we scrub the crap now

> > i dont see the point in declaring empty rules like "install: ;".  if
> > they're declared .PHONY, there is no need to add explicit rules to sub
> > Makefiles.
>
> They're there to avoid errors with targets not being found if I'm
> running recursive Make rules over the entire directory tree. So, I
> agree it's silly, but if you have a better idea, I'm all ears and I'll
> get on it ASAP. I'm trying to avoid cramming more variables into the
> Make system because it will only generate more confusion...

let's look at testcases/kernel/include/Makefile.  how would a missing install 
target here generate an error ?

> > clean targets should always delete common things like "*.o".  forcing
> > people to have to manually declare these is a waste.
>
> Ok. Once upon a time (~1 year ago) I found a testcase that generated a
> .o file which was just as input for a testcase (it was under
> testcases/kernel/io somewhere -- maybe the floppy test). Maybe that's
> a bug then that should be solved...

we should fix that then as that's just craziness
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 389 bytes --]

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize  autoconf logic
  2009-07-09  0:42     ` Mike Frysinger
@ 2009-07-09  9:08       ` Garrett Cooper
  2009-07-10  0:07         ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Garrett Cooper @ 2009-07-09  9:08 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list

On Wed, Jul 8, 2009 at 5:42 PM, Mike Frysinger<vapier@gentoo.org> wrote:
> On Wednesday 08 July 2009 20:21:11 Garrett Cooper wrote:
>> On Wed, Jul 8, 2009 at 4:53 PM, Mike Frysinger<vapier@gentoo.org> wrote:
>> > you have duplicated copyright notices here too
>>
>> The Cisco junk is just to pass by our in-house copyright checker, but
>> I suppose it really doesn't matter anyhow...
>
> i also noticed the statements "all rights reserved" ... i dont think those
> have any business being in open source code

Yes. It's going out the door with all stuff I develop. I'll get my
peer to do the same with commits that he's going to do as well.

>> > the if checking in the clean target seems unnecessary
>>
>> Uh, no. If someone's root and they specify $(INSTALL_DIR) := / (or
>> worse, empty), it'll nuke the host machine's entire rootfs. I ran the
>> build as a non-root user when I ran into that issue -- and quickly
>> quashed it :)...
>
> sorry, i meant the "-d" part.  besides, all recent distros will refuse to run
> something like `rm -rf /` -- the util itself rejects "/".

Key point -- recent distros. We don't know if some person's going to
be running an ancient distro with a 2.4 kernel because I've seen
report requests about that on the list. I'd rather keep the support to
prevent shooting one's self in the foot. Besides, INSTALL_DIR is
DESTDIR = "", prefix = "". Only if someone's dumb enough NOT to
specify both of these variables (in which case they'll be installing
like /testcases/bin, /lib/libltp.a) will this ever be an issue. And if
someone chooses to shoot themselves in the foot, they can very well do
so by hacking the Makefiles to remove the checks ;)...

The only time that it will error out is with clean, when INSTALL_DIR
isn't set to any value (most of the time when they haven't done
configure).

>> > for pre/post install hooks, why not declare a common name and everyone
>> > use that rather than forcing people to declare it.  i.e. declare the
>> > target "post- install-hook" as a .PHONY and always call/depend/etc... on
>> > it.
>>>
>> I'm a bit confused by this comment. Can you review to spots in the
>> patch (when I upload it tonight), so this can be resolved?
>
> testcases/kernel/controllers/cpuset/Makefile:
> why must "install" manually depend on pre-install ?  that dependency should
> always be there leaving the subdir to only have to define the pre-install
> target.

No longer than way anymore ;)...

#
#    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
#

include Makefile.inc

$(eval $(generic_trunk_target))

> testcases/Makefile:
> i dont get all these xxx_DEPS variables and the install-testcases-bin target

xxx_DEPS aren't used in typical situations. They are used in different
situations where one _must_ preserve dependency ordering. People
should NOT have to use these except with code generation, upper-level
target dependencies (my next stop after this all gets said and done,
e.g. if I do a submake from somewhere within testcases/kernel, I
better well have libltp.a built beforehand :)...), etc.

>> > why cant testcases/kernel/Makefile leverage these .mk files ?  the whole
>> > point was to get away from these custom written jobbies ...
>>
>> Some of these Makefiles get a bit ugly with the pre- and post- junk...
>> There are a small number of Makefiles that are haunted by this work,
>> but then again I did some more rework with the generic_trunk_target
>> define.
>
> so that means you'll fix the Makefile to use the .mk files

Yes. Again, these are bad hacks to work around the fact that these are
initial commits, and the fact that the rest of the source tree isn't
up to date with the new system (that will take ~3 days with straight
work and verification, but I'd quote a week and a half because of
random junk that can get in the way of getting things done). Only in a
few key Makefiles are these hacks required. testcases/Makefile is just
one of these examples. Here's the comment:

#
# bin, bin-clean, and install-testcases-bin are only here for compatibility
# until all of the Makefiles properly install files in $(DESTDIR)/$(prefix)/...
# using master_rules.mk, and similar behavior is properly emulated in the
# top-level Makefiles for larger components (ballista and open_posix_testsuite
# for instance).
#

This won't be the case in the majority of the hacked Makefiles, once
the children are up-to-date.

>> > what's this business of every Makefile having to declare MAKE_TARGETS ?
>> >  this should be a common default.
>>
>> It defaults to a wildcard of the .c files in the directory -- hence
>> the `?='. If that's a bad default, please let me know.
>
> i'm talking about the Makefiles that are setting this variable.  i.e.
> testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
> testcases/kernel/fs/proc/Makefile
> tools/Makefile

Zapped.

>> > doing a for loop on a `rm` command is silly.  call `rm` once.
>>
>> Yeah. I should be applying xargs instead of a loop. Calling rm once
>> may overflow the command line though (like with testcases/bin if it
>> grows large enough).
>
> if you really want to go that far, but i was looking at
> testcases/kernel/include/Makefile.  there's no way that is going to overflow.
> besides, i guess there shouldnt be a clean target in there anyways -- it
> should be using the default one.

Rewritten.

>> > debugging/optimization/warning/stripping flags shouldnt be added in any
>> > Makefile that is being converted to these common .mk files.  same for any
>> > DEBUG_XXX flags.
>>
>> Agreed. I was just duplicating what already existed, hoping that we
>> could sweep up this stuff after everything was in and the base
>> infrastructure was stable.
>
> i'd prefer we scrub the crap now

Yes, but how and when should this stuff be done, and in what way? is
the ultimate question. If I were to toss in every dumb warning
compiler flag imaginable (which believe it or not _is_ the default for
the proprietary code we compile), my group in Cisco would never be
able to compile LTP because of coding issues. How much is enough, and
how much is too little?

>> > i dont see the point in declaring empty rules like "install: ;".  if
>> > they're declared .PHONY, there is no need to add explicit rules to sub
>> > Makefiles.
>>
>> They're there to avoid errors with targets not being found if I'm
>> running recursive Make rules over the entire directory tree. So, I
>> agree it's silly, but if you have a better idea, I'm all ears and I'll
>> get on it ASAP. I'm trying to avoid cramming more variables into the
>> Make system because it will only generate more confusion...
>
> let's look at testcases/kernel/include/Makefile.  how would a missing install
> target here generate an error ?

testcases/kernel calls install recursively. I don't want to create
annoying subvariables for all, install, clean, and whatever other
recursive target I can think of, because even though I know how to, it
only serves to confuse and complicate the purpose of the system
(that's part of the reason why I'm the only individual, apart from two
others in a team of about 100, who can stumble around our complicated
build system at work).

>> > clean targets should always delete common things like "*.o".  forcing
>> > people to have to manually declare these is a waste.
>>
>> Ok. Once upon a time (~1 year ago) I found a testcase that generated a
>> .o file which was just as input for a testcase (it was under
>> testcases/kernel/io somewhere -- maybe the floppy test). Maybe that's
>> a bug then that should be solved...
>
> we should fix that then as that's just craziness

Seems like someone already might have removed it, but I'll keep my
eyes peeled and fix it immediately if it resurfaces.

Thanks,
-Garrett

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize  autoconf logic
  2009-07-08 23:53 ` Mike Frysinger
  2009-07-09  0:21   ` Garrett Cooper
@ 2009-07-09  9:39   ` Garrett Cooper
  1 sibling, 0 replies; 10+ messages in thread
From: Garrett Cooper @ 2009-07-09  9:39 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list

On Wed, Jul 8, 2009 at 4:53 PM, Mike Frysinger<vapier@gentoo.org> wrote:

One note:

> there is a $(basename ...) make function so you dont need to use `basename`

$(basename) has a different meaning, compared to the standard c libcall:

From http://www.gnu.org/software/make/manual/make.html#File-Name-Functions:

$(basename names...)
    Extract the base name (name without suffix) of each file name.
    See Functions for File Names.

$(notdir) is the actual preferred built-in. Now I remember why I was
doing $(notdir) :)...

Thanks,
-Garrett

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize autoconf logic
  2009-07-09  9:08       ` Garrett Cooper
@ 2009-07-10  0:07         ` Mike Frysinger
  2009-07-11 21:55           ` Garrett Cooper
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2009-07-10  0:07 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 4928 bytes --]

On Thursday 09 July 2009 05:08:22 Garrett Cooper wrote:
> On Wed, Jul 8, 2009 at 5:42 PM, Mike Frysinger wrote:
> > On Wednesday 08 July 2009 20:21:11 Garrett Cooper wrote:
> >> On Wed, Jul 8, 2009 at 4:53 PM, Mike Frysinger wrote:
> > testcases/Makefile:
> > i dont get all these xxx_DEPS variables and the install-testcases-bin
> > target
>
> xxx_DEPS aren't used in typical situations. They are used in different
> situations where one _must_ preserve dependency ordering. People
> should NOT have to use these except with code generation, upper-level
> target dependencies (my next stop after this all gets said and done,
> e.g. if I do a submake from somewhere within testcases/kernel, I
> better well have libltp.a built beforehand :)...), etc.

yes, but in the patch you posted, i didnt see why any of those needed to be in 
the Makefile's in question.  i dont have a problem adding knobs, but i do when 
they're used incorrectly or not at all.

i guess i'll wait until your follow up patch to check this stuff again

> >> > why cant testcases/kernel/Makefile leverage these .mk files ?  the
> >> > whole point was to get away from these custom written jobbies ...
> >>
> >> Some of these Makefiles get a bit ugly with the pre- and post- junk...
> >> There are a small number of Makefiles that are haunted by this work,
> >> but then again I did some more rework with the generic_trunk_target
> >> define.
> >
> > so that means you'll fix the Makefile to use the .mk files
>
> Yes. Again, these are bad hacks to work around the fact that these are
> initial commits, and the fact that the rest of the source tree isn't
> up to date with the new system (that will take ~3 days with straight
> work and verification, but I'd quote a week and a half because of
> random junk that can get in the way of getting things done). Only in a
> few key Makefiles are these hacks required. testcases/Makefile is just
> one of these examples. Here's the comment:

ok, transitional hacks which are commented should be fine.  i dont recall 
seeing this comment in the patch posted for review though ;).

> >> > debugging/optimization/warning/stripping flags shouldnt be added in
> >> > any Makefile that is being converted to these common .mk files.  same
> >> > for any DEBUG_XXX flags.
> >>
> >> Agreed. I was just duplicating what already existed, hoping that we
> >> could sweep up this stuff after everything was in and the base
> >> infrastructure was stable.
> >
> > i'd prefer we scrub the crap now
>
> Yes, but how and when should this stuff be done, and in what way? is
> the ultimate question. If I were to toss in every dumb warning
> compiler flag imaginable (which believe it or not _is_ the default for
> the proprietary code we compile), my group in Cisco would never be
> able to compile LTP because of coding issues. How much is enough, and
> how much is too little?

create a mirrored set of W*FLAG variables in the top level and stick the 
defaults in there.  then all sub level should be punted.  for now, use -Wall 
only.  we can save the -Wextra/-Werror/etc... bs for a later date.

i.e. the top level .mk should have:
WFLAGS ?= -Wall
WCFLAGS ?= $(WFLAGS)
WCXXFLAGS ?= $(WFLAGS)
...
CFLAGS += $(WCFLAGS)
CXXFLAGS += $(WCXXFLAGS)
...

keep language-dedicated flags available because there are language-specific 
warnings that if added to the wrong language, you get even more warnings (gcc 
warning you that this warning flag is not appropriate ;x)

> >> > i dont see the point in declaring empty rules like "install: ;".  if
> >> > they're declared .PHONY, there is no need to add explicit rules to sub
> >> > Makefiles.
> >>
> >> They're there to avoid errors with targets not being found if I'm
> >> running recursive Make rules over the entire directory tree. So, I
> >> agree it's silly, but if you have a better idea, I'm all ears and I'll
> >> get on it ASAP. I'm trying to avoid cramming more variables into the
> >> Make system because it will only generate more confusion...
> >
> > let's look at testcases/kernel/include/Makefile.  how would a missing
> > install target here generate an error ?
>
> testcases/kernel calls install recursively. I don't want to create
> annoying subvariables for all, install, clean, and whatever other
> recursive target I can think of, because even though I know how to, it
> only serves to confuse and complicate the purpose of the system
> (that's part of the reason why I'm the only individual, apart from two
> others in a team of about 100, who can stumble around our complicated
> build system at work).

sorry, i'm still not following.  why would the default install target not work 
in testcases/kernel/include/Makefile ?  if there are no subdirs to recurse 
into and there are no default targets to compile, what would the default 
install do exactly ?
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 389 bytes --]

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize  autoconf logic
  2009-07-10  0:07         ` Mike Frysinger
@ 2009-07-11 21:55           ` Garrett Cooper
  2009-07-12  4:06             ` Garrett Cooper
  0 siblings, 1 reply; 10+ messages in thread
From: Garrett Cooper @ 2009-07-11 21:55 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list

On Thu, Jul 9, 2009 at 5:07 PM, Mike Frysinger<vapier@gentoo.org> wrote:
> On Thursday 09 July 2009 05:08:22 Garrett Cooper wrote:
>> On Wed, Jul 8, 2009 at 5:42 PM, Mike Frysinger wrote:
>> > On Wednesday 08 July 2009 20:21:11 Garrett Cooper wrote:
>> >> On Wed, Jul 8, 2009 at 4:53 PM, Mike Frysinger wrote:
>> > testcases/Makefile:
>> > i dont get all these xxx_DEPS variables and the install-testcases-bin
>> > target
>>
>> xxx_DEPS aren't used in typical situations. They are used in different
>> situations where one _must_ preserve dependency ordering. People
>> should NOT have to use these except with code generation, upper-level
>> target dependencies (my next stop after this all gets said and done,
>> e.g. if I do a submake from somewhere within testcases/kernel, I
>> better well have libltp.a built beforehand :)...), etc.
>
> yes, but in the patch you posted, i didnt see why any of those needed to be in
> the Makefile's in question.  i dont have a problem adding knobs, but i do when
> they're used incorrectly or not at all.
>
> i guess i'll wait until your follow up patch to check this stuff again
>
>> >> > why cant testcases/kernel/Makefile leverage these .mk files ?  the
>> >> > whole point was to get away from these custom written jobbies ...
>> >>
>> >> Some of these Makefiles get a bit ugly with the pre- and post- junk...
>> >> There are a small number of Makefiles that are haunted by this work,
>> >> but then again I did some more rework with the generic_trunk_target
>> >> define.
>> >
>> > so that means you'll fix the Makefile to use the .mk files
>>
>> Yes. Again, these are bad hacks to work around the fact that these are
>> initial commits, and the fact that the rest of the source tree isn't
>> up to date with the new system (that will take ~3 days with straight
>> work and verification, but I'd quote a week and a half because of
>> random junk that can get in the way of getting things done). Only in a
>> few key Makefiles are these hacks required. testcases/Makefile is just
>> one of these examples. Here's the comment:
>
> ok, transitional hacks which are commented should be fine.  i dont recall
> seeing this comment in the patch posted for review though ;).
>
>> >> > debugging/optimization/warning/stripping flags shouldnt be added in
>> >> > any Makefile that is being converted to these common .mk files.  same
>> >> > for any DEBUG_XXX flags.
>> >>
>> >> Agreed. I was just duplicating what already existed, hoping that we
>> >> could sweep up this stuff after everything was in and the base
>> >> infrastructure was stable.
>> >
>> > i'd prefer we scrub the crap now
>>
>> Yes, but how and when should this stuff be done, and in what way? is
>> the ultimate question. If I were to toss in every dumb warning
>> compiler flag imaginable (which believe it or not _is_ the default for
>> the proprietary code we compile), my group in Cisco would never be
>> able to compile LTP because of coding issues. How much is enough, and
>> how much is too little?
>
> create a mirrored set of W*FLAG variables in the top level and stick the
> defaults in there.  then all sub level should be punted.  for now, use -Wall
> only.  we can save the -Wextra/-Werror/etc... bs for a later date.
>
> i.e. the top level .mk should have:
> WFLAGS ?= -Wall
> WCFLAGS ?= $(WFLAGS)
> WCXXFLAGS ?= $(WFLAGS)
> ...
> CFLAGS += $(WCFLAGS)
> CXXFLAGS += $(WCXXFLAGS)
> ...
>
> keep language-dedicated flags available because there are language-specific
> warnings that if added to the wrong language, you get even more warnings (gcc
> warning you that this warning flag is not appropriate ;x)
>
>> >> > i dont see the point in declaring empty rules like "install: ;".  if
>> >> > they're declared .PHONY, there is no need to add explicit rules to sub
>> >> > Makefiles.
>> >>
>> >> They're there to avoid errors with targets not being found if I'm
>> >> running recursive Make rules over the entire directory tree. So, I
>> >> agree it's silly, but if you have a better idea, I'm all ears and I'll
>> >> get on it ASAP. I'm trying to avoid cramming more variables into the
>> >> Make system because it will only generate more confusion...
>> >
>> > let's look at testcases/kernel/include/Makefile.  how would a missing
>> > install target here generate an error ?
>>
>> testcases/kernel calls install recursively. I don't want to create
>> annoying subvariables for all, install, clean, and whatever other
>> recursive target I can think of, because even though I know how to, it
>> only serves to confuse and complicate the purpose of the system
>> (that's part of the reason why I'm the only individual, apart from two
>> others in a team of about 100, who can stumble around our complicated
>> build system at work).
>
> sorry, i'm still not following.  why would the default install target not work
> in testcases/kernel/include/Makefile ?  if there are no subdirs to recurse
> into and there are no default targets to compile, what would the default
> install do exactly ?

The way it was originally designed (by whoever.. dunno who), regen did
the equivalent to all, and all did the equivalent to install. Pretty
whacky, but that's the way it was.

I fixed the caller so it doesn't do jack for all, but instead directly
calls install, like it basically should.

I've had to do a lot of invasive surgery on the build over the past 4
hours... once I can get it to compile through clean -> all -> install,
without issues, I'll run a diff check on the generated files and
resubmit the patch.

Thanks,
-Garrett

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize  autoconf logic
  2009-07-11 21:55           ` Garrett Cooper
@ 2009-07-12  4:06             ` Garrett Cooper
  2009-07-12  5:15               ` Garrett Cooper
  0 siblings, 1 reply; 10+ messages in thread
From: Garrett Cooper @ 2009-07-12  4:06 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list

On Sat, Jul 11, 2009 at 2:55 PM, Garrett Cooper<yanegomi@gmail.com> wrote:
> On Thu, Jul 9, 2009 at 5:07 PM, Mike Frysinger<vapier@gentoo.org> wrote:
>> On Thursday 09 July 2009 05:08:22 Garrett Cooper wrote:
>>> On Wed, Jul 8, 2009 at 5:42 PM, Mike Frysinger wrote:
>>> > On Wednesday 08 July 2009 20:21:11 Garrett Cooper wrote:
>>> >> On Wed, Jul 8, 2009 at 4:53 PM, Mike Frysinger wrote:
>>> > testcases/Makefile:
>>> > i dont get all these xxx_DEPS variables and the install-testcases-bin
>>> > target
>>>
>>> xxx_DEPS aren't used in typical situations. They are used in different
>>> situations where one _must_ preserve dependency ordering. People
>>> should NOT have to use these except with code generation, upper-level
>>> target dependencies (my next stop after this all gets said and done,
>>> e.g. if I do a submake from somewhere within testcases/kernel, I
>>> better well have libltp.a built beforehand :)...), etc.
>>
>> yes, but in the patch you posted, i didnt see why any of those needed to be in
>> the Makefile's in question.  i dont have a problem adding knobs, but i do when
>> they're used incorrectly or not at all.
>>
>> i guess i'll wait until your follow up patch to check this stuff again
>>
>>> >> > why cant testcases/kernel/Makefile leverage these .mk files ?  the
>>> >> > whole point was to get away from these custom written jobbies ...
>>> >>
>>> >> Some of these Makefiles get a bit ugly with the pre- and post- junk...
>>> >> There are a small number of Makefiles that are haunted by this work,
>>> >> but then again I did some more rework with the generic_trunk_target
>>> >> define.
>>> >
>>> > so that means you'll fix the Makefile to use the .mk files
>>>
>>> Yes. Again, these are bad hacks to work around the fact that these are
>>> initial commits, and the fact that the rest of the source tree isn't
>>> up to date with the new system (that will take ~3 days with straight
>>> work and verification, but I'd quote a week and a half because of
>>> random junk that can get in the way of getting things done). Only in a
>>> few key Makefiles are these hacks required. testcases/Makefile is just
>>> one of these examples. Here's the comment:
>>
>> ok, transitional hacks which are commented should be fine.  i dont recall
>> seeing this comment in the patch posted for review though ;).
>>
>>> >> > debugging/optimization/warning/stripping flags shouldnt be added in
>>> >> > any Makefile that is being converted to these common .mk files.  same
>>> >> > for any DEBUG_XXX flags.
>>> >>
>>> >> Agreed. I was just duplicating what already existed, hoping that we
>>> >> could sweep up this stuff after everything was in and the base
>>> >> infrastructure was stable.
>>> >
>>> > i'd prefer we scrub the crap now
>>>
>>> Yes, but how and when should this stuff be done, and in what way? is
>>> the ultimate question. If I were to toss in every dumb warning
>>> compiler flag imaginable (which believe it or not _is_ the default for
>>> the proprietary code we compile), my group in Cisco would never be
>>> able to compile LTP because of coding issues. How much is enough, and
>>> how much is too little?
>>
>> create a mirrored set of W*FLAG variables in the top level and stick the
>> defaults in there.  then all sub level should be punted.  for now, use -Wall
>> only.  we can save the -Wextra/-Werror/etc... bs for a later date.
>>
>> i.e. the top level .mk should have:
>> WFLAGS ?= -Wall
>> WCFLAGS ?= $(WFLAGS)
>> WCXXFLAGS ?= $(WFLAGS)
>> ...
>> CFLAGS += $(WCFLAGS)
>> CXXFLAGS += $(WCXXFLAGS)
>> ...
>>
>> keep language-dedicated flags available because there are language-specific
>> warnings that if added to the wrong language, you get even more warnings (gcc
>> warning you that this warning flag is not appropriate ;x)
>>
>>> >> > i dont see the point in declaring empty rules like "install: ;".  if
>>> >> > they're declared .PHONY, there is no need to add explicit rules to sub
>>> >> > Makefiles.
>>> >>
>>> >> They're there to avoid errors with targets not being found if I'm
>>> >> running recursive Make rules over the entire directory tree. So, I
>>> >> agree it's silly, but if you have a better idea, I'm all ears and I'll
>>> >> get on it ASAP. I'm trying to avoid cramming more variables into the
>>> >> Make system because it will only generate more confusion...
>>> >
>>> > let's look at testcases/kernel/include/Makefile.  how would a missing
>>> > install target here generate an error ?
>>>
>>> testcases/kernel calls install recursively. I don't want to create
>>> annoying subvariables for all, install, clean, and whatever other
>>> recursive target I can think of, because even though I know how to, it
>>> only serves to confuse and complicate the purpose of the system
>>> (that's part of the reason why I'm the only individual, apart from two
>>> others in a team of about 100, who can stumble around our complicated
>>> build system at work).
>>
>> sorry, i'm still not following.  why would the default install target not work
>> in testcases/kernel/include/Makefile ?  if there are no subdirs to recurse
>> into and there are no default targets to compile, what would the default
>> install do exactly ?
>
> The way it was originally designed (by whoever.. dunno who), regen did
> the equivalent to all, and all did the equivalent to install. Pretty
> whacky, but that's the way it was.
>
> I fixed the caller so it doesn't do jack for all, but instead directly
> calls install, like it basically should.
>
> I've had to do a lot of invasive surgery on the build over the past 4
> hours... once I can get it to compile through clean -> all -> install,
> without issues, I'll run a diff check on the generated files and
> resubmit the patch.

Sorry. Finding more and more random arse build issues. I *hope* I can
have a patch out by midnight PST, pending I don't run into too many
weird roadblocks.

So much was being hidden because set -e wasn't being run with certain
sections of the source tree when for-loops were used :(...

Thanks,
-Garrett

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize  autoconf logic
  2009-07-12  4:06             ` Garrett Cooper
@ 2009-07-12  5:15               ` Garrett Cooper
  0 siblings, 0 replies; 10+ messages in thread
From: Garrett Cooper @ 2009-07-12  5:15 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list

On Sat, Jul 11, 2009 at 9:06 PM, Garrett Cooper<yanegomi@gmail.com> wrote:
> On Sat, Jul 11, 2009 at 2:55 PM, Garrett Cooper<yanegomi@gmail.com> wrote:
>> On Thu, Jul 9, 2009 at 5:07 PM, Mike Frysinger<vapier@gentoo.org> wrote:
>>> On Thursday 09 July 2009 05:08:22 Garrett Cooper wrote:
>>>> On Wed, Jul 8, 2009 at 5:42 PM, Mike Frysinger wrote:
>>>> > On Wednesday 08 July 2009 20:21:11 Garrett Cooper wrote:
>>>> >> On Wed, Jul 8, 2009 at 4:53 PM, Mike Frysinger wrote:
>>>> > testcases/Makefile:
>>>> > i dont get all these xxx_DEPS variables and the install-testcases-bin
>>>> > target
>>>>
>>>> xxx_DEPS aren't used in typical situations. They are used in different
>>>> situations where one _must_ preserve dependency ordering. People
>>>> should NOT have to use these except with code generation, upper-level
>>>> target dependencies (my next stop after this all gets said and done,
>>>> e.g. if I do a submake from somewhere within testcases/kernel, I
>>>> better well have libltp.a built beforehand :)...), etc.
>>>
>>> yes, but in the patch you posted, i didnt see why any of those needed to be in
>>> the Makefile's in question.  i dont have a problem adding knobs, but i do when
>>> they're used incorrectly or not at all.
>>>
>>> i guess i'll wait until your follow up patch to check this stuff again
>>>
>>>> >> > why cant testcases/kernel/Makefile leverage these .mk files ?  the
>>>> >> > whole point was to get away from these custom written jobbies ...
>>>> >>
>>>> >> Some of these Makefiles get a bit ugly with the pre- and post- junk...
>>>> >> There are a small number of Makefiles that are haunted by this work,
>>>> >> but then again I did some more rework with the generic_trunk_target
>>>> >> define.
>>>> >
>>>> > so that means you'll fix the Makefile to use the .mk files
>>>>
>>>> Yes. Again, these are bad hacks to work around the fact that these are
>>>> initial commits, and the fact that the rest of the source tree isn't
>>>> up to date with the new system (that will take ~3 days with straight
>>>> work and verification, but I'd quote a week and a half because of
>>>> random junk that can get in the way of getting things done). Only in a
>>>> few key Makefiles are these hacks required. testcases/Makefile is just
>>>> one of these examples. Here's the comment:
>>>
>>> ok, transitional hacks which are commented should be fine.  i dont recall
>>> seeing this comment in the patch posted for review though ;).
>>>
>>>> >> > debugging/optimization/warning/stripping flags shouldnt be added in
>>>> >> > any Makefile that is being converted to these common .mk files.  same
>>>> >> > for any DEBUG_XXX flags.
>>>> >>
>>>> >> Agreed. I was just duplicating what already existed, hoping that we
>>>> >> could sweep up this stuff after everything was in and the base
>>>> >> infrastructure was stable.
>>>> >
>>>> > i'd prefer we scrub the crap now
>>>>
>>>> Yes, but how and when should this stuff be done, and in what way? is
>>>> the ultimate question. If I were to toss in every dumb warning
>>>> compiler flag imaginable (which believe it or not _is_ the default for
>>>> the proprietary code we compile), my group in Cisco would never be
>>>> able to compile LTP because of coding issues. How much is enough, and
>>>> how much is too little?
>>>
>>> create a mirrored set of W*FLAG variables in the top level and stick the
>>> defaults in there.  then all sub level should be punted.  for now, use -Wall
>>> only.  we can save the -Wextra/-Werror/etc... bs for a later date.
>>>
>>> i.e. the top level .mk should have:
>>> WFLAGS ?= -Wall
>>> WCFLAGS ?= $(WFLAGS)
>>> WCXXFLAGS ?= $(WFLAGS)
>>> ...
>>> CFLAGS += $(WCFLAGS)
>>> CXXFLAGS += $(WCXXFLAGS)
>>> ...
>>>
>>> keep language-dedicated flags available because there are language-specific
>>> warnings that if added to the wrong language, you get even more warnings (gcc
>>> warning you that this warning flag is not appropriate ;x)
>>>
>>>> >> > i dont see the point in declaring empty rules like "install: ;".  if
>>>> >> > they're declared .PHONY, there is no need to add explicit rules to sub
>>>> >> > Makefiles.
>>>> >>
>>>> >> They're there to avoid errors with targets not being found if I'm
>>>> >> running recursive Make rules over the entire directory tree. So, I
>>>> >> agree it's silly, but if you have a better idea, I'm all ears and I'll
>>>> >> get on it ASAP. I'm trying to avoid cramming more variables into the
>>>> >> Make system because it will only generate more confusion...
>>>> >
>>>> > let's look at testcases/kernel/include/Makefile.  how would a missing
>>>> > install target here generate an error ?
>>>>
>>>> testcases/kernel calls install recursively. I don't want to create
>>>> annoying subvariables for all, install, clean, and whatever other
>>>> recursive target I can think of, because even though I know how to, it
>>>> only serves to confuse and complicate the purpose of the system
>>>> (that's part of the reason why I'm the only individual, apart from two
>>>> others in a team of about 100, who can stumble around our complicated
>>>> build system at work).
>>>
>>> sorry, i'm still not following.  why would the default install target not work
>>> in testcases/kernel/include/Makefile ?  if there are no subdirs to recurse
>>> into and there are no default targets to compile, what would the default
>>> install do exactly ?
>>
>> The way it was originally designed (by whoever.. dunno who), regen did
>> the equivalent to all, and all did the equivalent to install. Pretty
>> whacky, but that's the way it was.
>>
>> I fixed the caller so it doesn't do jack for all, but instead directly
>> calls install, like it basically should.
>>
>> I've had to do a lot of invasive surgery on the build over the past 4
>> hours... once I can get it to compile through clean -> all -> install,
>> without issues, I'll run a diff check on the generated files and
>> resubmit the patch.
>
> Sorry. Finding more and more random arse build issues. I *hope* I can
> have a patch out by midnight PST, pending I don't run into too many
> weird roadblocks.
>
> So much was being hidden because set -e wasn't being run with certain
> sections of the source tree when for-loops were used :(...

Ok, here's version two of the previous diff.

Summary:
1. Logic fixes to multiple Makefiles.
2. Address majority of the issues brought up by Mike Frysinger.
3. Testcases now refer to testcases.mk instead of directly calling
master_includes.mk, so additional testcases/ directory logic can be
applied to the Makefile.
4. Move tool/genload/stress.c sources to tool/genload/genload.c to
avoid hackish Makefile logic.

Index: Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/Makefile,v
retrieving revision 1.39
diff -u -r1.39 Makefile
--- Makefile	25 Mar 2009 06:17:48 -0000	1.39
+++ Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,147 +1,165 @@
-# 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
+#
+
+# 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 include/mk/automake.mk
+include include/mk/master_include.mk
+
+# Only check for numa when not cross-compiling.
+ifeq ($(strip $(CROSS_COMPILE)),1)
+# Disable all undetectable cross-compilation required items.
+SKIP_IDCHECK		:= 1
+endif

-ifdef CROSS_COMPILE
-CROSS_COMPILER = $(CROSS_COMPILE)
+# 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 include/config.h),)
+.DEFAULT_GOAL		:= help
+else
+.DEFAULT_GOAL		:= all
 endif
-ifdef CROSS_COMPILER
-CC=$(CROSS_COMPILER)gcc
-AR=$(CROSS_COMPILER)ar
-RANLIB=$(CROSS_COMPILER)ranlib
-endif
-
-HAS_NUMA=$(shell sh tools/scripts/numa_test.sh)
-
-export CFLAGS += -Wall $(CROSS_CFLAGS)
-export CC AR RANLIB CPPFLAGS LDFLAGS HAS_NUMA
-
--include config.mk
-
-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
-
-	@./IDcheck.sh
-
-libltp.a: config.h
-	@$(MAKE) -C lib $@
-
-uclinux: uclinux_libltp.a
-	#@$(MAKE) -C pan all
-	@$(MAKE) -C testcases uclinux
-	@$(MAKE) -C tools all
-	@echo
-	@echo "*******************************************************"
-	@echo "** You now need to do a make uclinux_install as root **"
-	@echo "*******************************************************"
-
-uclinux_install: uclinux
-	@$(MAKE) -C testcases uclinux_install
-	@$(MAKE) -C tools install
-	@./IDcheck.sh

-uclinux_libltp.a:
-	@$(MAKE) -C lib UCLINUX=1 libltp.a
+export HAS_NUMA

-menuconfig:
-	@./ltpmenu
+vpath %.am		$(top_srcdir)/m4
+vpath %.default		$(top_srcdir)/include
+vpath %.h		$(top_srcdir)/include
+vpath %.in		$(top_srcdir)/include
+vpath %.m4		$(top_srcdir)/m4
+vpath %.mk		$(top_srcdir)/mk:$(top_srcdir)/mk/include
+
+# User wants uclinux binaries?
+UCLINUX			?= 0
+
+# 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
+
+# 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).
+
+# We're not using uclinux based targets (default).
+ifneq ($(UCLINUX),1)
+COMMON_TARGETS		:= pan utils
+INSTALL_TARGETS		:= doc m4
+endif

-clean: ac-clean
-	@$(MAKE) -C lib $@
-	@$(MAKE) -C pan $@
-	@$(MAKE) -C tools $@
-	@$(MAKE) -C testcases $@
-	@$(MAKE) -C utils $@
+COMMON_TARGETS		+= testcases tools
+INSTALL_TARGETS		+= $(COMMON_TARGETS)
+CLEAN_TARGETS		+= $(COMMON_TARGETS) include lib

-distclean: clean ac-distclean
-	@$(MAKE) -C include $@
+CLEAN_TARGETS		:= $(addsuffix -clean,$(CLEAN_TARGETS))
+INSTALL_TARGETS		:= $(addsuffix -install,$(INSTALL_TARGETS))
+MAKE_TARGETS		:= $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS)))

-maintainer-clean: distclean ac-maintainer-clean
-	@$(MAKE) -C include $@
+# 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))

-package:
-	rpmbuild -ba ltp-devel.spec
+$(MAKE_TARGETS): lib-install

+## Pattern based subtarget rules.
+lib-install: lib-all

-#
-# Autotools related
-#
-.PHONY: autotools
-autotools: aclocal autoconf autoheader automake
+lib-all: config.h $(top_srcdir)/include/mk/config.mk include-install

-.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
+$(MAKE_TARGETS) lib-all: %-all:
+	$(MAKE) -C $* all

+#
+# Let's not conflict with ac-clean, maintainer-clean, etc, so.
 #
-# Help
+# Make sure the Makefile already exists before cd'ing to the directory to avoid
+# incomplete source trees /
 #
+$(CLEAN_TARGETS): %-clean: %/Makefile
+	-$(MAKE) -C $* clean
+
+# include-install is separate to avoid creating a circular dependency below in
+# the install target.
+$(INSTALL_TARGETS) include-install lib-install: %-install:
+	$(MAKE) -C $* install
+
+INSTALL_DIR		= $(DESTDIR)/$(prefix)
+
+clean: $(CLEAN_TARGETS)
+ifneq ($(wildcard $(INSTALL_DIR)),/)
+	-$(RM) -Rf "$(INSTALL_DIR)"
+endif
+
+$(INSTALL_DIR):
+	mkdir -p $@
+
+RUNLTP			:= $(INSTALL_DIR)/runltp
+
+$(RUNLTP): $(top_srcdir)/runltp $(INSTALL_DIR)
+	install -m 00755 "$(firstword $^)" "$@"
+
+INSTALL_TARGETS		+= $(RUNLTP)
+
+$(INSTALL_TARGETS): all $(INSTALL_DIR)
+
+## Install
+install: $(INSTALL_TARGETS)
+ifneq ($(SKIP_IDCHECK),0)
+	CREATE_ENTRIES=$(CREATE_ENTRIES) \
+	DESTDIR=$(DESTDIR) \
+	$(top_srcdir)/IDcheck.sh
+else
+	echo "*******************************************************"
+	echo "** Will not run IDcheck.sh (SKIP_IDCHECK not set to 0)."
+	echo "*******************************************************"
+endif
+
+# The empty line above was intentional. Do _not_ delete.
+
+## Misc targets.
+
+## 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
+
+## Menuconfig
+menuconfig:
+	@$(SHELL) $(top_srcdir)/ltpmenu
+
+## Package
+package:
+	@$(RPMBUILD) -ba ltp-devel.spec
+
+## End misc targets.
Index: README.mk-user
===================================================================
RCS file: README.mk-user
diff -N README.mk-user
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ README.mk-user	12 Jul 2009 05:11:28 -0000
@@ -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
Index: include/mk/automake.mk
===================================================================
RCS file: include/mk/automake.mk
diff -N include/mk/automake.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ include/mk/automake.mk	12 Jul 2009 05:11:28 -0000
@@ -0,0 +1,74 @@
+#
+#    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)
+	$(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 $^ $@
+
+.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
+	$(RM) -f ltp-devel.spec README.ltp-devel include/mk/config.mk
+	$(RM) -f lib/ltp.pc m4/Makefile
+ac-distclean: ac-clean
+ac-maintainer-clean: ac-distclean
+	$(RM) -f aclocal.m4 configure $(AUTOMAKE_FILES) m4/Makefile.in
+	$(RM) -f config.h
+
+distclean: clean ac-distclean include-clean
+
+maintainer-clean: distclean ac-maintainer-clean
Index: lib/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/lib/Makefile,v
retrieving revision 1.16
diff -u -r1.16 Makefile
--- lib/Makefile	3 Apr 2009 06:58:18 -0000	1.16
+++ lib/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,26 +1,44 @@
+#
+#    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		?= ..
+
+include $(top_srcdir)/include/mk/lib.mk

-CFLAGS+= -Wall
-CPPFLAGS+= -I../include
 ifeq ($(shell uname -s),HP-UX)
-CFLAGS+=-Ae -D_LARGEFILE64_SOURCE +DA1.1
+CFLAGS			+=-Ae -D_LARGEFILE64_SOURCE +DA1.1
 endif
 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))
-
-$(TARGET): $(OBJS)
-	$(AR) -cr $@ $^
-
-clean:
-	rm -f $(TARGET) $(OBJS)
-
-install: $(TARGET)
-	install -D -m 644 $(TARGET) $(DESTDIR)/$(PREFIX)/lib$(LIBSUFFIX)/$(TARGET)
-	install -D -m 644 ltp.pc $(DESTDIR)/$(PREFIX)/share/pkgconfig/ltp.pc

+LIB			:= libltp.a
+
+pc_file			:= $(DESTDIR)/$(datarootdir)/pkgconfig/ltp.pc
+
+INSTALL_TARGETS		:= $(pc_file)
+
+$(pc_file):
+	test -d "$(@D)" || mkdir -p "$(@D)"
+	install -m $(INSTALL_MODE) "$(srcdir)/$(@F)" "$@"
+
+$(eval $(lib_target))
Index: testcases/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/Makefile,v
retrieving revision 1.16
diff -u -r1.16 Makefile
--- testcases/Makefile	30 Sep 2008 13:32:59 -0000	1.16
+++ testcases/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,21 +1,73 @@
-	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`
-UCLINUX_SUBDIRS = kernel
-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
-
-install:
-	mkdir -p bin
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
-
-uclinux:
-	@set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux; done
-
-uclinux_install:
-	mkdir -p bin
-	@set -e; for i in $(UCLINUX_SUBDIRS); \
-		do $(MAKE) -C $$i uclinux_install ; done
-
-clean:
-	rm -rf bin/
-	@set -e; for i in $(SUBDIRS) ; do $(MAKE) -C $$i clean ; 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
+#

+top_srcdir		?= ..
+
+include $(top_srcdir)/include/mk/master_include.mk
+
+.PHONY: bin-clean install-testcases-bin
+
+ifeq ($(UCLINUX),1)
+FILTER_OUT_DIRS		:= audit-test DOTS kdump open% pounder realtime
+else
+SUBDIRS			:= kernel
+endif
+
+CLEAN_DEPS		:= bin-clean
+
+INSTALL_DIR		:= testcases/bin
+
+MAKE_DEPS		:= bin
+
+POSTINSTALL_DEPS	:= install-testcases-bin
+
+#
+# XXX (garrcoop):
+#
+# bin, bin-clean, and install-testcases-bin are only here for compatibility
+# until all of the Makefiles properly install files in $(DESTDIR)/$(prefix)/...
+# using master_rules.mk, and similar behavior is properly emulated in the
+# top-level Makefiles for larger components (ballista and open_posix_testsuite
+# for instance).
+#
+bin:
+	mkdir -p $@
+
+bin-clean:
+	$(RM) -Rf bin
+
+# Don't bother doing the wildcard and generate the following rules if we're
+# not installing anything.
+ifeq ($(MAKECMDGOALS),install)
+TC_BIN_INSTALL_FILES	:= $(wildcard bin/*)
+
+install-testcases-bin: $(TC_BIN_INSTALL_FILES)
+
+define backwards_compat_install
+$(DESTDIR)/$(prefix)/$(INSTALL_DIR)/$(notdir $(1)): $(1)
+	install -m 00755 "$^" "$$@"
+endef
+
+$(foreach tc_bin_install_file,$(eval $(call
backwards_compat_install,$(tc_bin_install_file))),$(TC_BIN_INSTALL_FILES))
+endif
+
+$(eval $(generic_trunk_target))
Index: testcases/kernel/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/Makefile,v
retrieving revision 1.19
diff -u -r1.19 Makefile
--- testcases/kernel/Makefile	26 Feb 2009 11:32:30 -0000	1.19
+++ testcases/kernel/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,17 +1,42 @@
-SUBDIRS = power_management numa containers controllers connectors
include fs io ipc mem pty sched security syscalls timers
-UCLINUX_SUBDIRS = include syscalls
+#
+#    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
+#

-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/master_include.mk

-uclinux:
-	@set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux ; done
+ifneq ($(UCLINUX),1)
+# By some stroke of luck my system doesn't have mm.h support. Interesting...
+#SUBDIRS		:= power_management numa containers controllers connectors fs\
+		   mem io ipc pty sched security syscalls timers
+SUBDIRS		:= power_management numa containers controllers connectors fs\
+		   io ipc pty sched security syscalls timers
+else
+SUBDIRS		:= syscalls
+endif

-uclinux_install:
-	@set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux_install ; done
+trunk-all: $(includedir)/linux_syscall_numbers.h

-clean:
-	@set -e; for i in $(SUBDIRS) timers; do $(MAKE) -C $$i clean ; done
+$(includedir)/linux_syscall_numbers.h:
+	$(MAKE) -C include install
+
+$(eval $(generic_trunk_target))
Index: testcases/kernel/controllers/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/controllers/Makefile,v
retrieving revision 1.11
diff -u -r1.11 Makefile
--- testcases/kernel/controllers/Makefile	15 Jun 2009 18:53:06 -0000	1.11
+++ testcases/kernel/controllers/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,79 +1,105 @@
+#
+#    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
+#
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/master_include.mk
+
+SUBDIRS			:=
+
 ifdef CROSS_COMPILE
-CHECK_CGROUP := $(shell test -f
$(TARGET_DIR)/usr/include/linux/cgroupstats.h && echo 'cgroup')
+CHECK_CGROUP := $(shell test -f
$(DESTDIR)/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)
 endif

-ifdef CROSS_COMPILE
+ifeq ($(CROSS_COMPILE),1)	# CROSS_COMPILE == 1
 ifeq ($(CHECK_CGROUP),cgroup)
-SUBDIRS += cgroup
-SUBDIRS += cpuctl
-SUBDIRS += memctl
-SUBDIRS += io-throttle
-SUBDIRS += freezer
-SUBDIRS += cpuset
+SUBDIRS += cgroup cpuctl cpuset freezer io-throttle memctl
 else
 $(info "Kernel is not compiled with control cgroup support")
 endif
-else
+else				# CROSS_COMPILE != 1
+
+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)
+
 ifeq ($(CHECK_CGROUP),cgroup)
 SUBDIRS += cgroup
 else
-$(info "Kernel is not compiled with control cgroup support")
+$(info Kernel is not compiled with control cgroup support)
 endif

 ifeq ($(CHECK_MEMCTL),memory)
 SUBDIRS += memcg
 else
-$(info "Kernel is not compiled with memory resource controller support")
+$(info Kernel is not compiled with memory resource controller support)
 endif

 ifeq ($(CHECK_CPUCTL),cpu)
 SUBDIRS += cpuctl
 else
-$(info "Kernel is not compiled with cpu controller support")
+$(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")
+$(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")
+$(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")
+$(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
+$(info Kernel is not compiled with cpuset resource controller support)
 endif
+endif				# END: CROSS_COMPILE

-# If at least one of the controllers is available then build libcontrollers.
-ifneq ($(SUBDIRS),)
-SUBDIRS := libcontrollers $(SUBDIRS)
-endif
+LIB			:= $(libdir)/libcontrollers.a
+LIBDIR			:= libcontrollers
+
+# No need to do this now, because we define SUBDIRS explicitly, but just in
+# case someone adds the reference again by accident..
+FILTER_OUT_DIRS		:= $(LIBDIR)

-.PHONY: all install clean
+INSTALL_TARGETS		:= test_controllers.sh

-all:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done
+# 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):
+	$(MAKE) -C $(srcdir)/$(LIBDIR) all
+	$(MAKE) -C $(srcdir)/$(LIBDIR) install

-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
+MAKE_DEPS		:= $(LIB)

-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@ ; done
+$(eval $(generic_trunk_target))
Index: testcases/kernel/controllers/Makefile.inc
===================================================================
RCS file: testcases/kernel/controllers/Makefile.inc
diff -N testcases/kernel/controllers/Makefile.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testcases/kernel/controllers/Makefile.inc	12 Jul 2009 05:11:28 -0000
@@ -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!!!
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/master_include.mk
+
+HEADER_FILES		:= $(wildcard $(srcdir)/*.h)
+
+LIB			:= $(libdir)/libcontrollers.a
+
+LIBDIR			:= libcontrollers
+
+# 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):
+	$(MAKE) -C $(srcdir)/../$(LIBDIR) all
+	$(MAKE) -C $(srcdir)/../$(LIBDIR) install
+
+LDLIBS			+= -lcpu_set
+MAKE_DEPS		:= $(LIB)
+
+# vim: syntax=make
Index: testcases/kernel/controllers/cpuset/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/controllers/cpuset/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/controllers/cpuset/Makefile	23 Jun 2009 14:18:16 -0000	1.3
+++ testcases/kernel/controllers/cpuset/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,17 +1,41 @@
-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;
-
-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;
+#
+#    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
+#

-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/master_include.mk
+
+LIB			:= $(libdir)/libcpu_set.a
+
+LIBDIR			:= cpuset_lib
+
+FILTER_OUT_DIRS		:= $(LIBDIR)
+
+# 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):
+	$(MAKE) -C $(srcdir)/$(LIBDIR) all
+	$(MAKE) -C $(srcdir)/$(LIBDIR) install
+
+MAKE_DEPS		:= $(LIB)
+
+$(eval $(generic_trunk_target))
Index: testcases/kernel/controllers/cpuset/Makefile.inc
===================================================================
RCS file: testcases/kernel/controllers/cpuset/Makefile.inc
diff -N testcases/kernel/controllers/cpuset/Makefile.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testcases/kernel/controllers/cpuset/Makefile.inc	12 Jul 2009 05:11:28 -0000
@@ -0,0 +1,45 @@
+#
+#    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
+#
+
+# DO NOT USE THIS FILE FOR cpuset / cpuset_lib!!!
+
+top_srcdir		?= ../../../../..
+
+include	$(top_srcdir)/include/mk/master_include.mk
+
+LIB			:= $(libdir)/libcpu_set.a
+
+LIBDIR			:= cpuset_lib
+
+# 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):
+	$(MAKE) -C $(srcdir)/../$(LIBDIR) all
+	$(MAKE) -C $(srcdir)/../$(LIBDIR) install
+
+LDLIBS			+= -lcpu_set
+MAKE_DEPS		:= $(LIB)
+
+# We want to install the bourne scripts -- so let's make that the default.
+INSTALL_TARGETS		?= $(wildcard $(srcdir)/*.sh)
+
+# vim: syntax=make
Index: testcases/kernel/fs/proc/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/fs/proc/Makefile,v
retrieving revision 1.5
diff -u -r1.5 Makefile
--- testcases/kernel/fs/proc/Makefile	5 Feb 2009 11:18:58 -0000	1.5
+++ testcases/kernel/fs/proc/Makefile	12 Jul 2009 05:11:28 -0000
@@ -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)
+$(eval $(generic_leaf_target))
Index: testcases/kernel/fs/scsi/ltpscsi/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/fs/scsi/ltpscsi/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/fs/scsi/ltpscsi/Makefile	23 Jun 2009 14:18:17 -0000	1.3
+++ testcases/kernel/fs/scsi/ltpscsi/Makefile	12 Jul 2009 05:11:28 -0000
@@ -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
Index: testcases/kernel/include/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/include/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- testcases/kernel/include/Makefile	26 Feb 2009 11:32:31 -0000	1.7
+++ testcases/kernel/include/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,19 +1,38 @@
-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
+#
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/master_include.mk

-../../../include/linux_syscall_numbers.h: linux_syscall_numbers.h
-	ln -sf ../testcases/kernel/include/linux_syscall_numbers.h ../../../include/
+DEFAULT_GOAL		:= install

-clean distclean:
-	rm -f linux_syscall_numbers.h
-	rm -f ../../../include/linux_syscall_numbers.h
+PREINSTALL_DEPS		:= regen

-install uclinux_install:
-	@true
+INSTALL_DIR		:= $(includedir)

-linux_syscall_numbers.h: *.in regen.sh
-	$(MAKE) regen
+INSTALL_TARGETS		:= linux_syscall_numbers.h

 regen:
-	./regen.sh
+	@./regen.sh

-.PHONY: all clean distclean install regen
+$(eval $(generic_leaf_target))
Index: testcases/kernel/io/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/io/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/io/Makefile	29 Dec 2008 11:02:21 -0000	1.6
+++ testcases/kernel/io/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,10 +1,36 @@
-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/master_include.mk

-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+SUBDIRS 		:= direct_io disktest stress_cd stress_floppy \
+			   writetest
+
+# Don't even bother traversing down aio if the system doesn't have -laio
+# support.
+ifneq ($(AIO_LIBS),)
+SUBDIRS			+= aio
+endif
+
+$(eval $(generic_trunk_target))
Index: testcases/kernel/io/aio/aio01/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/io/aio/aio01/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- testcases/kernel/io/aio/aio01/Makefile	28 Jan 2009 06:43:09 -0000	1.2
+++ testcases/kernel/io/aio/aio01/Makefile	12 Jul 2009 05:11:28 -0000
@@ -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))
-
-all: $(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

+LDLIBS			+= $(AIO_LIBS)

+$(eval $(generic_leaf_target))
Index: testcases/kernel/io/aio/aio02/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/io/aio/aio02/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/io/aio/aio02/Makefile	18 Jun 2009 17:06:59 -0000	1.6
+++ testcases/kernel/io/aio/aio02/Makefile	12 Jul 2009 05:11:28 -0000
@@ -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)
+srcdir			?= ../../../../..

-$(PROGS): %: %.c $(HARNESS_SRCS) Makefile
-	$(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c $(LDFLAGS)
+include $(srcdir)/include/mk/testcases.mk

-clean:
-	rm -f $(PROGS) *.o runtests.out rofile wofile rwfile
+LDLIBS			+= $(AIO_LIBS)

-install:
+# foo.
+MAKE_TARGETS		:= $(patsubst %.c,%,$(wildcard cases/*.c))
+HARNESS_SRCS		:= main.c
+# io_queue.c
+
+#-lpthread -lrt
+$(MAKE_TARGETS): %: %.c $(HARNESS_SRCS)
+$(MAKE_TARGETS): CPPFLAGS += -DTEST_NAME=\"$(patsubst %.c,%,$(notdir $<))\"

+$(eval $(generic_leaf_target))
Index: testcases/kernel/io/stress_floppy/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/io/stress_floppy/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- testcases/kernel/io/stress_floppy/Makefile	28 Mar 2003 18:27:48 -0000	1.8
+++ testcases/kernel/io/stress_floppy/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,13 +1,35 @@
-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

+CLEAN_TARGETS		:= 10*K_file dumpdir
+
+MAKE_TARGETS		:=
+
+INSTALL_DEPS		:= generate
+# dumpdir's a directory.
+RM			+= -r
+
+.PHONY: generate
 generate:
-	./generate.sh
+	@./generate.sh

-clean:
-	rm -rf 10*K_file dumpdir
+$(eval $(generic_leaf_target))
Index: testcases/kernel/security/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/security/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/security/Makefile	28 Apr 2009 07:04:38 -0000	1.6
+++ testcases/kernel/security/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,12 +1,31 @@
-SUBDIRS = mmc_security filecaps integrity cap_bound
+#
+#  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
+include	$(top_srcdir)/include/mk/master_include.mk

-clean:
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
+OPT_CFLAGS		+= -O
+DEBUG_LDFLAGS		+= -s

+# There are the inverse directories of the previously incarnation of this
+# Makefile. Don't know if these tests are broken, either at runtime or at
+# compile time.
+FILTER_OUT_DIRS		:= digsig selinux-testsuite smack

+$(eval $(generic_trunk_target))
Index: testcases/kernel/security/integrity/ima/src/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/security/integrity/ima/src/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- testcases/kernel/security/integrity/ima/src/Makefile	31 Mar 2009
13:58:14 -0000	1.1
+++ testcases/kernel/security/integrity/ima/src/Makefile	12 Jul 2009
05:11:28 -0000
@@ -1,16 +1,37 @@
-include ../../../../../../config.mk
+#
+#    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
+#

-ifeq ($(CRYPTO_LIB),-lcrypto)
-	TARGETS=ima_mmap ima_measure ima_boot_aggregate
-	LDLIBS += $(CRYPTO_LIB)
-else
-	TARGETS=ima_mmap
+srcdir			?= ../../../../../..
+
+include $(srcdir)/include/mk/master_include.mk
+
+ifeq ($(CRYPTO_LIB),)
+LDLIBS			+= $(CRYPTO_LIB)
+MAKE_TARGETS		:= ima_mmap
 endif

-all: $(TARGETS)
+$(warning $(CRYPTO_LIB))
+$(warning $(MAKE_TARGETS))

-install:
-	@set -e; for i in $(TARGETS); do ln -f $$i ../../../../../bin/$$i; done
+$(eval $(generic_leaf_target))

-clean:
-	rm -f $(TARGETS)
+$(warning $(MAKE_TARGETS))
Index: testcases/kernel/syscalls/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/Makefile,v
retrieving revision 1.63
diff -u -r1.63 Makefile
--- testcases/kernel/syscalls/Makefile	26 Feb 2009 11:37:28 -0000	1.63
+++ testcases/kernel/syscalls/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,55 +1,34 @@
 #
-#  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.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
-#
-#  You should have 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) 2009, Cisco Systems Inc.
 #
-
-DEBUG_CFLAGS=-O
-DEBUG_LDFLAGS=-s
-CFLAGS+=-I../../include -g -Wall
-LDLIBS+=
-EXCLUDE_DIR=epoll
-
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
 #
-# Commented this out since there are directories here we don't want
built by default
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    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
 #
-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"`
-
-all:
-	@set -e; for i in $(SUBDIR); do \
-		$(MAKE) -C $$i  all; \
-	done

-install:
-	@set -e; for i in $(SUBDIR); do \
-		$(MAKE) -C $$i  install; \
-	done
+top_srcdir		?= ../../..

-uclinux:
-	@set -e; for i in $(UCLINUX_SUBDIR); do \
-		$(MAKE) -C $$i UCLINUX=1 all; \
-	done
+include	$(top_srcdir)/include/mk/master_include.mk

-uclinux_install:
-	@set -e; for i in $(UCLINUX_SUBDIR); do \
-		$(MAKE) -C $$i UCLINUX=1 install; \
-	done
+FILTER_OUT_SUBDIRS	:= epoll

-clean:
-	@set -e; for i in $(SUBDIR); do \
-		$(MAKE) -C $$i  clean; \
-	done
+ifeq ($(UCLINUX),1)
+FILTER_OUT_SUBDIRS	+= capget capset chmod chown clone fork getcontext \
+			   llseek nftw profil remap_file_pages
+endif

+$(eval $(generic_trunk_target))
Index: testcases/kernel/syscalls/eventfd/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/eventfd/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/syscalls/eventfd/Makefile	16 Jan 2009 09:03:14 -0000	1.6
+++ testcases/kernel/syscalls/eventfd/Makefile	12 Jul 2009 05:11:28 -0000
@@ -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
-
+$(eval $(generic_leaf_target))
Index: testcases/kernel/syscalls/io_cancel/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_cancel/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- testcases/kernel/syscalls/io_cancel/Makefile	20 Jan 2009 10:48:41 -0000	1.4
+++ testcases/kernel/syscalls/io_cancel/Makefile	12 Jul 2009 05:11:28 -0000
@@ -20,19 +20,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #

+srcdir			?= ../../../..

-include ../../../../config.mk
+include $(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)
+$(eval $(generic_leaf_target))
Index: testcases/kernel/syscalls/io_destroy/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_destroy/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/syscalls/io_destroy/Makefile	20 Jan 2009 10:48:41 -0000	1.3
+++ testcases/kernel/syscalls/io_destroy/Makefile	12 Jul 2009 05:11:28 -0000
@@ -20,15 +20,15 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #

+srcdir			?= ../../../..

-include ../../../../config.mk
+include $(srcdir)/include/mk/master_include.mk

+CFLAGS 			+= -I$(srcdir)/include -Wall
+LDFLAGS			+= $(AIO_LIBS) -L$(srcdir)/lib
+LDLIBS			+= -lltp

-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
+TARGETS 		:= $(patsubst %.c,%,$(wildcard *.c))

 all: $(TARGETS)

Index: testcases/kernel/syscalls/io_getevents/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_getevents/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/syscalls/io_getevents/Makefile	20 Jan 2009
10:48:41 -0000	1.3
+++ testcases/kernel/syscalls/io_getevents/Makefile	12 Jul 2009 05:11:28 -0000
@@ -20,20 +20,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #

+srcdir			?= ../../../..

-include ../../../../config.mk
+include $(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)
+$(eval $(generic_leaf_target))
Index: testcases/kernel/syscalls/io_setup/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_setup/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/syscalls/io_setup/Makefile	20 Jan 2009 10:48:42 -0000	1.3
+++ testcases/kernel/syscalls/io_setup/Makefile	12 Jul 2009 05:11:28 -0000
@@ -20,20 +20,10 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #

+srcdir			?= ../../../..

-include ../../../../config.mk
+include $(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)
+$(eval $(generic_leaf_target))
Index: testcases/kernel/syscalls/io_submit/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/io_submit/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- testcases/kernel/syscalls/io_submit/Makefile	20 Jan 2009 10:48:42 -0000	1.3
+++ testcases/kernel/syscalls/io_submit/Makefile	12 Jul 2009 05:11:28 -0000
@@ -20,16 +20,15 @@
 #  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #

+srcdir			?= ../../../..

-include ../../../../config.mk
+include $(srcdir)/include/mk/master_include.mk

+CFLAGS 			+= -I$(srcdir)/include -Wall
+LDFLAGS			+= $(AIO_LIBS) -L$(srcdir)/lib
+LDLIBS			+= -lltp

-SRCS    = $(wildcard *.c)
-TARGETS = $(patsubst %.c,%,$(SRCS))
-SYSCALL = io_submit
-
-CFLAGS += -I../../../../include -Wall
-LDLIBS += $(AIO_LIBS) -L../../../../lib -lltp
+TARGETS 		:= $(patsubst %.c,%,$(wildcard *.c))

 all: $(TARGETS)

Index: testcases/kernel/timers/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/kernel/timers/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- testcases/kernel/timers/Makefile	22 Aug 2006 05:14:39 -0000	1.6
+++ testcases/kernel/timers/Makefile	12 Jul 2009 05:11:28 -0000
@@ -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.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
-#  the GNU General Public License for more details.
-#
-#  You should have 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) 2009, Cisco Systems, Inc.
 #
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    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		?= ../../..

-SUBDIRS = $(patsubst %/Makefile,%,$(wildcard */Makefile))
+include $(top_srcdir)/include/mk/master_include.mk

-all %::
-	@set -e; \
-	for i in $(SUBDIRS); do \
-		$(MAKE) -C $$i $@; \
-	done
+$(eval $(generic_trunk_target))
Index: testcases/realtime/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/testcases/realtime/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- testcases/realtime/Makefile	24 Mar 2008 09:13:49 -0000	1.1
+++ testcases/realtime/Makefile	12 Jul 2009 05:11:28 -0000
@@ -12,4 +12,4 @@

 clean:
 	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
-	@rm .config
+	@rm .config *.o
Index: tools/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/tools/Makefile,v
retrieving revision 1.11
diff -u -r1.11 Makefile
--- tools/Makefile	19 Aug 2003 14:30:20 -0000	1.11
+++ tools/Makefile	12 Jul 2009 05:11:28 -0000
@@ -1,18 +1,30 @@
-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
+srcdir			?= ..

-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(srcdir)/include/mk/master_include.mk

-all: $(TARGETS)
-	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
+# top-LTP is really broken, apparently.
+FILTER_OUT_DIRS		:= 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
+$(eval $(generic_trunk_target))
Index: tools/genload/genload.c
===================================================================
RCS file: tools/genload/genload.c
diff -N tools/genload/genload.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tools/genload/genload.c	12 Jul 2009 05:11:28 -0000
@@ -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;
+}
Index: tools/genload/stress.c
===================================================================
RCS file: tools/genload/stress.c
diff -N tools/genload/stress.c
--- tools/genload/stress.c	26 Jul 2007 12:40:17 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,983 +0,0 @@
-/* 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;
-}
Index: tools/genload/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/tools/genload/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- tools/genload/Makefile	29 Sep 2008 16:22:14 -0000	1.4
+++ tools/genload/Makefile	12 Jul 2009 05:11:28 -0000
@@ -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
+srcdir		?= ../..

-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
+include $(srcdir)/include/mk/master_include.mk

-all: $(TARGETS)
+CFLAGS		+= -DPACKAGE=\"stress\" -DVERSION=\"0.17pre11\"

-install:
-	@ln -f $(TARGETS) ../../testcases/bin/genload
+LDLIBS		+= -lm

-clean:
-	rm -fr $(TARGETS)
+$(eval $(generic_leaf_target))

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-07-12  5:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-07  0:22 [LTP] [PATCH 3/4] Refactor top-level Makefiles, modularize autoconf logic Garrett Cooper
2009-07-08 23:53 ` Mike Frysinger
2009-07-09  0:21   ` Garrett Cooper
2009-07-09  0:42     ` Mike Frysinger
2009-07-09  9:08       ` Garrett Cooper
2009-07-10  0:07         ` Mike Frysinger
2009-07-11 21:55           ` Garrett Cooper
2009-07-12  4:06             ` Garrett Cooper
2009-07-12  5:15               ` Garrett Cooper
2009-07-09  9:39   ` Garrett Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.