105436638acc7c010349a69c3395f1a57c642dc62Ying Wang# Having a separate GNUmakefile lets me 'include' the dynamically 205436638acc7c010349a69c3395f1a57c642dc62Ying Wang# generated rules created via cfg.mk (package-local configuration) 305436638acc7c010349a69c3395f1a57c642dc62Ying Wang# as well as maint.mk (generic maintainer rules). 4cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# This makefile is used only if you run GNU Make. 5cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# It is necessary if you want to build targets usually of interest 6cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# only to the maintainer. 7cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 805436638acc7c010349a69c3395f1a57c642dc62Ying Wang# Copyright (C) 2001, 2003, 2006-2012 Free Software Foundation, Inc. 905436638acc7c010349a69c3395f1a57c642dc62Ying Wang 1005436638acc7c010349a69c3395f1a57c642dc62Ying Wang# This program is free software: you can redistribute it and/or modify 11cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# it under the terms of the GNU General Public License as published by 1205436638acc7c010349a69c3395f1a57c642dc62Ying Wang# the Free Software Foundation, either version 3 of the License, or 13cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# (at your option) any later version. 1405436638acc7c010349a69c3395f1a57c642dc62Ying Wang 15cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# This program is distributed in the hope that it will be useful, 16cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# but WITHOUT ANY WARRANTY; without even the implied warranty of 17cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# GNU General Public License for more details. 19cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 2005436638acc7c010349a69c3395f1a57c642dc62Ying Wang# You should have received a copy of the GNU General Public License 2105436638acc7c010349a69c3395f1a57c642dc62Ying Wang# along with this program. If not, see <http://www.gnu.org/licenses/>. 22cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 23cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# If the user runs GNU make but has not yet run ./configure, 24cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# give them a diagnostic. 2505436638acc7c010349a69c3395f1a57c642dc62Ying Wang_gl-Makefile := $(wildcard [M]akefile) 2605436638acc7c010349a69c3395f1a57c642dc62Ying Wangifneq ($(_gl-Makefile),) 27cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 28cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# Make tar archive easier to reproduce. 29cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectexport TAR_OPTIONS = --owner=0 --group=0 --numeric-owner 30cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 3105436638acc7c010349a69c3395f1a57c642dc62Ying Wang# Allow the user to add to this in the Makefile. 3205436638acc7c010349a69c3395f1a57c642dc62Ying WangALL_RECURSIVE_TARGETS = 3305436638acc7c010349a69c3395f1a57c642dc62Ying Wang 34cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectinclude Makefile 3505436638acc7c010349a69c3395f1a57c642dc62Ying Wang 3605436638acc7c010349a69c3395f1a57c642dc62Ying Wang# Some projects override e.g., _autoreconf here. 3705436638acc7c010349a69c3395f1a57c642dc62Ying Wang-include $(srcdir)/cfg.mk 3805436638acc7c010349a69c3395f1a57c642dc62Ying Wang 3905436638acc7c010349a69c3395f1a57c642dc62Ying Wang# Allow cfg.mk to override these. 4005436638acc7c010349a69c3395f1a57c642dc62Ying Wang_build-aux ?= build-aux 4105436638acc7c010349a69c3395f1a57c642dc62Ying Wang_autoreconf ?= autoreconf -v 4205436638acc7c010349a69c3395f1a57c642dc62Ying Wang 4305436638acc7c010349a69c3395f1a57c642dc62Ying Wanginclude $(srcdir)/maint.mk 4405436638acc7c010349a69c3395f1a57c642dc62Ying Wang 4505436638acc7c010349a69c3395f1a57c642dc62Ying Wang# Ensure that $(VERSION) is up to date for dist-related targets, but not 4605436638acc7c010349a69c3395f1a57c642dc62Ying Wang# for others: rerunning autoreconf and recompiling everything isn't cheap. 4705436638acc7c010349a69c3395f1a57c642dc62Ying Wang_have-git-version-gen := \ 4805436638acc7c010349a69c3395f1a57c642dc62Ying Wang $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes) 4905436638acc7c010349a69c3395f1a57c642dc62Ying Wangifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL)) 5005436638acc7c010349a69c3395f1a57c642dc62Ying Wang _is-dist-target ?= $(filter-out %clean, \ 5105436638acc7c010349a69c3395f1a57c642dc62Ying Wang $(filter maintainer-% dist% alpha beta stable,$(MAKECMDGOALS))) 5205436638acc7c010349a69c3395f1a57c642dc62Ying Wang _is-install-target ?= $(filter-out %check, $(filter install%,$(MAKECMDGOALS))) 5305436638acc7c010349a69c3395f1a57c642dc62Ying Wang ifneq (,$(_is-dist-target)$(_is-install-target)) 5405436638acc7c010349a69c3395f1a57c642dc62Ying Wang _curr-ver := $(shell cd $(srcdir) \ 5505436638acc7c010349a69c3395f1a57c642dc62Ying Wang && $(_build-aux)/git-version-gen \ 5605436638acc7c010349a69c3395f1a57c642dc62Ying Wang .tarball-version \ 5705436638acc7c010349a69c3395f1a57c642dc62Ying Wang $(git-version-gen-tag-sed-script)) 5805436638acc7c010349a69c3395f1a57c642dc62Ying Wang ifneq ($(_curr-ver),$(VERSION)) 5905436638acc7c010349a69c3395f1a57c642dc62Ying Wang ifeq ($(_curr-ver),UNKNOWN) 6005436638acc7c010349a69c3395f1a57c642dc62Ying Wang $(info WARNING: unable to verify if $(VERSION) is the correct version) 6105436638acc7c010349a69c3395f1a57c642dc62Ying Wang else 6205436638acc7c010349a69c3395f1a57c642dc62Ying Wang ifneq (,$(_is-install-target)) 6305436638acc7c010349a69c3395f1a57c642dc62Ying Wang # GNU Coding Standards state that 'make install' should not cause 6405436638acc7c010349a69c3395f1a57c642dc62Ying Wang # recompilation after 'make all'. But as long as changing the version 6505436638acc7c010349a69c3395f1a57c642dc62Ying Wang # string alters config.h, the cost of having 'make all' always have an 6605436638acc7c010349a69c3395f1a57c642dc62Ying Wang # up-to-date version is prohibitive. So, as a compromise, we merely 6705436638acc7c010349a69c3395f1a57c642dc62Ying Wang # warn when installing a version string that is out of date; the user 6805436638acc7c010349a69c3395f1a57c642dc62Ying Wang # should run 'autoreconf' (or something like 'make distcheck') to 6905436638acc7c010349a69c3395f1a57c642dc62Ying Wang # fix the version, 'make all' to propagate it, then 'make install'. 7005436638acc7c010349a69c3395f1a57c642dc62Ying Wang $(info WARNING: version string $(VERSION) is out of date;) 7105436638acc7c010349a69c3395f1a57c642dc62Ying Wang $(info run '$(MAKE) _version' to fix it) 7205436638acc7c010349a69c3395f1a57c642dc62Ying Wang else 7305436638acc7c010349a69c3395f1a57c642dc62Ying Wang $(info INFO: running autoreconf for new version string: $(_curr-ver)) 7405436638acc7c010349a69c3395f1a57c642dc62Ying WangGNUmakefile: _version 7505436638acc7c010349a69c3395f1a57c642dc62Ying Wang touch GNUmakefile 7605436638acc7c010349a69c3395f1a57c642dc62Ying Wang endif 7705436638acc7c010349a69c3395f1a57c642dc62Ying Wang endif 7805436638acc7c010349a69c3395f1a57c642dc62Ying Wang endif 7905436638acc7c010349a69c3395f1a57c642dc62Ying Wang endif 8005436638acc7c010349a69c3395f1a57c642dc62Ying Wangendif 8105436638acc7c010349a69c3395f1a57c642dc62Ying Wang 8205436638acc7c010349a69c3395f1a57c642dc62Ying Wang.PHONY: _version 8305436638acc7c010349a69c3395f1a57c642dc62Ying Wang_version: 8405436638acc7c010349a69c3395f1a57c642dc62Ying Wang cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf) 8505436638acc7c010349a69c3395f1a57c642dc62Ying Wang $(MAKE) $(AM_MAKEFLAGS) Makefile 86cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 87cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectelse 88cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 8905436638acc7c010349a69c3395f1a57c642dc62Ying Wang.DEFAULT_GOAL := abort-due-to-no-makefile 9005436638acc7c010349a69c3395f1a57c642dc62Ying Wangsrcdir = . 9105436638acc7c010349a69c3395f1a57c642dc62Ying Wang 9205436638acc7c010349a69c3395f1a57c642dc62Ying Wang# The package can override .DEFAULT_GOAL to run actions like autoreconf. 9305436638acc7c010349a69c3395f1a57c642dc62Ying Wang-include ./cfg.mk 9405436638acc7c010349a69c3395f1a57c642dc62Ying Wang 9505436638acc7c010349a69c3395f1a57c642dc62Ying Wang# Allow cfg.mk to override these. 9605436638acc7c010349a69c3395f1a57c642dc62Ying Wang_build-aux ?= build-aux 9705436638acc7c010349a69c3395f1a57c642dc62Ying Wang_autoreconf ?= autoreconf -v 9805436638acc7c010349a69c3395f1a57c642dc62Ying Wang 9905436638acc7c010349a69c3395f1a57c642dc62Ying Wanginclude ./maint.mk 10005436638acc7c010349a69c3395f1a57c642dc62Ying Wang 10105436638acc7c010349a69c3395f1a57c642dc62Ying Wangifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile) 10205436638acc7c010349a69c3395f1a57c642dc62Ying Wang$(MAKECMDGOALS): abort-due-to-no-makefile 10305436638acc7c010349a69c3395f1a57c642dc62Ying Wangendif 10405436638acc7c010349a69c3395f1a57c642dc62Ying Wang 10505436638acc7c010349a69c3395f1a57c642dc62Ying Wangabort-due-to-no-makefile: 10605436638acc7c010349a69c3395f1a57c642dc62Ying Wang @echo There seems to be no Makefile in this directory. 1>&2 10705436638acc7c010349a69c3395f1a57c642dc62Ying Wang @echo "You must run ./configure before running 'make'." 1>&2 108cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project @exit 1 109cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 110cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Projectendif 111cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project 112cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project# Tell version 3.79 and up of GNU make to not build goals in this 11305436638acc7c010349a69c3395f1a57c642dc62Ying Wang# directory in parallel, in case someone tries to build multiple 11405436638acc7c010349a69c3395f1a57c642dc62Ying Wang# targets, and one of them can cause a recursive target to be invoked. 11505436638acc7c010349a69c3395f1a57c642dc62Ying Wang 11605436638acc7c010349a69c3395f1a57c642dc62Ying Wang# Only set this if Automake doesn't provide it. 11705436638acc7c010349a69c3395f1a57c642dc62Ying WangAM_RECURSIVE_TARGETS ?= $(RECURSIVE_TARGETS:-recursive=) \ 11805436638acc7c010349a69c3395f1a57c642dc62Ying Wang $(RECURSIVE_CLEAN_TARGETS:-recursive=) \ 11905436638acc7c010349a69c3395f1a57c642dc62Ying Wang dist distcheck tags ctags 12005436638acc7c010349a69c3395f1a57c642dc62Ying Wang 12105436638acc7c010349a69c3395f1a57c642dc62Ying WangALL_RECURSIVE_TARGETS += $(AM_RECURSIVE_TARGETS) 12205436638acc7c010349a69c3395f1a57c642dc62Ying Wang 12305436638acc7c010349a69c3395f1a57c642dc62Ying Wangifneq ($(word 2, $(MAKECMDGOALS)), ) 12405436638acc7c010349a69c3395f1a57c642dc62Ying Wangifneq ($(filter $(ALL_RECURSIVE_TARGETS), $(MAKECMDGOALS)), ) 125cea198a11f15a2eb071d98491ca9a8bc8cebfbc4The Android Open Source Project.NOTPARALLEL: 12605436638acc7c010349a69c3395f1a57c642dc62Ying Wangendif 12705436638acc7c010349a69c3395f1a57c642dc62Ying Wangendif 128