Skip to content

Update autotools buildsystem for libdispatch-500.1.5 and testsuite #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ An uncustomized install requires:

The following configure options may be of general interest:

--with-apple-libc-source
--with-apple-libpthread-source

Specify the path to Apple's Libc package, so that appropriate headers can
be found and used.
Specify the path to Apple's libpthread package, so that appropriate headers
can be found and used.

--with-apple-libplatform-source

Specify the path to Apple's libplatform package, so that appropriate headers
can be found and used.

--with-apple-libclosure-source

Expand All @@ -38,12 +43,12 @@ The following configure options may be of general interest:
--with-blocks-runtime

On systems where -fblocks is supported, specify an additional library path
in which libBlocksRuntime can be found. This is not required on Mac OS X,
in which libBlocksRuntime can be found. This is not required on OS X,
where the Blocks runtime is included in libSystem, but is required on
FreeBSD.

The following options are likely to only be useful when building libdispatch on
Mac OS X as a replacement for /usr/lib/system/libdispatch.dylib:
OS X as a replacement for /usr/lib/system/libdispatch.dylib:

--with-apple-objc4-source

Expand All @@ -59,31 +64,33 @@ Mac OS X as a replacement for /usr/lib/system/libdispatch.dylib:

Do not tag libdispatch's init routine as __constructor, in which case it
must be run manually before libdispatch routines can be called. This is the
default when building on Mac OS X. For /usr/lib/system/libdispatch.dylib
default when building on OS X. For /usr/lib/system/libdispatch.dylib
the init routine is called automatically during process start.

--enable-apple-tsd-optimizations

Use a non-portable allocation scheme for pthread per-thread data (TSD) keys
when building libdispatch for /usr/lib/system on Mac OS X. This should not
be used on other OS's, or on Mac OS X when building a stand-alone library.
when building libdispatch for /usr/lib/system on OS X. This should not
be used on other OS's, or on OS X when building a stand-alone library.

Typical configuration commands

The following command lines create the configuration required to build
libdispatch for /usr/lib/system on OS X MountainLion:
libdispatch for /usr/lib/system on OS X El Capitan:

sh autogen.sh
clangpath=$(dirname `xcrun --find clang`)
sudo mkdir -p "$clangpath/../local/lib/clang/enable_objc_gc"
LIBTOOLIZE=glibtoolize sh autogen.sh
cflags='-arch x86_64 -arch i386 -g -Os'
./configure CFLAGS="$cflags" OBJCFLAGS="$cflags" CXXFLAGS="$cflags" \
--prefix=/usr --libdir=/usr/lib/system \
--disable-dependency-tracking --disable-static \
--prefix=/usr --libdir=/usr/lib/system --disable-static \
--enable-apple-tsd-optimizations \
--with-apple-libc-source=/path/to/10.8.0/Libc-825.24 \
--with-apple-libclosure-source=/path/to/10.8.0/libclosure-59 \
--with-apple-xnu-source=/path/to/10.8.0/xnu-2050.7.9 \
--with-apple-objc4-source=/path/to/10.8.0/objc4-532 \
--with-apple-libauto-source=/path/to/10.8.0/libauto-185.1
--with-apple-libpthread-source=/path/to/10.11.0/libpthread-137.1.1 \
--with-apple-libplatform-source=/path/to/10.11.0/libplatform-73.1.1 \
--with-apple-libclosure-source=/path/to/10.11.0/libclosure-65 \
--with-apple-xnu-source=/path/to/10.11.0/xnu-3247.1.106 \
--with-apple-objc4-source=/path/to/10.11.0/objc4-680 \
--with-apple-libauto-source=/path/to/10.11.0/libauto-186
make check

Typical configuration line for FreeBSD 8.x and 9.x to build libdispatch with
Expand Down
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ SUBDIRS= \
man \
os \
private \
src
src \
tests

EXTRA_DIST= \
README.md \
LICENSE \
PATCHES \
autogen.sh \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ libdispatch on Darwin is a combination of logic in the `xnu` kernel alongside th

Our first tasks for this project are:

