Improved Makefile and Gitignore.

This commit is contained in:
Adrian Pistol 2016-01-21 23:25:51 +01:00
parent cfeb8ed817
commit ef27ac7c40
2 changed files with 29 additions and 22 deletions

3
.gitignore vendored
View File

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

View File

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