Skip to content

Commit 21c00c0

Browse files
author
Kevin Pyle
committed
Combine sed expressions to reduce number of sed calls
Replace "cp && sed -i" with "sed >", so that the file is written with the desired values on the first pass. Using a single sed reduces the number of processes and the number of complete file rewrites.
1 parent b4d2623 commit 21c00c0

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

Makefile

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,11 @@ docs/_build/man/gcc-with-python.1: docs/gcc-with-python.rst
209209

210210
gcc-with-$(PLUGIN_NAME).1: docs/_build/man/gcc-with-python.1
211211
# Fixup the generic manpage for this build:
212-
cp docs/_build/man/gcc-with-python.1 gcc-with-$(PLUGIN_NAME).1
213212
sed \
214-
-i \
215213
-e"s|gcc-with-python|gcc-with-$(PLUGIN_NAME)|g" \
216-
gcc-with-$(PLUGIN_NAME).1
217-
sed \
218-
-i \
219214
-e"s|GCC-WITH-PYTHON|GCC-WITH-$(UpperPluginName)|g" \
220-
gcc-with-$(PLUGIN_NAME).1
215+
< $< \
216+
> $@
221217

222218
gcc-with-$(PLUGIN_NAME).1.gz: gcc-with-$(PLUGIN_NAME).1
223219
rm -f gcc-with-$(PLUGIN_NAME).1.gz
@@ -238,21 +234,17 @@ install: $(PLUGIN_DSO) gcc-with-$(PLUGIN_NAME).1.gz
238234

239235
# Create "gcc-with-" support script:
240236
mkdir -p $(DESTDIR)$(bindir)
241-
install -m 755 gcc-with-python $(DESTDIR)/$(bindir)/gcc-with-$(PLUGIN_NAME)
242237
# Fixup the reference to the plugin in that script, from being expressed as
243238
# a DSO filename with a path (for a working copy) to a name of an installed
244239
# plugin within GCC's search directory:
245-
sed \
246-
-i \
247-
-e"s|-fplugin=[^ ]*|-fplugin=$(PLUGIN_NAME)|" \
248-
$(DESTDIR)$(bindir)/gcc-with-$(PLUGIN_NAME)
249-
250-
# Fixup the plugin name within -fplugin-arg-PLUGIN_NAME-script to match the
240+
# Fixup the plugin name within -fplugin-arg-PLUGIN_NAME-script to match the
251241
# name for this specific build:
252242
sed \
253-
-i \
243+
-e"s|-fplugin=[^ ]*|-fplugin=$(PLUGIN_NAME)|" \
254244
-e"s|-fplugin-arg-python-script|-fplugin-arg-$(PLUGIN_NAME)-script|" \
255-
$(DESTDIR)$(bindir)/gcc-with-$(PLUGIN_NAME)
245+
< gcc-with-python \
246+
> $(DESTDIR)$(bindir)/gcc-with-$(PLUGIN_NAME)
247+
chmod 755 $(DESTDIR)$(bindir)/gcc-with-$(PLUGIN_NAME)
256248

257249
mkdir -p $(DESTDIR)$(mandir)/man1
258250
cp gcc-with-$(PLUGIN_NAME).1.gz $(DESTDIR)$(mandir)/man1

0 commit comments

Comments
 (0)