1) Use GNU libtool to build shared libraries on non-FreeBSD
systems (or on FreeBSD systems when using ports). 2) Overhaul the versioning logic. In particular, SHLIB_MAJOR number is now computed as "major+minor", which ensures library versions are the same for the FreeBSD build system and the portable libtool/autoconf/automake build system.
This commit is contained in:
parent
f6f67ea993
commit
db38abe649
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=151275
@ -1,7 +1,7 @@
|
||||
All of the C source code, header files, and documentation in this
|
||||
package are covered by the following:
|
||||
|
||||
Copyright (c) 2003-2004 Tim Kientzle
|
||||
Copyright (c) 2003-2005 Tim Kientzle
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -1,31 +1,55 @@
|
||||
# $FreeBSD$
|
||||
|
||||
#
|
||||
# Use "make distfile" to build a conventional tar.gz archive
|
||||
# complete with autoconf/automake-generated build system.
|
||||
#
|
||||
|
||||
# This Makefile is for use with the FreeBSD buid system. For
|
||||
# non-FreeBSD systems, you should first "make distfile" on FreeBSD,
|
||||
# then use the resulting tar.gz archive--which contains a portable
|
||||
# autoconf/automake-generated build system--on the other system.
|
||||
|
||||
LIB= archive
|
||||
VERSION= 1.02.033
|
||||
ARCHIVE_API_FEATURE= 2
|
||||
ARCHIVE_API_VERSION= 2
|
||||
SHLIB_MAJOR= ${ARCHIVE_API_VERSION}
|
||||
|
||||
# Versioning <sigh>. There are three distinct sets of version
|
||||
# numbers:
|
||||
# * libarchive version
|
||||
# * libtool version (for shared libs built using configure script)
|
||||
# * FreeBSD SHLIB_MAJOR
|
||||
# The following logic helps ensure that there is some consistency across
|
||||
# these three:
|
||||
|
||||
# First, the libarchive version is in three parts:
|
||||
# Bumped ONLY when API/ABI breakage happens (non-backwards-compatible change).
|
||||
ARCHIVE_API_MAJOR= 1
|
||||
# Bumped when significant new features are added.
|
||||
# Also used to bump SHLIB_MAJOR for reasons other than API/ABI breakage.
|
||||
# Note: Do NOT reset this to zero after bumping ARCHIVE_API_MAJOR!
|
||||
ARCHIVE_API_MINOR= 2
|
||||
# Bumped often. ;-)
|
||||
ARCHIVE_API_REVISION= 36
|
||||
# Full libarchive version combines the above three numbers.
|
||||
VERSION!=printf "%d.%02d.%03d" ${ARCHIVE_API_MAJOR} ${ARCHIVE_API_MINOR} ${ARCHIVE_API_REVISION}
|
||||
|
||||
# The FreeBSD SHLIB_MAJOR is computed from the above values.
|
||||
SHLIB_MAJOR!= expr ${ARCHIVE_API_MAJOR} + ${ARCHIVE_API_MINOR}
|
||||
|
||||
# The SHLIB_MAJOR computation above helps ensure that the libtool
|
||||
# version (computed in configure.ac.in) provides the same
|
||||
# shared library number as is used on FreeBSD.
|
||||
|
||||
CFLAGS+= -DPACKAGE_NAME=\"lib${LIB}\"
|
||||
CFLAGS+= -DPACKAGE_VERSION=\"${VERSION}\"
|
||||
CFLAGS+= -I${.OBJDIR}
|
||||
|
||||
# FreeBSD/arm has some limitations.
|
||||
.if ${MACHINE_ARCH} == "arm"
|
||||
WARNS?= 3
|
||||
.else
|
||||
WARNS?= 6
|
||||
.endif
|
||||
|
||||
# Headers to be installed in /usr/include
|
||||
INCS= archive.h archive_entry.h
|
||||
|
||||
# Note: archive.h does need to be listed here, since it's built
|
||||
SRCS= archive.h \
|
||||
archive_check_magic.c \
|
||||
# C sources to be compiled. This is one part of SRCS below.
|
||||
BASE_SRCS= archive_check_magic.c \
|
||||
archive_entry.c \
|
||||
archive_read.c \
|
||||
archive_read_data_into_buffer.c \
|
||||
@ -59,6 +83,12 @@ SRCS= archive.h \
|
||||
archive_write_set_format_shar.c \
|
||||
archive_write_set_format_ustar.c
|
||||
|
||||
# Note: archive.h does need to be in SRCS, since it is built
|
||||
# from archive.h.in. But it does not get included in DIST_FILES
|
||||
# below, so I build up SRCS in two steps.
|
||||
SRCS= ${BASE_SRCS} archive.h
|
||||
|
||||
# Man pages to be installed.
|
||||
MAN= archive_entry.3 \
|
||||
archive_read.3 \
|
||||
archive_util.3 \
|
||||
@ -67,6 +97,7 @@ MAN= archive_entry.3 \
|
||||
libarchive-formats.5 \
|
||||
tar.5
|
||||
|
||||
# Symlink the man pages under each function name.
|
||||
MLINKS+= archive_entry.3 archive_entry_acl_add_entry.3
|
||||
MLINKS+= archive_entry.3 archive_entry_acl_add_entry_w.3
|
||||
MLINKS+= archive_entry.3 archive_entry_acl_clear.3
|
||||
@ -169,11 +200,14 @@ MLINKS+= archive_write.3 archive_write_set_format_shar.3
|
||||
MLINKS+= archive_write.3 archive_write_set_format_ustar.3
|
||||
MLINKS+= libarchive.3 archive.3
|
||||
|
||||
# Build archive.h from archive.h.in
|
||||
# Build archive.h from archive.h.in by substituting version information.
|
||||
archive.h: archive.h.in Makefile
|
||||
cat ${.CURDIR}/archive.h.in | \
|
||||
sed 's/@ARCHIVE_API_VERSION@/${ARCHIVE_API_VERSION}/' | \
|
||||
sed 's/@ARCHIVE_API_FEATURE@/${ARCHIVE_API_FEATURE}/' | \
|
||||
sed 's/@VERSION@/${VERSION}/g' | \
|
||||
sed 's/@SHLIB_MAJOR@/${SHLIB_MAJOR}/g' | \
|
||||
sed 's/@ARCHIVE_API_MAJOR@/${ARCHIVE_API_MAJOR}/g' | \
|
||||
sed 's/@ARCHIVE_API_MINOR@/${ARCHIVE_API_MINOR}/g' | \
|
||||
sed 's/@ARCHIVE_API_REVISION@/${ARCHIVE_API_REVISION}/g' | \
|
||||
cat > archive.h
|
||||
|
||||
# archive.h needs to be cleaned
|
||||
@ -187,7 +221,8 @@ CLEANFILES+= archive.h
|
||||
DIST_WORK_DIR= ${.OBJDIR}/lib${LIB}-${VERSION}
|
||||
CLEANDIRS+= ${DIST_WORK_DIR}
|
||||
DISTFILE= lib${LIB}-${VERSION}.tar.gz
|
||||
DIST_FILES= ${SRCS}
|
||||
# DIST_FILES is the list of files to include in the distribution.
|
||||
DIST_FILES= ${BASE_SRCS}
|
||||
DIST_FILES+= ${MAN}
|
||||
DIST_FILES+= archive.h.in
|
||||
DIST_FILES+= archive_entry.h archive_platform.h
|
||||
@ -197,15 +232,24 @@ DIST_FILES+= Makefile.am
|
||||
distfile:
|
||||
rm -rf ${DIST_WORK_DIR}
|
||||
mkdir ${DIST_WORK_DIR}
|
||||
for f in ${DIST_FILES}; \
|
||||
do \
|
||||
cat ${.CURDIR}/$$f >${DIST_WORK_DIR}/$$f || true; \
|
||||
# Copy the DIST_FILES; ignore errors, don't preserve permissions.
|
||||
for f in ${DIST_FILES}; do \
|
||||
cat ${.CURDIR}/$$f >${DIST_WORK_DIR}/$$f || true; \
|
||||
done
|
||||
cat ${.CURDIR}/configure.ac.in | \
|
||||
sed 's/@VERSION@/${VERSION}/' | \
|
||||
# Build configure.ac from configure.ac.in
|
||||
cat ${.CURDIR}/configure.ac.in | \
|
||||
sed 's/@VERSION@/${VERSION}/g' | \
|
||||
sed 's/@SHLIB_MAJOR@/${SHLIB_MAJOR}/g' | \
|
||||
sed 's/@ARCHIVE_API_MAJOR@/${ARCHIVE_API_MAJOR}/g' | \
|
||||
sed 's/@ARCHIVE_API_MINOR@/${ARCHIVE_API_MINOR}/g' | \
|
||||
sed 's/@ARCHIVE_API_REVISION@/${ARCHIVE_API_REVISION}/g' | \
|
||||
cat > ${DIST_WORK_DIR}/configure.ac
|
||||
# Prepare some auxiliary files.
|
||||
(cd ${DIST_WORK_DIR} && libtoolize)
|
||||
(cd ${DIST_WORK_DIR} && aclocal && autoheader)
|
||||
# Build the configure script and portable Makefile
|
||||
(cd ${DIST_WORK_DIR} && autoconf && automake -a --foreign)
|
||||
# Now, use automake-generated Makefile to build the final dist file.
|
||||
(cd ${DIST_WORK_DIR} && ./configure && make distcheck && make dist)
|
||||
mv ${DIST_WORK_DIR}/${DISTFILE} ${.OBJDIR}
|
||||
@echo ==================================================
|
||||
|
@ -1,13 +1,13 @@
|
||||
# $FreeBSD$
|
||||
|
||||
lib_LIBRARIES= libarchive.a
|
||||
lib_LTLIBRARIES= libarchive.la
|
||||
|
||||
include_HEADERS= archive_entry.h
|
||||
# Note: archive.h is built from archive.h.in, so don't
|
||||
# include archive.h in the distfile, but do install it.
|
||||
nodist_include_HEADERS= archive.h
|
||||
|
||||
libarchive_a_SOURCES= \
|
||||
libarchive_la_SOURCES= \
|
||||
archive_check_magic.c \
|
||||
archive_entry.c \
|
||||
archive_entry.h \
|
||||
@ -46,6 +46,9 @@ libarchive_a_SOURCES= \
|
||||
archive_write_set_format_shar.c \
|
||||
archive_write_set_format_ustar.c
|
||||
|
||||
libarchive_la_LIBADD=-lz -lbz2
|
||||
libarchive_la_LDFLAGS= -version-info $(LIBTOOL_VERSION)
|
||||
|
||||
dist_man_MANS= archive_entry.3 \
|
||||
archive_read.3 \
|
||||
archive_util.3 \
|
||||
|
@ -29,6 +29,11 @@
|
||||
#ifndef ARCHIVE_H_INCLUDED
|
||||
#define ARCHIVE_H_INCLUDED
|
||||
|
||||
/*
|
||||
* This header file corresponds to:
|
||||
* Library version @VERSION@
|
||||
* Shared library version @SHLIB_MAJOR@
|
||||
*/
|
||||
|
||||
#include <sys/types.h> /* Linux requires this for off_t */
|
||||
#include <inttypes.h> /* For int64_t */
|
||||
@ -54,11 +59,12 @@ extern "C" {
|
||||
* 1 - Version tests are available.
|
||||
* 2 - archive_{read,write}_close available separately from _finish.
|
||||
*/
|
||||
#define ARCHIVE_API_VERSION @ARCHIVE_API_VERSION@
|
||||
#define ARCHIVE_API_VERSION @ARCHIVE_API_MAJOR@
|
||||
int archive_api_version(void);
|
||||
#define ARCHIVE_API_FEATURE @ARCHIVE_API_FEATURE@
|
||||
#define ARCHIVE_API_FEATURE @ARCHIVE_API_MINOR@
|
||||
int archive_api_feature(void);
|
||||
/* Textual name/version of the library. */
|
||||
#define ARCHIVE_LIBRARY_VERSION "libarchive @VERSION@"
|
||||
const char * archive_version(void);
|
||||
|
||||
#define ARCHIVE_BYTES_PER_RECORD 512
|
||||
|
@ -6,9 +6,13 @@ AM_INIT_AUTOMAKE(libarchive, @VERSION@)
|
||||
AC_CONFIG_SRCDIR([archive_write_set_format_ustar.c])
|
||||
AM_CONFIG_HEADER([config.h])
|
||||
|
||||
# Yes, libtool version numbering is somewhat strange.
|
||||
LIBTOOL_VERSION=@SHLIB_MAJOR@:@ARCHIVE_API_REVISION@:@ARCHIVE_API_MINOR@
|
||||
AC_SUBST(LIBTOOL_VERSION)
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_LIBTOOL
|
||||
AC_CHECK_TOOL([STRIP],[strip])
|
||||
|
||||
# Checks for libraries.
|
||||
@ -87,8 +91,8 @@ AC_CHECK_DECL([ACL_USER],
|
||||
|
||||
# Additional requirements
|
||||
AC_SYS_LARGEFILE
|
||||
AC_SUBST(ARCHIVE_API_VERSION,[1])
|
||||
AC_SUBST(ARCHIVE_API_FEATURE,[1])
|
||||
AC_SUBST(ARCHIVE_API_MAJOR,[@ARCHIVE_API_MAJOR@])
|
||||
AC_SUBST(ARCHIVE_API_MINOR,[@ARCHIVE_API_MINOR@])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_FILES([archive.h])
|
||||
|
Loading…
Reference in New Issue
Block a user