Makefile 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. GCC_LIB = $(shell $(CC) -print-libgcc-file-name )
  12. GCC_LIB_DIR = $(dir $(shell $(CC) -print-libgcc-file-name ))
  13. GCCINCDIR:= ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
  14. all: gcc-uClibc ld-uClibc
  15. gcc-uClibc.h: $(TOPDIR)/Config
  16. @echo "/* this file was autogenerated by make */" > gcc-uClibc.h
  17. @echo "#define UCLIBC_TARGET_PREFIX " \"$(TARGET_PREFIX)\" >> gcc-uClibc.h
  18. @echo "#define UCLIBC_DEVEL_PREFIX " \"$(DEVEL_PREFIX)\" >> gcc-uClibc.h
  19. @echo "#define UCLIBC_BUILD_DIR " \"$(UCLIBC_DIR)\" >> gcc-uClibc.h
  20. @echo "#define GCC_BIN " \"$(GCC_BIN)\" >> gcc-uClibc.h
  21. @echo "#define GCC_LIB " \"$(GCC_LIB)\" >> gcc-uClibc.h
  22. @echo "#define GCC_LIB_DIR " \"$(GCC_LIB_DIR)\" >> gcc-uClibc.h
  23. @echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> gcc-uClibc.h
  24. @echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> gcc-uClibc.h
  25. @echo "#define BUILD_DYNAMIC_LINKER " \"$(UCLIBC_DIR)/lib/$(UCLIBC_LDSO)\" >> gcc-uClibc.h
  26. ifeq ($(strip $(HAS_MMU)),true)
  27. @echo "#define HAS_MMU 1" >> gcc-uClibc.h
  28. else
  29. @echo "#undef HAS_MMU" >> gcc-uClibc.h
  30. endif
  31. gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
  32. gcc -Wall -O2 -Wl,-s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
  33. ld-uClibc:
  34. @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
  35. @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
  36. @echo "$(LD_BIN) \$$@ -L$(DEVEL_PREFIX)/usr/lib -L$(DEVEL_PREFIX)/lib "\
  37. "-L$(UCLIBC_DIR)" >> $(TARGET_ARCH)-uclibc-ld
  38. chmod a+x $(TARGET_ARCH)-uclibc-ld
  39. install: all
  40. install -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin;
  41. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin;
  42. install -m 755 $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  43. install -m 755 $(TARGET_ARCH)-uclibc-ld $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  44. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-g++
  45. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-c++
  46. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-cc
  47. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/c++
  48. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/g++
  49. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/gcc
  50. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/cc
  51. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ld $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ld
  52. for app in addr2line ar as cpp gasp nm objcopy \
  53. objdump ranlib size strings strip; do \
  54. ln -fs `which $(CROSS)$${app}` $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/$${app}; \
  55. ln -fs `which $(CROSS)$${app}` $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
  56. done
  57. clean:
  58. rm -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core