Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. # pull in Rules.mak.....
  20. TOPDIR=../
  21. include $(TOPDIR).config
  22. MAJOR_VERSION=0
  23. UCLIBC_LDSO=ld-uClibc.so.$(MAJOR_VERSION)
  24. # A nifty macro to make testing gcc features easier
  25. check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
  26. then echo "$(1)"; else echo "$(2)"; fi)
  27. # use '-Os' optimization if available, else use -O2, allow Config to override
  28. OPTIMIZATION=$(call check_gcc,-Os,-O2)
  29. UWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
  30. XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
  31. ifndef CROSS
  32. CROSS=
  33. endif
  34. CC= $(CROSS)gcc
  35. AR= $(CROSS)ar
  36. LD= $(CROSS)ld
  37. NM= $(CROSS)nm
  38. STRIPTOOL= $(CROSS)strip
  39. INSTALL= install
  40. LN= ln
  41. RM= rm -f
  42. override CFLAGS=$(UWARNINGS) $(OPTIMIZATION) #$(XARCH_CFLAGS)
  43. override LDFLAGS=-s
  44. ifeq ($(DODEBUG),y)
  45. override CFLAGS=$(UWARNINGS) -O0 -g3 #$(XARCH_CFLAGS)
  46. override LDFLAGS=
  47. endif
  48. # Make certain these contain a final "/", but no "//"s.
  49. RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
  50. DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
  51. TARGETS = ldd ldconfig readelf
  52. ifeq ($(HAVE_SHARED),y)
  53. LIBRARY_CACHE=#-DUSE_CACHE
  54. ifeq ($(BUILD_UCLIBC_LDSO),y)
  55. LDSO=$(TOPDIR)lib/$(UCLIBC_LDSO)
  56. DYNAMIC_LINKER=$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)
  57. else
  58. LDSO=$(SYSTEM_LDSO)
  59. DYNAMIC_LINKER=/lib/$(strip $(subst ",, $(notdir $(SYSTEM_LDSO))))
  60. endif
  61. endif
  62. XXFLAGS=
  63. ifeq ($(strip $(LDSO_LDD_SUPPORT)),y)
  64. XXFLAGS= -D__LDSO_LDD_SUPPORT
  65. else
  66. XXFLAGS=
  67. endif
  68. LDADD_LIBFLOAT=
  69. ifeq ($(strip $(UCLIBC_HAS_SOFT_FLOAT)),y)
  70. CFLAGS += $(call check_gcc,-msoft-float,)
  71. #LDFLAGS+= -Wa,-mno-fpu
  72. ifeq ($(strip $(TARGET_ARCH)),arm)
  73. LDADD_LIBFLOAT=-lfloat
  74. endif
  75. endif
  76. ifeq ($(strip $(HAVE_SHARED)),y)
  77. all: $(TARGETS)
  78. else
  79. all:
  80. endif
  81. headers:
  82. $(LN) -fs $(TOPDIR)include/elf.h
  83. readelf: readelf.c
  84. $(CC) $(CFLAGS) -Wl,-s $^ -o $@ $(LDADD_LIBFLOAT)
  85. $(STRIPTOOL) -x -R .note -R .comment $@
  86. ldconfig: ldconfig.c readsoname.c
  87. $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
  88. -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
  89. -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
  90. $^ -o $@ $(LDADD_LIBFLOAT)
  91. $(STRIPTOOL) -x -R .note -R .comment $@
  92. ldd: ldd.c
  93. $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
  94. -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
  95. -DUCLIBC_LDSO=$(UCLIBC_LDSO) \
  96. $^ -o $@ $(LDADD_LIBFLOAT)
  97. $(STRIPTOOL) -x -R .note -R .comment $@
  98. clean:
  99. $(RM) $(TARGETS) *.o *~ core *.target elf.h
  100. readelf.c readsoname.c ldconfig.c ldd.c: headers
  101. install: all
  102. ifeq ($(strip $(HAVE_SHARED)),y)
  103. $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)sbin
  104. $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)usr/bin
  105. $(INSTALL) -m 755 ldd $(PREFIX)$(RUNTIME_PREFIX)usr/bin/ldd
  106. $(INSTALL) -m 755 ldconfig $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig;
  107. # For now, don't bother with readelf since surely the host
  108. # system has binutils, or we couldn't have gotten this far...
  109. #$(INSTALL) -m 755 readelf $(PREFIX)$(RUNTIME_PREFIX)usr/bin/readelf
  110. endif