From 29e6fc2f22c465d57e96352fed398e67a89b90f6 Mon Sep 17 00:00:00 2001
From: Tim Wickberg <tim@schedmd.com>
Date: Tue, 19 Apr 2016 17:28:28 -0400
Subject: [PATCH] Header include cleanup part one.

No functional change in theory. Cleanup headers to reduce the mostly-useless
for some time now.

1) Remove common/{getopt.[ch],getopt1.c} files and remove from build. Use
   C99-required functions from <unistd.h> and <getopt.h>.

2) <inttypes.h> is required by C99 and has been required for some time. Remove
   #ifdef blocks and replace some older <stdint.h> includes.

3) <pthread.h> isn't optional at this point. PTHREAD_MUTEX_INITIALIZER is
   required throughout.

4) Use <limits.h> instead of <values.h> or <float.h>

5) <string.h> is required by C99. Remove long-deprecated <strings.h> includes.
---
 src/api/slurm_pmi.h                           |   13 +-
 src/common/Makefile.am                        |    1 -
 src/common/Makefile.in                        |   33 +-
 src/common/bitstring.h                        |   13 +-
 src/common/callerid.c                         |   25 +-
 src/common/env.c                              |   10 +-
 src/common/getopt.c                           | 1061 -----------------
 src/common/getopt.h                           |  180 ---
 src/common/getopt1.c                          |  188 ---
 src/common/gres.c                             |   35 +-
 src/common/hostlist.c                         |   29 +-
 src/common/io_hdr.h                           |    8 +-
 src/common/job_resources.h                    |    9 +-
 src/common/layouts_mgr.c                      |    8 +-
 src/common/macros.h                           |    6 +-
 src/common/node_conf.c                        |   12 +-
 src/common/node_conf.h                        |    8 +-
 src/common/node_features.c                    |   28 +-
 src/common/optz.h                             |    6 +-
 src/common/pack.h                             |   13 +-
 src/common/parse_spec.h                       |   13 +-
 src/common/parse_time.c                       |    1 -
 src/common/parse_time.h                       |   11 +-
 src/common/parse_value.c                      |    1 -
 src/common/plugin.h                           |   17 +-
 src/common/plugstack.h                        |    6 +-
 src/common/print_fields.h                     |   14 +-
 src/common/proc_args.c                        |   14 +-
 src/common/slurm_acct_gather.h                |   13 +-
 src/common/slurm_acct_gather_energy.h         |   12 +-
 src/common/slurm_acct_gather_filesystem.h     |   12 +-
 src/common/slurm_acct_gather_infiniband.h     |   12 +-
 src/common/slurm_acct_gather_profile.h        |   12 +-
 src/common/slurm_auth.h                       |   13 +-
 src/common/slurm_ext_sensors.h                |   12 +-
 src/common/slurm_jobacct_gather.h             |   13 +-
 src/common/slurm_jobcomp.h                    |    8 +-
 src/common/slurm_mcs.h                        |    8 +-
 src/common/slurm_priority.h                   |    8 +-
 src/common/slurm_protocol_api.h               |   12 +-
 src/common/slurm_protocol_defs.h              |   12 +-
 src/common/slurm_protocol_interface.h         |   33 +-
 src/common/slurm_protocol_pack.h              |   13 +-
 src/common/slurm_protocol_socket_common.h     |   12 +-
 src/common/slurm_protocol_util.h              |   12 +-
 src/common/slurm_resource_info.h              |    9 +-
 src/common/slurm_step_layout.h                |    9 +-
 src/common/slurmdbd_defs.c                    |   16 +-
 src/common/slurmdbd_defs.h                    |   13 +-
 src/common/xcgroup_read_config.h              |   13 +-
 src/database/mysql_common.h                   |   15 +-
 .../accounting_storage/common/common_as.c     |    5 +-
 .../filetxt/accounting_storage_filetxt.c      |    2 +-
 .../mysql/accounting_storage_mysql.h          |    2 +-
 .../slurmdbd/accounting_storage_slurmdbd.c    |   10 +-
 .../ofed/acct_gather_infiniband_ofed.c        |    9 +-
 .../acct_gather_profile/hdf5/hdf5_api.h       |   12 +-
 .../hdf5/sh5util/libsh5util_old/hdf5_api.h    |   12 +-
 .../hdf5/sh5util/libsh5util_old/sh5util.c     |    9 +-
 .../hdf5/sh5util/sh5util.c                    |    9 +-
 src/plugins/auth/munge/auth_munge.c           |   29 +-
 src/plugins/auth/none/auth_none.c             |   27 +-
 src/plugins/checkpoint/aix/checkpoint_aix.c   |   12 +-
 src/plugins/checkpoint/blcr/checkpoint_blcr.c |   14 +-
 src/plugins/checkpoint/none/checkpoint_none.c |    8 +-
 src/plugins/checkpoint/ompi/checkpoint_ompi.c |    8 +-
 src/plugins/checkpoint/poe/checkpoint_poe.c   |   12 +-
 src/plugins/core_spec/cray/core_spec_cray.c   |   27 +-
 src/plugins/core_spec/none/core_spec_none.c   |   27 +-
 src/plugins/crypto/munge/crypto_munge.c       |   13 +-
 src/plugins/crypto/openssl/crypto_openssl.c   |   12 +-
 src/plugins/gres/gpu/gres_gpu.c               |   27 +-
 src/plugins/gres/mic/gres_mic.c               |   29 +-
 src/plugins/gres/nic/gres_nic.c               |   27 +-
 .../job_submit_all_partitions.c               |   27 +-
 src/plugins/job_submit/cray/job_submit_cray.c |   27 +-
 .../job_submit/defaults/job_submit_defaults.c |   27 +-
 .../job_submit/logging/job_submit_logging.c   |   27 +-
 src/plugins/job_submit/lua/job_submit_lua.c   |   10 +-
 .../partition/job_submit_partition.c          |   27 +-
 src/plugins/job_submit/pbs/job_submit_pbs.c   |   18 +-
 .../job_submit/throttle/job_submit_throttle.c |   27 +-
 .../elasticsearch/jobcomp_elasticsearch.c     |    9 +-
 src/plugins/jobcomp/filetxt/jobcomp_filetxt.c |   11 +-
 src/plugins/jobcomp/none/jobcomp_none.c       |    8 +-
 src/plugins/jobcomp/script/jobcomp_script.c   |   18 +-
 src/plugins/mpi/mpichgm/mpichgm.c             |    2 +-
 src/plugins/mpi/mpichmx/mpichmx.c             |    2 +-
 src/plugins/mpi/mvapich/mvapich.c             |    2 +-
 src/plugins/mpi/pmi2/client.h                 |   13 +-
 src/plugins/mpi/pmi2/info.h                   |   13 +-
 src/plugins/mpi/pmi2/setup.h                  |   18 +-
 src/plugins/mpi/pmi2/spawn.h                  |   13 +-
 src/plugins/priority/basic/priority_basic.c   |   10 +-
 .../multifactor/priority_multifactor.c        |   23 +-
 src/plugins/proctrack/aix/proctrack_aix.c     |   12 +-
 .../proctrack/cgroup/proctrack_cgroup.c       |   10 +-
 src/plugins/proctrack/cray/proctrack_cray.c   |   14 +-
 src/plugins/proctrack/linuxproc/kill_tree.c   |   13 +-
 .../proctrack/linuxproc/proctrack_linuxproc.c |   12 +-
 src/plugins/proctrack/lua/proctrack_lua.c     |   17 +-
 src/plugins/proctrack/pgid/proctrack_pgid.c   |   10 +-
 .../proctrack/sgi_job/proctrack_sgi_job.c     |   15 +-
 src/plugins/sched/wiki/hostlist.c             |   14 +-
 src/plugins/sched/wiki/job_modify.c           |    2 +-
 src/plugins/sched/wiki/msg.h                  |   16 +-
 src/plugins/sched/wiki2/hostlist.c            |   12 +-
 src/plugins/sched/wiki2/initialize.c          |    2 +-
 src/plugins/sched/wiki2/job_modify.c          |    2 +-
 src/plugins/sched/wiki2/job_notify.c          |    2 +-
 src/plugins/sched/wiki2/job_signal.c          |    2 +-
 src/plugins/sched/wiki2/msg.h                 |   16 +-
 .../select/alps/libemulate/alps_emulate.c     |    9 +-
 src/plugins/select/alps/select_alps.c         |    7 +-
 src/plugins/select/bluegene/bg_job_run.c      |   11 +-
 src/plugins/select/bluegene/sfree/sfree.h     |    8 +-
 src/plugins/select/bluegene/slurm_epilog.c    |    5 +-
 src/plugins/select/bluegene/slurm_prolog.c    |    1 -
 src/plugins/select/cons_res/job_test.c        |    8 +-
 src/plugins/select/cons_res/select_cons_res.c |    9 +-
 src/plugins/select/cray/ccm.h                 |   15 +-
 src/plugins/select/linear/select_linear.c     |    7 +-
 src/plugins/select/serial/job_test.c          |    8 +-
 src/plugins/select/serial/select_serial.c     |    8 +-
 src/plugins/slurmctld/nonstop/do_work.c       |   10 +-
 src/plugins/slurmctld/nonstop/read_config.h   |   16 +-
 src/sacct/sacct.h                             |    1 -
 src/sacctmgr/sacctmgr.h                       |   23 +-
 src/salloc/opt.c                              |   21 +-
 src/sattach/opt.c                             |   18 +-
 src/sbatch/opt.c                              |   18 +-
 src/sbcast/opts.c                             |    7 +-
 src/scancel/opt.c                             |   11 +-
 src/scancel/scancel.c                         |   15 +-
 src/scontrol/scontrol.h                       |   23 +-
 src/sdiag/opts.c                              |    7 +-
 src/sinfo/opts.c                              |    7 +-
 src/sinfo/sinfo.h                             |    9 +-
 src/slurmctld/burst_buffer.c                  |   28 +-
 src/slurmctld/job_mgr.c                       |    1 -
 src/slurmctld/job_submit.c                    |   28 +-
 src/slurmctld/slurmctld.h                     |   16 +-
 src/slurmctld/slurmctld_plugstack.c           |   28 +-
 src/slurmctld/step_mgr.c                      |    5 +-
 src/slurmd/common/reverse_tree_math.h         |   13 +-
 src/slurmd/common/xcgroup.c                   |   19 +-
 src/slurmd/common/xcpuinfo.c                  |   16 +-
 src/slurmd/slurmd/get_mach_stat.h             |   13 +-
 src/slurmd/slurmd/slurmd.h                    |   12 +-
 src/slurmd/slurmd/slurmd_plugstack.c          |   28 +-
 src/slurmdbd/read_config.h                    |   13 +-
 src/smap/smap.h                               |   21 +-
 src/sprio/opts.c                              |    7 +-
 src/sprio/sprio.c                             |    8 -
 src/sprio/sprio.h                             |   10 +-
 src/squeue/opts.c                             |    7 +-
 src/squeue/squeue.h                           |   10 +-
 src/sreport/sreport.h                         |   23 +-
 src/srun/libsrun/opt.c                        |   16 +-
 src/sshare/sshare.h                           |   23 +-
 src/sstat/sstat.h                             |    2 +-
 src/strigger/opts.c                           |    7 +-
 src/strigger/strigger.c                       |    9 +-
 src/sview/sview.h                             |   16 +-
 164 files changed, 463 insertions(+), 3098 deletions(-)
 delete mode 100644 src/common/getopt.c
 delete mode 100644 src/common/getopt.h
 delete mode 100644 src/common/getopt1.c

diff --git a/src/api/slurm_pmi.h b/src/api/slurm_pmi.h
index 8601fb7dba6..975ce969c4f 100644
--- a/src/api/slurm_pmi.h
+++ b/src/api/slurm_pmi.h
@@ -41,16 +41,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 #include "src/common/pack.h"
 #include "src/common/slurm_protocol_defs.h"
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index f34c6503b59..0de34f1219c 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -107,7 +107,6 @@ libcommon_la_SOURCES = 			\
 	arg_desc.c arg_desc.h		\
 	macros.h			\
 	malloc.c malloc.h		\
-	getopt.h getopt.c getopt1.c     \
 	$(build_unsetenv_src)		\
 	slurm_selecttype_info.c 	\
 	slurm_selecttype_info.h		\
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
index 13bcc874467..555dff291b1 100644
--- a/src/common/Makefile.in
+++ b/src/common/Makefile.in
@@ -193,20 +193,20 @@ am__libcommon_la_SOURCES_DIST = assoc_mgr.c assoc_mgr.h \
 	slurm_acct_gather_filesystem.h slurm_jobcomp.c slurm_jobcomp.h \
 	slurm_route.c slurm_route.h slurm_time.c slurm_time.h \
 	slurm_topology.c slurm_topology.h switch.c switch.h arg_desc.c \
-	arg_desc.h macros.h malloc.c malloc.h getopt.h getopt.c \
-	getopt1.c unsetenv.c unsetenv.h slurm_selecttype_info.c \
-	slurm_selecttype_info.h slurm_resource_info.c \
-	slurm_resource_info.h hostlist.c hostlist.h \
-	slurm_step_layout.c slurm_step_layout.h checkpoint.c \
-	checkpoint.h job_resources.c job_resources.h parse_time.c \
-	parse_time.h job_options.c job_options.h global_defaults.c \
-	timers.c timers.h slurm_xlator.h stepd_api.c stepd_api.h \
-	write_labelled_message.c write_labelled_message.h proc_args.c \
-	proc_args.h slurm_strcasestr.c slurm_strcasestr.h node_conf.h \
-	node_conf.c gres.h gres.c entity.h entity.c layout.h layout.c \
-	layouts_mgr.h layouts_mgr.c mapping.c mapping.h \
-	xcgroup_read_config.c xcgroup_read_config.h xlua.c xlua.h \
-	callerid.c callerid.h siphash24.c siphash_slurm.c siphash.h
+	arg_desc.h macros.h malloc.c malloc.h unsetenv.c unsetenv.h \
+	slurm_selecttype_info.c slurm_selecttype_info.h \
+	slurm_resource_info.c slurm_resource_info.h hostlist.c \
+	hostlist.h slurm_step_layout.c slurm_step_layout.h \
+	checkpoint.c checkpoint.h job_resources.c job_resources.h \
+	parse_time.c parse_time.h job_options.c job_options.h \
+	global_defaults.c timers.c timers.h slurm_xlator.h stepd_api.c \
+	stepd_api.h write_labelled_message.c write_labelled_message.h \
+	proc_args.c proc_args.h slurm_strcasestr.c slurm_strcasestr.h \
+	node_conf.h node_conf.c gres.h gres.c entity.h entity.c \
+	layout.h layout.c layouts_mgr.h layouts_mgr.c mapping.c \
+	mapping.h xcgroup_read_config.c xcgroup_read_config.h xlua.c \
+	xlua.h callerid.c callerid.h siphash24.c siphash_slurm.c \
+	siphash.h
 @HAVE_UNSETENV_FALSE@am__objects_1 = unsetenv.lo
 am_libcommon_la_OBJECTS = assoc_mgr.lo cpu_frequency.lo \
 	node_features.lo xmalloc.lo xassert.lo xstring.lo xsignal.lo \
@@ -226,7 +226,7 @@ am_libcommon_la_OBJECTS = assoc_mgr.lo cpu_frequency.lo \
 	slurm_acct_gather_infiniband.lo \
 	slurm_acct_gather_filesystem.lo slurm_jobcomp.lo \
 	slurm_route.lo slurm_time.lo slurm_topology.lo switch.lo \
-	arg_desc.lo malloc.lo getopt.lo getopt1.lo $(am__objects_1) \
+	arg_desc.lo malloc.lo $(am__objects_1) \
 	slurm_selecttype_info.lo slurm_resource_info.lo hostlist.lo \
 	slurm_step_layout.lo checkpoint.lo job_resources.lo \
 	parse_time.lo job_options.lo global_defaults.lo timers.lo \
@@ -679,7 +679,6 @@ libcommon_la_SOURCES = \
 	arg_desc.c arg_desc.h		\
 	macros.h			\
 	malloc.c malloc.h		\
-	getopt.h getopt.c getopt1.c     \
 	$(build_unsetenv_src)		\
 	slurm_selecttype_info.c 	\
 	slurm_selecttype_info.h		\
@@ -827,8 +826,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/env.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/global_defaults.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gres.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hostlist.Plo@am__quote@
diff --git a/src/common/bitstring.h b/src/common/bitstring.h
index 4a1c5a34aa9..42e37c5aaf8 100644
--- a/src/common/bitstring.h
+++ b/src/common/bitstring.h
@@ -59,16 +59,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else	/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 #define BITSTR_SHIFT_WORD8	3
 #define BITSTR_SHIFT_WORD32	5
diff --git a/src/common/callerid.c b/src/common/callerid.c
index e36c0c64358..878cac4d0a4 100644
--- a/src/common/callerid.c
+++ b/src/common/callerid.c
@@ -36,37 +36,24 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
-
+#endif
 
 #ifndef _GNU_SOURCE
-#define _GNU_SOURCE
+#  define _GNU_SOURCE
 #endif
