Simple Makefile Problem (with a simple dependency)

Hi all,

I have 4 '.cpp' files and 1 header files:


1
2
3
4
5
6
Tools.cpp
Code1.cpp
Code2.cpp
Code3.cpp

and Tools.hh


Now all Code1.cpp, Code2.cpp, Code3.cpp
use functions stored in Tools.cpp.

Currently, what I do to compile all of them is using
this simple shell script:

1
2
3
4
5
6
7
8
9
#!/bin/bash
echo "compiling Code1.cpp";
g++ Code1.cpp Tools.cpp -o Code1

echo "compiling Code2.cpp";
g++ Code2.cpp Tools.cpp -o Code2 

echo "compiling Code3.cpp";
g++ Code3.cpp Tools.cpp -o Code3


It all works fine.

Now I want to do that using a standard makefile.
But why this doesnt' work:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
XX = g++

TOOLSRC = Tools.cpp Code1.cpp Code2.cpp \
Code3.cpp    

TOOLSINC = Tools.hh      

all: Code1 Code2 Code3

Code1: $(TOOLSRC) $(TOOLSINC) makefile
                $(CXX)   

Code2: $(TOOLSRC) $(TOOLSINC) makefile
                $(CXX)   

Code3: $(TOOLSRC) $(TOOLSINC) makefile
                $(CXX)   



The error I got is this:
1
2
3
4
g++
i686-apple-darwin9-g++-4.0.1: no input files
make: *** [Code1] Error 1

Last edited on
Topic archived. No new replies allowed.