summaryrefslogtreecommitdiff
path: root/extra/gnu-efi-libs/gnu-efi-3.0v-revert-makefile-commit.patch
blob: 3a04a4b3ea1bf809e92b9029f08790fbed2a0ee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
commit 06744d69273de4945cf0ffcaa4a6abf7cec707b6
Author: Nigel Croxon <nigel.croxon@hp.com>
Date:   Fri Mar 14 13:47:39 2014 -0400

    From: Sylvain Gault <sylvain.gault@gmail.com>
    Date: Wed, 19 Feb 2014 05:18:14 +0100
    Subject: [PATCH] make install: Don't overwrite up-to-date files
    
    make install used to copy files unconditionnally to their destination.
    However, if the destination is used by another Makefile, it will always
    see modified files. "install" target now only update the files when they
    need to.
    
    Signed-off-by: Sylvain Gault <sylvain.gault@gmail.com>
    Signed-off-by: Nigel Croxon <nigel.croxon@hp.com>

diff --git a/gnuefi/Makefile b/gnuefi/Makefile
index e99adbe..85a7db8 100644
--- a/gnuefi/Makefile
+++ b/gnuefi/Makefile
@@ -49,6 +49,19 @@ OBJS	= $(FILES:%=%.o)
 
 TARGETS	= crt0-efi-$(ARCH).o libgnuefi.a
 
+INSTALLTARGETS = $(TARGETS)
+ifneq (,$(findstring FreeBSD,$(OS)))
+ ifeq ($(ARCH),x86_64)
+  INSTALLTARGETS += elf_$(ARCH)_fbsd_efi.lds
+ else
+  INSTALLTARGETS += elf_$(ARCH)_efi.lds
+ endif
+else
+  INSTALLTARGETS += elf_$(ARCH)_efi.lds
+endif
+
+LIBDIRINSTALL = $(INSTALLROOT)/$(LIBDIR)
+
 all:	$(TARGETS)
 
 libgnuefi.a: $(patsubst %,libgnuefi.a(%),$(OBJS))
@@ -56,17 +69,14 @@ libgnuefi.a: $(patsubst %,libgnuefi.a(%),$(OBJS))
 clean:
 	rm -f $(TARGETS) *~ *.o $(OBJS)
 
-install:
-	mkdir -p $(INSTALLROOT)/$(LIBDIR)
-	$(INSTALL) -m 644 $(TARGETS) $(INSTALLROOT)/$(LIBDIR)
-ifneq (,$(findstring FreeBSD,$(OS)))
- ifeq ($(ARCH),x86_64)
-	$(INSTALL) -m 644 $(SRCDIR)/elf_$(ARCH)_fbsd_efi.lds $(INSTALLROOT)/$(LIBDIR)
- else
-	$(INSTALL) -m 644 $(SRCDIR)/elf_$(ARCH)_efi.lds $(INSTALLROOT)/$(LIBDIR)
- endif
-else
-	$(INSTALL) -m 644 $(SRCDIR)/elf_$(ARCH)_efi.lds $(INSTALLROOT)/$(LIBDIR)
-endif
+$(LIBDIRINSTALL):
+	mkdir -p $@
+
+.SECONDEXPANSION:
+
+$(LIBDIRINSTALL)/%: % | $$(dir $$@)
+	$(INSTALL) -m 644 $< $(dir $@)
+
+install: $(addprefix $(LIBDIRINSTALL)/,$(INSTALLTARGETS))
 
 include $(SRCDIR)/../Make.rules
diff --git a/inc/Makefile b/inc/Makefile
index 273d303..297385b 100644
--- a/inc/Makefile
+++ b/inc/Makefile
@@ -8,20 +8,32 @@ TOPDIR = $(SRCDIR)/..
 
 CDIR=$(TOPDIR)/..
 
+INCDIRINSTALL = $(INSTALLROOT)$(PREFIX)/include/efi
+
+SRCHEADERS = $(wildcard $(SRCDIR)/*.h) \
+             $(wildcard $(SRCDIR)/protocol/*.h) \
+             $(wildcard $(SRCDIR)/$(ARCH)/*.h)
+ifeq ($(ARCH),ia64)
+ SRCHEADERS += $(wildcard $(SRCDIR)/protocol/$(ARCH)/*.h)
+endif
+
+HEADERS = $(patsubst $(SRCDIR)/%,%,$(SRCHEADERS))
+
 all:
 
 clean:
 
-install:
-	mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi
-	mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol
-	mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH)
-	$(INSTALL) -m 644 $(SRCDIR)/*.h $(INSTALLROOT)$(PREFIX)/include/efi
-	$(INSTALL) -m 644 $(SRCDIR)/protocol/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol
-	$(INSTALL) -m 644 $(SRCDIR)/$(ARCH)/*.h $(INSTALLROOT)$(PREFIX)/include/efi/$(ARCH)
-ifeq ($(ARCH),ia64)
-	mkdir -p $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64
-	$(INSTALL) -m 644 $(SRCDIR)/protocol/ia64/*.h $(INSTALLROOT)$(PREFIX)/include/efi/protocol/ia64
-endif
+$(INCDIRINSTALL) \
+$(INCDIRINSTALL)/protocol \
+$(INCDIRINSTALL)/$(ARCH) \
+$(INCDIRINSTALL)/protocol/$(ARCH):
+	mkdir -p $@
+
+.SECONDEXPANSION:
+
+$(INCDIRINSTALL)/%.h: %.h | $$(dir $$@)
+	$(INSTALL) -m 644 $< $(dir $@)
+
+install: $(addprefix $(INCDIRINSTALL)/,$(HEADERS))
 
 include $(SRCDIR)/../Make.rules
diff --git a/lib/Makefile b/lib/Makefile
index e9f604e..d2635ad 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -61,8 +61,11 @@ OBJS  = $(FILES:%=%.o)
 
 SUBDIRS = ia32 x86_64 ia64 runtime
 
+LIBDIRINSTALL = $(INSTALLROOT)/$(LIBDIR)
+
 all: libsubdirs libefi.a
 
+.PHONY: libsubdirs
 libsubdirs:
 	for sdir in $(SUBDIRS); do mkdir -p $$sdir; done
 
@@ -71,9 +74,13 @@ libefi.a: $(patsubst %,libefi.a(%),$(OBJS))
 clean:
 	rm -f libefi.a *~ $(OBJS) */*.o
 
-install: libefi.a
-	mkdir -p $(INSTALLROOT)/$(LIBDIR)
-	$(INSTALL) -m 644 libefi.a $(INSTALLROOT)/$(LIBDIR)
+$(LIBDIRINSTALL):
+	mkdir -p $@
+
+$(LIBDIRINSTALL)/libefi.a: libefi.a | $(LIBDIRINSTALL)
+	$(INSTALL) -m 644 $< $(dir $@)
+
+install: $(LIBDIRINSTALL)/libefi.a
 
 include $(SRCDIR)/../Make.rules