-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
143 lines (107 loc) · 4.48 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
include $(TOPDIR)/deps.mk
#---------------------------------------------------------------------------------
# TARGET is the name of the output
#---------------------------------------------------------------------------------
TARGET := $(PLSR_TARGET)
SOURCES := $(addprefix $(PLSR_DIR), $(PLSR_SOURCES))
INCLUDES := $(addprefix $(PLSR_DIR), $(PLSR_INCLUDES))
BUILD := build
OUT := lib
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
DEFINES := -D__SWITCH__
CFLAGS := -g -Wall -Werror \
-ffunction-sections \
-fdata-sections \
$(ARCH) \
$(DEFINES) \
$(BUILD_CFLAGS)
CFLAGS += $(INCLUDE)
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH)
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD_TYPE),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(dir))
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
export LD := $(CC)
export OFILES_SRC := $(CFILES:.c=.o)
export OFILES := $(OFILES_SRC)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include)
.PHONY: clean all examples docs
#---------------------------------------------------------------------------------
all: debug release
examples: release
@$(MAKE) -C examples
docs:
@$(MAKE) -C docs
$(OUT):
@[ -d $@ ] || mkdir -p $@
$(OUT)/lib$(TARGET).a : $(OUT) $(SOURCES) $(INCLUDES)
@[ -d $(BUILD)/release ] || mkdir -p $(BUILD)/release
@$(MAKE) BUILD_TYPE=release OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DNDEBUG=1 -O2" \
DEPSDIR=$(CURDIR)/$(BUILD)/release \
--no-print-directory -C $(BUILD)/release \
-f $(TOPDIR)/Makefile
$(OUT)/lib$(TARGET)d.a : $(OUT) $(SOURCES) $(INCLUDES)
@[ -d $(BUILD)/debug ] || mkdir -p $(BUILD)/debug
@$(MAKE) BUILD_TYPE=debug OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DDEBUG=1 -Og" \
DEPSDIR=$(CURDIR)/$(BUILD)/debug \
--no-print-directory -C $(BUILD)/debug \
-f $(TOPDIR)/Makefile
debug: $(OUT)/lib$(TARGET)d.a
release: $(OUT)/lib$(TARGET).a
dist-bin: all
@tar --exclude=*~ -cJf lib$(TARGET).tar.xz include lib
dist-src:
@tar --exclude=*~ -cJf lib$(TARGET)-src.tar.xz include src Makefile deps.mk *.md
dist-docs: docs
@tar --exclude=*~ -cJf lib$(TARGET)-docs.tar.xz -C docs/build html
dist-examples: examples
@tar --exclude=*~ -cJf lib$(TARGET)-examples.tar.xz examples/build/*.nro examples/*.c
dist: dist-bin dist-src dist-docs dist-examples
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) lib *.xz
mrproper: clean
@$(MAKE) -C examples clean
@$(MAKE) -C docs clean
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT) : $(OFILES)
#---------------------------------------------------------------------------------
%_bin.h %.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------