[Bug 251191] Mk/Uses/ninja.mk: 'USES=cmake emacs' results in build error with ninja
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Mon Nov 16 17:50:17 GMT 2020
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251191
Bug ID: 251191
Summary: Mk/Uses/ninja.mk: 'USES=cmake emacs' results in build
error with ninja
Product: Ports & Packages
Version: Latest
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: Individual Port(s)
Assignee: ports-bugs at FreeBSD.org
Reporter: yasu at utahime.org
CC: kde at FreeBSD.org
Flags: exp-run?
Created attachment 219737
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=219737&action=edit
Patch file
1. Summary
'USES=cmake emacs' results in build error with ninja. This is bug of ports
build system. Attached patch fixes it.
2. Background
I'm trying to create port of following software.
libegit2: Emacs bindings for libgit2
https://github.com/magit/libegit2
3. What is the problem?
To port libegit2 following 2 steps are necessary.
a. Build libegit2.so with cmake and install it to ${PREFI}/lib
b. Byte-compile libgit.el and install them to
${PREFIX}/${EMACS_VERSION_SITE_LISPDIR}
So I need to add 'USES=cmake emacs' in Makefile. But it causes error of ninja
such as following.
----------------------------------------------------------------------
===> License GPLv3+ accepted by the user
===> libegit2-emacs27_nox-0.0.1.20200316 depends on file: /usr/local/sbin/pkg
- found
===> Fetching all distfiles required by libegit2-emacs27_nox-0.0.1.20200316 for
building
===> Extracting for libegit2-emacs27_nox-0.0.1.20200316
=> SHA256 Checksum OK for magit-libegit2-0.0.1.20200316-0ef8b13_GH0.tar.gz.
===> Patching for libegit2-emacs27_nox-0.0.1.20200316
===> Applying FreeBSD patches for libegit2-emacs27_nox-0.0.1.20200316 from
/usr0/freebsd/ports/git/devel/libegit2/files
===> libegit2-emacs27_nox-0.0.1.20200316 depends on file:
/usr/local/bin/cmake - found
===> libegit2-emacs27_nox-0.0.1.20200316 depends on executable: ninja - found
===> libegit2-emacs27_nox-0.0.1.20200316 depends on file:
/usr/local/bin/emacs-27.1 - found
===> libegit2-emacs27_nox-0.0.1.20200316 depends on package: pkgconf>=1.3.0_1
- found
===> libegit2-emacs27_nox-0.0.1.20200316 depends on shared library:
libgit2.so - found (/usr/local/lib/libgit2.so)
===> Configuring for libegit2-emacs27_nox-0.0.1.20200316
===> Performing out-of-source build
/bin/mkdir -p
/usr0/freebsd/ports/work/usr0/freebsd/ports/git/devel/libegit2/work-nox/.build
-- The C compiler identification is Clang 10.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is Clang 10.0.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: pkgconf (found version "1.7.3")
-- Checking for module 'libgit2'
-- Found libgit2, version 1.0.1
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_EXE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS
CMAKE_VERBOSE_MAKEFILE
THREADS_HAVE_PTHREAD_ARG
-- Build files have been written to:
/usr0/freebsd/ports/work/usr0/freebsd/ports/git/devel/libegit2/work-nox/.build
===> Building for libegit2-emacs27_nox-0.0.1.20200316
ninja: error: unknown target 'EMACS=/usr/local/bin/emacs-27.1'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1
Stop.
make: stopped in /usr0/freebsd/ports/git/devel/libegit2
Command exit status: 1
----------------------------------------------------------------------
I tried to build libegit2 according to the steps described in its document and
it succeeded without any error. Moreover I selected some ports that use
'USES=cmake', intentionally change them to 'USES=cmake emacs' and tried to
build them. Then build failed with same error for all of them. So this is bug
of ports build system.
4. Why the problem happens?
There is following line in Mk/Uses/emacs.mk
----------------------------------------------------------------------
MAKE_ARGS+= EMACS=${EMACS_CMD}
----------------------------------------------------------------------
So if both 'cmake' and 'emacs' is added to USES, then ninja is invoked with
something like `ninja -v EMACS=/usr/local/bin/emacs-27.1`. But according to the
output of `ninja --help`, ninja doesn't accept such argument as 'NAME=VALUE'
that `make` accepts. So it results in the error that happens when I try to
build my devel/libegit2 port.
I checked Mk/Uses/*.mk and found following ones also add extra arguments to
MAKE_ARGS.
* Mk/Uses/gnustep.mk
* Mk/Uses/scons.mk
* Mk/Uses/waf.mk
Moreover each port that uses 'USES=cmake' may do same thing. Therefore this
problem should be fixed by changing Mk/Uses/ninja.mk.
5. Solution
In Mk/bsd.port.mk MAKE_ARGS is used in following targets.
* do-build
* do-install
* do-test
So the solution is to re-define them in Mk/Uses/ninja.mk. As for do-install and
do-test, DO_MAKE_BUILD and DO_MAKE_TEST are defined and used when each target
is called respectively. So re-define them in ninja.mk so ninja is directly
invoked without using MAKE_ARGS. As for do-install DO_MAKE_INSTALL isn't
defined. So re-define the target with same way in ninja.mk.
As the result re-definition of following variables in ninja.mk gets
unnecessary.
* MAKE_ARGS
* MAKE_CMD
* MAKE_FLAGS
* MAKE_JOBS
* MAKEFILE
So remove them.
Additionally define NINJA_ARGS whose default value is empty and add it to
argument of executing ninja. It is intended that some ports may want to add
extra argument when executing ninja.
6. Test
Following branch includes both devel/libegit2 port and this fix.
https://github.com/yasuhirokimura/freebsd-ports/tree/libegit2/
(Note: This branch will be removed once devel/libegit2 is committed.)
It can be build without any error. I also confirmed some ports that uses
'USES=cmake' can be built successfully with attached patch. But it should be
tested more with exp-run.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the kde-freebsd
mailing list