#! /usr/bin/make -f ## rebuild.mk - POP3Lite rebuilder ## Copyright (C) 2000, 2001 Gergely Nagy <8@free.bsd.hu> ## ## This file is part of POP3Lite. ## ## POP3Lite is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## POP3Lite 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 General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## ## $Id: rebuild.mk,v 1.42.2.3 2001/05/22 13:23:26 algernon Exp $ ## ## macros ## # This needs to be defined before anything that uses SRCDIR. define get-src-dir for r in . .. ../.. ; do \ if test -f $$r/rebuild.mk; then \ echo $$r; \ exit; \ fi \ done; \ echo . endef ## ## Variables ## SRCDIR = $(shell $(get-src-dir)) BUILDDIR = $(CURDIR) CONFIG_FLAGS = --disable-static CFLAGS = -O2 ARCH_FLAGS = CFLAGS="$(CFLAGS)" GNU_ROOT = $(if $(findstring hurd,$(shell uname -a)),,/gnu) FREEBSD_ROOT = $(if $(findstring freebsd,$(BUILD)),,/FreeBSD) FREEBSD_VERSION = 5.0 VERSION = $(shell grep "^AC_INIT" $(SRCDIR)/configure.ac | sed -e "s/^AC_INIT.\[pop3lite\], \[\([0-9\.]*\(\-*[a-z]*\)*\)\].*/\1/") cpu = i386 target = linux-gnu HOST = $(shell $(SRCDIR)/config.sub $(cpu)-$(target)) BUILD = $(shell $(SRCDIR)/config.guess) RPM = rpm DPKG_BUILDPACKAGE = dpkg-buildpackage FREEBSD_CONFIG_FLAGS = --with-pgsql-libs=/usr/local/pgsql/lib --with-glib-prefix=/usr/local --with-layout=bsd --with-pgsql-headers=/usr/local/pgsql/include FREEBSD_ARCH_FLAGS = GLIB_CONFIG=$(FREEBSD_ROOT)/usr/local/bin/glib12-config GNU_CONFIG_FLAGS = GNU_ARCH_FLAGS = GLIB_CONFIG=$(GNU_ROOT)/usr/bin/glib-config LINUX_CONFIG_FLAGS = LINUX_ARCH_FLAGS = all: default bootstrap: cd $(SRCDIR) && $(MAKE) -f bootstrap.mk bootstrap src-configure src-Makefile.in \ src-aclocal.m4 src-config.h.in : src-%: @cd $(SRCDIR) && $(MAKE) -f bootstrap.mk $* ## ## Targets I use. ## NOTE: These are configure-only targets. You have to supply ## SRCDIR if you are'nt building in the source tree. Also, you ## have to issue a `make all install' command after this too! ## # I use this one rarely. GDB is really good at debugging optimised code # -pg is pretty useless too IMHO. debug: src-configure CFLAGS="-O0 -g3 -pg $(CFLAGS)" $(SRCDIR)/configure $(CONFIG_FLAGS) \ --with-layout=algernon \ --enable-test-modules \ --enable-cxx-warnings \ --enable-compile-warnings \ --enable-maintainer-mode \ --enable-debugging \ --enable-iso-c # This is the one I actually use default: src-configure CFLAGS="-g3 $(CFLAGS)" \ $(SRCDIR)/configure $(CONFIG_FLAGS) \ --with-layout=algernon \ --enable-test-modules \ --enable-cxx-warnings \ --enable-iso-c \ --enable-compile-warnings \ --enable-maintainer-mode \ --enable-debugging \ --with-builtin-modules=connectlog,mailbox # This is for people who want the best possible code # Debugging off, optimisations on optimised: src-configure CFLAGS="$(CFLAGS) -O3 -mcpu=$(shell uname -m) -march=$(shell uname -m)" \ $(SRCDIR)/configure $(CONFIG_FLAGS) \ --disable-test-modules \ --enable-compile-warnings \ --disable-debugging \ --with-builtin-modules=pam,mailbox,connectlog ## ## release target & dependencies ## NOTE: rel-source is called by rel-debian and/or rel-redhat! ## release: release-clean rel-linux-gnu rel-gnu rel-freebsd rel-debian rel-redhat build-release/debian build-release/freebsdelf4.0 build-release/gnu \ build-release/linux-gnu: install -d $@ rel-source build-release/pop3lite-$(VERSION).tar.gz: build-release/linux-gnu/Makefile $(MAKE) -C build-release/linux-gnu cvs-dist cp build-release/linux-gnu/pop3lite-*.tar.gz build-release/ rel-debian-prep: build-release/debian \ build-release/pop3lite-$(VERSION).tar.gz cd build-release/debian && tar xzf ../pop3lite-$(VERSION).tar.gz rel-debian: rel-debian-hurd rel-debian-i386 rel-debian-hurd: rel-debian-prep cd build-release/debian/pop3lite-$(VERSION) && $(DPKG_BUILDPACKAGE) -ahurd-i386 rel-debian-i386: rel-debian-prep cd build-release/debian/pop3lite-$(VERSION) && $(DPKG_BUILDPACKAGE) rel-redhat: build-release/pop3lite-$(VERSION).tar.gz $(RPM) -tb --sign build-release/pop3lite-$(VERSION).tar.gz rel-linux-gnu: $(MAKE) -f $(SRCDIR)/rebuild.mk release-part target=linux-gnu \ ARCH_FLAGS="$(LINUX_ARCH_FLAGS)" \ CONFIG_FLAGS="$(LINUX_CONFIG_FLAGS) $(CONFIG_FLAGS)" rel-gnu: $(MAKE) -f $(SRCDIR)/rebuild.mk release-part target=gnu \ ARCH_FLAGS="$(GNU_ARCH_FLAGS)" \ CONFIG_FLAGS="$(GNU_CONFIG_FLAGS) $(CONFIG_FLAGS)" rel-freebsd: $(MAKE) -f $(SRCDIR)/rebuild.mk release-part target=freebsdelf$(FREEBSD_VERSION) \ ARCH_FLAGS="$(FREEBSD_ARCH_FLAGS)" \ CONFIG_FLAGS="$(FREEBSD_CONFIG_FLAGS) $(CONFIG_FLAGS)" # release-part & co release-part: part-intro $(SRCDIR)/configure build-release/$(target) \ build-release/$(target)/pop3lite-$(VERSION).bin.$(HOST).tar.gz # This always is run part-intro: @echo '**** Building $(target) ****' # This must be run by hand part-distclean: build-release/$(target) -test -f build-release/$(target)/Makefile && ( $(MAKE) -C build-release/$(target) distclean || true ) # This is run by part-build when the required Makefile does # not exist build-release/%/Makefile: install -d build-release/$* rm -f build-release/$*/patch-stamp cd build-release/$* && $(ARCH_FLAGS) \ ../../configure $(CONFIG_FLAGS) --build=$(BUILD) \ --host=$(cpu)-$* # This is run by part-dist when the daemon # is not compiled yet build-release/%/src/pop3lite: build-release/%/Makefile $(MAKE) -f $(SRCDIR)/rebuild.mk patch-hook-$* target=$* || true $(MAKE) -C build-release/$* all # This is always run by release-part build-release/%/pop3lite-$(VERSION).bin.$(HOST).tar.gz: build-release/%/src/pop3lite $(MAKE) -C build-release/$* bin-dist cp build-release/$*/pop3lite-*.tar.gz build-release/ ## ## clean & install targets ## release-clean: rm -Rf build-release build-release/%/clean: rm -Rf $(shell echo "$@" | sed -e "s,/clean,,") ## ## hooks ## patch-hook-freebsdelf$(FREEBSD_VERSION): build-release/$(target)/patch-stamp patch -f --no-backup-if-mismatch -d build-release/$(target) -p0 -N <$(SRCDIR)/dist/libtool-freebsd-cross.diff touch build-release/$(target)/patch-stamp ## ## special rules ## .DEFAULT: @echo '*** Error: target not supported: $@' .PHONY: default release-part release debug optimised rel-linux-gnu rel-gnu \ rel-freebsd release-clean req rel-source rel-debian rel-redhat \ part-intro part-distclean patch-hook-freebsdelf4.0 rel-debian-prep \ rel-debian-hurd rel-debian-i386 boostrap src-configure src-Makefile.in \ src-aclocal.m4 src-config.h.in # This is here to avoid deletion of build-release/$*/src/pop3lite & co .PRECIOUS: % build-release/$(target)/src/pop3lite build-release/$(target)/Makefile