Skip to content

Commit

Permalink
Adopt PREFIX for installation destination
Browse files Browse the repository at this point in the history
  • Loading branch information
dspinellis committed Jul 29, 2024
1 parent 96c2cde commit 2025fe3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions doc/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ You install <em>CScout</em> in five steps:
<li> Run <code>sudo make install</code>. If you want the installation
to use a different directory hierarchy than the default
<code>/usr/local</code></li>, you can specify this on the command
line with the <code>INSTALL_PREFIX</code> variable.
For example, you run <code>make install INSTALL_PREFIX=/home/mydir</code>
line with the <code>PREFIX</code> variable.
For example, you run <code>make install PREFIX=/home/mydir</code>
to install <em>CScout</em> under your home directory or
<code>sudo make install INSTALL_PREFIX=/usr</code>
<code>sudo make install PREFIX=/usr</code>
to install <em>CScout</em> under /usr.
</ol>

Expand Down
18 changes: 9 additions & 9 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with CScout. If not, see <http://www.gnu.org/licenses/>.
#

INSTALL_PREFIX?=/usr/local
PREFIX?=/usr/local

# By default a production build is made.
# For a debug build run make as:
Expand Down Expand Up @@ -87,7 +87,7 @@ AUTOHEADERS=parse.tab.h
YACC=../btyacc/btyacc
#YACC=yacc

CPPFLAGS+=-pipe -Wall -I. -DINSTALL_PREFIX='"$(INSTALL_PREFIX)"'
CPPFLAGS+=-pipe -Wall -I. -DPREFIX='"$(PREFIX)"'
CXXFLAGS+=-std=gnu++11
ifdef DEBUG
# Debug build
Expand Down Expand Up @@ -270,15 +270,15 @@ obfuscation:
)

install: build/cscout
install -Ds $< "$(INSTALL_PREFIX)/bin/cscout"
./dest-install.sh "$(INSTALL_PREFIX)"
install -Ds $< "$(PREFIX)/bin/cscout"
./dest-install.sh "$(PREFIX)"

uninstall:
rm -f "$(INSTALL_PREFIX)/bin/cscc"
rm -f "$(INSTALL_PREFIX)/bin/cscout"
rm -f "$(INSTALL_PREFIX)/bin/csmake"
rm -f "$(INSTALL_PREFIX)/bin/cswc"
rm -rf "$(INSTALL_PREFIX)/include/cscout"
rm -f "$(PREFIX)/bin/cscc"
rm -f "$(PREFIX)/bin/cscout"
rm -f "$(PREFIX)/bin/csmake"
rm -f "$(PREFIX)/bin/cswc"
rm -rf "$(PREFIX)/include/cscout"

example: build/cscout
cd ../example && ../src/build/cscout awk.cs
Expand Down
10 changes: 5 additions & 5 deletions src/dest-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
#host-defs * * *
#csmake-defs * *

INSTALL_PREFIX="${1-/usr/local}"
PREFIX="${1-/usr/local}"
TMPFILE="/tmp/$0-$$"
INC=../include
INCLUDE_DIR="$INSTALL_PREFIX/include/cscout"
INCLUDE_DIR="$PREFIX/include/cscout"
# Permissions for header files
HMODE=644

Expand All @@ -43,7 +43,7 @@ WORKAROUNDS_PRE="$INC/template/gcc-defs.h $INC/template/llvm-defs.h $INC/templat
WORKAROUNDS_POST="$INC/template/llvm-undefs.h"

# Create required directories
install -d "$INCLUDE_DIR/stdc" "$INSTALL_PREFIX/bin"
install -d "$INCLUDE_DIR/stdc" "$PREFIX/bin"

# Generic C definitions
install -m $HMODE $INC/stdc/*.h "$INCLUDE_DIR/stdc/"
Expand Down Expand Up @@ -94,9 +94,9 @@ install -m $HMODE $TMPFILE "$INCLUDE_DIR/host-incs.h"
# Perl scripts (keep csmake.pl in the end)
for f in cswc.pl csmake.pl ; do
sed "s|INSTALL_INCLUDE|$INCLUDE_DIR|g" $f >$TMPFILE
install $TMPFILE "$INSTALL_PREFIX/bin/$(basename $f .pl)"
install $TMPFILE "$PREFIX/bin/$(basename $f .pl)"
done
# Install as cscc
install $TMPFILE "$INSTALL_PREFIX/bin/cscc"
install $TMPFILE "$PREFIX/bin/cscc"

rm -f $TMPFILE
4 changes: 2 additions & 2 deletions src/fileutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ cscout_dirs()
dirs.push_back("../src");
#endif
dirs.push_back(".cscout");
#if defined(INSTALL_PREFIX)
dirs.push_back(INSTALL_PREFIX "/include");
#if defined(PREFIX)
dirs.push_back(PREFIX "/include");
#endif
if (getenv("CSCOUT_HOME"))
dirs.push_back(getenv("CSCOUT_HOME"));
Expand Down

0 comments on commit 2025fe3

Please sign in to comment.