summaryrefslogtreecommitdiffstats
path: root/Makefile.in
blob: 72a114c2d3862030cc4221b044a7fb5d6f68f8e0 (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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# Makefile(.in) for xcftools
# This file was written by Henning Makholm <henning@makholm.net>
# It is hereby in the public domain.
# 
# In jurisdictions that do not recognise grants of copyright to the
# public domain: I, the author and (presumably, in those jurisdictions)
# copyright holder, hereby permit anyone to distribute and use this code,
# in source code or binary form, with or without modifications. This
# permission is world-wide and irrevocable.
#
# Of course, I will not be liable for any errors or shortcomings in the
# code, since I give it away without asking any compenstations.
#
# If you use or distribute this code, I would appreciate receiving
# credit for writing it, in whichever way you find proper and customary.

all:

datarootdir		= @datarootdir@
srcdir			= @srcdir@
prefix			= @prefix@
exec_prefix		= @exec_prefix@
bindir			= @bindir@
mandir			= @mandir@
datadir			= @datadir@
sysconfdir		= @sysconfdir@
localedir		= $(datadir)/locale

VERSION			= @PACKAGE_VERSION@
APPNAME			= @PACKAGE_TARNAME@
program_transform_name	= @program_transform_name@

CC			= @CC@
CFLAGS			= @CFLAGS@
LDFLAGS			= @LDFLAGS@ @LIBICONV@
LIBS			= @LIBS@

INSTALL			= @INSTALL@ -D
INSTALL_PROGRAM		= @INSTALL_PROGRAM@
INSTALL_DATA		= @INSTALL_DATA@

RM			= rm -f
SED			= sed
PERL			= @PERL@

o			= @OBJEXT@
e			= @EXEEXT@

# Allow using Makefile.in directly for cleaning and distmaking purposes
ifneq (,$(findstring @,$o))
e 			=
srcdir			= .
endif

#############################################################################

FILEIO			= io-unix

BINARIES		= xcfinfo$e xcf2pnm$e xcf2png$e xcfview
COMMANDS		= $(patsubst %$e,%,$(BINARIES))
MANPAGES		= $(patsubst %,%.1,$(COMMANDS))

ifeq (@USE_NLS@,yes)
LINGUAS			= da
MANLINGUAS		= da
endif

DEFAULT_VERBOSITY	= 1
V_CC			= $(V_CC_$(V))
V_CC_			= $(V_CC_$(DEFAULT_VERBOSITY))
V_CC_0			= @echo '  CC      ' '$@';
V_CC_1			=
V_CCLD			= $(V_CCLD_$(V))
V_CCLD_			= $(V_CCLD_$(DEFAULT_VERBOSITY))
V_CCLD_0		= @echo '  CCLD    ' '$@';
V_CCLD_1		=
V_GEN			= $(V_GEN_$(V))
V_GEN_			= $(V_GEN_$(DEFAULT_VERBOSITY))
V_GEN_0			= @echo '  GEN     ' '$@';
V_GEN_1			=
V_at			= $(V_at_$(V))
V_at_			= $(V_at_$(DEFAULT_VERBOSITY))
V_at_0			= @
V_at_1			=
V_echo			= $(V_echo_$(V))
V_echo_			= $(V_echo_$(DEFAULT_VERBOSITY))
V_echo_0		= :
V_echo_1		= echo

%.$o: %.c
	$(V_CC)$(CC) $(CFLAGS) -o $@ -c $<


all: $(BINARIES) $(SCRIPTS) $(MANPAGES) po/stamp manpo/all

xcfinfo$e: xcfinfo.$o $(FILEIO).$o enums.$o xcf-general.$o utils.$o nlsini.$o
	$(V_CCLD)$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)

xcf2pnm$e: xcf2pnm.$o $(FILEIO).$o enums.$o xcf-general.$o utils.$o nlsini.$o \
	   pixels.$o flatten.$o flatspec.$o scaletab.$o table.$o
	$(V_CCLD)$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)

xcf2png$e: xcf2png.$o $(FILEIO).$o enums.$o xcf-general.$o utils.$o nlsini.$o \
	   pixels.$o flatten.$o flatspec.$o scaletab.$o table.$o palette.$o
	$(V_CCLD)$(CC) $(LDFLAGS) $^ -o $@ $(LIBS) -lpng

xcfview: xcfview.in Makefile
	$(V_GEN)sed '1s,/usr/bin/perl,@PERL@,' < $< > $@

testscale$e: testscale.$o
	$(V_CCLD)$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)

