mirror of
git://git.musl-libc.org/musl
synced 2024-12-13 18:25:52 +00:00
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.
This commit is contained in:
parent
230f1813ad
commit
207c45d7ab
28
Makefile
28
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/%)
|
||||
|
||||
|
5
dist/config.mak
vendored
5
dist/config.mak
vendored
@ -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 =
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user