cons-discuss
[Top][All Lists]
Advanced

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

LIBS and %-expansion


From: David Sanderson
Subject: LIBS and %-expansion
Date: Thu, 30 Nov 2000 20:40:08 -0500

Cons 2.2.0 appears to process LIBS for dependencies before doing
%-expansion.  Here's what I'm seeing:

If my Construct file has

    $CONS = new cons(..., LIBS => '%LIBS_LOCAL', ...);

and my directory-specific Conscript file contains something like

    $CONS = $CONS->clone(LIBS_LOCAL => '-lworld');

to construct an environment appropriate for linking the programs in that
directory, cons makes what appears to be a correct linking line, but it
does not build the library.  If, on the other hand, the Conscript file
contains something like

    $CONS = $CONS->clone(LIBS => '-lworld');

then it does build the library.

Is this behavior intentional?

I have appended a small example to illustrate this behavior.
Directories c1 and c2 differ only in their src/hello/Conscript files as
shown above, but directory c1 builds and directory c2 does not.

David Sanderson (address@hidden)

#!/bin/sh
# This is a shell archive (produced by shar 3.50)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 12/01/2000 01:31 UTC by address@hidden
# Source directory /nfs/home/dws/repos
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#    542 -rw-r--r-- c1/Construct
#    136 -rw-r--r-- c1/src/hello/Conscript
#     66 -rw-r--r-- c1/src/hello/hello.c
#    153 -rw-r--r-- c1/src/world/Conscript
#     86 -rw-r--r-- c1/src/world/world.c
#     18 -rw-r--r-- c1/src/world/world.h
#    542 -rw-r--r-- c2/Construct
#    142 -rw-r--r-- c2/src/hello/Conscript
#     66 -rw-r--r-- c2/src/hello/hello.c
#    153 -rw-r--r-- c2/src/world/Conscript
#     86 -rw-r--r-- c2/src/world/world.c
#     18 -rw-r--r-- c2/src/world/world.h
#
# ============= c1/Construct ==============
if test ! -d 'c1'; then
    echo 'x - creating directory c1'
    mkdir 'c1'
fi
if test -f 'c1/Construct' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/Construct (File already exists)'
else
echo 'x - extracting c1/Construct (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/Construct' &&
$EXPORT = "#export";
X
# Tell cons to build this directory (recursively) by default.
Default (
X    $EXPORT
);
X
# Standard directories for sharing products.
$INCLUDE = "$EXPORT/include";
$LIB     = "$EXPORT/lib";
$BIN     = "$EXPORT/bin";
X
$CONS = new cons(
X    CC  => 'gcc',
X    ENV => {
X       PATH => '/usr/bin:/usr/ccs/bin:/opt/bin',
X    },
X    CPPPATH => $INCLUDE,
X    LIBPATH => $LIB,
X    LIBS    => '%LIBS_LOCAL',
);
X
Export qw( CONS INCLUDE LIB BIN );
X
Link 'build' => 'src';
X
Build qw(
X    build/hello/Conscript
X    build/world/Conscript
);
SHAR_EOF
chmod 0644 c1/Construct ||
echo 'restore of c1/Construct failed'
Wc_c="`wc -c < 'c1/Construct'`"
test 542 -eq "$Wc_c" ||
        echo 'c1/Construct: original size 542, current size' "$Wc_c"
fi
# ============= c1/src/hello/Conscript ==============
if test ! -d 'c1/src'; then
    echo 'x - creating directory c1/src'
    mkdir 'c1/src'
fi
if test ! -d 'c1/src/hello'; then
    echo 'x - creating directory c1/src/hello'
    mkdir 'c1/src/hello'
fi
if test -f 'c1/src/hello/Conscript' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/src/hello/Conscript (File already exists)'
else
echo 'x - extracting c1/src/hello/Conscript (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/src/hello/Conscript' &&
Import qw( CONS BIN );
X
$CONS = $CONS->clone(LIBS => '-lworld');
X
Install_Local $CONS $BIN, 'hello';
X
Program $CONS 'hello', 'hello.c';
SHAR_EOF
chmod 0644 c1/src/hello/Conscript ||
echo 'restore of c1/src/hello/Conscript failed'
Wc_c="`wc -c < 'c1/src/hello/Conscript'`"
test 136 -eq "$Wc_c" ||
        echo 'c1/src/hello/Conscript: original size 136, current size' "$Wc_c"
