From 1af0bd848651c62cdf72eea9918f5d57402de838 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Fri, 26 Feb 2010 21:24:09 +0100 Subject: [PATCH] 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. --- .gitignore | 1 + INSTALL | 5 ++--- Makefile.in | 53 ++++---------------------------------------------- autogen.sh | 2 +- configure-dev | 3 +++ configure.ac | 26 ++++++++----------------- dev.mk.in | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 73 insertions(+), 71 deletions(-) create mode 100755 configure-dev create mode 100644 dev.mk.in diff --git a/.gitignore b/.gitignore index cb7d05c..bcab83a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ config.h.in config.log config.status configure +dev.mk testdir.* diff --git a/INSTALL b/INSTALL index 73e7518..c4a94bf 100644 --- a/INSTALL +++ b/INSTALL @@ -6,7 +6,6 @@ PREREQUISITES To build ccache, you need: - - GNU 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. diff --git a/Makefile.in b/Makefile.in index 51f694a..466ee32 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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@ diff --git a/autogen.sh b/autogen.sh index 6c96c67..f1b566c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -4,4 +4,4 @@ set -e autoheader autoconf -echo "Now run ./configure and make" +echo "Now run ./configure-dev and make" diff --git a/configure-dev b/configure-dev new file mode 100755 index 0000000..36d62b6 --- /dev/null +++ b/configure-dev @@ -0,0 +1,3 @@ +#!/bin/sh + +`dirname $0`/configure --enable-dev "$@" diff --git a/configure.ac b/configure.ac index 8d506f9..078673c 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/dev.mk.in b/dev.mk.in new file mode 100644 index 0000000..7533baf --- /dev/null +++ b/dev.mk.in @@ -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)