-#include <arpa/inet.h>
-#include <ctype.h>
 
 #ifdef __FreeBSD__
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #define s6_addr32 __u6_addr.__u6_addr32
 #endif
 
-#if HAVE_DIRENT_H
-#  include <dirent.h>
-#endif
+#include <arpa/inet.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <inttypes.h>
 #include <libgen.h>
 #include <stddef.h>
-#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
diff --git a/src/common/env.c b/src/common/env.c
index c7da115e91a..debf307e556 100644
--- a/src/common/env.c
+++ b/src/common/env.c
@@ -42,17 +42,17 @@
 #endif
 
 #include <fcntl.h>
-#include <stdio.h>
+#include <poll.h>
+#include <signal.h>
 #include <stdarg.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
-#include <unistd.h>
-#include <signal.h>
-#include <poll.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/param.h>		/* MAXPATHLEN */
+#include <unistd.h>
+
 #include "slurm/slurm.h"
 #include "src/common/cpu_frequency.h"
 #include "src/common/log.h"
diff --git a/src/common/getopt.c b/src/common/getopt.c
deleted file mode 100644
index 183f58eb4f4..00000000000
--- a/src/common/getopt.c
+++ /dev/null
@@ -1,1061 +0,0 @@
-/* Getopt for GNU.
-   NOTE: getopt is now part of the C library, so if you don't know what
-   "Keep this file name-space clean" means, talk to drepper@gnu.org
-   before changing it!
-   Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
-   	Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301 USA.  */
-
-/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
-   Ditto for AIX 3.2 and <stdlib.h>.  */
-#ifndef _NO_PROTO
-# define _NO_PROTO
-#endif
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#if !defined __STDC__ || !__STDC__
-/* This is a separate conditional since some stdc systems
-   reject `defined (const)'.  */
-# ifndef const
-#  define const
-# endif
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "src/common/log.h"
-
-/* Comment out all this code if we are using the GNU C Library, and are not
-   actually compiling the library itself.  This code is part of the GNU C
-   Library, but also included in many other GNU distributions.  Compiling
-   and linking in this code is a waste when using the GNU C library
-   (especially if it is a shared library).  Rather than having every GNU
-   program understand `configure --with-gnu-libc' and omit the object files,
-   it is simpler to just do this in the source for each such file.  */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-# include <gnu-versions.h>
-# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#  define ELIDE_CODE
-# endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
-/* This needs to come after some library #include
-   to get __GNU_LIBRARY__ defined.  */
-#ifdef	__GNU_LIBRARY__
-/* Don't include stdlib.h for non-GNU C libraries because some of them
-   contain conflicting prototypes for getopt.  */
-# include <stdlib.h>
-# include <unistd.h>
-#endif	/* GNU C library.  */
-
-#ifdef VMS
-# include <unixlib.h>
-# if HAVE_STRING_H - 0
-#  include <string.h>
-# endif
-#endif
-
-#ifndef _
-/* This is for other GNU distributions with internationalized messages.  */
-# if defined HAVE_LIBINTL_H || defined _LIBC
-#  include <libintl.h>
-#  ifndef _
-#   define _(msgid)	gettext (msgid)
-#  endif
-# else
-#  define _(msgid)	(msgid)
-# endif
-#endif
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
-   but it behaves differently for the user, since it allows the user
-   to intersperse the options with the other arguments.
-
-   As `getopt' works, it permutes the elements of ARGV so that,
-   when it is done, all the options precede everything else.  Thus
-   all application programs are extended to handle flexible argument order.
-
-   Setting the environment variable POSIXLY_CORRECT disables permutation.
-   Then the behavior is completely standard.
-
-   GNU application programs can use a third alternative mode in which
-   they can distinguish the relative order of options and other arguments.  */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
-   When `getopt' finds an option that takes an argument,
-   the argument value is returned here.
-   Also, when `ordering' is RETURN_IN_ORDER,
-   each non-option ARGV-element is returned here.  */
-
-char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
-   This is used for communication to and from the caller
-   and for communication between successive calls to `getopt'.
-
-   On entry to `getopt', zero means this is the first call; initialize.
-
-   When `getopt' returns -1, this is the index of the first of the
-   non-option elements that the caller should itself scan.
-
-   Otherwise, `optind' communicates from one call to the next
-   how much of ARGV has been scanned so far.  */
-
-/* 1003.2 says this must be 1 before any call.  */
-int optind = 1;
-
-/* Formerly, initialization of getopt depended on optind==0, which
-   causes problems with re-calling getopt as programs generally don't
-   know that. */
-
-int __getopt_initialized;
-
-/* The next char to be scanned in the option-element
-   in which the last option character we returned was found.
-   This allows us to pick up the scan where we left off.
-
-   If this is zero, or a null string, it means resume the scan
-   by advancing to the next ARGV-element.  */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
-   for unrecognized options.  */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
-   This must be initialized on some systems to avoid linking in the
-   system's own getopt implementation.  */
-
-int optopt = '?';
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
-   If the caller did not specify anything,
-   the default is REQUIRE_ORDER if the environment variable
-   POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
-   REQUIRE_ORDER means don't recognize them as options;
-   stop option processing when the first non-option is seen.
-   This is what Unix does.
-   This mode of operation is selected by either setting the environment
-   variable POSIXLY_CORRECT, or using `+' as the first character
-   of the list of option characters.
-
-   PERMUTE is the default.  We permute the contents of ARGV as we scan,
-   so that eventually all the non-options are at the end.  This allows options
-   to be given in any order, even with programs that were not written to
-   expect this.
-
-   RETURN_IN_ORDER is an option available to programs that were written
-   to expect options and other ARGV-elements in any order and that care about
-   the ordering of the two.  We describe each non-option ARGV-element
-   as if it were the argument of an option with character code 1.
-   Using `-' as the first character of the list of option characters
-   selects this mode of operation.
-
-   The special argument `--' forces an end of option-scanning regardless
-   of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
-   `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
-
-static enum
-{
-  REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-/* Value of POSIXLY_CORRECT environment variable.  */
-static char *posixly_correct;
-
-#ifdef	__GNU_LIBRARY__
-/* We want to avoid inclusion of string.h with non-GNU libraries
-   because there are many ways it can cause trouble.
-   On some systems, it contains special magic macros that don't work
-   in GCC.  */
-# include <string.h>
-# define my_index	strchr
-#else
-
-# if HAVE_STRING_H
-#  include <string.h>
-# else
-#  include <strings.h>
-# endif
-
-/* Avoid depending on library functions or files
-   whose names are inconsistent.  */
-
-#ifndef getenv
-extern char *getenv ();
-#endif
-
-static char *
-my_index (str, chr)
-     const char *str;
-     int chr;
-{
-  while (*str)
-    {
-      if (*str == chr)
-	return (char *) str;
-      str++;
-    }
-  return 0;
-}
-
-/* If using GCC, we can safely declare strlen this way.
-   If not using GCC, it is ok not to declare it.  */
-#ifdef __GNUC__
-/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
-   That was relevant to code that was here before.  */
-# if (!defined __STDC__ || !__STDC__) && !defined strlen
-/* gcc with -traditional declares the built-in strlen to return int,
-   and has done so at least since version 2.4.5. -- rms.  */
-extern int strlen (const char *);
-# endif /* not __STDC__ */
-#endif /* __GNUC__ */
-
-#endif /* not __GNU_LIBRARY__ */
-
-/* Handle permutation of arguments.  */
-
-/* Describe the part of ARGV that contains non-options that have
-   been skipped.  `first_nonopt' is the index in ARGV of the first of them;
-   `last_nonopt' is the index after the last of them.  */
-
-static int first_nonopt;
-static int last_nonopt;
-
-#ifdef _LIBC
-/* Stored original parameters.
-   XXX This is no good solution.  We should rather copy the args so
-   that we can compare them later.  But we must not use malloc(3).  */
-extern int __libc_argc;
-extern char **__libc_argv;
-
-/* Bash 2.0 gives us an environment variable containing flags
-   indicating ARGV elements that should not be considered arguments.  */
-
-# ifdef USE_NONOPTION_FLAGS
-/* Defined in getopt_init.c  */
-extern char *__getopt_nonoption_flags;
-
-static int nonoption_flags_max_len;
-static int nonoption_flags_len;
-# endif
-
-# ifdef USE_NONOPTION_FLAGS
-#  define SWAP_FLAGS(ch1, ch2) \
-  if (nonoption_flags_len > 0)						      \
-    {									      \
-      char __tmp = __getopt_nonoption_flags[ch1];			      \
-      __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2];	      \
-      __getopt_nonoption_flags[ch2] = __tmp;				      \
-    }
-# else
-#  define SWAP_FLAGS(ch1, ch2)
-# endif
-#else	/* !_LIBC */
-# define SWAP_FLAGS(ch1, ch2)
-#endif	/* _LIBC */
-
-/* Exchange two adjacent subsequences of ARGV.
-   One subsequence is elements [first_nonopt,last_nonopt)
-   which contains all the non-options that have been skipped so far.
-   The other is elements [last_nonopt,optind), which contains all
-   the options processed since those non-options were skipped.
-
-   `first_nonopt' and `last_nonopt' are relocated so that they describe
-   the new indices of the non-options in ARGV after they are moved.  */
-
-#if defined __STDC__ && __STDC__
-static void exchange (char **);
-#endif
-
-static void
-exchange (argv)
-     char **argv;
-{
-  int bottom = first_nonopt;
-  int middle = last_nonopt;
-  int top = optind;
-  char *tem;
-
-  /* Exchange the shorter segment with the far end of the longer segment.
-     That puts the shorter segment into the right place.
-     It leaves the longer segment in the right place overall,
-     but it consists of two parts that need to be swapped next.  */
-
-#if defined _LIBC && defined USE_NONOPTION_FLAGS
-  /* First make sure the handling of the `__getopt_nonoption_flags'
-     string can work normally.  Our top argument must be in the range
-     of the string.  */
-  if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
-    {
-      /* We must extend the array.  The user plays games with us and
-	 presents new arguments.  */
-      char *new_str = malloc (top + 1);
-      if (new_str == NULL) {
-	nonoption_flags_len = nonoption_flags_max_len = 0;
-	log_oom(__FILE__, __LINE__, __CURRENT_FUNC__);
-	abort();
-      } else {
-	  memset (__mempcpy (new_str, __getopt_nonoption_flags,
-			     nonoption_flags_max_len),
-		  '\0', top + 1 - nonoption_flags_max_len);
-	  nonoption_flags_max_len = top + 1;
-	  __getopt_nonoption_flags = new_str;
-      }
-    }
-#endif
-
-  while (top > middle && middle > bottom)
-    {
-      if (top - middle > middle - bottom)
-	{
-	  /* Bottom segment is the short one.  */
-	  int len = middle - bottom;
-	  register int i;
-
-	  /* Swap it with the top part of the top segment.  */
-	  for (i = 0; i < len; i++)
-	    {
-	      tem = argv[bottom + i];
-	      argv[bottom + i] = argv[top - (middle - bottom) + i];
-	      argv[top - (middle - bottom) + i] = tem;
-	      SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
-	    }
-	  /* Exclude the moved bottom segment from further swapping.  */
-	  top -= len;
-	}
-      else
-	{
-	  /* Top segment is the short one.  */
-	  int len = top - middle;
-	  register int i;
-
-	  /* Swap it with the bottom part of the bottom segment.  */
-	  for (i = 0; i < len; i++)
-	    {
-	      tem = argv[bottom + i];
-	      argv[bottom + i] = argv[middle + i];
-	      argv[middle + i] = tem;
-	      SWAP_FLAGS (bottom + i, middle + i);
-	    }
-	  /* Exclude the moved top segment from further swapping.  */
-	  bottom += len;
-	}
-    }
-
-  /* Update records for the slots the non-options now occupy.  */
-
-  first_nonopt += (optind - last_nonopt);
-  last_nonopt = optind;
-}
-
-/* Initialize the internal data when the first call is made.  */
-
-#if defined __STDC__ && __STDC__
-static const char *_getopt_initialize (int, char *const *, const char *);
-#endif
-static const char *
-_getopt_initialize (argc, argv, optstring)
-     int argc;
-     char *const *argv;
-     const char *optstring;
-{
-  /* Start processing options with ARGV-element 1 (since ARGV-element 0
-     is the program name); the sequence of previously skipped
-     non-option ARGV-elements is empty.  */
-
-  first_nonopt = last_nonopt = optind;
-
-  nextchar = NULL;
-
-  posixly_correct = getenv ("POSIXLY_CORRECT");
-
-  /* Determine how to handle the ordering of options and nonoptions.  */
-
-  if (optstring[0] == '-')
-    {
-      ordering = RETURN_IN_ORDER;
-      ++optstring;
-    }
-  else if (optstring[0] == '+')
-    {
-      ordering = REQUIRE_ORDER;
-      ++optstring;
-    }
-  else if (posixly_correct != NULL)
-    ordering = REQUIRE_ORDER;
-  else
-    ordering = PERMUTE;
-
-#if defined _LIBC && defined USE_NONOPTION_FLAGS
-  if (posixly_correct == NULL
-      && argc == __libc_argc && argv == __libc_argv)
-    {
-      if (nonoption_flags_max_len == 0)
-	{
-	  if (__getopt_nonoption_flags == NULL
-	      || __getopt_nonoption_flags[0] == '\0')
-	    nonoption_flags_max_len = -1;
-	  else
-	    {
-	      const char *orig_str = __getopt_nonoption_flags;
-	      int len = nonoption_flags_max_len = strlen (orig_str);
-	      if (nonoption_flags_max_len < argc)
-		nonoption_flags_max_len = argc;
-	      __getopt_nonoption_flags =
-		(char *) malloc (nonoption_flags_max_len);
-	      if (__getopt_nonoption_flags == NULL) {
-		log_oom(__FILE__, __LINE__, __CURRENT_FUNC__);
-		abort();
-		nonoption_flags_max_len = -1;
-	      } else {
-		memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
-			'\0', nonoption_flags_max_len - len);
-	      }
-	    }
-	}
-      nonoption_flags_len = nonoption_flags_max_len;
-    }
-  else
-    nonoption_flags_len = 0;
-#endif
-
-  return optstring;
-}
-
-/* Scan elements of ARGV (whose length is ARGC) for option characters
-   given in OPTSTRING.
-
-   If an element of ARGV starts with '-', and is not exactly "-" or "--",
-   then it is an option element.  The characters of this element
-   (aside from the initial '-') are option characters.  If `getopt'
-   is called repeatedly, it returns successively each of the option characters
-   from each of the option elements.
-
-   If `getopt' finds another option character, it returns that character,
-   updating `optind' and `nextchar' so that the next call to `getopt' can
-   resume the scan with the following option character or ARGV-element.
-
-   If there are no more option characters, `getopt' returns -1.
-   Then `optind' is the index in ARGV of the first ARGV-element
-   that is not an option.  (The ARGV-elements have been permuted
-   so that those that are not options now come last.)
-
-   OPTSTRING is a string containing the legitimate option characters.
-   If an option character is seen that is not listed in OPTSTRING,
-   return '?' after printing an error message.  If you set `opterr' to
-   zero, the error message is suppressed but we still return '?'.
-
-   If a char in OPTSTRING is followed by a colon, that means it wants an arg,
-   so the following text in the same ARGV-element, or the text of the following
-   ARGV-element, is returned in `optarg'.  Two colons mean an option that
-   wants an optional arg; if there is text in the current ARGV-element,
-   it is returned in `optarg', otherwise `optarg' is set to zero.
-
-   If OPTSTRING starts with `-' or `+', it requests different methods of
-   handling the non-option ARGV-elements.
-   See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
-   Long-named options begin with `--' instead of `-'.
-   Their names may be abbreviated as long as the abbreviation is unique
-   or is an exact match for some defined option.  If they have an
-   argument, it follows the option name in the same ARGV-element, separated
-   from the option name by a `=', or else the in next ARGV-element.
-   When `getopt' finds a long-named option, it returns 0 if that option's
-   `flag' field is nonzero, the value of the option's `val' field
-   if the `flag' field is zero.
-
-   The elements of ARGV aren't really const, because we permute them.
-   But we pretend they're const in the prototype to be compatible
-   with other systems.
-
-   LONGOPTS is a vector of `struct option' terminated by an
-   element containing a name which is zero.
-
-   LONGIND returns the index in LONGOPT of the long-named option found.
-   It is only valid when a long-named option has been found by the most
-   recent call.
-
-   If LONG_ONLY is nonzero, '-' as well as '--' can introduce
-   long-named options.  */
-
-int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
-     int argc;
-     char *const *argv;
-     const char *optstring;
-     const struct option *longopts;
-     int *longind;
-     int long_only;
-{
-  int print_errors = opterr;
-  if (optstring[0] == ':')
-    print_errors = 0;
-
-  if (argc < 1)
-    return -1;
-
-  optarg = NULL;
-
-  if (optind == 0 || !__getopt_initialized)
-    {
-      if (optind == 0)
-	optind = 1;	/* Don't scan ARGV[0], the program name.  */
-      optstring = _getopt_initialize (argc, argv, optstring);
-      __getopt_initialized = 1;
-    }
-
-  /* Test whether ARGV[optind] points to a non-option argument.
-     Either it does not have option syntax, or there is an environment flag
-     from the shell indicating it is not an option.  The later information
-     is only used when the used in the GNU libc.  */
-#if defined _LIBC && defined USE_NONOPTION_FLAGS
-# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0'	      \
-		      || (optind < nonoption_flags_len			      \
-			  && __getopt_nonoption_flags[optind] == '1'))
-#else
-# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
-#endif
-
-  if (nextchar == NULL || *nextchar == '\0')
-    {
-      /* Advance to the next ARGV-element.  */
-
-      /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
-	 moved back by the user (who may also have changed the arguments).  */
-      if (last_nonopt > optind)
-	last_nonopt = optind;
-      if (first_nonopt > optind)
-	first_nonopt = optind;
-
-      if (ordering == PERMUTE)
-	{
-	  /* If we have just processed some options following some non-options,
-	     exchange them so that the options come first.  */
-
-	  if (first_nonopt != last_nonopt && last_nonopt != optind)
-	    exchange ((char **) argv);
-	  else if (last_nonopt != optind)
-	    first_nonopt = optind;
-
-	  /* Skip any additional non-options
-	     and extend the range of non-options previously skipped.  */
-
-	  while (optind < argc && NONOPTION_P)
-	    optind++;
-	  last_nonopt = optind;
-	}
-
-      /* The special ARGV-element `--' means premature end of options.
-	 Skip it like a null option,
-	 then exchange with previous non-options as if it were an option,
-	 then skip everything else like a non-option.  */
-
-      if (optind != argc && !xstrcmp (argv[optind], "--"))
-	{
-	  optind++;
-
-	  if (first_nonopt != last_nonopt && last_nonopt != optind)
-	    exchange ((char **) argv);
-	  else if (first_nonopt == last_nonopt)
-	    first_nonopt = optind;
-	  last_nonopt = argc;
-
-	  optind = argc;
-	}
-
-      /* If we have done all the ARGV-elements, stop the scan
-	 and back over any non-options that we skipped and permuted.  */
-
-      if (optind == argc)
-	{
-	  /* Set the next-arg-index to point at the non-options
-	     that we previously skipped, so the caller will digest them.  */
-	  if (first_nonopt != last_nonopt)
-	    optind = first_nonopt;
-	  return -1;
-	}
-
-      /* If we have come to a non-option and did not permute it,
-	 either stop the scan or describe it to the caller and pass it by.  */
-
-      if (NONOPTION_P)
-	{
-	  if (ordering == REQUIRE_ORDER)
-	    return -1;
-	  optarg = argv[optind++];
-	  return 1;
-	}
-
-      /* We have found another option-ARGV-element.
-	 Skip the initial punctuation.  */
-
-      nextchar = (argv[optind] + 1
-		  + (longopts != NULL && argv[optind][1] == '-'));
-    }
-
-  /* Decode the current option-ARGV-element.  */
-
-  /* Check whether the ARGV-element is a long option.
-
-     If long_only and the ARGV-element has the form "-f", where f is
-     a valid short option, don't consider it an abbreviated form of
-     a long option that starts with f.  Otherwise there would be no
-     way to give the -f short option.
-
-     On the other hand, if there's a long option "fubar" and
-     the ARGV-element is "-fu", do consider that an abbreviation of
-     the long option, just like "--fu", and not "-f" with arg "u".
-
-     This distinction seems to be the most useful approach.  */
-
-  if (longopts != NULL
-      && (argv[optind][1] == '-'
-	  || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
-    {
-      char *nameend;
-      const struct option *p;
-      const struct option *pfound = NULL;
-      int exact = 0;
-      int ambig = 0;
-      int indfound = -1;
-      int option_index;
-
-      for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
-	/* Do nothing.  */ ;
-
-      /* Test all long options for either exact match
-	 or abbreviated matches.  */
-      for (p = longopts, option_index = 0; p->name; p++, option_index++)
-	if (!xstrncmp (p->name, nextchar, nameend - nextchar))
-	  {
-	    if ((unsigned int) (nameend - nextchar)
-		== (unsigned int) strlen (p->name))
-	      {
-		/* Exact match found.  */
-		pfound = p;
-		indfound = option_index;
-		exact = 1;
-		break;
-	      }
-	    else if (pfound == NULL)
-	      {
-		/* First nonexact match found.  */
-		pfound = p;
-		indfound = option_index;
-	      }
-	    else if (long_only
-		     || pfound->has_arg != p->has_arg
-		     || pfound->flag != p->flag
-		     || pfound->val != p->val)
-	      /* Second or later nonexact match found.  */
-	      ambig = 1;
-	  }
-
-      if (ambig && !exact)
-	{
-	  if (print_errors)
-	    fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
-		     argv[0], argv[optind]);
-	  nextchar += strlen (nextchar);
-	  optind++;
-	  optopt = 0;
-	  return '?';
-	}
-
-      if (pfound != NULL)
-	{
-	  option_index = indfound;
-	  optind++;
-	  if (*nameend)
-	    {
-	      /* Don't test has_arg with >, because some C compilers don't
-		 allow it to be used on enums.  */
-	      if (pfound->has_arg)
-		optarg = nameend + 1;
-	      else
-		{
-		  if (print_errors)
-		    {
-		      if (argv[optind - 1][1] == '-')
-			/* --option */
-			fprintf (stderr,
-				 _("%s: option `--%s' doesn't allow an argument\n"),
-				 argv[0], pfound->name);
-		      else
-			/* +option or -option */
-			fprintf (stderr,
-				 _("%s: option `%c%s' doesn't allow an argument\n"),
-				 argv[0], argv[optind - 1][0], pfound->name);
-		    }
-
-		  nextchar += strlen (nextchar);
-
-		  optopt = pfound->val;
-		  return '?';
-		}
-	    }
-	  else if (pfound->has_arg == 1)
-	    {
-	      if (optind < argc)
-		optarg = argv[optind++];
-	      else
-		{
-		  if (print_errors)
-		    fprintf (stderr,
-			   _("%s: option `%s' requires an argument\n"),
-			   argv[0], argv[optind - 1]);
-		  nextchar += strlen (nextchar);
-		  optopt = pfound->val;
-		  return optstring[0] == ':' ? ':' : '?';
-		}
-	    }
-	  nextchar += strlen (nextchar);
-	  if (longind != NULL)
-	    *longind = option_index;
-	  if (pfound->flag)
-	    {
-	      *(pfound->flag) = pfound->val;
-	      return 0;
-	    }
-	  return pfound->val;
-	}
-
-      /* Can't find it as a long option.  If this is not getopt_long_only,
-	 or the option starts with '--' or is not a valid short
-	 option, then it's an error.
-	 Otherwise interpret it as a short option.  */
-      if (!long_only || argv[optind][1] == '-'
-	  || my_index (optstring, *nextchar) == NULL)
-	{
-	  if (print_errors)
-	    {
-	      if (argv[optind][1] == '-')
-		/* --option */
-		fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
-			 argv[0], nextchar);
-	      else
-		/* +option or -option */
-		fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
-			 argv[0], argv[optind][0], nextchar);
-	    }
-	  nextchar = (char *) "";
-	  optind++;
-	  optopt = 0;
-	  return '?';
-	}
-    }
-
-  /* Look at and handle the next short option-character.  */
-
-  {
-    char c = *nextchar++;
-    char *temp = my_index (optstring, c);
-
-    /* Increment `optind' when we start to process its last character.  */
-    if (*nextchar == '\0')
-      ++optind;
-
-    if (temp == NULL || c == ':')
-      {
-	if (print_errors)
-	  {
-	    if (posixly_correct)
-	      /* 1003.2 specifies the format of this message.  */
-	      fprintf (stderr, _("%s: illegal option -- %c\n"),
-		       argv[0], c);
-	    else
-	      fprintf (stderr, _("%s: invalid option -- %c\n"),
-		       argv[0], c);
-	  }
-	optopt = c;
-	return '?';
-      }
-    /* Convenience. Treat POSIX -W foo same as long option --foo */
-    if (temp[0] == 'W' && temp[1] == ';')
-      {
-	char *nameend;
-	const struct option *p;
-	const struct option *pfound = NULL;
-	int exact = 0;
-	int ambig = 0;
-	int indfound = 0;
-	int option_index;
-
-	/* This is an option that requires an argument.  */
-	if (*nextchar != '\0')
-	  {
-	    optarg = nextchar;
-	    /* If we end this ARGV-element by taking the rest as an arg,
-	       we must advance to the next element now.  */
-	    optind++;
-	  }
-	else if (optind == argc)
-	  {
-	    if (print_errors)
-	      {
-		/* 1003.2 specifies the format of this message.  */
-		fprintf (stderr, _("%s: option requires an argument -- %c\n"),
-			 argv[0], c);
-	      }
-	    optopt = c;
-	    if (optstring[0] == ':')
-	      c = ':';
-	    else
-	      c = '?';
-	    return c;
-	  }
-	else
-	  /* We already incremented `optind' once;
-	     increment it again when taking next ARGV-elt as argument.  */
-	  optarg = argv[optind++];
-
-	/* optarg is now the argument, see if it's in the
-	   table of longopts.  */
-
-	for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
-	  /* Do nothing.  */ ;
-
-	/* Test all long options for either exact match
-	   or abbreviated matches.  */
-	for (p = longopts, option_index = 0; p->name; p++, option_index++)
-	  if (!xstrncmp (p->name, nextchar, nameend - nextchar))
-	    {
-	      if ((unsigned int) (nameend - nextchar) == strlen (p->name))
-		{
-		  /* Exact match found.  */
-		  pfound = p;
-		  indfound = option_index;
-		  exact = 1;
-		  break;
-		}
-	      else if (pfound == NULL)
-		{
-		  /* First nonexact match found.  */
-		  pfound = p;
-		  indfound = option_index;
-		}
-	      else
-		/* Second or later nonexact match found.  */
-		ambig = 1;
-	    }
-	if (ambig && !exact)
-	  {
-	    if (print_errors)
-	      fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
-		       argv[0], argv[optind]);
-	    nextchar += strlen (nextchar);
-	    optind++;
-	    return '?';
-	  }
-	if (pfound != NULL)
-	  {
-	    option_index = indfound;
-	    if (*nameend)
-	      {
-		/* Don't test has_arg with >, because some C compilers don't
-		   allow it to be used on enums.  */
-		if (pfound->has_arg)
-		  optarg = nameend + 1;
-		else
-		  {
-		    if (print_errors)
-		      fprintf (stderr, _("\
-%s: option `-W %s' doesn't allow an argument\n"),
-			       argv[0], pfound->name);
-
-		    nextchar += strlen (nextchar);
-		    return '?';
-		  }
-	      }
-	    else if (pfound->has_arg == 1)
-	      {
-		if (optind < argc)
-		  optarg = argv[optind++];
-		else
-		  {
-		    if (print_errors)
-		      fprintf (stderr,
-			       _("%s: option `%s' requires an argument\n"),
-			       argv[0], argv[optind - 1]);
-		    nextchar += strlen (nextchar);
-		    return optstring[0] == ':' ? ':' : '?';
-		  }
-	      }
-	    nextchar += strlen (nextchar);
-	    if (longind != NULL)
-	      *longind = option_index;
-	    if (pfound->flag)
-	      {
-		*(pfound->flag) = pfound->val;
-		return 0;
-	      }
-	    return pfound->val;
-	  }
-	  nextchar = NULL;
-	  return 'W';	/* Let the application handle it.   */
-      }
-    if (temp[1] == ':')
-      {
-	if (temp[2] == ':')
-	  {
-	    /* This is an option that accepts an argument optionally.  */
-	    if (*nextchar != '\0')
-	      {
-		optarg = nextchar;
-		optind++;
-	      }
-	    else
-	      optarg = NULL;
-	    nextchar = NULL;
-	  }
-	else
-	  {
-	    /* This is an option that requires an argument.  */
-	    if (*nextchar != '\0')
-	      {
-		optarg = nextchar;
-		/* If we end this ARGV-element by taking the rest as an arg,
-		   we must advance to the next element now.  */
-		optind++;
-	      }
-	    else if (optind == argc)
-	      {
-		if (print_errors)
-		  {
-		    /* 1003.2 specifies the format of this message.  */
-		    fprintf (stderr,
-			     _("%s: option requires an argument -- %c\n"),
-			     argv[0], c);
-		  }
-		optopt = c;
-		if (optstring[0] == ':')
-		  c = ':';
-		else
-		  c = '?';
-	      }
-	    else
-	      /* We already incremented `optind' once;
-		 increment it again when taking next ARGV-elt as argument.  */
-	      optarg = argv[optind++];
-	    nextchar = NULL;
-	  }
-      }
-    return c;
-  }
-}
-
-int
-getopt (argc, argv, optstring)
-     int argc;
-     char *const *argv;
-     const char *optstring;
-{
-  return _getopt_internal (argc, argv, optstring,
-			   (const struct option *) 0,
-			   (int *) 0,
-			   0);
-}
-
-#endif	/* Not ELIDE_CODE.  */
-
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
-   the above definition of `getopt'.  */
-
-int
-main (argc, argv)
-     int argc;
-     char **argv;
-{
-  int c;
-  int digit_optind = 0;
-
-  while (1)
-    {
-      int this_option_optind = optind ? optind : 1;
-
-      c = getopt (argc, argv, "abc:d:0123456789");
-      if (c == -1)
-	break;
-
-      switch (c)
-	{
-	case '0':
-	case '1':
-	case '2':
-	case '3':
-	case '4':
-	case '5':
-	case '6':
-	case '7':
-	case '8':
-	case '9':
-	  if (digit_optind != 0 && digit_optind != this_option_optind)
-	    printf ("digits occur in two different argv-elements.\n");
-	  digit_optind = this_option_optind;
-	  printf ("option %c\n", c);
-	  break;
-
-	case 'a':
-	  printf ("option a\n");
-	  break;
-
-	case 'b':
-	  printf ("option b\n");
-	  break;
-
-	case 'c':
-	  printf ("option c with value `%s'\n", optarg);
-	  break;
-
-	case '?':
-	  break;
-
-	default:
-	  printf ("?? getopt returned character code 0%o ??\n", c);
-	}
-    }
-
-  if (optind < argc)
-    {
-      printf ("non-option ARGV-elements: ");
-      while (optind < argc)
-	printf ("%s ", argv[optind++]);
-      printf ("\n");
-    }
-
-  exit (0);
-}
-
-#endif /* TEST */
diff --git a/src/common/getopt.h b/src/common/getopt.h
deleted file mode 100644
index d0694bd3ee5..00000000000
--- a/src/common/getopt.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/* Declarations for getopt.
-   Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301 USA.  */
-
-#ifndef _GETOPT_H
-
-#ifndef __need_getopt
-# define _GETOPT_H 1
-#endif
-
-/* If __GNU_LIBRARY__ is not already defined, either we are being used
-   standalone, or this is the first header included in the source file.
-   If we are being used with glibc, we need to include <features.h>, but
-   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is
-   not defined, include <ctype.h>, which will pull in <features.h> for us
-   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it
-   doesn't flood the namespace with stuff the way some other headers do.)  */
-#if !defined __GNU_LIBRARY__
-# include <ctype.h>
-#endif
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
-   When `getopt' finds an option that takes an argument,
-   the argument value is returned here.
-   Also, when `ordering' is RETURN_IN_ORDER,
-   each non-option ARGV-element is returned here.  */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
-   This is used for communication to and from the caller
-   and for communication between successive calls to `getopt'.
-
-   On entry to `getopt', zero means this is the first call; initialize.
-
-   When `getopt' returns -1, this is the index of the first of the
-   non-option elements that the caller should itself scan.
-
-   Otherwise, `optind' communicates from one call to the next
-   how much of ARGV has been scanned so far.  */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
-   for unrecognized options.  */
-
-extern int opterr;
-
-/* Set to an option character which was unrecognized.  */
-
-extern int optopt;
-
-#ifndef __need_getopt
-/* Describe the long-named options requested by the application.
-   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
-   of `struct option' terminated by an element containing a name which is
-   zero.
-
-   The field `has_arg' is:
-   no_argument		(or 0) if the option does not take an argument,
-   required_argument	(or 1) if the option requires an argument,
-   optional_argument 	(or 2) if the option takes an optional argument.
-
-   If the field `flag' is not NULL, it points to a variable that is set
-   to the value given in the field `val' when the option is found, but
-   left unchanged if the option is not found.
-
-   To have a long-named option do something other than set an `int' to
-   a compiled-in constant, such as set a value from `optarg', set the
-   option's `flag' field to zero and its `val' field to a nonzero
-   value (the equivalent single-letter option character, if there is
-   one).  For long options that have a zero `flag' field, `getopt'
-   returns the contents of the `val' field.  */
-
-struct option
-{
-# if (defined __STDC__ && __STDC__) || defined __cplusplus
-  const char *name;
-# else
-  char *name;
-# endif
-  /* has_arg can't be an enum because some compilers complain about
-     type mismatches in all the code that assumes it is an int.  */
-  int has_arg;
-  int *flag;
-  int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'.  */
-
-# define no_argument		0
-# define required_argument	1
-# define optional_argument	2
-#endif	/* need getopt */
-
-
-/* Get definitions and prototypes for functions to process the
-   arguments in ARGV (ARGC of them, minus the program name) for
-   options given in OPTS.
-
-   Return the option character from OPTS just read.  Return -1 when
-   there are no more options.  For unrecognized options, or options
-   missing arguments, `optopt' is set to the option letter, and '?' is
-   returned.
-
-   The OPTS string is a list of characters which are recognized option
-   letters, optionally followed by colons, specifying that that letter
-   takes an argument, to be placed in `optarg'.
-
-   If a letter in OPTS is followed by two colons, its argument is
-   optional.  This behavior is specific to the GNU `getopt'.
-
-   The argument `--' causes premature termination of argument
-   scanning, explicitly telling `getopt' that there are no more
-   options.
-
-   If OPTS begins with `--', then non-option arguments are treated as
-   arguments to the option '\0'.  This behavior is specific to the GNU
-   `getopt'.  */
-
-#if (defined __STDC__ && __STDC__) || defined __cplusplus
-# ifdef __GNU_LIBRARY__
-/* Many other libraries have conflicting prototypes for getopt, with
-   differences in the consts, in stdlib.h.  To avoid compilation
-   errors, only prototype getopt for the GNU C library.  */
-extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
-# else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-# endif /* __GNU_LIBRARY__ */
-
-# ifndef __need_getopt
-extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
-		        const struct option *__longopts, int *__longind);
-extern int getopt_long_only (int __argc, char *const *__argv,
-			     const char *__shortopts,
-		             const struct option *__longopts, int *__longind);
-
-/* Internal only.  Users should not call this directly.  */
-extern int _getopt_internal (int __argc, char *const *__argv,
-			     const char *__shortopts,
-		             const struct option *__longopts, int *__longind,
-			     int __long_only);
-# endif
-#else /* not __STDC__ */
-extern int getopt ();
-# ifndef __need_getopt
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-# endif
-#endif /* __STDC__ */
-
-#ifdef	__cplusplus
-}
-#endif
-
-/* Make sure we later can get all the definitions and declarations.  */
-#undef __need_getopt
-
-#endif /* getopt.h */
diff --git a/src/common/getopt1.c b/src/common/getopt1.c
deleted file mode 100644
index 08952725003..00000000000
--- a/src/common/getopt1.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* getopt_long and getopt_long_only entry points for GNU getopt.
-   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
-     Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301 USA.  */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "getopt.h"
-
-#if !defined __STDC__ || !__STDC__
-/* This is a separate conditional since some stdc systems
-   reject `defined (const)'.  */
-#ifndef const
-#define const
-#endif
-#endif
-
-#include <stdio.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
-   actually compiling the library itself.  This code is part of the GNU C
-   Library, but also included in many other GNU distributions.  Compiling
-   and linking in this code is a waste when using the GNU C library
-   (especially if it is a shared library).  Rather than having every GNU
-   program understand `configure --with-gnu-libc' and omit the object files,
-   it is simpler to just do this in the source for each such file.  */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
-#include <gnu-versions.h>
-#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#define ELIDE_CODE
-#endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
-/* This needs to come after some library #include
-   to get __GNU_LIBRARY__ defined.  */
-#ifdef __GNU_LIBRARY__
-#include <stdlib.h>
-#endif
-
-#ifndef	NULL
-#define NULL 0
-#endif
-
-int
-getopt_long (argc, argv, options, long_options, opt_index)
-     int argc;
-     char *const *argv;
-     const char *options;
-     const struct option *long_options;
-     int *opt_index;
-{
-  return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
-}
-
-/* Like getopt_long, but '-' as well as '--' can indicate a long option.
-   If an option that starts with '-' (not '--') doesn't match a long option,
-   but does match a short option, it is parsed as a short option
-   instead.  */
-
-int
-getopt_long_only (argc, argv, options, long_options, opt_index)
-     int argc;
-     char *const *argv;
-     const char *options;
-     const struct option *long_options;
-     int *opt_index;
-{
-  return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
-}
-
-
-#endif	/* Not ELIDE_CODE.  */
-
-#ifdef TEST
-
-#include <stdio.h>
-
-int
-main (argc, argv)
-     int argc;
-     char **argv;
-{
-  int c;
-  int digit_optind = 0;
-
-  while (1)
-    {
-      int this_option_optind = optind ? optind : 1;
-      int option_index = 0;
-      static struct option long_options[] =
-      {
-	{"add", 1, 0, 0},
-	{"append", 0, 0, 0},
-	{"delete", 1, 0, 0},
-	{"verbose", 0, 0, 0},
-	{"create", 0, 0, 0},
-	{"file", 1, 0, 0},
-	{0, 0, 0, 0}
-      };
-
-      c = getopt_long (argc, argv, "abc:d:0123456789",
-		       long_options, &option_index);
-      if (c == -1)
-	break;
-
-      switch (c)
-	{
-	case 0:
-	  printf ("option %s", long_options[option_index].name);
-	  if (optarg)
-	    printf (" with arg %s", optarg);
-	  printf ("\n");
-	  break;
-
-	case '0':
-	case '1':
-	case '2':
-	case '3':
-	case '4':
-	case '5':
-	case '6':
-	case '7':
-	case '8':
-	case '9':
-	  if (digit_optind != 0 && digit_optind != this_option_optind)
-	    printf ("digits occur in two different argv-elements.\n");
-	  digit_optind = this_option_optind;
-	  printf ("option %c\n", c);
-	  break;
-
-	case 'a':
-	  printf ("option a\n");
-	  break;
-
-	case 'b':
-	  printf ("option b\n");
-	  break;
-
-	case 'c':
-	  printf ("option c with value `%s'\n", optarg);
-	  break;
-
-	case 'd':
-	  printf ("option d with value `%s'\n", optarg);
-	  break;
-
-	case '?':
-	  break;
-
-	default:
-	  printf ("?? getopt returned character code 0%o ??\n", c);
-	}
-    }
-
-  if (optind < argc)
-    {
-      printf ("non-option ARGV-elements: ");
-      while (optind < argc)
-	printf ("%s ", argv[optind++]);
-      printf ("\n");
-    }
-
-  exit (0);
-}
-
-#endif /* TEST */
diff --git a/src/common/gres.c b/src/common/gres.c
index 9bb5b1f6e9b..d71f30390f4 100644
--- a/src/common/gres.c
+++ b/src/common/gres.c
@@ -40,44 +40,23 @@
 #define _GNU_SOURCE
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#  ifdef HAVE_LIMITS_H
-#    include <limits.h>
-#  endif
-#else /* ! HAVE_CONFIG_H */
-#  include <limits.h>
-#  include <sys/types.h>
-#  include <stdint.h>
-#  include <stdlib.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
 #ifdef __FreeBSD__
