# MIT License # # Copyright (c) 2018, Alexey Dynda # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # ################################################################# # Makefile containing common logic for all systems # # Accepts the following parameters: # CC # CXX # STRIP # AR default: all DESTDIR ?= BLD ?= ../bld BACKSLASH?=/ MKDIR?=mkdir -p convert=$(subst /,$(BACKSLASH),$1) .SUFFIXES: .c .cpp .ino $(BLD)/%.o: %.c -$(MKDIR) $(call convert,$(dir $@)) $(CC) -std=gnu11 $(CCFLAGS) -c $< -o $@ $(BLD)/%.o: %.ino -$(MKDIR) $(call convert,$(dir $@)) $(CXX) -std=c++11 $(CCFLAGS) $(CXXFLAGS) $(CCFLAGS-$(basename $(notdir $@))) -x c++ -c $< -o $@ $(BLD)/%.o: %.cpp -$(MKDIR) $(call convert,$(dir $@)) $(CXX) -std=c++11 $(CCFLAGS) $(CXXFLAGS) $(CCFLAGS-$(basename $(notdir $@))) -c $< -o $@ ################ OPTIONS ########################## ifeq ($(ADAFRUIT),y) ADAFRUIT_DIR ?= $(shell readlink -f ~)/Arduino/libraries/Adafruit_GFX_Library INCLUDES += -I$(ADAFRUIT_DIR) \ # -I$(shell readlink -f ../src)/ssd1306_hal/linux/arduino CCFLAGS-Adafruit_GFX= -DARDUINO=100 SRCS += \ $(ADAFRUIT_DIR)/Adafruit_GFX.cpp endif # ************* Common defines ******************** INCLUDES += \ -I. CCFLAGS += -MD -g -Os $(INCLUDES) -Wall -Werror -ffunction-sections -fdata-sections \ -fno-exceptions CXXFLAGS += -fno-rtti ifeq ($(SDL_EMULATION),y) CCFLAGS += -DSDL_EMULATION -I../tools/sdl endif .PHONY: clean ssd1306 all help include Makefile.src ####################### Compiling library ######################### $(BLD)/libssd1306.a: $(OBJS) $(AR) rcs $@ $(OBJS) ssd1306: $(BLD)/libssd1306.a all: ssd1306 clean: rm -rf $(BLD) help: @echo "Makefile accepts the following options:" @echo " ADAFRUIT=y/n Enables compilation of Adafruit GFX library" @echo " ADAFRUIT_DIR=path Path to Adafruit GFX library" @echo " SDL_EMULATION=y/n Enables SDL emulator in the library" @echo " FREQUENCY=N Frequency in Hz" @echo " MCU=mcu_code Specifies MCU to compile for (valid for AVR)" -include $(OBJS:%.o=%.d)