Menu

#64 LUA_VERSION detection is broken

v1.0 (example)
closed
None
5
2014-11-11
2013-09-05
No

I think the LUA_VERSION detection in lua-detect.mk is broken.

$ pkg-config --exists lua5.1 && echo 5.1
5.1

$ make
build/lua-detect.mk:21: *** Could not find any lua version. (Did you install the -dev package?).  Stop.

I think this is happening because the makefile does

LUA_VERSION ?= $(shell pkg-config --exists lua5.2 && echo 5.2)
LUA_VERSION ?= $(shell pkg-config --exists lua5.1 && echo 5.1)
LUA_VERSION ?= $(shell pkg-config --exists lua    && echo 5.0)

but the first ?= assigns '' to LUA_VERSION. '' is not the same as undefined in make.

Related

Bugs: #86

Discussion

  • Mykola Orliuk

    Mykola Orliuk - 2013-09-10

    Yep. My suggestion is one assignment with ||

     
  • Justin Lebar

    Justin Lebar - 2013-09-10

    Close, but no cigar. I get LUA_VERSION == "5.1 5.0", I think because || and && have the same precedence.

     
    • Mykola Orliuk

      Mykola Orliuk - 2013-10-16

      No logic of both && and || exactly the same I expected:
      - If left side of && fails whole expression fails without calling right side.
      - If left side of || succeed than whole expression succeed without calling right-side.
      - Precedence of shell (at least bash) follows usual math rules (&& have higher preceedence over ||)

       
  • Arnout Engelen

    Arnout Engelen - 2013-09-10
    • status: open --> pending
     
  • Arnout Engelen

    Arnout Engelen - 2013-09-10
     
    • Justin Lebar

      Justin Lebar - 2013-09-10

      Yes, that works for me.

       
  • Arnout Engelen

    Arnout Engelen - 2013-09-11
    • status: pending --> closed
    • assigned_to: Arnout Engelen
     
  • Kevin Bryan

    Kevin Bryan - 2013-10-16

    In Gentoo, which currently doesn't seem to support side-by-side installs, version 5.1.5 does not install the pkg-config file as lua5.1. That would almost be ok since the version would be set to '', and it would call pkg-config correctly. The problem occurs later when the file expects LUA_INCLUDES to have a value. Gentoo's install doesn't require any flags here, so that test doesn't make sense. Removing that block allows it to proceed normally.

     
    • Mykola Orliuk

      Mykola Orliuk - 2013-10-16

      Yep I missed that. Looks like I forgot to check actual value of LUA_VERSION. I use Exherbo and use 5.1.4 but it works for by some reason. But both in Gentoo and Exherbo using auto-detection is a bad idea and should be changed to explicitly provide LUA_VERSION as make parameter. That will save us from auto-magic deps on unknown version of lua (in case if we'll have slotted versions).

      Nevertheless that code detects wrong version and assumes that I have 5.0. Lets first detect pkg-config module with those lines (i.e. to use lua5.1.pc or lua.pc). And after that call pkg-config --modversion lua. Sample:

      LUA_PKG_NAME ?= $(shell \
             pkg-config --exists lua5.2 && echo lua5.2 \
          || pkg-config --exists lua5.1 && echo lua5.1 \
          || pkg-config --exists lua && echo lua )
      
      LUA_FULL_VERSION ?= $(shell pkg-config --modversion $(LUA_PKG_NAME))
      LUA_VERSION_PARTS = $(subst ., ,$(LUA_FULL_VERSION))
      LUA_VERSION ?= $(word 1,$(LUA_VERSION_PARTS)).$(word 2,$(LUA_VERSION_PARTS))
      
      $(warning "LUA_FULL_VERSION=$(LUA_FULL_VERSION)")
      $(warning "LUA_VERSION=$(LUA_VERSION)")
      

      Note that I don't know do we need full version or only first two components.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.