gnu-make

multi-wildcard pattern rules of GNU Make

杀马特。学长 韩版系。学妹 提交于 2019-12-06 17:12:33
问题 I want to write something like regex: SRC:="a.dat.1 a.dat.2" $(SRC): %.dat.%: (\\1).rlt.(\\2) dat2rlt $^ $@ so that a.dat.1 and a.dat.2 will give a.rlt.1 and a.rlt.2 . In GNU Make info page, it says "the % can be used only once". Is there some trick to achieve this in GNU Make? 回答1: I'm afraid what you are trying to do is not possible the way you suggest to do it, since - as you already mention - (GNU) make only allows a single stem '%', see http://www.gnu.org/software/make/manual/make.html

Where do I place the makefile of a project? [closed]

本小妞迷上赌 提交于 2019-12-06 13:43:15
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . Assume the directory of a project contains subdirectories such as src , bin , lib , doc , etc. Where do I put the makefile of a project? For example, some projects put their makefile in src/ subdirectory of the root directories of the projects, some projects put their makefiles

Making multiple files from multiple files with one command in gnu make

倾然丶 夕夏残阳落幕 提交于 2019-12-06 12:26:16
Assume 1000 files with extension .xhtml are in directory input, and that a certain subset of those files (with output paths in $(FILES), say) need to be transformed via xslt to files with the same name in directory output. A simple make rule would be: $(FILES): output/%.xhtml : input/%.xhtml saxon s:$< o:$@ foo.xslt This works, of course, doing the transform one file at a time. The problem is that I want to use saxon's batch processing to do all the files at one time, since, given the number of files, that would be much faster, considering the overhead of loading java and saxon for each file.

How do I get a makefile function to stop the current target?

不想你离开。 提交于 2019-12-06 11:51:20
I have a function in a makefile that I want to stop the entire make run if a file doesn't exist, or at least the target it is executed from: vaultfile = ./vault $(shell test -f $(1) || exit 1) define get_token $(shell test -f $1 && cat $1 || exit 2) endef a: token = $(call get_token,$(vaultfile),tokenname) a: echo ==== $(token) .PHONY=a The above doesn't work, silently failing when the file is missing $ rm vault $ make echo ==== ==== $ echo f > vault $ make echo ==== f ==== f I want this to be in the function, because most targets do not call the function (which obviously does more IRL). How

Relink Makefile target when list of dependencies changes

梦想与她 提交于 2019-12-06 07:47:11
A common problem I've seen with Makefiles is that executables (and libraries, for that matter) aren't necessarily relinked when the list of dependencies changes. For example: SRCS=$(wildcard *.c) CPPFLAGS=-MMD -MP target: $(SRCS:.c=.o) $(CC) $(LDFLAGS) $^ -o $@ -include $(SRCS:.c=.d) So far, so good: it automatically handles any changes to source files and their included dependencies. If a file is added (because of the wildcard, that means just adding it to the directory, but an explicit list would have the same problem), make sees it and relinks the target. However, when a source file is

Number of parallel build jobs in recursive make call

做~自己de王妃 提交于 2019-12-06 06:00:46
问题 I have a makefile which wraps the real build in a single recursive call, in order to grab and release a license around the build, regardless of whether the build succeeds. Example: .PHONY main_target main_target: @license_grab & @sleep 2 -@$(MAKE) real_target @license_release This works great, until I want to run the make in parallel. On some systems it works fine, but on other systems I run into the documented problem with the -j flag when passing options to a sub-make: If your operating

Overriding `CC` and `CXX` variables in makefiles

馋奶兔 提交于 2019-12-06 05:48:45
I have a master makefile, which contains generic settings, and a child makefile that has project specific settings. From my other question about overriding variables in a makefile , I learned that I can use the following code in my master makefile: CC ?= avr-gcc CXX ?= avr-g++ In the child makefile, I use colorgcc and override these variables: CC ?= color-avr-gcc CXX ?= color-avr-g++ Everything works. But, if I remove the above lines from my child makefile, make starts using gcc and g++ instead of avr-gcc and avr-g++ . I guess both CC and CXX are treated differently and they are provided with

Can I make a makefile abort outside of a rule?

非 Y 不嫁゛ 提交于 2019-12-06 04:45:15
At the top of my Makefile, before any of the rules, I have the following: ifeq ($(ENVIRONMENT),LOCAL) TARGET := local_target else TARGET := hello endif If the ENVIRONMENT environment variable is not set, or is set to a value other than LOCAL , instead of setting TARGET to hello , I want the makefile to halt and exit with -1. Can I do that?? When I change TARGET := hello to exit -1 , I get the following error: Makefile:4: *** missing separator. Stop. How can I make this work?? exit is a shell command, so you could use the shell assignment operator (i.e.: != ) inside the Makefile to call exit :

Determine if Makefile is executed with gmake

廉价感情. 提交于 2019-12-06 04:30:53
问题 Say on FreeBSD an application needs to be compiled with GNU make (gmake), not the standard system make. Is there any directive I could put to the Makefile to stop executing it and print an error if the Makefile is not compiled with gmake? 回答1: Call your makefile GNUmakefile. GNU Make will find it, but not other makes. The first name checked, GNUmakefile, is not recommended for most makefiles. You should use this name if you have a makefile that is specific to GNU make, and will not be

How to run some commands globally in a Gnu Make file

五迷三道 提交于 2019-12-06 04:17:21
I have a gnu Makefile that collects version information through environment variables. Now, I want to do "something" globally before any target is built using the gnumake syntax. As pseudo code, this means: when a specified file exists, delete it run through an array of strings and put their value into a specified file I tried this: $(shell if exist $(subst /,\,$(products)filenames.h) del /F/Q $(subst /,\,$(products)filenames.h)) $(foreach Item, $(EnvFilenames), @echo $(Item) >> $(subst /,\,$(products)filenames.h)) this gives me an error: C:\temp\Makefile.mak:72: *** missing separator. Stop.