Browse Source

Add GNU make based build system

usb_midi_launchpad
heck 7 months ago
parent
commit
0aa8e478e7
  1. 13
      Makefile
  2. 35
      Makefile.conf
  3. 13
      build.conf.example
  4. 19
      src/Makefile

13
Makefile

@ -0,0 +1,13 @@
.PHONY: all flash clean
all: compile flash
compile:
$(MAKE) -C src
flash:
$(MAKE) -C src program
clean:
$(MAKE) -C src clean

35
Makefile.conf

@ -0,0 +1,35 @@
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
# Project Name
TARGET?=blink
# Configure for debugging
# common configurations:
# use DEBUG = 1 and OPT = -Og for debugging
# or DEBUG = 0 and OPT = -O3 for performance
DEBUG=0
OPT=-O3
# (optional) Includes FatFS source files within project.
#USE_FATFS = 1
# Relative to dir 'src'
LIBDAISY_DIR=../../heck_libDaisyWrong
DAISYSP_DIR=../../heck_DaisySPWrong
CXXFLAGS+=-Wall -Wno-unused -Wno-reorder-ctor -Wno-switch
######### Overrides from build.conf #########
-include $(HERE)build.conf
ifneq (,$(findstring g++,$(CXX)))
CXXFLAGS+=-fdiagnostics-color=always
else ifneq (,$(findstring clang,$(CXX)))
CXXFLAGS+=-fcolor-diagnostics
endif
ifeq ($(DEBUG),1)
CXXFLAGS+=-g -O0
else
CXXFLAGS+=-DNDEBUG=1 -O3
endif

13
build.conf.example

@ -0,0 +1,13 @@
# Build config
# also, infos for the build system about the dev environment
# TARGET sets the program to compile and flash
# the name of the main cxx file without the prefix 'main_'
TARGET=blink
#TARGET=testtone
DEBUG=0
# Daisy dependencies relative to dir 'src'
LIBDAISY_DIR=../../heck_libDaisy
DAISYSP_DIR=../../heck_DaisySP

19
src/Makefile

@ -0,0 +1,19 @@
include ../Makefile.conf
ALL_SRC=$(wildcard *.cc)
TARGET_SRC=main_$(TARGET).cc
MODULES_SRC=$(filter-out main_%,$(ALL_SRC))
CXX_SRC=$(MODULES_SRC) $(TARGET_SRC)
$(info CXXFLAGS: $(CXXFLAGS))
$(info SOURCES: $(ALL_SRC))
$(info MODULES: $(MODULES_SRC))
$(info TARGET_SRC: $(TARGET_SRC))
$(info CXX_SRC: $(CXX_SRC))
# libDaisy Makefile variables
CPPFLAGS=$(CXXFLAGS)
SYSTEM_FILES_DIR=$(LIBDAISY_DIR)/core
CPP_SOURCES=$(CXX_SRC)
include $(SYSTEM_FILES_DIR)/Makefile
Loading…
Cancel
Save