-#include <sys/param.h>
-#include <sys/cpuset.h>
+#  include <sys/param.h>
+#  include <sys/cpuset.h>
 typedef cpuset_t cpu_set_t;
 #endif
 
 #include <ctype.h>
+#include <inttypes.h>
+#include <limits.h>
 #include <sched.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <math.h>
 
 #include "slurm/slurm.h"
diff --git a/src/common/hostlist.c b/src/common/hostlist.c
index 5cd0cc43b00..f2894a6d4c7 100644
--- a/src/common/hostlist.c
+++ b/src/common/hostlist.c
@@ -38,33 +38,20 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#  if HAVE_STRING_H
-#    include <string.h>
-#  endif
-#  if HAVE_PTHREAD_H
-#    include <pthread.h>
-#  endif
-#else                /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#  include <string.h>
-#  include <pthread.h>
-#endif                /* HAVE_CONFIG_H */
+#endif
 
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
-#include <assert.h>
-#include <errno.h>
-#include <ctype.h>
+#include <string.h>
 #include <sys/param.h>
 #include <unistd.h>
+
 #include <slurm/slurmdb.h>
 
 #include "src/common/bitstring.h"
diff --git a/src/common/io_hdr.h b/src/common/io_hdr.h
index af924c17fb8..75b547be0ac 100644
--- a/src/common/io_hdr.h
+++ b/src/common/io_hdr.h
@@ -39,17 +39,11 @@
 #ifndef _HAVE_IO_HDR_H
 #define _HAVE_IO_HDR_H
 
