Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. STRIP= $(CROSS)strip
  39. LN=ln
  40. override CFLAGS=$(UWARNINGS) $(OPTIMIZATION) #$(XARCH_CFLAGS)
  41. override LDFLAGS=-s
  42. ifeq ($(DODEBUG),y)
  43. override CFLAGS=$(UWARNINGS) -O0 -g3 #$(XARCH_CFLAGS)
  44. override LDFLAGS=
  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. TARGETS = ldd ldconfig readelf
  50. ifeq ($(HAVE_SHARED),y)
  51. LIBRARY_CACHE=#-DUSE_CACHE
  52. ifeq ($(BUILD_UCLIBC_LDSO),y)
  53. LDSO=$(TOPDIR)lib/$(UCLIBC_LDSO)
  54. DYNAMIC_LINKER=$(SHARED_LIB_LOADER_PREFIX)/$(UCLIBC_LDSO)
  55. else
  56. LDSO=$(SYSTEM_LDSO)
  57. DYNAMIC_LINKER=/lib/$(strip $(subst ",, $(notdir $(SYSTEM_LDSO))))
  58. endif
  59. endif
  60. XXFLAGS=
  61. ifeq ($(strip $(LDSO_LDD_SUPPORT)),y)
  62. XXFLAGS= -D__LDSO_LDD_SUPPORT
  63. else
  64. XXFLAGS=
  65. endif
  66. LDADD_LIBFLOAT=
  67. ifeq ($(strip $(UCLIBC_HAS_SOFT_FLOAT)),y)
  68. CFLAGS += $(call check_gcc,-msoft-float,)
  69. #LDFLAGS+= -Wa,-mno-fpu
  70. ifeq ($(strip $(TARGET_ARCH)),arm)
  71. LDADD_LIBFLOAT=-lfloat
  72. endif
  73. endif
  74. ifeq ($(strip $(HAVE_SHARED)),y)
  75. all: $(TARGETS)
  76. else
  77. all:
  78. endif
  79. headers:
  80. $(LN) -fs $(TOPDIR)include/elf.h
  81. readelf: readelf.c
  82. $(CC) $(CFLAGS) -Wl,-s $^ -o $@ $(LDADD_LIBFLOAT)
  83. $(STRIP) -x -R .note -R .comment $@
  84. ldconfig: ldconfig.c readsoname.c
  85. $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
  86. -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
  87. -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
  88. $^ -o $@ $(LDADD_LIBFLOAT)
  89. $(STRIP) -x -R .note -R .comment $@
  90. ldd: ldd.c
  91. $(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
  92. -DUCLIBC_RUNTIME_PREFIX=$(R_PREFIX) \
  93. -DUCLIBC_LDSO=$(UCLIBC_LDSO) \
  94. $^ -o $@ $(LDADD_LIBFLOAT)
  95. $(STRIP) -x -R .note -R .comment $@
  96. clean:
  97. $(RM) $(TARGETS) *.o *~ core *.target elf.h
  98. readelf.c readsoname.c ldconfig.c ldd.c: headers
  99. install: all
  100. ifeq ($(strip $(HAVE_SHARED)),y)
  101. $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)sbin
  102. $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)usr/bin
  103. $(INSTALL) -m 755 ldd $(PREFIX)$(RUNTIME_PREFIX)usr/bin/ldd
  104. $(INSTALL) -m 755 ldconfig $(PREFIX)$(RUNTIME_PREFIX)sbin/ldconfig;
  105. # For now, don't bother with readelf since surely the host
  106. # system has binutils, or we couldn't have gotten this far...
  107. #$(INSTALL) -m 755 readelf $(PREFIX)$(RUNTIME_PREFIX)usr/bin/readelf
  108. endif