Makefile 2.2 KB

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