diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..50b45a0 --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +PREFIX ?= /usr/local +TARGET ?= lite + +OBJ_DIR ?= $(shell pwd)/build +SRC_DIR := $(shell pwd)/src + +SRC_EXT := c +OBJ_EXT := o + +SRCS := $(shell find $(SRC_DIR) -name *.$(SRC_EXT)) + +SOURCES := $(foreach sname, $(SRCS), $(abspath $(sname))) +OBJECTS := $(patsubst $(SRC_DIR)/%.$(SRC_EXT), $(OBJ_DIR)/%.$(OBJ_EXT), $(SOURCES)) + +CC := gcc +CFLAGS ?= +LDLAGS ?= + +CFLAGS +=-Wall -O3 -g -std=gnu11 -fno-strict-aliasing -Isrc -fPIC -DLUA_COMPAT_ALL +LDFLAGS +=-lSDL2 -lm + +UNAME := $(shell uname -s) +ifeq ($(UNAME_S),Linux) +CFLAGS +=-DLUA_USE_POSIX +endif + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CC) $^ -o $@ $(LDFLAGS) + +$(OBJ_DIR)/%$(OBJ_EXT): $(SRC_DIR)/%$(SRC_EXT) + mkdir -p $(dir $@) + $(CC) -c $(CFLAGS) $< -o $@ + +clean: + -rm -f $(OBJECTS) $(TARGET) + +.PHONY: clean + +install: all + @echo Installing to $(DESTDIR)$(PREFIX) ... + @mkdir -p $(DESTDIR)$(PREFIX)/bin/ + @cp -fp $(TARGET) $(DESTDIR)$(PREFIX)/bin/ + @echo Complete. diff --git a/README.md b/README.md index e61d8f1..f2b410a 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ You can build the project yourself on Linux with following prerequisites: #### Debian/Ubuntu ``` -sudo apt install libsdl2-dev gcc -./build.sh +sudo apt install libsdl2-dev gcc make +make ``` ### Windows