jiayouxjh / grafx2

Automatically exported from code.google.com/p/grafx2
0 stars 0 forks source link

pkg-config doesnt like 'lua5.1' #328

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

compiling source report missing lua although lua is present. 

OpSys-linux
Milestone-2.2.1404

As it seems pkg-config (or some version thereof?) can not parse 'lua5.1' in
the Makefile thus lua integration wont be available in the resulting binary. 

here are the version numbers,
pkg-config 0.23
lua 5.1.4
make 3.81

Attached a patch for the Makefile.

P.S. congrats to the new release! its awesome!

Original issue reported on code.google.com by fogbot...@googlemail.com on 22 Mar 2010 at 1:15

Attachments:

GoogleCodeExporter commented 9 years ago
Edit: patch was the wrong way around. fixed.

Original comment by fogbot...@googlemail.com on 22 Mar 2010 at 1:27

Attachments:

GoogleCodeExporter commented 9 years ago
I can confirm this. On my system, there is not a 'lua-5.1' package, but a 'lua'
package (whose version is 5.1.4 -- 'pkg-config --modversion lua')

Original comment by 00a...@gmail.com on 22 Mar 2010 at 10:57

GoogleCodeExporter commented 9 years ago
With a bit of googling, I find that:
Archlinux, OS X use 'lua'
Debian/Ubuntu use 'lua5.1'
FreeBSD may use 'lua-5.1'

Looks like we need to do some funky autodetection...Something that would test 
one
package after the other, and use the first it finds (lua-5.1 > lua5.1 > lua)

Original comment by yrizoud on 22 Mar 2010 at 11:53

GoogleCodeExporter commented 9 years ago
argh !
the idea behind pkg-config _is_ to avoid such funky black magic. Ask
whatever-your-distro-is to fix their handling of lua...

See here for debian :
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498416

Original comment by pulkoma...@gmail.com on 23 Mar 2010 at 12:45

GoogleCodeExporter commented 9 years ago
ok. after quite some research the horror surfaces. As it looks, but I won't 
take my
word for it since the debian / ubuntu packaging contains several 300+ line 
Makefiles
and more, the situation is as follows: 
1. Arch Linux uses pretty much the vanilla lua version though theres some 
patching to
the package. there are 6 patches. 4 are supposedly official upstream patches 
whilst 2
are Arch specific. 1 of them fiddles with lua.pc (the pkg-config file) but only 
sets
the version to 5.1 and alters the prefix from /usr/local to /usr. the only 
resulting
pkg-config file is lua.pc
2. ubuntu / debian are more invasive in that regard but I'm not familiar enough 
with
the .deb packaging standard but it seems that debian renames the lua binary to 
lua5.1
_as well_ as the .pc file to lua5.1

no idea about FreeBSD and MacOSX. It's all a bit hazy and i didnt go down that 
rabbit
hole to deep but the overall summary is that yes, you will need some funky
autodetection because distros prefer to patch pkg-config defunct / useless.
pkg-config could've been so nice... :<  

Original comment by fogbot...@googlemail.com on 8 Apr 2010 at 7:45

GoogleCodeExporter commented 9 years ago
Debian/ubuntu is using lua-5.1 because they also have lua-5.0 available and 
needed 
for some packages, they want to be able to differenciate them.

Ok, so if we need handtweaking, I see no use for pkg-config ...

Original comment by pulkoma...@gmail.com on 8 Apr 2010 at 10:25

GoogleCodeExporter commented 9 years ago
I attempted a fix for this in r1470. Can you tell me if it fixes the problem 
for 
you ?

Original comment by pulkoma...@gmail.com on 28 Apr 2010 at 6:58

GoogleCodeExporter commented 9 years ago
sorry for the late reply. I just tried a build with r1474 on Archlinux (like 
'lua',
dislikes 'lua-5.1') and libpng 1.4.1. 

