How to modify binutils 2.29 Makefile.am and recreate a new Makefile? - automake

I have changed a Makefile.am inside binutils-2.29/binutils directory to create a new library. So I'm running the following command to create a new Makefile
dinesh#dinesh-HP-Ubuntu:/home/packages/binutils-2.29$ sudo libtoolize && aclocal -I./ && autoreconf && automake
It gives me following error:
dinesh#dinesh-HP-Ubuntu:/home/packages/binutils-2.29$ sudo libtoolize && aclocal -I./ && autoreconf && automake
libtoolize: Consider adding '-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
autom4te: cannot open autom4te.cache/requests: Permission denied
aclocal: error: echo failed with exit status: 1
But there is no Makefile.am in the Parent directory, there are Makefile.am inside sub directories.
When i search for Makefile.am I get this:
dinesh#dinesh-HP-Ubuntu:/home/packages/binutils-2.29$ find -iname "Makefile.am" | xargs grep -inr "ACLOCAL_AMFLAGS"
./gas/Makefile.am:21:ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
./gold/Makefile.am:26:ACLOCAL_AMFLAGS = -I ../bfd -I ../config
./opcodes/Makefile.am:21:ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
./binutils/Makefile.am:21:ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
./ld/Makefile.am:21:ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
./zlib/Makefile.am:5:ACLOCAL_AMFLAGS = -I .. -I ../config
./gprof/Makefile.am:21:ACLOCAL_AMFLAGS = -I .. -I ../config -I ../bfd
./bfd/Makefile.am:21:ACLOCAL_AMFLAGS = -I . -I .. -I ../config
In which Makefile.am should I add -I m4 ?
Also In parent directory there are Makefiles with different extensions
dinesh#dinesh-HP-Ubuntu:/home/packages/binutils-2.29$ ls Makefile.*
Makefile.def Makefile.in Makefile.tpl

Related

How do I generate asconfig.texi when compiling GNU binutils' gas from git cloned source?

I have cloned the binutils-gdb repository from git://sourceware.org/git/binutils-gdb.git, checked out the tag binutils-2_40 (commit 32778522c7d8777803c88684b8e428ee729f0b22), in a separate directory run ../../binutils-gdb/configure which generated a large Makefile, then run make all-gas, and I eventually get the error cp: cannot create regular file 'doc/asconfig.texi': No such file or directory.
I have "texi2any (GNU texinfo) 7.0.2" which I (only vaguely) understand is required, but the failing command is cp, so it's as if the makefile isn't building some prerequisite file for the target.
In the tarball of 2.40 from the FTP, gas/doc/asconfig.texi exists, but it doesn't in the repository.
How can I successfully compile the project?
I'm aware there are some workarounds possible, which I'm tempted to follow because I don't even care that much about the documentation in this form anyway, but I dunno - I feel like configure && make && make install should work properly, and therefore that I'm missing something obvious.
The end of the make output is as follows:
Making all in po
make[3]: Entering directory '/home/asday/code/src/github.com/asday/osdev-barebones/build/binutils/gas/po'
file=`echo ../../../../binutils-gdb/gas/po/es | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/es.po
file=`echo ../../../../binutils-gdb/gas/po/fi | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/fi.po
file=`echo ../../../../binutils-gdb/gas/po/fr | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/fr.po
file=`echo ../../../../binutils-gdb/gas/po/id | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/id.po
file=`echo ../../../../binutils-gdb/gas/po/ja | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/ja.po
file=`echo ../../../../binutils-gdb/gas/po/ru | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/ru.po
file=`echo ../../../../binutils-gdb/gas/po/rw | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../..
/../../binutils-gdb/gas/po/rw.po
file=`echo ../../../../binutils-gdb/gas/po/sv | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/sv.po
file=`echo ../../../../binutils-gdb/gas/po/tr | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/tr.po
file=`echo ../../../../binutils-gdb/gas/po/uk | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/uk.po
file=`echo ../../../../binutils-gdb/gas/po/zh_CN | sed 's,.*/,,'`.gmo \
&& rm -f $file && PATH=../src:$PATH /usr/bin/msgfmt -o $file ../../../../binutils-gdb/gas/po/zh_CN.po
make[3]: Leaving directory '/home/asday/code/src/github.com/asday/osdev-barebones/build/binutils/gas/po'
make[3]: Entering directory '/home/asday/code/src/github.com/asday/osdev-barebones/build/binutils/gas'
GEN doc/asconfig.texi
cp: cannot create regular file 'doc/asconfig.texi': No such file or directory
make[3]: *** [Makefile:2234: doc/asconfig.texi] Error 1
make[3]: Leaving directory '/home/asday/code/src/github.com/asday/osdev-barebones/build/binutils/gas'
make[2]: *** [Makefile:1664: all-recursive] Error 1
make[2]: Leaving directory '/home/asday/code/src/github.com/asday/osdev-barebones/build/binutils/gas'
make[1]: *** [Makefile:1010: all] Error 2
make[1]: Leaving directory '/home/asday/code/src/github.com/asday/osdev-barebones/build/binutils/gas'
make: *** [Makefile:5475: all-gas] Error 2
binutils $
The target at the top of that traceback is as follows:
doc/asconfig.texi: doc/$(CONFIG).texi doc/$(am__dirstamp)
$(AM_V_at)rm -f doc/asconfig.texi
$(AM_V_GEN)cp $(srcdir)/doc/$(CONFIG).texi doc/asconfig.texi
$(AM_V_at)chmod u+w doc/asconfig.texi

