-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (61 loc) · 2.13 KB
/
Makefile
File metadata and controls
76 lines (61 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
lua ?= lua
TARGET_EXEC ?= ocvm
OPENCOMPUTERS=https://github.com/MightyPirates/OpenComputers/
LUA_CFLAGS := $(shell pkg-config --cflags $(lua) --silence-errors)
LUA_LDFLAGS := $(shell pkg-config --libs $(lua) --silence-errors)
ifeq ($(strip $(LUA_CFLAGS) $(LUA_LDFLAGS)),)
$(error "ERROR: pkg-config failed to find lua package: '$(lua)'")
endif
HOST=$(shell uname -s)
ldflags.Haiku = -lnetwork
dirs.Haiku = haiku
LDFLAGS+=-lstdc++
ifeq ($(shell uname -s 2>/dev/null),Haiku)
LDFLAGS+=-lnetwork
else
LDFLAGS+=-lstdc++fs -pthread -ldl
endif
SRC_DIRS = . apis color components drivers io model util $(dirs.$(HOST))
SRCS = $(foreach dir, $(SRC_DIRS), $(wildcard $(dir)/*.cpp))
CXXFLAGS += $(LUA_CFLAGS)
CXXFLAGS += -MMD -MP -Wall -g --std=c++17 -O0 -Wl,--no-as-needed
CXXFLAGS += $(addprefix -I,$(SRC_DIRS))
LDFLAGS += $(LUA_LDFLAGS) $(ldflags.$(HOST))
SYSTEM_DIR := system
SYSTEM_FILES := $(SYSTEM_DIR)/
BUILD_DIR ?= ./bin
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
DEPS := $(OBJS:.o=.d)
$(TARGET_EXEC): $(OBJS)
$(CXX) $(OBJS) -o $@ $(LDFLAGS)
-include $(DEPS)
$(BUILD_DIR)/%.cpp.o: %.cpp
@mkdir -p $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
deps:
@if ! command -v git >/dev/null; then \
echo deps cancelled: 'make deps' requires 'git' command. Aborting \
false; \
fi
@if [ -d $(SYSTEM_DIR) ]; then \
echo deps skipped: ./$(SYSTEM_DIR) already exists. To redownload system files, remove ./$(SYSTEM_DIR) and run 'make deps' again; \
else \
set -e; \
mkdir -p $(SYSTEM_DIR); \
cd $(SYSTEM_DIR); \
git clone -n --depth=1 --filter=tree:0 $(OPENCOMPUTERS); \
cd OpenComputers; \
git sparse-checkout set --no-cone /src/main/resources/assets/opencomputers/ && git checkout; \
set -x; \
mv src/main/resources/assets/opencomputers/loot ../; \
mv src/main/resources/assets/opencomputers/lua/machine.lua ../; \
mv src/main/resources/assets/opencomputers/lua/bios.lua ../; \
mv src/main/resources/assets/opencomputers/font.hex ../; \
cd ../..; \
rm -rf $(SYSTEM_DIR)/OpenComputers; \
fi
help:
@echo See README.md for build instructions
@echo Likely all you need is: make deps \$$\$$ make
clean:
$(RM) -r $(BUILD_DIR) $(TARGET_EXEC)