install: all
	for p in $(BINARIES) ; do \
	  case $$p in xcfview) strip= ;; *) strip=-s ;; esac ; \
	  $(INSTALL_PROGRAM) $$strip $$p \
	    $(DESTDIR)$(bindir)/`echo $$p | $(SED) $(program_transform_name)` \
	    || exit 1 ;\
        done
	for m in $(MANPAGES) ; do \
	  $(INSTALL_DATA) $$m \
	    $(DESTDIR)$(mandir)/man1/`echo $$m | $(SED) $(program_transform_name)` \
	    || exit 1 ; \
	done
	for lang in $(LINGUAS) ; do \
	  $(srcdir)/install-sh -d $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES ; \
	  $(INSTALL_DATA) po/$$lang.mo \
		$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(APPNAME).mo \
	  || exit 1 ; \
	done
	for L in $(MANLINGUAS) ; do \
	   $(srcdir)/install-sh -d $(DESTDIR)$(mandir)/$$L/man1 || exit 1 ; \
	   for P in $(patsubst %.1,%,$(MANPAGES)) ; do \
		$(INSTALL_DATA) manpo/$$P.$$L.1 $(DESTDIR)$(mandir)/$$L/man1/$$P.1 \
		|| exit 1; done ; done ;

C_GENERATED = enums.c table.c nlsini.c

ENUMSOURCES = gimp/base-enums.h gimp/gimpbaseenums.h gimp/xcf-private.h
enums.h: mkenumsh.pl $(ENUMSOURCES)
	$(V_GEN)$(PERL) $< $(ENUMSOURCES) > $@
enums.c: mkenumsc.pl enums.h
	$(V_GEN)$(PERL) $< enums.h > $@
table.c: mktablec.pl config.h
	$(V_GEN)$(PERL) $< > $@
nlsini.c: Makefile
	$(V_GEN)echo >$@ "#include \"xcftools.h\""
	$(V_at)echo >>$@ "#ifndef nls_init"
	$(V_at)echo >>$@ "void nls_init(void) {"
	$(V_at)echo >>$@ "  bindtextdomain(\"$(APPNAME)\",\"$(localedir)\");"
	$(V_at)echo >>$@ "  textdomain(\"$(APPNAME)\"); }"
	$(V_at)echo >>$@ "#endif"

%.oi: options.i mkopti.pl config.h
	$(V_GEN)$(PERL) mkopti.pl $*

%.1: %.oi %.10 config.h mancombine.pl
	$(V_GEN)$(PERL) mancombine.pl $*.10 > $@

#############################################################################
#
#  Localization stuff

POTFILES_NONC = $(patsubst %$e,%.oi,$(BINARIES)) options.i

po/$(APPNAME).pot$(SUPPRESS_AUTOFOO): $(POTFILES_NONC) \
		$(filter-out table.c nlsini.c, $(C_GENERATED) $(wildcard *.c))
	$(V_GEN)xgettext -o $@.tmp -C -k_ -kN_ \
		--foreign-user --msgid-bugs-address=henning@makholm.net \
		--flag=FatalGeneric:2:c-format \
		--flag=FatalUnexpected:1:c-format \
		--flag=FatalBadXCF:1:c-format \
		--flag=FatalUnsupportedXCF:1:c-format \
		$^
	$(V_at)if diff $@ $@.tmp | \
		grep -v '^\([^<>]\|. \?"POT-Creation-Date:\)' > /dev/null; \
	then mv -f $@.tmp $@ ; \
	else $(V_echo) OK, $@ is unchanged ; rm $@.tmp ; fi

po/%.po: po/$(APPNAME).pot
	$(V_GEN)test -f $@
	$(V_at)msgmerge -U $@ $<
	$(V_at)touch $@

po/%.mo: po/%.po
	$(V_GEN)msgfmt -c -o$@ $<