0. Develop a makefile or other build script for the project on Linux. The current build system is focused on Darwin.
0. Adapt the current autotools build system to work on Linux, or develop a new makefile or other build script for the project on Linux. The current version of the build system has only been tested on Darwin, though previous versions have been made to work on FreeBSD and Linux (see INSTALL).
0. Omit as much of the extra functionality of the library as possible, to get a core version of the project building. Much of the OS X-specific functionality can be elided completely on Linux.
0. Adopt libdispatch in other Core Libraries projects, especially Foundation. This will validate our work and get immediate coverage on basic functionality.
0. Incrementally add functionality back in.
Expand Down
65 changes: 36 additions & 29 deletions config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,20 @@
/* Define to 1 if you have the <pthread_np.h> header file. */
/* #undef HAVE_PTHREAD_NP_H */

/* Define to 1 if you have the <pthread/qos.h> header file. */
#define HAVE_PTHREAD_QOS_H 1

/* Define if pthread work queues are present */
#define HAVE_PTHREAD_WORKQUEUES 1

/* Define to 1 if you have the `pthread_workqueue_setdispatch_np' function. */
#define HAVE_PTHREAD_WORKQUEUE_SETDISPATCH_NP 1
/* Define to 1 if you have the <pthread_workqueue.h> header file. */
#define HAVE_PTHREAD_WORKQUEUE_H 1

/* Define to 1 if you have the `_pthread_workqueue_init' function. */
#define HAVE__PTHREAD_WORKQUEUE_INIT 1
/* Define to 1 if you have the <pthread/workqueue_private.h> header file. */
#define HAVE_PTHREAD_WORKQUEUE_PRIVATE_H 1

/* Define to 1 if you have the <pthread/qos.h> header file. */
#define HAVE_PTHREAD_QOS_H 1
/* Define to 1 if you have the `pthread_workqueue_setdispatch_np' function. */
#define HAVE_PTHREAD_WORKQUEUE_SETDISPATCH_NP 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
Expand Down Expand Up @@ -147,8 +150,10 @@
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
/* Define to 1 if you have the `_pthread_workqueue_init' function. */
#define HAVE__PTHREAD_WORKQUEUE_INIT 1

/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"

/* Name of package */
Expand All @@ -161,13 +166,16 @@
#define PACKAGE_NAME "libdispatch"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libdispatch 1.2"
#define PACKAGE_STRING "libdispatch 1.3"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libdispatch"

/* Define to the home page for this package. */
#define PACKAGE_URL "http://libdispatch.macosforge.org"

/* Define to the version of this package. */
#define PACKAGE_VERSION "1.2"
#define PACKAGE_VERSION "1.3"

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
Expand All @@ -184,20 +192,30 @@
/* Define to use POSIX semaphores */
/* #undef USE_POSIX_SEM */

/* Version number of package */
#define VERSION "1.2"

/* Define to 1 if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
/* # undef _ALL_SOURCE */
# define _ALL_SOURCE 1
#endif

/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif


/* Version number of package */
#define VERSION "1.3"

/* Define to 1 if on MINIX. */
/* #undef _MINIX */
Expand All @@ -211,14 +229,3 @@

/* Define if using Darwin $NOCANCEL */
#define __DARWIN_NON_CANCELABLE 1

