^src/((system|copy|chown-core|find-mount-point)\.h|make-prime-list\.c)$$
_src := (false|lbracket|chown-(chgrp|chown)
-_src := $(_src)|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
+_src := $(_src)|ls-(dir|ls|vdir)|make-prime-list|tac-pipe|uname-(arch|uname))
_gl_src = (xdecto.max|cl-strtold)
exclude_file_name_regexp--sc_require_config_h_first = \
(^lib/buffer-lcm\.c|gl/lib/$(_gl_src)\.c|src/$(_src)\.c)$$
exclude_file_name_regexp--sc_error_message_uppercase = ^src/factor\.c$$
exclude_file_name_regexp--sc_prohibit_atoi_atof = ^src/make-prime-list\.c$$
-# Exception here as we don't want __attribute elided on non GCC
-exclude_file_name_regexp--sc_prohibit-gl-attributes = ^src/libstdbuf\.c$$
+# Exception here as we don't want __attribute elided on non GCC for stdbuf
+# and we don't want to depend on gnulib for make-prime-list
+exclude_file_name_regexp--sc_prohibit-gl-attributes = \
+ ^src/(make-prime-list|libstdbuf)\.c$$
exclude_file_name_regexp--sc_prohibit_uppercase_id_est = \.diff$$
exclude_file_name_regexp--sc_ensure_dblspace_after_dot_before_id_est = \.diff$$
# Needed by the testsuite.
noinst_PROGRAMS = \
- src/getlimits \
- src/make-prime-list
+ src/getlimits
noinst_HEADERS = \
src/chown.h \
src_logname_LDADD = $(LDADD)
src_ls_LDADD = $(LDADD)
-# This must *not* depend on anything in lib/, since it is used to generate
-# src/primes.h. If it depended on libcoreutils.a, that would pull all lib/*.c
-# into BUILT_SOURCES.
-src_make_prime_list_LDADD =
-
src_md5sum_LDADD = $(LDADD)
src_mkdir_LDADD = $(LDADD)
src_mkfifo_LDADD = $(LDADD)
# and it needs to be built on a widest-known-int architecture, so it's
# built only if absent. It is not cleaned because we don't want to
# insist that maintainers must build on hosts that support the widest
-# known ints (currently 128-bit).
+# known ints (currently 128-bit). It is built in a temporary directory
+# to avoid Gnulib and allow cross-compilers. The BUILD_* definitions
+# come from Gnulib's gl_BUILD_CC which is invoked for the crc module.
BUILT_SOURCES += $(top_srcdir)/src/primes.h
-$(top_srcdir)/src/primes.h:
- $(AM_V_at)${MKDIR_P} src
- $(MAKE) src/make-prime-list$(EXEEXT)
- $(AM_V_GEN)rm -f $@ $@-t
- $(AM_V_at)src/make-prime-list$(EXEEXT) 5000 > $@-t
- $(AM_V_at)chmod a-w $@-t
- $(AM_V_at)mv $@-t $@
+$(top_srcdir)/src/primes.h: $(top_srcdir)/src/make-prime-list.c
+ $(AM_V_GEN)if test -n '$(BUILD_CC)'; then \
+ $(MKDIR_P) $(top_srcdir)/src/primes-tmp \
+ && (cd $(top_srcdir)/src/primes-tmp \
+ && $(BUILD_CC) $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) \
+ $(BUILD_LDFLAGS) -o make-prime-list$(EXEEXT) \
+ $(abs_top_srcdir)/src/make-prime-list.c) \
+ && rm -f $@ $@-t \
+ && $(top_srcdir)/src/primes-tmp/make-prime-list$(EXEEXT) \
+ 5000 > $@-t \
+ && chmod a-w $@-t \
+ && mv $@-t $@ \
+ && rm -rf $(top_srcdir)/src/primes-tmp; \
+ fi
# false exits nonzero even with --help or --version.
# test doesn't support --help or --version.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
-#include <config.h>
-
-#include <attribute.h>
#include <inttypes.h>
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
-/* Deactivate "rpl_"-prefixed definitions of these symbols. */
-#undef fclose
-#undef free
-#undef malloc
-#undef strerror
+/* This program is compiled in a separate directory to avoid linking to Gnulib
+ which may be cross-compiled. Therefore, we also do not have config.h and
+ attribute.h. Just define what we need. */
+#if 2 < __GNUC__ + (95 <= __GNUC_MINOR__)
+# define ATTRIBUTE_CONST __attribute__ ((__const__))
+#else
+# define ATTRIBUTE_CONST
+#endif
+#if 3 < __GNUC__
+# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+#else
+# define ATTRIBUTE_MALLOC
+#endif
+
/* An unsigned type that is no narrower than 32 bits and no narrower
than unsigned int. It's best to make it as wide as possible.