the build linked to libpng just fine but ultimately failed because lua wasn't 
found.
attached the build log. I had a look at the Makefile and its looking all good 
except
for the ifeq/else statements (line 205). 
As it seems it always falls through to lua-5.1 . unfortunately my Makefile foo 
isnt
up to it, but i'd recommend using the return codes instead of (`pkg-config 
--exists
lua --print-errors`,"")
not 100% sure that possible.

#> pkg-config --exists lua --print-errors
#> echo "$?" <-- return code of the last command
#> 0

#> pkg-config --exists lua-5.1 --print-errors
Package lua-5.1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua-5.1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua-5.1' found
#> echo "$?"
#> 1

so 0 is success and 1 is fail. 

Original comment by fogbot...@googlemail.com on 8 May 2010 at 7:12

Attachments:

GoogleCodeExporter commented 9 years ago
Yes but I don't know how to check for it... that's why I tried to use 
print-errors 
instead.

Original comment by pulkoma...@gmail.com on 16 May 2010 at 3:11

GoogleCodeExporter commented 9 years ago
On FreeBSD it is "lua-5.1" and therefore pkg-config is unable to see it.

Original comment by lesavik2...@gmail.com on 1 Jul 2010 at 5:06

GoogleCodeExporter commented 9 years ago
I did aother try in r1566. Can you tell me if it works better ?

Original comment by pulkoma...@gmail.com on 9 Aug 2010 at 9:30

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
me being late as always... tried with r1577. definitely works for pkg-config 
'lua'. can't really say about debian/ubuntu and freebsd but... since my 
pkg-config returns 'lua' i changed the order of the pkg-config OR's to probe 
for 'lua5.1' and 'lua-5.1' first. that build failed.
maybe it would be easier to just use a '-llua' ?

Original comment by fogbot...@googlemail.com on 16 Aug 2010 at 8:31

GoogleCodeExporter commented 9 years ago
No, Debian use -llua5.1 too :/
Could you try r1578 ? I added a --silence-errors test that should make it work 
properly for good.

Original comment by pulkoma...@gmail.com on 17 Aug 2010 at 12:42

GoogleCodeExporter commented 9 years ago
alright. I tried r1580 and again changed the order from
'lua' 'lua5.1' lua-5.1'
to
'lua5.1' 'lua-5.1' 'lua'
whilst everything is fine with 'lua' first (since pkg-config here
reports 'lua') there is just no way to get it to work with anything
else. compiling doesnt show any errors (as expected with
--silence-errors) but the resulting build fails miserably :(

Original comment by fogbot...@googlemail.com on 18 Aug 2010 at 5:21

GoogleCodeExporter commented 9 years ago
If you get an executable, this part is working and the problem is elsewhere. 
With --silence-errors pkg-config will not print anything, but return an error 
code, which is caught by || and makes it run the next command. The resulting 
output is the concatenation of the output of the 3 commands, so the good one 
should be in. I tested it in a shell and it worked fine; unfortunately I don't 
have a linux install anymore to do tests in a proper way.

Original comment by pulkoma...@gmail.com on 19 Aug 2010 at 12:32

GoogleCodeExporter commented 9 years ago
I'll test on my Debian, then. (and see what happens when I reverse the order of 
checks)

Original comment by yrizoud on 19 Aug 2010 at 1:12

GoogleCodeExporter commented 9 years ago
On Debian, it works as expected. I have lua as "lua5.1", and even when I switch 
the order of the members so it's tested first, second or last, it always 
compiles and runs successfully.
Is it the compilation that fails, or does the resulting executable fail to run?

If LUACOPT can't be set successfully, each compilation produces a 4-line-long 
warning, only factory.o fails to compile with a first message mentioning lua.h
If LUACOPT is fine but LUALOPT can't be successfully set, linking fails with 
many pages of errors ("undefined reference to 'Lua*****'")

Original comment by yrizoud on 19 Aug 2010 at 9:53

GoogleCodeExporter commented 9 years ago
Ok, so the current makefile works for everyone. Just remember to keep lua first 
:)

Original comment by pulkoma...@gmail.com on 20 Aug 2010 at 12:05

GoogleCodeExporter commented 9 years ago
just for reference, the binary gets build but as soon as I try to access the 
lua features it makes *kapoof*. other than that it works just fine. so keep 
that bug fixed ;)

Original comment by fogbot...@googlemail.com on 20 Aug 2010 at 5:03