Browse Source

Merge pull request #4 from vifino/master

Improve Makefile and Gitignore
libevent
Łukasz Magiera 7 years ago
parent
commit
2851b99eb5
  1. 3
      .gitignore
  2. 48
      Makefile

3
.gitignore

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

48
Makefile

@ -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:

Loading…
Cancel
Save