xref: /DragonStub/Makefile (revision 823f04931913f01ee1fc0dc0c7876156ad150388)
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
116gdb:
117	gdb-multiarch -n -x tools/.gdbinit
118
119install:
120	@set -e ; for d in $(SUBDIRS); do \
121		mkdir -p $(OBJDIR)/$$d; \
122		$(MAKE) -C $(OBJDIR)/$$d -f $(SRCDIR)/$$d/Makefile SRCDIR=$(SRCDIR)/$$d install; done
123
124.PHONY:	$(SUBDIRS) clean depend
125
126#
127# on both platforms you must use gcc 3.0 or higher
128#
129check_gcc:
130ifeq ($(GCC_VERSION),2)
131	@echo "you need to use a version of gcc >= 3.0, you are using `$(CC) --version`"
132	@exit 1
133endif
134
135include $(SRCDIR)/Make.rules
136
137test-archive:
138	@rm -rf /tmp/gnu-efi-$(VERSION) /tmp/gnu-efi-$(VERSION)-tmp
139	@mkdir -p /tmp/gnu-efi-$(VERSION)-tmp
140	@git archive --format=tar $(shell git branch | awk '/^*/ { print $$2 }') | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; tar x )
141	@git diff | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; patch -s -p1 -b -z .gitdiff )
142	@mv /tmp/gnu-efi-$(VERSION)-tmp/ /tmp/gnu-efi-$(VERSION)/
143	@dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/gnu-efi-$(VERSION).tar.bz2 gnu-efi-$(VERSION)
144	@rm -rf /tmp/gnu-efi-$(VERSION)
145	@echo "The archive is in gnu-efi-$(VERSION).tar.bz2"
146
147tag:
148	git tag $(VERSION) refs/heads/master
149
150archive: tag
151	@rm -rf /tmp/gnu-efi-$(VERSION) /tmp/gnu-efi-$(VERSION)-tmp
152	@mkdir -p /tmp/gnu-efi-$(VERSION)-tmp
153	@git archive --format=tar $(VERSION) | ( cd /tmp/gnu-efi-$(VERSION)-tmp/ ; tar x )
154	@mv /tmp/gnu-efi-$(VERSION)-tmp/ /tmp/gnu-efi-$(VERSION)/
155	@dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/gnu-efi-$(VERSION).tar.bz2 gnu-efi-$(VERSION)
156	@rm -rf /tmp/gnu-efi-$(VERSION)
157	@echo "The archive is in gnu-efi-$(VERSION).tar.bz2"
158
159