Makefile 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Makefile for building a fake gcc/binutils toolchain
  2. # that simply spoofs the location of the C library
  3. #
  4. # Copyright (C) 2000,2001 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. gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
  34. $(NATIVE_CC) $(NATIVE_CFLAGS) -Wl,-s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
  35. ld-uClibc:
  36. @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
  37. @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
  38. @echo "$(LD_BIN) \$$@ -L$(DEVEL_PREFIX)/usr/lib -L$(DEVEL_PREFIX)/lib "\
  39. "-L$(UCLIBC_DIR)" >> $(TARGET_ARCH)-uclibc-ld
  40. chmod a+x $(TARGET_ARCH)-uclibc-ld
  41. install: all
  42. install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
  43. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin;
  44. install -m 755 $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  45. install -m 755 $(TARGET_ARCH)-uclibc-ld $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  46. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-g++
  47. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-c++
  48. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-cc
  49. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/c++
  50. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/g++
  51. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/gcc
  52. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/cc
  53. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ld $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ld
  54. for app in addr2line ar as cpp gasp nm objcopy \
  55. objdump ranlib size strings strip; do \
  56. APPNAME=`which $(CROSS)$${app}`; \
  57. if [ -x "$$APPNAME" ] ; then \
  58. ln -fs "$$APPNAME" $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/$${app}; \
  59. ln -fs "$$APPNAME" $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
  60. fi; \
  61. done
  62. clean:
  63. rm -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core