fi
# ============= c1/src/hello/hello.c ==============
if test -f 'c1/src/hello/hello.c' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/src/hello/hello.c (File already exists)'
else
echo 'x - extracting c1/src/hello/hello.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/src/hello/hello.c' &&
#include "world.h"
X
int
main(void)
{
X    world();
X    return 0;
}
SHAR_EOF
chmod 0644 c1/src/hello/hello.c ||
echo 'restore of c1/src/hello/hello.c failed'
Wc_c="`wc -c < 'c1/src/hello/hello.c'`"
test 66 -eq "$Wc_c" ||
        echo 'c1/src/hello/hello.c: original size 66, current size' "$Wc_c"
fi
# ============= c1/src/world/Conscript ==============
if test ! -d 'c1/src/world'; then
    echo 'x - creating directory c1/src/world'
    mkdir 'c1/src/world'
fi
if test -f 'c1/src/world/Conscript' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/src/world/Conscript (File already exists)'
else
echo 'x - extracting c1/src/world/Conscript (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/src/world/Conscript' &&
Import qw( CONS INCLUDE LIB );
X
Install_Local $CONS $LIB, 'libworld.a';
Install_Local $CONS $INCLUDE, 'world.h';
X
Library $CONS 'libworld.a', 'world.c';
SHAR_EOF
chmod 0644 c1/src/world/Conscript ||
echo 'restore of c1/src/world/Conscript failed'
Wc_c="`wc -c < 'c1/src/world/Conscript'`"
test 153 -eq "$Wc_c" ||
        echo 'c1/src/world/Conscript: original size 153, current size' "$Wc_c"
fi
# ============= c1/src/world/world.c ==============
if test -f 'c1/src/world/world.c' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/src/world/world.c (File already exists)'
else
echo 'x - extracting c1/src/world/world.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/src/world/world.c' &&
#include <stdio.h>
#include <world.h>
X
void
world(void)
{
X    puts("hello, world");
}
SHAR_EOF
chmod 0644 c1/src/world/world.c ||
echo 'restore of c1/src/world/world.c failed'
Wc_c="`wc -c < 'c1/src/world/world.c'`"
test 86 -eq "$Wc_c" ||
        echo 'c1/src/world/world.c: original size 86, current size' "$Wc_c"
fi
# ============= c1/src/world/world.h ==============
if test -f 'c1/src/world/world.h' -a X"$1" != X"-c"; then
        echo 'x - skipping c1/src/world/world.h (File already exists)'
else
echo 'x - extracting c1/src/world/world.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c1/src/world/world.h' &&
void
world(void);
SHAR_EOF
chmod 0644 c1/src/world/world.h ||
echo 'restore of c1/src/world/world.h failed'
Wc_c="`wc -c < 'c1/src/world/world.h'`"
test 18 -eq "$Wc_c" ||
        echo 'c1/src/world/world.h: original size 18, current size' "$Wc_c"
fi
# ============= c2/Construct ==============
if test ! -d 'c2'; then
    echo 'x - creating directory c2'
    mkdir 'c2'
fi
if test -f 'c2/Construct' -a X"$1" != X"-c"; then
        echo 'x - skipping c2/Construct (File already exists)'
else
echo 'x - extracting c2/Construct (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c2/Construct' &&
$EXPORT = "#export";
X
# Tell cons to build this directory (recursively) by default.
Default (
X    $EXPORT
);
X
# Standard directories for sharing products.
$INCLUDE = "$EXPORT/include";
$LIB     = "$EXPORT/lib";
$BIN     = "$EXPORT/bin";
X
$CONS = new cons(
X    CC  => 'gcc',
X    ENV => {
X       PATH => '/usr/bin:/usr/ccs/bin:/opt/bin',
X    },
X    CPPPATH => $INCLUDE,
X    LIBPATH => $LIB,
X    LIBS    => '%LIBS_LOCAL',
);
X
Export qw( CONS INCLUDE LIB BIN );
X
Link 'build' => 'src';
X
Build qw(
X    build/hello/Conscript
X    build/world/Conscript
);
SHAR_EOF
chmod 0644 c2/Construct ||
echo 'restore of c2/Construct failed'
Wc_c="`wc -c < 'c2/Construct'`"
test 542 -eq "$Wc_c" ||
        echo 'c2/Construct: original size 542, current size' "$Wc_c"
