lua-users home
lua-l archive

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


This is the makefile syntax I am using for my own lua modules.  I have
build scripts that invoke make with the appropriate environment
variables set to select the cross compiler for the architecture I am
targeting (currently ARM or PPC).  One advantage of this approach is
that I can simply run "make" from the command line on my x86 linux box
and build natively when the environment variables are not set.

---------------------------------------------------------------------------------------------------------
.PHONY: clean install

PROJECT := fwutil.so
CC      := $(if $(CROSS_TARGET),$(CROSS_TARGET)-gcc,gcc)
STRIP   := $(if $(CROSS_TARGET),$(CROSS_TARGET)-strip,strip)
SOURCES := $(wildcard *.c)
OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
CFLAGS  := $(CFLAGS) -fPIC -Wall -O2

$(PROJECT): $(OBJECTS)
    $(CC) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $(OBJECTS)

$(OBJECTS): $(SOURCES)
    $(CC) $(CFLAGS) -c $(SOURCES)

install: $(PROJECT)
    $(STRIP) $(PROJECT)
    install -m 0644 -D $(PROJECT) $(DESTDIR)/usr/lib/lua/5.1/$(PROJECT)

clean:
    rm -f *.o $(PROJECT)
---------------------------------------------------------------------------------------------------------

On Thu, Mar 4, 2010 at 4:35 PM, Rory Toma <rory@ooma.com> wrote:
> I notice that every package that I cross compile, I have to, at a minimum,
> rewrite the configure scripts and often the Makefiles. What is the standard
> lua way of building for cross-compile?
>