Makefiles using GNU make
I have some specific needs and after reading the documentation either I'm missunderstanding how things work or there's no easy way to do what I need.
I have some specific c/cpp modules that need to be compiled as ARM code, and others that need to be compiled as THUMB. I figure I'd have two lists,
arm_list = this.o that.o
thumb_list = foo.o bar.o
then, for the rules
$(arm_list):: %.o: %.c
$(CC) $(CFLAGS) $(ARMFLAGS) $<
$(arm_list):: %.o: %.cpp
$(CXX) $(CXXFLAGS) $(ARMFLAGS) $<
Repeat for thumb, and repeat for asm sources that are either passed to the compiler to be preprocessed, (.S) or the assembler (.s).
As far as I can understand it, this wont work because some .o files exist as .c files, others as .cpp files, so somewhere along the line I get a 'no rule to build target' or whatever the specific message is for this.c when make looks for this.cpp to build this.o from.
I've tried %.o: %.c and %.o: %.cpp as the target : Pre-requisite but that just takes all .c and .cpp files in the directory and builds them with one set of flags, and I can't specify arm/thumb.
If anybody knows their makefiles very well I'd like to pick your brain.
------------
- outRider -
[edited by - outRider on August 18, 2003 9:01:38 PM]
Try like this:
arm_list = this.o that.o
thumb_list = foo.o bar.o
arm list:
$(arm_list):: %.o: %.c
$(CC) $(CFLAGS) $(ARMFLAGS) $<
thumb_list:
$(arm_list):: %.o: %.cpp
$(CXX) $(CXXFLAGS) $(THUMBFLAGS) $<
then just type
make arm_list
make thumb_list
arm_list = this.o that.o
thumb_list = foo.o bar.o
arm list:
$(arm_list):: %.o: %.c
$(CC) $(CFLAGS) $(ARMFLAGS) $<
thumb_list:
$(arm_list):: %.o: %.cpp
$(CXX) $(CXXFLAGS) $(THUMBFLAGS) $<
then just type
make arm_list
make thumb_list
You could also try
arm_cpp_list = $(patsubst %.cpp, %.o, $(wildcard *.cpp))
arm_c_list = $(patsubst %.c, %.o, $(wildcard *.c))
arm_cpp_list = $(patsubst %.cpp, %.o, $(wildcard *.cpp))
arm_c_list = $(patsubst %.c, %.o, $(wildcard *.c))
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement