Here is my attempt at a redo file for st, instead of a Makefile. I expect it is a complete replacement. If it interests any of you, please take a look and give me constructive criticism. Does it have any flaws? Could it be improved? I know that there are advantages to having the .do files separated, so there is no need to mention that. I am choosing one big file for my learning [1].
Attached and included. Thanks in advance.
[1]
https://redo.readthedocs.io/en/latest/FAQSemantics/#can-i-put-all-my-rules-in-one-big-redofile-like-make-does
CC=${CC:-cc}
VERSION=0.8.4
PREFIX=/usr/local
MANPREFIX=${PREFIX}/share/man
X11INC=/usr/X11R6/include
X11LIB=/usr/X11R6/lib
PKG_CONFIG=pkg-config
INCS="-I${X11INC}"
INCS="$INCS `${PKG_CONFIG} --cflags fontconfig`"
INCS="$INCS `${PKG_CONFIG} --cflags freetype2`"
LIBS="-L${X11LIB} -lm -lrt -lX11 -lutil -lXft"
LIBS="$LIBS `${PKG_CONFIG} --libs fontconfig`"
LIBS="$LIBS `${PKG_CONFIG} --libs freetype2`"
STCPPFLAGS="-DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600"
STCFLAGS="${INCS} ${STCPPFLAGS} ${CPPFLAGS} ${CFLAGS}"
STLDFLAGS="${LIBS} ${LDFLAGS}"
SRC="st.c x.c"
OBJ="st.o x.o"
case "$1" in
# Actual file targets in alphabetical order
config.h)
cp config.def.h "$3"
;;
st)
redo-ifchange $OBJ
$CC -o "$3" $OBJ $STLDFLAGS
;;
*.o)
source="${1%.o}.c"
redo-ifchange "$source" `sed -n 's/#include "\(.*\)"$/\1/p' "$source"`
$CC $STCFLAGS -o "$3" -c "$source"
;;
# ".Phony" targets in alphabetical order
all)
redo-ifchange st
;;
clean)
redo-always
rm -f st $OBJ st-"$VERSION".tar.gz
;;
dist) # this creates an actual file, but it's not called "dist"
redo-always
mkdir -p st-"$VERSION"
cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\
config.def.h st.info st.1 arg.h st.h win.h $SRC\
st-"$VERSION"
tar -cf - st-"$VERSION" | gzip > st-"$VERSION".tar.gz
rm -rf st-"$VERSION"
;;
install)
redo-always
exec >&2
mkdir -p "$DESTDIR$PREFIX"/bin
cp -f st "$DESTDIR$PREFIX"/bin
chmod 755 "$DESTDIR$PREFIX"/bin/st
mkdir -p "$DESTDIR$MANPREFIX"/man1
sed "s/VERSION/$VERSION/g" < st.1 > "$DESTDIR$MANPREFIX"/man1/st.1
chmod 644 "$DESTDIR$MANPREFIX"/man1/st.1
tic -sx st.info
echo Please see the README file regarding the terminfo entry of st.
;;
uninstall)
redo-always
rm -f "$DESTDIR$PREFIX"/bin/st
rm -f "$DESTDIR$MANPREFIX"/man1/st.1
;;
esac
Received on Wed Jan 06 2021 - 14:52:21 CET