gnumake

Recursive wildcards in GNU make?

It's been a while since I've used make, so bear with me... I've got a directory, flac, containing .FLAC files. I've got a corresponding directory, mp3 containing MP3 files. If a FLAC file is newer than the corresponding MP3 file (or the corresponding MP3 file doesn't exist), then I want to run a bunch of commands to convert the FLAC fil...

GNU make: should -j equal number the number of CPU cores in a system?

Hi What is you experience with the make -j flag? There seem to be some controversial if the jobs are supposed to be equal to the numbers of cores, or if you can maximize the build by adding one extra job that can be cued up while the others "work". The question is if it is better to use -j4 or -j5 on a quad core system? And have you...

Using Cmake with GNU Make: How can I see the exact commands?

I use Cmake with GNU Make and would like to see all commands exactly (for example how the compiler is executed, all the flags etc) GNU make has --debug, but it does not seem to be that helpful are there any other options? Does Cmake provide additional flags in the generated Makefile for debugging purpose? ...

Why does Gnumake from parent directory behave differently?

I am stumped as to why when I do a gnumake from the parent directory it behaves incorrectly, whereas, if I cd to the subdirectory and do gnumake it works correctly. In the parent makefile, I have a rule like this: .PHONY: zlib-1.2.5 zlib-1.2.5: @ echo Issuing $(MAKE) in $@ ... pushd zlib-1.2.5; make; popd I also tried it like...

gnu make installed with OS language

I installed the latest GNU make to my windows machine. The installer decided to setup the language as the OS language, which I did not get prompted for. I want it to be english. My OS is in swedish. I remember I had similar problem with another GNU program (can't recall which), which was solved by adding the env var "lang" with value "...

Compile all C files in a directory into separate programs

Is there a way using GNU Make of compiling all of the C files in a directory into separate programs, with each program named as the source file without the .c extension? ...

How to strip out a -D for just one file in a gnu makefile?

I have '-Wredundant-decls' in my CXXFLAGS but for one file, I want it removed. In my GNU makefile, how can I structure a rule to remove just that part of the CXXFLAGS. I know how to add only for that file, I would do something like this: $O/just_one_file.o: CXXFLAGS += -Wredundant-decls So, ideally I'd do something like this (which ...

How to write Android.mk for library using Gnu makefile

I want to make an Android application using huge third party native libraries which use the Gnu build tools (gnu makefile). My question is how to write the "Android.mk" files for these libraries in order to build them using the Android build system or the Android NDK. Thanks in advance ...

Skip makefile dependency generation for certain targets (e.g. `clean`)

I have several C and C++ projects that all follow a basic structure I've been using for a while now. My source files go in src/*.c, intermediate files in obj/*.[do], and the actual executable in the top level directory. My makefiles follow roughly this template: # The final executable TARGET := something # Source files (without src/) I...

How to make automake less ugly?

I recently learned how to use automake, and I'm somewhat annoyed that my compile commands went from a bunch of: g++ -O2 -Wall -c fileName.cpp To a bunch of: depbase=`echo src/Unit.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ g++ -DHAVE_CONFIG_H -I. -I./src -g -O2 -MT src/Unit.o -MD -MP -MF $depbase.Tpo -c -o src/Unit.o src/Unit.cp...

GNU Make - Dependencies on non program code

A requirement for a program I am writing is that it must be able to trust a configuration file. To accomplish this, I am using several kinds of hashing algorithms to generate a hash of the file at compile time, this produces a header with the hashes as constants. Dependencies for this are pretty straight forward, my program depends on c...

How to check for installed libraries e.g. libpcap when installing software using gnu make?

I am developing an application which depends on libpcap and want to know how to write the gnu makefile such that i can check for installation of libpcap on a machine before proceeding with the installation of my application. ...

Generate multiple target using single action/rule

How do I write a rule to generate set of files using a single action. Example: Files x, y, z are generated as a result of single execution of script t.sh which takes file a as input. x y z: a t.sh $@ GNU make tries to execute t.sh 3 times. ...

Qt4 book says "make release", reality disagrees

According to various soures, for a Qt4 app you build the release or debug versions with "make release" or "make debug". In real life, these give errors. make: *** No rule to make target `debug'. Stop Only bare naked "make" works. I'm not sure what it produces. Running "strip" does reduce the executables' size, but gdb isn't find...

How to write different implicit rules for different file names for GNU Make

Hi! I have a directory in which I keep adding different C++ source files, and generic Makefile to compile them. This is the content of the Makefile: .PHONY: all clean CXXFLAGS = -pipe -Wall -Wextra -Weffc++ -pedantic -ggdb SRCS = $(wildcard *.cxx) OBJS = $(patsubst %.cxx,%.out,$(SRCS)) all: $(OBJS) clean: rm -fv $(OBJS) %.out:...

GNU Makefile: multiple outputs from single rule + preventing intermediate files from being deleted

This is sort of a continuation of question from here. The problem is that there is a rule generating multiple outputs from a single input, and the command is time-consuming so we would prefer to avoid recomputation. Now there is an additional twist, that we want to keep files from being deleted as intermediate files, and rules involve wi...

Makefile and rm -f file.{ext1,ext2,ext3} issue

Hello, Could you explain me, why Makefile rule: clean: rm -f foo.{bar1,bar2,bar3} does not result in removing files: foo.bar1 foo.bar2 and foo.bar3? I believe I saw pattern like that many times in various Makefiles, but I'm currently writing my own Makefile and can't make that rule work correctly (no files are removed). I'm usin...

How can I capture GNUMake differences between two directories

I have a tricky issue with gmake, when I build from the parent directory, something is different and the make does not build all the .o(s) it needs and fails, but if I cd to the directory and do a make it builds them fine. How can I get GNUmake to tell me the difference between these two runs? There must be some make variables set in th...

List goals/targets in GNU make

I have a fairly large makefile that creates a number of targets on the fly by computing names from variables. (eg foo$(VAR) : $(PREREQS)). Is there any way that gnu make can be convinced to spit out a list of targets after it has expanded these variables? I'd like to be able to get the targets for an aribitrary makefile. I'm trying to...

Makefile generic pattern rule -- xyzzy-en_US.ext2 from xyzzy.ext0

I can't figure out a way to define a generic pattern rule for the following kind of production with make: require xyzzy-en_US.ext2 from xyzzy.ext0 via xyzzy.ext1. This works: all: xyzzy-en_US.ext2 # to be compiled from xyzzy.ext0 %.ext1 : %.ext0 # produce xyzzy.ext1 %-en_US.ext2 : %.ext1 # produce xyzzy-en_US.ext2 But how to g...