Bug 395378 - Gnu Makefile is faulty (solution provided)
Summary: Gnu Makefile is faulty (solution provided)
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build-managed (show other bugs)
Version: Next   Edit
Hardware: PC Windows XP
: P3 trivial (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-29 11:08 EST by al_eclipse1 A CLA
Modified: 2020-09-04 15:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description al_eclipse1 A CLA 2012-11-29 11:08:35 EST
Hello,

I've just checked the GNU makefile that Eclipse generates (via this option: http://eclipsebook.in/_images/c-wiz-proj-prop-builder.png)

The makefile is slightly faulty and can be improved!
(I'm running the normal current CDT, downloaded a few days ago)


Here's what needs changing:




1) makefile (top-level)
top-level makefile should have the all-target RIGHT AT THE TOP (before all other include lines). This is to guarantee that the all-target is the default target. So right at the top just add:

all:



2) subdir.mk 
subdir.mk should use:

# Each subdirectory must supply rules for building sources it contributes
src/%.o: ../src/%.c
	@echo 'Building file: $<'
	@echo 'Invoking: GCC C Compiler'
	#gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"     #this line is in error
	gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -o "$@" "$<"
	@echo 'Finished building: $<'
	@echo ' '


Reason:
we want test.d to have this content:
src/test.o: ../src/testc.
and NOT:
src/test.d: ../src/test.c              #this is faulty





Regards,
Comment 1 al_eclipse1 A CLA 2012-11-29 11:11:57 EST
the folding of the code fragment of subdir.mk (shown above) make it slightly hard to read.

the long commented line is the current line that eclipse generates, and is in error

#gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"     #this line is in error


This line needs to be changed to 

gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -o "$@" "$<"