4 # Morgan Deters <mdeters@cs.nyu.edu> for the CVC4 project
5 # Copyright (c) 2010, 2011 The CVC4 Project
7 # usage: addsourcedir paths...
10 progname
=`basename "$0"`
15 echo "usage: $progname paths..." >&2
17 echo "Each path should be relative to the top-level source directory, e.g.:" >&2
19 echo " $progname src/expr" >&2
24 while [ $# -gt 0 ]; do
27 # remove trailing slashes, if any
28 srcdir
=`expr "$srcdir" : '\(.*[^/]\)/*$'`
29 # remove redundant slashes, if any
30 srcdir
=`echo "$srcdir" | sed 's,//*,/,g'`
32 if expr "$srcdir" : src
/ >/dev
/null
; then :; else
33 echo "$progname: error: Directories must be under src/" >&2
34 echo "$progname: error: and \`$srcdir' isn't!" >&2
35 echo "$progname: error: Make sure you provide source paths" >&2
36 echo "$progname: error: relative to the top level, e.g. \`src/expr'." >&2
40 if [ -d "$srcdir" ]; then :; else
41 echo "creating directory \`$srcdir'..."
45 # enough dotdots to get us back to the top-level directory
46 # (e.g. "src/foo" yields "../.." here), used for $(topdir) in Makefile
47 topdir
=`echo "$srcdir" | sed 's,[^/][^/]*,..,g'`
48 # one less, used for the include path in Makefile.am
49 topsrcdir
=`echo "$topdir" | sed 's,\.\./,,'`
51 if [ -e "$srcdir/Makefile" ]; then
52 echo "$progname: warning: not replacing extant \`$srcdir/Makefile'." >&2
54 echo "generating \`$srcdir/Makefile'..."
55 cat >"$srcdir/Makefile" <<EOF
59 include \$(topdir)/Makefile.subdir
63 if [ -e "$srcdir/Makefile.am" ]; then
64 echo "$progname: warning: not replacing extant \`$srcdir/Makefile.am'." >&2
66 echo "generating \`$srcdir/Makefile.am'..."
67 clibbase
=`expr "$srcdir" : '.*/\([^/][^/]*\)$'`
68 if expr "$srcdir" : src
/parser
>/dev
/null
; then
69 definitions
=" -D__BUILDING_CVC4PARSERLIB \\
71 visibility
=' $(FLAG_VISIBILITY_HIDDEN)'
72 elif expr "$srcdir" : src
/main
>/dev
/null
; then
76 definitions
=" -D__BUILDING_CVC4LIB \\
78 visibility
=' $(FLAG_VISIBILITY_HIDDEN)'
80 clibname
="lib${clibbase}.la"
81 clibtarget
="lib${clibbase}_la"
82 cat >"$srcdir/Makefile.am" <<EOF
84 $definitions -I@srcdir@/$topsrcdir/include -I@srcdir@/$topsrcdir -I@builddir@/$topsrcdir
85 AM_CXXFLAGS = -Wall$visibility
87 noinst_LTLIBRARIES = $clibname
89 ${clibtarget}_SOURCES = \\