"Quoting within quoting" question for professed bash affectionate

Out of sheer curiosity I would like to know how this quoting dilemma can be fixed.
I already solved the issue by circumnavigating it (I added [vcodec!*=av01] to the -f argument and simply removed the --exec part entirely). Otherwise it only worked, when there were no spaces or minus signs in the --exec argument.
The culprit line is the last and the issue is at the end with the --exec argument. You can ignore the rest.
Thanks for your help on the road to enlightenment! ;-)
#!/bin/bash
trap "exit" INT
avtomp4conv () {
# tests if the given file (in argument) is an AV1 media and if so, converts it to mp4
echo "${1}"
if ($( ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "${1}" | grep -i av > /dev/null )); then
echo "$1 bad codec"
ffmpeg -hide_banner -loglevel error -stats -i "${1}" -movflags faststart -preset ultrafast "${1%.mp4}_fixed.mp4" && mv "${1}" bogus/ && mv -n "${1%.mp4}_fixed.mp4" "${1}"
fi
}
# ... lotsa other stuff ...
export -f avtomp4conv
cat links.txt | parallel -u -I % --retries 3 --max-args 1 --jobs 4 python3 `which youtube-dl` -c -f "'bestvideo[height<=720][ext=mp4]+bestaudio[ext=m4a]/mp4'" --external-downloader aria2c --external-downloader-args "'-x 4 -s 4'" --exec \'bash -c \"export -f avtomp4conv\;avtomp4conv \{\}\"\' %
Use another function to save you from the double indirection in a single command (parallel executes youtube-dl that executes avtomp4conv). GNU parallel uses your current shell to execute its commands, so no need for bash -c here.
avtomp4conv () {
...
}
ytdl() {
youtube-dl ... --exec "bash -c 'avtomp4conv \"$0\"' {}"
}
export -f avtomp4conv ytdl
< links.txt parallel ... ytdl
Without the function ytdl you could try the following. But why bother with these nested quotes?
< links.txt parallel ... -I insteadOf{} \
"youtube-dl ... --exec \"bash -c 'avtomp4conv \\\"\$0\\\"' {}\""

Makefile not writing files to /usr/local/lib/ in cygwin

