gnu-make

Using GNU Make to build both debug and release targets at the same time

耗尽温柔 提交于 2019-12-02 20:37:48
I'm working on a medium sized project which contains several libraries with interdependence's which I've recently converted over to build using a non-recursive makefile. My next goal is to enable building of both debug and release builds out of the same source tree at the same time (make debug;make release). My first step was to make debug and release targets which contained the correct build flags. I did this using target specific variables, like this: CXXFLAGS=-Wall -Wextra -Werror -DLINUX CXX_DEBUG_FLAGS=-g3 -DDEBUG_ALL CXX_RELEASE_FLAGS=-O3 .PHONY: debug debug: CXXFLAGS+=$(CXX_DEBUG_FLAGS)

Error in makefile (“no input files”)

不问归期 提交于 2019-12-02 19:01:39
问题 This is my absolute first time ever making a makefile, and I'm really trying to understand the process. I'm trying to create a very simple makefile for a C++ project whose structure is as follows: root folder makefile readme src folder ...source files all here... include folder ...header files for external libraries here... lib folder ...external lib files all here... bin folder ...output directory for built executable... obj folder ...object files all here... I followed the tutorial here.

Makefile pattern rule for no extension?

£可爱£侵袭症+ 提交于 2019-12-02 18:07:46
I have a bunch of applications that are built with the same type of make rule: apps = foo bar baz all: $(apps) foo: foo.o $(objects) $(link) bar: bar.o $(objects) $(link) baz: baz.o $(objects) $(link) If they had an extension (for example .x ) I could make a pattern rule like: %.x: %.o $(objects) $(link) and I wouldn't have to write out a new rule for each app. But they don't have an extension, and I'm pretty sure that: %: %.o $(objects) $(link) won't work (because it specifies that to build any file you can use this rule). Is there anyway to specify one rule that will cover all the $(apps)

GNU make's -j option

和自甴很熟 提交于 2019-12-02 17:51:16
Ever since I learned about -j I've used -j8 blithely. The other day I was compiling an atlas installation and the make failed. Eventually I tracked it down to things being made out of order - and it worked fine once I went back to singlethreaded make. This makes me nervous. What sort of conditions do I need to watch for when writing my own make files to avoid doing something unexpected with make -j? I think make -j will respect the dependencies you specify in your Makefile; i.e. if you specify that objA depends on objB and objC, then make won't start working on objA until objB and objC are

Make uses same source file for different object files

試著忘記壹切 提交于 2019-12-02 17:23:33
问题 Make chooses the same source file for different object files. Both are a list of files, only with different filenames. Make switches between the object files but not the source files. I've already tried some of the answers on StackOverflow with related problems, though those solutions either seem too complicated for what's needed, some don't work and others need the files to be in one directory. I've also tried compiling the files together in one go (with gcc), but this gives some problems

Using gmake to build large system

荒凉一梦 提交于 2019-12-02 16:04:41
问题 I'm working on trying to fix/redo the makefile(s) for a legacy system, and I keep banging my head against some things. This is a huge software system, consisting of numerous executables, shared objects, and libraries, using C, Fortran, and a couple of other compilers (such as Motif's UIL compiler). I'm trying to avoid recursive make and I would prefer "one makefile to build them all" rather than the existing "one makefile per executable/.so/.a" idea. (We call each executable, shared object,

How can I highlight the warning and error lines in the make output?

て烟熏妆下的殇ゞ 提交于 2019-12-02 15:12:59
Sometimes, make's output fills the screen. It's a little bit hard to identify all the warning and error message lines. I know may shell color output can help Can anyone can help me? Fredrik Pihl Have a look at colormake , found here $ apt-cache search colormake colormake - simple wrapper around make to colorize output Using the power of google, I also found this bash-function. make() { pathpat="(/[^/]*)+:[0-9]+" ccred=$(echo -e "\033[0;31m") ccyellow=$(echo -e "\033[0;33m") ccend=$(echo -e "\033[0m") /usr/bin/make "$@" 2>&1 | sed -E -e "/[Ee]rror[: ]/ s%$pathpat%$ccred&$ccend%g" -e "/[Ww

Functions in Makefile

前提是你 提交于 2019-12-02 14:22:07
I am writing a Makefile with a lot of repetitive stuff, e.g. debug_ifort_Linux: if [ $(UNAME) = Linux ]; then \ $(MAKE) FC=ifort FFLAGS=$(difort) PETSC_FFLAGS="..." \ TARGET=$@ LEXT="ifort_$(UNAME)" -e syst; \ else \ echo $(err_arch); \ exit 1; \ fi where the target 'syst' is defined, the variable 'UNAME' is defined (and is usually Linux, but might also by Cygwin or OSF1) and the variables 'difort' and 'err_arch' are also defined. This block of code is used very many times for different compiler targets (using a name convention of ' '). Since this is a huge amount of redundant code, I would

Make and last modification times of directories on Linux

走远了吗. 提交于 2019-12-02 14:01:19
问题 Consider the following makefile: foo : mkdir foo foo/a.out : foo a.in cp a.in foo/a.out foo/b.out : foo b.in cp b.in foo/b.out and the following interaction with it, starting from a directory that contains files a.in and b.in and nothing else: $ make foo/a.out mkdir foo cp a.in foo/a.out So far, so good. $ make foo/b.out cp b.in foo/b.out Still good, but now: $ make foo/a.out # a.out should be up to date now! cp a.in foo/a.out It rebuilds the a.out target, even though none of its

GNU Makefile treating each recipe line as sub-shell command without continuation character

帅比萌擦擦* 提交于 2019-12-02 09:59:21
I am trying to get the target_compile to work. copy_shared_object: cp shared_object.so ${CURRENT_DIR} PROJECT_SIM_OPTS += -LDFLAGS -L${CURRENT_DIR},-lm -load target_compile: copy_shared_object actual_compile_with_sim_opts . . . actual_compile_with_sim_opts: . . . I am getting the Error despite the fact that I have not added ;\ on the first line starting with cp make: PROJECT_SIM_OPTS: Command not found makefile:282: recipe for target 'copy_shared_object' failed make: *** [copy_shared_object] Error 127 What you likely want is something like: ${CURRENT_DIR}/shared_object.so: shared_object.so cp