/* Enable extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
84 changes: 57 additions & 27 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# When this file changes, rerun autogen.sh.
#

AC_PREREQ(2.59)
AC_INIT([libdispatch], [1.2], [libdispatch@macosforge.org], [libdispatch])
AC_PREREQ(2.69)
AC_INIT([libdispatch], [1.3], [libdispatch@macosforge.org], [libdispatch], [http://libdispatch.macosforge.org])
AC_REVISION([$$])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_HEADER([config/config.h])
Expand All @@ -14,32 +14,42 @@ AM_MAINTAINER_MODE
AC_PROG_CC([clang gcc cc])
AC_PROG_CXX([clang++ g++ c++])
AC_PROG_OBJC([clang gcc cc])
AC_PROG_OBJCXX([clang++ g++ c++])

#
# On Mac OS X, some required header files come from other source packages;
# allow specifying where those are.
#
AC_ARG_WITH([apple-libc-source],
[AS_HELP_STRING([--with-apple-libc-source],
[Specify path to Apple Libc source])], [
apple_libc_source_pthreads_path=${withval}/pthreads
CPPFLAGS="$CPPFLAGS -I$apple_libc_source_pthreads_path"
AC_ARG_WITH([apple-libpthread-source],
[AS_HELP_STRING([--with-apple-libpthread-source],
[Specify path to Apple libpthread source])], [
apple_libpthread_source_path=${withval}
CPPFLAGS="$CPPFLAGS -isystem $apple_libpthread_source_path"
])

AC_ARG_WITH([apple-libplatform-source],
[AS_HELP_STRING([--with-apple-libplatform-source],
[Specify path to Apple libplatform source])], [
apple_libplatform_source_include_path=${withval}/include
CPPFLAGS="$CPPFLAGS -isystem $apple_libplatform_source_include_path"
])

AC_ARG_WITH([apple-libclosure-source],
[AS_HELP_STRING([--with-apple-libclosure-source],
[Specify path to Apple libclosure source])], [
apple_libclosure_source_path=${withval}
CPPFLAGS="$CPPFLAGS -I$apple_libclosure_source_path"
CPPFLAGS="$CPPFLAGS -isystem $apple_libclosure_source_path"
])

AC_ARG_WITH([apple-xnu-source],
[AS_HELP_STRING([--with-apple-xnu-source],
[Specify path to Apple XNU source])], [
apple_xnu_source_libsyscall_path=${withval}/libsyscall
apple_xnu_source_libproc_path=${withval}/libsyscall/wrappers/libproc
apple_xnu_source_libkern_path=${withval}/libkern
apple_xnu_source_bsd_path=${withval}/bsd
apple_xnu_source_osfmk_path=${withval}/osfmk
CPPFLAGS="$CPPFLAGS -idirafter $apple_xnu_source_libkern_path -isystem $apple_xnu_source_bsd_path"
CPPFLAGS="$CPPFLAGS -idirafter $apple_xnu_source_libkern_path -isystem $apple_xnu_source_bsd_path -isystem $apple_xnu_source_libsyscall_path -isystem $apple_xnu_source_libproc_path "
])

AC_ARG_WITH([apple-objc4-source],
Expand All @@ -52,15 +62,15 @@ AC_ARG_WITH([apple-libauto-source],
[AS_HELP_STRING([--with-apple-libauto-source],
[Specify path to Apple libauto source])], [
apple_libauto_source_path=${withval}
CPPFLAGS="$CPPFLAGS -I$apple_libauto_source_path"
CPPFLAGS="$CPPFLAGS -isystem $apple_libauto_source_path"
])

AC_CACHE_CHECK([for System.framework/PrivateHeaders], dispatch_cv_system_privateheaders,
[AS_IF([test -d /System/Library/Frameworks/System.framework/PrivateHeaders],
[dispatch_cv_system_privateheaders=yes], [dispatch_cv_system_privateheaders=no])]
)
AS_IF([test "x$dispatch_cv_system_privateheaders" != "xno"],
[CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/System.framework/PrivateHeaders"]
[CPPFLAGS="$CPPFLAGS -isystem /System/Library/Frameworks/System.framework/PrivateHeaders"]
)

#
Expand Down Expand Up @@ -97,6 +107,12 @@ LT_INIT([disable-static])

AC_PROG_INSTALL
AC_PATH_PROGS(MIG, mig)
AC_PATH_PROG(DTRACE, dtrace)
AS_IF([test "x$DTRACE" != "x"], [use_dtrace=true],[
use_dtrace=false
CPPFLAGS="$CPPFLAGS -DDISPATCH_USE_DTRACE=0"
])
AM_CONDITIONAL(USE_DTRACE, $use_dtrace)
AC_PATH_PROG(LEAKS, leaks)
AS_IF([test "x$LEAKS" != "x"],
[AC_DEFINE(HAVE_LEAKS, 1, [Define if Apple leaks program is present])]
Expand Down Expand Up @@ -128,21 +144,38 @@ AC_CHECK_HEADER(sys/event.h, [],
# Checks for header files.
#
AC_HEADER_STDC
AC_CHECK_HEADERS([TargetConditionals.h pthread_np.h malloc/malloc.h libkern/OSCrossEndian.h libkern/OSAtomic.h sys/guarded.h libproc_internal.h])
AC_CHECK_HEADERS([TargetConditionals.h pthread_np.h malloc/malloc.h libkern/OSCrossEndian.h libkern/OSAtomic.h sys/guarded.h fcntl.h])

# hack for pthread_machdep.h's #include <System/machine/cpu_capabilities.h>
AS_IF([test -n "$apple_xnu_source_osfmk_path"], [
# hack for pthread/private headers
AS_IF([test -n "$apple_libpthread_source_path" -a -n "$apple_xnu_source_osfmk_path"], [
saveCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I."
ln -fsh "$apple_libpthread_source_path"/private/tsd_private.h pthread_machdep.h
ln -fsh "$apple_libpthread_source_path"/private pthread
ln -fsh "$apple_xnu_source_osfmk_path" System
mkdir -p mach && ln -fsh "$apple_xnu_source_osfmk_path"/mach/coalition.h mach
])
AC_CHECK_HEADERS([pthread_machdep.h])
AS_IF([test -n "$apple_xnu_source_osfmk_path"], [
rm -f System
AC_CHECK_HEADERS([pthread_machdep.h pthread/qos.h])
AC_CHECK_HEADERS([pthread/workqueue_private.h pthread_workqueue.h],
[AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])]
)
AC_CHECK_HEADERS([libproc_internal.h], [], [], [#include <mach/mach.h>])
AC_CHECK_FUNCS([pthread_workqueue_setdispatch_np _pthread_workqueue_init])
AS_IF([test -n "$apple_libpthread_source_path" -a -n "$apple_xnu_source_osfmk_path"], [
rm -f pthread_machdep.h pthread System mach/coalition.h
CPPFLAGS="$saveCPPFLAGS"
AC_CONFIG_COMMANDS([src/pthread_machdep.h],
[ln -fsh "$apple_libpthread_source_path"/private/tsd_private.h src/pthread_machdep.h],
[apple_libpthread_source_path="$apple_libpthread_source_path"])
AC_CONFIG_COMMANDS([src/pthread],
[ln -fsh "$apple_libpthread_source_path"/private src/pthread],
[apple_libpthread_source_path="$apple_libpthread_source_path"])
AC_CONFIG_COMMANDS([src/System],
[ln -fsh "$apple_xnu_source_osfmk_path" src/System],
[apple_xnu_source_osfmk_path="$apple_xnu_source_osfmk_path"])
AC_CONFIG_COMMANDS([src/mach/coalition.h],
[ln -fsh "$apple_xnu_source_osfmk_path"/mach/coalition.h src/mach],
[apple_xnu_source_osfmk_path="$apple_xnu_source_osfmk_path"])
])
# hack for xnu/bsd/sys/event.h EVFILT_SOCK declaration
AS_IF([test -n "$apple_xnu_source_bsd_path"], [
Expand Down Expand Up @@ -194,15 +227,6 @@ AC_CHECK_HEADER([mach/mach.h], [
)
AM_CONDITIONAL(USE_MIG, $have_mach)

#
# We use the availability of pthread_workqueue.h to decide whether to compile
# in support for pthread work queues.
#
AC_CHECK_HEADER([pthread_workqueue.h],
[AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])]
)
AC_CHECK_FUNCS([pthread_workqueue_setdispatch_np])

#
# Find functions and declarations we care about.
#
Expand Down Expand Up @@ -295,5 +319,11 @@ AC_COMPILE_IFELSE(
#
# Generate Makefiles.
#
AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile os/Makefile private/Makefile src/Makefile])
AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile os/Makefile private/Makefile src/Makefile tests/Makefile])

#
# Generate testsuite links
#
AC_CONFIG_LINKS([tests/dispatch:${x:+}private tests/leaks-wrapper:tests/leaks-wrapper.sh])

AC_OUTPUT
1 change: 1 addition & 0 deletions dispatch/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dispatchdir=$(includedir)/dispatch

dispatch_HEADERS= \
base.h \
block.h \
data.h \
dispatch.h \
group.h \
Expand Down
Loading