Merge pull request #4 from vifino/master

Improve Makefile and Gitignore
This commit is contained in:
Łukasz Magiera 2016-01-22 01:53:30 +01:00
commit 2851b99eb5
2 changed files with 29 additions and 22 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
# Ignore binary objects and build results
*.o
/bin
/src/c/gen

View File

@ -1,57 +1,61 @@
# TARGET=arm-none-eabi
# LuPI2 Makefile
#CC=$(TARGET)-gcc
CC=gcc
CFLAGS=-O2 -g -std=c99 -Isrc/lib/lua -Iinclude
# Default compiler settings.
CC?=cc
CFLAGS?=-O2 -std=c99
LDFLAGS+= -static
# Project specific stuff
BUILD = bin/
SOURCE = src/c/
SOURCE = src/c
CORELUA = src/lua/core
RESOURCES = resources
LIBS=-lm
INCLUDES=-I$(SOURCE) -Isrc/c/lib/lua -Iinclude
GENERATED=include/luares.h src/c/gen/luares.c include/res.h src/c/gen/res.c
LUAPARAMS = $(CORELUA) include/luares.h src/c/gen/luares.c lua_
RESPARAMS = $(RESOURCES) include/res.h src/c/gen/res.c res_
LDFLAGS=-static
SRCDIRECTORIES = $(shell find $(SOURCE) -type d)
BUILDDIRECTORIES = $(patsubst $(SOURCE)%, $(BUILD)%, $(SRCDIRECTORIES))
BUILDDIRECTORIES = $(patsubst $(SOURCE)/%, $(BUILD)%, $(SRCDIRECTORIES))
CFILES = $(shell find $(SOURCE) -type f -name '*.c')
OBJECTS := $(patsubst $(SOURCE)%.c, $(BUILD)%.c.o, $(CFILES))
OBJECTS := $(patsubst $(SOURCE)/%.c, $(BUILD)%.c.o, $(CFILES))
# Targets
# Pseudo Targets
debug: CFLAGS+= -g
#Rules
#Prepare
$(BUILDDIRECTORIES):
mkdir -p $@
#Build
all: smallclean $(BUILDDIRECTORIES) resources $(BUILD)lupi
build: smallclean $(BUILDDIRECTORIES) resources $(BUILD)lupi
build: clean all
all: clean build
$(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 $@
$(BUILD)%.c.o: $(SOURCE)/%.c
$(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@
#Resources
resources: cleanresourcues
resources: cleanresources
scripts/txt2c $(LUAPARAMS)
scripts/txt2c $(RESPARAMS)
#Clean rules
cleanresourcues:
# Clean rules
cleanresources:
-rm -f $(GENERATED)
mkdir -p src/c/gen/
touch src/c/gen/luares.c
mkdir -p $(SOURCE)/gen/
touch $(SOURCE)/gen/luares.c
touch include/luares.h
clean: cleanresourcues
clean: cleanresources
-rm -rf $(BUILD)
smallclean: