Make - two target produced by one recipe


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Make - two target produced by one recipe
# 1  
Old 01-18-2011
Make - two target produced by one recipe

Suppose executable X produces files A and B from nothing, Y produces C from A, Z produces D from B, and my final goal is to produce C and D. I wrote the following makefile:

.PHONY: all
all: C D

C: A
Y A
D: B
Z B
A B:
X
This makefile seems to reflect all dependencies, as it should be. However if I delete A and B, then X will be executed twice.

How do I fix this file so that it still reflects all dependencies, but in any case executes X only once?

Thanks in advance
# 2  
Old 01-18-2011
If you post in code tags, you won't need to use excessive amounts of spaces to indent things. [ code ] stuff [ /code ] without the extra spaces in the tags.

What version of make do you have? I don't get this behavior:

Code:
$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i686-pc-linux-gnu

$ cat Makefile
.PHONY: all
all: C D

C: A
        touch C

D: B
        touch D

A B:
        touch A B
$ make
touch A B
touch C
touch D
$ rm A B
$ make
touch A B
touch C
touch D
$

This minimal example of yours might be a little too minimal to show the actual problem.
# 3  
Old 01-18-2011
I use version 3.82. Indeed my example must be too minimal - I receive the same behavior as you do. I'll reinvestigate my real problem. Thanks anyway!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Makefile No rule to make target

I am trying to create a makefile to build a program and am getting the following error: make -f tsimplex.mk make: *** No rule to make target `/main/tsimplex_main.cpp', needed by `tsimplex_main.o'. Stop. OPSYS = $(shell uname -s ) TARGET = tsimplex ROOTDIR = ../../.. GTSDIR =... (1 Reply)
Discussion started by: kristinu
1 Replies

2. UNIX for Dummies Questions & Answers

Using sed with special characters produced from crypto

Hey there, I'm facing some weird issues with sed when trying to do substitution in a text file with the content of some environment variables. Those variables are used to store crypted (3DES) info with much special characters and that's where the problem starts. I've already tried to use both... (7 Replies)
Discussion started by: Jormun
7 Replies

3. Programming

Issue with make, no rule to make target etc.

I have been trying to split up my src directory to clear out files that are not re-compiled very often. Now I have the following setup in my trunk, trunk/bld trunk/src/ trunk/src/src_server trunk/makefile.linux In the make file, I have compile rules SOURCELOC = src # compile src c++... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

4. UNIX for Dummies Questions & Answers

make - two wildcards in the target

Suppose I have a Makefile like this: x/Ax: x/Bx touch x/Ax y/Ay: y/By touch y/Ay z/Az: z/Bz touch z/Az It does not look like a proper style for make. I would like to write something like %/A%: %/B% touch %/A% but make does not accept it. What is a right way to shorten such a... (1 Reply)
Discussion started by: ybelenky
1 Replies

5. Programming

compile fails in linux ... "No rule to make target" ... HELP

hello all, attached you can find a tool (written in C) that i really need to make it compile under linux i am able to compile and run it successfully in mac os x, but in linux the compilation fails the only thing that i did so far is to change the following #include <sys/malloc.h> to... (13 Replies)
Discussion started by: OneDreamCloser
13 Replies

6. Shell Programming and Scripting

make Fatal error: Command failed for target 'exp_inter.o'

I am trying to install Expect 5.43 on my Solaris 10 x86 PC. When I run the make file I get - Command failed for target 'exp_inter.o'. I tried to find the file (find / -name exp_inter.o -print 2>/dev/null) but could not. Where can I get this file from? (2 Replies)
Discussion started by: pazzy
2 Replies

7. UNIX for Dummies Questions & Answers

make command failed for target 'obj/gp_unix.o'

hi, i am trying to run make command in solaris 9. its giving the error: make:Fatal error:Command failed for target 'obj/gp_unix.o' i came to know X11 should be inastalled for gp_unix.o.But it is already installed.still the same error. ./configure worked fine. can anybody please suggest... (3 Replies)
Discussion started by: rosalina
3 Replies

8. UNIX for Dummies Questions & Answers

Ignoring files that are currently being produced

Hi! Letīs say I want copy dump-files to a location. These dump-files vary between 80 and 280MB and will be produced in about 1min or less. I have a cronjob which (not only) copies those. So how can I find out whether a file is currently produced or not? Because if my script works with these... (2 Replies)
Discussion started by: cypher82
2 Replies

9. Linux

make file_Configuration lookup disabled for target.

hello everyone, while i am compiling a c++ module.at the compilation end i am getting the following error. ======================= Configuration lookup disabled for target"/swtemp/usbs/cc/unix-ce/root/subsys/cb/cdbc/obj_0001/HP-UX//rdr_types.h" what does it mean.can somebody clarify the... (0 Replies)
Discussion started by: mannam srinivas
0 Replies

10. UNIX for Dummies Questions & Answers

Solaris 9: make: Fatal error:Command failed for target

Hi everyone first of all you should know that I've been working with solaris for a few days only. :) I need to install some programs and I have had the following troubles: 1. When I used /.configure it showed the following message: "no acceptable C compiler found in $PATH" I included... (2 Replies)
Discussion started by: eldiego
2 Replies
Login or Register to Ask a Question