diff --git a/lib/Makefile b/lib/Makefile index 61a41ae5..d291cdd9 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,14 +1,11 @@ include ../vars.mk -LIBMAJOR = 0 -LIBMINOR = 0 -LIBMICRO = 0 -LIBXBPS_SHLIB = libxbps.so.$(LIBMAJOR).$(LIBMINOR).$(LIBMICRO) -SHAREDLIB_LDFLAGS = -lprop -larchive -ifdef WITH_SSL -SHAREDLIB_LDFLAGS += -lssl -endif -SHAREDLIB_LDFLAGS += -shared -Wl,-soname,libxbps.so.$(LIBMAJOR) +LIBMAJOR = 0 +LIBMINOR = 0 +LIBMICRO = 0 +LIBXBPS_SHLIB = libxbps.so.$(LIBMAJOR).$(LIBMINOR).$(LIBMICRO) +LDFLAGS += -lprop -larchive -lssl +LDFLAGS += -shared -Wl,-soname,libxbps.so.$(LIBMAJOR) # libfetch LIBFETCH_OBJS = fetch/common.o fetch/fetch.o fetch/file.o fetch/ftp.o fetch/http.o @@ -29,11 +26,11 @@ libfetch: %.o: %.c @echo " [CC] $@" - @$(CC) $(CPPFLAGS) $(SHAREDLIB_CFLAGS) $(CFLAGS) -c $< + @$(CC) $(CPPFLAGS) $(CFLAGS) $(SHAREDLIB_CFLAGS) -c $< libxbps.so: $(OBJS) $(LIBFETCH_OBJS) @echo " [CCLD] $@" - @$(CC) $(LDFLAGS) $(SHAREDLIB_LDFLAGS) $^ -o $(LIBXBPS_SHLIB) + @$(CC) $(LDFLAGS) $^ -o $(LIBXBPS_SHLIB) @-ln -sf $(LIBXBPS_SHLIB) libxbps.so.$(LIBMAJOR) @-ln -sf $(LIBXBPS_SHLIB) libxbps.so diff --git a/lib/fetch/Makefile b/lib/fetch/Makefile index b92cf3de..a018c301 100644 --- a/lib/fetch/Makefile +++ b/lib/fetch/Makefile @@ -3,14 +3,7 @@ include $(TOPDIR)/vars.mk CFLAGS += -Wno-unused-macros -Wno-conversion -Wno-stack-protector CPPFLAGS += -DFTP_COMBINE_CWDS -DNETBSD -I$(TOPDIR)/include - -ifdef WITH_INET6 -CPPFLAGS += -DINET6 -endif - -ifdef WITH_SSL -CPPFLAGS += -DWITH_SSL -endif +CPPFLAGS += -DINET6 -DWITH_SSL OBJS= fetch.o common.o ftp.o http.o file.o INCS= common.h @@ -21,7 +14,7 @@ all: $(INCS) $(GEN) $(OBJS) %.o: %.c $(INCS) $(GEN) @echo " [CC] $@" - @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(SHAREDLIB_CFLAGS) -c $< + @$(CC) $(CPPFLAGS) $(CFLAGS) $(SHAREDLIB_CFLAGS) $(LDFLAGS) -c $< ftperr.h: ftp.errors @echo " [GEN] $@" diff --git a/prog.mk b/prog.mk index df33f378..699867f2 100644 --- a/prog.mk +++ b/prog.mk @@ -1,4 +1,5 @@ OBJS ?= main.o +CFLAGS += -fPIE LDFLAGS += -lxbps .PHONY: all @@ -44,5 +45,5 @@ $(BIN).static: $(OBJS) $(BIN): $(OBJS) @echo " [CCLD] $@" - @$(CC) $^ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ + @$(CC) $^ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -pie -o $@ diff --git a/vars.mk b/vars.mk index 4965e422..c7974469 100644 --- a/vars.mk +++ b/vars.mk @@ -1,8 +1,5 @@ # Common variables. -WITH_INET6 = yes -WITH_SSL = yes - PREFIX ?= /usr/local SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin LIBDIR ?= $(DESTDIR)$(PREFIX)/lib @@ -10,20 +7,21 @@ MANDIR ?= $(DESTDIR)$(PREFIX)/share/man/man8 TOPDIR ?= .. INSTALL_STRIPPED ?= -s +LDFLAGS = -L$(TOPDIR)/lib +CPPFLAGS = -I$(TOPDIR)/include -D_XOPEN_SOURCE=600 -D_GNU_SOURCE +CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES + ifdef DEBUG INSTALL_STRIPPED= DEBUG_FLAGS = -g CPPFLAGS += -DDEBUG endif -LDFLAGS = -L$(TOPDIR)/lib -CPPFLAGS += -I$(TOPDIR)/include -D_XOPEN_SOURCE=600 -D_GNU_SOURCE -CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -SHAREDLIB_CFLAGS = -fvisibility=hidden -WARNFLAGS ?= -pedantic -std=c99 -Wall -Wextra -Werror -Wshadow -Wformat=2 +WARNFLAGS = -pedantic -std=c99 -Wall -Wextra -Werror -Wshadow -Wformat=2 WARNFLAGS += -Wmissing-declarations -Wcomment -Wunused-macros -Wendif-labels WARNFLAGS += -Wcast-qual -Wcast-align -Wstack-protector -CFLAGS += $(DEBUG_FLAGS) $(WARNFLAGS) -fPIC -DPIC -fstack-protector-all +CFLAGS = $(DEBUG_FLAGS) $(WARNFLAGS) -fPIC -DPIC -fstack-protector-all +SHAREDLIB_CFLAGS = -fvisibility=hidden # Grr, hate the static libs! STATIC_LIBS = -lprop -lpthread -larchive -lssl -lcrypto -ldl -lacl \