Skip to content

Commit

Permalink
Add --with-libarchive configure option to specify where to find archi…
Browse files Browse the repository at this point in the history
…ve.h.

By default it is searched in /usr/include and /usr/local/include, if the
header file is not in these directory you must use this option. For
example: ./configure --with-libarchive=/opt/csw
  • Loading branch information
darold committed Mar 17, 2019
1 parent 86abf54 commit b17224b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
28 changes: 26 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ with_gnu_ld
with_sysroot
enable_libtool_lock
with_c_icap
with_libarchive
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -1455,6 +1456,7 @@ Optional Packages:
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
--with-c-icap Where to find c-icap
--with-libarchive Where to find archive.h
Some influential environment variables:
CC C compiler command
Expand Down Expand Up @@ -12655,9 +12657,31 @@ if test -z "$cicapdir"; then
fi
# Check for libarchive
if test -f "/usr/include/archive.h" || test -f "/usr/local/include/archive.h"; then
# Check whether --with-libarchive was given.
if test "${with_libarchive+set}" = set; then :
withval=$with_libarchive;
if test -f $withval/archive.h; then
haslibarchive='yes'
libarchivelibs=" -larchive -lz -lbz2"
libarchivedir=" -I$withval"
fi
fi
if test -z "$haslibarchive"; then
if test -f "/usr/include/archive.h"; then
haslibarchive='yes'
libarchivelibs=" -larchive -lz -lbz2"
libarchivedir=""
else
if test -f "/usr/local/include/archive.h"; then
haslibarchive='yes'
libarchivelibs=" -larchive -lz -lbz2"
libarchivedir=" -I/usr/local/include"
fi
fi
fi
if test -n $cicapmods; then
Expand All @@ -12669,7 +12693,7 @@ else
fi
CFLAGS="$CFLAGS $cicapflags"
CFLAGS="$CFLAGS $cicapflags $libarchivedir"
MODULES_LIBADD="$cicaplibs $libarchivelibs"
UTILITIES_LIBADD="$cicapliblibs"
UTILITIES_CFLAGS="$cicaplibflags"
Expand Down
24 changes: 22 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,34 @@ if test -z "$cicapdir"; then
fi

# Check for libarchive
if test -f "/usr/include/archive.h" || test -f "/usr/local/include/archive.h"; then
AC_ARG_WITH(libarchive,
[ --with-libarchive Where to find archive.h ],
[
if test -f $withval/archive.h; then
haslibarchive='yes'
libarchivelibs=" -larchive -lz -lbz2"
libarchivedir=" -I$withval"
fi
],
)

if test -z "$haslibarchive"; then
if test -f "/usr/include/archive.h"; then
haslibarchive='yes'
libarchivelibs=" -larchive -lz -lbz2"
libarchivedir=""
else
if test -f "/usr/local/include/archive.h"; then
haslibarchive='yes'
libarchivelibs=" -larchive -lz -lbz2"
libarchivedir=" -I/usr/local/include"
fi
fi
fi

AM_CONDITIONAL(CICAPMODULESDIR, [test -n $cicapmods])

CFLAGS="$CFLAGS $cicapflags"
CFLAGS="$CFLAGS $cicapflags $libarchivedir"
MODULES_LIBADD="$cicaplibs $libarchivelibs"
UTILITIES_LIBADD="$cicapliblibs"
UTILITIES_CFLAGS="$cicaplibflags"
Expand Down

5 comments on commit b17224b

@yvoinov
Copy link
Contributor

@yvoinov yvoinov commented on b17224b Mar 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes.

Option can't discover archive.h, when path specified

--with-libarchive=/opt/csw

(i.e. like in --with-c-icap=/usr/local option, when we're specified one level up directory).

and, to find libarchive, option must be specified

--with-libarchive=/opt/csw/include

which look a bit illogical.

Also a bit cosmetic:

https://i.imgur.com/Itmy9GK.png

--with-* options looks like unformatted ;)

@darold
Copy link
Owner Author

@darold darold commented on b17224b Mar 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why it is illogical? You have to give the directory where archive.h is stored. The configure script will use -I/opt/csw/include or -I/usr/local/include.

I've also noted the cosmetic issue on --help output formatting.

@yvoinov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually in --with-* options set base dir, not exact dir (for libraries/includes).

--with-c-icap= found ICAP library/include starting from base_dir (/usr/local, for example).

Thus, will be logical --with-libarchive will have same behaviour, isn't it? ;)

@darold
Copy link
Owner Author

@darold darold commented on b17224b Mar 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree even if --with-c-icap is not a good example :-) Commit b465edd allow both, base dir and real dir. The cosmetic issue is also fixed. Thanks Yuri.

@yvoinov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem :)

Please sign in to comment.