| # -*- makefile -*- | |
| # This is the developer's makefile, not the user's makefile. | |
| # Don't use it unless you know exactly what you do! | |
| # It requires GNU make. | |
| # It obeys the environment variables GNULIB_TOOL, CC, CFLAGS | |
| # if you have set them. | |
| ifneq (,) | |
| This makefile requires GNU Make. | |
| endif | |
| SHELL = /bin/sh | |
| MAKE = make | |
| # [stardust] Allow overriding autotools paths from environment so the Bazel | |
| # sandbox can supply its own versions. | |
| AUTOCONF ?= autoconf | |
| AUTOHEADER ?= autoheader | |
| AUTOMAKE ?= automake-1.16 | |
| ACLOCAL ?= aclocal-1.16 | |
| GPERF ?= gperf | |
| # [stardust] Use CC_FOR_BUILD (host compiler) instead of CC (target compiler) | |
| # for code generators (genaliases, genflags, gentranslit) that must run on the | |
| # build machine during autogen. CFLAGS_FOR_BUILD and LDFLAGS_FOR_BUILD are | |
| # also needed so the host toolchain can find its linker (e.g. -fuse-ld=lld). | |
| # These variables are set by rules_foreign_cc's configure_script.bzl. | |
| CC_FOR_BUILD ?= gcc | |
| CFLAGS_FOR_BUILD ?= | |
| LDFLAGS_FOR_BUILD ?= | |
| CC = $(CC_FOR_BUILD) | |
| CFLAGS = $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -Wall | |
| MAN2HTML = groff -mandoc -Thtml | |
| CP = cp | |
| RM = rm -f | |
| # [stardust] Man page HTML targets removed from 'all' — they require groff | |
| # which is not available in the Bazel sandbox. The upstream list included: | |
| # man/iconv.1.html man/iconv.3.html man/iconv_close.3.html | |
| # man/iconv_open.3.html man/iconvctl.3.html man/iconv_open_into.3.html | |
| all : srclib/Makefile.in \ | |
| configures config.h.in \ | |
| include/iconv.h.build.in \ | |
| lib/aliases.h lib/aliases_sysaix.h lib/aliases_syshpux.h lib/aliases_sysosf1.h lib/aliases_syssolaris.h \ | |
| lib/aliases_aix.h lib/aliases_aix_sysaix.h \ | |
| lib/aliases_osf1.h lib/aliases_osf1_sysosf1.h \ | |
| lib/aliases_dos.h \ | |
| lib/aliases_zos.h \ | |
| lib/aliases_extra.h \ | |
| lib/flags.h lib/translit.h \ | |
| force | |
| cd libcharset && $(MAKE) -f Makefile.devel all | |
| # Before making a new release: | |
| # - check that the encoding lists in README and man/iconv_open.3 are up to date, | |
| # - check that the files in libcharset/lib/ are in sync with the gnulib module | |
| # 'localcharset', | |
| # - increment the version number in | |
| # configure.ac | |
| # include/iconv.h.in | |
| # README | |
| # - update the version info in lib/Makefile.in, | |
| # - $ ./autogen.sh | |
| # Making a new release: | |
| # - $ ./configure CPPFLAGS=-Wall; make; make check | |
| # - $ make dist | |
| # The downstream removes the following GPL modules to avoid importing GPL code that we don't use: | |
| # | |
| # * progname | |
| # * relocatable-prog | |
| # * unlocked-io | |
| # * xalloc | |
| # * libiconv-misc | |
| GNULIB_MODULES = \ | |
| binary-io \ | |
| error \ | |
| gettext \ | |
| gettext-h \ | |
| lib-symbol-visibility \ | |
| mbstate \ | |
| safe-read \ | |
| sigpipe \ | |
| stdbool \ | |
| stdio \ | |
| stdlib \ | |
| strerror \ | |
| unistd \ | |
| uniwidth/width | |
| # The downstream adds the --lgpl=2 argument to make sure no GPL modules are imported, and create | |
| # stub files that are needed for the upstream build scripts. | |
| srclib/Makefile.gnulib : | |
| if test -n "$$GNULIB_TOOL"; then \ | |
| $$GNULIB_TOOL --copy-file m4/codeset.m4 srcm4/codeset.m4 || exit $$?; \ | |
| $$GNULIB_TOOL --lib=libicrt --source-base=srclib --m4-base=srcm4 --makefile-name=Makefile.gnulib --no-libtool --local-dir=gnulib-local --no-vc-files \ | |
| --lgpl=2 --import $(GNULIB_MODULES); \ | |
| touch build-aux/config.libpath build-aux/libtool-reloc srcm4/relocatable.m4 \ | |
| srcm4/relocatable-lib.m4; \ | |
| fi | |
| # The downstream removes copying tests/qemu.h to avoid depending on Gnulib test | |
| # files that are excluded from Gnulib's lgpl2_srcs, and adds install-sh because | |
| # removing srclib/Makefile.am (GPL-2.0) skips `automake --add-missing --copy` | |
| # which previously populated build-aux/install-sh for autogen.sh and configure. | |
| gnulib-imported-files : force | |
| if test -n "$$GNULIB_TOOL"; then \ | |
| for file in config.guess config.sub install-sh; do \ | |
| $$GNULIB_TOOL --copy-file build-aux/$$file || exit $$?; \ | |
| chmod a+x build-aux/$$file || exit $$?; \ | |
| done; \ | |
| fi | |
| # [stardust] srclib/Makefile.am (GPL-2.0) has been removed since srclib is only | |
| # used by the CLI tool in src/ and not linked into libiconv.a or libiconv.so. | |
| # Instead of running automake on srclib/Makefile, ensure libcharset/build-aux | |
| # exists (since libcharset/build-aux/ltmain.sh was removed) and create | |
| # placeholder build-aux/compile and build-aux/missing scripts required by | |
| # AM_INIT_AUTOMAKE after `libtoolize --force --copy` cleans build-aux/. | |
| srclib/Makefile.in : srclib/Makefile.gnulib aclocal.m4 | |
| mkdir -p libcharset/build-aux && touch build-aux/compile build-aux/missing && chmod a+x build-aux/compile build-aux/missing | |
| CONFIGURES = configure | |
| CONFIGURES_IN = configure.ac | |
| aclocal.m4 : $(CONFIGURES_IN) srclib/Makefile.gnulib $(wildcard m4/*.m4) $(wildcard srcm4/*.m4) | |
| $(ACLOCAL) -I m4 -I srcm4 --output=$@ && touch $@ && rm -rf autom4te.cache | |
| configures : $(CONFIGURES) | |
| AUTOCONF_FILES = aclocal.m4 $(wildcard m4/*.m4) $(wildcard srcm4/*.m4) | |
| configure : configure.ac $(AUTOCONF_FILES) | |
| $(AUTOCONF) && rm -rf autom4te.cache | |
| check-configures : $(CONFIGURES) | |
| set -e; for f in $(CONFIGURES); do bash -x -n $$f; done | |
| config.h.in : configure.ac $(AUTOCONF_FILES) | |
| $(AUTOHEADER) && rm -rf autom4te.cache | |
| touch $@ | |
| include/iconv.h.build.in : include/iconv.h.in include/export.h | |
| cat $< \ | |
| | sed -e 's/extern \([^"]\)/extern LIBICONV_SHLIB_EXPORTED \1/' \ | |
| -e '/_LIBICONV_VERSION/r include/export.h' \ | |
| | sed -e '/_LIBICONV_VERSION/,/[*][/]$$/{/_LIBICONV_VERSION/!d;}' > $@ | |
| lib/aliases.h lib/canonical.h lib/canonical_local.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c | |
| $(CC) $(CFLAGS) lib/genaliases.c -o genaliases | |
| ./genaliases lib/aliases.gperf canonical.sh canonical_local.sh | |
| $(RM) genaliases | |
| $(GPERF) -m 10 lib/aliases.gperf > tmp.h | |
| sed -e 's/^\(const struct alias \)/static \1/' < tmp.h > lib/aliases.h | |
| sh canonical.sh > lib/canonical.h | |
| sh canonical_local.sh > lib/canonical_local.h | |
| $(RM) tmp.h canonical.sh canonical_local.sh | |
| lib/aliases_sysaix.h lib/canonical_sysaix.h lib/canonical_local_sysaix.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c | |
| $(CC) $(CFLAGS) -DUSE_AIX_ALIASES lib/genaliases.c -o genaliases | |
| ./genaliases lib/aliases_sysaix.gperf canonical.sh canonical_local.sh | |
| $(RM) genaliases | |
| $(GPERF) -m 10 lib/aliases_sysaix.gperf > tmp.h | |
| sed -e 's/^\(const struct alias \)/static \1/' < tmp.h > lib/aliases_sysaix.h | |
| sh canonical.sh > lib/canonical_sysaix.h | |
| sh canonical_local.sh > lib/canonical_local_sysaix.h | |
| $(RM) tmp.h canonical.sh canonical_local.sh | |
| lib/aliases_syshpux.h lib/canonical_syshpux.h lib/canonical_local_syshpux.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c | |
| $(CC) $(CFLAGS) -DUSE_HPUX_ALIASES lib/genaliases.c -o genaliases | |
| ./genaliases lib/aliases_syshpux.gperf canonical.sh canonical_local.sh | |
| $(RM) genaliases | |
| $(GPERF) -m 10 lib/aliases_syshpux.gperf > tmp.h | |
| sed -e 's/^\(const struct alias \)/static \1/' < tmp.h > lib/aliases_syshpux.h | |
| sh canonical.sh > lib/canonical_syshpux.h | |
| sh canonical_local.sh > lib/canonical_local_syshpux.h | |
| $(RM) tmp.h canonical.sh canonical_local.sh | |
| lib/aliases_sysosf1.h lib/canonical_sysosf1.h lib/canonical_local_sysosf1.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c | |
| $(CC) $(CFLAGS) -DUSE_OSF1_ALIASES lib/genaliases.c -o genaliases | |
| ./genaliases lib/aliases_sysosf1.gperf canonical.sh canonical_local.sh | |
| $(RM) genaliases | |
| $(GPERF) -m 10 lib/aliases_sysosf1.gperf > tmp.h | |
| sed -e 's/^\(const struct alias \)/static \1/' < tmp.h > lib/aliases_sysosf1.h | |
| sh canonical.sh > lib/canonical_sysosf1.h | |
| sh canonical_local.sh > lib/canonical_local_sysosf1.h | |
| $(RM) tmp.h canonical.sh canonical_local.sh | |
| lib/aliases_syssolaris.h lib/canonical_syssolaris.h lib/canonical_local_syssolaris.h : lib/encodings.def lib/encodings_local.def lib/genaliases.c | |
| $(CC) $(CFLAGS) -DUSE_SOLARIS_ALIASES lib/genaliases.c -o genaliases | |
| ./genaliases lib/aliases_syssolaris.gperf canonical.sh canonical_local.sh | |
| $(RM) genaliases | |
| $(GPERF) -m 10 lib/aliases_syssolaris.gperf > tmp.h | |
| sed -e 's/^\(const struct alias \)/static \1/' < tmp.h > lib/aliases_syssolaris.h | |
| sh canonical.sh > lib/canonical_syssolaris.h | |
| sh canonical_local.sh > lib/canonical_local_syssolaris.h | |
| $(RM) tmp.h canonical.sh canonical_local.sh | |
| lib/aliases_aix.h lib/canonical_aix.h : lib/encodings_aix.def lib/genaliases2.c | |
| $(CC) $(CFLAGS) -DUSE_AIX lib/genaliases2.c -o genaliases | |
| ./genaliases aix lib/aliases_aix.h lib/canonical_aix.h | |
| $(RM) genaliases | |
| lib/aliases_aix_sysaix.h lib/canonical_aix_sysaix.h : lib/encodings_aix.def lib/genaliases2.c | |
| $(CC) $(CFLAGS) -DUSE_AIX -DUSE_AIX_ALIASES lib/genaliases2.c -o genaliases | |
| ./genaliases aix lib/aliases_aix_sysaix.h lib/canonical_aix_sysaix.h | |
| $(RM) genaliases | |
| lib/aliases_osf1.h lib/canonical_osf1.h : lib/encodings_osf1.def lib/genaliases2.c | |
| $(CC) $(CFLAGS) -DUSE_OSF1 lib/genaliases2.c -o genaliases | |
| ./genaliases osf1 lib/aliases_osf1.h lib/canonical_osf1.h | |
| $(RM) genaliases | |
| lib/aliases_osf1_sysosf1.h lib/canonical_osf1_sysosf1.h : lib/encodings_osf1.def lib/genaliases2.c | |
| $(CC) $(CFLAGS) -DUSE_OSF1 -DUSE_OSF1_ALIASES lib/genaliases2.c -o genaliases | |
| ./genaliases osf1 lib/aliases_osf1_sysosf1.h lib/canonical_osf1_sysosf1.h | |
| $(RM) genaliases | |
| lib/aliases_dos.h lib/canonical_dos.h : lib/encodings_dos.def lib/genaliases2.c | |
| $(CC) $(CFLAGS) -DUSE_DOS lib/genaliases2.c -o genaliases | |
| ./genaliases dos lib/aliases_dos.h lib/canonical_dos.h | |
| $(RM) genaliases | |
| lib/aliases_zos.h lib/canonical_zos.h : lib/encodings_zos.def lib/genaliases2.c | |
| $(CC) $(CFLAGS) -DUSE_ZOS lib/genaliases2.c -o genaliases | |
| ./genaliases zos lib/aliases_zos.h lib/canonical_zos.h | |
| $(RM) genaliases | |
| lib/aliases_extra.h lib/canonical_extra.h : lib/encodings_extra.def lib/genaliases2.c | |
| $(CC) $(CFLAGS) -DUSE_EXTRA lib/genaliases2.c -o genaliases | |
| ./genaliases extra lib/aliases_extra.h lib/canonical_extra.h | |
| $(RM) genaliases | |
| lib/flags.h : lib/encodings.def lib/encodings_aix.def lib/encodings_osf1.def lib/encodings_dos.def lib/encodings_zos.def lib/encodings_extra.def lib/converters.h lib/genflags.c | |
| $(CC) $(CFLAGS) lib/genflags.c -o genflags | |
| ./genflags > lib/flags.h | |
| $(RM) genflags | |
| lib/translit.h : lib/translit.def lib/gentranslit.c | |
| $(CC) $(CFLAGS) lib/gentranslit.c -o gentranslit | |
| ./gentranslit < lib/translit.def > lib/translit.h | |
| $(RM) gentranslit | |
| man/%.html : man/% | |
| $(MAN2HTML) $< > $@-t | |
| grep -v '<!-- CreationDate' < $@-t > $@ | |
| $(RM) $@-t | |
| gnulib-clean : force | |
| # Move srclib/Makefile.gnulib away, so that the target 'srclib/Makefile.gnulib' will actually do something. | |
| if test -f srclib/Makefile.gnulib; then \ | |
| mv srclib/Makefile.gnulib srclib/Makefile.gnulib~; \ | |
| fi | |
| # No need to remove the stale files. gnulib-tool does this itself, thanks to srcm4/gnulib-comp.m4. | |
| # find srclib '(' -name '*.h' -o -name '*.c' -o -name '*.valgrind' ')' -exec rm -f '{}' ';' | |
| # rm -rf srcm4 | |
| totally-clean : force | |
| rm -f srclib/Makefile.in | |
| rm -f aclocal.m4 $(CONFIGURES) config.h.in include/iconv.h.build.in | |
| rm -f lib/aliases.gperf lib/aliases_sysaix.gperf lib/aliases_syshpux.gperf lib/aliases_sysosf1.gperf lib/aliases_syssolaris.gperf | |
| rm -f lib/aliases.h lib/aliases_sysaix.h lib/aliases_syshpux.h lib/aliases_sysosf1.h lib/aliases_syssolaris.h | |
| rm -f lib/aliases_aix.h lib/aliases_aix_sysaix.h | |
| rm -f lib/aliases_osf1.h lib/aliases_osf1_sysosf1.h | |
| rm -f lib/aliases_dos.h | |
| rm -f lib/aliases_zos.h | |
| rm -f lib/aliases_extra.h | |
| rm -f lib/canonical.h lib/canonical_sysaix.h lib/canonical_syshpux.h lib/canonical_sysosf1.h lib/canonical_syssolaris.h | |
| rm -f lib/canonical_aix.h lib/canonical_aix_sysaix.h | |
| rm -f lib/canonical_osf1.h lib/canonical_osf1_sysosf1.h | |
| rm -f lib/canonical_dos.h | |
| rm -f lib/canonical_zos.h | |
| rm -f lib/canonical_extra.h | |
| rm -f lib/canonical_local.h lib/canonical_local_sysaix.h lib/canonical_local_syshpux.h lib/canonical_local_sysosf1.h lib/canonical_local_syssolaris.h | |
| rm -f lib/flags.h | |
| rm -f lib/translit.h | |
| rm -f man/iconv.1.html man/iconv.3.html man/iconv_close.3.html man/iconv_open.3.html man/iconvctl.3.html man/iconv_open_into.3.html | |
| cd libcharset && $(MAKE) -f Makefile.devel totally-clean | |
| force : |