summaryrefslogtreecommitdiff
path: root/maintMakefile
blob: 1910674bbba10db9cc6ef39bb49e9123df8d80db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# Maintainer-only makefile segment.  This contains things that are relevant
# only if you have the full copy of the GNU make sources from the CVS
# tree, not a dist copy.
#

# Find the glob source files... this might be dangerous, but we're maintainers!
#
globsrc := $(wildcard glob/*.c)
globhdr := $(wildcard glob/*.h)

TEMPLATES = README README.DOS README.W32 \
	    config.ami configh.dos config.h.W32 config.h-vms
MTEMPLATES = Makefile.DOS SMakefile

# We need this to ensure that README and build.sh.in are created on time to
# avoid errors by automake.
#
#Makefile.in: README build.sh.in

# General rule for turning a .template into a regular file.
#
$(TEMPLATES) : % : %.template Makefile
	rm -f $@
	sed -e 's@%VERSION%@$(VERSION)@g' \
	    -e 's@%PACKAGE%@$(PACKAGE)@g' \
	  $< > $@
	chmod a-w $@

# Construct Makefiles by adding on dependencies, etc.
#
$(MTEMPLATES) : % : %.template .dep_segment Makefile
	rm -f $@
	sed -e 's@%VERSION%@$(VERSION)@g' \
	    -e 's@%PROGRAMS%@$(bin_PROGRAMS)@g' \
	    -e 's@%SOURCES%@$(filter-out remote-%,$(make_SOURCES)) remote-$$(REMOTE).c@g' \
	    -e 's@%OBJECTS%@$(filter-out remote-%,$(make_OBJECTS)) remote-$$(REMOTE).o@g' \
	    -e 's@%GLOB_SOURCES%@$(globsrc) $(globhdr)@g' \
	    -e 's@%GLOB_OBJECTS%@$(globsrc:glob/%.c=%.o)@g' \
	  $< > $@
	echo >>$@; echo '# --------------- DEPENDENCIES' >>$@; echo '#' >>$@; \
	  cat $(word 2,$^) >>$@
	chmod a-w $@

NMakefile: NMakefile.template .dep_segment Makefile
	rm -f $@
	cp $< $@
	echo >>$@; echo '# --------------- DEPENDENCIES' >>$@; echo '#' >>$@; \
	  sed 's/^\([^ ]*\)\.o:/$$(OUTDIR)\/\1.obj:/' $(word 2,$^) >>$@
	chmod a-w $@

# Construct build.sh.in
#
build.sh.in: build.template Makefile
	rm -f $@
	sed -e 's@%objs%@$(filter-out remote-%,$(make_OBJECTS)@g' \
	    -e 's@%globobjs%@$(patsubst %.c,%.o,$(globsrc)))@g' \
	  $< > $@
	chmod a-w+x $@


# Use automake to build a dependency list file, for "foreign" makefiles like
# Makefile.DOS.
#
# Automake used to have a --generate-deps flag, but it's gone now, so we have
# to do it ourselves.
#
.dep_segment: Makefile.am maintMakefile $(DEP_FILES)
	cat $(DEP_FILES) \
	  | sed -e '/^[^:]*\.[ch] *:/d' \
		-e 's, /usr/[^ ]*,,g' \
		-e 's, $(srcdir)/, ,g' \
		-e '/^ \\$$/d' \
	  > $@

# Get rid of everything "else".
#
maintFILES = configure aclocal.m4 config.h.in Makefile.in stamp-h.in

MAINTAINERCLEANFILES +=	$(maintFILES) $(TEMPLATES) $(MTEMPLATES) NMakefile \
			missing build.sh.in .dep_segment

# Put the alpha distribution files up for anonymous FTP.
#
ALPHA	:= ~ftp/gnu
TARFILE	:= $(distdir).tar.gz

.PHONY: alpha
alpha: $(ALPHA) $(TARFILE)
	@rm -f $(ALPHA)/$(TARFILE)
	cp -p $(TARFILE) $(ALPHA)


# ----------------------------------------------------------------------
#
# The sections below were stolen from the Makefile.maint used by fileutils,
# sh-utils, textutils, CPPI, Bison, and Autoconf.


## ---------------- ##
## Updating files.  ##
## ---------------- ##

WGET = wget --passive-ftp --non-verbose
ftp-gnu = ftp://ftp.gnu.org/gnu

move_if_change =  if test -r $(target) && cmp -s $(target).t $(target); then \
		    echo $(target) is unchanged; rm -f $(target).t; \
		  else \
		    mv $(target).t $(target); \
		  fi

# ------------------- #
# Updating PO files.  #
# ------------------- #

po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
.PHONY: do-po-update po-update
do-po-update:
	tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
	rm -rf $$tmppo && \
	mkdir $$tmppo && \
	(cd $$tmppo && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
	cp $$tmppo/*.po po
	cd po && $(MAKE) update-po
	$(MAKE) po-check

po-update:
	if test -d "po"; then \
	  $(MAKE) do-po-update; \
	fi

# -------------------------- #
# Updating GNU build tools.  #
# -------------------------- #

# The following pseudo table associates a local directory and a URL
# with each of the files that belongs to some other package and is
# regularly updated from the specified URL.
#              $(srcdir)/src/ansi2knr.c


wget_files ?= $(srcdir)/config/config.guess $(srcdir)/config/config.sub \
	      $(srcdir)/doc/texinfo.tex $(srcdir)/doc/make-stds.texi \
	      $(srcdir)/doc/fdl.texi

wget-targets = $(patsubst %, get-%, $(wget_files))

config.guess-url_prefix = $(ftp-gnu)/config/
config.sub-url_prefix = $(ftp-gnu)/config/

ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/

texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/

standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/
make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/
fdl.texi-url_prefix = $(ftp-gnu)/GNUinfo/

target = $(patsubst get-%,%,$@)
url = $($(notdir $(target))-url_prefix)$(notdir $(target))

.PHONY: $(wget-targets)
$(wget-targets):
	@echo $(WGET) $(url) -O $(target) \
	  && $(WGET) $(url) -O $(target).t \
	  && $(move_if_change)

.PHONY: wget-update
wget-update: $(wget-targets)


# Updating tools via CVS.
cvs_files ?= depcomp missing
cvs-targets = $(patsubst %, get-%, $(cvs_files))

automake_repo = :pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake
.PHONY: $(cvs-targets)
$(cvs-targets):
	$(CVS) -d $(automake_repo) co -p automake/lib/$(notdir $(target)) \
	  >$(target).t \
	    && $(move_if_change)

.PHONY: cvs-update
cvs-update: $(cvs-targets)


# --------------------- #
# Updating everything.  #
# --------------------- #

.PHONY: update
update: wget-update po-update

# cvs-update


## --------------- ##
## Sanity checks.  ##
## --------------- ##

# Checks that don't require cvs.  Run `changelog-check' last as
# previous test may reveal problems requiring new ChangeLog entries.
local-check: po-check changelog-check

# copyright-check writable-files

changelog-check:
	if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
	  :; \
	else \
	  echo "$(VERSION) not in ChangeLog" 1>&2; \
	  exit 1; \
	fi

# Verify that all source files using _() are listed in po/POTFILES.in.
po-check:
	if test -f po/POTFILES.in; then \
	  grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
	  grep -E -l '\b_\(' lib/*.c src/*.c | sort > $@-2; \
	  diff -u $@-1 $@-2 || exit 1; \
	  rm -f $@-1 $@-2; \
	fi