Makefile 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 $(UCLIBC_HAS_MMU)),y)
  24. @echo "#define __UCLIBC_HAS_MMU__ 1" >> gcc-uClibc.h
  25. else
  26. @echo "#undef __UCLIBC_HAS_MMU__" >> gcc-uClibc.h
  27. endif
  28. ifeq ($(strip $(HAS_ELF)),y)
  29. @echo "#define __HAS_ELF__ 1" >> gcc-uClibc.h
  30. else
  31. @echo "#undef __HAS_ELF__" >> gcc-uClibc.h
  32. endif
  33. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  34. @echo "#define __UCLIBC_CTOR_DTOR__ 1" >> gcc-uClibc.h
  35. ifeq ($(strip $(UCLIBC_PROFILING)),y)
  36. @echo "#define __UCLIBC_PROFILING__ 1" >> gcc-uClibc.h
  37. else
  38. @echo "#undef __UCLIBC_PROFILING__" >> gcc-uClibc.h
  39. endif
  40. else
  41. @echo "#undef __UCLIBC_CTOR_DTOR__" >> gcc-uClibc.h
  42. endif
  43. gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
  44. $(HOSTCC) $(HOSTCFLAGS) -Wl,-s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
  45. ld-uClibc:
  46. @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
  47. @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
  48. @echo "$(LD_BIN) \$$@ -L$(DEVEL_PREFIX)/usr/lib -L$(DEVEL_PREFIX)/lib "\
  49. "-L$(UCLIBC_DIR)" >> $(TARGET_ARCH)-uclibc-ld
  50. chmod a+x $(TARGET_ARCH)-uclibc-ld
  51. install: all
  52. install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
  53. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin;
  54. install -m 755 $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  55. install -m 755 $(TARGET_ARCH)-uclibc-ld $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  56. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-cc
  57. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/gcc
  58. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/cc
  59. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ld $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ld
  60. ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
  61. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-g++
  62. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-c++
  63. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/c++
  64. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/g++
  65. endif
  66. for app in addr2line ar as cpp gasp nm objcopy \
  67. objdump ranlib size strings strip; do \
  68. APPNAME=`which $(CROSS)$${app}`; \
  69. if [ -x "$$APPNAME" ] ; then \
  70. ln -fs "$$APPNAME" $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/$${app}; \
  71. ln -fs "$$APPNAME" $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
  72. fi; \
  73. done
  74. clean:
  75. rm -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core