From 2025fe3e0d8f040da1e630cc79daed0b56056bc2 Mon Sep 17 00:00:00 2001 From: Diomidis Spinellis Date: Mon, 29 Jul 2024 14:34:49 +0300 Subject: [PATCH] Adopt PREFIX for installation destination --- doc/setup.xml | 6 +++--- src/Makefile | 18 +++++++++--------- src/dest-install.sh | 10 +++++----- src/fileutils.cpp | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/setup.xml b/doc/setup.xml index 883285e3..50537850 100644 --- a/doc/setup.xml +++ b/doc/setup.xml @@ -40,10 +40,10 @@ You install CScout in five steps:
  • Run sudo make install. If you want the installation to use a different directory hierarchy than the default /usr/local
  • , you can specify this on the command -line with the INSTALL_PREFIX variable. -For example, you run make install INSTALL_PREFIX=/home/mydir +line with the PREFIX variable. +For example, you run make install PREFIX=/home/mydir to install CScout under your home directory or -sudo make install INSTALL_PREFIX=/usr +sudo make install PREFIX=/usr to install CScout under /usr. diff --git a/src/Makefile b/src/Makefile index 69a918d2..29928933 100644 --- a/src/Makefile +++ b/src/Makefile @@ -17,7 +17,7 @@ # along with CScout. If not, see . # -INSTALL_PREFIX?=/usr/local +PREFIX?=/usr/local # By default a production build is made. # For a debug build run make as: @@ -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 @@ -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 diff --git a/src/dest-install.sh b/src/dest-install.sh index 42d7913d..256f05dc 100755 --- a/src/dest-install.sh +++ b/src/dest-install.sh @@ -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 @@ -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/" @@ -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 diff --git a/src/fileutils.cpp b/src/fileutils.cpp index 27c940cb..25ae7c27 100644 --- a/src/fileutils.cpp +++ b/src/fileutils.cpp @@ -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"));