1# Copyright (C) 2016 and later: Unicode, Inc. and others.
2# License & terms of use: http://www.unicode.org/copyright.html
3#******************************************************************************
4#
5#   Copyright (C) 1998-2016, International Business Machines
6#   Corporation and others.  All Rights Reserved.
7#
8#******************************************************************************
9## Top-level Makefile.in for ICU
10## Stephen F. Booth
11
12srcdir = @srcdir@
13top_srcdir = @top_srcdir@
14
15top_builddir = .
16
17include $(top_builddir)/icudefs.mk
18
19docdir = $(datadir)/doc
20docsubdir = $(PACKAGE)$(ICULIBDASHSUFFIX)/html
21docfilesdir = doc/html
22docfiles = $(docfilesdir)/*.png $(docfilesdir)/*.html $(docfilesdir)/*.css $(docfilesdir)/*.tag
23docsrchdir = $(docfilesdir)/search
24docsrchfiles = $(docsrchdir)/*
25
26##
27
28## Build directory information
29subdir = .
30
31#AUTOCONF = @AUTOCONF@
32
33## Optional directory setup
34@LAYOUTEX_TRUE@LAYOUTEX = layoutex
35@ICUIO_TRUE@ICUIO = io
36@EXTRAS_TRUE@EXTRA = extra
37@TESTS_TRUE@TEST = test
38@SAMPLES_TRUE@SAMPLE = samples
39@TOOLS_TRUE@TOOLS = tools
40
41## pkgconfig setup. Always have uc and i18n. Others are optional.
42ALL_PKGCONFIG_SUFFIX=uc i18n
43@LAYOUTEX_TRUE@ALL_PKGCONFIG_SUFFIX+= lx
44@ICUIO_TRUE@ALL_PKGCONFIG_SUFFIX+= io
45
46DOXYGEN = @DOXYGEN@
47DOCZIP = icu-docs.zip
48
49## Files to remove for 'make clean'
50CLEANFILES = *~
51
52ALL_PKGCONFIG_FILES=$(ALL_PKGCONFIG_SUFFIX:%=$(top_builddir)/config/icu-%.pc)
53
54## Files built (autoconfed) and installed
55INSTALLED_BUILT_FILES = $(top_builddir)/config/Makefile.inc $(top_builddir)/config/pkgdata.inc $(top_builddir)/config/icu-config @platform_make_fragment@ $(EXTRA_DATA:%=$(DESTDIR)$(pkglibdir)/%) $(ALL_PKGCONFIG_FILES)
56
57## Files built (autoconfed) but not installed
58LOCAL_BUILT_FILES = icudefs.mk config/icucross.mk config/icucross.inc
59
60DOCDIRS = common i18n
61SUBDIRS =  stubdata common i18n $(LAYOUTEX) $(ICUIO) $(TOOLS) data $(EXTRA) $(SAMPLE) $(TEST)
62
63SECTION = 1
64
65MANX_FILES = config/icu-config.$(SECTION)
66
67ALL_MAN_FILES = $(MANX_FILES)
68
69## Extra files to install [nothing at present]
70EXTRA_DATA =
71
72## List of phony targets
73.PHONY : all all-local all-recursive install install-local install-udata install-udata-files install-udata-dlls		\
74install-recursive clean clean-local clean-recursive distclean		\
75distclean-local distclean-recursive doc dist dist-local dist-recursive	\
76check check-local check-recursive clean-recursive-with-twist install-icu \
77doc install-doc tests icu4j-data icu4j-data-install update-windows-makefiles xcheck-local xcheck-recursive xperf xcheck xperf-recursive \
78check-exhaustive check-exhaustive-local check-exhaustive-recursive releaseDist
79
80## Clear suffix list
81.SUFFIXES :
82
83## List of standard targets
84all: all-local all-recursive
85install: install-recursive install-local
86clean: clean-recursive-with-twist clean-local
87distclean : distclean-recursive distclean-local
88dist: dist-recursive dist-local
89check: all check-recursive
90check-recursive: all
91xcheck: all xcheck-recursive
92xperf: all xperf-recursive
93check-exhaustive: all check-exhaustive-recursive
94
95pcheck: all tests
96	@$(MAKE) -C test pcheck
97
98check-exhaustive-local: check-local
99
100xcheck-recursive: all xcheck-local
101	@$(MAKE) -C test xcheck
102
103xperf-recursive: all tests
104	@$(MAKE) -C test/perf xperf
105
106$(top_builddir)/config/icuinfo.xml: all
107	@$(MAKE) -C tools/icuinfo check
108
109ifeq ($(DOXYGEN),)
110doc doc-searchengine:
111	@echo you need Doxygen to generate documentation. Doxygen can be found on the Web
112	@echo at http://www.doxygen.org/
113else
114doc: doc/html/index.html
115
116doc-searchengine: Doxyfile $(wildcard ./common/unicode/platform.h $(srcdir)/common/unicode/*.h $(srcdir)/i18n/unicode/*.h $(srcdir)/io/unicode/*.h)
117	sed < Doxyfile -e 's%[^#]*SEARCHENGINE.*%SEARCHENGINE=YES%' | $(DOXYGEN) -
118	@echo adding links from non-namespaced class files
119	find doc/html -name 'classicu_1_1*' -print | sed -e 's%^\(.*class\)icu_1_1\(.*\)$$%ln & \1\2%' | sh
120	@echo Docs created - WARNING, probably contains non-GPL .js files
121
122doc/html/index.html: Doxyfile $(wildcard ./common/unicode/platform.h $(srcdir)/common/unicode/*.h $(srcdir)/i18n/unicode/*.h $(srcdir)/io/unicode/*.h)
123	$(DOXYGEN)
124	@echo adding links from non-namespaced class files
125	find doc/html -name 'classicu_1_1*' -print | sed -e 's%^\(.*class\)icu_1_1\(.*\)$$%ln & \1\2%' | sh
126
127Doxyfile: $(srcdir)/Doxyfile.in
128	CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
129
130$(DOCZIP): doc
131	-$(RMV) $(DOCZIP)
132	( cd doc/html ; zip -r ../../$(DOCZIP) * )
133endif
134
135LOCAL_SUBDIRS = $(SUBDIRS)
136CLEAN_FIRST_SUBDIRS = $(TOOLS)
137
138$(LIBDIR) $(BINDIR):
139	-$(MKINSTALLDIRS) $@
140
141## Recursive targets
142## Strictly speaking, the $(MAKEOVERRIDES) is not necessary when recursing, but
143## there is a bug in GNU make 3.82 that throws away the original overrides in
144## favor of RECURSIVE=YES when the submake in the subdirectory restarts itself
145## after dependency files have been created.
146all-recursive install-recursive clean-recursive distclean-recursive dist-recursive check-recursive check-exhaustive-recursive: $(LIBDIR) $(BINDIR)
147	@dot_seen=no; \
148	target=`echo $@ | sed s/-recursive//`; \
149	list='$(LOCAL_SUBDIRS)'; for subdir in $$list; do \
150	  echo "$(MAKE)[$(MAKELEVEL)]: Making \`$$target' in \`$$subdir'"; \
151	  if test "$$subdir" = "."; then \
152	    dot_seen=yes; \
153	    local_target="$$target-local"; \
154	  else \
155	    local_target="$$target"; \
156	  fi; \
157	  (cd $$subdir && $(MAKE) $(MAKEOVERRIDES) RECURSIVE=YES $$local_target) || exit; \
158	done; \
159	if test "$$dot_seen" = "no"; then \
160	  $(MAKE) "$$target-local" || exit; \
161	fi
162
163clean-recursive-with-twist:
164	$(MAKE) clean-recursive LOCAL_SUBDIRS='$(CLEAN_FIRST_SUBDIRS) $(filter-out $(CLEAN_FIRST_SUBDIRS),$(LOCAL_SUBDIRS))'
165
166all-local: $(srcdir)/configure $(LOCAL_BUILT_FILES) $(INSTALLED_BUILT_FILES)
167ifndef VERBOSE
168	@echo "Note: rebuild with \"$(MAKE) VERBOSE=1 $(MAKECMDGOALS)\" to show all compiler parameters."
169endif
170install-local: install-icu install-manx
171
172# always installs. Used by layoutex.
173install-pkgconfig: $(ALL_PKGCONFIG_FILES)
174	@$(MKINSTALLDIRS) $(DESTDIR)$(libdir)/pkgconfig
175	$(INSTALL_DATA) $(ALL_PKGCONFIG_FILES) $(DESTDIR)$(libdir)/pkgconfig/
176
177install-icu: $(INSTALLED_BUILT_FILES)
178	@$(MKINSTALLDIRS) $(DESTDIR)$(pkgdatadir)/config
179	@$(MKINSTALLDIRS) $(DESTDIR)$(pkglibdir)
180	@$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
181	@$(MKINSTALLDIRS) $(DESTDIR)$(sbindir)
182	$(INSTALL_DATA) @platform_make_fragment@ $(DESTDIR)$(pkgdatadir)/config/@platform_make_fragment_name@
183	$(INSTALL_SCRIPT) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(pkgdatadir)/mkinstalldirs
184	$(INSTALL_SCRIPT) $(top_srcdir)/install-sh $(DESTDIR)$(pkgdatadir)/install-sh
185	@$(MKINSTALLDIRS) $(DESTDIR)$(libdir)/pkgconfig
186	$(INSTALL_DATA) $(ALL_PKGCONFIG_FILES) $(DESTDIR)$(libdir)/pkgconfig/
187	$(INSTALL_DATA) $(top_srcdir)/../LICENSE $(DESTDIR)$(pkgdatadir)/LICENSE
188	$(INSTALL_SCRIPT) $(top_builddir)/config/icu-config $(DESTDIR)$(bindir)/icu-config
189	$(INSTALL_DATA) $(top_builddir)/config/Makefile.inc $(DESTDIR)$(pkglibdir)/Makefile.inc
190	$(INSTALL_DATA) $(top_builddir)/config/pkgdata.inc $(DESTDIR)$(pkglibdir)/pkgdata.inc
191#	@echo icuinfo.xml is built after make check.
192#	-$(INSTALL_DATA) $(top_builddir)/config/icuinfo.xml $(DESTDIR)$(pkglibdir)/icuinfo.xml
193	cd $(DESTDIR)$(pkglibdir)/..; \
194	    $(RM) current && ln -s $(VERSION) current; \
195	    $(RM) Makefile.inc && ln -s current/Makefile.inc Makefile.inc; \
196	    $(RM) pkgdata.inc && ln -s current/pkgdata.inc pkgdata.inc
197
198ifeq ($(DOXYGEN),)
199install-doc:
200else
201install-doc: doc
202	$(RM) -r $(DESTDIR)$(docdir)/$(docsubdir)
203	$(MKINSTALLDIRS) $(DESTDIR)$(docdir)/$(docsubdir)
204	$(INSTALL_DATA) $(docfiles) $(DESTDIR)$(docdir)/$(docsubdir)
205
206endif
207
208$(DESTDIR)$(pkglibdir)/%: $(top_srcdir)/../data/%
209	$(INSTALL_DATA) $< $@
210
211# Build the tests, but don't run them.
212tests: all
213	$(MAKE) -C $(top_builddir)/test
214
215clean-local:
216	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
217	-$(RMV) "test-*.xml"
218	-$(RMV) "perf-*.xml"
219	-$(RMV) $(ALL_PKGCONFIG_FILES) $(top_builddir)/config/icuinfo.xml
220	$(RMV) Doxyfile doc $(DOCZIP)
221
222distclean-local: clean-local
223	$(RMV) $(top_builddir)/config/Makefile.inc $(top_builddir)/config/pkgdata.inc $(top_builddir)/config/icu-config $(top_builddir)/config/icu.pc $(ALL_PKGCONFIG_FILES)
224	$(RMV) config.cache config.log config.status $(top_builddir)/config/icucross.mk $(top_builddir)/config/icucross.inc autom4te.cache uconfig.h.prepend
225	$(RMV) Makefile config/Makefile icudefs.mk $(LIBDIR) $(BINDIR)
226	-$(RMV) dist
227
228check-local: xcheck-local
229	-$(RMV) test-local.xml
230
231xcheck-local: $(top_builddir)/config/icu-config $(top_builddir)/config/Makefile.inc $(top_builddir)/config/pkgdata.inc
232	@echo verifying that icu-config --selfcheck can operate
233	@test "passed" = "$(shell $(top_builddir)/config/icu-config --selfcheck 2>&1)" || (echo "FAIL: icu-config could not run properly." ; exit 1)
234	@echo verifying that $(MAKE) -f Makefile.inc selfcheck can operate
235	@test "passed" = "$(shell $(MAKE) --no-print-directory -f $(top_builddir)/config/Makefile.inc SELFCHECK=1 selfcheck)" || (echo "FAIL: Makefile.inc could not run properly." ; exit 1 )
236	@echo "PASS: config selfcheck OK"
237
238#$(srcdir)/configure : $(srcdir)/configure.ac $(top_srcdir)/aclocal.m4
239#	cd $(srcdir) && aclocal && $(AUTOCONF)
240
241icudefs.mk: $(srcdir)/icudefs.mk.in  $(top_builddir)/config.status
242	cd $(top_builddir) \
243		&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
244
245config/icucross.mk: $(top_builddir)/icudefs.mk  $(top_builddir)/Makefile
246	@echo rebuilding $@
247	@(echo "CROSS_ICU_VERSION=$(VERSION)" ;\
248	  echo "TOOLEXEEXT=$(EXEEXT)" \
249	   ) > $@
250	@(echo 'TOOLBINDIR=$$(cross_buildroot)/bin' ;\
251	  echo 'TOOLLIBDIR=$$(cross_buildroot)/lib' ;\
252	  echo "INVOKE=$(LDLIBRARYPATH_ENVVAR)=$(LIBRARY_PATH_PREFIX)"'$$(TOOLLIBDIR):$$(cross_buildroot)/stubdata:$$(cross_buildroot)/tools/ctestfw:$$$$'"$(LDLIBRARYPATH_ENVVAR)" ;\
253	  echo "PKGDATA_INVOKE=$(LDLIBRARYPATH_ENVVAR)=$(LIBRARY_PATH_PREFIX)"'$$(cross_buildroot)/stubdata:$$(cross_buildroot)/tools/ctestfw:$$(TOOLLIBDIR):$$$$'"$(LDLIBRARYPATH_ENVVAR) " ;\
254	  echo ) >> $@
255
256config/icucross.inc: $(top_builddir)/icudefs.mk  $(top_builddir)/Makefile @platform_make_fragment@
257	@echo rebuilding $@
258	@(grep '^CURR_FULL_DIR' $(top_builddir)/icudefs.mk ; \
259	  grep '^CURR_FULL_DIR' @platform_make_fragment@ || echo ""; \
260	   ) > $@
261
262config/icu.pc: $(srcdir)/config/icu.pc.in
263	cd $(top_builddir) \
264	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
265
266config/icu-uc.pc: config/icu.pc Makefile icudefs.mk
267	@cat config/icu.pc > $@
268	@echo "Description: $(PACKAGE_ICU_DESCRIPTION): Common and Data libraries" >> $@
269	@echo "Name: $(PACKAGE)-uc" >> $@
270	@echo "Libs:" '-L$${libdir}' "${ICULIBS_UC}" "${ICULIBS_DT}" >> $@
271	@echo "Libs.private:" '$${baselibs}' >> $@
272	@echo $@ updated.
273
274config/icu-i18n.pc: config/icu.pc Makefile icudefs.mk
275	@cat config/icu.pc > $@
276	@echo "Description: $(PACKAGE_ICU_DESCRIPTION): Internationalization library" >> $@
277	@echo "Name: $(PACKAGE)-i18n" >> $@
278	@echo "Requires: icu-uc" >> $@
279	@echo "Libs:" "${ICULIBS_I18N}" >> $@
280	@echo $@ updated.
281
282config/icu-io.pc: config/icu.pc Makefile icudefs.mk
283	@cat config/icu.pc > $@
284	@echo "Description: $(PACKAGE_ICU_DESCRIPTION): Stream and I/O Library" >> $@
285	@echo "Name: $(PACKAGE)-io" >> $@
286	@echo "Requires: icu-i18n" >> $@
287	@echo "Libs:" "${ICULIBS_IO}" >> $@
288	@echo $@ updated.
289
290ICULEHB_LIBS=@ICULEHB_LIBS@
291USING_HB=
292ifneq ($(ICULEHB_LIBS),)
293USING_HB=(Using HarfBuzz)
294endif
295
296
297config/icu-lx.pc: config/icu.pc Makefile icudefs.mk
298	@cat config/icu.pc > $@
299	@echo "Description: $(PACKAGE_ICU_DESCRIPTION): Paragraph Layout library $(USING_HB)" >> $@
300	@echo "Name: $(PACKAGE)-lx" >> $@
301ifneq ($(ICULEHB_LIBS),)
302	@echo "Requires: icu-le-hb icu-uc" >> $@
303else
304	@echo "Requires: icu-le" >> $@
305endif
306	@echo "Libs:" "${ICULIBS_LX}" >> $@
307	@echo $@ updated.
308
309
310Makefile: $(srcdir)/Makefile.in icudefs.mk $(top_builddir)/config.status
311	cd $(top_builddir) \
312		&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
313
314$(top_builddir)/config/Makefile.inc: $(srcdir)/config/Makefile.inc.in  $(top_builddir)/config.status
315	cd $(top_builddir) \
316		&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
317
318$(top_builddir)/config/pkgdata.inc: icudefs.mk $(top_builddir)/config/pkgdataMakefile
319	cd $(top_builddir)/config; \
320		$(MAKE) -f pkgdataMakefile
321
322$(top_builddir)/config/pkgdataMakefile:
323	cd $(top_builddir) \
324		&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
325
326$(top_builddir)/config/icu-config: $(top_builddir)/Makefile $(top_srcdir)/config/icu-config-top $(top_srcdir)/config/icu-config-bottom $(top_builddir)/config/Makefile.inc @platform_make_fragment@ $(top_srcdir)/config/make2sh.sed
327	-$(RMV) $@
328	$(INSTALL_SCRIPT) $(top_srcdir)/config/icu-config-top $@
329	chmod u+w $@
330	@echo "# Following from @platform_make_fragment@" >> $@
331	LC_ALL=C sed -f $(top_srcdir)/config/make2sh.sed < $(top_builddir)/config/Makefile.inc | grep -v '#M#' | uniq >> $@
332	LC_ALL=C sed -f $(top_srcdir)/config/make2sh.sed < @platform_make_fragment@ | grep -v '#M#' | uniq >> $@
333	cat $(top_srcdir)/config/icu-config-bottom >> $@
334	chmod u-w $@
335
336config.status: $(srcdir)/configure $(srcdir)/common/unicode/uvernum.h
337	@echo
338	@echo
339	@echo "*** config.status has become stale ***"
340	@echo "   'configure' and/or 'uvernum.h' have changed, please"
341	@echo "  do 'runConfigureICU' (or 'configure') again, as per"
342	@echo "  the readme.html."
343	@echo
344	@echo
345	exit 1
346
347
348install-manx: $(MANX_FILES)
349	$(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(SECTION)
350	$(INSTALL_DATA) $? $(DESTDIR)$(mandir)/man$(SECTION)
351
352config/%.$(SECTION): $(srcdir)/config/%.$(SECTION).in
353	cd $(top_builddir) \
354	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
355
356icu4j-data-install icu4j-data: all tests
357	@echo ICU4J_ROOT=$(ICU4J_ROOT)
358	@$(MAKE) -C test/testdata $@
359	@$(MAKE) -C data $@
360
361# For updating Windows makefiles
362
363WINDOWS_UPDATEFILES=$(srcdir)/data/makedata.mak $(shell find $(srcdir) -name '*.vcproj' -o -name '*.vcxproj')
364
365WINDOWS_UPDATEFILES_SED=config/windows-update.sed
366
367update-windows-makefiles: config.status
368	@echo Updating Windows Makefiles for ICU $(VERSION)
369	CONFIG_FILES=$(WINDOWS_UPDATEFILES_SED) CONFIG_HEADERS= $(SHELL) ./config.status
370	@for file in $(WINDOWS_UPDATEFILES); do \
371	  echo "Updating $$file"; \
372	  mv "$${file}" "$${file}.bak" && \
373	  sed -f $(WINDOWS_UPDATEFILES_SED) < "$${file}.bak" > "$${file}" && \
374	  rm "$${file}.bak"; \
375	done;
376	$(RMV) $(WINDOWS_UPDATEFILES_SED)
377	@echo Please check over the changes carefully before checking them in.
378
379# For building a source distribution.
380distcheck dist-local:
381	$(MAKE) -C . -f $(top_srcdir)/config/dist.mk srcdir="$(srcdir)" top_srcdir="$(top_srcdir)" $@
382
383ifeq ($(DESTDIR),)
384releaseDist:
385	@echo "Please provide DESTDIR when calling the target releaseDist."
386else
387releaseDist: install
388	@echo -n "ICU Version: " > $(DESTDIR)/readme.txt
389	@echo `./config/icu-config --noverify --version` >> $(DESTDIR)/readme.txt
390	@echo -n "HOST: " >> $(DESTDIR)/readme.txt
391	@echo `./config/icu-config --noverify --host` >> $(DESTDIR)/readme.txt
392	@echo -n "CC Compiler: " >> $(DESTDIR)/readme.txt
393	@echo `./config/icu-config --noverify --cc` >> $(DESTDIR)/readme.txt
394	@echo -n "CXX Compiler: " >> $(DESTDIR)/readme.txt
395	@echo `./config/icu-config --noverify --cxx` >> $(DESTDIR)/readme.txt
396endif
397
398check-installed-icu: install
399	@echo "Testing ICU installed in $(prefix)"
400	$(INSTALLED_INVOKE) $(bindir)/icuinfo$(EXEEXT)
401	$(INSTALLED_INVOKE) $(bindir)/uconv$(EXEEXT) -V
402	$(INSTALLED_INVOKE) $(bindir)/genrb$(EXEEXT) -V
403	$(INSTALLED_INVOKE) $(bindir)/gencnval$(EXEEXT) -h
404	@echo INSTALLED ICU IN "$(prefix)" OK!
405