Portability: don't require GNU make

The part of Makefile.in that requires GNU make has been split into dev.mk.in,
and the configure script has learned a new --enable-dev option that makes
Makefile include dev.mk. The configure script doesn't check for GNU make
anymore. There is also a new configure-dev convenience script that runs
configure with --enable-dev.
This commit is contained in:
Joel Rosdahl 2010-02-26 21:24:09 +01:00
parent f9cf675f44
commit 1af0bd8486
7 changed files with 73 additions and 71 deletions

1
.gitignore vendored
View File

@ -10,4 +10,5 @@ config.h.in
config.log
config.status
configure
dev.mk
testdir.*

View File

@ -6,7 +6,6 @@ PREREQUISITES
To build ccache, you need:
- GNU make <http://www.gnu.org/software/make/>
- A C compiler (for instance GCC)
It is also recommended that you have:
@ -60,5 +59,5 @@ In addition to the prerequisites mentioned above, you also need:
- asciidoc (http://www.methods.co.nz/asciidoc/) to build the documentation.
- autoconf (http://www.gnu.org/software/autoconf/)
Run "./autogen.sh" to generate "configure" and "config.h.in" and then follow
the steps mentioned under INSTALLATION above.
Run "./autogen.sh" and then follow the steps mentioned under INSTALLATION
above.

View File

@ -10,7 +10,7 @@ installcmd = @INSTALL@
CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@ -I. -MD -MP -MF .deps/$(subst .._,,$(subst /,_,$<)).d
CPPFLAGS = @CPPFLAGS@ -I.
LDFLAGS = @LDFLAGS@
EXEEXT = @EXEEXT@
@ -28,16 +28,6 @@ headers = \
objs = $(all_sources:.c=.o)
dist_files = \
$(sources) $(headers) ccache.1 config.h.in configure install-sh \
Makefile.in test.sh zlib/*.h zlib/*.c COPYING INSTALL NEWS README
version := $(shell sed -n 's/^\#define CCACHE_VERSION "\(.*\)"/\1/p' \
$(srcdir)/ccache.h)
dist_dir := ccache-$(version)
dist_archive_tar_bz2 := ccache-$(version).tar.bz2
dist_archive_tar_gz := ccache-$(version).tar.gz
.PHONY: all
all: ccache$(EXEEXT)
@ -48,7 +38,7 @@ ccache$(EXEEXT): $(objs)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(objs) $(libs)
ccache.1: ccache.yo
yodl2man -o ccache.1 ccache.yo
yodl2man -o ccache.1 $(srcdir)/ccache.yo
.PHONY: install
install: all
@ -57,25 +47,6 @@ install: all
$(installcmd) -d $(DESTDIR)$(mandir)/man1
-$(installcmd) -m 644 $(srcdir)/ccache.1 $(DESTDIR)$(mandir)/man1/
.PHONY: dist
dist: $(dist_archive_tar_bz2) $(dist_archive_tar_gz)
define create_dist_archive
tmpdir=$$(mktemp -d) && \
dir=$$tmpdir/$(dist_dir) && \
mkdir $$dir && \
cp -r --parents $(dist_files) $$dir && \
(cd $$tmpdir && \
tar $(1) $(CURDIR)/$@ $(dist_dir)) && \
rm -rf $$tmpdir
endef
$(dist_archive_tar_bz2): $(dist_files)
$(call create_dist_archive, cjf)
$(dist_archive_tar_gz): $(dist_files)
$(call create_dist_archive, czf)
.PHONY: clean
clean:
rm -f $(objs) *~ ccache$(EXEEXT) .deps/* ccache.1 \
@ -90,26 +61,10 @@ check: test
.PHONY: distclean
distclean: clean
rm -rf Makefile config.h config.log config.status .deps
rm -rf Makefile dev.mk config.h config.log config.status .deps
.PHONY: installcheck
installcheck:
CCACHE=$(bindir)/ccache $(srcdir)/test.sh
.PHONY: distcheck
distcheck: $(dist_archive_tar_bz2)
tmpdir=$$(mktemp -d) && \
(cd $$tmpdir && \
tar xjf $(CURDIR)/$(dist_archive_tar_bz2) && \
mkdir -p $(dist_dir)/build && \
cd $(dist_dir)/build && \
../configure --prefix=$$tmpdir/root && \
$(MAKE) install && \
$(MAKE) installcheck) && \
rm -rf $$tmpdir
.PHONY: check-syntax
check-syntax:
$(CC) @CPPFLAGS@ -I. $(CFLAGS) -S -o /dev/null $(CHK_SOURCES)
-include $(all_sources:%=.deps/%.d)
@include_dev_mk@

View File

@ -4,4 +4,4 @@ set -e
autoheader
autoconf
echo "Now run ./configure and make"
echo "Now run ./configure-dev and make"

3
configure-dev Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
`dirname $0`/configure --enable-dev "$@"

View File

@ -8,6 +8,12 @@ AC_MSG_NOTICE([Configuring ccache])
AC_CONFIG_HEADER(config.h)
AC_SUBST(extra_sources)
AC_SUBST(include_dev_mk)
AC_ARG_ENABLE(
dev,
AS_HELP_STRING(--enable-dev, enable developer mode (requires GNU make)),
[include_dev_mk='include dev.mk'])
dnl Checks for programs.
AC_PROG_CC
@ -108,23 +114,7 @@ else
mkdir -p zlib
fi
dnl Check for GNU make.
AC_PATH_PROGS(MAKE, gmake make)
AC_CACHE_CHECK(
for GNU make,
ccache_cv_gnu_make,
[
if $ac_cv_path_MAKE --version | head -1 | grep GNU >/dev/null 2>&1; then
ccache_cv_gnu_make=yes
else
ccache_cv_gnu_make=no
fi
])
if test x$ccache_cv_gnu_make = xno; then
AC_MSG_ERROR(Please install GNU make as gmake or make)
fi
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([Makefile dev.mk])
AC_OUTPUT
mkdir -p .deps
@ -133,4 +123,4 @@ if test x$use_bundled_zlib = xyes; then
AC_MSG_WARN(using bundled zlib)
fi
AC_MSG_NOTICE(now please build ccache by running $ac_cv_path_MAKE)
AC_MSG_NOTICE(now build ccache by running make)

54
dev.mk.in Normal file
View File

@ -0,0 +1,54 @@
CPPFLAGS += -MD -MP -MF .deps/$(subst .._,,$(subst /,_,$<)).d
version = $(shell sed -n 's/^\#define CCACHE_VERSION "\(.*\)"/\1/p' \
$(srcdir)/ccache.h)
dist_dir = ccache-$(version)
dist_archive_tar_bz2 = ccache-$(version).tar.bz2
dist_archive_tar_gz = ccache-$(version).tar.gz
source_dist_files = \
$(sources) $(headers) zlib/*.c zlib/*.h \
config.h.in configure configure-dev dev.mk.in install-sh Makefile.in \
test.sh COPYING INSTALL NEWS README
built_dist_files = ccache.1
dist_files = \
$(addprefix $(srcdir)/, $(source_dist_files)) \
$(built_dist_files)
.PHONY: dist
dist: $(dist_archive_tar_bz2) $(dist_archive_tar_gz)
define create_dist_archive
tmpdir=$$(mktemp -d) && \
dir=$$tmpdir/$(dist_dir) && \
mkdir $$dir && \
(cd $(srcdir) && \
cp -r --parents $(source_dist_files) $$dir) && \
cp $(built_dist_files) $$dir && \
(cd $$tmpdir && \
tar $(1) $(CURDIR)/$@ $(dist_dir)) && \
rm -rf $$tmpdir
endef
$(dist_archive_tar_bz2): $(dist_files)
$(call create_dist_archive, cjf)
$(dist_archive_tar_gz): $(dist_files)
$(call create_dist_archive, czf)
.PHONY: distcheck
distcheck: $(dist_archive_tar_bz2)
tmpdir=$$(mktemp -d) && \
(cd $$tmpdir && \
tar xjf $(CURDIR)/$(dist_archive_tar_bz2) && \
mkdir -p $(dist_dir)/build && \
cd $(dist_dir)/build && \
../configure --prefix=$$tmpdir/root && \
$(MAKE) install && \
$(MAKE) installcheck) && \
rm -rf $$tmpdir
.PHONY: check-syntax
check-syntax:
$(CC) @CPPFLAGS@ -I. $(CFLAGS) -S -o /dev/null $(CHK_SOURCES)
-include $(all_sources:%=.deps/%.d)