Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
software: add nofloat libbase for size-optimized binaries
  • Loading branch information
Sebastien Bourdeauducq committed May 19, 2013
1 parent fb6cd48 commit d487dc6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion software/bios/Makefile
Expand Up @@ -22,7 +22,7 @@ bios-rescue.elf: linker-rescue.ld $(OBJECTS) libs
-L$(M2DIR)/software/libnet \
-L$(M2DIR)/software/libbase \
-L$(M2DIR)/software/libcompiler-rt \
-lnet -lbase -lcompiler-rt
-lnet -lbase-nofloat -lcompiler-rt
chmod -x $@

main.o: main.c
Expand Down
8 changes: 4 additions & 4 deletions software/common.mak
Expand Up @@ -49,8 +49,8 @@ LDFLAGS = -nostdlib -nodefaultlibs
# http://scottmcpeak.com/autodepend/autodepend.html

define compilexx-dep
$(CX) -c $(CXXFLAGS) $< -o $*.o
@$(CX_normal) -MM $(CXXFLAGS) $< > $*.d
$(CX) -c $(CXXFLAGS) $(1) $< -o $*.o
@$(CX_normal) -MM $(CXXFLAGS) $(1) $< > $*.d
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
Expand All @@ -59,8 +59,8 @@ $(CX) -c $(CXXFLAGS) $< -o $*.o
endef

define compile-dep
$(CC) -c $(CFLAGS) $< -o $*.o
@$(CC_normal) -MM $(CFLAGS) $< > $*.d
$(CC) -c $(CFLAGS) $(1) $< -o $*.o
@$(CC_normal) -MM $(CFLAGS) $(1) $< > $*.d
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
Expand Down
18 changes: 13 additions & 5 deletions software/libbase/Makefile
@@ -1,17 +1,24 @@
M2DIR=../..
include $(M2DIR)/software/common.mak

OBJECTS=setjmp.o libc.o errno.o crc16.o crc32.o console.o system.o board.o uart.o vsnprintf.o strtod.o qsort.o
OBJECTS=setjmp.o libc.o errno.o crc16.o crc32.o console.o system.o board.o uart.o qsort.o strtod.o

all: libbase.a
all: libbase.a libbase-nofloat.a

# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)

libbase.a: $(OBJECTS)
$(AR) clr libbase.a $(OBJECTS)
libbase.a: $(OBJECTS) vsnprintf.o
$(AR) clr libbase.a $(OBJECTS) vsnprintf.o
$(RANLIB) libbase.a

libbase-nofloat.a: $(OBJECTS) vsnprintf-nofloat.o
$(AR) clr libbase-nofloat.a $(OBJECTS) vsnprintf-nofloat.o
$(RANLIB) libbase-nofloat.a

vsnprintf-nofloat.o: vsnprintf.c
$(call compile-dep,-DNO_FLOAT)

%.o: %.c
$(compile-dep)

Expand All @@ -21,4 +28,5 @@ libbase.a: $(OBJECTS)
.PHONY: clean

clean:
$(RM) $(OBJECTS) $(OBJECTS:.o=.ts) $(OBJECTS:.o=.d) libbase.a .*~ *~
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) vsnprintf.o vsnprintf.d vsnprintf-nofloat.o vsnprintf-nofloat.d
$(RM) libbase.a libbase-nofloat.a .*~ *~
2 changes: 2 additions & 0 deletions software/libbase/vsnprintf.c
Expand Up @@ -192,6 +192,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
16, field_width, precision, flags);
continue;

#ifndef NO_FLOAT
case 'g':
case 'f': {
int m;
Expand Down Expand Up @@ -241,6 +242,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)

continue;
}
#endif

case 'n':
/* FIXME:
Expand Down

0 comments on commit d487dc6

Please sign in to comment.