Restructure the Makefiles, INET6 and SSL support in libfetch is now

mandatory, build executables as PIE objects.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20100106101556-tqzwk80xpp0iz20t
This commit is contained in:
Juan RP 2010-01-06 11:15:56 +01:00
parent 253be2e783
commit ec907d0646
4 changed files with 19 additions and 30 deletions

View File

@ -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

View File

@ -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] $@"

View File

@ -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 $@

16
vars.mk
View File

@ -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 \