Skip to content

Commit 9fce16d

Browse files
authored
Merge pull request #3061 from theotherjimmy/makefile-lib-fix
Exporters: Use correct names for library files in makefile exporter
2 parents 5b67832 + 1a4dabd commit 9fce16d

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

tools/export/makefile/Makefile.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ PROJECT := {{name}}
5353
{% endfor %}
5454
{% for path in include_paths %}INCLUDE_PATHS += -I{{path}}
5555
{% endfor %}
56-
LIBRARY_PATHS :={% for p in library_paths %} -L{{p}} {% endfor %}
57-
LIBRARIES :={% for lib in libraries %} -l{{lib}} {% endfor %}
56+
LIBRARY_PATHS :={% for p in library_paths %} {{user_library_flag}}{{p}} {% endfor %}
57+
LIBRARIES :={% for lib in libraries %} {{lib}} {% endfor %}
5858
LINKER_SCRIPT := {{linker_script}}
5959
{%- block additional_variables -%}{% endblock %}
6060

tools/export/makefile/__init__.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def generate(self):
4444
self.resources.c_sources +
4545
self.resources.cpp_sources]
4646

47-
libraries = [splitext(lib)[0][3:] for lib in self.resources.libraries]
47+
libraries = [self.prepare_lib(basename(lib)) for lib
48+
in self.resources.libraries]
4849

4950
ctx = {
5051
'name': self.project_name,
@@ -70,6 +71,7 @@ def generate(self):
7071
'elf2bin_cmd': "\'" + self.toolchain.elf2bin + "\'",
7172
'link_script_ext': self.toolchain.LINKER_EXT,
7273
'link_script_option': self.LINK_SCRIPT_OPTION,
74+
'user_library_flag': self.USER_LIBRARY_FLAG,
7375
}
7476

7577
for key in ['include_paths', 'library_paths', 'linker_script',
@@ -108,6 +110,11 @@ class GccArm(Makefile):
108110
NAME = 'Make-GCC-ARM'
109111
TOOLCHAIN = "GCC_ARM"
110112
LINK_SCRIPT_OPTION = "-T"
113+
USER_LIBRARY_FLAG = "-L"
114+
115+
@staticmethod
116+
def prepare_lib(libname):
117+
return "-l:" + libname
111118

112119

113120
class Armc5(Makefile):
@@ -117,6 +124,11 @@ class Armc5(Makefile):
117124
NAME = 'Make-ARMc5'
118125
TOOLCHAIN = "ARM"
119126
LINK_SCRIPT_OPTION = "--scatter"
127+
USER_LIBRARY_FLAG = "--userlibpath "
128+
129+
@staticmethod
130+
def prepare_lib(libname):
131+
return libname
120132

121133

122134
class IAR(Makefile):
@@ -126,3 +138,10 @@ class IAR(Makefile):
126138
NAME = 'Make-IAR'
127139
TOOLCHAIN = "IAR"
128140
LINK_SCRIPT_OPTION = "--config"
141+
USER_LIBRARY_FLAG = "-L"
142+
143+
@staticmethod
144+
def prepare_lib(libname):
145+
if "lib" == libname[:3]:
146+
libname = libname[3:]
147+
return "-l" + splitext(libname)[0]

0 commit comments

Comments
 (0)