Be aware that both cscope and make honor $SOURCEDIRS

Emerging media-sound/cdparanoia failed lately on my box when I was running "sudo emerge...".
The error was that an archive file was missing.
However, I didn't find any bug report related to that on bug.g.o.
So, I decided to take a look myself. I found that if I emerged it using root user, then everything was ok. So, I suspected this might have something to do with my environment setting, coz I don't reset env for users in wheel group(so that I can "USE=... sudo emerge").
I ran ebuild unpack/install/compile/install separately using normal user and root to determine which stage caused the difference. Finally, I found the difference happened when "make"ing in the paranoia directory. An target called "lib" defines the rule to build that archive file. The lib is not a real file, however it is not labeled as PHONY. Apparently, the target is not run. But why?
I straced make as normal user. I found something strange. The strange thing was make looked in /usr/src/linux for "lib" and found it - everyone has it. So make believed that lib was already there, no need to make. That's why the archive file was missing. But why looking for lib under /usr/src/linux?
I ran "env | grep '/usr/src/linux'", and found SOURCEDIRS is defined to that value. It is intended to be used by cscope.
Up till this moment, everthing is clear.
The lessons we can learn from this incident:
1. Not resetting env for sudo may cause problems
2. If a target is not a real file, lable it as .PHONY in makefile
3. Be aware that both cscope and make honor SOURCEDIRS.


Popular posts from this blog

Ripple's XRP: Giving the Third-Largest Cryptocurrency a Second Look

Illinois Is Venezuela and the Solution Is Cryptocurrency