1# Maintainer-only makefile segment.  This contains things that are relevant
2# only if you have the full copy of the GNU make sources from the CVS
3# tree, not a dist copy.
4
5# We like mondo-warnings!
6ifeq ($(KBUILD_TARGET),openbsd) # bird
7AM_CFLAGS += -Wall -Wshadow -Wpointer-arith -Wbad-function-cast
8else
9AM_CFLAGS += -Wall -Wextra -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast
10endif
11
12# I want this one but I have to wait for the const cleanup!
13# -Wwrite-strings
14
15# Find the glob source files... this might be dangerous, but we're maintainers!
16globsrc := $(wildcard glob/*.c)
17globhdr := $(wildcard glob/*.h)
18
19TEMPLATES = README README.DOS README.W32 README.OS2 \
20	    config.ami configh.dos config.h.W32 config.h-vms
21MTEMPLATES = Makefile.DOS SMakefile
22
23# These are built as a side-effect of the dist rule
24#all-am: $(TEMPLATES) $(MTEMPLATES) build.sh.in
25
26# General rule for turning a .template into a regular file.
27#
28$(TEMPLATES) : % : %.template Makefile
29	rm -f $@
30	sed -e 's@%VERSION%@$(VERSION)@g' \
31	    -e 's@%PACKAGE%@$(PACKAGE)@g' \
32	  $< > $@
33	chmod a-w $@
34
35# Construct Makefiles by adding on dependencies, etc.
36#
37$(MTEMPLATES) : % : %.template .dep_segment Makefile
38	rm -f $@
39	sed -e 's@%VERSION%@$(VERSION)@g' \
40	    -e 's@%PROGRAMS%@$(bin_PROGRAMS)@g' \
41	    -e 's@%SOURCES%@$(filter-out remote-%,$(make_SOURCES)) remote-$$(REMOTE).c@g' \
42	    -e 's@%OBJECTS%@$(filter-out remote-%,$(make_OBJECTS)) remote-$$(REMOTE).o@g' \
43	    -e 's@%GLOB_SOURCES%@$(globsrc) $(globhdr)@g' \
44	    -e 's@%GLOB_OBJECTS%@$(globsrc:glob/%.c=%.o)@g' \
45	  $< > $@
46	echo >>$@; echo '# --------------- DEPENDENCIES' >>$@; echo '#' >>$@; \
47	  cat $(word 2,$^) >>$@
48	chmod a-w $@
49
50NMakefile: NMakefile.template .dep_segment Makefile
51	rm -f $@
52	cp $< $@
53	echo >>$@; echo '# --------------- DEPENDENCIES' >>$@; echo '#' >>$@; \
54	  sed 's/^\([^ ]*\)\.o:/$$(OUTDIR)\/\1.obj:/' $(word 2,$^) >>$@
55	chmod a-w $@
56
57# Construct build.sh.in
58#
59build.sh.in: build.template Makefile
60	rm -f $@
61	sed -e 's@%objs%@$(patsubst %.o,%.$${OBJEXT},$(filter-out remote-%,$(make_OBJECTS)))@g' \
62	    -e 's@%globobjs%@$(patsubst %.c,%.$${OBJEXT},$(globsrc))@g' \
63	  $< > $@
64	chmod a-w+x $@
65
66
67# Use automake to build a dependency list file, for "foreign" makefiles like
68# Makefile.DOS.
69#
70# Automake used to have a --generate-deps flag, but it's gone now, so we have
71# to do it ourselves.
72#
73DEP_FILES := $(wildcard $(DEPDIR)/*.Po)
74.dep_segment: Makefile.am maintMakefile $(DEP_FILES)
75	rm -f $@
76	(for f in $(DEPDIR)/*.Po; do \
77	   echo ""; \
78	   echo "# $$f"; \
79	   sed	-e '/^[^:]*\.[ch] *:/d' \
80		-e 's, /usr/[^ ]*,,g' \
81		-e 's, $(srcdir)/, ,g' \
82		-e '/^ *\\$$/d' \
83		-e '/^ *$$/d' \
84		< $$f; \
85	 done) > $@
86
87# Get rid of everything "else".
88#
89maintFILES = configure aclocal.m4 config.h.in Makefile.in stamp-h.in
90
91CVS-CLEAN-FILES +=	$(maintFILES) $(TEMPLATES) $(MTEMPLATES) NMakefile \
92			build.sh.in .deps .dep_segment ABOUT-NLS \
93			ansi2knr.*
94
95# This rule tries to clean the tree right down to how it looks when you do a
96# virgin CVS checkout.
97
98# This target is potentially dangerous since it removes _ANY FILE_ that
99# is not in CVS.  Including files you might mean to add to CVS but
100# haven't yet...  I only use this in subdirectories where it's unlikely
101# we have any new files.  Still... be careful!!
102
103cvsclean = $(PERL) -e '$$k{CVS} = 1; open(E,"< CVS/Entries") || die "CVS/Entries: $$!\n"; while (defined ($$_ = <E>)) { m%^/([^/]*)% or next; $$k{$$1} = 1; } close(E) || die "CVS/Entries: $$!\n"; opendir(D, ".") || die ".: $$!\n"; while (defined ($$_ = readdir(D))) { -f $$_ && ! exists $$k{$$_} && unlink($$_); } closedir(D) || die ".: $$!\n";'
104
105.PHONY: cvs-clean
106cvs-clean: maintainer-clean
107	-rm -rf *~ $(CVS-CLEAN-FILES)
108	-cd config && $(cvsclean)
109	-cd po     && $(cvsclean)
110	-cd doc    && $(cvsclean)
111	-cd glob   && $(cvsclean)
112
113
114# ----------------------------------------------------------------------
115#
116# The sections below were stolen from the Makefile.maint used by fileutils,
117# sh-utils, textutils, CPPI, Bison, and Autoconf.
118
119
120## ---------------- ##
121## Updating files.  ##
122## ---------------- ##
123
124WGET = wget --passive-ftp -nv
125ftp-gnu = ftp://ftp.gnu.org/gnu
126
127move_if_change =  if test -r $(target) && cmp -s $(target).t $(target); then \
128		    echo $(target) is unchanged; rm -f $(target).t; \
129		  else \
130		    mv $(target).t $(target); \
131		  fi
132
133# ------------------- #
134# Updating PO files.  #
135# ------------------- #
136
137# PO archive mirrors --- Be careful; some might not be fully populated!
138#   ftp://ftp.unex.es/pub/gnu-i18n/po/maint/
139#   http://translation.sf.net/maint/
140#   ftp://tiger.informatik.hu-berlin.de/pub/po/maint/
141
142po_repo = http://translationproject.org/latest/$(PACKAGE)
143.PHONY: do-po-update po-update
144do-po-update:
145	tmppo="/tmp/po-$(PACKAGE)-$(VERSION).$$$$" \
146	  && rm -rf "$$tmppo" \
147	  && mkdir "$$tmppo" \
148	  && (cd "$$tmppo" \
149		&& $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) \
150	  && cp "$$tmppo"/*.po $(top_srcdir)/po && rm -rf "$$tmppo"
151	cd po && $(MAKE) update-po
152	$(MAKE) po-check
153
154po-update:
155	[ -d "po" ] && $(MAKE) do-po-update
156
157# -------------------------- #
158# Updating GNU build files.  #
159# -------------------------- #
160
161# The following pseudo table associates a local directory and a URL
162# with each of the files that belongs to some other package and is
163# regularly updated from the specified URL.
164
165cvs-url = http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~
166git-url = http://git.savannah.gnu.org/cgit
167target = $(patsubst get-%,%,$@)
168
169config-url = $(git-url)/config.git/plain/$(patsubst get-config/%,%,$@)
170get-config/config.guess get-config/config.sub:
171	@echo $(WGET) $(config-url) -O $(target) \
172	  && $(WGET) $(config-url) -O $(target).t \
173	  && $(move_if_change)
174
175gnulib-url = $(git-url)/gnulib.git/plain/build-aux/$(patsubst get-config/%,%,$@)
176get-config/texinfo.tex:
177	@echo $(WGET) $(gnulib-url) -O $(target) \
178	  && $(WGET) $(gnulib-url) -O $(target).t \
179	  && $(move_if_change)
180
181gnustandards-url = $(cvs-url)/gnustandards/gnustandards/$(patsubst get-doc/%,%,$@)
182get-doc/make-stds.texi get-doc/fdl.texi:
183	@echo $(WGET) $(gnustandards-url) -O $(target) \
184	  && $(WGET) $(gnustandards-url) -O $(target).t \
185	  && $(move_if_change)
186
187.PHONY: scm-update
188scm-update: get-config/texinfo.tex get-config/config.guess get-config/config.sub get-doc/make-stds.texi get-doc/fdl.texi
189
190
191# --------------------- #
192# Updating everything.  #
193# --------------------- #
194
195.PHONY: update
196update: po-update scm-update
197
198
199## --------------- ##
200## Sanity checks.  ##
201## --------------- ##
202
203# Checks that don't require cvs.  Run `changelog-check' last as
204# previous test may reveal problems requiring new ChangeLog entries.
205local-check: po-check changelog-check
206
207# copyright-check writable-files
208
209changelog-check:
210	if head $(top_srcdir)/ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
211	  :; \
212	else \
213	  echo "$(VERSION) not in ChangeLog" 1>&2; \
214	  exit 1; \
215	fi
216
217# Verify that all source files using _() are listed in po/POTFILES.in.
218# Ignore make.h; it defines _().
219po-check:
220	if test -f po/POTFILES.in; then \
221	  grep '^[^#]' po/POTFILES.in | sort > $@-1; \
222	  $(PERL) -wn -e 'if (/\b_\(/) { $$ARGV eq "make.h" || print "$$ARGV\n" and close ARGV }' *.c *.h | sort > $@-2; \
223	  diff -u $@-1 $@-2 || exit 1; \
224	  rm -f $@-1 $@-2; \
225	fi
226
227## ------------------------- ##
228## GNU FTP upload artifacts. ##
229## ------------------------- ##
230
231# This target creates the upload artifacts.
232# Sign it with my key.  If you don't have my key/passphrase then sorry,
233# you're SOL! :)
234
235GPG = gpg
236GPGFLAGS = -u 6338B6D4
237
238DIST_ARCHIVES_SIG = $(addsuffix .sig,$(DIST_ARCHIVES))
239DIST_ARCHIVES_DIRECTIVE = $(addsuffix .directive.asc,$(DIST_ARCHIVES))
240
241# A simple rule to test signing, etc.
242.PHONY: distsign
243distsign: $(DIST_ARCHIVES_SIG) $(DIST_ARCHIVES_DIRECTIVE)
244
245%.sig : %
246	@echo "Signing file '$<':"
247	$(GPG) $(GPGFLAGS) -o "$@" -b "$<"
248
249%.directive.asc: %
250	@echo "Creating directive file '$@':"
251	@( \
252	   echo 'version: 1.1'; \
253	   echo 'directory: make'; \
254	   echo 'filename: $*'; \
255	   echo 'comment: Official upload of GNU make version $(VERSION)'; \
256	 ) > "$*.directive"
257	$(GPG) $(GPGFLAGS) -o "$@" --clearsign "$*.directive"
258	@rm -f "$*.directive"
259
260# Upload the artifacts
261
262FTPPUT = ncftpput
263gnu-upload-host = ftp-upload.gnu.org
264gnu-upload-dir  = /incoming
265
266
267UPLOADS = upload-alpha upload-ftp
268.PHONY: $(UPLOADS)
269$(UPLOADS): $(DIST_ARCHIVES) $(DIST_ARCHIVES_SIG) $(DIST_ARCHIVES_DIRECTIVE)
270	$(FTPPUT) "$(gnu-upload-host)" "$(gnu-upload-dir)/$(@:upload-%=%)" $^
271
272
273# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
274# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
275# This file is part of GNU Make.
276#
277# GNU Make is free software; you can redistribute it and/or modify it under
278# the terms of the GNU General Public License as published by the Free Software
279# Foundation; either version 3 of the License, or (at your option) any later
280# version.
281#
282# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
283# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
284# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
285# details.
286#
287# You should have received a copy of the GNU General Public License along with
288# this program.  If not, see <http://www.gnu.org/licenses/>.
289