lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Could you please elaborate? I don't recall any major issues reported
> here.

Since I've criticized the Lua Makefile now I need to explain :-)

When you build lua you give something like:

make linux

so you give the PLATFORM as the target and this is already wrong. You
are not doing "linux", you are building Lua. The platform should be a
variable, not the target.

Then you go inside the "src" directory and you discover something like that:
---------------------
aix:
        $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX
-DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"

ansi:
        $(MAKE) all MYCFLAGS=-DLUA_ANSI

bsd:
        $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"

freebsd:
        $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"

generic:
        $(MAKE) all MYCFLAGS=

linux:
        $(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl
-lreadline -lhistory -lncurses"
--------------------------

Once again, this is wrong because "linux" or "bsd" or "macosx" is not
the target but the real problem is how it works.

It call *again* make with a "make all" by setting MYCFLAGS and MYLIBS.
Once make is called for the second time now it can do the real work.

Why this is wrong ? Well, actually it *works* but it is really
convoluted and it is not the idiomatic way to write a makefile. The
platform should be an option, not the target, so it should be
something like:

make PLAT=linux

Because of this "error" you are obliged to call make *twice* in the
directory src, the first time with the wrong target (e.g. linux) and
the second time with the good target (all) but with the good options
MYCFLAGS etc.

So, the makefile is not really wrong but it is convoluted and it does
use the makefile in a non idiomatic way.

For the other side the LuaJIT2 makefile use a very smart way to detect
the OS so you don't even need to specify the platform. The trick is:

ifneq (,$(findstring Windows,$(OS)))
  HOST_SYS= Windows
else
  HOST_SYS:= $(shell uname -s)
  ifneq (,$(findstring CYGWIN,$(TARGET_SYS)))
    HOST_SYS= Windows
  endif
endif
ifeq (Windows,$(HOST_SYS))
  HOST_RM= del
endif

So the LuaJIT2's Makefile is more successfull at using Makefile in the
right way :-)

I guess that it does depend on the GNU Makefile but the motto is:
"do not write portable makefiles but use a portable make (GNU make)" :-)

-- 
Francesco