From: Sebastien Bourdeauducq Date: Sun, 19 May 2013 10:41:40 +0000 (+0200) Subject: software: add nofloat libbase for size-optimized binaries X-Git-Tag: 24jan2021_ls180~2920 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d487dc607faf8568b52c8535eff7330a91250e11;p=litex.git software: add nofloat libbase for size-optimized binaries --- diff --git a/software/bios/Makefile b/software/bios/Makefile index af8552e8..95d182c4 100644 --- a/software/bios/Makefile +++ b/software/bios/Makefile @@ -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 diff --git a/software/common.mak b/software/common.mak index 8f6e507e..adc7c936 100644 --- a/software/common.mak +++ b/software/common.mak @@ -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 | \ @@ -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 | \ diff --git a/software/libbase/Makefile b/software/libbase/Makefile index 1a80ed19..0a97b973 100644 --- a/software/libbase/Makefile +++ b/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) @@ -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 .*~ *~ diff --git a/software/libbase/vsnprintf.c b/software/libbase/vsnprintf.c index 57948a6a..d23f66a7 100644 --- a/software/libbase/vsnprintf.c +++ b/software/libbase/vsnprintf.c @@ -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; @@ -241,6 +242,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) continue; } +#endif case 'n': /* FIXME: