From 5d370e4533ade668ce807764cf38d73f38b5f749 Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Fri, 28 Jan 2011 19:03:39 -0500 Subject: [PATCH] Linux: allow compile flags to be passed to AC_CHECK_LINUX_BUILD Some linux autoconf tests require particular compile flags such as -Werror. Add a parameter to the AC_CHECK_LINUX_BUILD macro that lets the caller pass in any needed special flags. Adapt a few existing tests that were still using AC_TRY_KBUILD directly. Reviewed-on: http://gerrit.openafs.org/3769 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit ca38c9546e323b59189670b80740510fb9ec5269) Change-Id: I421c95f4f4f0b001ac1eab400dfbabfd2008e7a5 Reviewed-on: http://gerrit.openafs.org/3916 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/cf/linux-test1.m4 | 7 +- src/cf/linux-test4.m4 | 188 +++++++++++++++++++++++------------------- 2 files changed, 108 insertions(+), 87 deletions(-) diff --git a/src/cf/linux-test1.m4 b/src/cf/linux-test1.m4 index fb5e061b6..c1c1c0c7e 100644 --- a/src/cf/linux-test1.m4 +++ b/src/cf/linux-test1.m4 @@ -85,13 +85,16 @@ AC_DEFUN([LINUX_KBUILD_USES_EXTRA_CFLAGS], [ CPPFLAGS="$save_CPPFLAGS" AC_MSG_RESULT($ac_linux_kbuild_requires_extra_cflags)]) -dnl AC_CHECK_LINUX_BUILD([msg], [var], [includes], [code], [define]) +dnl AC_CHECK_LINUX_BUILD([msg], [var], [includes], [code], [define], [CFLAGS]) AC_DEFUN([AC_CHECK_LINUX_BUILD], [AS_VAR_PUSHDEF([ac_linux_build], [$2])dnl AC_CACHE_CHECK([$1], [ac_linux_build], - [AC_TRY_KBUILD([$3], [$4], + [save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $7" + AC_TRY_KBUILD([$3], [$4], AS_VAR_SET([ac_linux_build], [yes]), AS_VAR_SET([ac_linux_build], [no])) + CPPFLAGS="$save_CPPFLAGS" ]) AS_IF([test AS_VAR_GET([ac_linux_build]) = yes], [AC_DEFINE([$5],1,[$6])]) diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 72d78aeb5..4335e0cfb 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -7,7 +7,8 @@ extern rwlock_t tasklist_lock __attribute__((weak)); read_lock(&tasklist_lock); ], [EXPORTED_TASKLIST_LOCK], - [define if tasklist_lock exported]) + [define if tasklist_lock exported], + []) ]) AC_DEFUN([LINUX_COMPLETION_H_EXISTS], [ @@ -20,7 +21,8 @@ AC_DEFUN([LINUX_COMPLETION_H_EXISTS], [ lose #endif], [HAVE_LINUX_COMPLETION_H] - [Define if your kernel has a usable linux/completion.h]) + [Define if your kernel has a usable linux/completion.h], + []) ]) @@ -30,7 +32,8 @@ AC_DEFUN([LINUX_EXPORTS_INIT_MM], [ [extern struct mm_struct init_mm;], [void *address = &init_mm; printk("%p\n", address);], [EXPORTED_INIT_MM], - [define if your kernel exports init_mm]) + [define if your kernel exports init_mm], + []) ]) @@ -42,7 +45,8 @@ AC_DEFUN([LINUX_EXPORTS_KALLSYMS_ADDRESS], [ #error kallsyms_address_to_symbol not exported #endif], [EXPORTED_KALLSYMS_ADDRESS], - [define if your linux kernel exports kallsyms address]) + [define if your linux kernel exports kallsyms address], + []) ]) @@ -54,7 +58,8 @@ AC_DEFUN([LINUX_EXPORTS_KALLSYMS_SYMBOL], [ #error kallsyms_symbol_to_address not exported #endif], [EXPORTED_KALLSYMS_SYMBOL], - [define if your linux kernel exports kallsyms]) + [define if your linux kernel exports kallsyms], + []) ]) @@ -66,7 +71,8 @@ AC_DEFUN([LINUX_EXPORTS_SYS_CALL_TABLE], [ #error sys_call_table not exported #endif], [EXPORTED_SYS_CALL_TABLE], - [define if your linux kernel exports sys_call_table]) + [define if your linux kernel exports sys_call_table], + []) ]) @@ -78,7 +84,8 @@ AC_DEFUN([LINUX_EXPORTS_IA32_SYS_CALL_TABLE], [ #error ia32_sys_call_table not exported #endif], [EXPORTED_IA32_SYS_CALL_TABLE], - [define if your linux kernel exports ia32_sys_call_table]) + [define if your linux kernel exports ia32_sys_call_table], + []) ]) @@ -88,7 +95,8 @@ AC_DEFUN([LINUX_EXPORTS_SYS_CHDIR], [ [extern asmlinkage long sys_chdir(void) __attribute__((weak));], [void *address = &sys_chdir; printk("%p\n", address);], [EXPORTED_SYS_CHDIR], - [define if your linux kernel exports sys_chdir]) + [define if your linux kernel exports sys_chdir], + []) ]) @@ -98,7 +106,8 @@ AC_DEFUN([LINUX_EXPORTS_SYS_OPEN], [ [extern asmlinkage long sys_open(void) __attribute__((weak));], [void *address = &sys_open; printk("%p\n", address);], [EXPORTED_SYS_OPEN], - [define if your linux kernel exports sys_open]) + [define if your linux kernel exports sys_open], + []) ]) @@ -108,7 +117,8 @@ AC_DEFUN([LINUX_RECALC_SIGPENDING_ARG_TYPE], [ [#include ], [recalc_sigpending();], [RECALC_SIGPENDING_TAKES_VOID], - [define if your recalc_sigpending takes void]) + [define if your recalc_sigpending takes void], + []) ]) @@ -118,7 +128,8 @@ AC_DEFUN([LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM], [ [#include ], [struct task_struct _tsk; printk("%d\n", _tsk.signal->rlim);], [STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM], - [define if your struct task_struct has signal->rlim]) + [define if your struct task_struct has signal->rlim], + []) ]) @@ -128,7 +139,8 @@ AC_DEFUN([LINUX_KERNEL_POSIX_LOCK_FILE_WAIT_ARG], [ [#include ], [posix_lock_file(0,0,0);], [POSIX_LOCK_FILE_WAIT_ARG], - [define if your kernel uses 3 arguments for posix_lock_file]) + [define if your kernel uses 3 arguments for posix_lock_file], + []) ]) AC_DEFUN([LINUX_KERNEL_SOCK_CREATE], [ @@ -137,7 +149,8 @@ AC_DEFUN([LINUX_KERNEL_SOCK_CREATE], [ [#include ], [sock_create(0,0,0,0,0);], [LINUX_KERNEL_SOCK_CREATE_V], - [define if your linux kernel uses 5 arguments for sock_create]) + [define if your linux kernel uses 5 arguments for sock_create], + []) ]) @@ -150,7 +163,8 @@ AC_DEFUN([LINUX_INODE_SETATTR_RETURN_TYPE], [ int i; i = inode_setattr(&_inode, &_iattr);], [INODE_SETATTR_NOT_VOID], - [define if your setattr return return non-void]) + [define if your setattr return return non-void], + []) ]) @@ -166,7 +180,8 @@ struct page _page; struct writeback_control _writeback_control; (void)_aops.writepage(&_page, &_writeback_control);], [AOP_WRITEPAGE_TAKES_WRITEBACK_CONTROL], - [define if aops.writepage takes a struct writeback_control]) + [define if aops.writepage takes a struct writeback_control], + []) ]) @@ -179,7 +194,8 @@ AC_DEFUN([LINUX_REFRIGERATOR], [ #endif], [refrigerator(PF_FREEZE);], [LINUX_REFRIGERATOR_TAKES_PF_FREEZE], - [define if your refrigerator takes PF_FREEZE]) + [define if your refrigerator takes PF_FREEZE], + []) ]) @@ -194,7 +210,8 @@ struct nameidata _nameidata; (void)_inode.i_op->create(&_inode, &_dentry, 0, &_nameidata);], [IOP_CREATE_TAKES_NAMEIDATA], - [define if your iops.create takes a nameidata argument]) + [define if your iops.create takes a nameidata argument], + []) ]) @@ -208,7 +225,8 @@ struct dentry _dentry; struct nameidata _nameidata; (void)_inode.i_op->lookup(&_inode, &_dentry, &_nameidata);], [IOP_LOOKUP_TAKES_NAMEIDATA], - [define if your iops.lookup takes a nameidata argument]) + [define if your iops.lookup takes a nameidata argument], + []) ]) @@ -222,7 +240,8 @@ struct dentry _dentry; struct nameidata _nameidata; (void)_inode.i_op->permission(&_inode, 0, &_nameidata);], [IOP_PERMISSION_TAKES_NAMEIDATA], - [define if your iops.permission takes a nameidata argument]) + [define if your iops.permission takes a nameidata argument], + []) ]) @@ -237,7 +256,8 @@ struct nameidata _nameidata; void *cookie; (void)_inode.i_op->put_link(&_dentry, &_nameidata, cookie);], [IOP_PUT_LINK_TAKES_COOKIE], - [define if your iops.put_link takes a cookie]) + [define if your iops.put_link takes a cookie], + []) ]) @@ -250,7 +270,8 @@ AC_DEFUN([LINUX_DOP_D_REVALIDATE_TAKES_NAMEIDATA], [ struct nameidata _nameidata; (void)_dentry.d_op->d_revalidate(&_dentry, &_nameidata);], [DOP_REVALIDATE_TAKES_NAMEIDATA], - [define if your dops.d_revalidate takes a nameidata argument]) + [define if your dops.d_revalidate takes a nameidata argument], + []) ]) @@ -260,7 +281,8 @@ AC_DEFUN([LINUX_GET_SB_HAS_STRUCT_VFSMOUNT], [ [#include ], [get_sb_nodev(0,0,0,0,0);], [GET_SB_HAS_STRUCT_VFSMOUNT], - [define if your get_sb_nodev needs a struct vfsmount argument]) + [define if your get_sb_nodev needs a struct vfsmount argument], + []) ]) @@ -271,7 +293,8 @@ AC_DEFUN([LINUX_STATFS_TAKES_DENTRY], [ #include ], [extern int simple_statfs(struct dentry *, struct kstatfs *);], [STATFS_TAKES_DENTRY], - [define if your statfs takes a dentry argument]) + [define if your statfs takes a dentry argument], + []) ]) @@ -293,48 +316,34 @@ request_key(NULL, NULL, NULL); #error rebuild your kernel with CONFIG_KEYS #endif], [LINUX_KEYRING_SUPPORT], - [define if your kernel has keyring support]) + [define if your kernel has keyring support], + []) ]) AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK], [ - AC_CACHE_CHECK([if key_alloc() takes a struct task *], - [ac_cv_key_alloc_needs_struct_task], -[ - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -Werror -Wno-pointer-arith" - AC_TRY_KBUILD( -[#include -#include -], -[struct task_struct *t=NULL; -(void) key_alloc(NULL, NULL, 0, 0, t, 0, 0);], - ac_cv_key_alloc_needs_struct_task=yes, - ac_cv_key_alloc_needs_struct_task=no) - CPPFLAGS="$save_CPPFLAGS"]) - AS_IF([test "x$ac_cv_key_alloc_needs_struct_task" = "xyes"], - [AC_DEFINE([KEY_ALLOC_NEEDS_STRUCT_TASK], 1, - [define if key_alloc takes a struct task *])]) + AC_CHECK_LINUX_BUILD([if key_alloc() takes a struct task *], + [ac_cv_key_alloc_needs_struct_task], + [#include + #include ], + [struct task_struct *t=NULL; + (void) key_alloc(NULL, NULL, 0, 0, t, 0, 0);], + [KEY_ALLOC_NEEDS_STRUCT_TASK], + [define if key_alloc takes a struct task *], + [-Werror -Wno-pointer-arith]) ]) AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_CRED], [ - AC_CACHE_CHECK([if key_alloc() takes credentials], - [ac_cv_key_alloc_needs_cred], -[ - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -Werror -Wno-pointer-arith" - AC_TRY_KBUILD( -[#include -#include ], -[struct cred *c = NULL; -(void) key_alloc(NULL, NULL, 0, 0, c, 0, 0);], - ac_cv_key_alloc_needs_cred=yes, - ac_cv_key_alloc_needs_cred=no) - CPPFLAGS="$save_CPPFLAGS"]) - AS_IF([test "x$ac_cv_key_alloc_needs_cred" = "xyes"], - [AC_DEFINE([KEY_ALLOC_NEEDS_CRED], 1, - [define if key_alloc takes credentials])]) + AC_CHECK_LINUX_BUILD([if key_alloc() takes credentials], + [ac_cv_key_alloc_needs_cred], + [#include + #include ], + [struct cred *c = NULL; + (void) key_alloc(NULL, NULL, 0, 0, c, 0, 0);], + [KEY_ALLOC_NEEDS_CRED], + [define if key_alloc takes credentials], + [-Werror -Wno-pointer-arith]) ]) @@ -349,7 +358,8 @@ struct work_struct *w; int *i; INIT_WORK(w,f,i);], [INIT_WORK_HAS_DATA], - [define if INIT_WORK takes a data (3rd) argument]) + [define if INIT_WORK takes a data (3rd) argument], + []) ]) @@ -359,7 +369,8 @@ AC_DEFUN([LINUX_REGISTER_SYSCTL_TABLE_NOFLAG], [ [#include ], [ctl_table *t; register_sysctl_table (t);], [REGISTER_SYSCTL_TABLE_NOFLAG], - [define if register_sysctl_table has no insert_at head flag]) + [define if register_sysctl_table has no insert_at head flag], + []) ]) @@ -372,7 +383,8 @@ struct file _file; fl_owner_t id; (void)_inode.i_fop->flush(&_file, &id);], [FOP_FLUSH_TAKES_FL_OWNER_T], - [define if your fops.flush takes an fl_owner_t argument]) + [define if your fops.flush takes an fl_owner_t argument], + []) ]) @@ -385,7 +397,8 @@ struct file _file; struct dentry _d; (void)_inode.i_fop->fsync(&_file, &_d, 0);], [FOP_FSYNC_TAKES_DENTRY], - [define if your fops.fsync takes an dentry argument]) + [define if your fops.fsync takes an dentry argument], + []) ]) @@ -395,7 +408,8 @@ AC_DEFUN([LINUX_HAVE_KMEM_CACHE_T], [ [#include ], [kmem_cache_t *k;], [HAVE_KMEM_CACHE_T], - [define if kmem_cache_t exists]) + [define if kmem_cache_t exists], + []) ]) @@ -405,24 +419,19 @@ AC_DEFUN([LINUX_KMEM_CACHE_CREATE_TAKES_DTOR], [ [#include ], [kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);], [KMEM_CACHE_TAKES_DTOR], - [define if kmem_cache_create takes a destructor argument]) + [define if kmem_cache_create takes a destructor argument], + []) ]) AC_DEFUN([LINUX_KMEM_CACHE_CREATE_CTOR_TAKES_VOID],[ - AC_CACHE_CHECK([whether kmem_cache_create constructor takes a void pointer], - [ac_cv_linux_kmem_cache_create_ctor_takes_void], [ - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -Werror" - AC_TRY_KBUILD([#include ], - [void _ctor(void *v) { }; kmem_cache_create(NULL, 0, 0, 0, _ctor);], - ac_cv_linux_kmem_cache_create_ctor_takes_void=yes, - ac_cv_linux_kmem_cache_create_ctor_takes_void=no) - CPPFLAGS="$save_CPPFLAGS" - ]) - AS_IF([test "x$ac_cv_linux_kmem_cache_create_ctor_takes_void" = "xyes"], - [AC_DEFINE([KMEM_CACHE_CTOR_TAKES_VOID], 1, - [define if kmem_cache_create constructor takes a single void ptr])]) + AC_CHECK_LINUX_BUILD([whether kmem_cache_create constructor takes a void pointer], + [ac_cv_linux_kmem_cache_create_ctor_takes_void], + [#include ], + [void _ctor(void *v) { }; kmem_cache_create(NULL, 0, 0, 0, _ctor);], + [KMEM_CACHE_CTOR_TAKES_VOID], + [define if kmem_cache_create constructor takes a single void ptr], + [-Werror]) ]) @@ -437,7 +446,8 @@ AC_DEFUN([LINUX_FS_STRUCT_FOP_HAS_SPLICE], [ _fop.splice_write(NULL, NULL, NULL, 0, 0); _fop.splice_read(NULL, NULL, NULL, 0, 0);], [STRUCT_FILE_OPERATIONS_HAS_SPLICE], - [define if struct file_operations has splice functions]) + [define if struct file_operations has splice functions], + []) ]) @@ -451,7 +461,8 @@ AC_DEFUN([LINUX_KMEM_CACHE_INIT], [ void (*)(struct kmem_cache *, void *)); return;], [KMEM_CACHE_INIT], - [define for new kmem_cache init function parameters]) + [define for new kmem_cache init function parameters], + []) ]) @@ -461,7 +472,8 @@ AC_DEFUN([LINUX_EXPORTS_PROC_ROOT_FS], [ [#include ], [struct proc_dir_entry *p = proc_root_fs;], [EXPORTED_PROC_ROOT_FS], - [define if proc_root_fs is exported]) + [define if proc_root_fs is exported], + []) ]) @@ -471,7 +483,8 @@ AC_DEFUN([LINUX_D_PATH_TAKES_STRUCT_PATH], [ [#include ], [struct path *p; d_path(p, NULL, 0);], [D_PATH_TAKES_STRUCT_PATH], - [define if d_path() takes a struct path argument]) + [define if d_path() takes a struct path argument], + []) ]) @@ -482,7 +495,8 @@ AC_DEFUN([LINUX_NEW_EXPORT_OPS], [ [struct export_operations _eops; _eops.fh_to_parent(NULL, NULL, 0, 0);], [NEW_EXPORT_OPS], - [define if kernel uses new export ops]) + [define if kernel uses new export ops], + []) ]) @@ -494,7 +508,8 @@ AC_DEFUN([LINUX_POSIX_TEST_LOCK_RETURNS_CONFLICT], [ struct file * file; lock = posix_test_lock(file, lock);], [POSIX_TEST_LOCK_RETURNS_CONFLICT], - [define if posix_test_lock returns the conflicting lock]) + [define if posix_test_lock returns the conflicting lock], + []) ]) @@ -506,7 +521,8 @@ AC_DEFUN([LINUX_POSIX_TEST_LOCK_CONFLICT_ARG], [ struct file *file; posix_test_lock(file, lock, lock);], [POSIX_TEST_LOCK_CONFLICT_ARG], - [define if posix_test_lock takes a conflict argument]) + [define if posix_test_lock takes a conflict argument], + []) ]) @@ -521,7 +537,8 @@ AC_DEFUN([LINUX_EXPORTS_KEY_TYPE_KEYRING], [ ], [printk("%s", key_type_keyring.name);], [EXPORTED_KEY_TYPE_KEYRING], - [define if key_type_keyring is exported]) + [define if key_type_keyring is exported], + []) ]) @@ -548,6 +565,7 @@ AC_DEFUN([LINUX_HAVE_TRY_TO_FREEZE], [ try_to_freeze(); #endif], [HAVE_TRY_TO_FREEZE], - [define if your kernel has the try_to_freeze function]) + [define if your kernel has the try_to_freeze function], + []) ]) -- 2.39.5