summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-08-17 22:21:11 -0400
committerRich Felker <dalias@aerifal.cx>2013-08-17 22:21:11 -0400
commite678fc6f32e5e5c013ab4f99c38f5703b15ff6cd (patch)
treede7c3f0b61f5da227bc978c5f3fc0f53180773ca /Makefile
parent109bd65acf5180f0a48ea4c4e5f2bc6884be202d (diff)
downloadmusl-e678fc6f32e5e5c013ab4f99c38f5703b15ff6cd.tar.gz
replace system's install command with a shell script
the historical (non-standardized) install command is really inappropriate for installing binaries/libraries on a system that utilizes memory-mapped executable files. rather than replacing an existing file atomically, it overwrites the existing file. this can cause running programs to see a partially-modified version of the file, resulting in unpredictable behavior, or SIGBUS. a MAP_COPY mode for mmap would get around this problem, but Linux lacks MAP_COPY. the shell script added with this commit works around the problem by writing temporary files and moving them into place. unlike the historical install utility, it also support a -l option for installing a symbolic link atomically, via the same method.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile14
1 files changed, 7 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 7e634dad..829b5f93 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,7 @@ CFLAGS_ALL_SHARED = $(CFLAGS_ALL) -fPIC -DSHARED
AR = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib
+INSTALL = ./tools/install.sh
ARCH_INCLUDES = $(wildcard arch/$(ARCH)/bits/*.h)
ALL_INCLUDES = $(sort $(wildcard include/*.h include/*/*.h) $(GENH) $(ARCH_INCLUDES:arch/$(ARCH)/%=include/%))
@@ -141,23 +142,22 @@ tools/musl-gcc: config.mak
chmod +x $@
$(DESTDIR)$(bindir)/%: tools/%
- install -D $< $@
+ $(INSTALL) -D $< $@
$(DESTDIR)$(libdir)/%.so: lib/%.so
- install -D -m 755 $< $@
+ $(INSTALL) -D -m 755 $< $@
$(DESTDIR)$(libdir)/%: lib/%
- install -D -m 644 $< $@
+ $(INSTALL) -D -m 644 $< $@
$(DESTDIR)$(includedir)/bits/%: arch/$(ARCH)/bits/%
- install -D -m 644 $< $@
+ $(INSTALL) -D -m 644 $< $@
$(DESTDIR)$(includedir)/%: include/%
- install -D -m 644 $< $@
+ $(INSTALL) -D -m 644 $< $@
$(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(libdir)/libc.so
- test -d $(DESTDIR)$(syslibdir) || install -d -m 755 $(DESTDIR)$(syslibdir) || true
- { ln -sf $(libdir)/libc.so $@.tmp.$$$$ && mv -f $@.tmp.$$$$ $@ ; } || true
+ $(INSTALL) -D -l $< $@
install-libs: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(if $(SHARED_LIBS),$(DESTDIR)$(LDSO_PATHNAME),)