fi
# ============= c2/src/hello/Conscript ==============
if test ! -d 'c2/src'; then
    echo 'x - creating directory c2/src'
    mkdir 'c2/src'
fi
if test ! -d 'c2/src/hello'; then
    echo 'x - creating directory c2/src/hello'
    mkdir 'c2/src/hello'
fi
if test -f 'c2/src/hello/Conscript' -a X"$1" != X"-c"; then
        echo 'x - skipping c2/src/hello/Conscript (File already exists)'
else
echo 'x - extracting c2/src/hello/Conscript (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c2/src/hello/Conscript' &&
Import qw( CONS BIN );
X
$CONS = $CONS->clone(LIBS_LOCAL => '-lworld');
X
Install_Local $CONS $BIN, 'hello';
X
Program $CONS 'hello', 'hello.c';
SHAR_EOF
chmod 0644 c2/src/hello/Conscript ||
echo 'restore of c2/src/hello/Conscript failed'
Wc_c="`wc -c < 'c2/src/hello/Conscript'`"
test 142 -eq "$Wc_c" ||
        echo 'c2/src/hello/Conscript: original size 142, current size' "$Wc_c"
fi
# ============= c2/src/hello/hello.c ==============
if test -f 'c2/src/hello/hello.c' -a X"$1" != X"-c"; then
        echo 'x - skipping c2/src/hello/hello.c (File already exists)'
else
echo 'x - extracting c2/src/hello/hello.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c2/src/hello/hello.c' &&
#include "world.h"
X
int
main(void)
{
X    world();
X    return 0;
}
SHAR_EOF
chmod 0644 c2/src/hello/hello.c ||
echo 'restore of c2/src/hello/hello.c failed'
Wc_c="`wc -c < 'c2/src/hello/hello.c'`"
test 66 -eq "$Wc_c" ||
        echo 'c2/src/hello/hello.c: original size 66, current size' "$Wc_c"
fi
# ============= c2/src/world/Conscript ==============
if test ! -d 'c2/src/world'; then
    echo 'x - creating directory c2/src/world'
    mkdir 'c2/src/world'
fi
if test -f 'c2/src/world/Conscript' -a X"$1" != X"-c"; then
        echo 'x - skipping c2/src/world/Conscript (File already exists)'
else
echo 'x - extracting c2/src/world/Conscript (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c2/src/world/Conscript' &&
Import qw( CONS INCLUDE LIB );
X
Install_Local $CONS $LIB, 'libworld.a';
Install_Local $CONS $INCLUDE, 'world.h';
X
Library $CONS 'libworld.a', 'world.c';
SHAR_EOF
chmod 0644 c2/src/world/Conscript ||
echo 'restore of c2/src/world/Conscript failed'
Wc_c="`wc -c < 'c2/src/world/Conscript'`"
test 153 -eq "$Wc_c" ||
        echo 'c2/src/world/Conscript: original size 153, current size' "$Wc_c"
fi
# ============= c2/src/world/world.c ==============
if test -f 'c2/src/world/world.c' -a X"$1" != X"-c"; then
        echo 'x - skipping c2/src/world/world.c (File already exists)'
else
echo 'x - extracting c2/src/world/world.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c2/src/world/world.c' &&
#include <stdio.h>
#include <world.h>
X
void
world(void)
{
X    puts("hello, world");
}
SHAR_EOF
chmod 0644 c2/src/world/world.c ||
echo 'restore of c2/src/world/world.c failed'
Wc_c="`wc -c < 'c2/src/world/world.c'`"
test 86 -eq "$Wc_c" ||
        echo 'c2/src/world/world.c: original size 86, current size' "$Wc_c"
fi
# ============= c2/src/world/world.h ==============
if test -f 'c2/src/world/world.h' -a X"$1" != X"-c"; then
        echo 'x - skipping c2/src/world/world.h (File already exists)'
else
echo 'x - extracting c2/src/world/world.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'c2/src/world/world.h' &&
void
world(void);
SHAR_EOF
chmod 0644 c2/src/world/world.h ||
echo 'restore of c2/src/world/world.h failed'
Wc_c="`wc -c < 'c2/src/world/world.h'`"
test 18 -eq "$Wc_c" ||
        echo 'c2/src/world/world.h: original size 18, current size' "$Wc_c"
fi
exit 0



reply via email to

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