diff --git a/recipes/imake/all/conandata.yml b/recipes/imake/all/conandata.yml new file mode 100644 index 0000000000000..b60e9f5b7c62c --- /dev/null +++ b/recipes/imake/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "1.0.8": + url: "https://www.x.org/releases/individual/util/imake-1.0.8.tar.gz" + sha256: "8178a09bfef33ad5f61cb5cb62283df7d3a5682f014507d2e7cfd922485a5c00" +patches: + "1.0.8": + - patch_file: "patches/0001-reproducible-behavior.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-msvc-debug-build_type.patch" + base_path: "source_subfolder" diff --git a/recipes/imake/all/conanfile.py b/recipes/imake/all/conanfile.py new file mode 100644 index 0000000000000..f5048e50d11a2 --- /dev/null +++ b/recipes/imake/all/conanfile.py @@ -0,0 +1,141 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +import contextlib +import os + +required_conan_version = ">=1.33.0" + + +class ImakeConan(ConanFile): + name = "imake" + description = "Obsolete C preprocessor interface to the make utility" + topics = ("conan", "imake", "xmkmf", "preprocessor", "build", "system") + license = "MIT" + homepage = "https://gitlab.freedesktop.org/xorg/util/imake" + url = "https://github.com/conan-io/conan-center-index" + settings = "os", "arch", "compiler", "build_type" + options = { + "ccmakedep": [True, False], + "cleanlinks": [True, False], + "makeg": [True, False], + "mergelib": [True, False], + "mkdirhier": [True, False], + "mkhtmlindex": [True, False], + "revpath": [True, False], + "xmkmf": [True, False], + } + default_options = { + "ccmakedep": True, + "cleanlinks": True, + "makeg": True, + "mergelib": True, + "mkdirhier": True, + "mkhtmlindex": True, + "revpath": True, + "xmkmf": True, + } + + exports_sources = "patches/*" + generators = "pkg_config" + + _autotools = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def requirements(self): + self.requires("xorg-proto/2021.4") + + def build_requirements(self): + self.build_requires("automake/1.16.3") + self.build_requires("pkgconf/1.7.4") + if self._settings_build.os == "Windows": + self.build_requires("msys2/cci.latest") + + def configure(self): + del self.settings.compiler.cppstd + del self.settings.compiler.libcxx + + def package_id(self): + del self.info.settings.compiler + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CXX": "{} cl -nologo".format(tools.unix_path(self._user_info_build["automake"].compile)), + "CPP": "{} cl -E".format(tools.unix_path(self._user_info_build["automake"].compile)), + } + with tools.environment_append(env): + yield + else: + yield + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=self._settings_build.os == "Windows") + self._autotools.libs = [] + if self.settings.os == "Windows": + self._autotools.defines.append("WIN32") + if self.settings.compiler == "Visual Studio": + self._autotools.defines.extend([ + "_CRT_SECURE_NO_WARNINGS", + "CROSSCOMPILE_CPP", + ]) + self._autotools.flags.append("-FS") + yes_no = lambda v: "yes" if v else "no" + conf_args = [ + "--enable-ccmakedep={}".format(yes_no(self.options.ccmakedep)), + "--enable-cleanlinks={}".format(yes_no(self.options.cleanlinks)), + "--enable-makeg={}".format(yes_no(self.options.makeg)), + "--enable-mergelib={}".format(yes_no(self.options.mergelib)), + "--enable-mkdirhier={}".format(yes_no(self.options.mkdirhier)), + "--enable-mkhtmlindex={}".format(yes_no(self.options.mkhtmlindex)), + "--enable-revpath={}".format(yes_no(self.options.revpath)), + "--enable-xmkmf={}".format(yes_no(self.options.xmkmf)), + ] + + # FIXME: RAWCPP (ac_cv_path_RAWCPP) is not compatible with MSVC preprocessor. It needs to be cpp. + if tools.get_env("CPP"): + conf_args.extend([ + "--with-script-preproc-cmd={}".format(tools.get_env("CPP")), + ]) + self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder) + return self._autotools + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + # tools.replace_in_file(os.path.join(self._source_subfolder, "")) + with self._build_context(): + autotools = self._configure_autotools() + autotools.make(args=["V=1"]) + + def package(self): + self.copy("COPYING", src=self._source_subfolder, dst="licenses") + with self._build_context(): + autotools = self._configure_autotools() + autotools.install() + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libdirs = [] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/recipes/imake/all/patches/0001-reproducible-behavior.patch b/recipes/imake/all/patches/0001-reproducible-behavior.patch new file mode 100644 index 0000000000000..605ae7e7b2c1f --- /dev/null +++ b/recipes/imake/all/patches/0001-reproducible-behavior.patch @@ -0,0 +1,14 @@ +Hardcode gcc instead of using `PREPROC` (=compiler used when building imake). +This leads to more reproducible behavior. +(CC can be overridden by a CC environment variable or --cc argument) +--- mdepend.cpp ++++ mdepend.cpp +@@ -21,7 +21,7 @@ + XCOMM "-" (at least, that is what the documentation implies). + XCOMM + +-CC=PREPROC ++CC=gcc + + silent='-' + diff --git a/recipes/imake/all/patches/0002-msvc-debug-build_type.patch b/recipes/imake/all/patches/0002-msvc-debug-build_type.patch new file mode 100644 index 0000000000000..8af26fe967a05 --- /dev/null +++ b/recipes/imake/all/patches/0002-msvc-debug-build_type.patch @@ -0,0 +1,57 @@ +Needed when building MSVC with build_type=Debug + compiler.runtime=MTd +- escape comments with XCOMM +- avoid C4717: '_fstat64i32': recursive on all control paths, function will cause runtime stack overflow +- /tmp/xxxx does not exist on Windows +--- mdepend.cpp ++++ mdepend.cpp +@@ -125,9 +125,9 @@ + shift + ;; + +- # Flag to tell compiler to output dependencies directly +- # For example, with Sun compilers, -xM or -xM1 or +- # with gcc, -M ++ XCOMM Flag to tell compiler to output dependencies directly ++ XCOMM For example, with Sun compilers, -xM or -xM1 or ++ XCOMM with gcc, -M + -d) + compilerlistsdepends="y" + compilerlistdependsflag="$2" +--- imake.c ++++ imake.c +@@ -159,9 +159,6 @@ + #include + #include + #include +-#ifdef WIN32 +-# include "Xw32defs.h" +-#endif + #include + #include + #ifdef X_NOT_POSIX +@@ -252,6 +249,9 @@ + #if defined(__NetBSD__) /* see code clock in init() below */ + # include + #endif ++#ifdef WIN32 ++# include "Xw32defs.h" ++#endif + + typedef unsigned char boolean; + #define TRUE 1 +@@ -303,9 +303,14 @@ + const char *cpp = NULL; + + const char *tmpMakefile; ++#ifdef _WIN32 ++const char *tmpMakefileTemplate = "Imf.XXXXXX"; /* HACK: create temporary files in current folder */ ++const char *tmpImakefileTemplate = "IIf.XXXXXX"; /* HACK: create temporary files in current folder */ ++#else + const char *tmpMakefileTemplate = "/tmp/Imf.XXXXXX"; +-const char *tmpImakefile; + const char *tmpImakefileTemplate = "/tmp/IIf.XXXXXX"; ++#endif ++const char *tmpImakefile; + const char *make_argv[ ARGUMENTS ] = { + #ifdef WIN32 + "nmake" diff --git a/recipes/imake/all/test_package/Imake.tmpl b/recipes/imake/all/test_package/Imake.tmpl new file mode 100644 index 0000000000000..3b7cb31780b8f --- /dev/null +++ b/recipes/imake/all/test_package/Imake.tmpl @@ -0,0 +1,2 @@ +default: + @echo "IMAKE_TEMPLATE:" IMAKE_TEMPLATE diff --git a/recipes/imake/all/test_package/Imakefile b/recipes/imake/all/test_package/Imakefile new file mode 100644 index 0000000000000..8a9b031f63620 --- /dev/null +++ b/recipes/imake/all/test_package/Imakefile @@ -0,0 +1 @@ +# Imakefile diff --git a/recipes/imake/all/test_package/conanfile.py b/recipes/imake/all/test_package/conanfile.py new file mode 100644 index 0000000000000..99bf0a8a9c2d8 --- /dev/null +++ b/recipes/imake/all/test_package/conanfile.py @@ -0,0 +1,44 @@ +from conans import AutoToolsBuildEnvironment, ConanFile, tools +import contextlib +import os +import shutil + +required_conan_version = ">=1.36.0" + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + + exports_sources = "Imakefile", "Imake.tmpl" + + def build_requirements(self): + if not tools.get_env("CONAN_MAKE_PROGRAM"): + self.build_requires("make/4.2.1") + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + @contextlib.contextmanager + def _build_context(self): + if self.settings.compiler == "Visual Studio": + with tools.vcvars(self): + env = { + "CC": "cl -nologo", + } + with tools.environment_append(env): + yield + else: + yield + + def build(self): + for src in self.exports_sources: + shutil.copy(os.path.join(self.source_folder, src), os.path.join(self.build_folder, src)) + if not tools.cross_building(self): + with self._build_context(): + self.run("imake", run_environment=True) + + def test(self): + if not tools.cross_building(self): + autotools = AutoToolsBuildEnvironment(self) + autotools.make() diff --git a/recipes/imake/config.yml b/recipes/imake/config.yml new file mode 100644 index 0000000000000..28e3ee22ca8ac --- /dev/null +++ b/recipes/imake/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.8": + folder: all