Improved Makefile and Gitignore.
This commit is contained in:
parent
cfeb8ed817
commit
ef27ac7c40
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
|||||||
|
# Ignore binary objects and build results
|
||||||
*.o
|
*.o
|
||||||
|
/bin
|
||||||
|
/src/c/gen
|
||||||
|
46
Makefile
46
Makefile
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user