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

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

Related

Makefile: make text file and append strings in it

I'm having difficulties with makefiles.
So in a recipe, I'm making a file (with a name and a .ujc extension) in a for loop and would like to have a text file at the end which contains all the created files. Purpose is to feed it to an application.
For example, in a semi high-level example,
List= [Class1,Class2,Class3]
foreach(Class C in List) {
#do operations on C > outputs a ClassX.ujc file
# add name of file to a text file named "list_of_files"
}
At the end I should have a text file, list_of_files.txt, which contains the following string:
Class1.ujc Class2.ujc Class3.ujc
As a reference, the code I have at the moment (and which does a bit of the stuff above but does not work is) is:
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 && \
cat app_file_list.txt | xargs echo ./Applications/$(C).ujc >app_file_list.txt && \
) true
time -p ./$(APP) `cat app_file_list.txt` `cat filelist.txt`
The internal make does make a filelist which is fed to the app, but I'd also like to feed the app_file_list but its construction goes totally wrong.
Probably simple, but I'm not getting there.
Edit:
The code below does what I want:
pc: $(APP)
rm -f cat app_file_list.txt
$(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 && \
cat app_file_list.txt | echo ./Applications/$(C).ujc >>app_file_list.txt && \
) true
time -p ./$(APP) `cat app_file_list.txt` `cat filelist.txt`
Notable mistake I made was the xargs.
(Also in the post)
The solution turned out to be not-so-difficult. I needed to remove the xargs command and do the correct operation (i.e., >> instead of >) in the 'cat app_file_list.txt | etc...' line.
The code below does what I want:
pc: $(APP)
rm -f cat app_file_list.txt
$(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 && \
cat app_file_list.txt | echo ./Applications/$(C).ujc >>app_file_list.txt && \
) true
time -p ./$(APP) `cat app_file_list.txt` `cat filelist.txt`
Notable mistake I made was the xargs which caused strings to repeat into the .txt file.

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 can I find and test the *actual linker* a compiler is using, on an arbitrary system?

I need to pass some objects from [ some assembler | another compiler | an archive ] directly to the linker.
But seems that the ld being found on the path is [ broken | missing | linking for the wrong ABI ].
And sometimes, I can't even find ld at all.
How can I find the actual linker being used, by whatever the C compiler happens to be,
[ on a Mac | on Linux | on BSD | from a configure script ]?
I just had to figure this one out.
It was kind of tough, so I thought I'd share.
Give this a shot:
#!/usr/bin/env sh
# 'main;' is the shortest C program possible (I think.).
# So it is compiled, linked, and written to /dev/null.
# So if the linker can't link, this should return 1.
for link in collect2 ld; do # Order matters, because of GCC.
echo 'main;' | $CC -v -x c - -o /dev/null -\#\#\# 2>&1 | grep -q $link &&
echo 'main;' | $CC -v -x c - -o /dev/null -\#\#\# 2>&1 | grep $link |
sed -e "s|\(.*$link\).*|\1|" -e 's/ //g' -e 's|"||' && break
done
# That should work on just about anything, and returns an absolute path,
# except with ICC. If we want to try to get an absolute path there too,
# we have to:
# If 'which' is missing, and it might not have an -s flag.
which="$(which which >/dev/null 2>&1)" || which=echo
$which "$(for link in collect2 ld; do
echo 'main;' | $CC -v -x c - -o /dev/null -\#\#\# 2>&1 | grep -q $link &&
echo 'main;' | $CC -v -x c - -o /dev/null -\#\#\# 2>&1 | grep $link |
sed -e "s|\(.*$link\).*|\1|" -e 's/ //g' -e 's|"||' && break
done)"
So you might have just said,
Come on guy, no way that's necessary! Just, like, which ld.
Honestly and truly, that doesn't work for me a large portion of the time.
Its not so unusual today, since ld is frequently a wrapper.
Lets test it, see what turns up:
#!/usr/bin/env sh
# On my Mac, nothing too special, I swear.
# Just a MacBook, Xcode, GCC from Homebrew, and one commercial compiler.
echo; $which ld; echo "...Not necessarily."; echo
for CC in cc gcc clang icc; do echo $c:
for link in collect2 ld; do
echo 'main;' | $CC -v -x c - -o /dev/null -\#\#\# 2>&1 | grep -q $link &&
echo 'main;' | $CC -v -x c - -o /dev/null -\#\#\# 2>&1 | grep $link |
sed -e "s|\(.*$link\).*|\1|" -e 's/ //g' -e 's|"||' && break
done
which="$(which which 2>/dev/null 1>&1)" || which=echo
$which "$(for link in collect2 ld; do
echo 'main;' | $CC -v -x c - -o /dev/null -\#\#\# 2>&1 | grep -q $link &&
echo 'main;' | $CC -v -x c - -o /dev/null -\#\#\# 2>&1 | grep $link |
sed -e "s|\(.*$link\).*|\1|" -e 's/ //g' -e 's|"||' && break
done)"
echo
done
Returns:
/usr/bin/ld
...Not necessarily.
cc:
/Applications/Xcode51-Beta4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
/Applications/Xcode51-Beta4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
gcc:
/Users/Shared/usr/local/Cellar/gcc49/4.9-20140119/libexec/gcc/x86_64-apple-darwin13.1.0/4.9.0/collect2
/Users/Shared/usr/local/Cellar/gcc49/4.9-20140119/libexec/gcc/x86_64-apple-darwin13.1.0/4.9.0/collect2
clang:
/Applications/Xcode51-Beta4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
/Applications/Xcode51-Beta4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
icc:
ld
/usr/bin/ld

