LuPPC/Makefile
2016-01-18 22:19:10 +01:00

59 lines
1.2 KiB
Makefile

# TARGET=arm-none-eabi
#CC=$(TARGET)-gcc
CC=gcc
CFLAGS=-O2 -std=c90 -Isrc/lib/lua -Iinclude -DLUA_C89_NUMBERS
BUILD = bin/
SOURCE = src/c/
CORELUA = src/lua/core
LIBS=-lm
GENERATED=include/luares.h src/c/gen/luares.c
LUAPARAMS = $(CORELUA) include/luares.h src/c/gen/luares.c lua_
LDFLAGS=-static
SRCDIRECTORIES = $(shell find $(SOURCE) -type d)
BUILDDIRECTORIES = $(patsubst $(SOURCE)%, $(BUILD)%, $(SRCDIRECTORIES))
CFILES = $(shell find $(SOURCE) -type f -name '*.c')
OBJECTS := $(patsubst $(SOURCE)%.c, $(BUILD)%.c.o, $(CFILES))
#Rules
#Prepare
$(BUILDDIRECTORIES):
mkdir -p $@
#Build
all: smallclean $(BUILDDIRECTORIES) luaresources $(BUILD)lupi
build: clean all
$(BUILD)lupi: $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS)
$(BUILD)%.c.o: $(SOURCE)%.c
$(CC) -c $(CFLAGS) -I /usr/include -I src/c -I src/c/lib/lua $< -o $@
#Resources
luaresources: cleanresourcues
scripts/txt2c $(LUAPARAMS)
#Clean rules
cleanresourcues:
-rm -f $(GENERATED)
mkdir -p src/c/gen/
touch src/c/gen/luares.c
touch include/luares.h
clean: cleanresourcues
-rm -rf $(BUILD)
smallclean:
find . -name '*~' -type f -exec rm {} \;
# Other
.PHONY: clean cleanresourcues luaresources build smallclean all