-
Notifications
You must be signed in to change notification settings - Fork 0
/
clunet.mk
72 lines (56 loc) · 2.16 KB
/
clunet.mk
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
#
# DMBS Build System
# Released into the public domain.
#
# dean [at] fourwalledcubicle [dot] com
# www.fourwalledcubicle.com
#
# Include Guard
ifeq ($(filter CLUNET, $(DMBS_BUILD_MODULES)),)
# Sanity check user supplied DMBS path
ifndef DMBS_PATH
$(error Makefile DMBS_PATH option cannot be blank)
endif
# Location of the current module
CLUNET_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
# Import the CORE module of DMBS
include $(DMBS_PATH)/core.mk
# This module needs to be included before gcc.mk
ifneq ($(findstring GCC, $(DMBS_BUILD_MODULES)),)
$(error Include this module before gcc.mk)
endif
# Help settings
DMBS_BUILD_MODULES += CLUNET
DMBS_BUILD_TARGETS +=
DMBS_BUILD_MANDATORY_VARS += DMBS_PATH CLUNET_DEVICE_ADDRESS CLUNET_BOOTLOADER_SUPPORT CLUNET_BOOTLOADER_ADDRESS
DMBS_BUILD_OPTIONAL_VARS +=
DMBS_BUILD_PROVIDED_VARS += CLUNET_SRC
DMBS_BUILD_PROVIDED_MACROS +=
# Sanity check user supplied values
$(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
# CLUNET Library
$(call ERROR_IF_EMPTY, CLUNET_DEVICE_ADDRESS)
$(call ERROR_IF_EMPTY, CLUNET_BOOTLOADER_SUPPORT)
$(call ERROR_IF_EMPTY, CLUNET_BOOTLOADER_ADDRESS)
CC_FLAGS += -DCLUNET_BOOTLOADER_SUPPORT=$(CLUNET_BOOTLOADER_SUPPORT) -DCLUNET_DEVICE_ADDRESS=$(CLUNET_DEVICE_ADDRESS)
ifneq ($(CLUNET_BOOTLOADER_SUPPORT), 0)
# bootloader support enabled
CC_FLAGS += -DCLUNET_BOOTLOADER_ADDRESS=$(CLUNET_BOOTLOADER_ADDRESS)
LD_FLAGS += -ubtldr_main -Wl,--section-start=.bootloader=$(CLUNET_BOOTLOADER_ADDRESS)
LD_FLAGS += -Wl,--section-start=.clunetreset=$(shell printf "0x%X\n" $$(($(CLUNET_BOOTLOADER_ADDRESS) - 2)))
endif
CLUNET_SRC := $(CLUNET_MODULE_PATH)/src/clunet.S
ifeq ($(CLUNET_BOOTLOADER_SUPPORT), 3)
SRC :=
TARGET := bootloader
CLUNET_SRC := $(CLUNET_MODULE_PATH)/src/boot.S
LD_FLAGS += -nostartfiles
else ifeq ($(CLUNET_BOOTLOADER_SUPPORT), 2)
CLUNET_SRC += $(CLUNET_MODULE_PATH)/src/boot.S
endif
# Compiler flags and sources
SRC += $(CLUNET_SRC)
CC_FLAGS += -I$(CLUNET_MODULE_PATH)/include/
# Phony build targets for this module
.PHONY: $(DMBS_BUILD_TARGETS)
endif