[dev] can redo handle phony targets properly?

From: Greg Reagle <list_AT_speedpost.net>
Date: Fri, 08 Jan 2021 09:55:48 -0500

On Wed, Jan 6, 2021, at 10:56, Greg Reagle wrote:
> On Wed, Jan 6, 2021, at 09:57, Sergey Matveev wrote:
> > > clean)
> > > redo-always
> >
> > No need to add redo-always to the targets that only can be "called" by
> > the human/user. User uses "redo" command, that forces specified targets
> > to be rebuild. So "redo clean/dst/install/whatever" will always do the
> > target. redo-always here is completely useless.
>
> Thank you. I applied this change.

I am experiencing a problem with phony targets in redo [1]. If there exists a file named clean or all or dist or install or uninstall, then redo does not work properly (i.e. it won't run). Even if I put redo-always in the rule. Can I force redo to treat a target as phony somehow? Typescript included followed by redo file.

[1] https://github.com/apenwarr/redo

$ cat typescript
Script started on 2021-01-08 09:54:05-05:00 [TERM="dumb" TTY="/dev/pts/2" COLUMNS="111" LINES="61"]
~/a/st (master|✚3…) $ redo clean
redo clean
~/a/st (master|✚3…) $ touch clean
~/a/st (master|✚3…) $ redo clean
redo: clean - you modified it; skipping
redo: clean - old: '0'
redo: clean - new: '1610117657.081428-0-26608022-33184-1000-1000'
~/a/st (master|✚3…) $

Script done on 2021-01-08 09:54:22-05:00 [COMMAND_EXIT_CODE="0"]


::::::::::::::
default.do
::::::::::::::
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)
                # what if there is a file named 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"
                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-ifchange st
                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)
                rm -f "$DESTDIR$PREFIX"/bin/st
                rm -f "$DESTDIR$MANPREFIX"/man1/st.1
                ;;
        *)
                echo "no rule to build '$1'" >&2
                exit 1
                ;;
esac
Received on Fri Jan 08 2021 - 15:55:48 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 08 2021 - 17:12:10 CET