Skip to content

Commit

Permalink
Merge pull request #462 from flit/feature/makefile_improvements
Browse files Browse the repository at this point in the history
Makefile improvements
  • Loading branch information
0xc0170 committed Nov 20, 2019
2 parents a67bbeb + 7b74444 commit f928533
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions project_generator/templates/makefile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ ASM_FLAGS = {% for option in asm_flags %} {{option}} {% endfor %}
CFLAGS = $(C_FLAGS) $(INC_DIRS_F) -c $(CC_SYMBOLS)
CXXFLAGS = $(CXX_FLAGS) $(INC_DIRS_F) -c $(CC_SYMBOLS)
ASFLAGS = $(ASM_FLAGS) $(INC_DIRS_F) -c $(ASM_SYMBOLS)
NMFLAGS = -n -f posix -C -l

# Linker options
LD_OPTIONS += {% for option in ld_flags %} {{option}} {% endfor %}
Expand Down Expand Up @@ -106,6 +107,11 @@ S_OBJS += $(patsubst %.S,$(OBJ_FOLDER)%.o,$(filter %.S,$(notdir $(S_SRCS))))

O_OBJS := {% for file in source_files_obj %} {{file}} {% endfor %}

ALL_OBJS := $(C_OBJS) \
$(CPP_OBJS) \
$(S_OBJS) \
$(O_OBJS)

VPATH := $(SRC_DIRS)

$(OBJ_FOLDER)%.o : %.c
Expand Down Expand Up @@ -155,8 +161,7 @@ print_info: $(OBJ_FOLDER)$(TARGET)$(TARGET_EXT)
$(SIZE) --totals $(OBJ_FOLDER)$(TARGET)$(TARGET_EXT)
$(OBJCOPY) {% block TOHEX %}{% endblock %} $(OBJ_FOLDER)$(TARGET)$(TARGET_EXT) {% block objcopy_output %}{% endblock %} $(OBJ_FOLDER)$(TARGET).hex
$(OBJCOPY) {% block TOBIN %}{% endblock %} -v $(OBJ_FOLDER)$(TARGET)$(TARGET_EXT) {{ self.objcopy_output() }} $(OBJ_FOLDER)$(TARGET).bin
-$(OBJDUMP) -D $(OBJ_FOLDER)$(TARGET)$(TARGET_EXT) > $(OBJ_FOLDER)$(TARGET).lst
-$(NM) $(OBJ_FOLDER)$(TARGET)$(TARGET_EXT) > $(OBJ_FOLDER)$(TARGET)-symbol-table.txt
-$(NM) $(NMFLAGS) $(OBJ_FOLDER)$(TARGET)$(TARGET_EXT) > $(OBJ_FOLDER)$(TARGET)-symbol-table.txt
@echo ' '

{% else %}
Expand All @@ -179,3 +184,6 @@ clean:
@echo ' '

.PHONY: clean print_info

# Include dependencies
-include $(ALL_OBJS:.o=.d)
4 changes: 2 additions & 2 deletions project_generator/tools/makefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def get_generated_project_files(self):
def process_data_for_makefile(self, project_data):
# Flatten source dictionaries, we don't need groups
for key in SOURCE_KEYS:
project_data[key] = list(chain(*project_data[key].values()))
project_data[key] = list(sorted(chain(*project_data[key].values())))
# flatten also include files
project_data['include_files'] = list(chain(*project_data['include_files'].values()))
project_data['include_files'] = list(sorted(chain(*project_data['include_files'].values())))

self._get_libs(project_data)
self._parse_specific_options(project_data)
Expand Down

0 comments on commit f928533

Please sign in to comment.