| 1 | #                                               -*- Autoconf -*- | 
|---|
| 2 | # Process this file with autoconf to produce a configure script. | 
|---|
| 3 |  | 
|---|
| 4 | AC_PREREQ([2.68]) | 
|---|
| 5 | AC_INIT([cfa-cc],[1.0.0.0],[cforall@plg.uwaterloo.ca]) | 
|---|
| 6 | AC_CONFIG_AUX_DIR([automake]) | 
|---|
| 7 | AC_CONFIG_MACRO_DIRS([automake]) | 
|---|
| 8 | AM_SILENT_RULES([yes]) | 
|---|
| 9 |  | 
|---|
| 10 | m4_include([../automake/cfa.m4]) | 
|---|
| 11 |  | 
|---|
| 12 | AM_INIT_AUTOMAKE([subdir-objects]) | 
|---|
| 13 |  | 
|---|
| 14 | # don't use the default CFLAGS as they unconditonnaly add -O2 | 
|---|
| 15 | : ${CFLAGS=""} | 
|---|
| 16 |  | 
|---|
| 17 | # define this to override | 
|---|
| 18 | AR_FLAGS="cr" | 
|---|
| 19 |  | 
|---|
| 20 | # Allow program name tansformation | 
|---|
| 21 | # will fill program_transform_name with appropriate sed regex | 
|---|
| 22 | AC_ARG_PROGRAM | 
|---|
| 23 |  | 
|---|
| 24 | AC_ARG_VAR(ARCHITECTURE,  [The architecture  to use when building libcfa]) | 
|---|
| 25 | AC_ARG_VAR(CONFIGURATION, [The configuration to use when building libcfa, options are: deubg, nodebug, nolib (prelude-only)]) | 
|---|
| 26 | AC_ARG_VAR(DRIVER_DIR, [The path to the cforall driver directory]) | 
|---|
| 27 | AC_ARG_VAR(CFA_VERSION, [The long version of cfa]) | 
|---|
| 28 |  | 
|---|
| 29 | AC_ARG_ENABLE(distcc, | 
|---|
| 30 | [  --enable-distcc     whether or not to enable distributed compilation], | 
|---|
| 31 | enable_distcc=$enableval, enable_distcc=no) | 
|---|
| 32 |  | 
|---|
| 33 | AC_ARG_WITH(bwlimit, | 
|---|
| 34 | [  --with-bwlimit=RATE     RATE the maximum rate at which rsync will be limited when using distributed builds], | 
|---|
| 35 | DIST_BWLIMIT=$withval, DIST_BWLIMIT=0) | 
|---|
| 36 |  | 
|---|
| 37 | echo -n "checking for distributated build... " | 
|---|
| 38 | if test x$enable_distcc = xno; then | 
|---|
| 39 | CFACC=${DRIVER_DIR}cfa | 
|---|
| 40 | echo "no" | 
|---|
| 41 | else | 
|---|
| 42 | tools="$(readlink -m $ac_confdir/)/../tools/build" | 
|---|
| 43 | config=$(basename $(readlink -f .)) | 
|---|
| 44 | echo "$tools/distcc_hash $config" | 
|---|
| 45 | CFADIR_HASH=$($tools/distcc_hash $config) | 
|---|
| 46 | CFACC="distcc ~/.cfadistcc/${CFADIR_HASH}/cfa" | 
|---|
| 47 | echo "yes (hash=${CFADIR_HASH})" | 
|---|
| 48 | fi | 
|---|
| 49 | CFACPP=${DRIVER_DIR}cfa-cpp | 
|---|
| 50 | LOCAL_CFACC=${DRIVER_DIR}cfa | 
|---|
| 51 | LOCAL_CC1=${DRIVER_DIR}cc1 | 
|---|
| 52 |  | 
|---|
| 53 | AM_CONDITIONAL([ENABLE_DISTCC], [test x$enable_distcc = xyes]) | 
|---|
| 54 |  | 
|---|
| 55 | AC_SUBST(CFACC) | 
|---|
| 56 | AC_SUBST(CFACPP) | 
|---|
| 57 | AC_SUBST(LOCAL_CFACC) | 
|---|
| 58 | AC_SUBST(LOCAL_CC1) | 
|---|
| 59 | AC_SUBST(CFADIR_HASH) | 
|---|
| 60 | AC_SUBST(CFA_VERSION) | 
|---|
| 61 | AC_SUBST(DIST_BWLIMIT) | 
|---|
| 62 |  | 
|---|
| 63 | #============================================================================== | 
|---|
| 64 | #Handle specific flags | 
|---|
| 65 | case $ARCHITECTURE in | 
|---|
| 66 | "x64"        ) ARCH_FLAGS="-m64";; | 
|---|
| 67 | "x86"        ) ARCH_FLAGS="-m32";; | 
|---|
| 68 | "arm"        ) ARCH_FLAGS="";; | 
|---|
| 69 | esac | 
|---|
| 70 |  | 
|---|
| 71 | AC_SUBST(ARCH_FLAGS) | 
|---|
| 72 |  | 
|---|
| 73 | case $CONFIGURATION in | 
|---|
| 74 | "debug"   ) | 
|---|
| 75 | CONFIG_CFLAGS="-O0 -g" | 
|---|
| 76 | CONFIG_CFAFLAGS="-debug" | 
|---|
| 77 | CONFIG_BUILDLIB="yes" | 
|---|
| 78 | ;; | 
|---|
| 79 | "nodebug" ) | 
|---|
| 80 | CONFIG_CFLAGS="-O3 -s" | 
|---|
| 81 | CONFIG_CFAFLAGS="-nodebug" | 
|---|
| 82 | CONFIG_BUILDLIB="yes" | 
|---|
| 83 | ;; | 
|---|
| 84 | "nolib"   ) | 
|---|
| 85 | CONFIG_CFLAGS="-O3 -s" | 
|---|
| 86 | CONFIG_CFAFLAGS="-nolib" | 
|---|
| 87 | CONFIG_BUILDLIB="no" | 
|---|
| 88 | ;; | 
|---|
| 89 | "profile" ) | 
|---|
| 90 | CONFIG_CFLAGS="-O3 -g -fno-omit-frame-pointer" | 
|---|
| 91 | CONFIG_CFAFLAGS="-nodebug" | 
|---|
| 92 | CONFIG_BUILDLIB="yes" | 
|---|
| 93 | ;; | 
|---|
| 94 | *) | 
|---|
| 95 | AC_MSG_ERROR('Invalid value $CONFIGURATION for \$CONFIGURATION') | 
|---|
| 96 | ;; | 
|---|
| 97 | esac | 
|---|
| 98 |  | 
|---|
| 99 | CONFIG_CFAFLAGS="${CONFIG_CFAFLAGS} ${CFAFLAGS}" | 
|---|
| 100 |  | 
|---|
| 101 | AC_SUBST(CONFIG_CFLAGS) | 
|---|
| 102 | AC_SUBST(CONFIG_CFAFLAGS) | 
|---|
| 103 | AC_SUBST(CONFIG_BUILDLIB) | 
|---|
| 104 |  | 
|---|
| 105 | AM_CONDITIONAL([BUILDLIB], [test "x${CONFIG_BUILDLIB}" = "xyes"]) | 
|---|
| 106 |  | 
|---|
| 107 | #============================================================================== | 
|---|
| 108 | #Trasforming cc1 will break compilation | 
|---|
| 109 | M4CFA_PROGRAM_NAME | 
|---|
| 110 |  | 
|---|
| 111 | #============================================================================== | 
|---|
| 112 | # Installation paths | 
|---|
| 113 | M4CFA_PARSE_PREFIX | 
|---|
| 114 |  | 
|---|
| 115 | # Checks for programs. | 
|---|
| 116 | LT_INIT([disable-static]) | 
|---|
| 117 |  | 
|---|
| 118 | AC_PROG_CXX | 
|---|
| 119 | AC_PROG_CC | 
|---|
| 120 | AM_PROG_AS | 
|---|
| 121 | AC_PROG_LIBTOOL | 
|---|
| 122 | AC_PROG_INSTALL | 
|---|
| 123 | AC_PROG_MAKE_SET | 
|---|
| 124 |  | 
|---|
| 125 |  | 
|---|
| 126 |  | 
|---|
| 127 | #io_uring 5.4 and earlier uses defines | 
|---|
| 128 | #io_uring 5.5 uses enum values | 
|---|
| 129 | #io_uring 5.6 and later uses probes | 
|---|
| 130 | define(ioring_ops, [IORING_OP_NOP,IORING_OP_READV,IORING_OP_WRITEV,IORING_OP_FSYNC,IORING_OP_READ_FIXED,IORING_OP_WRITE_FIXED,IORING_OP_POLL_ADD,IORING_OP_POLL_REMOVE,IORING_OP_SYNC_FILE_RANGE,IORING_OP_SENDMSG,IORING_OP_RECVMSG,IORING_OP_TIMEOUT,IORING_OP_TIMEOUT_REMOVE,IORING_OP_ACCEPT,IORING_OP_ASYNC_CANCEL,IORING_OP_LINK_TIMEOUT,IORING_OP_CONNECT,IORING_OP_FALLOCATE,IORING_OP_OPENAT,IORING_OP_CLOSE,IORING_OP_FILES_UPDATE,IORING_OP_STATX,IORING_OP_READ,IORING_OP_WRITE,IORING_OP_FADVISE,IORING_OP_MADVISE,IORING_OP_SEND,IORING_OP_RECV,IORING_OP_OPENAT2,IORING_OP_EPOLL_CTL,IORING_OP_SPLICE,IORING_OP_PROVIDE_BUFFERS,IORING_OP_REMOVE_BUFFER]) | 
|---|
| 131 | define(ioring_flags, [IOSQE_FIXED_FILE,IOSQE_IO_DRAIN,IOSQE_ASYNC,IOSQE_IO_LINK,IOSQE_IO_HARDLINK,SPLICE_F_FD_IN_FIXED]) | 
|---|
| 132 |  | 
|---|
| 133 | define(ioring_from_decls, [ | 
|---|
| 134 | m4_foreach([op], [ioring_ops], [ | 
|---|
| 135 | AC_CHECK_DECL(op, [AC_DEFINE([CFA_HAVE_]op)], [], [[#include <linux/io_uring.h>]]) | 
|---|
| 136 | ]) | 
|---|
| 137 | ]) | 
|---|
| 138 |  | 
|---|
| 139 | AC_CHECK_HEADERS([linux/io_uring.h], [ | 
|---|
| 140 | AC_DEFINE(CFA_HAVE_LINUX_IO_URING_H) | 
|---|
| 141 | AC_CHECK_HEADER([liburing.h], [ | 
|---|
| 142 | AC_CHECK_LIB([uring], [io_uring_get_probe], [ | 
|---|
| 143 | m4_foreach([op], [ioring_ops], [ | 
|---|
| 144 | AC_CHECK_DECL(op, [ | 
|---|
| 145 | AC_RUN_IFELSE([ | 
|---|
| 146 | AC_LANG_PROGRAM( | 
|---|
| 147 | [[#include <liburing.h>]], | 
|---|
| 148 | [[int main() {]] | 
|---|
| 149 | [[      struct io_uring_probe *probe = io_uring_get_probe();]] | 
|---|
| 150 | [[      if(io_uring_opcode_supported(probe, ]]op[[))]] | 
|---|
| 151 | [[              return 0;]] | 
|---|
| 152 | [[      else]] | 
|---|
| 153 | [[              return 1;]] | 
|---|
| 154 | [[}]] | 
|---|
| 155 | ) | 
|---|
| 156 | ],[ | 
|---|
| 157 | AC_DEFINE([CFA_HAVE_]op) | 
|---|
| 158 | ],[ | 
|---|
| 159 | AC_MSG_FAILURE([Check support for] op [ with liburing failed]) | 
|---|
| 160 | ]) | 
|---|
| 161 | ], [], [[#include <linux/io_uring.h>]]) | 
|---|
| 162 | ]) | 
|---|
| 163 | ], [ | 
|---|
| 164 | ioring_from_decls | 
|---|
| 165 | ]) | 
|---|
| 166 | ], [ | 
|---|
| 167 | ioring_from_decls | 
|---|
| 168 | ]) | 
|---|
| 169 |  | 
|---|
| 170 | # check support for various io_uring flags | 
|---|
| 171 | m4_foreach([op], [ioring_flags], [ | 
|---|
| 172 | AC_CHECK_DECL(op, [AC_DEFINE([CFA_HAVE_]op)], [], [[#include <linux/io_uring.h>]]) | 
|---|
| 173 | ]) | 
|---|
| 174 | ]) | 
|---|
| 175 | AC_CHECK_FUNCS([preadv2 pwritev2]) | 
|---|
| 176 |  | 
|---|
| 177 | AC_CONFIG_FILES([ | 
|---|
| 178 | Makefile | 
|---|
| 179 | src/Makefile | 
|---|
| 180 | prelude/Makefile | 
|---|
| 181 | ]) | 
|---|
| 182 |  | 
|---|
| 183 | AC_CONFIG_HEADERS(prelude/defines.hfa) | 
|---|
| 184 |  | 
|---|
| 185 | AC_OUTPUT() | 
|---|
| 186 |  | 
|---|
| 187 | # Final text | 
|---|
| 188 | AC_MSG_RESULT(Cforall library configuraton completed. Type "make -j 8 install".) | 
|---|