-
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
+#include <inttypes.h>
 
 #include "src/common/macros.h"   /* Containes SLURM_CRED_SIGLEN */
 #include "src/common/pack.h"
diff --git a/src/common/job_resources.h b/src/common/job_resources.h
index 318ec5b4a4c..170bd28e95b 100644
--- a/src/common/job_resources.h
+++ b/src/common/job_resources.h
@@ -41,15 +41,10 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
 #endif
 
+#include <inttypes.h>
+
 #include "src/common/bitstring.h"
 #include "src/common/pack.h"
 #include "src/slurmctld/slurmctld.h"
diff --git a/src/common/layouts_mgr.c b/src/common/layouts_mgr.c
index 56e38a8b3e3..886f4adc2e5 100644
--- a/src/common/layouts_mgr.c
+++ b/src/common/layouts_mgr.c
@@ -36,19 +36,17 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
+#include <ctype.h>
 #include <pthread.h>
 #include <string.h>
-#include <strings.h>
-#include <ctype.h>
 #include <sys/stat.h>
 
 #include "layouts_mgr.h"
 
-#include "src/common/entity.h"
-#include "src/common/layout.h"
-
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
+#include "src/common/entity.h"
+#include "src/common/layout.h"
 #include "src/common/hostlist.h"
 #include "src/common/list.h"
 #include "src/common/node_conf.h"
diff --git a/src/common/macros.h b/src/common/macros.h
index cc9644a6c00..67e8e5e3240 100644
--- a/src/common/macros.h
+++ b/src/common/macros.h
@@ -55,12 +55,10 @@
 #  endif
 #endif /* !HAVE_STDBOOL_H */
 
-#if HAVE_PTHREAD_H
-#  include <pthread.h>
-#endif
-
 #include <errno.h>              /* for errno   */
+#include <pthread.h>
 #include <stdlib.h>		/* for abort() */
+
 #include "src/common/log.h"	/* for error() */
 
 #ifndef FALSE
diff --git a/src/common/node_conf.c b/src/common/node_conf.c
index 2937c6704d8..e0b1d9464c8 100644
--- a/src/common/node_conf.c
+++ b/src/common/node_conf.c
@@ -45,24 +45,18 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
 #endif
 
 #include <ctype.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <fcntl.h>
+#include <time.h>
 
 #include "src/common/hostlist.h"
 #include "src/common/macros.h"
diff --git a/src/common/node_conf.h b/src/common/node_conf.h
index ee9831678dc..771cb76d2d9 100644
--- a/src/common/node_conf.h
+++ b/src/common/node_conf.h
@@ -44,15 +44,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
 #endif
 
+#include <inttypes.h>
 #include <time.h>
 
 #include "src/common/bitstring.h"
diff --git a/src/common/node_features.c b/src/common/node_features.c
index 8750834acdd..7954a404934 100644
--- a/src/common/node_features.c
+++ b/src/common/node_features.c
@@ -37,28 +37,12 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "src/common/macros.h"
diff --git a/src/common/optz.h b/src/common/optz.h
index 377769088db..708ebdfefac 100644
--- a/src/common/optz.h
+++ b/src/common/optz.h
@@ -46,11 +46,7 @@
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
+#include <getopt.h>
 
 struct option * optz_create (void);
 
diff --git a/src/common/pack.h b/src/common/pack.h
index 80cb2fd436b..54413317451 100644
--- a/src/common/pack.h
+++ b/src/common/pack.h
@@ -43,20 +43,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#include <stdint.h>
-#endif  /* HAVE_CONFIG_H */
+#endif
 
 #include <assert.h>
+#include <inttypes.h>
 #include <time.h>
 #include <string.h>
+
 #include "src/common/bitstring.h"
 
 #define BUF_MAGIC 0x42554545
diff --git a/src/common/parse_spec.h b/src/common/parse_spec.h
index 05518354f75..201527ffd4c 100644
--- a/src/common/parse_spec.h
+++ b/src/common/parse_spec.h
@@ -41,16 +41,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else	/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 /*
  * slurm_parser - parse the supplied specification into keyword/value pairs
diff --git a/src/common/parse_time.c b/src/common/parse_time.c
index 734dd1ac858..86db6286eaf 100644
--- a/src/common/parse_time.c
+++ b/src/common/parse_time.c
@@ -44,7 +44,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
 #include <time.h>
 
 #ifndef   __USE_ISOC99
diff --git a/src/common/parse_time.h b/src/common/parse_time.h
index b98c1df84be..775584179df 100644
--- a/src/common/parse_time.h
+++ b/src/common/parse_time.h
@@ -41,17 +41,10 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif                        /* HAVE_INTTYPES_H */
-#else                           /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
 #endif
 
+#include <inttypes.h>
+
 #include <time.h>
 
 /* Convert string to equivalent time value
diff --git a/src/common/parse_value.c b/src/common/parse_value.c
index 2d4b7006058..acee9ec3370 100644
--- a/src/common/parse_value.c
+++ b/src/common/parse_value.c
@@ -43,7 +43,6 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
 #include <unistd.h>
 #include <math.h>
 
diff --git a/src/common/plugin.h b/src/common/plugin.h
index a51f5d69d4b..2e1e57eee34 100644
--- a/src/common/plugin.h
+++ b/src/common/plugin.h
@@ -41,19 +41,10 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif
-#else /* ! HAVE_CONFIG_H_ */
-#  include <inttypes.h>
-#endif /* HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
+#include <sys/types.h>
 
 #include "slurm/slurm_errno.h"
 
diff --git a/src/common/plugstack.h b/src/common/plugstack.h
index bdbb363445c..9ba620c2f85 100644
--- a/src/common/plugstack.h
+++ b/src/common/plugstack.h
@@ -46,11 +46,7 @@
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
+#include <getopt.h>
 
 #include "src/common/job_options.h"
 #include "src/slurmd/slurmstepd/slurmstepd_job.h"
diff --git a/src/common/print_fields.h b/src/common/print_fields.h
index 85fb2503d79..2feae07dccb 100644
--- a/src/common/print_fields.h
+++ b/src/common/print_fields.h
@@ -43,22 +43,12 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef HAVE_STRING_H
-#  include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
+#include <getopt.h>
+#include <string.h>
 #include <time.h>
 #include <unistd.h>
 
diff --git a/src/common/proc_args.c b/src/common/proc_args.c
index c8eb88c72ea..086ccfc5de0 100644
--- a/src/common/proc_args.c
+++ b/src/common/proc_args.c
@@ -40,12 +40,6 @@
 #  include "config.h"
 #endif
 
-#include <string.h>		/* strcpy, strncasecmp */
-
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
-
 #ifndef __USE_ISOC99
 #define __USE_ISOC99
 #endif
@@ -62,18 +56,18 @@
 #  define SYSTEM_DIMENSIONS 1
 #endif
 
+#include <ctype.h>		/* isdigit    */
 #include <fcntl.h>
+#include <pwd.h>		/* getpwuid   */
 #include <stdarg.h>		/* va_start   */
 #include <stdio.h>
 #include <stdlib.h>		/* getenv, strtoll */
-#include <pwd.h>		/* getpwuid   */
-#include <ctype.h>		/* isdigit    */
+#include <string.h>		/* strcpy, strncasecmp */
 #include <sys/param.h>		/* MAXPATHLEN */
 #include <sys/stat.h>
-#include <unistd.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 #include "src/common/gres.h"
 #include "src/common/list.h"
diff --git a/src/common/slurm_acct_gather.h b/src/common/slurm_acct_gather.h
index e6533a92a01..743a228ef84 100644
--- a/src/common/slurm_acct_gather.h
+++ b/src/common/slurm_acct_gather.h
@@ -40,16 +40,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 #include "read_config.h"
 #include "slurm_acct_gather_energy.h"
diff --git a/src/common/slurm_acct_gather_energy.h b/src/common/slurm_acct_gather_energy.h
index 3e6e6cfc7d1..d876ccaf01b 100644
--- a/src/common/slurm_acct_gather_energy.h
+++ b/src/common/slurm_acct_gather_energy.h
@@ -40,17 +40,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <time.h>
diff --git a/src/common/slurm_acct_gather_filesystem.h b/src/common/slurm_acct_gather_filesystem.h
index 593e768c126..13d45cba4f5 100644
--- a/src/common/slurm_acct_gather_filesystem.h
+++ b/src/common/slurm_acct_gather_filesystem.h
@@ -40,17 +40,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <time.h>
diff --git a/src/common/slurm_acct_gather_infiniband.h b/src/common/slurm_acct_gather_infiniband.h
index 973fccd76ed..85e0ed35bab 100644
--- a/src/common/slurm_acct_gather_infiniband.h
+++ b/src/common/slurm_acct_gather_infiniband.h
@@ -40,17 +40,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <time.h>
diff --git a/src/common/slurm_acct_gather_profile.h b/src/common/slurm_acct_gather_profile.h
index f1c0c62ac7b..48a8ef4118a 100644
--- a/src/common/slurm_acct_gather_profile.h
+++ b/src/common/slurm_acct_gather_profile.h
@@ -41,17 +41,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <time.h>
diff --git a/src/common/slurm_auth.h b/src/common/slurm_auth.h
index eeaab391ef6..00f0fa17f37 100644
--- a/src/common/slurm_auth.h
+++ b/src/common/slurm_auth.h
@@ -43,16 +43,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 #include "src/common/plugrack.h"
 #include "src/common/pack.h"