po/stamp: $(patsubst %,po/%.mo,$(LINGUAS))
	$(V_GEN)if ! make -q po/$(APPNAME).pot ; then \
	touch po/$(APPNAME).pot ; touch po/*.po ; touch po/*.mo ; fi
	$(V_at)touch $@

# Manpage localization stuff

POTFILES_MAN = options.mi $(patsubst %.1,%.10,$(MANPAGES)) \
		exit.1i

options.mi: manpo/optipot.pl options.i
	$(V_GEN)$(PERL) manpo/optipot.pl > $@
manpo/manpages.pot$(SUPPRESS_AUTOFOO): manpo/mantranslate.pl $(POTFILES_MAN)
	$(V_GEN)$(PERL) manpo/mantranslate.pl -x $(POTFILES_MAN) > $@.tmp
	$(V_at)if diff $@ $@.tmp | \
		grep -v '^\([^<>]\|. \?"POT-Creation-Date:\)' > /dev/null; \
	then mv -f $@.tmp $@ ; \
	else $(V_echo) OK, $@ is unchanged ; rm $@.tmp ; fi

manpo/%.po: manpo/manpages.pot
	$(V_GEN)test -f $@
	$(V_at)msgmerge -U $@ $<
	$(V_at)touch $@

manpo/stamp: $(patsubst %,manpo/%.po,$(MANLINGUAS))
	$(V_GEN)if ! make -q manpo/manpages.pot ; then \
	touch manpo/manpages.pot ; touch $^ ; fi
	$(V_at)touch $@

manpo/all: manpo/stamp $(MANPAGES)
	$(V_GEN)for L in $(MANLINGUAS) ; do \
	   for P in $(patsubst %.1,%,$(MANPAGES)) ; do \
	      $(PERL) manpo/mantranslate.pl manpo/$$L.po $$P.1 \
		> manpo/$$P.$$L.1 || exit 1; done ; done ;
	$(V_at)touch $@

#############################################################################
#
#  Dependency tracking, by hand

COMMON_HEADERS = xcftools.h config.h enums.h
enums.$o:	enums.h
nlsini.$o:	$(COMMON_HEADERS)
table.$o:	$(COMMON_HEADERS) pixels.h
scaletab.$o:	$(COMMON_HEADERS) pixels.h
io-unix.$o:     $(COMMON_HEADERS)
xcf-general.$o: $(COMMON_HEADERS)
utils.$o:	$(COMMON_HEADERS)
pixels.$o:	$(COMMON_HEADERS) pixels.h
palette.$o:	$(COMMON_HEADERS) pixels.h flatten.h     palette.h
flatten.$o:	$(COMMON_HEADERS) pixels.h flatten.h
flatspec.$o:	$(COMMON_HEADERS) pixels.h flatten.h
xcfinfo.$o:     $(COMMON_HEADERS)                    xcfinfo.oi
xcf2pnm.$o:	$(COMMON_HEADERS) pixels.h flatten.h xcf2pnm.oi
xcf2png.$o:	$(COMMON_HEADERS) pixels.h flatten.h xcf2png.oi palette.h

#############################################################################
#
#  Standard cleaning and other metarules

check: $(BINARIES)
	cd test && $(MAKE) check

clean:
	$(RM) *.$o */*~ *~ .*~ xcf*.1i xcf*.1il *.1 *.oi *.mi
	$(RM) enums.h $(C_GENERATED) $(BINARIES)
	$(RM) po/*.mo */stamp manpo/all manpo/*.1
	cd test && $(MAKE) clean

distclean: clean
	$(RM) Makefile config.log config.cache config.status config.h
	$(RM) aclocal.m4
	$(RM) -r autom4te.cache

realclean: distclean
	$(RM) configure config.hin

.SUFFIXES: .c .$o

.PHONY: clean distclean realclean dist all

#############################################################################
#
#  Tarball-making rule

ifeq (,$(findstring @,$o))
dist: ajour $(patsubst %,po/%.po,$(LINGUAS))
	$(MAKE) distclean
	noncvs > notcvsfiles || cp dist-generated notcvsfiles
	diff -u dist-generated notcvsfiles
	$(RM) notcvsfiles
	find . -type f -print | grep -v CVS | grep -v debian | \
		sed 's!^\./!$(APPNAME)-$(VERSION)/!' | sort -o tar-manifest
	ln -s . $(APPNAME)-$(VERSION)
	GZIP=-9 tar cvzf $(APPNAME)-$(VERSION).tar.gz `cat tar-manifest`
	rm tar-manifest
	rm $(APPNAME)-$(VERSION)
else
dist: ajour
	$(MAKE) dist
endif


#############################################################################
#
#  Autofoo rules:

$(srcdir)/configure$(SUPPRESS_AUTOFOO): configure.ac
	cd $(srcdir) && aclocal
	cd $(srcdir) && autoconf
	cd $(srcdir) && autoheader

$(srcdir)/config.hin$(SUPPRESS_AUTOFOO): $(srcdir)/configure

config.status: $(srcdir)/configure config.sub config.guess
	if [ -f config.status ] ; \
	then ./config.status --recheck ; \
	else ./configure ; fi

Makefile$(SUPPRESS_AUTOFOO): Makefile.in config.status
	./config.status $@

config.h: config.hin config.status
	./config.status $@
	touch $@

ajour: Makefile config.h

config.sub config.guess:
	-test -r /usr/share/misc/$@ && cp /usr/share/misc/$@ .

.PHONY: ajour dist