Makefile multiple rules

Makefile multiple rules. If you use spaces or forget the colon at the end, you will get "missing separator". o someotherfile. 7 Rules for Cleaning the Directory; 3 Writing Makefiles. Comments. Makefile - Directives. (assuming GNU make) see target-specific variable values in GNU Make manual (and the immediately following pattern-specific variable values, maybe). tgt: file ; touch tgt. 3 Including Other Makefiles; 3. input object. I also have a rule that depends on the one of the outputs of this "multi-output" rule. Will use the second rule to make the target foo. How to make a pattern rule in a Makefile Jan 15, 2014 · Make will likely use its own built-in rules for this, which is OK except that there won't be any prerequisites so it won't rebuild files when headers change. The only thing that changes is the name of the files that I touch/remove, and they are related. Thus, ‘e%t’ matches the file name src/eat, with ‘src/a’ as the stem. For example, if you have a makefile called `Makefile' that says how to make the target `foo' (and other targets), you can write a makefile called `GNUmakefile' that contains: foo: frobnicate > foo. c and call the output x. o file from a . Steps 2 and 3 also happen for the b files. Dependencies can either be other targets or file names; if a target depends on another target, it guarantees that target will be run prior, and if a target depends on a file, it will check to see if that file has changed to avoid executing redundantly. defines a rule that can make any file x. 7 How make Reads a Makefile. If I have a Makefile rule like this: a b c: echo "Creating a b c". 2 Rule Syntax. # easily changed: AS = gcc -S. Still, I want to be able to add some pre-processing steps before "some" (not all) of the targets. Writing Makefiles. So if you have multiple things you want GNU Make - Writing Rules. o’, then d is ‘src/’ and n is ‘foo. Typically, the result of executing these commands is that the target of the rule is brought up to date. @echo build $(PACKAGE) @echo test $(PACKAGE) I can now build all packages with make build-all or individual packages with, e. It is possible that more than one pattern rule will meet these criteria. The explicit rule for main. ba. I am using the gnu make and I have the same problem reported in when multiple pattern rules match a target. It follows that syntactic units of the makefile, such as rules, may safely be split across the beginning or the end of the conditional. Go to the previous, next section. Jul 21, 2016 · Try instead this. all: one two three one: touch one two: touch two three: touch three clean: rm -f one two three Multiple targets. Beware: • Each command (i. s. (You have to write one pattern rule per directory where your source files are. input. Without it, creating such 'multi-dimensional' targets is cumbersome. You can write your makefile like this: $(CXX) $(CXXFLAGS) -o $@ $^ $(LDLIBS) $(COMPILE. As you can read in the GNU make manual, the percent acts as a wildcard. The rule contributes the same dependencies to Rules (GNU make) Recipes Makefiles Top Contents Index. Jul 16, 2009 · The traditional way is to have a Makefile in each of the subdirectories ( part1, part2, etc. May 1, 2017 · 5. gif but for the other file types I get "No Nov 20, 2015 · 3. A rule appears in the makefile and says when and how to remake certain files, called the rule’s targets (most often only one per rule). One way around this is by rebuilding the name of the dependency in the command (rather than in the dependency list): SRC := a. h files in the dependency line of the Makefile on which the current target is dependent on, make wi. It is easy enough to do without an explicit rule for directories, by using mkdir -p in other rules. I have several rules: all; clean; fclean; re; I can already use those rules, which will call every sub makefile with the same rule. Where the spaces before the gcc lines are a single tab not spaces. gcc -g -o program first. : convert $< -resize 100x100 $@. The default rule is all; to make all, make ensures that each of the files alib. If a pattern rule has multiple targets, make knows that the rule’s recipe is responsible for making all of the targets. This implicit rule says how to make x out of x. out1 object. A target is usually the name of a file that is generated by a program; examples of targets are executable or object files. Thus, x: y. (2) Make a list of all the pattern rules one of whose targets Defining Custom Suffix Rules in Makefile - Make can automatically create a. That's it, that's the whole makefile. o files. Jul 13, 2012 · The GNU make manual says. I have mentioned a list of files to be compiled as C_OBJFILES and ASM_OBJFILES. /myscript. cpp $(LINKER_SCRIPT) gcc blah blah blah. Hot Network Questions convert a problem into problem hamiltonian The words to describe a slave's Dec 17, 2016 · 1. o: | $(BUILDDIR) essentially has no effect. ${COMPILER} ${CCFLAGS1} main. Here is a catalogue of predefined implicit rules which are always available unless the makefile explicitly overrides or cancels them. IT does something similar to producing thumbnails from images. If a user gives "JUST" the commands as indicated below, it should print a message saying "CATEGORY defined TEST undefined" and vice-versa. In makefiles, anything following a # character is a comment up to the end of the line. Then use the following code: define depend_on_dir. I would like to create a Makefile with multiple ways to produce a file: . xlsx Is it possible ? How ? May 22, 2017 · Pattern rules may have more than one target. Jan 8, 2015 · Pattern rules may have more than one target. We split each long line into two lines using backslash-newline; this is like using one long line, but is easier to read. c makefile'--folder2-2 'foo5. I would like the more specific one to be executed ONLY. 4 Writing Rules. When prerequisites are turned into file names, the directories from the stem are added at the front, while the rest of the stem is substituted for . Make provides functions for string manipulation, file handling, etc. Apr 12, 2017 · I have a Makefile which I use to call different sub-Makefiles. $(CC) -o $@ -c $<. Advanced pattern matching in Makefile. Targets in a Makefile can be named anything (though as you’ll see, certain names can incur certain behavior). The recipe uses the automatic variables ‘ $@ ’ and ‘ $< ’ to substitute the names of the target file and Sep 26, 2023 · Sort of. Jul 4, 2015 · In a GNU makefile, I am wondering if it is possible, with an file list input, to make a file list output with new extensions. …. o z. cpp: $(CC) $(CFLAGS) $@. this gets even more awkward when trying to pass multiple arguments or arguments containing spaces. bin file: bin-dependency ; touch file. You define an implicit rule by writing a pattern rule. This can be stated as an implicit rule −. Feb 26, 2023 · GNU Make A Program for Directing Recompilation GNU make Version 4. or like this: targets : prerequisites ; recipe recipe. make LINKER_SCRIPT=link:0. cat a b c > output. Aug 24, 2018 · 1. (Many versions of make set ‘ $< ’ only in implicit rules. 1. I have several project, and I would like to generate rules with that format: $(PROJECT_NAME)-$(RULES) With that, I would like to have each rule for Nov 13, 2013 · particular_file. The same commands. 2 Catalogue of Built-In Rules. Here are some examples of pattern rules actually predefined in make. That is, if you wanted to fix the following rule: object. The target is considered a pattern for matching file names; the ‘ % ’ can match any nonempty substring, while other The double-colon rules for a target are executed in the order they appear in the makefile. o does designate prerequisites for it, which make will take into account. . Use prefix rules to generate *. If there is a wildcard symbol (%) in the pattern, this will match any number Feb 16, 2018 · The Makefile should consist of the following: program: first. mk othermakefile. Comment characters typically occur at you need to write: $ make run var=arg. Depending on what you want. o third. dll and blib. 6 Another Style of Makefile; 2. txt. These rules are built-in the make, and you can take this advantage to shorten your Makefile. foo file. Oct 29, 2019 · I have a makefile with a rule that produces multiple outputs. mk: define Build/DefaultTargets. 1. I have a number of assembly and C source files in a directory. When an explicit rule has multiple targets they can be treated in one of two possible ways: as independent targets or as grouped targets. sh $< > $@. For example, if t is ‘src/foo. exe: foo. When you launch make, it reads Makefile, and checks for changed files. Aug 16, 2011 · Possible Duplicate: GNU Makefile rule generating a few targets from a single source file. In general, a rule looks like this: targets : prerequisites recipe. To use this makefile to create the executable file called `edit' , type: make. It lists the other files that are the prerequisites of the target, and the recipe to use to create or update the target. target1: target1. abc = "$<" ]; then mycommand; fi. This is why the larger syntactic units of the makefile, such as rules, may cross the beginning or the end of the conditional. 6 Overriding Part of Another Makefile; 3. docx file2. apply to all the targets, but their effects may vary because you can. I want to write the recipe once and have a list of implicit rules that each call the recipe, e. o when `x. This way you can have multiple sources with the same file name (e. Sep 29, 2009 · Do not confuse them with the un-nice (IMHO) Pattern Rules. For example: LINKER_SCRIPT := link. Use a single make (instead of recursively invoking make on subdirectories). However, i don't understand how this Makefile in openwrt works: In include/package. # default target named "all", with all targets I want to build as its prerequisites. you need to write. ) Oct 23, 2012 · Following the "Implicit rule search algorithm" in the GNU make user manual we get: (1) Split t into a directory part, called d, and the rest, called n. +$(MAKE) -C part2. c' and `z. c file. If no existing file name matches a pattern, then that pattern is Unconditional makefile text follows. Feb 2, 2021 · 1. dat. out2. c : Classes/%. o miscb. Dec 12, 2018 · 0. Sep 30, 2013 · I'm looking for a Makefile which is more user friendly in a test environment. Sorted by: 134. First, Make sometimes removes trailing slashes from targets, which can cause some confusion. The correct usage of the Makefile is one of the below. o file, using cc -c on the corresponding . Editorial note: it would be idiomatic to use CXX rather 5 Answers. So the $(OUT) : $(OBJ) is not enough! Thanks! I was thinking that the line $(OUT) : $(OBJ) would be enough but, reading the make manual more carefully, it turned out that make set the first rule as the goal of the makefile and if the goal has multiple targets, make will take only the first one! Jan 11, 2012 · vcs $(OPTIONS) top. 1 a. generate and evaluate them inline with GNU make's $(eval) and $(call) functions. I would suggest simply spelling out your targets as separate targets in the makefile: all: target1 target2. o second. If multiple rules have prerequisites that exist or can be built, make will use the rule that matches to the shortest stem. Create one Makefile rule for several files. cpp,. o $(OTHER_OBJS) target2: target2. o $(OTHER_OBJS) Then make, make target1, make target2, and so on will all do what you want. or. rm –f . cpp) -o $@ $<. Mar 10, 2019 · A rule with multiple targets is equivalent to writing many rules, each. 1 What a Rule Looks Like. PHONY: app bin tgt. Oct 27, 2011 · Apply a single Makefile target rule to multiple input files. Make analyze, will compile all the files in its dependency & builds the final executable. The make program on your system may not support all the directives. See Canceling Implicit Rules, for information on canceling or overriding an implicit rule. GNU make does its work in two distinct phases. 2 What Name to Give Your Makefile; 3. I have no control over the content of the included makefile. Mar 23, 2021 · I'm starting out with makefile and I am a bit puzzled about how patterns work. $(CC) -fPIC -o $@ -c $<. In this case it takes your rule bin/%/ $(BLD)/%/: , which you clearly intended for directories, and uses it for files, at least sometimes. 5 Writing Recipes in Rules. 10 Multiple Targets in a Rule. 0. 10. Writing Rules. Actually you can have two set of environment variables in the same make file. But it doesn't run the main makefile. /frob input. cpp. o fourth. As this example illustrates, conditionals work at the textual level: the lines of the conditional are treated as part of the makefile, or ignored, according to the condition. Consider the following example: install: @echo "install target" include othermakefile. Aug 26, 2016 · 3. All the prerequisites mentioned in all the rules are merged into one list of prerequisites for the target. 2. make CATEGORY=parser TEST=basic. out2: object. See the make manual about double colon rules for more information. The recipe is executed only once to make all the targets. – Makefile Gotchas. mk contains install target as well. When using GNU make, relying on ‘ VPATH ’ to find the source file will work in the case where there is a single dependency file, since the make automatic variable ‘ $< ’ will represent the source file wherever it is. If the value of the wildcard is foo, then this will indicate a prerequisite which is a target (or file) named MODEL=foo. and I run make -j9 output. o: gcc -c -g $<. How can I write a "SINGLE Makefile rule", which will compile all its dependencies and build an executable - Mimicking the above with a rule SOMETHING LIKE: analyze: %. c. The. So far I have Jul 1, 2012 · The second version, when fixed to remove the extra colon and the typo, should work: all: $(LIBS_SO) $(LIBS_DLL) $(LIBS_SO) $(LIBS_DLL): cp . o : %_specific. That graph is definied in the Makefile. v. so, blib. Basically two rules, a generic one, and a more specific one, match the same target but the more generic one gets executed!!. For instance, make clean. Wildcard characters may be used (see Using Wildcard Characters in File Names) and a name of the form a(m) represents member m in archive file a 4. So it surprised me that: Multiple pattern rules match the target, and since the stem for the %_specific. The manner in which they are treated is determined by the separator that appears after the list of targets. Feb 21, 2021 · MakeFile is versatile and it allows you to add variables, that can be called multiple times in a file, irrespective of the rule. Since you already have a list of prerequisites you can use regular and static pattern rules instead: BUILDDIR := build. 4. May 15, 2018 · There are files (source, object, executable) in this graph, and rules (make's terminology). o. touch a b c. command with caution • To use an implicit rule to make an . make enable_debug=yes enable_video=no # will compile from zero. May 24, 2015 · Makefile with multiple rules to make a single file. make ALL. make CATEGORY=parser. Unlike normal rules, this does not act as many different rules with the same prerequisites and recipe. As an example, VENV here is acting as a variable As an example 63. Here I use one just for the convenience that whatever matched the % in the rule is available as $* in the recipe. ${COMPILER} ${CCFLAGS2} test. The ‘ -r ’ or ‘ --no-builtin-rules ’ option cancels all predefined rules. A target can also be the name of an action to carry out, such as ‘ clean ’ (see 1. A simple makefile consists of “rules” with the following shape: target … : prerequisites …. There can only be one recipe to be executed for a file. for example. Dec 18, 2012 · 21. /prog foo "bar baz". Makefile Implicit Rules. First, if the targets involved have a common stem, you can use a prefix rule (with GNU make). o’. . s extension. xls And I would like to build this variable in my makefile from FILES_IN variable: FILES_OUT=file1. One common solution when source files reside in different directories is to build an isomorphic directory structure in the build directory. o miscc. , make build PACKAGE=a. One file can be the target of several rules. dll exists and is up to date. 4. 4 The Variable MAKEFILES; 3. Since this is the first rule listed, it will run by default if make is called without specifying a target. Simple pattern rule in make. ) allowing you to build them independently. Go to the first, previous, next, last section, table of contents . c makefile'-folder2 'makefile'--folder2-1 'foo3. First, define a variable ALL_TARGET_FILES that holds the file name of every file that your makefile will be build. vcs $(OPTIONS) %. if [ myfile. for generating the object files. A pattern rule looks like an ordinary rule, except that its target contains the character ‘%’ (exactly one of them). Mar 23, 2014 · So it creates the rule. If the condition is true, make reads the lines of the text-if-true as part of the makefile; if the condition is false, make ignores those lines completely. Instead of a code generator, for this example I have written a simple shell script, frob which generates multiple output files from one input file: echo "This is output${i}, generated from ${1}. The rule may produce/update further files, which may trigger other rules and so on. The only decent solution to your problem is to have ONE instance of make build all the sub-directory targets you want. It lists the other files that are the dependencies of the target, and commands to use to create or update the target. The second rule is the default rule used by make to create a . The -g -DMEMPOOL too, for that matter. with one target, and all identical aside from that. This means that the line $(BUILDDIR)/%. util. If you now run. The command is one that ought to work in all cases where we build an executable x out of the source code x. If there's any, it triggers the rule, which depends on it. cpp to *. OTHER_OBJS = misca. Smith Since this is the first rule listed, it will run by default if make is called without specifying a target. $(AS) $(ASFLAGS) -o $@ $<. bar file from a . Given these definitions, subst should be used to substitute the src part of the directory, and the file extension. It basically scrambles the file. Feb 26, 2023 · 2. I have a command that can take multiple types of input files and generate relevant output. I've just come up with a fairly reasonable solution that lets you define the files to build and have directories be automatically created. o from x. Feb 28, 2019 · Makefile: rule that match multiple patterns. There are numerous directives available in various forms. The same commands apply to all the targets, but their effects may vary because you can substitute the actual target name into the command using `$@'. mk or similar) that you include within your actual makefile with GNU make's include statement. Usage Example 1: Python Project Makefile In this case, the phony target all depends on multiple executable files. Make doesn't have any intuitive way to do this, but there are two decent workarounds. I would like to have a variable storing all the "stems" of the targets and prerequisities at the top, and then just adding the prefix/suffix and a common recipe for all of them. $ make run var="foo \"bar baz\"". Also it is possible with -f flag to call which makefile you want to call. myprog: myprog. cc) but in different directories and the object files won't collide because they get built into different directories. I was wondering what happens if there is 2 targets with the same name in a Makefile: According to This question, Having 2 targets with the same name throws warnings. substitute the actual target name into the command using `$@'. During the first phase it reads all the makefiles, included makefiles, etc. c', `y. Users use many different shell programs, but recipes in makefiles are always interpreted by An Introduction to Makefiles. Jun 14, 2012 · Then there's MODEL\=%, which indicates that the author of this makefile was a little confused (and didn't believe in testing). @echo Stem is: $*. You say your makefile "derives the SRC list from Jul 22, 2018 · 2. foo-bin object. Some of the assembly files has . o's prerequisites. Each item/word in the last argument is compared against this pattern, and if it matches, it is replaced with the second argument. Double-colon rules are somewhat obscure and not often very useful; they provide a mechanism for cases in which the method Jun 20, 2012 · I have a makefile containing an include statement. Typing make all or placing this rule at the top of the rule list for default application will cause make to create all of the executables. $ make run var="foo bar\ baz". The recipe of a rule consists of one or more shell command lines to be executed, one at a time, in the order they appear. Apply a single Makefile target rule to multiple input files. Making multiple targets and you want all of them to run? Make an all target. Either use dependencies or recursive making to connect from one rule to another. # specify the assembler command as a variable, near the top, to enable it to be. c makefile' Each makefile in the very last directory has been included to it's upper makefile. g. s sayhello. o : CFLAGS+=-O3. Stallman, Roland McGrath, Paul D. It should execute the commands once for each missing target. all: $(ASSEMBLY_TARGETS) # One pattern rule covering both targets. o If you want to do wildcard expansion in such places, you need to use the wildcard function, like this: $(wildcard pattern …) This string, used anywhere in a makefile, is replaced by a space-separated list of names of existing files that match one of the given file name patterns. A rule with multiple targets is equivalent to writing many rules, each with one target, and all identical aside from that. For DIR/3/abc. Here is a Makefile that I currently use to make targets with different configurations, i. o ’ files: $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@. The first rule allows you to create a . cpp rule Jun 24, 2010 · 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. c ’ files into ‘ . I'm really new to GNU make and I want to have something like this but I don't know how. 3. The first argument of the patsubst function forms the pattern. Jun 23, 2015 · The directories are ignored only for the purpose of finding an implicit rule to use, not in the application of that rule. ld. Having the parent make invoke multiple sub-makes in parallel in the same directory, unless every invocation uses a completely disjoint set of targets, is a guaranteed fail situation. $(if $(QUILT),$(Build/Quilt)) Jul 27, 2013 · root 'makefile'-folder1 'foo1. To work around the issue of this rule often being run multiple times when run in parallel, I've used a dummy "timestamp file". then you can just say make a or make b. Aug 21, 2012 · 12. The \ "escapes" the =, so that Make will not abort, but that is simply suppression of a healthy Dec 8, 2023 · Makefiles can contain conditional statements (ifeq, ifneq, else, endif). There are essentally two ways of doing this: write them to makefiles ( %-cc. It is similar to what happens for the a files except that this time $(2) is set to the string %_b3. Dependencies would be done like this (though the order will be different): rule1: echo "bye" rule2: date rule3: rule1 @echo "hello". Mar 1, 2016 · What you want to do is not possible in gnu make. If multiple rules match to the shortest stem, make will use the first one in the Makefile. and internalizes all the variables and their values and implicit and explicit rules, and builds a dependency graph of all the targets and their prerequisites. , second line of each dependency rule) must begin with a tab character, not spaces • Use the . When there are multiple targets for a rule, the commands will be run for each target. c foo4. input was:" cat ${1} } > output${i} This rule does the right thing for a simple program with only one source file. What a Rule Looks Like; A Simple Makefile; How make Processes a Makefile; Variables Make Makefiles Simpler; Letting make Deduce the Commands; Another Style of Makefile; Rules for Cleaning the Directory. It lists the other files that are the dependencies of the target, and commands to use to create or A rule appears in the makefile and says when and how to remake certain files, called the rule’s targets (most often only one per rule). recipe. Such that I could run make tgt and depending on whether the file app-dependency or bin-dependency was present would decide which to targets to run. doc file2. 1 Splitting Long Lines; 3. 11 Multiple Rules for One Target. cpp $(LDFLAGS) -o $@. To use this makefile to delete the executable file and all the object files from the directory, type: make clean. I have added the rules as. myprog: somefile. For example: @echo Stem is: $*. The above works for a single file dependency. Also note, that commands are used from the most specific rule for given file, so you can have in case target-specific variable value is not sufficient: particular 有时,让同一个目标调用在 makefile 的不同部分中定义的多个配方很有用;您可以为此使用双冒号规则(请参阅 Double-Colon )。 仅包含先决条件的额外规则可用于同时为许多文件提供一些额外的先决条件。 See section Defining and Redefining Pattern Rules, for more information on pattern rules. log". A rule appears in the makefile and says when and how to remake certain files, called the rule's targets (most often only one per rule). This only has to be done once, except when new modules are added to the program, the Makefile must be updated to add new module dependencies to existing rules and to add new rules to build the new modules. Functions. The answer given on the above thread is basically to Create a Makefile listing the rules for building the executable the file should be named 'Makefile' or 'makefile'. $(CC) $(CFLAGS) -o $@ $<. In that case, make will choose the rule with the shortest stem (that is, the pattern that matches most specifically). If the target is older than any prerequisite from any rule, the recipe is executed. But yes, again following the same procedure, we build each of main. Mar 31, 2015 · 3. app file: app-dependency ; touch file. rm -rf output*. This is essentially the method I've used in the past to avoid duplication of rules for cases where the rules were rather complex. c -- run cc on x. Jul 1, 2021 · As a result there is no way to use one single pattern rule to build all your source files like this. There are double colon rules which allows multiple recipes for one target, but they do not work with suffix rules or pattern rules. bar, echoing Stem is: o. However, the cases where double-colon rules really make sense are those where the order of executing the recipes would not matter. This works for . 1 February 2023 Richard M. c' all exist will execute: GNU make - Writing Rules. 5 Defining and Redefining Pattern Rules. Further, have a Makefile in the root directory of the project which builds everything. instead of writing. o fifth. e. Now there is an additional twist, that we want to keep files from being deleted as intermediate files, and rules involve wildcards to allow for parameters. May 23, 2017 · 1. , I am building different software packages with the same target, either all at once or individually. Recursive make would be done like this (though it does involve a subprocess): rule1: echo "bye" rule2 Aug 24, 2011 · Another idea is to make GNU make generate the two pattern rules. There are a number of options you have: You can create multiple pattern rules, one for each source directory (it's easier to avoid static pattern rules in this situation): $(OBJ_DIR)/%. %: force. Dec 23, 2016 · 54. The Makefile looks like this: cat $^ > $@. When all this is run from a clean state, it all works fine. If you indicate just the . txt, d = DIR/3 and n = abc. I have multiple different targets, each with a name-matching prerequisite. 1 What Makefiles Contain. $ . executable, the executable must have the same name as one of the . The rule contributes the same prerequisites to all the targets also. A pattern rule looks like an ordinary rule, except that its target contains the character ‘ % ’ (exactly one of them). An implicit rule with no recipes is dropped during implicit rule search, its only purpose is to cancel any previously defined identical rule. Static pattern rules are really useful whenever the list of targets can be matched by one of make's noddy patterns (same applies to the dependencies). It will also do the right thing if there are multiple object files (presumably coming from various other source files), one of which has a name matching that of the executable file. so, alib. 2. Aug 30, 2020 · ASSEMBLY_TARGETS = hellomain. ) A Makefile target like. But the target is not the same thing as the rule, and that prerequisite-only rule is not the one that will be selected for building main. 7 How make Reads a Makefile; 3. Because Make doesn't do quoting remotely properly this can also happen if you pass in filenames that contain characters it doesn't like (spaces or :) and then you expand them. In input, I get this list: FILES_IN=file1. First, the rule that compiles ‘ . Here is a workaround: flip -e abc "$<" > "logs/$*. 5 How Makefiles Are Remade; 3. The order of rules is not significant, except for determining the default goal: the Oct 14, 2013 · The code presented above is a bit redundant: you see that I remove a file, touch another and remove a Makefile in both cases. o Conditionals affect which lines of the makefile make uses. The "root" Makefile would look something like the following: all: +$(MAKE) -C part1. You might need a src/ in there too, but I don't see where that came from in your original file. c foo2. o,$(SRC))) Then, you have to add new pattern rules to compile your source files. output: a b c. OBJ = $(subst src/,bin/,$(subst . May 7, 2013 · To make it work, you want them to be pattern rules, to match up a specific object with a specific source file. What Makefiles Contain; What Name to Give Your Makefile; Including Other Makefiles; The Mar 30, 2014 · Not sure what flavour of Makefile you use, or what OS you're building, however here are some ideas for a GNU Make and a unix-like environment. all: one two three one: touch one two: touch two three: touch three clean: rm -f one two three Multiple targets Multiple Targets in a Rule. The targets are file names, separated by spaces. ms ad ub na yv ai cl qv af mg