OSDN Git Service

Refactor to consolidate three instances of duplicate code.
[mingw/mingw-get.git] / Makefile.in
1 # @configure_input@
2 #
3 # $Id$
4
5 PACKAGE_TARNAME = @PACKAGE_TARNAME@
6 PACKAGE_VERSION = @PACKAGE_VERSION@
7
8 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
9 # Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project
10 #
11 #
12 # Makefile template for mingw-get
13 #
14 #
15 # This is free software.  Permission is granted to copy, modify and
16 # redistribute this software, under the provisions of the GNU General
17 # Public License, Version 3, (or, at your option, any later version),
18 # as published by the Free Software Foundation; see the file COPYING
19 # for licensing details.
20 #
21 # Note, in particular, that this software is provided "as is", in the
22 # hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
23 # even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
24 # PARTICULAR PURPOSE.  Under no circumstances will the author, or the
25 # MinGW.org Project, accept liability for any damages, however caused,
26 # arising from the use of this software.
27 #
28 PACKAGE_SUBSYSTEM = @host_os@
29
30 CLI_RELEASE_CLASS = @CLI_RELEASE_CLASS@
31 GUI_RELEASE_CLASS = @GUI_RELEASE_CLASS@
32
33 BUILD_TAG = `>> build.tag; cat build.tag`
34 DEBUGLEVEL = @DEBUGLEVEL@
35
36 srcdir = @srcdir@
37 abs_top_srcdir = @abs_top_srcdir@
38
39 vpath %.ico @srcdir@/icons
40 VPATH = @top_srcdir@/src:@top_srcdir@/src/pkginfo:@top_srcdir@/tinyxml
41
42 CC = @CC@
43 CFLAGS = @CFLAGS@
44 CPPFLAGS = @CPPFLAGS@ -D DEBUGLEVEL=$(DEBUGLEVEL) $(INCLUDES)
45
46 CXX = @CXX@
47 CXXFLAGS = $(CFLAGS)
48
49 INCLUDES = -I ${srcdir}/src -I ${srcdir}/src/pkginfo -I ${srcdir}/tinyxml
50
51 LEX = @LEX@
52
53 AR = @AR@
54 ARFLAGS = @ARFLAGS@
55
56 RC = @RC@
57 RC_SCRIPT = tag=$(BUILD_TAG); \
58   test "x$$tag" != x && tag="-$(GUI_RELEASE_CLASS)-$$tag"; \
59     $(TAG_SCRIPT)
60
61 VERSION_SCRIPT = tag=$(BUILD_TAG); \
62   test "x$$tag" != x && tag="-$(CLI_RELEASE_CLASS)-$$tag"; \
63     $(TAG_SCRIPT)
64
65 TAG_SCRIPT = sed \
66   -e "s!%PACKAGE_NAME%!$(PACKAGE_TARNAME)!g" \
67   -e "s!%PACKAGE_VERSION%!$(PACKAGE_VERSION)$$tag!g" \
68   -e "s!%COPYRIGHT_HOLDER%!@COPYRIGHT_HOLDER@!g" \
69   -e "s!%YEARS_OF_ISSUE%!@YEARS_OF_ISSUE@!g"
70
71 RC_INCLUDES = -I ${srcdir}/src -I ${srcdir}/icons
72
73 OBJEXT = @OBJEXT@
74 EXEEXT = @EXEEXT@
75
76 LDFLAGS = @LDFLAGS@
77 GUI_LDFLAGS = -mwindows $(LDFLAGS)
78 LIBS = -Wl,-Bstatic -llua -lz -lbz2 -llzma -Wl,-Bdynamic -lwininet
79
80 CORE_DLL_OBJECTS  =  climain.$(OBJEXT) pkgshow.$(OBJEXT) dmh.$(OBJEXT) \
81    pkgbind.$(OBJEXT) pkginet.$(OBJEXT) pkgstrm.$(OBJEXT) pkgname.$(OBJEXT) \
82    pkgexec.$(OBJEXT) pkgfind.$(OBJEXT) pkginfo.$(OBJEXT) pkgspec.$(OBJEXT) \
83    pkgopts.$(OBJEXT) sysroot.$(OBJEXT) pkghash.$(OBJEXT) pkgkeys.$(OBJEXT) \
84    pkgdeps.$(OBJEXT) pkgreqs.$(OBJEXT) pkginst.$(OBJEXT) pkgunst.$(OBJEXT) \
85    tarproc.$(OBJEXT) xmlfile.$(OBJEXT) keyword.$(OBJEXT) vercmp.$(OBJEXT) \
86    tinyxml.$(OBJEXT) tinystr.$(OBJEXT) tinyxmlparser.$(OBJEXT) \
87    mkpath.$(OBJEXT)  tinyxmlerror.$(OBJEXT)
88
89 CLI_EXE_OBJECTS  =   \
90    clistub.$(OBJEXT) version.$(OBJEXT) approot.$(OBJEXT) getopt.$(OBJEXT)
91
92 GUIMAIN_OBJECTS  =   \
93    guimain.$(OBJEXT) guidata.$(OBJEXT) guixmld.$(OBJEXT) guidmh.$(OBJEXT) \
94    approot.$(OBJEXT) pkgview.$(OBJEXT) pkglist.$(OBJEXT) pkgdata.$(OBJEXT)
95
96 GUIMAIN_LIBS = -lwtklite -lcomctl32
97
98 script_srcdir = ${srcdir}/scripts/libexec
99
100 BIN_PROGRAMS = pkginfo$(EXEEXT) mingw-get$(EXEEXT)
101 LIBEXEC_PROGRAMS = gui$(EXEEXT) guimain$(EXEEXT) lastrites$(EXEEXT)
102 LIBEXEC_SCRIPTS = ${script_srcdir}/setup.lua ${script_srcdir}/wsh.lua \
103    ${script_srcdir}/shlink.js ${script_srcdir}/unlink.js
104 LIBEXEC_DATA = mingw-get-0.dll
105
106 # Primary build goals...
107 #
108 all: $(BIN_PROGRAMS) $(LIBEXEC_PROGRAMS) $(LIBEXEC_DATA)
109
110 pkginfo$(EXEEXT):  driver.$(OBJEXT) pkginfo.$(OBJEXT)
111         $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $+
112
113 mingw-get$(EXEEXT): $(CLI_EXE_OBJECTS)
114         $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $+
115
116 gui$(EXEEXT): guistub.$(OBJEXT) pkgicon.$(OBJEXT)
117         $(CXX) -o $@ $(CXXFLAGS) $(GUI_LDFLAGS) $+
118
119 guimain$(EXEEXT): $(GUIMAIN_OBJECTS) $(LIBEXEC_DATA)
120         $(CXX) -o $@ $(CXXFLAGS) $(GUI_LDFLAGS) $+ $(GUIMAIN_LIBS)
121
122 lastrites$(EXEEXT): rites.$(OBJEXT)
123         $(CC) -o $@ $(CFLAGS) $(GUI_LDFLAGS) $+
124
125 mingw-get-0.dll: $(CORE_DLL_OBJECTS)
126         $(CXX) -shared -o $@ $(CXXFLAGS) $(LDFLAGS) $+ $(LIBS)
127
128 # Compilation and dependency tracking...
129 #
130 DEPFLAGS = -MM -MP -MD
131 sinclude *.d
132
133 %.$(OBJEXT): %.c
134         $(CC) $(DEPFLAGS) $(CPPFLAGS) $(CFLAGS) $<
135         $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
136
137 %.$(OBJEXT): %.cpp
138         $(CXX) $(DEPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $<
139         $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
140
141 %.$(OBJEXT): %.rc
142         $(CC) $(DEPFLAGS) $(RC_INCLUDES) -DRC_INVOKED -xc-header $<
143         $(RC_SCRIPT) $< | $(RC) $(RC_INCLUDES) -o $@
144
145 %.$(OBJEXT): %.ico
146         echo $* ICON $*.ico | $(RC) -I ${srcdir}/icons -o $@
147
148 # Release tagging...
149 #
150 time-stamp:
151 %.tagged.time: time-stamp
152         > $*.time
153
154 %.time:
155         > $*.time
156
157 %.tag: %.tagged.time
158         >> $@; tag=`date +%Y%m%d`; \
159           tag=`awk -F- -v today=$$tag ' \
160             BEGIN { tag = 1 } $$1 == today { tag += $$2 } \
161             END { print today "-" tag }' $@`; \
162           echo $$tag > $@
163
164 %.c: %.c.in
165         $(VERSION_SCRIPT) $< > $@
166
167 version.c: build.time
168 guidata.$(OBJEXT): build.time
169
170 # Installation tools and directory paths...
171 #
172 mkinstalldirs = @MKDIR_P@
173
174 prefix = @prefix@
175 exec_prefix = @exec_prefix@
176 localstatedir = @localstatedir@
177 libexecdir = @libexecdir@
178 bindir = @bindir@
179
180 PACKAGE_CONFIG_DIR = ${localstatedir}/lib/${PACKAGE_TARNAME}/data
181
182 INSTALL = @INSTALL@
183 INSTALL_DATA = @INSTALL_DATA@
184 INSTALL_PROGRAM = @INSTALL_PROGRAM@
185 INSTALL_SCRIPT = @INSTALL_SCRIPT@
186
187 STRIP = @STRIP@
188 LN_S = @LN_S@
189
190 # Installation rules...
191 #
192 installdirs:
193         $(mkinstalldirs) ${bindir}
194         $(mkinstalldirs) ${libexecdir}/${PACKAGE_TARNAME}
195         $(mkinstalldirs) ${PACKAGE_CONFIG_DIR}
196
197 install: installdirs install-profile
198         for image in $(BIN_PROGRAMS); do \
199           $(INSTALL_PROGRAM) $$image ${bindir}; \
200           done
201         for image in $(LIBEXEC_PROGRAMS); do \
202           $(INSTALL_PROGRAM) $$image ${libexecdir}/${PACKAGE_TARNAME}; \
203           done
204         for image in $(LIBEXEC_DATA) $(LIBEXEC_SCRIPTS); do \
205           $(INSTALL_DATA) $$image ${libexecdir}/${PACKAGE_TARNAME}; \
206           done
207
208 install-profile:
209         $(INSTALL_DATA) ${srcdir}/xml/profile.xml \
210           ${PACKAGE_CONFIG_DIR}/defaults.xml
211
212 install-strip: install
213         for image in $(BIN_PROGRAMS); do \
214           $(STRIP) ${bindir}/$$image; \
215           done
216         for image in $(LIBEXEC_PROGRAMS) $(LIBEXEC_DATA); do \
217           $(STRIP) ${libexecdir}/${PACKAGE_TARNAME}/$$image; \
218           done
219
220 # Packaging and distribution...
221 #
222 LICENCE_FILES = README COPYING
223 SRCDIST_FILES = $(LICENCE_FILES) ChangeLog NEWS INSTALL \
224   aclocal.m4 configure.ac configure Makefile.in version.c.in
225
226 SRCDIST_SUBDIRS = build-aux build-aux/m4 icons src src/pkginfo \
227   srcdist-doc scripts/libexec tinyxml xml
228
229 # The names of distributed package archive files incorporate version
230 # information, derived from PACKAGE_VERSION; this is decomposed, so that
231 # the PACKAGE_SUBSYSTEM may be interposed between the principal version
232 # number and any qualifying suffix, which specifies development status.
233 # Additionally, the package maintainer may specify, (at `make dist' time),
234 # a SNAPSHOT qualifier; if specified, this will be appended, (literally),
235 # to the principal version number component of the package version number,
236 # as it appears in the distributed archive file names.
237 #
238 PACKAGE_DISTROOT = $(PACKAGE_TARNAME)-$(PACKAGE_ROOTVERSION)
239 PACKAGE_ROOTVERSION = `echo $(PACKAGE_VERSION) | sed 's,-[^0-9].*,,'`
240 PACKAGE_DISTVERSION = `echo $(PACKAGE_VERSION)-$(PACKAGE_SUBSYSTEM) | sed \
241   -e 's,-[^0-9],-$(PACKAGE_SUBSYSTEM)&,' \
242   -e 's,\(-$(PACKAGE_SUBSYSTEM).*\)-$(PACKAGE_SUBSYSTEM),\1,' \
243   -e 's,-$(PACKAGE_SUBSYSTEM),$(SNAPSHOT)&,'`
244 PACKAGE_DISTNAME = $(PACKAGE_TARNAME)-$(PACKAGE_DISTVERSION)
245
246 dist: srcdist bindist readme.txt
247
248 # Specify default compression command, and associated file name extension,
249 # for creation and identification of packaged tar archives.
250 #
251 TARZIP = xz
252 TAREXT = tar.$(TARZIP)
253
254 bindist: all licdist
255         rm -rf staged
256         $(MAKE) --no-print-directory prefix=`pwd`/staged install-strip
257         cd staged; tar chf - bin/pkginfo$(EXEEXT) | $(TARZIP) -c > \
258           ../pkginfo-$(PACKAGE_DISTVERSION)-bin.$(TAREXT)
259         rm staged/bin/pkginfo$(EXEEXT)
260         cd staged; tar chf - * | $(TARZIP) -c > \
261           ../$(PACKAGE_DISTNAME)-bin.$(TAREXT)
262         cd staged; zip -r ../$(PACKAGE_DISTNAME)-bin.zip *
263         rm -rf staged
264
265 licdist:
266         rm -rf share
267         $(mkinstalldirs) ./share/doc/${PACKAGE_TARNAME}
268         cd ./share/doc/${PACKAGE_TARNAME}; for file in $(LICENCE_FILES); \
269           do test -f ${abs_top_srcdir}/$$file \
270             && $(LN_S) ${abs_top_srcdir}/$$file . \
271             || $(LN_S) ${CURDIR}/$$file .; \
272           done
273         tar chf - share | $(TARZIP) -c > $(PACKAGE_DISTNAME)-lic.$(TAREXT)
274         rm -rf share
275
276 srcdist: srcdist-doc
277         rm -rf ${PACKAGE_DISTROOT} && mkdir ${PACKAGE_DISTROOT}
278         cd ${PACKAGE_DISTROOT}; for file in $(SRCDIST_FILES); do \
279           test -f ${abs_top_srcdir}/$$file \
280             && $(LN_S) ${abs_top_srcdir}/$$file . \
281             || $(LN_S) ../$$file .; \
282           done
283         for dir in $(SRCDIST_SUBDIRS); do \
284           $(mkinstalldirs) ${PACKAGE_DISTROOT}/$$dir \
285           && cd ${PACKAGE_DISTROOT}/$$dir; \
286           for file in `cd ${abs_top_srcdir}/$$dir && echo *`; do \
287             if test -f ${abs_top_srcdir}/$$dir/$$file; then \
288               $(LN_S) ${abs_top_srcdir}/$$dir/$$file .; \
289             fi; \
290           done; \
291         cd ${CURDIR}; done
292         cd ${PACKAGE_DISTROOT}/src/pkginfo; $(LN_S) ${CURDIR}/pkginfo.c .
293         tar chf - ${PACKAGE_DISTROOT} | $(TARZIP) -c > \
294           ${PACKAGE_DISTNAME}-src.$(TAREXT)
295         rm -rf ${PACKAGE_DISTROOT}
296
297 # README, INSTALL and NEWS files to be included in the source distribution
298 # are generated on demand, as indirect side effects of a set of phoney goals
299 # so that they are always regenerated for each distribution, from templates
300 # in srcdist-doc so that we can make them version specific.
301 #
302 vpath %.in ${srcdir}/srcdist-doc
303 srcdist-doc: README.dist NEWS.dist INSTALL.dist
304
305 # We need to ensure that, when we invoke nroff, the generated output
306 # will be suited to an ASCII class of typesetter; without the -Tascii
307 # option, GNU nroff will substitute Unicode hyphens (u2010) in place
308 # of ASCII hyphens (code 45).
309 #
310 NROFF = nroff -Tascii
311
312 %.dist: %.in gendoc.simple.sed
313         sed -f gendoc.simple.sed $< | $(NROFF) > $*
314
315 %.simple.sed: %.sed.in
316         sed -e s,'$${PACKAGE_DIRNAME}',"${PACKAGE_DISTROOT}", \
317             -e s,'$${PACKAGE_DISTNAME}',"${PACKAGE_DISTNAME}", $< > $@
318
319 %.combined.sed: %.sed.in
320         sed -e s,'$${PACKAGE_DIRNAME}',"${PACKAGE_DISTROOT}", \
321             -e s,'$${PACKAGE_DISTNAME}',"${PACKAGE_DISTNAME}", \
322             -e s,'^# *cut:',, $< > $@
323
324 # The following rules use sed and awk to match the RCS Id keyword;
325 # we define and use the following macro, in the form "$(DOLLAR)Id:",
326 # to avoid unwanted substitution on CVS checkout.
327 #
328 DOLLAR = $$
329
330 # The following rule provides a mechanism for generating a composite from
331 # README, INSTALL and NEWS, for use as an on-line package description.
332 #
333 readme.txt: gendoc.combined.sed readme.txt.tag readme.txt.in
334         sed s,'$(DOLLAR)Id:.*',"`cat $@.tag`", $@.in > $@
335         echo '$$Document: $@ $$: end of file' >> $@
336         rm -f gendoc.combined.sed $@.*
337
338 # There should be a new generation of readme.txt for each package release;
339 # since each release should also include an updated NEWS file; we adopt the
340 # ID tag-line from NEWS.in, as most the appropriate template for generation
341 # of a corresponding tag-line for readme.in
342 #
343 readme.txt.tag: NEWS.in
344         awk '/\$(DOLLAR)Id:/{ $$2 = "readme.txt\\,v"; print }' $^ > $@
345
346 # The tag-line generated by the preceding rule may then be substituted, by
347 # the primary readme.txt generation rule above, into the document template
348 # generated by the following rule
349 #
350 readme.txt.in: README.in NEWS.in INSTALL.in
351         rm -f $@
352         for input in $^; do \
353           sed -f gendoc.combined.sed $$input | $(NROFF) >> $@; \
354           done
355
356 # Workspace clean-up...
357 #
358 clean:
359         rm -f *.$(OBJEXT) *.d *.dll $(BIN_PROGRAMS) $(LIBEXEC_PROGRAMS)
360
361 distclean: clean
362         rm -f config.* version.c
363
364 maintainer-clean: distclean
365         rm -f README NEWS INSTALL readme.txt Makefile pkginfo.c
366         rm -f *-$(PACKAGE_DISTVERSION)-*.tar.* *-$(PACKAGE_DISTVERSION)-*.zip
367         rm -rf ${PACKAGE_DISTROOT} staged ${srcdir}/autom4te.cache
368
369 # $RCSfile$: end of file