diff --git a/utils/Makefile b/utils/Makefile index 294501ae4b..c3c8075962 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -1,33 +1,46 @@ PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin CFLAGS += -Wall -Werror -O3 -I$(PREFIX)/include -CFLAGS += -funroll-all-loops -ftree-loop-linear -LDFLAGS += -lprop +CFLAGS += -funroll-all-loops -ftree-loop-linear -fPIC -DPIC +LDFLAGS += -L $$(pwd) -Wl,-rpath $$(pwd) -lxbps BINS ?= xbps-bin xbps-cmpver xbps-digest xbps-pkgdb -all: $(BINS) +# The shared library. +MAJOR = 0 +MINOR = 0 +MICRO = 0 +LIBXBPS_SO = $(LIBXBPS).$(MAJOR).$(MINOR).$(MICRO) +LIBXBPS = libxbps.so +LIBXBPS_LDFLAGS = -lprop -shared -Wl,-soname,$(LIBXBPS).$(MAJOR) + +all: $(LIBXBPS_NAME) $(BINS) .PHONY: all -xbps-bin: xbps-bin.o plist.o +$(LIBXBPS): sha256.o plist.o + $(CC) $(LIBXBPS_LDFLAGS) $^ -o $(LIBXBPS_SO) + -ln -sf $(LIBXBPS_SO) $(LIBXBPS).$(MAJOR) + -ln -sf $(LIBXBPS_SO) $(LIBXBPS) + +xbps-bin: xbps-bin.o $(LIBXBPS) $(CC) $(LDFLAGS) $^ -o $@ xbps-cmpver: xbps-cmpver.o $(CC) $^ -o $@ -xbps-digest: xbps-digest.o sha256.o - $(CC) $^ -o $@ +xbps-digest: xbps-digest.o $(LIBXBPS) + $(CC) $(LDFLAGS) $^ -o $@ -xbps-pkgdb: xbps-pkgdb.o plist.o +xbps-pkgdb: xbps-pkgdb.o $(LIBXBPS) $(CC) $(LDFLAGS) $^ -o $@ .PHONY: clean clean: clean-bins clean-objs clean-bins: - -rm -f $(BINS) + -rm -f $(BINS) $(LIBXBPS)* clean-objs: - -rm -f *.o + -rm -f *.o $(LIBXBPS)* install: $(BINS) install -D $(BINS) $(BINDIR)