diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-06-27 21:38:11 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-06-27 21:38:11 -0400 |
commit | 207c45d7abdf7a4bd93973f195deb4d8e202c3e3 (patch) | |
tree | 87dbe7fe45e66c912d4e5c320318be7d1bbf2fc7 | |
parent | 230f1813ad8264f09d5247fa0ed1e8e361c21e0e (diff) | |
download | musl-207c45d7abdf7a4bd93973f195deb4d8e202c3e3.tar.gz musl-207c45d7abdf7a4bd93973f195deb4d8e202c3e3.tar.xz musl-207c45d7abdf7a4bd93973f195deb4d8e202c3e3.zip |
cleanup shared library build system to be more $HOME-local-install friendly
the path for the dynamic linker is now configurable, and failure to install the symlink for it will not stop the build.
-rw-r--r-- | Makefile | 28 | ||||
-rw-r--r-- | dist/config.mak | 5 | ||||
-rw-r--r-- | tools/gen-musl-gcc.sh | 4 |
3 files changed, 21 insertions, 16 deletions
diff --git a/Makefile b/Makefile index 7185b83c..59ba71e8 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ bindir = $(exec_prefix)/bin prefix = /usr/local/musl includedir = $(prefix)/include libdir = $(prefix)/lib +syslibdir = /lib SRCS = $(sort $(wildcard src/*/*.c)) OBJS = $(SRCS:.c=.o) @@ -33,17 +34,18 @@ ALL_INCLUDES = $(sort $(wildcard include/*.h include/*/*.h) $(GENH)) EMPTY_LIB_NAMES = m rt pthread crypt util xnet resolv dl EMPTY_LIBS = $(EMPTY_LIB_NAMES:%=lib/lib%.a) CRT_LIBS = lib/crt1.o lib/crti.o lib/crtn.o -LIBC_LIBS = lib/libc.a -ALL_LIBS = $(LIBC_LIBS) $(CRT_LIBS) $(EMPTY_LIBS) -ALL_LDSO = lib/ld-musl-$(ARCH).so.1 - +STATIC_LIBS = lib/libc.a $(EMPTY_LIBS) +SHARED_LIBS = lib/libc.so +ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) ALL_TOOLS = tools/musl-gcc +LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH).so.1 + -include config.mak all: $(ALL_LIBS) $(ALL_TOOLS) $(ALL_LDSO) -install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(ALL_INCLUDES:include/%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:tools/%=$(DESTDIR)$(bindir)/%) $(ALL_LDSO:%=$(DESTDIR)/%) $(ALL_LDSO:%/ld-musl-$(ARCH).so.1=$(DESTDIR)$(libdir)/libc.so) +install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(ALL_INCLUDES:include/%=$(DESTDIR)$(includedir)/%) $(ALL_TOOLS:tools/%=$(DESTDIR)$(bindir)/%) $(ALL_LDSO:%=$(DESTDIR)/%) $(LDSO_PATHNAME) clean: rm -f crt/*.o @@ -75,8 +77,8 @@ include/bits/alltypes.h: include/bits/alltypes.h.sh %.lo: %.c $(GENH) $(CC) $(CFLAGS) $(INC) $(PIC) -c -o $@ $< -lib/ld-musl-$(ARCH).so.1: $(LOBJS) - $(CC) $(LDFLAGS) -Wl,-soname=libc.so.1 -o $@ $(LOBJS) -lgcc +lib/libc.so: $(LOBJS) + $(CC) $(LDFLAGS) -Wl,-soname=libc.so -o $@ $(LOBJS) -lgcc $(OBJCOPY) --weaken $@ lib/libc.a: $(OBJS) @@ -92,23 +94,23 @@ lib/%.o: crt/%.o cp $< $@ tools/musl-gcc: tools/gen-musl-gcc.sh config.mak - sh $< "$(prefix)" "$(ARCH)" > $@ || { rm -f $@ ; exit 1 ; } + sh $< "$(prefix)" "$(LDSO_PATHNAME)" > $@ || { rm -f $@ ; exit 1 ; } chmod +x $@ $(DESTDIR)$(bindir)/%: tools/% install -D $< $@ +$(DESTDIR)$(libdir)/%.so: lib/%.so + install -D -m 755 $< $@ + $(DESTDIR)$(libdir)/%: lib/% install -D -m 644 $< $@ $(DESTDIR)$(includedir)/%: include/% install -D -m 644 $< $@ -$(DESTDIR)/lib/ld-musl-$(ARCH).so.1: lib/ld-musl-$(ARCH).so.1 - install -D -m 755 $< $@ - -$(DESTDIR)$(libdir)/libc.so: lib/ld-musl-$(ARCH).so.1 - ln -sf /lib/ld-musl-$(ARCH).so.1 $@ +$(DESTDIR)$(LDSO_PATHNAME): lib/libc.so + ln -sf $(libdir)/libc.so $@ || true .PRECIOUS: $(CRT_LIBS:lib/%=crt/%) diff --git a/dist/config.mak b/dist/config.mak index f0b8fd8f..5429582c 100644 --- a/dist/config.mak +++ b/dist/config.mak @@ -11,6 +11,9 @@ prefix = /usr/local/musl # Installation prefix for musl-gcc compiler wrapper. exec_prefix = /usr/local +# Location for the dynamic linker ld-musl-$(ARCH).so.1 +syslibdir = /lib + # Uncomment if you want to build i386 musl on a 64-bit host #CFLAGS += -m32 @@ -21,4 +24,4 @@ exec_prefix = /usr/local #CFLAGS += -Werror -Wall -Wpointer-arith -Wcast-align -Wno-parentheses -Wno-char-subscripts -Wno-uninitialized -Wno-sequence-point -Wno-missing-braces -Wno-unused-value -Wno-overflow -Wno-int-to-pointer-cast # Uncomment if you want to disable building the shared library. -#ALL_LDSO = +#SHARED_LIBS = diff --git a/tools/gen-musl-gcc.sh b/tools/gen-musl-gcc.sh index 6a35c71f..42fdaec7 100644 --- a/tools/gen-musl-gcc.sh +++ b/tools/gen-musl-gcc.sh @@ -1,6 +1,6 @@ #!/bin/sh -printf '#!/bin/sh\n\nlibc_prefix="%s"\narch="%s"\n' "$1" "$2" +printf '#!/bin/sh\n\nlibc_prefix="%s"\nldso_pathname="%s"\n' "$1" "$2" cat <<"EOF" libc_lib=$libc_prefix/lib @@ -28,5 +28,5 @@ exec "$0" "$@" ' -std=gnu99 -nostdinc -nostdlib \ -isystem "$libc_inc" -isystem "$gcc_inc" \ -Wl,-xxxxxx "$@" -L"$libc_lib" -lc -L"$libgcc" -lgcc -Lxxxxxx \ - -Wl,-dynamic-linker,/lib/ld-musl-"$arch".so.1 -Wl,-nostdlib + -Wl,-dynamic-linker,"$ldso_pathname" -Wl,-nostdlib EOF |