forked from andreaco/miosix-audio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
133 lines (110 loc) · 3.85 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
##
## Makefile for Miosix embedded OS
##
MAKEFILE_VERSION := 1.09
GCCMAJOR := $(shell arm-miosix-eabi-gcc --version | \
perl -e '$$_=<>;/\(GCC\) (\d+)/;print "$$1"')
## Path to kernel directory (edited by init_project_out_of_git_repo.pl)
KPATH := miosix
## Path to config directory (edited by init_project_out_of_git_repo.pl)
CONFPATH := $(KPATH)
include $(CONFPATH)/config/Makefile.inc
##
## List here subdirectories which contains makefiles
##
SUBDIRS := $(KPATH)
##
## List here your source files (both .s, .c and .cpp)
##
SRC := \
src/main.cpp \
src/drivers/stm32f407vg_discovery/audio.cpp \
src/drivers/stm32f407vg_discovery/cs43l22dac.cpp \
src/midi/midiXparser.cpp \
src/midi/midi.cpp \
src/audio_modules/virtual_analog_oscillator.cpp \
src/audio_modules/lookup_tables.cpp \
src/audio_modules/envelope.cpp \
src/audio_modules/lowpass_filter_1p.cpp \
src/audio_modules/lowpass_filter_ladder_4p.cpp \
src/audio_processors/synthesizer.cpp \
src/audio_processors/mono_synth.cpp \
src/drivers/stm32f407vg_discovery/core_util_stm32f407vg.cpp \
src/drivers/encoder.cpp \
src/drivers/double_encoder.cpp \
src/drivers/button.cpp \
src/drivers/midi_in_port.cpp
##
## List here additional static libraries with relative path
##
LIBS :=
##
## List here additional include directories (in the form -Iinclude_dir)
##
INCLUDE_DIRS :=
##############################################################################
## You should not need to modify anything below ##
##############################################################################
ifeq ("$(VERBOSE)","1")
Q :=
ECHO := @true
else
Q := @
ECHO := @echo
endif
## Replaces both "foo.cpp"-->"foo.o" and "foo.c"-->"foo.o"
OBJ := $(addsuffix .o, $(basename $(SRC)))
## Includes the miosix base directory for C/C++
## Always include CONFPATH first, as it overrides the config file location
CXXFLAGS := $(CXXFLAGS_BASE) -I$(CONFPATH) -I$(CONFPATH)/config/$(BOARD_INC) \
-I. -I$(KPATH) -I$(KPATH)/arch/common -I$(KPATH)/$(ARCH_INC) \
-I$(KPATH)/$(BOARD_INC) $(INCLUDE_DIRS)
CFLAGS := $(CFLAGS_BASE) -I$(CONFPATH) -I$(CONFPATH)/config/$(BOARD_INC) \
-I. -I$(KPATH) -I$(KPATH)/arch/common -I$(KPATH)/$(ARCH_INC) \
-I$(KPATH)/$(BOARD_INC) $(INCLUDE_DIRS) \
-ffunction-sections -fdata-sections
AFLAGS := $(AFLAGS_BASE)
LFLAGS := $(LFLAGS_BASE)
DFLAGS := -MMD -MP
## libmiosix.a is among stdlibs because needs to be within start/end group
STDLIBS := -lmiosix -lstdc++ -lc -lm -lgcc
ifneq ($(GCCMAJOR),4)
STDLIBS += -latomic
endif
LINK_LIBS := $(LIBS) -L$(KPATH) -Wl,--start-group $(STDLIBS) -Wl,--end-group
all: all-recursive main
clean: clean-recursive clean-topdir
program:
$(PROGRAM_CMDLINE)
all-recursive:
$(foreach i,$(SUBDIRS),$(MAKE) -C $(i) \
KPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(KPATH)) \
CONFPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(CONFPATH)) \
|| exit 1;)
clean-recursive:
$(foreach i,$(SUBDIRS),$(MAKE) -C $(i) \
KPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(KPATH)) \
CONFPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(CONFPATH)) \
clean || exit 1;)
clean-topdir:
-rm -f $(OBJ) main.elf main.hex main.bin main.map $(OBJ:.o=.d)
main: main.elf
$(ECHO) "[CP ] main.hex"
$(Q)$(CP) -O ihex main.elf main.hex
$(ECHO) "[CP ] main.bin"
$(Q)$(CP) -O binary main.elf main.bin
$(Q)$(SZ) main.elf
main.elf: $(OBJ) all-recursive
$(ECHO) "[LD ] main.elf"
$(Q)$(CXX) $(LFLAGS) -o main.elf $(OBJ) $(KPATH)/$(BOOT_FILE) $(LINK_LIBS)
%.o: %.s
$(ECHO) "[AS ] $<"
$(Q)$(AS) $(AFLAGS) $< -o $@
%.o : %.c
$(ECHO) "[CC ] $<"
$(Q)$(CC) $(DFLAGS) $(CFLAGS) $< -o $@
%.o : %.cpp
$(ECHO) "[CXX ] $<"
$(Q)$(CXX) $(DFLAGS) $(CXXFLAGS) $< -o $@
#pull in dependecy info for existing .o files
-include $(OBJ:.o=.d)