Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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: clean
  10. @echo "/* this file was autogenerated by make */" > gcc-uClibc.h
  11. @echo "#define UCLIBC_ROOT_DIR " \"$(ROOT_DIR)\" >> 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. gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
  20. gcc -Wall -O2 -s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
  21. ld-uClibc:
  22. @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
  23. @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
  24. @echo "$(LD_BIN) -L- -L$(DEVEL_PREFIX)$(ROOT_DIR)/lib -L$(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib "\
  25. "-L$(UCLIBC_DIR) \$$@" >> $(TARGET_ARCH)-uclibc-ld
  26. chmod a+x $(TARGET_ARCH)-uclibc-ld
  27. install: all
  28. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/bin;
  29. install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin;
  30. if [ -x ./$(TARGET_ARCH)-uclibc-gcc ] ; then \
  31. install -m 755 $(TARGET_ARCH)-uclibc-gcc $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin/ ; \
  32. install -m 755 $(TARGET_ARCH)-uclibc-ld $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin/ ; \
  33. ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-gcc $(DEVEL_PREFIX)$(ROOT_DIR)/bin/cc; \
  34. ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-gcc $(DEVEL_PREFIX)$(ROOT_DIR)/bin/gcc; \
  35. ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-ld $(DEVEL_PREFIX)$(ROOT_DIR)/bin/ld; \
  36. ln -fs $(TARGET_ARCH)-uclibc-gcc $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin/$(TARGET_ARCH)-uclibc-cc; \
  37. fi;
  38. for app in addr2line ar as cpp gasp nm objcopy \
  39. objdump ranlib size strings strip; do \
  40. ln -fs `which $(CROSS)$${app}` $(DEVEL_PREFIX)$(ROOT_DIR)/bin/$${app}; \
  41. done;
  42. for app in addr2line ar as cpp gasp nm objcopy \
  43. objdump ranlib size strings strip; do \
  44. ln -fs `which $(CROSS)$${app}` $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin/$(TARGET_ARCH)-uclibc-$${app}; \
  45. done;
  46. clean:
  47. rm -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core