diff --git a/src/common/slurm_ext_sensors.h b/src/common/slurm_ext_sensors.h
index 4ddc8f9acb5..33136621d32 100644
--- a/src/common/slurm_ext_sensors.h
+++ b/src/common/slurm_ext_sensors.h
@@ -40,17 +40,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <time.h>
diff --git a/src/common/slurm_jobacct_gather.h b/src/common/slurm_jobacct_gather.h
index 93696d1545d..163524797bc 100644
--- a/src/common/slurm_jobacct_gather.h
+++ b/src/common/slurm_jobacct_gather.h
@@ -47,23 +47,14 @@
  *       Morris Jette, et al.
 \*****************************************************************************/
 
-
 #ifndef __SLURM_JOBACCT_GATHER_H__
 #define __SLURM_JOBACCT_GATHER_H__
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <time.h>
diff --git a/src/common/slurm_jobcomp.h b/src/common/slurm_jobcomp.h
index e0899327d8d..f7155565394 100644
--- a/src/common/slurm_jobcomp.h
+++ b/src/common/slurm_jobcomp.h
@@ -43,12 +43,8 @@
 #if HAVE_CONFIG_H
 #  include "config.h"
 #endif
-#if HAVE_STDINT_H
-#  include <stdint.h>           /* for uint16_t, uint32_t definitions */
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>         /* for uint16_t, uint32_t definitions */
-#endif
+
+#include <inttypes.h>
 #include <sys/types.h>
 #include <time.h>
 #include <unistd.h>
diff --git a/src/common/slurm_mcs.h b/src/common/slurm_mcs.h
index 4d6c6c71716..e4cfa610a27 100644
--- a/src/common/slurm_mcs.h
+++ b/src/common/slurm_mcs.h
@@ -40,12 +40,8 @@
 #if HAVE_CONFIG_H
 #  include "config.h"
 #endif
-#if HAVE_STDINT_H
-#  include <stdint.h>           /* for uint16_t, uint32_t definitions */
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>         /* for uint16_t, uint32_t definitions */
-#endif
+
+#include <inttypes.h>
 
 #include "src/slurmctld/slurmctld.h"
 
diff --git a/src/common/slurm_priority.h b/src/common/slurm_priority.h
index 173e5166f7e..3b786af2f1d 100644
--- a/src/common/slurm_priority.h
+++ b/src/common/slurm_priority.h
@@ -42,12 +42,8 @@
 #if HAVE_CONFIG_H
 #  include "config.h"
 #endif
-#if HAVE_STDINT_H
-#  include <stdint.h>           /* for uint16_t, uint32_t definitions */
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>         /* for uint16_t, uint32_t definitions */
-#endif
+
+#include <inttypes.h>
 
 #include "src/slurmctld/slurmctld.h"
 #include "src/common/slurm_accounting_storage.h"
diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h
index 971e36f4b02..bd8e164381d 100644
--- a/src/common/slurm_protocol_api.h
+++ b/src/common/slurm_protocol_api.h
@@ -44,17 +44,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <sys/types.h>
 #include <stdarg.h>
 
diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h
index a03ad8ab7e8..caeae1ade19 100644
--- a/src/common/slurm_protocol_defs.h
+++ b/src/common/slurm_protocol_defs.h
@@ -43,17 +43,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <sys/wait.h>
 
 #include "slurm/slurm.h"
diff --git a/src/common/slurm_protocol_interface.h b/src/common/slurm_protocol_interface.h
index d646015c9cf..244f71b8eb6 100644
--- a/src/common/slurm_protocol_interface.h
+++ b/src/common/slurm_protocol_interface.h
@@ -41,37 +41,18 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
-
-/* WHAT ABOUT THESE INCLUDES */
+#endif
+
+#include <fcntl.h>
+#include <inttypes.h>
 #include <netdb.h>
 #include <netinet/in.h>
+#include <stdarg.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
 #include <sys/time.h>
-
-
-#if HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#else
-#  if HAVE_SOCKET_H
-#    include <socket.h>
-#  endif
-#endif
-
-
 #include <sys/types.h>
-#include <sys/ioctl.h>
 #include <unistd.h>
-#include <fcntl.h>
-#include <stdarg.h>
 
 #include "src/common/macros.h"
 #include "src/common/pack.h"
diff --git a/src/common/slurm_protocol_pack.h b/src/common/slurm_protocol_pack.h
index e608cb19dd7..012d38ff380 100644
--- a/src/common/slurm_protocol_pack.h
+++ b/src/common/slurm_protocol_pack.h
@@ -42,16 +42,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 #include "src/common/pack.h"
 #include "src/common/slurm_protocol_defs.h"
diff --git a/src/common/slurm_protocol_socket_common.h b/src/common/slurm_protocol_socket_common.h
index ebf74df833a..0719e30ab22 100644
--- a/src/common/slurm_protocol_socket_common.h
+++ b/src/common/slurm_protocol_socket_common.h
@@ -42,17 +42,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <netinet/in.h>
 
 #define AF_SLURM AF_INET
diff --git a/src/common/slurm_protocol_util.h b/src/common/slurm_protocol_util.h
index 98965c72dc7..f9df1d9d09c 100644
--- a/src/common/slurm_protocol_util.h
+++ b/src/common/slurm_protocol_util.h
@@ -41,17 +41,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
 
 #include "src/common/slurm_protocol_defs.h"
diff --git a/src/common/slurm_resource_info.h b/src/common/slurm_resource_info.h
index 20284678573..1a3981a433f 100644
--- a/src/common/slurm_resource_info.h
+++ b/src/common/slurm_resource_info.h
@@ -40,15 +40,10 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
 #endif
 
+#include <stdint.h>
+
 void slurm_print_cpu_bind_help(void);
 void slurm_print_mem_bind_help(void);
 
diff --git a/src/common/slurm_step_layout.h b/src/common/slurm_step_layout.h
index c3583209d51..27cd2fd4cb4 100644
--- a/src/common/slurm_step_layout.h
+++ b/src/common/slurm_step_layout.h
@@ -33,15 +33,10 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
 #endif
 
+#include <inttypes.h>
+
 #include "src/common/hostlist.h"
 #include "src/common/pack.h"
 
diff --git a/src/common/slurmdbd_defs.c b/src/common/slurmdbd_defs.c
index 64cc3a015d3..7fad2c191f3 100644
--- a/src/common/slurmdbd_defs.c
+++ b/src/common/slurmdbd_defs.c
@@ -38,26 +38,18 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
 #include <arpa/inet.h>
 #include <fcntl.h>
+#include <inttypes.h>
+#include <poll.h>
 #include <pthread.h>
 #include <stdio.h>
-#include <syslog.h>
-#include <poll.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <syslog.h>
 #include <time.h>
 #include <unistd.h>
 
diff --git a/src/common/slurmdbd_defs.h b/src/common/slurmdbd_defs.h
index a177d60d849..78f1be43f64 100644
--- a/src/common/slurmdbd_defs.h
+++ b/src/common/slurmdbd_defs.h
@@ -41,16 +41,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 #include "slurm/slurm.h"
 
diff --git a/src/common/xcgroup_read_config.h b/src/common/xcgroup_read_config.h
index dffa8c5ac12..53cb3af9a8c 100644
--- a/src/common/xcgroup_read_config.h
+++ b/src/common/xcgroup_read_config.h
@@ -39,16 +39,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#include <stdint.h>
-#endif  /* HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 /*  Default lower bound on memory limit in MB. This is required so we
  *   don't immediately kill slurmstepd on mem cgroup creation if
diff --git a/src/database/mysql_common.h b/src/database/mysql_common.h
index e3adb3ccffe..468e02f735a 100644
--- a/src/database/mysql_common.h
+++ b/src/database/mysql_common.h
@@ -45,21 +45,14 @@
 #  include "config.h"
 #endif
 
-#ifdef WITH_PTHREADS
-#  include <pthread.h>
-#endif				/* WITH_PTHREADS */
-
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
+#include <inttypes.h>
+#include <pthread.h>
 #include <stdio.h>
+
 #include "slurm/slurm_errno.h"
 #include "src/common/list.h"
 #include "src/common/xstring.h"
+
 #include <mysql.h>
 #include <mysqld_error.h>
 
diff --git a/src/plugins/accounting_storage/common/common_as.c b/src/plugins/accounting_storage/common/common_as.c
index 3872617d538..b0db9e19af5 100644
--- a/src/plugins/accounting_storage/common/common_as.c
+++ b/src/plugins/accounting_storage/common/common_as.c
@@ -36,11 +36,12 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#include <strings.h>
+#include <fcntl.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <fcntl.h>
+
 #include "src/common/env.h"
 #include "src/common/slurmdbd_defs.h"
 #include "src/common/slurm_auth.h"
diff --git a/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c b/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c
index 49c9478fabe..5aa5e4789c1 100644
--- a/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c
+++ b/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c
@@ -36,7 +36,7 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 \*****************************************************************************/
 
-#include <strings.h>
+#include <string.h>
 #include "src/common/slurm_xlator.h"
 #include "src/common/slurm_accounting_storage.h"
 #include "filetxt_jobacct_process.h"
diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.h b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.h
index 16ade4c1a95..f17908b749e 100644
--- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.h
+++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.h
@@ -39,7 +39,7 @@
 #ifndef _HAVE_ACCOUNTING_STORAGE_MYSQL_H
 #define _HAVE_ACCOUNTING_STORAGE_MYSQL_H
 
-#include <strings.h>
+#include <string.h>
 #include <stdlib.h>
 
 /* we can't include common/slurm_xlator.h here since it contains
diff --git a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
index fdad804484f..0176a09fb26 100644
--- a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
+++ b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
@@ -40,20 +40,14 @@
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
 #if HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
 
+#include <inttypes.h>
+#include <pwd.h>
 #include <stdio.h>
 #include <sys/types.h>
-#include <pwd.h>
 
 #include "slurm/slurm_errno.h"
 
diff --git a/src/plugins/acct_gather_infiniband/ofed/acct_gather_infiniband_ofed.c b/src/plugins/acct_gather_infiniband/ofed/acct_gather_infiniband_ofed.c
index 02caf555ca7..be7803e1136 100644
--- a/src/plugins/acct_gather_infiniband/ofed/acct_gather_infiniband_ofed.c
+++ b/src/plugins/acct_gather_infiniband/ofed/acct_gather_infiniband_ofed.c
@@ -37,17 +37,14 @@
  *  Copyright (C) 2002 The Regents of the University of California.
 \*****************************************************************************/
 
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <fcntl.h>
-#include <sys/stat.h>
-#include <signal.h>
-
-#include <unistd.h>
 #include <getopt.h>
 #include <netinet/in.h>
-
+#include <signal.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include "src/common/slurm_xlator.h"
 #include "src/common/slurm_acct_gather_infiniband.h"
diff --git a/src/plugins/acct_gather_profile/hdf5/hdf5_api.h b/src/plugins/acct_gather_profile/hdf5/hdf5_api.h
index 9f59cfd8e54..60a6fa0e3df 100644
--- a/src/plugins/acct_gather_profile/hdf5/hdf5_api.h
+++ b/src/plugins/acct_gather_profile/hdf5/hdf5_api.h
@@ -45,17 +45,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdlib.h>
 
 #include <hdf5.h>
diff --git a/src/plugins/acct_gather_profile/hdf5/sh5util/libsh5util_old/hdf5_api.h b/src/plugins/acct_gather_profile/hdf5/sh5util/libsh5util_old/hdf5_api.h
index 001fc1ae610..c7dec5f5d2e 100644
--- a/src/plugins/acct_gather_profile/hdf5/sh5util/libsh5util_old/hdf5_api.h
+++ b/src/plugins/acct_gather_profile/hdf5/sh5util/libsh5util_old/hdf5_api.h
@@ -45,17 +45,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdlib.h>
 
 #include <hdf5.h>
diff --git a/src/plugins/acct_gather_profile/hdf5/sh5util/libsh5util_old/sh5util.c b/src/plugins/acct_gather_profile/hdf5/sh5util/libsh5util_old/sh5util.c
index 259cc8434f8..7266ed6253b 100644
--- a/src/plugins/acct_gather_profile/hdf5/sh5util/libsh5util_old/sh5util.c
+++ b/src/plugins/acct_gather_profile/hdf5/sh5util/libsh5util_old/sh5util.c
@@ -51,19 +51,14 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #include <dirent.h>
-#include <sys/stat.h>
 #include <fcntl.h>
+#include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/time.h>
+#include <sys/stat.h>
 
 #include "src/common/uid.h"
 #include "src/common/read_config.h"
diff --git a/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c b/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c
index 51c263083f4..2a115aecc36 100644
--- a/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c
+++ b/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c
@@ -51,18 +51,13 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #include <dirent.h>
-#include <sys/stat.h>
 #include <fcntl.h>
+#include <getopt.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
 #include <sys/time.h>
 
 #include "src/common/uid.h"
diff --git a/src/plugins/auth/munge/auth_munge.c b/src/plugins/auth/munge/auth_munge.c
index 7f27de5e8f7..c98305361f8 100644
--- a/src/plugins/auth/munge/auth_munge.c
+++ b/src/plugins/auth/munge/auth_munge.c
@@ -39,32 +39,15 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <time.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <time.h>
+#include <unistd.h>
 
 #include <munge.h>
 
diff --git a/src/plugins/auth/none/auth_none.c b/src/plugins/auth/none/auth_none.c
index 4f6cb9a216f..8a55c2dace4 100644
--- a/src/plugins/auth/none/auth_none.c
+++ b/src/plugins/auth/none/auth_none.c
@@ -39,30 +39,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm_errno.h"
 #include "src/common/slurm_xlator.h"
diff --git a/src/plugins/checkpoint/aix/checkpoint_aix.c b/src/plugins/checkpoint/aix/checkpoint_aix.c
index 307e8d7257e..d591edeefe5 100644
--- a/src/plugins/checkpoint/aix/checkpoint_aix.c
+++ b/src/plugins/checkpoint/aix/checkpoint_aix.c
@@ -41,16 +41,8 @@
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-#ifdef WITH_PTHREADS
-#  include <pthread.h>
-#endif
-
+#include <inttypes.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdio.h>
 #include <time.h>
diff --git a/src/plugins/checkpoint/blcr/checkpoint_blcr.c b/src/plugins/checkpoint/blcr/checkpoint_blcr.c
index ed70858ed03..039e73d7f9d 100644
--- a/src/plugins/checkpoint/blcr/checkpoint_blcr.c
+++ b/src/plugins/checkpoint/blcr/checkpoint_blcr.c
@@ -39,22 +39,14 @@
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-#ifdef WITH_PTHREADS
-#  include <pthread.h>
-#endif
-
+#include <inttypes.h>
+#include <libgen.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <unistd.h>
-#include <libgen.h>
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/stat.h>
diff --git a/src/plugins/checkpoint/none/checkpoint_none.c b/src/plugins/checkpoint/none/checkpoint_none.c
index 469d668b27b..9f78cc80979 100644
--- a/src/plugins/checkpoint/none/checkpoint_none.c
+++ b/src/plugins/checkpoint/none/checkpoint_none.c
@@ -41,13 +41,7 @@
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
+#include <inttypes.h>
 #include <stdio.h>
 
 #include "slurm/slurm.h"
diff --git a/src/plugins/checkpoint/ompi/checkpoint_ompi.c b/src/plugins/checkpoint/ompi/checkpoint_ompi.c
index 6def4764db9..04561809f43 100644
--- a/src/plugins/checkpoint/ompi/checkpoint_ompi.c
+++ b/src/plugins/checkpoint/ompi/checkpoint_ompi.c
@@ -41,13 +41,7 @@
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
+#include <inttypes.h>
 #include <stdio.h>
 
 #include "slurm/slurm.h"
diff --git a/src/plugins/checkpoint/poe/checkpoint_poe.c b/src/plugins/checkpoint/poe/checkpoint_poe.c
index 1926569025b..2bda9df6d93 100644
--- a/src/plugins/checkpoint/poe/checkpoint_poe.c
+++ b/src/plugins/checkpoint/poe/checkpoint_poe.c
@@ -47,16 +47,8 @@
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-#ifdef WITH_PTHREADS
-#  include <pthread.h>
-#endif
-
+#include <inttypes.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdio.h>
 #include <time.h>
