Reputation: 3284
I wrote a dovecot plugin in C the last days. My source code itself seems to be quite fine, but I'm currently wondering how to compile it or how to have a more dynamical Makefile.
The problem is, that whenever I try to compile, I get the error Error: unknown type name: »uoff_t«
The problem is, that this type is defined in one referenced library in this way:
#if defined (HAVE_UOFF_T)
/* native support */
#elif defined (UOFF_T_INT)
typedef unsigned int uoff_t;
#elif defined (UOFF_T_LONG)
typedef unsigned long uoff_t;
#elif defined (UOFF_T_LONG_LONG)
typedef unsigned long long uoff_t;
#else
# error uoff_t size not set
#endif
Within dovecot's Autoconf these variables are set based on another type:
AC_CHECK_TYPE(uoff_t, [
have_uoff_t=yes
AC_DEFINE(HAVE_UOFF_T,, Define if you have a native uoff_t type)
], [
have_uoff_t=no
])
AC_TYPEOF(off_t, long int long-long)
case "$typeof_off_t" in
int)
offt_max=INT_MAX
uofft_fmt="u"
if test "$have_uoff_t" != "yes"; then
AC_DEFINE(UOFF_T_INT,, Define if off_t is int)
fi
offt_bits=`expr 8 \* $ac_cv_sizeof_int`
;;
long)
offt_max=LONG_MAX
uofft_fmt="lu"
if test "$have_uoff_t" != "yes"; then
AC_DEFINE(UOFF_T_LONG,, Define if off_t is long)
fi
offt_bits=`expr 8 \* $ac_cv_sizeof_long`
;;
"long long")
offt_max=LLONG_MAX
uofft_fmt="llu"
if test "$have_uoff_t" != "yes"; then
AC_DEFINE(UOFF_T_LONG_LONG,, Define if off_t is long long)
fi
offt_bits=`expr 8 \* $ac_cv_sizeof_long_long`
;;
*)
AC_MSG_ERROR([Unsupported off_t type])
;;
esac
So after all my question is, whether I can have this stuff in an equivalent way in my Makefile without using Automake.
My goal is to check, whether uoff_t is defined already somewhere (for HAVE_UOFF_T) or how the type off_t is defined (for the other parameters). Any ideas, or am I missing something?
Thanks in advance!
Upvotes: 1
Views: 200
Reputation: 3284
Obviously what I tried to do seems not to be possible. I ended up digging myself into autoconf and reusing dovecot's generic definition.
Thanks anyway!
Cheers
Upvotes: 1
Reputation: 54355
My first idea is that if it is a Dovecot plugin (which I know nothing about) doesn't it have to include Dovecot include files?
Wouldn't those include files have already been through the Dovecot autoconf and have all the right values for the uoff_t type?
So the first thing that I would try is to just rely on the Dovecot definition.
I suppose the other thing to do is something that I have done on occasion. Reproduce the autoconf tests inside your Makefile. But I have to warn you it tends to look really ugly. Sort of like this:
TESTOPTTMP:=$(shell mkdir -p tmp; mktemp tmp/test_opt_XXXXXXXXXX)
CFLAGS += $(shell (echo '\#include <pthread.h>'; echo '__thread int global; int main() { global = 1; return 0; }') | gcc -x c -D_GNU_SOURCE -pthread -o $(TESTOPTTMP) - >>/dev/stderr 2>&1; $(TESTOPTTMP) && echo '-DHAVE_TLS'; rm -f $(TESTOPTTMP))
That was for testing compiler support for __thread
. Ugly, isn't it.
Upvotes: 0