-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
47 lines (39 loc) · 1.02 KB
/
Makefile
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
# We only allow compilation on linux!
ifneq ($(shell uname), Linux)
$(error OS must be Linux!)
endif
# Check if all required tools are on the system.
REQUIRED = sdcc sdar sdasz80
K := $(foreach exec,$(REQUIRED),\
$(if $(shell which $(exec)),,$(error "$(exec) not found. Please install or add to path.")))
# Global settings: folders.
ROOT = $(realpath .)
export BUILD_DIR = $(ROOT)/build
export BIN_DIR = $(ROOT)/bin
# Globa settings: tools.
export CC = sdcc
export CFLAGS = --std-c11 -mz80 -I. --no-std-crt0 --nostdinc --nostdlib --debug
export AS = sdasz80
export ASFLAGS = -xlos -g
export AR = sdar
export ARFLAGS = -rc
# Subfolders for make.
SUBDIRS = src
# Rules.
.PHONY: all
all: $(BUILD_DIR) $(SUBDIRS)
cp $(BUILD_DIR)/*.lib $(BIN_DIR)
.PHONY: $(BUILD_DIR)
$(BUILD_DIR):
# Create build dir.
mkdir -p $(BUILD_DIR)
# Remove bin dir (we are going to write again).
rm -f -r $(BIN_DIR)
# And re-create!
mkdir -p $(BIN_DIR)
.PHONY: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
.PHONY: clean
clean:
rm -f -r $(BUILD_DIR)