Makefile 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Makefile for uClibc
  2. #
  3. # Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
  4. #
  5. # This program is free software; you can redistribute it and/or modify it under
  6. # the terms of the GNU Library General Public License as published by the Free
  7. # Software Foundation; either version 2 of the License, or (at your option) any
  8. # later version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but WITHOUT
  11. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Library General Public License
  16. # along with this program; if not, write to the Free Software Foundation, Inc.,
  17. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. # Pull in the user's uClibc configuration, but do not
  19. # include Rules.mak.....
  20. TOPDIR=../
  21. include $(TOPDIR).config
  22. # A nifty macro to make testing gcc features easier
  23. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  24. then echo "$(1)"; else echo "$(2)"; fi)
  25. # use '-Os' optimization if available, else use -O2, allow Config to override
  26. OPTIMIZATION+=$(call check_gcc,-Os,-O2)
  27. XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
  28. MAJOR_VERSION:=0
  29. UCLIBC_LDSO:=ld-uClibc.so.$(MAJOR_VERSION)
  30. ifndef CROSS
  31. CROSS=
  32. endif
  33. CC= $(CROSS)gcc
  34. AR= $(CROSS)ar
  35. LD= $(CROSS)ld
  36. NM= $(CROSS)nm
  37. STRIP= $(CROSS)strip
  38. LN=ln
  39. ifeq ($(DODEBUG),y)
  40. CFLAGS = $(XWARNINGS) -O0 -g3
  41. LDFLAGS =
  42. else
  43. CFLAGS=$(XWARNINGS) $(OPTIMIZATION)
  44. LDFLAGS = -s
  45. endif
  46. # Make certain these contain a final "/", but no "//"s.
  47. RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
  48. DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
  49. export RUNTIME_PREFIX DEVEL_PREFIX
  50. TARGETS = ldd ldconfig readelf
  51. ifeq ($(strip $(LDSO_LDD_SUPPORT)),y)
  52. XXFLAGS = -D__LDSO_LDD_SUPPORT
  53. endif
  54. ifeq ($(strip $(HAVE_SHARED)),y)
  55. all: $(TARGETS)
  56. else
  57. all:
  58. endif
  59. headers:
  60. $(LN) -fs $(TOPDIR)include/elf.h
  61. readelf: readelf.c
  62. $(CC) $(CFLAGS) -Wl,-s $^ -o $@ $(LDADD_LIBFLOAT)
  63. $(STRIP) -x -R .note -R .comment $@
  64. ldconfig: ldconfig.c readsoname.c
  65. $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
  66. -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
  67. -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
  68. $^ -o $@ $(LDADD_LIBFLOAT)
  69. $(STRIP) -x -R .note -R .comment $@
  70. ldd: ldd.c
  71. $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
  72. -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
  73. -DUCLIBC_LDSO=$(UCLIBC_LDSO) \
  74. $^ -o $@ $(LDADD_LIBFLOAT)
  75. $(STRIP) -x -R .note -R .comment $@
  76. clean:
  77. $(RM) $(TARGETS) *.o *~ core *.target elf.h
  78. readelf.c readsoname.c ldconfig.c ldd.c: headers