[tools] Optimization the EXTERN_LIB variable use

This commit is contained in:
iysheng 2021-06-04 23:53:29 +08:00
parent 2884700817
commit 9776fa5021
2 changed files with 10 additions and 2 deletions

View File

@ -51,6 +51,14 @@ def TargetMakefile(env):
if 'CXXFLAGS' in dir(rtconfig):
make.write('CXXFLAGS :=%s' % (rtconfig.CXXFLAGS))
make.write('\n')
if env.has_key('LIBS'):
make.write('EXTERN_LIB := ')
for tlib in env['LIBS']:
make.write('-l%s ' % (tlib))
if env.has_key('LIBPATH'):
for tlibpath in env['LIBPATH']:
make.write('-L%s ' % (tlibpath))
make.write('\n')
make.write('\n')

View File

@ -122,10 +122,10 @@ $(TARGET): $(OBJS)
@echo ar $(TARGET)
@$(CROSS_COMPILE)ar -rv $@ $(OBJS)
else
$(TARGET): $(OBJS) $(EXTERN_LIB)
$(TARGET): $(OBJS)
@echo ------------------------------------------------
@echo link $(TARGET)
@$(CROSS_COMPILE)g++ -o $@ $(LFLAGS) $(OBJS) $(EXTERN_LIB) -lc -lm
@$(CROSS_COMPILE)g++ -o $@ $(LFLAGS) $(OBJS) $(EXTERN_LIB)
@echo ------------------------------------------------
@$(CROSS_COMPILE)objcopy -O binary $@ rtthread.bin
@$(CROSS_COMPILE)size $@