diff --git a/src/plugins/core_spec/cray/core_spec_cray.c b/src/plugins/core_spec/cray/core_spec_cray.c
index 2713f94e86a..f35401860e7 100644
--- a/src/plugins/core_spec/cray/core_spec_cray.c
+++ b/src/plugins/core_spec/cray/core_spec_cray.c
@@ -36,30 +36,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/core_spec/none/core_spec_none.c b/src/plugins/core_spec/none/core_spec_none.c
index 2d4749d159f..2a322cfc484 100644
--- a/src/plugins/core_spec/none/core_spec_none.c
+++ b/src/plugins/core_spec/none/core_spec_none.c
@@ -36,30 +36,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/crypto/munge/crypto_munge.c b/src/plugins/crypto/munge/crypto_munge.c
index 14947c82ef5..5db95b605e0 100644
--- a/src/plugins/crypto/munge/crypto_munge.c
+++ b/src/plugins/crypto/munge/crypto_munge.c
@@ -39,23 +39,14 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <stdint.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
-#define GPL_LICENSED 1
 #include <munge.h>
 
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/crypto/openssl/crypto_openssl.c b/src/plugins/crypto/openssl/crypto_openssl.c
index 2fa9767aaee..914f6212ed9 100644
--- a/src/plugins/crypto/openssl/crypto_openssl.c
+++ b/src/plugins/crypto/openssl/crypto_openssl.c
@@ -39,17 +39,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <stdint.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
 
 /*
diff --git a/src/plugins/gres/gpu/gres_gpu.c b/src/plugins/gres/gpu/gres_gpu.c
index d5a1bd66eb6..effa14dc041 100644
--- a/src/plugins/gres/gpu/gres_gpu.c
+++ b/src/plugins/gres/gpu/gres_gpu.c
@@ -39,33 +39,16 @@
 #define _GNU_SOURCE
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
 #include <ctype.h>
+#include <inttypes.h>
 #include <sched.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/gres/mic/gres_mic.c b/src/plugins/gres/mic/gres_mic.c
index f91d75d17af..8d92b1fe444 100644
--- a/src/plugins/gres/mic/gres_mic.c
+++ b/src/plugins/gres/mic/gres_mic.c
@@ -40,32 +40,15 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <ctype.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <ctype.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/gres/nic/gres_nic.c b/src/plugins/gres/nic/gres_nic.c
index f53d45c23e7..31977e8f8bd 100644
--- a/src/plugins/gres/nic/gres_nic.c
+++ b/src/plugins/gres/nic/gres_nic.c
@@ -38,32 +38,15 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
 #include <ctype.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/job_submit/all_partitions/job_submit_all_partitions.c b/src/plugins/job_submit/all_partitions/job_submit_all_partitions.c
index 2d00244771d..d5bc0123d63 100644
--- a/src/plugins/job_submit/all_partitions/job_submit_all_partitions.c
+++ b/src/plugins/job_submit/all_partitions/job_submit_all_partitions.c
@@ -39,30 +39,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm_errno.h"
 #include "src/common/slurm_xlator.h"
diff --git a/src/plugins/job_submit/cray/job_submit_cray.c b/src/plugins/job_submit/cray/job_submit_cray.c
index f8b12393af9..5aeea221f47 100644
--- a/src/plugins/job_submit/cray/job_submit_cray.c
+++ b/src/plugins/job_submit/cray/job_submit_cray.c
@@ -38,30 +38,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm_errno.h"
 #include "src/common/slurm_xlator.h"
diff --git a/src/plugins/job_submit/defaults/job_submit_defaults.c b/src/plugins/job_submit/defaults/job_submit_defaults.c
index 3c9402be626..ca8f6eae9ab 100644
--- a/src/plugins/job_submit/defaults/job_submit_defaults.c
+++ b/src/plugins/job_submit/defaults/job_submit_defaults.c
@@ -38,30 +38,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm_errno.h"
 #include "src/common/slurm_xlator.h"
diff --git a/src/plugins/job_submit/logging/job_submit_logging.c b/src/plugins/job_submit/logging/job_submit_logging.c
index a6ec3a0f666..5894ce99f50 100644
--- a/src/plugins/job_submit/logging/job_submit_logging.c
+++ b/src/plugins/job_submit/logging/job_submit_logging.c
@@ -38,30 +38,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/job_submit/lua/job_submit_lua.c b/src/plugins/job_submit/lua/job_submit_lua.c
index 7728675fb2b..e81876d8d09 100644
--- a/src/plugins/job_submit/lua/job_submit_lua.c
+++ b/src/plugins/job_submit/lua/job_submit_lua.c
@@ -41,17 +41,11 @@
 #   include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
 #include <dlfcn.h>
+#include <inttypes.h>
 #include <pthread.h>
-#include <stdio.h>
 #include <signal.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <sys/types.h>
diff --git a/src/plugins/job_submit/partition/job_submit_partition.c b/src/plugins/job_submit/partition/job_submit_partition.c
index b373b77dcc3..ba275e52ae8 100644
--- a/src/plugins/job_submit/partition/job_submit_partition.c
+++ b/src/plugins/job_submit/partition/job_submit_partition.c
@@ -39,30 +39,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm_errno.h"
 #include "src/common/slurm_xlator.h"
diff --git a/src/plugins/job_submit/pbs/job_submit_pbs.c b/src/plugins/job_submit/pbs/job_submit_pbs.c
index 7b3264c7a82..fc61319b32b 100644
--- a/src/plugins/job_submit/pbs/job_submit_pbs.c
+++ b/src/plugins/job_submit/pbs/job_submit_pbs.c
@@ -39,22 +39,14 @@
 #   include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <stdio.h>
-
-#include <sys/types.h>
+#include <dlfcn.h>
+#include <inttypes.h>
+#include <pthread.h>
 #include <signal.h>
+#include <stdio.h>
 #include <stdlib.h>
+#include <sys/types.h>
 #include <unistd.h>
-#include <dlfcn.h>
-#include <pthread.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/job_submit/throttle/job_submit_throttle.c b/src/plugins/job_submit/throttle/job_submit_throttle.c
index 896067df5a0..4a84e758f84 100644
--- a/src/plugins/job_submit/throttle/job_submit_throttle.c
+++ b/src/plugins/job_submit/throttle/job_submit_throttle.c
@@ -40,30 +40,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm_errno.h"
 #include "src/common/slurm_xlator.h"
diff --git a/src/plugins/jobcomp/elasticsearch/jobcomp_elasticsearch.c b/src/plugins/jobcomp/elasticsearch/jobcomp_elasticsearch.c
index d185acded4c..1d6728e2b9e 100644
--- a/src/plugins/jobcomp/elasticsearch/jobcomp_elasticsearch.c
+++ b/src/plugins/jobcomp/elasticsearch/jobcomp_elasticsearch.c
@@ -40,15 +40,9 @@
 #   include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
 #include <curl/curl.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <grp.h>
 #include <pwd.h>
 #include <stdlib.h>
@@ -56,6 +50,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+
 #include "src/common/assoc_mgr.h"
 #include "src/common/fd.h"
 #include "src/common/list.h"
diff --git a/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c b/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c
index 633478dce0d..a706b72b715 100644
--- a/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c
+++ b/src/plugins/jobcomp/filetxt/jobcomp_filetxt.c
@@ -40,17 +40,12 @@
 #   include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
 #include <fcntl.h>
-#include <pwd.h>
 #include <grp.h>
+#include <inttypes.h>
+#include <pwd.h>
 #include <unistd.h>
+
 #include "src/common/slurm_protocol_defs.h"
 #include "src/common/slurm_jobcomp.h"
 #include "src/common/parse_time.h"
diff --git a/src/plugins/jobcomp/none/jobcomp_none.c b/src/plugins/jobcomp/none/jobcomp_none.c
index 0f8c978027f..c993abd9fcf 100644
--- a/src/plugins/jobcomp/none/jobcomp_none.c
+++ b/src/plugins/jobcomp/none/jobcomp_none.c
@@ -40,13 +40,7 @@
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
+#include <inttypes.h>
 #include <stdio.h>
 
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/jobcomp/script/jobcomp_script.c b/src/plugins/jobcomp/script/jobcomp_script.c
index 7af27162331..35f201f8922 100644
--- a/src/plugins/jobcomp/script/jobcomp_script.c
+++ b/src/plugins/jobcomp/script/jobcomp_script.c
@@ -67,27 +67,21 @@
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
 #if HAVE_PATHS_H
 #  include <paths.h>
 #endif
 
+#include <fcntl.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdarg.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <fcntl.h>
+#include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
-#include <pthread.h>
-#include <signal.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/mpi/mpichgm/mpichgm.c b/src/plugins/mpi/mpichgm/mpichgm.c
index 2365b330218..62186d14497 100644
--- a/src/plugins/mpi/mpichgm/mpichgm.c
+++ b/src/plugins/mpi/mpichgm/mpichgm.c
@@ -49,7 +49,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include <strings.h>
+#include <string.h>
 
 #include "src/common/slurm_xlator.h"
 #include "src/common/net.h"
diff --git a/src/plugins/mpi/mpichmx/mpichmx.c b/src/plugins/mpi/mpichmx/mpichmx.c
index adf0a32529e..18a0f394c5e 100644
--- a/src/plugins/mpi/mpichmx/mpichmx.c
+++ b/src/plugins/mpi/mpichmx/mpichmx.c
@@ -49,7 +49,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include <strings.h>
+#include <string.h>
 
 #include "src/common/slurm_xlator.h"
 #include "src/common/net.h"
diff --git a/src/plugins/mpi/mvapich/mvapich.c b/src/plugins/mpi/mvapich/mvapich.c
index 02f416fa8e0..e41522d5df3 100644
--- a/src/plugins/mpi/mvapich/mvapich.c
+++ b/src/plugins/mpi/mvapich/mvapich.c
@@ -49,7 +49,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include <strings.h>
+#include <string.h>
 #include <poll.h>
 #include <sys/time.h>
 
diff --git a/src/plugins/mpi/pmi2/client.h b/src/plugins/mpi/pmi2/client.h
index 85bbe77bcb9..ce6461c8070 100644
--- a/src/plugins/mpi/pmi2/client.h
+++ b/src/plugins/mpi/pmi2/client.h
@@ -40,16 +40,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 #include "spawn.h"
 
diff --git a/src/plugins/mpi/pmi2/info.h b/src/plugins/mpi/pmi2/info.h
index 095f955f057..97a2bd42107 100644
--- a/src/plugins/mpi/pmi2/info.h
+++ b/src/plugins/mpi/pmi2/info.h
@@ -40,16 +40,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 extern char *job_attr_get(char *key);
 extern char *node_attr_get(char *key);
diff --git a/src/plugins/mpi/pmi2/setup.h b/src/plugins/mpi/pmi2/setup.h
index 0e0a91cedde..fed054e1151 100644
--- a/src/plugins/mpi/pmi2/setup.h
+++ b/src/plugins/mpi/pmi2/setup.h
@@ -43,25 +43,17 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
+
+#include "slurm/slurm_errno.h"
 
-#include <slurm/slurm_errno.h>
 #include "src/common/slurm_xlator.h"
 #include "src/common/pack.h"
 #include "src/common/slurm_mpi.h"
 #include "src/common/xstring.h"
-
 #include "src/slurmd/slurmstepd/slurmstepd_job.h"
-
 #include "src/srun/libsrun/debugger.h"
 #include "src/srun/libsrun/opt.h"
 
diff --git a/src/plugins/mpi/pmi2/spawn.h b/src/plugins/mpi/pmi2/spawn.h
index 4e534666bce..6c15e57f877 100644
--- a/src/plugins/mpi/pmi2/spawn.h
+++ b/src/plugins/mpi/pmi2/spawn.h
@@ -40,16 +40,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 #include "src/common/pack.h"
 
diff --git a/src/plugins/priority/basic/priority_basic.c b/src/plugins/priority/basic/priority_basic.c
index 16dce1fd518..ec6e1d923bd 100644
--- a/src/plugins/priority/basic/priority_basic.c
+++ b/src/plugins/priority/basic/priority_basic.c
@@ -40,15 +40,9 @@
 #  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <stdio.h>
+#include <inttypes.h>
 #include <math.h>
+#include <stdio.h>
 
 #include "slurm/slurm_errno.h"
 
diff --git a/src/plugins/priority/multifactor/priority_multifactor.c b/src/plugins/priority/multifactor/priority_multifactor.c
index 617303a158e..78dd979c90f 100644
--- a/src/plugins/priority/multifactor/priority_multifactor.c
+++ b/src/plugins/priority/multifactor/priority_multifactor.c
@@ -47,30 +47,17 @@
 #  include "config.h"
 #endif
 
-#if HAVE_FLOAT_H
-#  include <float.h>
-#endif
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-#ifdef WITH_PTHREADS
-#  include <pthread.h>
-#endif				/* WITH_PTHREADS */
-#if HAVE_VALUES_H
-#  include <values.h>
-#endif
 #if HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
 #endif
 
-#include <sys/stat.h>
-#include <stdio.h>
 #include <fcntl.h>
-
+#include <limits.h>
 #include <math.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <sys/stat.h>
+
 #include "slurm/slurm_errno.h"
 
 #include "src/common/parse_time.h"
diff --git a/src/plugins/proctrack/aix/proctrack_aix.c b/src/plugins/proctrack/aix/proctrack_aix.c
index 434e533cfcf..299124d40d2 100644
--- a/src/plugins/proctrack/aix/proctrack_aix.c
+++ b/src/plugins/proctrack/aix/proctrack_aix.c
@@ -40,18 +40,12 @@
 #   include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <sys/types.h>
+#include <inttypes.h>
+#include <proctrack.h>
 #include <signal.h>
 #include <stdlib.h>
+#include <sys/types.h>
 #include <unistd.h>
-#include <proctrack.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/proctrack/cgroup/proctrack_cgroup.c b/src/plugins/proctrack/cgroup/proctrack_cgroup.c
index 4a1690ff5ec..9659d779205 100644
--- a/src/plugins/proctrack/cgroup/proctrack_cgroup.c
+++ b/src/plugins/proctrack/cgroup/proctrack_cgroup.c
@@ -38,18 +38,12 @@
 #include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-
 #include <fcntl.h>
+#include <inttypes.h>
 #include <signal.h>
 #include <stdlib.h>
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/proctrack/cray/proctrack_cray.c b/src/plugins/proctrack/cray/proctrack_cray.c
index 838029f9034..8c0533f6d63 100644
--- a/src/plugins/proctrack/cray/proctrack_cray.c
+++ b/src/plugins/proctrack/cray/proctrack_cray.c
@@ -42,20 +42,14 @@
 #   include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
+#include <dlfcn.h>
 #include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+#include <inttypes.h>
 #include <signal.h>
 #include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
-#include <dlfcn.h>
 
 #include <job.h>	/* Cray's job module component */
 
diff --git a/src/plugins/proctrack/linuxproc/kill_tree.c b/src/plugins/proctrack/linuxproc/kill_tree.c
index 83d792afef0..ec161c822c5 100644
--- a/src/plugins/proctrack/linuxproc/kill_tree.c
+++ b/src/plugins/proctrack/linuxproc/kill_tree.c
@@ -41,17 +41,16 @@
 #  include "config.h"
 #endif
 
-#include <sys/types.h>
 #include <dirent.h>
-#include <sys/stat.h>
 #include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
+#include <limits.h>
 #include <signal.h>
-#include <strings.h>
-#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c b/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c
index 5e97f32c852..17256268243 100644
--- a/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c
+++ b/src/plugins/proctrack/linuxproc/proctrack_linuxproc.c
@@ -37,18 +37,12 @@
 \*****************************************************************************/
 
 #if HAVE_CONFIG_H
-#   include "config.h"
+#  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <sys/types.h>
+#include <inttypes.h>
 #include <signal.h>	/* SIGKILL */
+#include <sys/types.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/proctrack/lua/proctrack_lua.c b/src/plugins/proctrack/lua/proctrack_lua.c
index 280c9f7b962..8712ddf4e72 100644
--- a/src/plugins/proctrack/lua/proctrack_lua.c
+++ b/src/plugins/proctrack/lua/proctrack_lua.c
@@ -37,22 +37,16 @@
 \*****************************************************************************/
 
 #if HAVE_CONFIG_H
-#   include "config.h"
+#  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <sys/types.h>
+#include <dlfcn.h>
+#include <inttypes.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdlib.h>
+#include <sys/types.h>
 #include <unistd.h>
-#include <dlfcn.h>
-#include <pthread.h>
 
 #include <lua.h>
 #include <lauxlib.h>
@@ -66,7 +60,6 @@
 #include "src/common/xlua.h"
 #include "src/slurmd/slurmstepd/slurmstepd_job.h"
 
-
 const char plugin_name[]            = "LUA proctrack module";
 const char plugin_type[]            = "proctrack/lua";
 const uint32_t plugin_version       = SLURM_VERSION_NUMBER;
diff --git a/src/plugins/proctrack/pgid/proctrack_pgid.c b/src/plugins/proctrack/pgid/proctrack_pgid.c
index 869136b1655..8c2eeb57263 100644
--- a/src/plugins/proctrack/pgid/proctrack_pgid.c
+++ b/src/plugins/proctrack/pgid/proctrack_pgid.c
@@ -40,26 +40,20 @@
 #   include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
 #ifndef   __USE_XOPEN_EXTENDED
 #  define __USE_XOPEN_EXTENDED /* getpgid */
 #endif
