xref: /DragonStub/Makefile (revision 2604d7835e66d1fccc0973634b0121c7925e25f6)
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
37include env.mk
38
39
40export VERSION = 3.0.17
41
42MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
43SRCDIR = $(dir $(MKFILE_PATH))
44
45VPATH = $(SRCDIR)
46
47include $(SRCDIR)/Make.defaults
48
49SUBDIRS = lib gnuefi inc apps
50
51all_stagge2: check_gcc $(SUBDIRS)
52
53ensure_dirs:
54	@mkdir -p $(OBJDIR)/apps/lib
55	@mkdir -p $(OBJDIR)/apps/lib/libfdt
56	@$(MAKE) all_stagge2
57
58all: ensure_dirs
59ifeq ($(ARCH), riscv64)
60	@mkdir -p output
61	cp riscv64/apps/dragon_stub.efi ./output/dragon_stub-riscv64.efi
62endif
63
64.PHONY:
65run:
66	@$(MAKE) all -j $(shell nproc)
67	@$(MAKE) qemu
68
69qemu:
70	cd tools && ./run-qemu.sh && cd ..
71
72install: all
73ifeq ($(ARCH), riscv64)
74	@mkdir -p $(TARGET_SYSROOT)/efi/boot/
75	cp ./output/dragon_stub-riscv64.efi $(TARGET_SYSROOT)/efi/boot/bootriscv64.efi
76else
77	@echo "Not support `make install` for $(ARCH)"
78	exit 1
79endif
80
81gnuefi: lib
82apps:	gnuefi
83
84mkvars:
85	@echo AR=$(AR)
86	@echo ARCH=$(ARCH)
87	@echo ARCH3264=$(ARCH3264)
88	@echo AS=$(AS)
89	@echo ASFLAGS=$(ASFLAGS)
90	@echo CC=$(CC)
91	@echo CFLAGS=$(CFLAGS)
92	@echo CPPFLAGS=$(CPPFLAGS)
93	@echo GCCMINOR=$(GCCMINOR)
94	@echo GCCNEWENOUGH=$(GCCNEWENOUGH)
95	@echo GCCVERSION=$(GCCVERSION)
96	@echo HOSTARCH=$(HOSTARCH)
97	@echo INCDIR=$(INCDIR)
98	@echo INSTALL=$(INSTALL)
99	@echo INSTALLROOT=$(INSTALLROOT)
100	@echo LD=$(LD)
101	@echo LDFLAGS=$(LDFLAGS)
102	@echo LIBDIR=$(LIBDIR)
103	@echo OBJCOPY=$(OBJCOPY)
104	@echo OS=$(OS)
105	@echo prefix=$(prefix)
106	@echo PREFIX=$(PREFIX)
107	@echo RANLIB=$(RANLIB)
108	@echo SRCDIR=$(SRCDIR)
109	@echo TOPDIR=$(TOPDIR)
110	@echo OBJDIR=$(OBJDIR)
111
112$(SUBDIRS):
113	mkdir -p $(OBJDIR)/$@
114	$(MAKE) -C $(OBJDIR)/$@ -f $(SRCDIR)/$@/Makefile SRCDIR=$(SRCDIR)/$@ ARCH=$(ARCH)
115
116clean:
117	rm -f *~
118	rm -f $(shell find . -name "*.o")
119	@set -e ; for d in $(SUBDIRS); do \
120		if [ -d $(OBJDIR)/$$d ]; then \
121			$(MAKE) -C $(OBJDIR)/$$d -f $(SRCDIR)/$$d/Makefile SRCDIR=$(SRCDIR)/$$d clean; \
122		fi; \
123	done
124
125gdb:
126	gdb-multiarch -n -x tools/.gdbinit
127
128#install:
129#	@set -e ; for d in $(SUBDIRS); do \
130#		mkdir -p $(OBJDIR)/$$d; \
131#		$(MAKE) -C $(OBJDIR)/$$d -f $(SRCDIR)/$$d/Makefile SRCDIR=$(SRCDIR)/$$d install; done
132
133.PHONY:	$(SUBDIRS) clean depend
134
135#
136# on both platforms you must use gcc 3.0 or higher
137#
138check_gcc:
139ifeq ($(GCC_VERSION),2)
140	@echo "you need to use a version of gcc >= 3.0, you are using `$(CC) --version`"
141	@exit 1
142endif
143
144include $(SRCDIR)/Make.rules
145
146test-archive:
147	@rm -rf /tmp/gnu-efi-$(VERSION) /tmp/gnu-efi-$(VERSION)-tmp
148	@mkdir -p /tmp/gnu-efi-$(VERSION)-tmp
149	@git archive --format=tar $(shell git branch | awk '/^*/ { print $$2 }') | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; tar x )
150	@git diff | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; patch -s -p1 -b -z .gitdiff )
151	@mv /tmp/gnu-efi-$(VERSION)-tmp/ /tmp/gnu-efi-$(VERSION)/
152	@dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/gnu-efi-$(VERSION).tar.bz2 gnu-efi-$(VERSION)
153	@rm -rf /tmp/gnu-efi-$(VERSION)
154	@echo "The archive is in gnu-efi-$(VERSION).tar.bz2"
155
156tag:
157	git tag $(VERSION) refs/heads/master
158
159archive: tag
160	@rm -rf /tmp/gnu-efi-$(VERSION) /tmp/gnu-efi-$(VERSION)-tmp
161	@mkdir -p /tmp/gnu-efi-$(VERSION)-tmp
162	@git archive --format=tar $(VERSION) | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; tar x )
163	@mv /tmp/gnu-efi-$(VERSION)-tmp/ /tmp/gnu-efi-$(VERSION)/
164	@dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/gnu-efi-$(VERSION).tar.bz2 gnu-efi-$(VERSION)
165	@rm -rf /tmp/gnu-efi-$(VERSION)
166	@echo "The archive is in gnu-efi-$(VERSION).tar.bz2"
167
168