Help convert makefile to CodeLite
Posted: Tue Jul 19, 2011 7:44 pm
I'm in the early stages of a project. I have a hand written makefile that builds it, and I'm interested in using CodeLite to manage the build instead.
There are a few things I can't figure out how to do. I'll run down the lines in the makefile and say how I *think* I should address them in CodeLite,
so you can correct me if/when I'm wrong, and ask questions where I don't know.
The following lines point to the cross compiler and the objcopy utility. I know how to tell CodeLite what compiler to use: I go to Settings -> Build Settings and add a new compiler.
I have no idea what to do with the objcopy utility.
The following identifies compiler flags. For the ones I want to apply to any project using this compiler, I put them with the Build Settings for that compiler.
For the project specific flags, I put them in Project Settings -> Common Settings -> Compiler.
The following are linker flags. I put them in "Linker options" for that compiler under Build Settings. Also I added the path to the linker when I added the compiler.
These are assembler flags. What do I do with them?
There's a long list of object files. Is it correct that I don't need to put those anywhere if CodeLite is managing the build?
There's a long list of include directories. Do I need to add them all to the "Include Paths" in Project Settings?
This rule uses the assembler flags. If any .s files have been updated, it creates object files for them. Where and how do I tell CodeLite to do this?
Here's a second object file rule, which uses the compiler flags, if any .c files or include files have changed. I don't think I have to do anything in particular to instruct CodeLite to do this, right?
This links the objects into a .elf file. What should I tell CodeLite for the type of target here? Is it an executable? This isn't even the final result of the build.
This final step in the build uses objcopy to convert the .elf into a binary suitable for download onto the target microprocessor. How do I instruct CodeLite to do this?
There are a few things I can't figure out how to do. I'll run down the lines in the makefile and say how I *think* I should address them in CodeLite,
so you can correct me if/when I'm wrong, and ask questions where I don't know.
The following lines point to the cross compiler and the objcopy utility. I know how to tell CodeLite what compiler to use: I go to Settings -> Build Settings and add a new compiler.
I have no idea what to do with the objcopy utility.
Code: Select all
CC="C:\path\to\my\cross-gcc"
OBJCOPY="C:\path\to\my\cross-objcopy"
For the project specific flags, I put them in Project Settings -> Common Settings -> Compiler.
Code: Select all
CFLAGS=-mthumb -mcpu=cortex-m3 -DSTM32F10X_CL -DUSE_STDPERIPH_DRIVER \
-DMYFLAG1=0 -DMYFLAG2=0 -O0 \
-ffunction-sections -fdata-sections -g -Wall
Code: Select all
LDFLAGS=-mthumb -mcpu=cortex-m3 -Tstm32_flash.ld -static \
-Wl,-cref,-u,Reset_Handler -Wl,-Map=myproject.map \
-Wl,--gc-sections
Code: Select all
ASFLAGS=-mthumb -mcpu=cortex-m3 -g -Wa,--warn
Code: Select all
OBJS= \
./path/to/object/file.o \
./path/to/another/file.o
There's a long list of include directories. Do I need to add them all to the "Include Paths" in Project Settings?
Code: Select all
INC= \
-I./common_includes/inc/ \
-I./other/includes
Code: Select all
%.o: %.s
$(CC) -c $(ASFLAGS) -o $@ $<
Here's a second object file rule, which uses the compiler flags, if any .c files or include files have changed. I don't think I have to do anything in particular to instruct CodeLite to do this, right?
Code: Select all
%.o: %.c $(INCLUDES)
$(CC) -c $(CFLAGS) $(INC) -o $@ $<
Code: Select all
myproject.elf: $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
Code: Select all
myproject.bin: myproject.elf
$(OBJCOPY) -O binary myproject.elf myproject.bin