Makefile 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 GCC_INCDIR " \"$(GCCINCDIR)\" >> gcc-uClibc.h
  24. @echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> gcc-uClibc.h
  25. @echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> gcc-uClibc.h
  26. @echo "#define BUILD_DYNAMIC_LINKER " \"$(UCLIBC_DIR)/lib/$(UCLIBC_LDSO)\" >> gcc-uClibc.h
  27. gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
  28. gcc -Wall -O2 -Wl,-s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
  29. ld-uClibc:
  30. @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
  31. @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
  32. @echo "$(LD_BIN) \$$@ -L$(DEVEL_PREFIX)/usr/lib -L$(DEVEL_PREFIX)/lib "\
  33. "-L$(UCLIBC_DIR)" >> $(TARGET_ARCH)-uclibc-ld
  34. chmod a+x $(TARGET_ARCH)-uclibc-ld
  35. install: all
  36. install -d $(PREFIX)$(DEVEL_PREFIX)/bin;
  37. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin;
  38. install -m 755 $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  39. install -m 755 $(TARGET_ARCH)-uclibc-ld $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  40. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-g++
  41. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-c++
  42. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-cc
  43. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/c++
  44. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/g++
  45. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/gcc
  46. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/cc
  47. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ld $(PREFIX)$(DEVEL_PREFIX)/bin/ld
  48. for app in addr2line ar as cpp gasp nm objcopy \
  49. objdump ranlib size strings strip; do \
  50. ln -fs `which $(CROSS)$${app}` $(PREFIX)$(DEVEL_PREFIX)/bin/$${app}; \
  51. ln -fs `which $(CROSS)$${app}` $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
  52. done
  53. clean:
  54. rm -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core