Ensure libraries linked are listed after objects using them

The Ubuntu toolchain uses -Wl,--as-needed by default, which causes
libraries to be dropped from the final binary if they aren't used.  For
portability, make sure that libraries are always listed on the linker
commandline /after/ the objects that reference them.
.
This also avoids passing -l options to the compiler when compiling .o files.
This commit is contained in:
Steve Langasek 2019-09-09 21:04:11 -04:00 committed by Jerome Charaoui
parent f13d4bbcd3
commit 44150667f5
1 changed files with 2 additions and 3 deletions

View File

@ -3,8 +3,7 @@ VERSION=1.1.9
CFLAGS+= -O2 -Wall -Wextra -Wshadow -rdynamic\
-D_FILE_OFFSET_BITS=64 -DVERSION=\"$(VERSION)\" \
`pkg-config --cflags-only-I gumbo libcurl fuse`
LDFLAGS+= -pthread -lgumbo -lcurl -lfuse -lcrypto \
`pkg-config --libs-only-L gumbo libcurl fuse`
LIBS = -pthread -lgumbo -lcurl -lfuse -lcrypto
COBJS = main.o network.o fuse_local.o link.o cache.o util.o
prefix ?= /usr/local
@ -15,7 +14,7 @@ all: httpdirfs
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c -o $@ $<
httpdirfs: $(COBJS)
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
install:
install -m 755 -D httpdirfs \