I ran a particular Makefile on my Lubuntu machine, and it created a couple directories of files in my /usr/local/lib directory.
Tonight I'm trying to create a similar setup in a cygwin window on my Windows 10 machine. Same Makefile, but the /usr/local/lib directory ends up empty. So when I run a different Makefile later on that wants to call these /usr/local/lib libraries, it fails.
What could I be doing wrong? Is there an environment variable that needs to be set such that the /usr/loal/lib directory can be written to during the make?
Thanks.
Update: I just figured out that I can install Ubuntu as an application in Windows https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/ , and my makefile install is working great now. No problems at all, so it appears to be a cygwin problem only. That being said, here is my make file:
#! /usr/bin/make -f
# -*- make -*-
#
# Main gcc Makefile.
# This makefile is maintained by Greg King <greg.king4#verizon.net>.
# Goals that are supported by the cc65 package
.PHONY: all bins libs docs samples tests clean zap
.PHONY: uninstall install install-bins install-libs install-docs install-samps
# If SYS is defined on this makefile's command-line, then we want it to go
# to "samples" and "tests", but not to the other rules. So, we disable a
# feature of GNU make that would have given ${SYS} to every sub-make.
#MAKEOVERRIDES=
# (That trick has been disabled.)
# To compile with custom make-options, set them here; for example:
#MAKEOPTS = -j 2 CFLAGS=-O4 CC=clang
MAKEOPTS =
# The install prefix and directories
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
datadir = $(prefix)/share
docdir = $(datadir)/doc
libdir = $(exec_prefix)/lib
CC65_DOC = $(docdir)/cc65
CC65_HOME = $(libdir)/cc65
CA65_INC = $(CC65_HOME)/asminc
CC65_INC = $(CC65_HOME)/include
LD65_CFG = $(CC65_HOME)/cfg
LD65_LIB = $(CC65_HOME)/lib
LD65_OBJ = $(CC65_HOME)/obj
# Programs
MKDIR = mkdir -m 755
# BSD-like install-script/-program
INSTALL = make/install-sh
INSTALL_DATA = $(INSTALL) -c -m 644
INSTALL_PROG = $(INSTALL) -c -m 755
INSTALL_STRIP = $(INSTALL_PROG) -s
# This file-name extension is needed on DOS/Windows systems.
ifdef COMSPEC
EXT = .exe
endif
# Rules
# The sample and library-test programs must be compiled for only one platform
# at a time. So, those rules are done automatically only when a user names
# a system on the command-line. (A user can do those rules with their
# defaults by putting "all samples tests" on the command-line.)
#
all: bins libs docs $(SYS:%=samples tests)
bins:
#$(MAKE) -C src -f make/gcc.mak $(MAKEOPTS) \
CA65_INC=\\\"${CA65_INC}/\\\" CC65_INC=\\\"${CC65_INC}/\\\" \
LD65_CFG=\\\"${LD65_CFG}/\\\" LD65_LIB=\\\"${LD65_LIB}/\\\" \
LD65_OBJ=\\\"${LD65_OBJ}/\\\"
libs:
#$(MAKE) -C libsrc
# This rule won't try to generate HTML files
# if a host system doesn't have LinuxDoc Tools.
docs:
#if linuxdoc -B check doc/index >/dev/null 2>&1; \
then $(MAKE) -C doc $(MAKEOPTS) html; \
else echo '"LinuxDoc Tools" is not installed; skipping HTML documentation.'; \
fi
# Some platforms cannot compile all of the sample and library-test programs.
# So, these rules ignore errors.
samples:
-#$(MAKE) -k -C samples prefix=$(prefix) $(SYS:%=SYS=%)
tests:
-#$(MAKE) -k -C testcode/lib prefix=$(prefix) $(SYS:%=SYS=%)
clean zap:
#$(MAKE) -C src -f make/gcc.mak $#
#$(MAKE) -C libsrc $#
#$(MAKE) -C doc $#
#$(MAKE) -C samples $#
# #$(MAKE) -C testcode/lib $# $(SYS:%=SYS=%)
uninstall: install-test
cd $(bindir) && $(RM) ar65${EXT} ca65${EXT} cc65${EXT} cl65${EXT} \
co65${EXT} da65${EXT} ld65${EXT} od65${EXT} grc65${EXT} ca65html
$(RM) -R $(CC65_HOME) $(CC65_DOC)
install: install-test install-dirs install-bins install-libs install-docs
#echo
#echo 'If you installed the files into non-default directories, then'
#echo 'you might need to export some shell environment variables:'
#echo
#echo 'CC65_HOME=$(CC65_HOME)'
#echo ' or'
#echo 'CA65_INC=$(CA65_INC)'
#echo 'CC65_INC=$(CC65_INC)'
#echo 'LD65_CFG=$(LD65_CFG)'
#echo 'LD65_LIB=$(LD65_LIB)'
#echo 'LD65_OBJ=$(LD65_OBJ)'
#echo
#if [ -x $(bindir)/grc${EXT} ]; then \
echo 'grc was renamed to grc65; but, a grc command is in your binaries directory.'; \
echo "If that command is an old copy of CC65's program,"; \
echo 'then you should use a "${MAKE} erase-grc" command to remove it.'; \
fi
.PHONY: install-test
install-test:
#if [ `id -u` != 0 ]; then \
echo; \
echo 'If you are denied permission to install or uninstall this package,'; \
echo 'then you will need to do "make/gcc.mak install" or "make/gcc.mak uninstall"'; \
echo 'as either the root user or an administrator.'; \
echo; \
fi 2>/dev/null
.PHONY: install-dirs
install-dirs: $(bindir) $(datadir) $(docdir) $(libdir) \
$(CC65_DOC) $(CC65_HOME) \
$(CA65_INC) $(CC65_INC) \
$(CC65_INC)/em $(CC65_INC)/geos $(CC65_INC)/joystick \
$(CC65_INC)/mouse $(CC65_INC)/sys $(CC65_INC)/tgi \
$(LD65_CFG) $(LD65_LIB) $(LD65_OBJ) \
$(CC65_HOME)/emd $(CC65_HOME)/joy $(CC65_HOME)/mou \
$(CC65_HOME)/ser $(CC65_HOME)/tgi
$(bindir) $(datadir) $(docdir) $(libdir) \
$(CC65_DOC) $(CC65_HOME) \
$(CA65_INC) $(CC65_INC) \
$(LD65_CFG) $(LD65_LIB) $(LD65_OBJ):
$(MKDIR) -p $# || $(MKDIR) $#
$(CC65_HOME)/% $(CC65_INC)/% $(CC65_DOC)/%:
$(MKDIR) $#
install-bins:
for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc65 sp65; \
do $(INSTALL_STRIP) src/$$f/$$f${EXT} $(bindir) || exit $$?; \
done
$(INSTALL_PROG) src/ca65html/ca65html $(bindir)
install-libs:
for f in asminc/*.inc; \
do $(INSTALL_DATA) $$f $(CA65_INC) || exit $$?; \
done
for f in include/*.h; \
do $(INSTALL_DATA) $$f $(CC65_INC) || exit $$?; \
done
for d in em geos joystick mouse sys tgi; \
do for f in include/$$d/*.h; \
do $(INSTALL_DATA) $$f $(CC65_INC)/$$d || exit $$?; \
done || exit $$?; \
done
for f in libsrc/*.lib; \
do $(INSTALL_DATA) $$f $(LD65_LIB) || exit $$?; \
done
for f in libsrc/*-*.o; \
do $(INSTALL_DATA) $$f $(LD65_OBJ) || exit $$?; \
done
for f in src/ld65/cfg/[!g]*-*.cfg; \
do $(INSTALL_DATA) $$f $(LD65_CFG) || exit $$?; \
done
for d in emd joy mou ser tgi; \
do for f in libsrc/*.$$d; \
do $(INSTALL_DATA) $$f $(CC65_HOME)/$$d || exit $$?; \
done || exit $$?; \
done
install-docs:
for f in src/ca65/macpack/*.mac; \
do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
done
for f in readme.1st compile.txt CREDITS BUGS internal.txt newvers.txt; \
do $(INSTALL_DATA) doc/$$f $(CC65_DOC) || exit $$?; \
done
if [ -f doc/index.htm* ]; \
then for f in doc/*.htm*; \
do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
done; \
fi
install-samps: ${addprefix $(CC65_DOC)/, $(shell find samples -type d)}
#$(MAKE) -C samples zap
for d in `find samples -type d`; \
do for f in $$d/*; \
do if [ -f $$f ]; \
then $(INSTALL_DATA) $$f $(CC65_DOC)/$$d || exit $$?; \
fi; \
done || exit $$?; \
done
erase-grc:
$(RM) $(bindir)/grc${EXT}

Makefile with multiple values for a parameter

Currently, I am working on a makefile that takes a parameter "CLASS=xxx" and then compiles and does stuff with that value.
In the end, it runs an application ($APP) on a bunch of files.
I enter this command:
make default CLASS=Test_UART
and the makefile processes it thusly:
pc: $(APP)
make -C BUILDENV CLASS=$(CLASS) BUILD=just_filelist OUTPUT=filelist.txt SKIPSELF=yes
../classCvt/classCvt <./Applications/$(CLASS).class> ./Applications/$(CLASS).ujc
time -p ./$(APP) ./Applications/$(CLASS).ujc `cat filelist.txt`
Hence it calls a makefile in my BUILDENV folder which does the following:
#USAGE: make -C <PATH_TO_THIS_FILES_PARENT_DIR> CLASS=<MY_JAVA_FILE_NAME_WITHOUT_JAVA_EXTENSION> OUT=<OUTPUT_FILE_NAME>
SELF := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
CLASS ?= PLEASE_SPECIFY_CLASS_PARAM
DIR := $(PWD)#print working directory
CCVT ?= $(SELF)/../../classCvt/classCvt
TOBIN ?= $(SELF)/../../classCvt/tobin
OUTPUT ?=
### Comment: Defining CMD.
ifeq ($(BUILD), just_filelist)
CMD = echo
else
ifeq ($(BUILD), PC)
CMD = echo
else
ifeq ($(BUILD), unopt)
CMD = $(TOBIN)
else
### Comment: Optimized CMD = tobin -c ccvt
CMD = $(TOBIN) -c $(CCVT)
endif
endif
endif
ifeq ($(OUTPUT), )
OUT = &1
else
OUT = $(DIR)/$(OUTPUT)
endif
ifeq ($(SKIPSELF), yes)
MYCLASS =
else
MYCLASS = $(DIR)/Applications/$(CLASS).class
endif
all:
CLASSPATH=$(SELF)/RT/real:$(SELF)/RT/fake:$(DIR) javac $(DIR)/Applications/$(CLASS).java
find $(SELF)/RT/real -iname "*.class" -type f > $(SELF)/files
ls $(DIR)/Applications/*.class | grep -v "$(CLASS)\.class" >> $(SELF)/files || true
cat $(SELF)/files | xargs $(CMD) $(MYCLASS) >$(OUT)
rm -f $(SELF)/files
What I would like to do is give a command like:
make default CLASS=Test1,Test2,Test3
and the makefile to process it for the 3 classes and put the given classes in a .txt and the default classes in a different .txt, something like this like this:
pc: $(APP)
make -C BUILDENV default_classes BUILD=list_default_classes OUTPUT=list_default_classes.txt
# make -C BUILDENV given_classes BUILD=list_given_classes OUTPUT=list_given_classes.txt CLASS=$(CLASS) SKIPSELF=yes
../classCvt/classCvt `cat list_given_classes.txt`./Applications/$(CLASS).ujc
#here the list_given_classes should now contain the .ujc files
time -p ./$(APP) `cat list_given_classes.txt` `cat list_default_classes.txt`
and for the makefile in the BUILDENV, I expect something like:
default_classes:
CLASSPATH=$(SELF)/RT/real:$(SELF)/RT/fake:$(DIR)
find $(SELF)/RT/real -iname "*.class" -type f > $(SELF)/files
ls $(DIR)/Applications/*.class | grep -v "$(CLASS1)\.class" "$(CLASS2)\.class">> $(SELF)/files || true
cat $(SELF)/files | xargs $(CMD) >$(OUT)
rm -f $(SELF)/files
given_classes:
javac $(DIR)/Applications/$(CLASS).java
find $(SELF)/RT/real -iname "*.class" -type f > $(SELF)/files
ls $(DIR)/Applications/*.class | grep -v "$(CLASS)\.class" >> $(SELF)/files || true
cat $(SELF)/files | xargs $(CMD) $(MYCLASS) >$(OUT)
rm -f $(SELF)/files
However, I'm not sure how to do this for a CLASS parameter containing multiple classes.
I'm thinking to try and parse the Test1,Test2,Test3 value into a list of 1,2,3 and then iterating over it. But no clue if this is a good way and even on how to do it.
What do you guys suggest?
Pretty way:
pc: $(APP)
define BUILD_CLASS
pc: pc-$(CLASS_SPLIT)
pc-$(CLASS_SPLIT):
make -C BUILDENV CLASS=$(CLASS_SPLIT) BUILD=just_filelist OUTPUT=filelist.txt SKIPSELF=yes
../classCvt/classCvt <./Applications/$(CLASS_SPLIT).class> ./Applications/$(CLASS_SPLIT).ujc
time -p ./$(APP) ./Applications/$(CLASS_SPLIT).ujc `cat filelist.txt`
endef
CLASSES := $(shell echo $(CLASS) | tr ',' ' ')
$(foreach CLASS_SPLIT, $(CLASSES), $(eval $(BUILD_CLASS)))
Simple way:
pc: $(APP)
$(foreach C, $(shell echo $(CLASS) | tr ',' ' '), \
make -C BUILDENV CLASS=$(C) BUILD=just_filelist OUTPUT=filelist.txt SKIPSELF=yes && \
../classCvt/classCvt <./Applications/$(C).class> ./Applications/$(C).ujc && \
time -p ./$(APP) ./Applications/$(C).ujc `cat filelist.txt` &&) true

How to swap two files in a GNU make function?

I would like to swap two files using a function / macro when running the uninstall target in my Makefile.
Here is what I have which is only leaving one of the files and removing the other two:
swap = mv $(1) $(3); mv $(2) $(1); mv $(3) $(2)
uninstall:
#$(call swap,`printf "%s\n" $(FILE).* | sort -r | sed -n 1p`,\
$(FILE),$(shell mktemp $(FILE).XXX))
If you know what files to swap you could try something like the following. I assume the pairs to swap are fooXXX, barXXX.
define SWAP_files
swap_$(1):
#temp=$$(shell mktemp temp.XXXXXX); \
to_swap_with=$$(patsubst foo%,bar%,$(1)); \
mv $(1) $$$$temp; \
mv $$$$to_swap_with $(1); \
mv $$$$temp $$$$to_swap_with
uninstall: swap_$(1)
endef
$(foreach foo,$(FOOS),$(eval $(call SWAP_files,$(foo))))
Foreach fooXXX file it instantiates a rule:
swap_fooXXX:
#temp=$(shell mktemp temp.XXXXXX); \
to_swap_with=$(patsubst foo%,bar%,fooXXX); \
mv fooXXX $$temp; \
mv $$to_swap_with fooXXX; \
mv $$temp $$to_swap_with
and a rule:
uninstall: swap_fooXXX

Resources