xref: /DragonStub/Makefile (revision 3e6106c4d60a23aae3c0740979c5e6fb728b63c3)
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
72gnuefi: lib
73apps:	gnuefi
74
75mkvars:
76	@echo AR=$(AR)
77	@echo ARCH=$(ARCH)
78	@echo ARCH3264=$(ARCH3264)
79	@echo AS=$(AS)
80	@echo ASFLAGS=$(ASFLAGS)
81	@echo CC=$(CC)
82	@echo CFLAGS=$(CFLAGS)
83	@echo CPPFLAGS=$(CPPFLAGS)
84	@echo GCCMINOR=$(GCCMINOR)
85	@echo GCCNEWENOUGH=$(GCCNEWENOUGH)
86	@echo GCCVERSION=$(GCCVERSION)
87	@echo HOSTARCH=$(HOSTARCH)
88	@echo INCDIR=$(INCDIR)
89	@echo INSTALL=$(INSTALL)
90	@echo INSTALLROOT=$(INSTALLROOT)
91	@echo LD=$(LD)
92	@echo LDFLAGS=$(LDFLAGS)
93	@echo LIBDIR=$(LIBDIR)
94	@echo OBJCOPY=$(OBJCOPY)
95	@echo OS=$(OS)
96	@echo prefix=$(prefix)
97	@echo PREFIX=$(PREFIX)
98	@echo RANLIB=$(RANLIB)
99	@echo SRCDIR=$(SRCDIR)
100	@echo TOPDIR=$(TOPDIR)
101	@echo OBJDIR=$(OBJDIR)
102
103$(SUBDIRS):
104	mkdir -p $(OBJDIR)/$@
105	$(MAKE) -C $(OBJDIR)/$@ -f $(SRCDIR)/$@/Makefile SRCDIR=$(SRCDIR)/$@ ARCH=$(ARCH)
106
107clean:
108	rm -f *~
109	rm -f $(shell find . -name "*.o")
110	@set -e ; for d in $(SUBDIRS); do \
111		if [ -d $(OBJDIR)/$$d ]; then \
112			$(MAKE) -C $(OBJDIR)/$$d -f $(SRCDIR)/$$d/Makefile SRCDIR=$(SRCDIR)/$$d clean; \
113		fi; \
114	done
115
116install:
117	@set -e ; for d in $(SUBDIRS); do \
118		mkdir -p $(OBJDIR)/$$d; \
119		$(MAKE) -C $(OBJDIR)/$$d -f $(SRCDIR)/$$d/Makefile SRCDIR=$(SRCDIR)/$$d install; done
120
121.PHONY:	$(SUBDIRS) clean depend
122
123#
124# on both platforms you must use gcc 3.0 or higher
125#
126check_gcc:
127ifeq ($(GCC_VERSION),2)
128	@echo "you need to use a version of gcc >= 3.0, you are using `$(CC) --version`"
129	@exit 1
130endif
131
132include $(SRCDIR)/Make.rules
133
134test-archive:
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 $(shell git branch | awk '/^*/ { print $$2 }') | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; tar x )
138	@git diff | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; patch -s -p1 -b -z .gitdiff )
139	@mv /tmp/gnu-efi-$(VERSION)-tmp/ /tmp/gnu-efi-$(VERSION)/
140	@dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/gnu-efi-$(VERSION).tar.bz2 gnu-efi-$(VERSION)
141	@rm -rf /tmp/gnu-efi-$(VERSION)
142	@echo "The archive is in gnu-efi-$(VERSION).tar.bz2"
143
144tag:
145	git tag $(VERSION) refs/heads/master
146
147archive: tag
148	@rm -rf /tmp/gnu-efi-$(VERSION) /tmp/gnu-efi-$(VERSION)-tmp
149	@mkdir -p /tmp/gnu-efi-$(VERSION)-tmp
150	@git archive --format=tar $(VERSION) | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; tar x )
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
156