Index: configure.ac
===================================================================
RCS file: /cvsroot/ltp/ltp/configure.ac,v
retrieving revision 1.13
diff -u -r1.13 configure.ac
--- configure.ac 25 May 2009 15:01:45 -0000 1.13
+++ configure.ac 19 Jul 2009 07:00:50 -0000
@@ -2,17 +2,27 @@
AC_INIT([ltp], [cvs], [ltp-results@lists.sourceforge.net])
AM_INIT_AUTOMAKE([1.10])
AC_CONFIG_HEADERS([include/config.h])
-AC_CONFIG_FILES([config.mk m4/Makefile])
+AC_CONFIG_FILES([ \
+ include/mk/config.mk \
+ lib/ltp.pc \
+ ltp-devel.spec \
+ m4/Makefile \
+ README.ltp-devel \
+])
AC_CANONICAL_HOST
AC_PROG_CC
AC_PROG_AR
AC_PROG_RANLIB
+AC_PREFIX_DEFAULT(/opt/ltp)
AC_CHECK_HEADERS_ONCE([ \
-ifaddrs.h \
-sys/capability.h \
-sys/inotify.h \
+ dmapi.h \
+ ifaddrs.h \
+ libaio.h \
+ mm.h \
+ sys/capability.h \
+ sys/inotify.h \
])
LTP_CHECK_SYSCALL_EVENTFD
Index: config.mk.in
===================================================================
RCS file: config.mk.in
diff -N config.mk.in
--- config.mk.in 31 Mar 2009 13:58:13 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
-CC = @CC@
-AR = @AR@
-RANLIB = @RANLIB@
-
-CPPFLAGS = @CPPFLAGS@
-CFLAGS = @CFLAGS@
-LDFLAGS = @LDFLAGS@
-
-AIO_LIBS = @AIO_LIBS@
-SELINUX_LIBS = @SELINUX_LIBS@
-CRYPTO_LIB = @CRYPTO_LIB@
Index: ltp-devel.spec.in
===================================================================
RCS file: ltp-devel.spec.in
diff -N ltp-devel.spec.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ltp-devel.spec.in 19 Jul 2009 07:00:50 -0000
@@ -0,0 +1,68 @@
+#
+# RPM Package Manager (RPM) spec file for ltp-devel
+#
+Summary: Linux Test Project (LTP) Software Development Kit (SDK)
+Name: ltp-devel
+Version: 2.0
+Release: 0.0
+Prefix: @prefix@
+License: GPL
+Group: Development/Libraries
+URL: http://www.linuxtestproject.org
+Vendor: IBM Corp
+Packager: Subrata Modak <subrata.modak@@in.ibm.com>
+AutoReqProv: 0
+Provides: LTP
+#ExclusiveArch: i386
+ExclusiveOS: linux
+%description
+This is a development package of the Linux Test Project (LTP).
+It is intended to be used to build testcases using the provided API.
+%files
+@prefix@/lib/libltp.a
+@datarootdir@/pkgconfig/ltp.pc
+@prefix@/bin/ltp-pan
+@prefix@/bin/ltp-scanner
+@prefix@/bin/ltp-bump
+@prefix@/include/linux_syscall_numbers.h
+@prefix@/include/libtestsuite.h
+@prefix@/include/usctest.h
+@prefix@/include/string_to_tokens.h
+@prefix@/include/str_to_bytes.h
+@prefix@/include/databin.h
+@prefix@/include/open_flags.h
+@prefix@/include/write_log.h
+@prefix@/include/dataascii.h
+@prefix@/include/forker.h
+@prefix@/include/compiler.h
+@prefix@/include/test.h
+@prefix@/include/tlibio.h
+@prefix@/include/pattern.h
+@prefix@/include/file_lock.h
+@prefix@/include/random_range.h
+@prefix@/include/search_path.h
+@prefix@/include/rmobj.h
+@mandir@/man3/tst_tmpdir.3
+@mandir@/man3/random_range_seed.3
+@mandir@/man3/pattern.3
+@mandir@/man3/parse_ranges.3
+@mandir@/man3/usctest.3
+@mandir@/man3/random_range.3
+@mandir@/man3/forker.3
+@mandir@/man3/rmobj.3
+@mandir@/man3/parse_open_flags.3
+@mandir@/man3/tst_res.3
+@mandir@/man3/write_log.3
+@mandir@/man3/str_to_bytes.3
+@mandir@/man3/tst_set_error.3
+@mandir@/man3/parse_opts.3
+@mandir@/man3/string_to_tokens.3
+@mandir@/man3/tst_sig.3
+@mandir@/man3/get_attrib.3
+@mandir@/man1/ltp-pan.1
+@mandir@/man1/doio.1
+@mandir@/man1/iogen.1
+@mandir@/man1/ltp-bump.1
+# Post-install stuff would go here.
+#EOF
+
Index: README.ltp-devel.in
===================================================================
RCS file: README.ltp-devel.in
diff -N README.ltp-devel.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ README.ltp-devel.in 19 Jul 2009 07:00:50 -0000
@@ -0,0 +1,48 @@
+This is a README to describe the ltp-devel.patch functional changes.
+
+"make install" is to build and install:
+
+ @prefix@/bin/ltp-bump
+ @prefix@/bin/ltp-pan
+ @prefix@/bin/ltp-scanner
+ @prefix@/lib/libltp.a
+ @datarootdir@/pkgconfig/ltp.pc
+ @prefix@/include/
+ @mandir@
+
+"make package" is to rpm package what was installed above:
+
+ /usr/src/redhat/RPMS/i386/ltp-devel-1.0-0.0.i386.rpm
+
+For someone wanting to write a standalone test that uses "libltp.a", then
+their Makefile would compile their test program like this:
+
+ test: test.c
+ cc test.c `pkg-config --cflags --libs ltp`
+
+To read manual pages, then the developer would type:
+(Most Important man pages)
+
+ man usctest
+ man ltp-pan
+ man tst_res
+ man tst_sig
+ man tst_set_error
+ man tst_tmpdir
+ man parse_opts
+
+(Others)
+ man ltp-bump
+ man doio
+ man iogen
+ man forker
+ man pattern
+ man random_range_seed
+ man string_to_tokens
+ man get_attrib
+ man parse_open_flags
+ man parse_ranges
+ man random_range
+ man rmobj
+ man str_to_bytes
+ man write_log
Index: include/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/include/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- include/Makefile 23 Jun 2009 14:18:16 -0000 1.7
+++ include/Makefile 19 Jul 2009 07:00:50 -0000
@@ -1,27 +1,46 @@
+#
+# 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
+
+CLEAN_DEPS := ac-clean
+
+INSTALL_DIR := $(includedir)
+INSTALL_MODE := 00644
-PREFIX=/opt/ltp
-HEADERS=compiler.h dataascii.h databin.h file_lock.h forker.h open_flags.h \
- pattern.h random_range.h rmobj.h search_path.h string_to_tokens.h \
- str_to_bytes.h test.h tlibio.h usctest.h write_log.h \
- linux_syscall_numbers.h libtestsuite.h config.h
-
-.PHONY: all install
-all:
-
-install: $(HEADERS)
- @set -e; for i in $(HEADERS); do \
- install -D -m 644 $$i $(DESTDIR)/$(PREFIX)/include/ltp/$$i; \
- done
+INSTALL_TARGETS := $(wildcard $(srcdir)/*.h)
-.PHONY: clean distclean maintainer-clean
-clean: ac-clean
+MAKE_TARGETS :=
+
+.PHONY: ac-clean ac-distclean ac-maintainer-clean distclean maintainer-clean
distclean: clean ac-distclean
maintainer-clean: distclean ac-maintainer-clean
-
-.PHONY: ac-clean ac-distclean ac-maintainerclean
ac-clean:
ac-distclean:
- rm -f config.h
+ $(RM) -f config.h
ac-maintainer-clean:
- rm -f config.h.in
+ $(RM) -f config.h.in
+
+$(eval $(generic_leaf_target))
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 19 Jul 2009 07:00:50 -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: lib/ltp.pc.in
===================================================================
RCS file: lib/ltp.pc.in
diff -N lib/ltp.pc.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/ltp.pc.in 19 Jul 2009 07:00:50 -0000
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+
+Name: LTP
+Description: Linux Test Project
+Version: 1.0
+Libs: -L${libdir} -lltp
+Cflags: -I${includedir}
+Libs.private: -L${libdir} -lltp
Index: include/mk/master_include.mk
===================================================================
RCS file: include/mk/master_include.mk
diff -N include/mk/master_include.mk
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/mk/master_include.mk 19 Jul 2009 07:00:50 -0000
@@ -0,0 +1,25 @@
+#
+# Master 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
+#
+
+# Only include config.mk for non-clean based targets.
+-include $(top_srcdir)/include/mk/config.mk
+include $(top_srcdir)/include/mk/master_rules.mk
Index: include/mk/master_rules.mk
===================================================================
RCS file: include/mk/master_rules.mk
diff -N include/mk/master_rules.mk
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/mk/master_rules.mk 19 Jul 2009 07:00:50 -0000
@@ -0,0 +1,318 @@
+#
+# Master rules Makefile.
+#
+# Copyright (C) 2009, Cisco Systems Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# Get the absolute path for the source directory.
+ifeq ($(origin top_srcdir),undefined)
+$(error top_srcdir is not defined)
+endif
+
+# Where's the root source directory?
+top_srcdir := $(abspath $(top_srcdir))
+
+# Where's the root object directory?
+top_builddir ?= $(top_srcdir) # Just in case
+ # it's not
+ # specified...
+
+top_builddir := $(abspath $(top_builddir)) # We need the
+ # absolute
+ # path...
+# Where's the source located at?
+srcdir ?= .
+# Where's the root object directory?
+builddir ?= $(srcdir)
+# Where are we going to install the files? Most of this junk ends up in
+# testcases/bin, so let's dump it there :)...
+INSTALL_DIR ?= testcases/bin
+
+abs_builddir := $(abspath $(builddir))
+abs_srcdir := $(abspath $(srcdir))
+
+# We can piece together where we're located in the source and object trees with
+# just these two vars and $(CURDIR).
+export top_srcdir top_builddir
+
+define generate_vpath_rule
+vpath %.$(1) $(if $(2),$(2),$(srcdir))
+endef
+
+define generate_install_rule
+$$(warning "gir: $(1) => $(2)")
+
+$(1):
+ install -m $$(INSTALL_MODE) "$(2)/$$(@F)" "$$@"
+endef
+
+# Default source search path. Modify as necessary, but I would call that
+# poor software design if you need more than one search directory, and
+# would suggest creating a general purpose static library to that end.
+$(eval $(call generate_vpath_rule,c))
+
+#
+# get_make_dirs
+#
+# Sets the make directories in $(SUBDIRS), and then subsequently filters out
+# the subdirectories based on $(FILTER_OUT_DIRS).
+#
+define get_make_dirs
+
+SUBDIRS ?= $$(patsubst %/Makefile,%,$$(wildcard */Makefile))
+
+ifneq ($$(strip $$(SUBDIRS)),) # We have directories to parse.
+ifneq ($$(strip $$(FILTER_OUT_DIRS)),) # We have directories to filter-out.
+SUBDIRS := $$(filter-out $$(FILTER_OUT_DIRS),$$(SUBDIRS))
+endif
+endif
+
+endef
+
+define generic_target_env_setup
+
+ifeq ($$(origin MAKE_TARGETS),undefined)
+MAKE_TARGETS := $$(notdir $$(patsubst %.c,%,$$(wildcard $$(srcdir)/*.c)))
+endif
+
+# Don't append $(MAKE_TARGETS) unless it is non-NUL length.
+ifneq ($$(strip $$(MAKE_TARGETS)),)
+
+CLEAN_TARGETS += $$(MAKE_TARGETS)
+INSTALL_TARGETS += $$(MAKE_TARGETS)
+
+endif
+
+CLEAN_TARGETS += $$(wildcard *.o)
+
+# The large majority of the files that we install are going to be apps and
+# scripts, so let's chmod them like that.
+INSTALL_MODE ?= 00775
+
+ifneq ($(filter-out %install,$(MAKECMDGOALS)),) # Not an install target -- skip.
+ifeq ($$(origin INSTALL_DIR),undefined) # Not set by the user -- most like a
+ # programming error now in this .mk
+ # file.
+$$(error INSTALL_DIR is not set (undefined))
+else
+ifeq ($$(strip $$(INSTALL_DIR)),) # Set to a NUL-length string (dev
+ # error in a leaf Makefile, or
+ # someone's toying with the
+ # environment).
+$$(error INSTALL_DIR is not set to a non-NUL string)
+ # else $(INSTALL_DIR) is set to a
+ # non-NUL string.
+
+endif # END: INSTALL_DIR NUL-length string.
+endif # END: undefined
+endif # END: Not install
+
+# An absolute path; don't append $(DESTDIR)/$(prefix) to the var.
+ifeq ($$(patsubst /%,,$$(INSTALL_DIR)),)
+INSTALL_PATH := $$(INSTALL_DIR)
+# Otherwise, let's assume that it's not relative to $(prefix)
+else
+INSTALL_PATH := $$(DESTDIR)/$$(prefix)/$$(INSTALL_DIR)
+endif
+
+INSTALL_FILES := $$(addprefix $$(INSTALL_PATH)/,$$(notdir $$(INSTALL_TARGETS)))
+
+CLEAN_TARGETS += $$(INSTALL_FILES)
+
+$$(INSTALL_PATH):
+ mkdir -p $$@
+
+$$(INSTALL_FILES): %: pre-install $$(abs_builddir)/$$(@F) $$(INSTALL_DEPS)
+ install -m $$(INSTALL_MODE) $$(abs_builddir)/$$(@F) $$@
+
+endef
+
+#
+# generic_leaf_target
+#
+# Generate a set of basic targets (all, clean, install) for a leaf directory
+# (no subdirectories).
+#
+# In order to properly emulate pre- and post- behavior, a pre-install and
+# _install target are generated as well. The flow for install is as follows:
+#
+# pre-install -> $(INSTALL_FILES) -> install
+#
+# Helpful variables are:
+#
+# $(MAKE_DEPS) : What to execute before all.
+# $(MAKE_TARGETS) : What to execute as direct dependencies of
+# all.
+# 1. Defaults to the basename of the targets
+# produced by the %.c -> % implicit pattern
+# rules, e.g. the MAKE_TARGET in a directory
+# like the following:
+#
+# $$ ls /bar
+# foo.c
+#
+# Would be `foo'. Similarly, the following
+# dir structure:
+#
+# $$ ls /bar
+# foo.c zanzibar.c
+#
+# Would be `foo zanzibar'.
+#
+# 2. If you define MAKE_TARGETS as an empty
+# string, this will override the defaults.
+# I did this to avoid providing too much
+# rope to hang one's self in the event of
+# unwanted behavior.
+#
+# $(CLEAN_TARGETS) : What targets should be cleaned (must be
+# real files). This will automatically append
+# adds the .o suffix to all files referenced
+# by $(MAKE_TARGETS)) to CLEAN_TARGETS, if
+# MAKE_TARGETS wasn't defined (see
+# $(MAKE_TARGETS)).
+# $(PREINSTALL_DEPS) : What to run as direct dependencies of
+# pre-install.
+# $(INSTALL_DEPS) : What to run as direct dependencies of
+# the _install target. These must be real
+# files.
+# $(POSTINSTALL_DEPS) : What to install direct dependencies of
+# the install target.
+# $(INSTALL_MODE) : What mode should we using when calling
+# install(1)?
+#
+# If you choose to cherrypick the logic contained here, by changing around the
+# dependencies for $(INSTALL_DEPS) and $(POSTINSTALL_DEPS), then you must also
+# emulate the $(INSTALL_DEPS): pre-install and install: $(POSTINSTALL_DEPS)
+# dependencies, if you _use_ them.
+#
+# Also, if you wish to change the installation directory, from the set default
+# (testcases/bin) you must do something like either one of the following items:
+#
+# Method A:
+#
+# INSTALL_DIR := /path/to/installdir/from/$(DESTDIR)/$(prefix)
+#
+# e.g. if I wanted to install my binaries in testcases/bin, I would do:
+#
+# INSTALL_DIR := testcases/bin
+#
+# in my calling Makefile.
+#
+# Or Method B:
+#
+# INSTALL_DIR := /path/to/installdir/from/$(DESTDIR)
+#
+# e.g. if I wanted to install my binaries in $(libdir) (which may not exist
+# outside of $(prefix) right now, but could in the future), I could do the
+# following:
+#
+# INSTALL_DIR := $(libdir)
+#
+define generic_leaf_target
+
+$$(eval $$(generic_target_env_setup))
+
+.PHONY: all clean _install install pre-install
+
+$$(MAKE_TARGETS): | $$(MAKE_DEPS)
+
+all: | $$(MAKE_TARGETS)
+
+clean:: $$(CLEAN_DEPS)
+ -$(RM) -f $$(CLEAN_TARGETS)
+
+pre-install: | $$(INSTALL_PATH) $$(PREINSTALL_DEPS)
+
+install: | $$(INSTALL_FILES) $$(POSTINSTALL_DEPS)
+
+endef
+
+#
+# generic_trunk_target
+#
+# Generate a set of recursive targets to apply over a trunk directory (has
+# directories) -- optionally with a set of trunk-based files.
+#
+# All variables in this canned define are essentially the same as
+# generic_leaf_target, with the exception that the install flow for local
+# targets is:
+#
+# pre-install -> $(INSTALL_FILES) -> trunk-install
+#
+# All recursive targets are traverse SUBDIRS as defined by the user, or if
+# undefined, defaults to any subdirectories where Makefile's are contained
+# within.
+#
+# generic_trunk_target specific variables are:
+#
+# RECURSIVE_TARGETS : a list of targets to apply over an entire
+# directory tree. This defaults to
+# `all clean install'.
+#
+# See generic_leaf_target, generic_target_env_setup, and get_make_dirs for
+# more details and design notes.
+#
+define generic_trunk_target
+
+#
+# Doesn't need forced secondary expansion because $(CURDIR) isn't going to
+# change (or at least it bloody well shouldn't ;)...).
+#
+# Don't do this in generic_target_env_setup, because we only need to do this
+# by default for generic_dir_target.
+#
+$(eval $(get_make_dirs))
+
+RECURSIVE_TARGETS ?= all install
+
+.PHONY: $$(RECURSIVE_TARGETS) $$(addprefix trunk-,$$(RECURSIVE_TARGETS)) pre-install
+
+$$(eval $$(generic_target_env_setup))
+
+trunk-all: | $$(MAKE_DEPS) $$(MAKE_TARGETS)
+
+trunk-clean:: $$(CLEAN_DEPS)
+ -$(RM) -f $$(CLEAN_TARGETS)
+
+pre-install: | $$(INSTALL_PATH) $$(PREINSTALL_DEPS)
+
+trunk-install: | $$(INSTALL_FILES) $$(POSTINSTALL_DEPS)
+
+# Avoid creating duplicate .PHONY references to all, clean, and install. IIRC,
+# I've seen some indeterministic behavior when one does this in the past with
+# GNU Make...
+.PHONY: $$(filter-out $$(RECURSIVE_TARGETS),all clean install)
+all: trunk-all
+
+clean:: trunk-clean
+
+install: trunk-install
+
+clean::
+ @set -e; for dir in $$(SUBDIRS); do \
+ $(MAKE) -C $$$$dir $$@; \
+ done
+
+$$(RECURSIVE_TARGETS): %:
+ @set -e; for dir in $$(SUBDIRS); do \
+ $(MAKE) -C $$$$dir $$@; \
+ done
+
+endef
Index: include/mk/lib.mk
===================================================================
RCS file: include/mk/lib.mk
diff -N include/mk/lib.mk
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/mk/lib.mk 19 Jul 2009 07:00:50 -0000
@@ -0,0 +1,71 @@
+#
+# library include Makefile.
+#
+# Copyright (C) 2009, Cisco Systems Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+include $(top_srcdir)/include/mk/master_include.mk
+
+# Change the default goal when nothing is specified to install because we want
+# to ensure that the libraries get installed ASAP so they can be properly
+# linked in with all required apps.
+CPPFLAGS += -I$(includedir)
+
+# An extension of generic_leaf_target, strictly for libraries.
+define lib_target
+
+.PHONY: install_headers
+
+ifeq ($$(origin LIB),undefined)
+$$(error You must define LIB when including this Makefile)
+endif
+
+install_headers: $$(addprefix $(includedir)/,$$(notdir $$(HEADER_FILES)))
+
+INSTALL_DEPS := install_headers
+
+INSTALL_DIR := $(libdir)
+
+INSTALL_MODE ?= 00664
+
+LIB := $$(addprefix $$(builddir)/,$$(LIB))
+
+MAKE_TARGETS := $$(LIB)
+
+ifeq ($$(origin LIBSRCS),undefined)
+LIBSRCS ?= $$(wildcard $(srcdir)/*.c)
+endif
+
+LIBSRCS := $$(notdir $$(LIBSRCS))
+
+LIBOBJS := $$(addprefix $$(builddir)/,$$(patsubst %.c,%.o,$$(LIBSRCS)))
+
+$$(warning $$(LIBSRCS))
+
+$$(LIB): $$(LIBOBJS)
+ set -e; if [ -z "$$(strip $$^)" ] ; then \
+ echo "Cowardly refusing to create empty archive."; \
+ exit 1; \
+ fi
+ $$(AR) -rc $$@ $$^
+ $$(RANLIB) $$@
+
+$$(eval $$(generic_leaf_target))
+
+endef
Index: include/mk/config.mk.in
===================================================================
RCS file: include/mk/config.mk.in
diff -N include/mk/config.mk.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/mk/config.mk.in 19 Jul 2009 07:00:50 -0000
@@ -0,0 +1,82 @@
+#
+# config.mk.in.
+#
+# Copyright (C) 2009, Cisco Systems Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+# Application specifying variables. You should never have to change these.
+AR = @AR@
+CC = @CC@
+RANLIB = @RANLIB@
+
+AIO_LIBS = @AIO_LIBS@
+CRYPTO_LIBS = @CRYPTO_LIBS@
+SELINUX_LIBS = @SELINUX_LIBS@
+
+prefix = @prefix@
+
+datarootdir = @datarootdir@
+includedir = @includedir@
+exec_prefix = @exec_prefix@
+libdir = @libdir@
+mandir = @mandir@
+
+# Avoid overwriting definitions in leaf callers.
+ifndef LTP_BUILD_DEFAULTS_SET
+LTP_BUILD_DEFAULTS_SET = 1
+
+RPMBUILD ?= rpmbuild
+
+srcdir ?= .
+
+CPPFLAGS ?= @CPPFLAGS@ -I$(includedir)
+CFLAGS ?= @CFLAGS@
+LDLIBS ?= @LIBS@
+LDFLAGS ?= @LDFLAGS@ -L$(libdir)
+
+DEBUG_CFLAGS ?= -g
+DEBUG_CXXFLAGS ?= $(DEBUG_CFLAGS)
+
+# Please see README.mk-devel about fstrict-aliasing.
+OPT_CFLAGS ?= -O2 -fno-strict-aliasing -pipe
+OPT_CXXFLAGS ?= $(OPT_CFLAGS)
+
+WCFLAGS ?= -Wall
+WCXXFLAGS ?= $(WCFLAGS)
+
+endif
+
+CPPFLAGS += -I$(includedir)
+LDFLAGS += -L$(libdir) $(WLDFLAGS)
+CFLAGS += $(DEBUG_CFLAGS) $(OPT_CFLAGS) $(WCFLAGS)
+CXXFLAGS += $(DEBUG_CXXFLAGS) $(OPT_CXXFLAGS) $(WCXXFLAGS)
+
+LDFLAGS += $(WLDFLAGS)
+
+# Only check for numa when not cross-compiling.
+ifeq ($(strip $(CROSS_COMPILE)),1)
+# Disable all undetectable cross-compilation required items.
+HAS_NUMA ?= 0
+else
+# Only check for numa when not cross-compiling.
+HAS_NUMA ?= $(shell sh $(top_srcdir)/tools/scripts/numa_test.sh 2>/dev/null)
+endif
+
+export datarootdir includedir libdir mandir prefix LTP_BUILD_DEFAULTS_SET
+export HAS_NUMA
Index: m4/GNUmakefile
===================================================================
RCS file: /cvsroot/ltp/ltp/m4/GNUmakefile,v
retrieving revision 1.1
diff -u -r1.1 GNUmakefile
--- m4/GNUmakefile 18 Jan 2009 22:22:40 -0000 1.1
+++ m4/GNUmakefile 19 Jul 2009 07:00:50 -0000
@@ -1,12 +1,37 @@
+#
+# m4 Makefile.
+#
+# Copyright (C) 2009, Cisco Systems Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+srcdir ?= ..
-PREFIX=/opt/ltp
-M4MACROS=$(notdir $(wildcard *.m4))
+include $(srcdir)/include/mk/master_include.mk
-all:
+M4MACROS := $(notdir $(wildcard *.m4))
-install: $(M4MACROS)
- for i in $(M4MACROS); do \
- install -D -m 644 $$i $(DESTDIR)/$(PREFIX)/share/aclocal/$$i; \
- done
+INSTALL_DIR := $(datarootdir)/aclocal
+INSTALL_MODE := 00644
+
+INSTALL_TARGETS := $(M4_MACROS)
+
+MAKE_TARGETS :=
+
+$(eval $(generic_leaf_target))
Index: pan/Makefile
===================================================================
RCS file: /cvsroot/ltp/ltp/pan/Makefile,v
retrieving revision 1.19
diff -u -r1.19 Makefile
--- pan/Makefile 19 May 2009 09:39:11 -0000 1.19
+++ pan/Makefile 19 Jul 2009 07:00:50 -0000
@@ -1,24 +1,39 @@
+#
+# pan Makefile.
+#
+# Copyright (C) 2009, Cisco Systems Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir ?= ..
-LOADLIBES += -lm
-LFLAGS += -l -w
-CFLAGS += -w
-PREFIX = /opt/ltp
+include $(top_srcdir)/include/mk/master_include.mk
-all: ltp-pan ltp-bump ltp-scanner
+LDLIBS += -lm
-ltp-pan: ltp-pan.o zoolib.o splitstr.o
+INSTALL_DIR := bin
+MAKE_TARGETS := ltp-bump ltp-pan ltp-scanner
ltp-bump: ltp-bump.o zoolib.o
+ltp-pan: ltp-pan.o zoolib.o splitstr.o
ltp-scanner: scan.o ltp-scanner.o reporter.o tag_report.o symbol.o splitstr.o debug.o
-
-install: ltp-pan ltp-bump ltp-scanner
- install -D ltp-scanner $(DESTDIR)/$(PREFIX)/bin/ltp-scanner
- install -D ltp-pan $(DESTDIR)/$(PREFIX)/bin/ltp-pan
- install -D ltp-bump $(DESTDIR)/$(PREFIX)/bin/ltp-bump
-
-clean:
- rm -f *.o ltp-pan ltp-bump ltp-scanner
+$(eval $(generic_leaf_target))