I don't know if this is a problem related to OpenWrt or Guix. It worked on
Manjaro.

That’s pretty weird!

#+BEGIN_SRC
$(STAGING_DIR_HOST)/.prereq-build: include/prereq-build.mk
        mkdir -p tmp
        @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f 
$(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
                echo "Prerequisite check failed. Use FORCE=1 to override."; \
                false; \
        }
  ifneq ($(realpath $(TOPDIR)/include/prepare.mk),)
        @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prepare.mk 
prepare 2>/dev/null || { \
                echo "Preparation failed."; \
                false; \
        }
  endif
        touch $@
#+END_SRC

#+BEGIN_SRC
$(eval $(call RequireCHeader,ncurses.h, \
        Please install ncurses. (Missing libncurses.so or ncurses.h), \
        initscr(), -lncurses))

ifeq ($(HOST_OS),Linux)
  $(eval $(call RequireCHeader,argp.h, \
        Missing argp.h Please install the argp-standalone package if musl libc))

  $(eval $(call RequireCHeader,fts.h, \
        Missing fts.h Please install the musl-fts-dev package if musl libc))

  $(eval $(call RequireCHeader,obstack.h, \
        Missing obstack.h Please install the musl-obstack-dev package if musl 
libc))

  $(eval $(call RequireCHeader,libintl.h, \
        Missing libintl.h Please install the musl-libintl package if musl libc))
endif
#+END_SRC

#+BEGIN_SRC
# 1: display name
# 2: error message
define Require
  export PREREQ_CHECK=1
  ifeq ($$(CHECK_$(1)),)
    prereq: prereq-$(1)

    prereq-$(1): $(if $(PREREQ_PREV),prereq-$(PREREQ_PREV)) FORCE
                printf "Checking '$(1)'... "
                if $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) check-$(1) 
PATH="$(ORIG_PATH)" >/dev/null 2>/dev/null; then \
                        echo 'ok.'; \
                elif $(NO_TRACE_MAKE) -f $(firstword $(MAKEFILE_LIST)) 
check-$(1) PATH="$(ORIG_PATH)" >/dev/null 2>/dev/null; then \
                        echo 'updated.'; \
                else \
                        echo 'failed.'; \
                        echo "$(PKG_NAME): $(strip $(2))" >> 
$(TMP_DIR)/.prereq-error; \
                fi

    check-$(1): FORCE
          $(call Require/$(1))
    CHECK_$(1):=1

    .SILENT: prereq-$(1) check-$(1)
    .NOTPARALLEL:
  endif

  PREREQ_PREV=$(1)
endef
[...]
# 1: header to test
# 2: failure message
# 3: optional compile time test
# 4: optional link library test (example -lncurses)
define RequireCHeader
  define Require/$(1)
    echo 'int main(int argc, char **argv) { $(3); return 0; }' | gcc -include 
$(1) -x c -o $(TMP_DIR)/a.out - $(4)
  endef

  $$(eval $$(call Require,$(1),$(2)))
endef
[...]
#+END_SRC

#+BEGIN_SRC
kevin@GUIX-WORKSTATION ~/Devel/openwrt [env]$ echo 'int main(int argc, char 
**argv) { initscr(); return 0; }' | gcc -include ncurses.h -x c -o tmp/a.out - 
-lncurses
kevin@GUIX-WORKSTATION ~/Devel/openwrt [env]$ echo $?
0
kevin@GUIX-WORKSTATION ~/Devel/openwrt [env]$
#+END_SRC

Any ideas?
-- 
Best regards,
Kevin Vigouroux

Reply via email to