I am facing some strange changes in behaviour between gmake 3.8 and gmake 4.0. This is observed on the same machine, running Windows 7. The following is a much simplified example - it is obviously not a useful makefile, but illustrates the issue.
make -v output for 3.8 identifies as:
GNU Make 3.80
and 4.0 as:
GNU Make 4.0
Built for Windows32
The "Built for Windows32" is missing from the 3.8 output, but I assume this was added after the 3.8 release.
Consider the following directory structure:
.
./Build
./PROJ1
./PROJ1/Makefile
And following makefile in PROJ1:
.PHONY: build clean
build:
#echo Build Recipe
clean:
#echo Clean Recipe
This makefile is run from the parent directory eg:
make -C PROJ1 build.
In gmake 3.8, this does the expected thing of printing Build Recipe:
make: Entering Directory PROJ1
Build Recipe
make: Exiting Directory PROJ1
However, the same makefile in gmake 4.0 does something unexpected:
make -C PROJ1 build
make: Entering directory 'PROJ1'
make: *** No rule to make target 'Build'. Stop.
make: Leaving directory 'PROJ1'
Strange. For some reason it is trying to make 'Build' rather than 'build'. Now, if we try to make clean, then in both 3.8 and 4.0 we get the following:
testmake>make -C PROJ1 clean
make: Entering directory 'PROJ1'
Clean Recipe
make: Leaving directory 'PROJ1'
Which is the desired behaviour. One thing i noticed is that this affects every target where there is a directory with a name differing only by case - and we can demonstrate this by creating a directory "Clean":
.
./Build
./Clean
./PROJ1
./PROJ1/Makefile
make -C PROJ1 clean
make: Entering directory 'PROJ1'
make: *** No rule to make target 'Clean'. Stop.
make: Leaving directory 'PROJ1'
What is going on, and how can I resolve this?
Interestingly, gmake 4.2.1 running in cygwin does not exhibit the crazy behaviour - it correctly executes the build or clean recipe as requested.
Related
I am trying to create an package for dietsplash for buildroot, and I've added the files
Config.in
config BR2_PACKAGE_DIETSPLASH
bool "dietsplash"
help
dietsplash is an simple splash screen service for
embedded devices. It has support for animations.
dietsplash.mk
################################################################################
#
# dietsplash
#
################################################################################
DIETSPLASH_VERSION = v0.3
DIETSPLASH_SOURCE = dietsplash-$(DIETSPLASH_VERSION).tar.gz
DIETSPLASH_SITE = git://github.com/lucasdemarchi/dietsplash.git
DIETSPLASH_AUTORECONF = YES
$(eval $(autotools-package))
The github repository is
https://github.com/lucasdemarchi/dietsplash
The output of make is:
>>> dietsplash v0.3 Building
PATH="/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/host/bin:/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/host/sbin:/home/justus_fluegel/.pub-cache/bin/:/usr/share/flutter/flutter/bin/cache/dart-sdk/bin/:/usr/share/flutter/flutter/bin/:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin:/snap/bin:/usr/local/texlive/2019/bin/x86_64-linux" /usr/bin/make -j5 -C /media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3/
make[1]: Entering directory '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3'
/usr/bin/make all-am
make[2]: Entering directory '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3'
GEN src/background.h
/bin/bash: src/genstaticlogo: cannot execute binary file: Exec format error
Makefile:1017: recipe for target 'src/background.h' failed
make[2]: *** [src/background.h] Error 126
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3'
Makefile:400: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3'
package/pkg-generic.mk:238: recipe for target '/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3/.stamp_built' failed
make: *** [/media/justus_fluegel/PROJECTS/buildroot/buildroot-2019.11.1/output/build/dietsplash-v0.3/.stamp_built] Error 2
And file of src/genstaticlogo
src/genstaticlogo: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 4.19.0, not stripped
I think the problem is that src/genstaticlogo is compiled for the target but executed by the Makefile.am during the build process. How do I tell make to compile src/genstaticlogo for the build machine and not for the target? Altough the repository is not my work, it's theoretically possible to modify the makefile after download.
Thank you for your help!
You will need to patch the Makefile.am to support cross-compilation. See this old answer for details. In short, you will need something like this in the Makefile.am:
$(genstaticlogo_OBJECTS): CC=$(CC_FOR_BUILD)
$(genstaticlogo_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD)
$(genstaticlogo_OBJECTS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
Since you will be patching Makefile.am, you will also need to set DIETSPLASH_AUTORECONF = YES in the Buildroot dietsplash.mk file.
GOAL: compile samples/bpf, compile bpf/bpftool and use them.
PROBLEM: on a VM with Ubuntu 18.04 bionic with a kernel 4.18.0-25-generic I've installed kernel src code executing apt install linux-source-4.18.0.
Now I cd into /usr/src/linux-source-4.18.0/linux-source-4.18.0/samples/bpf and I run make and the result is
make -C ../../ /usr/src/linux-source-4.18.0/linux-source-4.18.0/samples/bpf/ BPF_SAMPLES_PATH=/usr/src/linux-source-4.18.0/linux-source-4.18.0/samples/bpf
make[1]: Entering directory '/usr/src/linux-source-4.18.0/linux-source-4.18.0'
scripts/kconfig/conf --syncconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
scripts/kconfig/Makefile:40: recipe for target 'syncconfig' failed
make[3]: *** [syncconfig] Error 1
Makefile:562: recipe for target 'syncconfig' failed
make[2]: *** [syncconfig] Error 2
make[1]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/kernel.release'. Stop.
make[1]: Leaving directory '/usr/src/linux-source-4.18.0/linux-source-4.18.0'
Makefile:203: recipe for target 'all' failed
make: *** [all] Error 2
If I cd into ../samples/bpf and I run sudo make the result is
Auto-detecting system features:
... libbfd: [ OFF ]
... disassembler-four-args: [ OFF ]
CC map_perf_ring.o
CC xlated_dumper.o
CC perf.o
CC cfg.o
CC common.o
CC cgroup.o
CC main.o
main.c:36:10: fatal error: bfd.h: No such file or directory
#include <bfd.h>
^~~~~~~
compilation terminated.
Makefile:92: recipe for target 'main.o' failed
make: *** [main.o] Error 1
QUESTIONS: what am I missing? After I compile them if I want to write a program which, for example, needs to use bpftool I have to write the program inside the source kernel directory or I can write it everywhere?
Build errors
The first case (Makefile:562: recipe for target 'syncconfig' failed) fails because you run make from the top of the linux kernel repository, and before trying to compile the samples, the build system tries to load a config file to use for your system (but does not find one).
Before trying to build the samples (make -C samples/bpf), you can create a .config file from your current kernel configuration like this:
$ cp /usr/src/linux-headers-$(uname -r)/.config <path to repo>/.config
$ make olddefconfig
Or even simply generate a default config file from scratch:
$ make defconfig
See make help from top directory to see the available make options.
Your second error, regarding bfd.h not found, is that you miss a library. Libbfd on Ubuntu comes with binutils-dev, so apt install binutils-dev should do the trick.
Compiling the programs
Finally, regarding your question on compiling the programs:
You can write and build program from the kernel repository, just by creating a new sample and reusing the existing Makefiles.
You can also write and compile programs outside of the kernel tree. The basic clang (v4.0 or above, if possible v6.0 or above) command to compile them usually looks something like this:
$ clang -O2 -emit-llvm -c my_bpf_prog.c -o - | \
llc -march=bpf -filetype=obj -o my_bpf_prog.o
You can find examples of programs compiled out of the kernel tree in that repository (disclaimer: by my company) or in the XDP tutorial repo.
I am trying to compile Ruby 2.4.5 from source using gcc compiler on AIX 7.1. The configure works fine, but the make fails giving an error C is not a recognized flag. Anybody faced the same issue and managed to compile ruby on AIX 7.1?
Steps followed:
1) ./configure --disable-install-doc CC="gcc" CFLAGS="-maix64 -mminimal-toc" CXX="g++" CXXFLAGS="-maix64 -mminimal-toc" NM="nm -X64" AR="ar -X64" LDFLAGS="-maix64" EXTLDFLAGS=" -- works perfectly fine
2) make - fails with the below error
make: Not a recognized flag: C
usage: make [-einqrst] [-k|-S] [-d[A|adg[1|2]mstv]] [-D variable] [-f makefile] [-j [jobs]] [variable=value ...] [target ...]
make: 1254-004 The error code from the last command is 2.
Stop.
make: 1254-004 The error code from the last command is 2.
Stop.
make: 1254-004 The error code from the last command is 2.
Update :
Switching to GNU make gives the below error:
Making all in man
make[5]: Entering directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1/man'
make[5]: Nothing to be done for 'all'.
make[5]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1/man'
make[5]: Entering directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1'
CC src/prep_cif.lo
CC src/types.lo
CC src/raw_api.lo
CC src/java_raw_api.lo
CC src/closures.lo
CC src/powerpc/ffi_darwin.lo
../../../../ext/fiddle/libffi-3.2.1/src/powerpc/ffi_darwin.c: In function 'ffi_p rep_args':
../../../../ext/fiddle/libffi-3.2.1/src/powerpc/ffi_darwin.c:112:17: warning: un used variable 'abi' [-Wunused-variable]
const ffi_abi abi = ecif->cif->abi;
^
CPPAS src/powerpc/aix.lo
libtool: compile: unable to infer tagged configuration
libtool: compile: specify a tag with `--tag'
Makefile:1335: recipe for target 'src/powerpc/aix.lo' failed
make[5]: *** [src/powerpc/aix.lo] Error 1
make[5]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1'
Makefile:1596: recipe for target 'all-recursive' failed
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1'
Makefile:730: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle/libffi-3.2.1'
Makefile:370: recipe for target 'libffi-3.2.1/.libs/libffi_convenience.a' failed
make[2]: *** [libffi-3.2.1/.libs/libffi_convenience.a] Error 2
make[2]: Leaving directory '/test/ruby-2.4.5/tst/ext/fiddle'
exts.mk:212: recipe for target 'ext/fiddle/all' failed
make[1]: *** [ext/fiddle/all] Error 2
make[1]: Leaving directory '/test/ruby-2.4.5/tst'
uncommon.mk:220: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2
The issue is that you are using AIX's built-in copy of make and it does not support the command-line option -C. That option is available in GNU make.
If you run make -v and do not see output like the following then you are not using GNU make:
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
Run the command which make and it will return either /usr/bin/make or /opt/freeware/bin/make (or a similar path outside of /usr/bin):
If it returns /usr/bin/make then you do not have GNU make installed on your system and will need to follow one of several tutorials to get it installed on AIX.
If it returns /opt/freeware/bin/make then you do have GNU make installed, but it's not reflected in $PATH. You can add it to your path temporarily while you compile Ruby by running export PATH=/opt/freeware/bin:$PATH before you run the make command.
Update:
I would encourage you to open a separate question for your current build trouble, since the original question was about the -C flag for make not working on AIX, and now you have a separate question about running GNU make with an entirely different set of issues and possible solutions.
That said, it's possible you may be able to resolve your issue by starting over and running ./configure LIBTOOL='/usr/bin/libtool --tag=CC' (or whatever your path is to libtool). This is based off the following messages:
libtool: compile: unable to infer tagged configuration
libtool: compile: specify a tag with `--tag'
If this doesn't work then you'll probably have to edit the Makefile by looking for those specific invocations of libtool and append --tag=CC to them one by one until you're able to progress beyond these errors.
Both solutions are assuming that the only code being compiled is C. To my knowledge, everything in MRI that needs to be compiled is written in C, but if anything is written in C++ then the libtool invocations would require --tag=CXX. You can read more about tags here.
I'm trying to compile transmission from source code checkout from svn, and ran into some issues compiling.
It says
"Makefile.in:15 *** missing seperator..."
where the line was #SET_MAKE# that has no white spaces in front of it.
After I commented out that line, it says:
make: #SHELL#: Command not found
Makefile.in:484: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 127
The Makefile.in is generated by ./autogen.sh
Automake and Autoconf are both up-to-date and exceeds minimum requirement.
Debian Jessie updated.
Makefile.in is only a template for a makefile, this is typically used by GNU Autotools. In order to generate a Makefile from that template, you have to run ./configure, which should also have been generated by ./autogen.sh.
I am new to compiling.
I am trying to compile iperf3 for Windows 10 because there is no official Windows distribution of iperf3 and for the learning experience. I am trying to do so on the new Windows Subsystem for Linux feature via Bash on Ubuntu on Windows, also for the learning experience.
I installed mingw-w64, which should give me the proper compiler and environment necessary for cross-compiling:
sudo apt-get install mingw-w64
This put two directories into my /usr directory:
i686-w64-mingw32
x86_64-w64-mingw32
It also put a bunch of things that look like compilers into /usr/bin.
I unzipped the .tar.gz file from iperf3 and navigated into it. Then, I run ./configure --host=i686-w64-mingw32.static and it completes without errors.
I note that the output of the command has a worrisome line: checking for i686-w64-mingw32.static-gcc... no
I note that the Makefile's CC variable is set to gcc, which doesn't sound like the proper compiler.
Then, I run make. It fails with errors:
collect2: error: ld returned 1 exit status
make[2]: *** [iperf3] Error 1
make[2]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/snip/iperf3/iperf-3.1.4/src'
make: *** [all-recursive] Error 1
I also see the line: libtool: warning: undefined symbols not allowed in i686-w64-mingw32.static shared libraries; building static only
I think that the ./configure is not working correctly since it appears to have not found the right compiler for my --host argument and put it in the Makefile.
What am I doing wrong?
EDIT:
I changed the command to ./configure --host=i686-w64-mingw32 per comments and it completes without error. But no makefile is created so make yields make: *** No targets specified and no makefile found. Stop.
What am I doing wrong, now?
EDIT 2:
Looks like the ./configure actually is failing. Last line of its output is nanosleep() required for timing operations., which seems to mean that its missing a library for nanosleep.
How do I get nanosleep?
mingw doesn't support nanosleep. So programs using it cannot be compiled using mingw-w64.