gnu-make

Properly build a git submodule with gnu make

谁都会走 提交于 2019-12-04 08:55:50
I currently try to write a Makefile that build properly a project which contains a git submodule. This submodule have its own set of makefiles and produce several targets at once, including some libraries. This Makefile should have the following properties. Don't rebuild twice the submodule even with parallel build. Update the submodule targets when the submodule code has changed (maybe because I navigated through the revisions of the main repository). Re-link the main project when the submodule library have changed. Don't copy-paste the Makefiles of the submodule in the top-level project (i.e

CMake and Make need to be run twice in order to build code successfully

不问归期 提交于 2019-12-04 07:23:09
I am using CMake 3.8.2, GNU make 4.2.1 and GCC 6.4.0 for my C++14 project and I noticed a strange behavior when building. I am using CMake for an out-of-source build in a sub-folder called "build" where I run cmake .. followed by make . CMake runs fine without any errors and make will build all source files like I expect until it is done compiling and starts linking them. It will then fail with an error [ 83%] ... [100%] Linking CXX executable myproject /usr/bin/ld: some-source-file.cc.o: undefined reference to symbol '_ZNKSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEE3strEv@@GLIBCXX

meaning of llvm[n] when compiling llvm, where n is an integer

▼魔方 西西 提交于 2019-12-04 07:01:02
问题 I'm compiling LLVM as well as clang. I noticed that the output of compilation has llvm[1]: or llvm[2]: or llvm[3] : prefixed to each line. What do those integers in brackets mean? 回答1: It's the number of the compilation job ( make -j ). Helpful to trace compilation errors. 回答2: Apparently, it's not connected to the number of the compilation job (can be easily checked via make -j 1). The autoconf-based build system indicates the "level" of the makefile inside the source tree). To be prices, it

Include generated makefile without warning message

淺唱寂寞╮ 提交于 2019-12-04 05:59:59
For a project of mine I am automatically generating makefiles and including them, like this: all: @echo 'SUCCESS is $(SUCCESS)' clean: rm depend.mk depend.mk: @echo 'Creating $@' @echo 'SUCCESS := 1' > $@ .PHONY: all clean include depend.mk This works, but the include line generates a warning message: $ make Makefile:13: depend.mk: No such file or directory Creating depend.mk SUCCESS is 1 I would like to silence that first warning line saying that depend.mk doesn't exist. I know it doesn't exist since I have a rule written to generate it, so the warning is unnecessary (unless of course there

Backtrace for GNU make

筅森魡賤 提交于 2019-12-04 05:34:07
Is there any way to get GNU make to print a "backtrace" of the targets that led to the command being executed when it fails? I regularly deal with heavily obfuscated makefiles while resolving portability issues building software on a new system, and it seems like this should be an extremely simple thing for make to do that would greatly aid in debugging, but I can't find any way to request it. What I'd like to see is something like: gcc: error: ... make[2]: error: gcc ... make[2]: error building target bar make[2]: error building dependency bar for target foo make[1]: error: make -C subdir

How can i pass ENV variables between make targets

情到浓时终转凉″ 提交于 2019-12-04 04:37:30
I have like this in makefile target1: export var1=test $(MAKE) target2 target2: echo $(var1) This is coming as empty I have other depencies so i want to set variable in first target and then all children dependencies should be able to access that EDIT: .ONESHELL: target1: export var1=test echo $(var1) output make target1 export var1=test echo By default make invokes a new shell environment for each recipe, the export ed variable on the first line isn't in scope for the second. You can fix this in multiple ways: Export the variable with make's export directive target1: export var1 := test

Using library paths in makefiles

佐手、 提交于 2019-12-04 03:14:54
I have written a makefile like this: HEADER = -I./cygdrive/c/cpros/kajj/source4 LIBB = -L./cygdrive/c/cpros/kajj/source1 -L./cygdrive/c/cpros/kajj/source2 LIBRA = -larith -ldekk target : game.o gcc $(HEADER) $(LIBB) $< -o $@ $(LIBRA) game.o : game.c gcc -c game.c I have created my own static library and included the header file path and library path. When I execute my makefile it gives an error saying that /usr/lib/gcc cannot find -larith -ldekk . It is pointing to the lib/ directory but it is not over there: -ldekk and -larith are in source1 and source2 files respectively. How to solve this

How can I make a target “private” in GNU make for internal use only? OR: how to best enforce target-specific variable-values?

陌路散爱 提交于 2019-12-04 02:43:44
I have some ancillary targets in a makefile that I want to restrict for internal or "private" use (only) inside the makefile. That is, I want to be able to specify these targets as dependencies from within the makefile, but I want to prevent the target from being specified as a build goal from the command line. Somewhat analogous to a private function from OOP: the target is harmful (or simply doesn't make sense) to build separately. I wish there were a special-target .HIDDEN or .PRIVATE or something that did this, akin to what .PHONY does for non-file targets, but I don't think this exists.

Makefile pattern rule fails?

别来无恙 提交于 2019-12-04 02:35:40
While using GNU-make, my Makefile has some pattern rule as: %.o:%.c gcc $< -o:$@ This rule is added by me. But when I do make it gives an error saying No rule to make target %.o and doesn't build the targets. At times, there is this other behaviour as well. It does not build the target when I say make first time(It gives error saying No rule to make target), but when i say make again immediately, it does build correctly. So when i explicity specify each source file separately, then it builds the targets fine first time itself. EDIT: I am using GNU-make on a Centos (v6.3 i guess, not sure).

How to synthesize line breaks in GNU Make warnings or errors?

旧街凉风 提交于 2019-12-04 00:32:40
问题 When using the built-in $(error text) and $(warning text) functions of GNU Make, how can I get line breaks into the error/warning output without acrobatics? By acrobatics I mean funny methods such as these two: $(warning $(shell /bin/echo -e "something\nfoo\nbar\nbaz")) $(warning $(shell /bin/bash -c 'echo -e "something\nfoo\nbar\nbaz"')) which, btw, didn't work for me with GNU Make 3.81 on Ubuntu 10.04. Rationale: I want to make the error output in conditional parts ( ifeq , ifneq ) of my