aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/simulator/Makefile
blob: 1834ed1a24c4c151f6610ceaa1dc51e6eb432e2a (plain)
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
# Build configuration
CONF_DEBUG		:= 1
CONF_BOOST		:= 0
CONF_IDLE		:= 1
CONF_IDLETOGGLE		:= 0
CONF_PRESETS		:= 1
CONF_EERING		:= 1
CONF_ADJ		:= 1
CONF_KCONF		:= 1
CONF_CURRCUTOFFHYST	:= 0.1
CONF_CURRCUTOFF		:= 1.8


BIN		:= pyxytronic.so

SRCS		:= pyxytronic.cxx \
		   simulator.cxx \
		   firmware.cxx

CPPFLAGS	:= -I.. -I../tests/fake \
		   $(shell python3-config --includes) \
		   -include ../tests/fake/fake.h \
		   -include simulator.h \
		   -include sparse.h \
		   -DNDEBUG \
		   -D_DEFAULT_SOURCE -D_GNU_SOURCE \
		   -DF_CPU=8000000UL \
		   -Dirq_disable=sim_irq_disable \
		   -Dirq_enable=sim_irq_enable \
		   -Dirq_disable_save=sim_irq_disable_save \
		   -Dirq_restore=sim_irq_restore \
		   -DSIMULATOR \
		   -DHW_SMD \
		   -DCONF_DEBUG=$(CONF_DEBUG) \
		   -DCONF_BOOST=$(CONF_BOOST) \
		   -DCONF_IDLE=$(CONF_IDLE) \
		   -DCONF_IDLETOGGLE=$(CONF_IDLETOGGLE) \
		   -DCONF_PRESETS=$(CONF_PRESETS) \
		   -DCONF_EERING=$(CONF_EERING) \
		   -DCONF_ADJ=$(CONF_ADJ) \
		   -DCONF_KCONF=$(CONF_KCONF) \
		   -DCONF_CURRCUTOFF=$(CONF_CURRCUTOFF) \
		   -DCONF_CURRCUTOFFHYST=$(CONF_CURRCUTOFFHYST)

CXXFLAGS	:= -std=c++17 -g -O2 -pthread -fPIC -fconcepts \
		   -Wall -Wextra -Wno-unused-parameter -Wswitch-enum \
		   -Wsuggest-attribute=noreturn -Wundef -Wpointer-arith \
		   -Wno-shift-negative-value \
		   -Wno-suggest-attribute=noreturn \
		   -Wno-attributes

LDFLAGS		:= $(shell python3-config --libs)


V		= @             # Verbose build:  make V=1
Q		= $(V:1=)
QUIET_CXX	= $(Q:@=@echo '     CXX      '$@;)$(CXX)
QUIET_DEPEND	= $(Q:@=@echo '     DEPEND   '$@;)$(CXX)

DEPS		= $(patsubst %.cxx,dep/%.d,$(1))
OBJS		= $(patsubst %.cxx,obj/%.o,$(1))


.SUFFIXES:
.PHONY: all install clean
.DEFAULT_GOAL := all

# Generate dependencies
$(call DEPS,$(SRCS)): dep/%.d: %.cxx
	@mkdir -p $(dir $@)
	$(QUIET_DEPEND) -o $@.tmp -MM -MT "$@ $(patsubst dep/%.d,obj/%.o,$@)" $(CXXFLAGS) $< && mv -f $@.tmp $@

-include $(call DEPS,$(SRCS))

# Generate object files
$(call OBJS,$(SRCS)): obj/%.o:
	@mkdir -p $(dir $@)
	$(QUIET_CXX) -o $@ -c $(CPPFLAGS) $(CXXFLAGS) $<

$(BIN): $(call OBJS,$(SRCS))
	$(QUIET_CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $(LDFLAGS) -shared $(LIBS) $(call OBJS,$(SRCS))

all: $(BIN)

clean:
	rm -Rf dep obj core *~ $(BIN)
bues.ch cgit interface