1# Install/unInstall package files in LAMMPS
2# mode = 0/1/2 for uninstall/install/update
3
4mode=$1
5
6# arg1 = file, arg2 = file it depends on
7
8# enforce using portable C locale
9LC_ALL=C
10export LC_ALL
11
12action () {
13  if (test $mode = 0) then
14    rm -f ../$1
15  elif (! cmp -s $1 ../$1) then
16    if (test -z "$2" || test -e ../$2) then
17      cp $1 ..
18      if (test $mode = 2) then
19        echo "  updating src/$1"
20      fi
21    fi
22  elif (test -n "$2") then
23    if (test ! -e ../$2) then
24      rm -f ../$1
25    fi
26  fi
27}
28
29# all package files with no dependencies
30
31for file in *.cpp *.h; do
32  test -f ${file} && action $file
33done
34
35# edit 2 Makefile.package files to include/exclude package info
36
37if (test $1 = 1) then
38
39  if (test -e ../Makefile.package) then
40    sed -i -e 's/[^ \t]*poems[^ \t]* //' ../Makefile.package
41    sed -i -e 's|^PKG_INC =[ \t]*|&-I../../lib/poems |' ../Makefile.package
42    sed -i -e 's|^PKG_PATH =[ \t]*|&-L../../lib/poems |' ../Makefile.package
43    sed -i -e 's|^PKG_LIB =[ \t]*|&-lpoems |' ../Makefile.package
44  fi
45
46  if (test -e ../Makefile.package.settings) then
47    sed -i -e '/^include.*poems.*$/d' ../Makefile.package.settings
48    # multiline form needed for BSD sed on Macs
49    sed -i -e '4 i \
50include ..\/..\/lib\/poems\/Makefile.lammps
51' ../Makefile.package.settings
52  fi
53
54elif (test $1 = 0) then
55
56  if (test -e ../Makefile.package) then
57    sed -i -e 's/[^ \t]*poems[^ \t]* //' ../Makefile.package
58  fi
59
60  if (test -e ../Makefile.package.settings) then
61    sed -i -e '/^include.*poems.*$/d' ../Makefile.package.settings
62  fi
63
64fi
65