Makefile 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # Makefile for building a fake gcc/binutils toolchain
  2. # that simply spoofs the location of the C library
  3. #
  4. # Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
  5. #
  6. TOPDIR = ../../
  7. include $(TOPDIR)Rules.mak
  8. UCLIBC_DIR := $(shell (cd $(TOPDIR); /bin/pwd))
  9. GCC_BIN := $(shell which $(CC))
  10. LD_BIN := $(shell which $(LD))
  11. GCCINCDIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
  12. all: $(TARGET_ARCH)-uclibc-gcc $(TARGET_ARCH)-uclibc-ld
  13. gcc-uClibc.h: Makefile $(TOPDIR)/.config
  14. @echo "/* this file was autogenerated by make */" > $@
  15. @echo "#define UCLIBC_TARGET_PREFIX " \"$(TARGET_PREFIX)\" >> $@
  16. @echo "#define UCLIBC_DEVEL_PREFIX " \"$(DEVEL_PREFIX)\" >> $@
  17. @echo "#define UCLIBC_BUILD_DIR " \"$(UCLIBC_DIR)\" >> $@
  18. @echo "#define GCC_BIN " \"$(GCC_BIN)\" >> $@
  19. @echo "#define LIBGCC_DIR " \"$(LIBGCC_DIR)\" >> $@
  20. @echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> $@
  21. @echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> $@
  22. @echo "#define BUILD_DYNAMIC_LINKER " \"$(UCLIBC_DIR)/lib/$(UCLIBC_LDSO)\" >> $@
  23. ifeq ($(strip $(HAVE_SHARED)),y)
  24. @echo "#define __UCLIBC_HAS_SHARED__ 1" >> $@
  25. else
  26. @echo "#undef __UCLIBC_HAS_SHARED__" >> $@
  27. endif
  28. ifeq ($(strip $(UCLIBC_HAS_MMU)),y)
  29. @echo "#define __UCLIBC_HAS_MMU__ 1" >> $@
  30. else
  31. @echo "#undef __UCLIBC_HAS_MMU__" >> $@
  32. endif
  33. ifeq ($(strip $(HAS_ELF)),y)
  34. @echo "#define __HAS_ELF__ 1" >> $@
  35. else
  36. @echo "#undef __HAS_ELF__" >> $@
  37. endif
  38. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  39. @echo "#define __UCLIBC_CTOR_DTOR__ 1" >> $@
  40. ifeq ($(strip $(UCLIBC_PROFILING)),y)
  41. @echo "#define __UCLIBC_PROFILING__ 1" >> $@
  42. else
  43. @echo "#undef __UCLIBC_PROFILING__" >> $@
  44. endif
  45. else
  46. @echo "#undef __UCLIBC_CTOR_DTOR__" >> $@
  47. endif
  48. $(TARGET_ARCH)-uclibc-gcc: gcc-uClibc.c gcc-uClibc.h
  49. $(HOSTCC) $(HOSTCFLAGS) -s $< -o $@
  50. $(TARGET_ARCH)-uclibc-ld: Makefile $(TOPDIR)/.config
  51. @echo "#!/bin/sh" > $@
  52. @echo "# This file was autogenerated by make" >> $@
  53. @echo "exec $(LD_BIN) \"\$$@\" -L$(DEVEL_PREFIX)/usr/lib " \
  54. "-L$(DEVEL_PREFIX)/lib -L$(UCLIBC_DIR)" >> $@
  55. chmod a+x $@
  56. install: all
  57. $(INSTALL) -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
  58. $(INSTALL) -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
  59. $(INSTALL) -m 755 $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  60. $(INSTALL) -m 755 $(TARGET_ARCH)-uclibc-ld $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  61. $(LN) -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-cc
  62. $(LN) -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/gcc
  63. $(LN) -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/cc
  64. $(LN) -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ld $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ld
  65. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  66. $(LN) -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-g++
  67. $(LN) -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-c++
  68. $(LN) -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/c++
  69. $(LN) -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/g++
  70. endif
  71. for app in addr2line ar as cpp gasp nm objcopy \
  72. objdump ranlib size strings strip; do \
  73. APPNAME=`which $(CROSS)$${app} 2>/dev/null`; \
  74. if [ -x "$$APPNAME" ] ; then \
  75. $(LN) -fs "$$APPNAME" $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/$${app}; \
  76. $(LN) -fs "$$APPNAME" $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
  77. fi; \
  78. done
  79. clean:
  80. $(RM) gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core