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