Insert dependency in parallel makefile

I'm trying to add an extra dependency to a rule in a parallel makefile. I might have found a way, but I'm in doubt. (I haven't written the original makefile and I'm not an expert in make.)
The original makefile looks like this:
VER = busybox-1.16.2
URL = http://busybox.net/downloads/$(VER).tar.bz2
export KBUILD_OUTPUT = $(ROOTDIR)/user/busybox/build-$(VER)
all: build-$(VER)/.config depmod.pl
$(MAKE) -C build-$(VER)
build-$(VER)/.config: $(ROOTDIR)/config/.config
mkdir -p build-$(VER)
sed -n \
-e '/_CROSS_COMPILER_PREFIX=/s:=.*:="$(CROSS_COMPILE)":' \
-e '/CONFIG_USER_BUSYBOX_/s:CONFIG_USER_BUSYBOX_:CONFIG_:p' \
$< > $#.uclinux-dist.new
set -e ; \
if [ ! -e $# ] || ! cmp -s $#.uclinux-dist.new $#.uclinux-dist.old ; then \
cp $#.uclinux-dist.new $#.uclinux-dist.old ; \
cp $#.uclinux-dist.old $# ; \
yes "" | $(MAKE) -C $(VER) oldconfig ; \
fi
depmod.pl: $(VER)/examples/depmod.pl
ln -sf $< $#
I want to add a 'download' rule to the make.
$(VER)/: $(VER).tar.bz2
tar -jxvf $(VER).tar.bz2
touch $#
$(VER).tar.bz2:
wget $(URL)
touch $#
This rule must be executed before anything else. The parallel build prevent constructs like
all: |$(VER)/ build-$(VER)/.config depmod.pl
(This works in single threaded builds.)
My solution so far is this:
VER = busybox-1.18.5
URL = http://busybox.net/downloads/$(VER).tar.bz2
export KBUILD_OUTPUT = $(ROOTDIR)/user/busybox/build-$(VER)
all: build-$(VER)/.config depmod.pl
$(MAKE) -C build-$(VER)
$(VER)/: $(VER).tar.bz2
tar -jxvf $(VER).tar.bz2
touch $#
$(VER).tar.bz2:
wget $(URL)
touch $#
build-$(VER)/.config: $(ROOTDIR)/config/.config | $(VER)/
mkdir -p build-$(VER)
sed -n \
-e '/_CROSS_COMPILER_PREFIX=/s:=.*:="$(CROSS_COMPILE)":' \
-e '/CONFIG_USER_BUSYBOX_/s:CONFIG_USER_BUSYBOX_:CONFIG_:p' \
$< > $#.uclinux-dist.new
set -e ; \
if [ ! -e $# ] || ! cmp -s $#.uclinux-dist.new $#.uclinux-dist.old ; then \
cp $#.uclinux-dist.new $#.uclinux-dist.old ; \
cp $#.uclinux-dist.old $# ; \
yes "" | $(MAKE) -C $(VER) oldconfig ; \
fi
depmod.pl: $(VER)/examples/depmod.pl
ln -sf $< $#
$(VER)/examples/depmod.pl: | $(VER)/
Problem is, I don't really know what kind of magic the depmod.pl rule is. Is it executed correctly, now that I've added an explicit empty rule?
I'd hate to answer my own question, but I think I've found the answer.
The dependency of the depmod.pl rule is not real/relevant in the original script.
The code:
depmod.pl: $(VER)/examples/depmod.pl
ln -sf $< $#
Ought to be written:
depmod.pl:
ln -sf $(VER)/examples/depmod.pl $#
So my extra empty rule makes no difference. In the new script, the dependency almost makes sence though.

libzip makefile error: make: *** No rule to make target `/Makefile.common'. Stop

I cloned libzip from github and now want to do the make but it gives an error ***No rule to make target '/Makefile.common' Stop. The cloned folder (libzip) has 3 files (libzip.spec, sources, Makefile).This is the Makefile, what could be the problem.
# This makefile is downloading any file found in
# the 'sources' file already existing in this directory
# and validating the sha256sum of the archive against it.
NAME := libzip
define find-common-dir
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then echo "$$d"; break ; fi ; done
endef
COMMON_DIR := $(shell $(find-common-dir))
include $(COMMON_DIR)/Makefile.common
SOURCEFILES := $(shell cat sources 2>/dev/null | awk '{ print $$2 }' | awk -F'*' '{ print $$2 }')
sources: $(SOURCEFILES)
$(SOURCEFILES):
#for sourcefile in $(SOURCEFILES); do \
$(CLIENT) $(LOOKASIDE_URI)/$(NAME)/$${sourcefile}; \
done
sha256sum -c sources || ( echo 'SHA256 check failed' && rm $(SOURCEFILES); exit 1 )
clean:
rm $(SOURCEFILES)
Please use the official mercurial repository:
http://hg.nih.at/libzip/
and let us know if you still have problems.

Resources