LuPPC/Makefile

67 lines
1.4 KiB
Makefile
Raw Normal View History

2016-01-22 09:25:51 +11:00
# LuPI2 Makefile
2016-01-19 05:42:32 +11:00
2016-01-22 09:25:51 +11:00
# Default compiler settings.
CC?=cc
CFLAGS?=-O2 -std=c99
LDFLAGS+= -static
2016-01-04 04:08:43 +11:00
2016-01-22 09:25:51 +11:00
# Project specific stuff
2016-01-04 04:08:43 +11:00
BUILD = bin/
2016-01-22 09:25:51 +11:00
SOURCE = src/c
2016-01-04 04:08:43 +11:00
2016-01-03 13:25:12 +11:00
CORELUA = src/lua/core
2016-01-19 11:25:14 +11:00
RESOURCES = resources
2016-01-04 04:08:43 +11:00
LIBS=-lm
2016-01-22 09:25:51 +11:00
INCLUDES=-I$(SOURCE) -Isrc/c/lib/lua -Iinclude
2016-01-19 11:25:14 +11:00
GENERATED=include/luares.h src/c/gen/luares.c include/res.h src/c/gen/res.c
2016-01-03 13:25:12 +11:00
LUAPARAMS = $(CORELUA) include/luares.h src/c/gen/luares.c lua_
2016-01-19 11:25:14 +11:00
RESPARAMS = $(RESOURCES) include/res.h src/c/gen/res.c res_
2016-01-03 13:25:12 +11:00
2016-01-04 04:08:43 +11:00
SRCDIRECTORIES = $(shell find $(SOURCE) -type d)
2016-01-22 09:25:51 +11:00
BUILDDIRECTORIES = $(patsubst $(SOURCE)/%, $(BUILD)%, $(SRCDIRECTORIES))
2016-01-04 04:08:43 +11:00
CFILES = $(shell find $(SOURCE) -type f -name '*.c')
2016-01-22 09:25:51 +11:00
OBJECTS := $(patsubst $(SOURCE)/%.c, $(BUILD)%.c.o, $(CFILES))
# Targets
# Pseudo Targets
debug: CFLAGS+= -g
2016-01-04 04:08:43 +11:00
$(BUILDDIRECTORIES):
2016-01-05 04:20:40 +11:00
mkdir -p $@
2016-01-04 04:08:43 +11:00
2016-01-22 09:25:51 +11:00
build: smallclean $(BUILDDIRECTORIES) resources $(BUILD)lupi
2016-01-03 13:25:12 +11:00
2016-01-22 09:25:51 +11:00
all: clean build
2016-01-04 04:08:43 +11:00
$(BUILD)lupi: $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBS)
2016-01-22 09:25:51 +11:00
$(BUILD)%.c.o: $(SOURCE)/%.c
$(CC) -c $(CFLAGS) $(INCLUDES) $< -o $@
2016-01-03 13:25:12 +11:00
#Resources
2016-01-22 09:25:51 +11:00
resources: cleanresources
2016-01-03 13:25:12 +11:00
scripts/txt2c $(LUAPARAMS)
2016-01-19 11:25:14 +11:00
scripts/txt2c $(RESPARAMS)
2016-01-03 13:25:12 +11:00
2016-01-22 09:25:51 +11:00
# Clean rules
cleanresources:
2016-01-03 13:25:12 +11:00
-rm -f $(GENERATED)
2016-01-22 09:25:51 +11:00
mkdir -p $(SOURCE)/gen/
touch $(SOURCE)/gen/luares.c
2016-01-03 13:25:12 +11:00
touch include/luares.h
2016-01-22 09:25:51 +11:00
clean: cleanresources
2016-01-04 04:08:43 +11:00
-rm -rf $(BUILD)
2016-01-19 05:42:32 +11:00
smallclean:
find . -name '*~' -type f -exec rm {} \;
# Other
2016-01-20 05:46:40 +11:00
.PHONY: clean cleanresourcues resources build smallclean all