automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

making tests dependent on the library that they test...


From: Ed Hartnett
Subject: making tests dependent on the library that they test...
Date: Thu, 21 Jul 2005 09:24:18 -0600
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

Howdy All!

Firstly, thanks to all Automake developers, maintainers, and
supporters. Great program!

I'm using it to build a library, and I have a bunch of test programs
that test that library.

I want make to rebuild test files if the library has been
rebuilt. That is, if I have a program tst_something.c, and the
executable tst_something exists, and I've changed the library, I want
make to know that it now needs to rebuild tst_something.

The way I've done it is like this:

# Test programs (unless they have _h_ in the name) are dependent on
# the netcdf library (i.e. should be rebuilt if the library's more
# recent).
tst_nc_converts_DEPENDENCIES = libnetcdf.la
tst_lists_DEPENDENCIES = libnetcdf.la
tst_dims_DEPENDENCIES = libnetcdf.la
tst_v2_DEPENDENCIES = libnetcdf.la
tst_files_DEPENDENCIES = libnetcdf.la
...

Is there a better way to do this? Specifically, one which doesn't
require me to explicitly list the dependency program for each and
every test program that depends on it.

In case more info is needed, I've appended the Makefile.am below.

Thanks!

Ed

## This is a automake file, part of Unidata's netCDF package.
# Copyright 2005, see the COPYRIGHT file for more information.

# This automake file generates the Makefile to build netCDF-4. The
# generated makefile is not run unless the user selected to build
# netCDF-4.

# $Id: Makefile.am,v 1.38 2005/06/28 10:26:26 ed Exp $

# Turn on debug info and warnings, but not warnings I don't care about.
AM_CFLAGS = -g -Wall -Wno-inline -Wno-cast-qual -Wno-padded 

# Cause C preprocessor to search current and parent directory.
AM_CPPFLAGS = -DDEBUG -I.  -I$(top_srcdir) -I$(top_srcdir)/libsrc

# Linker needs to search current directory when building tests.
AM_LDFLAGS = -L. -L$(top_srcdir)/libsrc4

# If the user specified a root location for HDF5, use it.
if USE_HDF5_DIR
AM_CPPFLAGS += address@hidden@/include
AM_LDFLAGS += address@hidden@/lib
endif

# Tell automake that netcdf.h is a header file we want to install.
include_HEADERS = netcdf.h

# This is our output. The big enchilada.
lib_LTLIBRARIES = libnetcdf.la

# Our output library will also include contents of the netcdf3 and
# netcdf2 convenience libraries.
libnetcdf_la_LIBADD = ../libsrc/libnetcdf3.la ../libsrc/libnetcdf2.la

# If the f77 api is being built, include it's convenience library.
if BUILD_F77
libnetcdf_la_LIBADD += ../fortran/libnetcdff.la
endif

# Netcdf-4 source.
libnetcdf_la_SOURCES = nc4attr.c nc4internal.c nc4var.c netcdf3.h       \
nc4dim.c nc4internal.h ncfunc.c nc4file.c netcdf.h error.c error.h      \
nc4internal.h netcdf3.h netcdf.h nc4grp.c nc4type.c nc4hdf.c

# These linker flags specify libtool version info.
libnetcdf_la_LDFLAGS = -version-info 0:0:0

# These programs are all built for make check in this directory.
check_PROGRAMS = tst_nc_converts tst_h_files tst_h_atts tst_h_vars      \
tst_h_grps tst_h_compounds tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl          \
tst_h_opaques tst_h_strings tst_h_converts tst_h_dimscales              \
tst_h_dimscales2 tst_lists tst_dims tst_v2 tst_files tst_vars           \
tst_unlim_vars tst_atts tst_converts tst_grps tst_compounds tst_vl      \
tst_opaques tst_strings

# Test programs (unless they have _h_ in the name) are dependent on
# the netcdf library (i.e. should be rebuilt if the library's more
# recent).
tst_nc_converts_DEPENDENCIES = libnetcdf.la
tst_lists_DEPENDENCIES = libnetcdf.la
tst_dims_DEPENDENCIES = libnetcdf.la
tst_v2_DEPENDENCIES = libnetcdf.la
tst_files_DEPENDENCIES = libnetcdf.la
tst_vars_DEPENDENCIES = libnetcdf.la
tst_unlim_vars_DEPENDENCIES = libnetcdf.la
tst_atts_DEPENDENCIES = libnetcdf.la
tst_converts_DEPENDENCIES = libnetcdf.la
tst_grps_DEPENDENCIES = libnetcdf.la
tst_compounds_DEPENDENCIES = libnetcdf.la
tst_vl_DEPENDENCIES = libnetcdf.la
tst_opaques_DEPENDENCIES = libnetcdf.la
tst_strings_DEPENDENCIES = libnetcdf.la

# These linker flags will be applied to all test program compiles.
LDADD = -lnetcdf -lhdf5 -lhdf5_hl

# This header is used by all test programs.
noinst_HEADERS = tests.h

# This will run all the test programs.
TESTS = ${check_PROGRAMS}

# Clean up. Each test program creates one data file, with the same
# name as the test program, and either a .h5 or .nc, for "pure" HDF5
# files and netCDF-4 files.
MAINTAINERCLEANFILES = Makefile.in
CLEANFILES = tst_nc_converts.nc tst_h_files.h5 tst_h_atts.h5            \
tst_h_vars.h5 tst_h_grps.h5 tst_h_compounds.h5 tst_h_wrt_cmp.h5         \
tst_h_vl.h5 tst_h_opaques.h5 tst_h_strings.h5 tst_h_converts.h5         \
tst_h_dimscales.h5 tst_h_dimscales2.h5 tst_lists.nc tst_dims.nc         \
tst_files.nc tst_vars.nc tst_unlim_vars. nc tst_atts.nc                 \
tst_converts.nc tst_grps.nc tst_compounds.nc tst_vl.nc tst_opaque.nc    \
tst_strings.nc



-- 
Ed Hartnett  -- address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]