Makefile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. TOPDIR = ../../
  2. include $(TOPDIR)Rules.mak
  3. UCLIBC_DIR = $(shell (cd ../.. ; /bin/pwd))
  4. GCC_BIN = $(shell which $(CC))
  5. LD_BIN = $(shell which $(LD))
  6. GCC_LIB = $(shell $(CC) -print-libgcc-file-name )
  7. #GCCINCDIR inherited from Rules.mak
  8. all: gcc-uClibc ld-uClibc
  9. gcc-uClibc.h: $(TOPDIR)/Config
  10. @echo "/* this file was autogenerated by make */" > gcc-uClibc.h
  11. @echo "#define UCLIBC_TARGET_PREFIX " \"$(TARGET_PREFIX)\" >> gcc-uClibc.h
  12. @echo "#define UCLIBC_DEVEL_PREFIX " \"$(DEVEL_PREFIX)\" >> gcc-uClibc.h
  13. @echo "#define UCLIBC_BUILD_DIR " \"$(UCLIBC_DIR)/\" >> gcc-uClibc.h
  14. @echo "#define GCC_BIN " \"$(GCC_BIN)\" >> gcc-uClibc.h
  15. @echo "#define GCC_LIB " \"$(GCC_LIB)\" >> gcc-uClibc.h
  16. @echo "#define GCC_INCDIR " \"-I$(GCCINCDIR)/\" >> gcc-uClibc.h
  17. @echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> gcc-uClibc.h
  18. @echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> gcc-uClibc.h
  19. @echo "#define BUILD_DYNAMIC_LINKER " \"$(UCLIBC_DIR)/lib/$(UCLIBC_LDSO)\" >> gcc-uClibc.h
  20. gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
  21. gcc -Wall -O2 -s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
  22. ld-uClibc:
  23. @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
  24. @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
  25. @echo "$(LD_BIN) -L- -L$(DEVEL_PREFIX)/lib -L$(DEVEL_PREFIX)/usr/lib "\
  26. "-L$(UCLIBC_DIR) \$$@" >> $(TARGET_ARCH)-uclibc-ld
  27. chmod a+x $(TARGET_ARCH)-uclibc-ld
  28. install: all
  29. install -d $(PREFIX)$(DEVEL_PREFIX)/bin;
  30. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin;
  31. install -m 755 $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  32. install -m 755 $(TARGET_ARCH)-uclibc-ld $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  33. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-cc
  34. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/gcc
  35. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/cc
  36. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ld $(PREFIX)$(DEVEL_PREFIX)/bin/ld
  37. for app in addr2line ar as cpp gasp nm objcopy \
  38. objdump ranlib size strings strip; do \
  39. ln -fs `which $(CROSS)$${app}` $(PREFIX)$(DEVEL_PREFIX)/bin/$${app}; \
  40. ln -fs `which $(CROSS)$${app}` $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
  41. done
  42. clean:
  43. rm -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core