Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 ../.. ; /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: gcc-uClibc ld-uClibc
  13. gcc-uClibc.h: Makefile $(TOPDIR)/.config
  14. @echo "/* this file was autogenerated by make */" > gcc-uClibc.h
  15. @echo "#define UCLIBC_TARGET_PREFIX " \"$(TARGET_PREFIX)\" >> gcc-uClibc.h
  16. @echo "#define UCLIBC_DEVEL_PREFIX " \"$(DEVEL_PREFIX)\" >> gcc-uClibc.h
  17. @echo "#define UCLIBC_BUILD_DIR " \"$(UCLIBC_DIR)\" >> gcc-uClibc.h
  18. @echo "#define GCC_BIN " \"$(GCC_BIN)\" >> gcc-uClibc.h
  19. @echo "#define LIBGCC_DIR " \"$(LIBGCC_DIR)\" >> gcc-uClibc.h
  20. @echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> gcc-uClibc.h
  21. @echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> gcc-uClibc.h
  22. @echo "#define BUILD_DYNAMIC_LINKER " \"$(UCLIBC_DIR)/lib/$(UCLIBC_LDSO)\" >> gcc-uClibc.h
  23. ifeq ($(strip $(HAVE_SHARED)),y)
  24. @echo "#define __UCLIBC_HAS_SHARED__ 1" >> gcc-uClibc.h
  25. else
  26. @echo "#undef __UCLIBC_HAS_SHARED__" >> gcc-uClibc.h
  27. endif
  28. ifeq ($(strip $(UCLIBC_HAS_MMU)),y)
  29. @echo "#define __UCLIBC_HAS_MMU__ 1" >> gcc-uClibc.h
  30. else
  31. @echo "#undef __UCLIBC_HAS_MMU__" >> gcc-uClibc.h
  32. endif
  33. ifeq ($(strip $(HAS_ELF)),y)
  34. @echo "#define __HAS_ELF__ 1" >> gcc-uClibc.h
  35. else
  36. @echo "#undef __HAS_ELF__" >> gcc-uClibc.h
  37. endif
  38. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  39. @echo "#define __UCLIBC_CTOR_DTOR__ 1" >> gcc-uClibc.h
  40. ifeq ($(strip $(UCLIBC_PROFILING)),y)
  41. @echo "#define __UCLIBC_PROFILING__ 1" >> gcc-uClibc.h
  42. else
  43. @echo "#undef __UCLIBC_PROFILING__" >> gcc-uClibc.h
  44. endif
  45. else
  46. @echo "#undef __UCLIBC_CTOR_DTOR__" >> gcc-uClibc.h
  47. endif
  48. gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
  49. $(HOSTCC) $(HOSTCFLAGS) -Wl,-s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
  50. ld-uClibc:
  51. @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
  52. @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
  53. @echo "$(LD_BIN) \$$@ -L$(DEVEL_PREFIX)/usr/lib -L$(DEVEL_PREFIX)/lib "\
  54. "-L$(UCLIBC_DIR)" >> $(TARGET_ARCH)-uclibc-ld
  55. chmod a+x $(TARGET_ARCH)-uclibc-ld
  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}`; \
  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 -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core