Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #
  2. # Copyright (C) 1999-2007 Hewlett-Packard Co.
  3. # Contributed by David Mosberger <davidm@hpl.hp.com>
  4. # Contributed by Stephane Eranian <eranian@hpl.hp.com>
  5. #
  6. # All rights reserved.
  7. #
  8. # Redistribution and use in source and binary forms, with or without
  9. # modification, are permitted provided that the following conditions
  10. # are met:
  11. #
  12. # * Redistributions of source code must retain the above copyright
  13. # notice, this list of conditions and the following disclaimer.
  14. # * Redistributions in binary form must reproduce the above
  15. # copyright notice, this list of conditions and the following
  16. # disclaimer in the documentation and/or other materials
  17. # provided with the distribution.
  18. # * Neither the name of Hewlett-Packard Co. nor the names of its
  19. # contributors may be used to endorse or promote products derived
  20. # from this software without specific prior written permission.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  23. # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  24. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  25. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  27. # BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  28. # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  30. # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  32. # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  33. # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. # SUCH DAMAGE.
  35. #
  36. include env.mk
  37. export VERSION = 3.0.17
  38. MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
  39. SRCDIR = $(dir $(MKFILE_PATH))
  40. VPATH = $(SRCDIR)
  41. include $(SRCDIR)/Make.defaults
  42. SUBDIRS = lib gnuefi inc apps
  43. all_stagge2: check_gcc $(SUBDIRS)
  44. ensure_dirs:
  45. @mkdir -p $(OBJDIR)/apps/lib
  46. @mkdir -p $(OBJDIR)/apps/lib/libfdt
  47. @$(MAKE) all_stagge2
  48. all: ensure_dirs
  49. ifeq ($(ARCH), riscv64)
  50. @mkdir -p output
  51. cp riscv64/apps/dragon_stub.efi ./output/dragon_stub-riscv64.efi
  52. endif
  53. .PHONY:
  54. run:
  55. @$(MAKE) all -j $(shell nproc)
  56. @$(MAKE) qemu
  57. qemu:
  58. cd tools && ./run-qemu.sh && cd ..
  59. install: all
  60. ifeq ($(ARCH), riscv64)
  61. @mkdir -p $(TARGET_SYSROOT)/efi/boot/
  62. cp ./output/dragon_stub-riscv64.efi $(TARGET_SYSROOT)/efi/boot/bootriscv64.efi
  63. else
  64. @echo "Not support `make install` for $(ARCH)"
  65. exit 1
  66. endif
  67. gnuefi: lib
  68. apps: gnuefi
  69. mkvars:
  70. @echo AR=$(AR)
  71. @echo ARCH=$(ARCH)
  72. @echo ARCH3264=$(ARCH3264)
  73. @echo AS=$(AS)
  74. @echo ASFLAGS=$(ASFLAGS)
  75. @echo CC=$(CC)
  76. @echo CFLAGS=$(CFLAGS)
  77. @echo CPPFLAGS=$(CPPFLAGS)
  78. @echo GCCMINOR=$(GCCMINOR)
  79. @echo GCCNEWENOUGH=$(GCCNEWENOUGH)
  80. @echo GCCVERSION=$(GCCVERSION)
  81. @echo HOSTARCH=$(HOSTARCH)
  82. @echo INCDIR=$(INCDIR)
  83. @echo INSTALL=$(INSTALL)
  84. @echo INSTALLROOT=$(INSTALLROOT)
  85. @echo LD=$(LD)
  86. @echo LDFLAGS=$(LDFLAGS)
  87. @echo LIBDIR=$(LIBDIR)
  88. @echo OBJCOPY=$(OBJCOPY)
  89. @echo OS=$(OS)
  90. @echo prefix=$(prefix)
  91. @echo PREFIX=$(PREFIX)
  92. @echo RANLIB=$(RANLIB)
  93. @echo SRCDIR=$(SRCDIR)
  94. @echo TOPDIR=$(TOPDIR)
  95. @echo OBJDIR=$(OBJDIR)
  96. $(SUBDIRS):
  97. mkdir -p $(OBJDIR)/$@
  98. $(MAKE) -C $(OBJDIR)/$@ -f $(SRCDIR)/$@/Makefile SRCDIR=$(SRCDIR)/$@ ARCH=$(ARCH)
  99. clean:
  100. rm -f *~
  101. rm -f $(shell find . -name "*.o")
  102. @set -e ; for d in $(SUBDIRS); do \
  103. if [ -d $(OBJDIR)/$$d ]; then \
  104. $(MAKE) -C $(OBJDIR)/$$d -f $(SRCDIR)/$$d/Makefile SRCDIR=$(SRCDIR)/$$d clean; \
  105. fi; \
  106. done
  107. gdb:
  108. gdb-multiarch -n -x tools/.gdbinit
  109. #install:
  110. # @set -e ; for d in $(SUBDIRS); do \
  111. # mkdir -p $(OBJDIR)/$$d; \
  112. # $(MAKE) -C $(OBJDIR)/$$d -f $(SRCDIR)/$$d/Makefile SRCDIR=$(SRCDIR)/$$d install; done
  113. .PHONY: $(SUBDIRS) clean depend
  114. #
  115. # on both platforms you must use gcc 3.0 or higher
  116. #
  117. check_gcc:
  118. ifeq ($(GCC_VERSION),2)
  119. @echo "you need to use a version of gcc >= 3.0, you are using `$(CC) --version`"
  120. @exit 1
  121. endif
  122. include $(SRCDIR)/Make.rules
  123. test-archive:
  124. @rm -rf /tmp/gnu-efi-$(VERSION) /tmp/gnu-efi-$(VERSION)-tmp
  125. @mkdir -p /tmp/gnu-efi-$(VERSION)-tmp
  126. @git archive --format=tar $(shell git branch | awk '/^*/ { print $$2 }') | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; tar x )
  127. @git diff | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; patch -s -p1 -b -z .gitdiff )
  128. @mv /tmp/gnu-efi-$(VERSION)-tmp/ /tmp/gnu-efi-$(VERSION)/
  129. @dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/gnu-efi-$(VERSION).tar.bz2 gnu-efi-$(VERSION)
  130. @rm -rf /tmp/gnu-efi-$(VERSION)
  131. @echo "The archive is in gnu-efi-$(VERSION).tar.bz2"
  132. tag:
  133. git tag $(VERSION) refs/heads/master
  134. archive: tag
  135. @rm -rf /tmp/gnu-efi-$(VERSION) /tmp/gnu-efi-$(VERSION)-tmp
  136. @mkdir -p /tmp/gnu-efi-$(VERSION)-tmp
  137. @git archive --format=tar $(VERSION) | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; tar x )
  138. @mv /tmp/gnu-efi-$(VERSION)-tmp/ /tmp/gnu-efi-$(VERSION)/
  139. @dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/gnu-efi-$(VERSION).tar.bz2 gnu-efi-$(VERSION)
  140. @rm -rf /tmp/gnu-efi-$(VERSION)
  141. @echo "The archive is in gnu-efi-$(VERSION).tar.bz2"