-#include <unistd.h>
 
 #include <dirent.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <limits.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/plugins/proctrack/sgi_job/proctrack_sgi_job.c b/src/plugins/proctrack/sgi_job/proctrack_sgi_job.c
index fcc5569df8a..35ed470aa7d 100644
--- a/src/plugins/proctrack/sgi_job/proctrack_sgi_job.c
+++ b/src/plugins/proctrack/sgi_job/proctrack_sgi_job.c
@@ -37,21 +37,15 @@
 \*****************************************************************************/
 
 #if HAVE_CONFIG_H
-#   include "config.h"
+#  include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <sys/types.h>
+#include <dlfcn.h>
+#include <inttypes.h>
 #include <signal.h>
 #include <stdlib.h>
+#include <sys/types.h>
 #include <unistd.h>
-#include <dlfcn.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
@@ -59,7 +53,6 @@
 
 #include "src/slurmd/slurmstepd/slurmstepd_job.h"
 
-
 const char plugin_name[]      = "Process tracking via SGI job module";
 const char plugin_type[]      = "proctrack/sgi_job";
 const uint32_t plugin_version = SLURM_VERSION_NUMBER;
diff --git a/src/plugins/sched/wiki/hostlist.c b/src/plugins/sched/wiki/hostlist.c
index 96d99899f79..58d5ab9c787 100644
--- a/src/plugins/sched/wiki/hostlist.c
+++ b/src/plugins/sched/wiki/hostlist.c
@@ -39,21 +39,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "./msg.h"
+#include "msg.h"
 #include "src/common/hostlist.h"
 #include "src/common/node_select.h"
 #include "src/common/xmalloc.h"
diff --git a/src/plugins/sched/wiki/job_modify.c b/src/plugins/sched/wiki/job_modify.c
index 762cc20520b..56232a3fced 100644
--- a/src/plugins/sched/wiki/job_modify.c
+++ b/src/plugins/sched/wiki/job_modify.c
@@ -37,7 +37,7 @@
 \*****************************************************************************/
 
 #include "./msg.h"
-#include <strings.h>
+#include <string.h>
 #include "src/slurmctld/job_scheduler.h"
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
diff --git a/src/plugins/sched/wiki/msg.h b/src/plugins/sched/wiki/msg.h
index 9d81afbfdc7..d15e636f80f 100644
--- a/src/plugins/sched/wiki/msg.h
+++ b/src/plugins/sched/wiki/msg.h
@@ -50,24 +50,16 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
 
 #include <ctype.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <strings.h>
-#include <unistd.h>
+#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm_errno.h"
 
diff --git a/src/plugins/sched/wiki2/hostlist.c b/src/plugins/sched/wiki2/hostlist.c
index 435e1fbd4d5..819597fa216 100644
--- a/src/plugins/sched/wiki2/hostlist.c
+++ b/src/plugins/sched/wiki2/hostlist.c
@@ -39,17 +39,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/src/plugins/sched/wiki2/initialize.c b/src/plugins/sched/wiki2/initialize.c
index af0f3b6d1ad..218f4fcc449 100644
--- a/src/plugins/sched/wiki2/initialize.c
+++ b/src/plugins/sched/wiki2/initialize.c
@@ -37,7 +37,7 @@
 \*****************************************************************************/
 
 #include "./msg.h"
-#include <strings.h>
+#include <string.h>
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 
diff --git a/src/plugins/sched/wiki2/job_modify.c b/src/plugins/sched/wiki2/job_modify.c
index 6cbb2d3aaa9..2bfe35cd6f1 100644
--- a/src/plugins/sched/wiki2/job_modify.c
+++ b/src/plugins/sched/wiki2/job_modify.c
@@ -38,7 +38,7 @@
 \*****************************************************************************/
 
 #include "./msg.h"
-#include <strings.h>
+#include <string.h>
 #include "src/common/gres.h"
 #include "src/common/node_select.h"
 #include "src/common/assoc_mgr.h"
diff --git a/src/plugins/sched/wiki2/job_notify.c b/src/plugins/sched/wiki2/job_notify.c
index 5cab0db1a6e..9487c832326 100644
--- a/src/plugins/sched/wiki2/job_notify.c
+++ b/src/plugins/sched/wiki2/job_notify.c
@@ -37,7 +37,7 @@
 \*****************************************************************************/
 
 #include "./msg.h"
-#include <strings.h>
+#include <string.h>
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 #include "src/slurmctld/srun_comm.h"
diff --git a/src/plugins/sched/wiki2/job_signal.c b/src/plugins/sched/wiki2/job_signal.c
index befc22d4ee7..2d725235072 100644
--- a/src/plugins/sched/wiki2/job_signal.c
+++ b/src/plugins/sched/wiki2/job_signal.c
@@ -37,7 +37,7 @@
 \*****************************************************************************/
 
 #include "./msg.h"
-#include <strings.h>
+#include <string.h>
 #include "src/slurmctld/locks.h"
 #include "src/slurmctld/slurmctld.h"
 
diff --git a/src/plugins/sched/wiki2/msg.h b/src/plugins/sched/wiki2/msg.h
index 0d77179d2f2..8cefdb0b9a4 100644
--- a/src/plugins/sched/wiki2/msg.h
+++ b/src/plugins/sched/wiki2/msg.h
@@ -50,24 +50,16 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
 
 #include <ctype.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <strings.h>
-#include <unistd.h>
+#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm_errno.h"
 
diff --git a/src/plugins/select/alps/libemulate/alps_emulate.c b/src/plugins/select/alps/libemulate/alps_emulate.c
index e6bf8c0e414..c55c6e412da 100644
--- a/src/plugins/select/alps/libemulate/alps_emulate.c
+++ b/src/plugins/select/alps/libemulate/alps_emulate.c
@@ -37,19 +37,16 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  endif
 #endif
+
+#include <inttypes.h>
 #include <stdlib.h>
 #include <unistd.h>
 
 #include "src/common/log.h"
 #include "src/common/node_conf.h"
 #include "src/common/xmalloc.h"
+
 #include "../basil_alps.h"
 #include "../parser_common.h"
 #include "hilbert.h"
diff --git a/src/plugins/select/alps/select_alps.c b/src/plugins/select/alps/select_alps.c
index 68c5330164e..810be202e48 100644
--- a/src/plugins/select/alps/select_alps.c
+++ b/src/plugins/select/alps/select_alps.c
@@ -40,16 +40,11 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  endif
 #endif
 
 #include "slurm/slurm.h"
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/src/plugins/select/bluegene/bg_job_run.c b/src/plugins/select/bluegene/bg_job_run.c
index ad432361271..e60454dac25 100644
--- a/src/plugins/select/bluegene/bg_job_run.c
+++ b/src/plugins/select/bluegene/bg_job_run.c
@@ -39,17 +39,10 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  endif
-#  if WITH_PTHREADS
-#    include <pthread.h>
-#  endif
 #endif
 
+#include <inttypes.h>
+#include <pthread.h>
 #include <signal.h>
 #include <unistd.h>
 
diff --git a/src/plugins/select/bluegene/sfree/sfree.h b/src/plugins/select/bluegene/sfree/sfree.h
index 83028ce31da..9ac2180f4b3 100644
--- a/src/plugins/select/bluegene/sfree/sfree.h
+++ b/src/plugins/select/bluegene/sfree/sfree.h
@@ -43,15 +43,11 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
+#include <getopt.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>		/* getenv     */
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "../bg_enums.h"
diff --git a/src/plugins/select/bluegene/slurm_epilog.c b/src/plugins/select/bluegene/slurm_epilog.c
index 589cc2e9bd6..3edc22ab297 100644
--- a/src/plugins/select/bluegene/slurm_epilog.c
+++ b/src/plugins/select/bluegene/slurm_epilog.c
@@ -42,13 +42,12 @@
 #  include "config.h"
 #endif
 
-#include <stdlib.h>
 #include <errno.h>
 #include <stdio.h>
-#include <unistd.h>
+#include <stdlib.h>
 #include <string.h>
-#include <strings.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 
diff --git a/src/plugins/select/bluegene/slurm_prolog.c b/src/plugins/select/bluegene/slurm_prolog.c
index 597ba3dec9a..3ac62220d27 100644
--- a/src/plugins/select/bluegene/slurm_prolog.c
+++ b/src/plugins/select/bluegene/slurm_prolog.c
@@ -47,7 +47,6 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
-#include <strings.h>
 #include <sys/types.h>
 
 #include "slurm/slurm.h"
diff --git a/src/plugins/select/cons_res/job_test.c b/src/plugins/select/cons_res/job_test.c
index a53a96047f7..2994cf05268 100644
--- a/src/plugins/select/cons_res/job_test.c
+++ b/src/plugins/select/cons_res/job_test.c
@@ -94,13 +94,9 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  endif
 #endif
+
+#include <inttypes.h>
 #include <time.h>
 
 #include "dist_tasks.h"
diff --git a/src/plugins/select/cons_res/select_cons_res.c b/src/plugins/select/cons_res/select_cons_res.c
index 5eaf6180132..f5d673ca335 100644
--- a/src/plugins/select/cons_res/select_cons_res.c
+++ b/src/plugins/select/cons_res/select_cons_res.c
@@ -97,23 +97,18 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  endif
 #endif
 
+#include <inttypes.h>
 #include <string.h>
 
 #include "src/common/slurm_xlator.h"
 #include "src/common/slurm_selecttype_info.h"
 #include "select_cons_res.h"
+
 #include "dist_tasks.h"
 #include "job_test.h"
 
-
 #define NODEINFO_MAGIC 0x82aa
 
 /* These are defined here so when we link with something other than
diff --git a/src/plugins/select/cray/ccm.h b/src/plugins/select/cray/ccm.h
index 69f529fa223..a04f8121566 100644
--- a/src/plugins/select/cray/ccm.h
+++ b/src/plugins/select/cray/ccm.h
@@ -38,22 +38,15 @@
 #ifndef SELECT_CRAY_CCM_H
 #define SELECT_CRAY_CCM_H
 
-#include "src/common/slurm_xlator.h"
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  endif
-#  if WITH_PTHREADS
-#    include <pthread.h>
-#  endif
 #endif
 
-/* CCM use */
+#include <inttypes.h>
+#include <pthread.h>
 #include <string.h>
+
+#include "src/common/slurm_xlator.h"
 #include "src/slurmctld/job_scheduler.h"
 #include "src/slurmctld/srun_comm.h"
 
diff --git a/src/plugins/select/linear/select_linear.c b/src/plugins/select/linear/select_linear.c
index c02e36fa25b..e73434a3a89 100644
--- a/src/plugins/select/linear/select_linear.c
+++ b/src/plugins/select/linear/select_linear.c
@@ -47,14 +47,9 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  endif
 #endif
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
diff --git a/src/plugins/select/serial/job_test.c b/src/plugins/select/serial/job_test.c
index afe13082efd..1d4551acae2 100644
--- a/src/plugins/select/serial/job_test.c
+++ b/src/plugins/select/serial/job_test.c
@@ -37,13 +37,9 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  endif
 #endif
+
+#include <inttypes.h>
 #include <time.h>
 
 #include "dist_tasks.h"
diff --git a/src/plugins/select/serial/select_serial.c b/src/plugins/select/serial/select_serial.c
index 9e98b28c66f..1ebde3d5c15 100644
--- a/src/plugins/select/serial/select_serial.c
+++ b/src/plugins/select/serial/select_serial.c
@@ -34,14 +34,10 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  endif
 #endif
 
+#include <inttypes.h>
+
 #include "src/common/slurm_xlator.h"
 #include "src/common/slurm_selecttype_info.h"
 #include "select_serial.h"
diff --git a/src/plugins/slurmctld/nonstop/do_work.c b/src/plugins/slurmctld/nonstop/do_work.c
index 48098afb40b..6de5de17144 100644
--- a/src/plugins/slurmctld/nonstop/do_work.c
+++ b/src/plugins/slurmctld/nonstop/do_work.c
@@ -36,16 +36,10 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif
 #endif
 
 #include <fcntl.h>
+#include <inttypes.h>
 #include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
@@ -55,8 +49,8 @@
 #include <time.h>
 #include <unistd.h>
 
-//#include "slurm/slurmdb.h"
 #include "slurm/smd_ns.h"
+
 #include "src/common/slurm_xlator.h"	/* Must be first */
 #include "src/common/bitstring.h"
 #include "src/common/job_resources.h"
diff --git a/src/plugins/slurmctld/nonstop/read_config.h b/src/plugins/slurmctld/nonstop/read_config.h
index c11795627ec..5b8236d88e8 100644
--- a/src/plugins/slurmctld/nonstop/read_config.h
+++ b/src/plugins/slurmctld/nonstop/read_config.h
@@ -40,24 +40,12 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_STDBOOL_H
-#    include <stdbool.h>
-#  else
-     typedef enum {false, true} bool;
-#  endif			/* !HAVE_STDBOOL_H */
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
 #endif
 
-#define GPL_LICENSED 1
+#include <inttypes.h>
 #include <munge.h>
-#include <unistd.h>
 #include <sys/types.h>
+#include <unistd.h>
 
 #define DEFAULT_NONSTOP_PORT		6820
 
diff --git a/src/sacct/sacct.h b/src/sacct/sacct.h
index 3380b0a271b..04915562d95 100644
--- a/src/sacct/sacct.h
+++ b/src/sacct/sacct.h
@@ -51,7 +51,6 @@
 #include <time.h>
 #include <unistd.h>
 
-#include "src/common/getopt.h"
 #include "src/common/xmalloc.h"
 #include "src/common/xstring.h"
 #include "src/common/list.h"
diff --git a/src/sacctmgr/sacctmgr.h b/src/sacctmgr/sacctmgr.h
index c01da83e733..980c57568f3 100644
--- a/src/sacctmgr/sacctmgr.h
+++ b/src/sacctmgr/sacctmgr.h
@@ -44,22 +44,13 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #include <ctype.h>
 #include <errno.h>
+#include <getopt.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef HAVE_STRING_H
-#  include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
+#include <string.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -68,14 +59,6 @@
 #  include <readline/history.h>
 #endif
 
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-
 #include "slurm/slurm.h"
 
 #include "src/common/slurm_jobacct_gather.h"
diff --git a/src/salloc/opt.c b/src/salloc/opt.c
index 4a02d079a27..3229261d90b 100644
--- a/src/salloc/opt.c
+++ b/src/salloc/opt.c
@@ -42,38 +42,27 @@
 #  include "config.h"
 #endif
 
-#include <string.h>		/* strcpy, strncasecmp */
-
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
-
 #ifndef _GNU_SOURCE
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #ifdef HAVE_LIMITS_H
 #  include <limits.h>
 #endif
 
 #include <fcntl.h>
+#include <getopt.h>
+#include <pwd.h>		/* getpwuid   */
+#include <ctype.h>		/* isdigit    */
 #include <stdarg.h>		/* va_start   */
 #include <stdio.h>
 #include <stdlib.h>		/* getenv, strtol, etc. */
-#include <pwd.h>		/* getpwuid   */
-#include <ctype.h>		/* isdigit    */
+#include <string.h>		/* strcpy, strncasecmp */
 #include <sys/param.h>		/* MAXPATHLEN */
 #include <sys/stat.h>
-#include <unistd.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 #include "src/common/cpu_frequency.h"
 #include "src/common/list.h"
diff --git a/src/sattach/opt.c b/src/sattach/opt.c
index 7b247b3ac34..01b5eca676a 100644
--- a/src/sattach/opt.c
+++ b/src/sattach/opt.c
@@ -29,37 +29,27 @@
 #  include "config.h"
 #endif
 
-#include <string.h>		/* strcpy, strncasecmp */
-
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
 
 #ifndef _GNU_SOURCE
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #ifdef HAVE_LIMITS_H
 #  include <limits.h>
 #endif
 
+#include <ctype.h>		/* isdigit    */
 #include <fcntl.h>
+#include <getopt.h>
 #include <stdarg.h>		/* va_start   */
 #include <stdio.h>
 #include <stdlib.h>		/* getenv     */
-#include <ctype.h>		/* isdigit    */
+#include <string.h>		/* strcpy, strncasecmp */
 #include <sys/param.h>		/* MAXPATHLEN */
 #include <sys/stat.h>
-#include <unistd.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 #include "src/common/list.h"
 #include "src/common/log.h"
diff --git a/src/sbatch/opt.c b/src/sbatch/opt.c
index 2ddb96663af..9de467f68f1 100644
--- a/src/sbatch/opt.c
+++ b/src/sbatch/opt.c
@@ -42,38 +42,26 @@
 #  include "config.h"
 #endif
 
-#include <string.h>		/* strcpy, strncasecmp */
-
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
-
 #ifndef _GNU_SOURCE
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #ifdef HAVE_LIMITS_H
 #  include <limits.h>
 #endif
 
 #include <ctype.h>
 #include <fcntl.h>
+#include <getopt.h>
 #include <stdarg.h>		/* va_start   */
 #include <stdio.h>
 #include <stdlib.h>		/* getenv     */
