Makefile 3.4 KB

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