Makefile 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #GCCINCDIR inherited from Rules.mak
  13. all: gcc-uClibc ld-uClibc
  14. gcc-uClibc.h: $(TOPDIR)/Config
  15. @echo "/* this file was autogenerated by make */" > gcc-uClibc.h
  16. @echo "#define UCLIBC_TARGET_PREFIX " \"$(TARGET_PREFIX)\" >> gcc-uClibc.h
  17. @echo "#define UCLIBC_DEVEL_PREFIX " \"$(DEVEL_PREFIX)\" >> gcc-uClibc.h
  18. @echo "#define UCLIBC_BUILD_DIR " \"$(UCLIBC_DIR)/\" >> gcc-uClibc.h
  19. @echo "#define GCC_BIN " \"$(GCC_BIN)\" >> gcc-uClibc.h
  20. @echo "#define GCC_LIB " \"$(GCC_LIB)\" >> gcc-uClibc.h
  21. @echo "#define GCC_INCDIR " \"-I$(GCCINCDIR)/\" >> gcc-uClibc.h
  22. @echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> gcc-uClibc.h
  23. @echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> gcc-uClibc.h
  24. @echo "#define BUILD_DYNAMIC_LINKER " \"$(UCLIBC_DIR)/lib/$(UCLIBC_LDSO)\" >> gcc-uClibc.h
  25. gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
  26. gcc -Wall -O2 -s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
  27. ld-uClibc:
  28. @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
  29. @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
  30. @echo "$(LD_BIN) -L- -L$(DEVEL_PREFIX)/lib -L$(DEVEL_PREFIX)/usr/lib "\
  31. "-L$(UCLIBC_DIR) \$$@" >> $(TARGET_ARCH)-uclibc-ld
  32. chmod a+x $(TARGET_ARCH)-uclibc-ld
  33. install: all
  34. install -d $(PREFIX)$(DEVEL_PREFIX)/bin;
  35. install -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin;
  36. install -m 755 $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  37. install -m 755 $(TARGET_ARCH)-uclibc-ld $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
  38. ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-cc
  39. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/gcc
  40. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/cc
  41. ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ld $(PREFIX)$(DEVEL_PREFIX)/bin/ld
  42. for app in addr2line ar as cpp gasp nm objcopy \
  43. objdump ranlib size strings strip; do \
  44. ln -fs `which $(CROSS)$${app}` $(PREFIX)$(DEVEL_PREFIX)/bin/$${app}; \
  45. ln -fs `which $(CROSS)$${app}` $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
  46. done
  47. clean:
  48. rm -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core