-#include <ctype.h>		/* isdigit    */
+#include <string.h>		/* strcpy, strncasecmp */
 #include <sys/param.h>		/* MAXPATHLEN */
 #include <sys/stat.h>
-#include <unistd.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/utsname.h>
+#include <unistd.h>
 
 #include "src/common/cpu_frequency.h"
 #include "src/common/list.h"
diff --git a/src/sbcast/opts.c b/src/sbcast/opts.c
index 9c7bcb1015c..66796582cb6 100644
--- a/src/sbcast/opts.c
+++ b/src/sbcast/opts.c
@@ -45,12 +45,7 @@
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
+#include <getopt.h>
 #include <limits.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/src/scancel/opt.c b/src/scancel/opt.c
index 19a459ffd8d..1e9bac1ec7a 100644
--- a/src/scancel/opt.c
+++ b/src/scancel/opt.c
@@ -46,12 +46,7 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
+#include <getopt.h>
 #include <pwd.h>
 #include <signal.h>
 #include <stdlib.h>
@@ -59,10 +54,6 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
-
 #include "src/common/log.h"
 #include "src/common/macros.h"
 #include "src/common/slurm_protocol_defs.h"
diff --git a/src/scancel/scancel.c b/src/scancel/scancel.c
index 74cf09b37e6..3f9e2a5c1f1 100644
--- a/src/scancel/scancel.c
+++ b/src/scancel/scancel.c
@@ -42,21 +42,14 @@
 #  include "config.h"
 #endif
 
-#include <unistd.h>
 #include <errno.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <signal.h>
-#include <pthread.h>
-
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 
diff --git a/src/scontrol/scontrol.h b/src/scontrol/scontrol.h
index ea77d3b3053..af95ab458ee 100644
--- a/src/scontrol/scontrol.h
+++ b/src/scontrol/scontrol.h
@@ -44,22 +44,13 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #include <ctype.h>
 #include <errno.h>
+#include <getopt.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef HAVE_STRING_H
-#  include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
+#include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <time.h>
@@ -70,14 +61,6 @@
 #  include <readline/history.h>
 #endif
 
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-
 #include "slurm/slurm.h"
 
 #include "src/common/hostlist.h"
diff --git a/src/sdiag/opts.c b/src/sdiag/opts.c
index 8160ffbeb13..20925a5d873 100644
--- a/src/sdiag/opts.c
+++ b/src/sdiag/opts.c
@@ -42,12 +42,7 @@
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
+#include <getopt.h>
 #include <stdlib.h>
 #include <unistd.h>
 
diff --git a/src/sinfo/opts.c b/src/sinfo/opts.c
index 96b171c6f6f..cc1f6253203 100644
--- a/src/sinfo/opts.c
+++ b/src/sinfo/opts.c
@@ -46,12 +46,7 @@
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
+#include <getopt.h>
 #include <stdlib.h>
 #include <unistd.h>
 
diff --git a/src/sinfo/sinfo.h b/src/sinfo/sinfo.h
index 3c8f685d2fe..cbb8906f7e0 100644
--- a/src/sinfo/sinfo.h
+++ b/src/sinfo/sinfo.h
@@ -46,20 +46,13 @@
 #endif
 
 #include <ctype.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
 
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-
 #include "slurm/slurm.h"
 
 #include "src/common/hostlist.h"
diff --git a/src/slurmctld/burst_buffer.c b/src/slurmctld/burst_buffer.c
index 13c0e5ba587..7b82f351e8e 100644
--- a/src/slurmctld/burst_buffer.c
+++ b/src/slurmctld/burst_buffer.c
@@ -36,29 +36,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c
index b357fc6e867..1c7ab9f91fd 100644
--- a/src/slurmctld/job_mgr.c
+++ b/src/slurmctld/job_mgr.c
@@ -53,7 +53,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/param.h>
diff --git a/src/slurmctld/job_submit.c b/src/slurmctld/job_submit.c
index 7216d5535a7..64b43903f8f 100644
--- a/src/slurmctld/job_submit.c
+++ b/src/slurmctld/job_submit.c
@@ -38,29 +38,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/slurmctld/slurmctld.h b/src/slurmctld/slurmctld.h
index dba1df43fcb..11d731ffd77 100644
--- a/src/slurmctld/slurmctld.h
+++ b/src/slurmctld/slurmctld.h
@@ -41,29 +41,17 @@
 #ifndef _HAVE_SLURMCTLD_H
 #define _HAVE_SLURMCTLD_H
 
-
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
 #endif
 
+#include <inttypes.h>
 #include <pthread.h>
-/* #include <stdlib.h> */
 #include <time.h>
-#include <strings.h>
+#include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
 
-#ifdef WITH_PTHREADS
-#  include <pthread.h>
-#endif				/* WITH_PTHREADS */
-
 #include "slurm/slurm.h"
 
 #include "src/common/bitstring.h"
diff --git a/src/slurmctld/slurmctld_plugstack.c b/src/slurmctld/slurmctld_plugstack.c
index bc134d1e57e..25a2adc686b 100644
--- a/src/slurmctld/slurmctld_plugstack.c
+++ b/src/slurmctld/slurmctld_plugstack.c
@@ -36,29 +36,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c
index de253d06d5c..e0987819437 100644
--- a/src/slurmctld/step_mgr.c
+++ b/src/slurmctld/step_mgr.c
@@ -42,16 +42,15 @@
 #  include "config.h"
 #endif
 
-#include <time.h>
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/param.h>
-#include <string.h>
-#include <strings.h>
+#include <time.h>
 #include <unistd.h>
 
 #include "slurm/slurm_errno.h"
diff --git a/src/slurmd/common/reverse_tree_math.h b/src/slurmd/common/reverse_tree_math.h
index 40d7bc6e7bb..294779c96c7 100644
--- a/src/slurmd/common/reverse_tree_math.h
+++ b/src/slurmd/common/reverse_tree_math.h
@@ -44,16 +44,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 #include "src/slurmd/common/reverse_tree.h"
 
diff --git a/src/slurmd/common/xcgroup.c b/src/slurmd/common/xcgroup.c
index ba164a02441..617d9b1a162 100644
--- a/src/slurmd/common/xcgroup.c
+++ b/src/slurmd/common/xcgroup.c
@@ -38,23 +38,16 @@
 #   include "config.h"
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <sys/file.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+#include <dirent.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
-#include <dirent.h>
+#include <sys/file.h>
 #include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/slurmd/common/xcpuinfo.c b/src/slurmd/common/xcpuinfo.c
index 8f325544ac9..819afd96bf2 100644
--- a/src/slurmd/common/xcpuinfo.c
+++ b/src/slurmd/common/xcpuinfo.c
@@ -36,27 +36,21 @@
 \*****************************************************************************/
 
 #if HAVE_CONFIG_H
-#   include "config.h"
+#  include "config.h"
 #endif
 
 #ifndef   _GNU_SOURCE
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
 #include <ctype.h>
 #include <fcntl.h>
+#include <inttypes.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#include <strings.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/slurmd/slurmd/get_mach_stat.h b/src/slurmd/slurmd/get_mach_stat.h
index 951586419de..323b825df1f 100644
--- a/src/slurmd/slurmd/get_mach_stat.h
+++ b/src/slurmd/slurmd/get_mach_stat.h
@@ -40,16 +40,9 @@
 #define _GET_MACH_STAT_H
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif  /*  HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 
 extern int get_cpu_load(uint32_t *cpu_load);
 extern int get_free_mem(uint32_t *free_mem);
diff --git a/src/slurmd/slurmd/slurmd.h b/src/slurmd/slurmd/slurmd.h
index 68970f4116b..efd4e7d79da 100644
--- a/src/slurmd/slurmd/slurmd.h
+++ b/src/slurmd/slurmd/slurmd.h
@@ -41,17 +41,9 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif			/* HAVE_INTTYPES_H */
-#else				/* !HAVE_CONFIG_H */
-#  include <inttypes.h>
-#endif				/*  HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <pthread.h>
 #include <sys/types.h>
 
diff --git a/src/slurmd/slurmd/slurmd_plugstack.c b/src/slurmd/slurmd/slurmd_plugstack.c
index 3dbab18ad95..9d9d3a72a8d 100644
--- a/src/slurmd/slurmd/slurmd_plugstack.c
+++ b/src/slurmd/slurmd/slurmd_plugstack.c
@@ -36,29 +36,13 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#  if STDC_HEADERS
-#    include <string.h>
-#  endif
-#  if HAVE_SYS_TYPES_H
-#    include <sys/types.h>
-#  endif /* HAVE_SYS_TYPES_H */
-#  if HAVE_UNISTD_H
-#    include <unistd.h>
-#  endif
-#  if HAVE_INTTYPES_H
-#    include <inttypes.h>
-#  else /* ! HAVE_INTTYPES_H */
-#    if HAVE_STDINT_H
-#      include <stdint.h>
-#    endif
-#  endif /* HAVE_INTTYPES_H */
-#else /* ! HAVE_CONFIG_H */
-#  include <sys/types.h>
-#  include <unistd.h>
-#  include <stdint.h>
-#  include <string.h>
-#endif /* HAVE_CONFIG_H */
+#endif
+
+#include <inttypes.h>
 #include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #include "slurm/slurm.h"
 #include "slurm/slurm_errno.h"
diff --git a/src/slurmdbd/read_config.h b/src/slurmdbd/read_config.h
index c80b52067b9..b73294a9a0c 100644
--- a/src/slurmdbd/read_config.h
+++ b/src/slurmdbd/read_config.h
@@ -42,19 +42,12 @@
 
 #if HAVE_CONFIG_H
 #  include "config.h"
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-#else   /* !HAVE_CONFIG_H */
-#include <stdint.h>
-#endif  /* HAVE_CONFIG_H */
+#endif
 
+#include <inttypes.h>
 #include <time.h>
 #include <pthread.h>
+
 #include "src/common/list.h"
 
 #define DEFAULT_SLURMDBD_AUTHTYPE	"auth/none"
diff --git a/src/smap/smap.h b/src/smap/smap.h
index 605a28b8009..adad2486340 100644
--- a/src/smap/smap.h
+++ b/src/smap/smap.h
@@ -48,20 +48,6 @@
 #  include "config.h"
 #endif
 
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else				/* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif				/* HAVE_INTTYPES_H */
-
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 /*
  * The following define is necessary for OS X 10.6. The apple supplied
  * ncurses.h sets NCURSES_OPAQUE to 1 and then we can't get to the WINDOW
@@ -90,14 +76,17 @@
 #ifdef lines
 #  undef lines
 #endif
+
 #ifndef SYSTEM_DIMENSIONS
 #  define SYSTEM_DIMENSIONS 1
 #endif
 
-#include <stdlib.h>
-#include <pwd.h>
 #include <ctype.h>
+#include <getopt.h>
+#include <inttypes.h>
+#include <pwd.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
diff --git a/src/sprio/opts.c b/src/sprio/opts.c
index 07579b756b0..bde0e29e125 100644
--- a/src/sprio/opts.c
+++ b/src/sprio/opts.c
@@ -44,12 +44,7 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
+#include <getopt.h>
 #include <pwd.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/sprio/sprio.c b/src/sprio/sprio.c
index 63905c39c36..138f414d75e 100644
--- a/src/sprio/sprio.c
+++ b/src/sprio/sprio.c
@@ -40,14 +40,6 @@
 #  include "config.h"
 #endif /* HAVE_CONFIG_H */
 
-#if HAVE_STDINT_H
-#  include <stdint.h>
-#endif
-
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#endif
-
 #ifdef HAVE_TERMCAP_H
 #  include <termcap.h>
 #endif
diff --git a/src/sprio/sprio.h b/src/sprio/sprio.h
index 8d35e13b500..48699c2054a 100644
--- a/src/sprio/sprio.h
+++ b/src/sprio/sprio.h
@@ -44,16 +44,8 @@
 #endif
 
 #include <ctype.h>
+#include <inttypes.h>
 #include <stdio.h>
-
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
diff --git a/src/squeue/opts.c b/src/squeue/opts.c
index 3ed69f61ff5..8c0e4f787ee 100644
--- a/src/squeue/opts.c
+++ b/src/squeue/opts.c
@@ -46,12 +46,7 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
+#include <getopt.h>
 #include <pwd.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/src/squeue/squeue.h b/src/squeue/squeue.h
index f8842062402..94ed194c846 100644
--- a/src/squeue/squeue.h
+++ b/src/squeue/squeue.h
@@ -45,16 +45,8 @@
 #endif
 
 #include <ctype.h>
+#include <inttypes.h>
 #include <stdio.h>
-
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
diff --git a/src/sreport/sreport.h b/src/sreport/sreport.h
index a513efae156..412a28f58f9 100644
--- a/src/sreport/sreport.h
+++ b/src/sreport/sreport.h
@@ -45,22 +45,13 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #include <ctype.h>
 #include <errno.h>
+#include <getopt.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef HAVE_STRING_H
-#  include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
+#include <string.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -69,14 +60,6 @@
 #  include <readline/history.h>
 #endif
 
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-
 #include "slurm/slurm.h"
 #include "slurm/slurmdb.h"
 
diff --git a/src/srun/libsrun/opt.c b/src/srun/libsrun/opt.c
index b2859647372..9f13978ac66 100644
--- a/src/srun/libsrun/opt.c
+++ b/src/srun/libsrun/opt.c
@@ -42,31 +42,21 @@
 #  include "config.h"
 #endif
 
-#include <string.h>		/* strcpy, strncasecmp */
-#include <ctype.h>      /* isdigit() */
-
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
-
 #ifndef _GNU_SOURCE
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #ifdef HAVE_LIMITS_H
 #  include <limits.h>
 #endif
 
+#include <ctype.h>		/* isdigit() */
 #include <fcntl.h>
+#include <getopt.h>
 #include <stdarg.h>		/* va_start   */
 #include <stdio.h>
 #include <stdlib.h>		/* getenv     */
+#include <string.h>		/* strcpy, strncasecmp */
 #include <sys/param.h>		/* MAXPATHLEN */
 #include <sys/stat.h>
 #include <sys/types.h>
diff --git a/src/sshare/sshare.h b/src/sshare/sshare.h
index 3dc2facaaec..759ce92ac51 100644
--- a/src/sshare/sshare.h
+++ b/src/sshare/sshare.h
@@ -44,22 +44,13 @@
 #  include "config.h"
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #include <ctype.h>
 #include <errno.h>
+#include <getopt.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef HAVE_STRING_H
-#  include <string.h>
-#endif
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
+#include <string.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -68,14 +59,6 @@
 #  include <readline/history.h>
 #endif
 
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else  /* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif  /* HAVE_INTTYPES_H */
-
 #include "slurm/slurm.h"
 
 #include "src/common/parse_time.h"
diff --git a/src/sstat/sstat.h b/src/sstat/sstat.h
index e6c8eb6e210..8f938fe3b2c 100644
--- a/src/sstat/sstat.h
+++ b/src/sstat/sstat.h
@@ -41,6 +41,7 @@
 
 #include <ctype.h>
 #include <errno.h>
+#include <getopt.h>
 #include <grp.h>
 #include <pwd.h>
 #include <stdio.h>
@@ -52,7 +53,6 @@
 #include <time.h>
 #include <unistd.h>
 
-#include "src/common/getopt.h"
 #include "src/common/xmalloc.h"
 #include "src/common/xstring.h"
 #include "src/common/list.h"
diff --git a/src/strigger/opts.c b/src/strigger/opts.c
index df2500528d1..462dc70fdce 100644
--- a/src/strigger/opts.c
+++ b/src/strigger/opts.c
@@ -45,12 +45,7 @@
 #  define _GNU_SOURCE
 #endif
 
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
+#include <getopt.h>
 #include <limits.h>
 #include <pwd.h>
 #include <stdlib.h>
diff --git a/src/strigger/strigger.c b/src/strigger/strigger.c
index ce58fba22a1..05b59638f2e 100644
--- a/src/strigger/strigger.c
+++ b/src/strigger/strigger.c
@@ -46,13 +46,12 @@
 #include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
+#include <time.h>
+#include <unistd.h>
+
 #include "slurm/slurm_errno.h"
 #include "slurm/slurm.h"
 
diff --git a/src/sview/sview.h b/src/sview/sview.h
index c491e724262..b121d7ac659 100644
--- a/src/sview/sview.h
+++ b/src/sview/sview.h
@@ -36,21 +36,9 @@
 #  include "config.h"
 #endif
 
-#if HAVE_INTTYPES_H
-#  include <inttypes.h>
-#else				/* !HAVE_INTTYPES_H */
-#  if HAVE_STDINT_H
-#    include <stdint.h>
-#  endif
-#endif				/* HAVE_INTTYPES_H */
-
-#if HAVE_GETOPT_H
-#  include <getopt.h>
-#else
-#  include "src/common/getopt.h"
-#endif
-
 #include <ctype.h>
+#include <inttypes.h>
+#include <getopt.h>
 #include <pwd.h>
 #include <stdlib.h>
 #include <stdio.h>
-- 
GitLab