From: Charles Wilson Date: Sat, 21 Mar 2009 14:25:50 +0000 (-0400) Subject: Issue 15, part 14. Build system X-Git-Tag: v2.7.0~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79cb8e5b9986a3b150c5bb9e2a580c652ccc799b;p=thirdparty%2Flibarchive.git Issue 15, part 14. Build system build/m4/la_syslibsearchpath.m4: New. Allows to automatically determine where binmode.o is located, even on cross builds (hopefully). configure.ac: specify AC_CONFIG_MACRO_DIR, AC_CANONICAL_HOST, and AC_LIBTOOL_WIN32_DLL. Add new AM_CONDITIONALs INC_WINDOWS_FILES and INC_CYGWIN_FILES. Use new macro LA_SYS_LIB_SEARCH_PATH to set new AC_SUBST, PROG_LDADD_EXTRA, to /binmode.o on cygwin. Makefile.am: Specify ACLOCAL_AMFLAGS. Use INC_WINDOWS_FILES and INC_CYGWIN_FILES where appropriate. Update all *_EXTRA_DIST variables with new files. Add -DLIBARCHIVE_STATIC to all *_test_CPPFLAGS. Add or update existing ${APP}_LDADD to specify @PROG_LDADD_EXTRA@ (this enables to link apps with binmode.o on cygwin). Works on cygwin (ac-2.63, am-1.10.1, libtool-2.2.7a). Passes all tests. Works on linux (ac-2.61, am-1.10, libtool-1.5.22). Passes all tests. Makefile.am | 75 +++++++++++++++++++++++++++++++---- build/m4/la_syslibsearchpath.m4 | 84 ++++++++++++++++++++++++++++++++++++++++ configure.ac | 34 ++++++++++++++++ SVN-Revision: 827 --- diff --git a/Makefile.am b/Makefile.am index 6855a073b..4709dc125 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,7 @@ ## Process this file with automake to produce Makefile.in AUTOMAKE_OPTIONS= foreign subdir-objects +ACLOCAL_AMFLAGS = -I build/m4 # # What to build and install @@ -152,6 +153,14 @@ libarchive_la_SOURCES= \ libarchive/filter_fork.c \ libarchive/filter_fork.h +if INC_WINDOWS_FILES +libarchive_la_SOURCES+= \ + libarchive/archive_windows.h \ + libarchive/archive_windows.c \ + libarchive/filter_fork_windows.c +endif + + libarchive_la_CPPFLAGS=-I $(top_builddir)/libarchive # -no-undefined marks that libarchive doesn't rely on symbols # defined in the application. This is mandatory for cygwin. @@ -177,6 +186,10 @@ libarchive_EXTRA_DIST= \ libarchive/test/list.h \ libarchive/archive_windows.c \ libarchive/archive_windows.h \ + libarchive/filter_fork_windows.c \ + libarchive/CMakeLists.txt \ + libarchive/COPYING \ + libarchive/README \ $(libarchive_man_MANS) # @@ -266,7 +279,9 @@ libarchive_test_SOURCES= \ libarchive/test/test_write_format_tar_ustar.c \ libarchive/test/test_write_open_memory.c -libarchive_test_CPPFLAGS= -I$(top_builddir)/libarchive -I$(top_srcdir)/libarchive -I$(top_builddir)/libarchive/test +libarchive_test_CPPFLAGS= -I$(top_builddir)/libarchive -I$(top_srcdir)/libarchive -I$(top_builddir)/libarchive/test -DLIBARCHIVE_STATIC + +libarchive_test_LDADD=@PROG_LDADD_EXTRA@ # The "list.h" file just lists all of the tests defined in all of the sources. # Building it automatically provides a sanity-check on libarchive_test_SOURCES @@ -297,7 +312,9 @@ libarchive_test_EXTRA_DIST=\ libarchive/test/test_read_format_isojolietrr_bz2.iso.bz2.uu \ libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu \ libarchive/test/test_read_format_tar_empty_filename.tar.uu \ - libarchive/test/test_read_format_zip.zip.uu + libarchive/test/test_read_format_zip.zip.uu \ + libarchive/test/CMakeLists.txt \ + libarchive/test/README # @@ -321,6 +338,17 @@ bsdtar_SOURCES= \ tar/util.c \ tar/write.c +if INC_WINDOWS_FILES +bsdtar_SOURCES+= \ + tar/bsdtar_windows.h \ + tar/bsdtar_windows.c +endif +if INC_CYGWIN_FILES +bsdtar_SOURCES+= \ + tar/bsdtar_cygwin.h \ + tar/bsdtar_cygwin.c +endif + bsdtar_DEPENDENCIES= libarchive.la if STATIC_BSDTAR @@ -329,11 +357,19 @@ else bsdtar_static= endif -bsdtar_LDADD= libarchive.la +bsdtar_LDADD= libarchive.la @PROG_LDADD_EXTRA@ bsdtar_CPPFLAGS= -I$(top_builddir)/libarchive -I$(top_srcdir)/libarchive bsdtar_LDFLAGS= $(bsdtar_static) bsdtar_EXTRA_DIST= \ - tar/bsdtar.1 + tar/bsdtar.1 \ + tar/bsdtar_windows.h \ + tar/bsdtar_windows.c \ + tar/bsdtar_cygwin.h \ + tar/bsdtar_cygwin.c \ + tar/CMakeLists.txt \ + tar/config_freebsd.h \ + tar/COPYING + if BUILD_BSDTAR bsdtar_man_MANS= tar/bsdtar.1 @@ -366,7 +402,9 @@ bsdtar_test_SOURCES= \ tar/test/test_version.c \ tar/test/test_windows.c + bsdtar_test_CPPFLAGS= -I$(top_builddir)/tar/test +bsdtar_test_LDADD=@PROG_LDADD_EXTRA@ tar/test/list.h: Makefile cat $(top_srcdir)/tar/test/test_*.c | grep DEFINE_TEST > tar/test/list.h @@ -382,7 +420,8 @@ endif bsdtar_test_EXTRA_DIST= \ tar/test/test_patterns_2.tar.uu \ tar/test/test_patterns_3.tar.uu \ - tar/test/test_patterns_4.tar.uu + tar/test/test_patterns_4.tar.uu \ + tar/test/CMakeLists.txt # @@ -402,6 +441,17 @@ bsdcpio_SOURCES= \ cpio/pathmatch.c \ cpio/pathmatch.h +if INC_WINDOWS_FILES +bsdcpio_SOURCES+= \ + cpio/cpio_windows.h \ + cpio/cpio_windows.c +endif +if INC_CYGWIN_FILES +bsdcpio_SOURCES+= \ + cpio/cpio_cygwin.h \ + cpio/cpio_cygwin.c +endif + bsdcpio_DEPENDENCIES = libarchive.la @@ -411,12 +461,19 @@ else bsdcpio_static= endif -bsdcpio_LDADD= libarchive.la +bsdcpio_LDADD= libarchive.la @PROG_LDADD_EXTRA@ bsdcpio_CPPFLAGS= -I$(top_builddir)/libarchive -I$(top_srcdir)/libarchive bsdcpio_LDFLAGS= $(bsdcpio_static) bsdcpio_EXTRA_DIST= \ cpio/test/list.h \ - cpio/bsdcpio.1 + cpio/bsdcpio.1 \ + cpio/cpio_cygwin.h \ + cpio/cpio_cygwin.c \ + cpio/cpio_windows.h \ + cpio/cpio_windows.c \ + cpio/CMakeLists.txt \ + cpio/config_freebsd.h + if BUILD_BSDCPIO # Manpages to install @@ -461,6 +518,7 @@ bsdcpio_test_SOURCES= \ cpio/test/test_pathmatch.c bsdcpio_test_CPPFLAGS= -I$(top_builddir)/libarchive -I$(top_srcdir)/libarchive -I$(top_builddir)/cpio/test +bsdcpio_test_LDADD=@PROG_LDADD_EXTRA@ cpio/test/list.h: Makefile cat $(top_srcdir)/cpio/test/test_*.c | grep DEFINE_TEST > cpio/test/list.h @@ -482,4 +540,5 @@ bsdcpio_test_EXTRA_DIST= \ cpio/test/test_option_m.cpio.uu \ cpio/test/test_option_t.cpio.uu \ cpio/test/test_option_t.stdout.uu \ - cpio/test/test_option_tv.stdout.uu + cpio/test/test_option_tv.stdout.uu \ + cpio/test/CMakeLists.txt diff --git a/build/m4/la_syslibsearchpath.m4 b/build/m4/la_syslibsearchpath.m4 new file mode 100644 index 000000000..8edd81ce7 --- /dev/null +++ b/build/m4/la_syslibsearchpath.m4 @@ -0,0 +1,84 @@ +# la_syslibsearchpath.m4 - attempt to determine the compiler's +# library search directories. +# sets $la_sys_lib_search_path_spec to space-separated list of +# directories, specifing the compiler's built-in search path +# for libraries. This is used by configure.ac when $host_os is +# cygwin, to locate a special *object* we need to link against: +# binmode.o. We know this object is located in that search path. +# However, because gcc does not search for objects in its +# libsearchpath (there is no -l for .o's), we must extract the +# path(s) and search manually. +# +# Adapted from libtool.m4 (_LT_SYS_DYNAMIC_LINKER): +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +AC_DEFUN([LA_SYS_LIB_SEARCH_PATH], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_SED])dnl +AC_REQUIRE([AC_PROG_AWK])dnl +AC_MSG_CHECKING([compiler library search path]) +# don't bother with EBCDIC systems here: +la_NL2SP="tr \\015\\012 \\040\\040" +if test "$GCC" = yes; then + case $host_os in + darwin*) la_awk_arg="/^libraries:/,/LR/" ;; + *) la_awk_arg="/^libraries:/" ;; + esac + la_search_path_spec=`$CC -print-search-dirs | $AWK $la_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + case $la_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + la_search_path_spec=`echo "$la_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + la_search_path_spec=`echo "$la_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + la_tmp_la_search_path_spec= + la_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for la_sys_path in $la_search_path_spec; do + if test -d "$la_sys_path/$la_multi_os_dir"; then + la_tmp_la_search_path_spec="$la_tmp_la_search_path_spec $la_sys_path/$la_multi_os_dir" + else + test -d "$la_sys_path" && \ + la_tmp_la_search_path_spec="$la_tmp_la_search_path_spec $la_sys_path" + fi + done + la_search_path_spec=`echo "$la_tmp_la_search_path_spec" | $AWK ' +BEGIN {RS=" "; FS="/|\n";} { + la_foo=""; + la_count=0; + for (la_i = NF; la_i > 0; la_i--) { + if ($la_i != "" && $la_i != ".") { + if ($la_i == "..") { + la_count++; + } else { + if (la_count == 0) { + la_foo="/" $la_i la_foo; + } else { + la_count--; + } + } + } + } + if (la_foo != "") { la_freq[[la_foo]]++; } + if (la_freq[[la_foo]] == 1) { print la_foo; } +}'` + la_sys_lib_search_path_spec=`echo "$la_search_path_spec" | $la_NL2SP` +else + la_sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +AC_MSG_RESULT($la_sys_lib_search_path_spec)]) + diff --git a/configure.ac b/configure.ac index cd4988010..8669445a0 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,8 @@ AC_INIT([libarchive],LIBARCHIVE_VERSION_S(),[kientzle@freebsd.org]) AC_CONFIG_SRCDIR([libarchive]) # Use auxiliary subscripts from this subdirectory (cleans up root) AC_CONFIG_AUX_DIR([build/autoconf]) +# M4 scripts +AC_CONFIG_MACRO_DIR([build/m4]) # Must follow AC_CONFIG macros above... AM_INIT_AUTOMAKE() @@ -63,13 +65,45 @@ AC_SUBST(LIBARCHIVE_VERSION_NUMBER) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile]) +# Check for host type +AC_CANONICAL_HOST + +dnl Compilation on mingw and Cygwin needs special Makefile rules +inc_windows_files=no +inc_cygwin_files=no +case "$host_os" in + *mingw* ) inc_windows_files=yes ;; + *cygwin*) inc_cygwin_files=yes ;; +esac +AM_CONDITIONAL([INC_WINDOWS_FILES], [test $inc_windows_files = yes]) +AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes]) + # Checks for programs. AC_PROG_CC AM_PROG_CC_C_O AC_PROG_YACC +AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL AC_CHECK_TOOL([STRIP],[strip]) +# +# Locate some specific link objects for cygwin +# +LA_SYS_LIB_SEARCH_PATH +prog_ldadd_extra= +case "$host_os" in +*cygwin*) + for la_sys_path in $la_sys_lib_search_path_spec; do + if test -f $la_sys_path/binmode.o ; then + prog_ldadd_extra=$la_sys_path/binmode.o + break + fi + done + ;; +esac +PROG_LDADD_EXTRA=$prog_ldadd_extra +AC_SUBST(PROG_LDADD_EXTRA) + # # Options for building bsdtar. #