Skip to content

Commit 1a4dabd

Browse files
committed
Account for different linker flags across the compilers
1 parent 7a8917f commit 1a4dabd

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def generate(self):
4444
self.resources.c_sources +
4545
self.resources.cpp_sources]
4646

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

5050
ctx = {
@@ -71,6 +71,7 @@ def generate(self):
7171
'elf2bin_cmd': "\'" + self.toolchain.elf2bin + "\'",
7272
'link_script_ext': self.toolchain.LINKER_EXT,
7373
'link_script_option': self.LINK_SCRIPT_OPTION,
74+
'user_library_flag': self.USER_LIBRARY_FLAG,
7475
}
7576

7677
for key in ['include_paths', 'library_paths', 'linker_script',
@@ -109,6 +110,11 @@ class GccArm(Makefile):
109110
NAME = 'Make-GCC-ARM'
110111
TOOLCHAIN = "GCC_ARM"
111112
LINK_SCRIPT_OPTION = "-T"
113+
USER_LIBRARY_FLAG = "-L"
114+
115+
@staticmethod
116+
def prepare_lib(libname):
117+
return "-l:" + libname
112118

113119

114120
class Armc5(Makefile):
@@ -118,6 +124,11 @@ class Armc5(Makefile):
118124
NAME = 'Make-ARMc5'
119125
TOOLCHAIN = "ARM"
120126
LINK_SCRIPT_OPTION = "--scatter"
127+
USER_LIBRARY_FLAG = "--userlibpath "
128+
129+
@staticmethod
130+
def prepare_lib(libname):
131+
return libname
121132

122133

123134
class IAR(Makefile):
@@ -127,3 +138,10 @@ class IAR(Makefile):
127138
NAME = 'Make-IAR'
128139
TOOLCHAIN = "IAR"
129140
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)