Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -17,13 +17,19 @@ BUILDSYS_LIB AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins]) if test x"$PLUGIN_SUFFIX" != "x"; then AC_SUBST(OFPLUGIN_M, "OFPlugin.m") AC_SUBST(OFPLUGIN, "OFPlugin") + AC_SUBST(OFPLUGIN_DEF, "-DOF_PLUGINS") fi -AC_C_BIGENDIAN([AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian])]) +AC_C_BIGENDIAN([ + AC_DEFINE(OF_BIG_ENDIAN, 1, [Whether we are big endian]) + AC_SUBST(ENDIANESS_DEF, "-DOF_BIG_ENDIAN") + ], [ + AC_DEFINE(OF_LITTLE_ENDIAN, 1, [Whether we are little endian]) + AC_SUBST(ENDIANESS_DEF, "-DOF_LITTLE_ENDIAN")]) AC_MSG_CHECKING(for SIZE_MAX) AC_EGREP_CPP(yes, [ #include #include @@ -48,11 +54,13 @@ AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl") AC_CHECK_FUNC(asprintf, [ have_asprintf="yes" - AC_DEFINE(HAVE_ASPRINTF, 1, [Whether we have asprintf])], [ + AC_DEFINE(OF_HAVE_ASPRINTF, 1, [Whether we have asprintf]) + AC_SUBST(ASPRINTF_DEF, "-DOF_HAVE_ASPRINTF") + ], [ have_asprintf="no" AC_SUBST(ASPRINTF_C, "asprintf.c")]) AC_MSG_CHECKING(whether snprintf returns something useful) AC_CACHE_VAL(ac_cv_snprintf_useful_ret, [ Index: objfw-config.in ================================================================== --- objfw-config.in +++ objfw-config.in @@ -1,10 +1,10 @@ #!/bin/sh prefix="@prefix@" exec_prefix="@exec_prefix@" CFLAGS="" -CPPFLAGS="-I@includedir@/objfw" +CPPFLAGS="-I@includedir@/objfw @ENDIANESS_DEF@ @ASPRINTF_DEF@ @OFPLUGIN_DEF@" CXXFLAGS="" OBJCFLAGS="-fobjc-exceptions -fconstant-string-class=OFConstString" OBJCFLAGS="$OBJCFLAGS @NO_CONST_CFSTRINGS@" LIBS="-L@libdir@ -lobjfw @LIBS@" VERSION="0.1" Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -25,20 +25,22 @@ OFString.m \ OFTCPSocket.m \ OFThread.m \ OFURLEncoding.m \ OFXMLFactory.m \ - ${ASPRINTF_C} INCLUDESTMP := ${SRCS:.c=.h} INCLUDES := ${INCLUDESTMP:.m=.h} \ - OFMacros.h + OFMacros.h \ + asprintf.h \ + objfw.h -SRCS += ${OBJC_SYNC_M} +SRCS += ${OBJC_SYNC_M} \ + ${ASPRINTF_C} include ../buildsys.mk CPPFLAGS += -I.. CFLAGS += ${LIB_CFLAGS} OBJCFLAGS += ${LIB_CFLAGS} LD = ${OBJC} LDFLAGS += ${LIB_LDFLAGS} Index: src/OFMacros.h ================================================================== --- src/OFMacros.h +++ src/OFMacros.h @@ -7,14 +7,10 @@ * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ -#ifndef OF_CONFIG_H -#error "You need to have the objfw defines in your config.h and include it!" -#endif - #ifdef __GNUC__ #define OF_INLINE inline __attribute__((always_inline)) #define OF_LIKELY(cond) __builtin_expect(!!(cond), 1) #define OF_UNLIKELY(cond) __builtin_expect(!!(cond), 0) #else @@ -21,11 +17,11 @@ #define OF_INLINE inline #define OF_LIKELY(cond) cond #define OF_UNLIKELY(cond) cond #endif -#ifdef OF_BIG_ENDIAN +#if defined(OF_BIG_ENDIAN) static OF_INLINE void OF_BSWAP_V(uint8_t *buf, size_t len) { uint32_t t; @@ -34,12 +30,14 @@ ((uint32_t)buf[1] << 8 | buf[0]); *(uint32_t*)buf = t; buf += sizeof(t); } } -#else +#elif defined(OF_LITTLE_ENDIAN) #define OF_BSWAP_V(buf, len) +#else +#error Please define either OF_BIG_ENDIAN or OF_LITTLE_ENDIAN! #endif #define OF_ROL(val, bits) \ (((val) << (bits)) | ((val) >> (32 - (bits)))) Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -26,13 +26,11 @@ #import "OFMutableString.h" #import "OFExceptions.h" #import "OFMacros.h" -#ifndef HAVE_ASPRINTF #import "asprintf.h" -#endif @implementation OFMutableString - (id)copy { return [[OFString alloc] initWithString: self]; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -26,13 +26,11 @@ #import "OFAutoreleasePool.h" #import "OFURLEncoding.h" #import "OFExceptions.h" #import "OFMacros.h" -#ifndef HAVE_ASPRINTF #import "asprintf.h" -#endif /* Reference for static linking */ void _reference_to_OFURLEncoding_in_OFString() { _OFURLEncoding_reference = 1; Index: src/asprintf.h ================================================================== --- src/asprintf.h +++ src/asprintf.h @@ -6,8 +6,12 @@ * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ + +#ifndef OF_HAVE_ASPRINTF +#include extern int asprintf(char**, const char*, ...); extern int vasprintf(char**, const char*, va_list); +#endif ADDED src/objfw.h Index: src/objfw.h ================================================================== --- src/objfw.h +++ src/objfw.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2008 - 2009 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of libobjfw. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE included in + * the packaging of this file. + */ + +#import +#import + +#import +#import + +#import +#import + +#import + +#import +#import + +#import + +#import + +#import + +#import +#import + +#import +#import +#import + +#ifdef OF_PLUGINS +#import +#endif + +#import +#import