Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. TOPDIR = ../../
  2. include $(TOPDIR)Rules.mak
  3. # NOTE: This may need to be modified for your system
  4. ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
  5. DYNAMIC_LINKER = $(INSTALL_DIR)/lib/ld-linux-uclibc.so.$(MAJOR_VERSION)
  6. else
  7. DYNAMIC_LINKER=$(SYSTEM_LDSO)
  8. endif
  9. UCLIBC_DIR = $(shell (cd ../.. ; /bin/pwd))
  10. GCC_BIN = $(shell which $(CC))
  11. LD_BIN = $(shell which $(LD))
  12. GCC_LIB = $(shell $(CC) -print-libgcc-file-name )
  13. #GCCINCDIR inherited from Rules.mak
  14. all: gcc-uClibc ld-uClibc
  15. gcc-uClibc.h: clean
  16. @echo "/* this file was autogenerated by make */" > gcc-uClibc.h
  17. @echo "#define UCLIBC_INSTALL_DIR " \"$(INSTALL_DIR)/\" >> gcc-uClibc.h
  18. @echo "#define UCLIBC_BUILD_DIR " \"$(UCLIBC_DIR)/\" >> gcc-uClibc.h
  19. @echo "#define GCC_BIN " \"$(GCC_BIN)\" >> gcc-uClibc.h
  20. @echo "#define GCC_LIB " \"$(GCC_LIB)\" >> gcc-uClibc.h
  21. @echo "#define GCC_INCDIR " \"-I$(GCCINCDIR)/\" >> gcc-uClibc.h
  22. @echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> gcc-uClibc.h
  23. @echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> gcc-uClibc.h
  24. gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
  25. gcc -Wall -O2 -s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
  26. ld-uClibc:
  27. @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
  28. @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
  29. @echo "$(LD_BIN) -L- -L $(INSTALL_DIR)/lib -L$(UCLIBC_DIR) \$$@" >> $(TARGET_ARCH)-uclibc-ld
  30. chmod a+x $(TARGET_ARCH)-uclibc-ld
  31. install: all
  32. install -d $(INSTALL_DIR)/bin;
  33. install -d $(INSTALL_DIR)/usr/bin;
  34. if [ -x ./$(TARGET_ARCH)-uclibc-gcc ] ; then \
  35. install -m 755 $(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/usr/bin/ ; \
  36. install -m 755 $(TARGET_ARCH)-uclibc-ld $(INSTALL_DIR)/usr/bin/ ; \
  37. ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/bin/cc; \
  38. ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/bin/gcc; \
  39. ln -fs ../usr/bin/$(TARGET_ARCH)-uclibc-ld $(INSTALL_DIR)/bin/ld; \
  40. ln -fs $(TARGET_ARCH)-uclibc-gcc $(INSTALL_DIR)/usr/bin/$(TARGET_ARCH)-uclibc-cc; \
  41. fi;
  42. for app in addr2line ar as cpp gasp nm objcopy \
  43. objdump ranlib readelf size strings strip; do \
  44. ln -fs `which $(CROSS)$${app}` $(INSTALL_DIR)/bin/$${app}; \
  45. done;
  46. for app in addr2line ar as cpp gasp nm objcopy \
  47. objdump ranlib readelf size strings strip; do \
  48. ln -fs `which $(CROSS)$${app}` $(INSTALL_DIR)/usr/bin/$(TARGET_ARCH)-uclibc-$${app}; \
  49. done;
  50. clean:
  51. rm -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core