#*********************************************************************** # Copyright (C) 2021 Prosource (CLI Systems LLC) # https://prosource.dev # # License: # THIS SOURCE CODE IS PART OF THE prosource.dev EMBEDDED SYSTEM # KNOWLEDGE-BASE. This source code is a Free Solution as defined # in the Prosource Usage License and is provided under the # Creative Commons Attribution 4.0 International (CC BY 4.0) license # as defined at https://creativecommons.org/licenses/by/4.0/ # # This source code and all software distributed under the License are # distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER # EXPRESS OR IMPLIED # #********************************************************************** #========================================================== # Makefile of project #========================================================== #TARGET = ARM # Basic system C_COMPILE = RFS_ROOT= DFLAGS = NAME = test OPT ?= -O0 GCC_PREFIX = EXE = $(NAME).bin ifeq ($(TARGET),ARM) TOOLCHAIN_DIR = $(HOME)/projects/arm-buildroot-linux-gnueabihf_sdk-buildroot GCC_PREFIX = arm-buildroot-linux-gnueabihf- DFLAGS = -D__ARM__ EXE = $(NAME)_arm.bin C_COMPILE = $(TOOLCHAIN_DIR)/bin/$(GCC_PREFIX) RFS_ROOT = $(TOOLCHAIN_DIR)/arm-buildroot-linux-gnueabihf/sysroot/ endif # Setup output parameters PATH_TARGET = PATH_OBJ = bin/ CC = $(C_COMPILE)gcc CXX = $(C_COMPILE)g++ STRIP = $(C_COMPILE)strip CFLAGS = -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable CFLAGS += -Wno-switch -ffunction-sections -fdata-sections #CFLAGS += -Wno-pointer-to-int-cast ifeq ($(TARGET),ARM) CFLAGS += -Wno-format endif CFLAGS += -g $(OPT) #DFLAGS += -DDEBUG # Directories and files ###################################################### DIRS = ./ SRC_FILES = $(shell find . -name '*.c') CXX_SRC_FILES = $(shell find . -name '*.cpp') OBJ_FILES = $(subst ./,$(PATH_OBJ),$(patsubst %.c,%.o,$(SRC_FILES))) CXX_OBJ_FILES = $(subst ./,$(PATH_OBJ),$(patsubst %.cpp,%.o,$(CXX_SRC_FILES))) # Defaults ###################################################### # Need to include headers for libraries INCLUDE = -I . INCLUDE += -I $(RFS_ROOT)/usr/include/ INCLUDE += $(foreach dir,$(DIRS),-I $(dir)) # Need to link in libs LIBS = LIBS += -L $(RFS_ROOT)/usr/lib/ # Use libs LDFLAGS = LDFLAGS += -lrt -lm -lpthread LNFLAGS = -Wl,--gc-sections # FLTK ###################################################### LDFLAGS += -lfltk # Sections and rules ###################################################### # Remove SILENT to see the build cmd .SILENT: .PHONY: all all-pre all-post all: all-pre $(EXE) all-post all-pre: echo "-- Building $(EXE) --" echo "GCC: $(CC)" mkdir -p $(foreach dir,$(DIRS),$(PATH_OBJ)$(dir)) all-post: # echo "Done..." $(EXE): $(OBJ_FILES) $(CXX_OBJ_FILES) echo " LNK $@" $(CXX) $(LNFLAGS) -s -o $(PATH_TARGET)$@ $(foreach dir,$(DIRS),$(PATH_OBJ)$(dir)*.o) $(LIBS) $(LDFLAGS) $(PATH_OBJ)%.o:%.c echo " CC $@" $(CC) $(CFLAGS) $(INCLUDE) $(DFLAGS) -c -o $@ $< $(PATH_OBJ)%.o:%.cpp echo " CXX $@" $(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDE) $(DFLAGS) -c -o $@ $< new: clean all clean: echo " RM .o" rm -rf $(EXE) rm -rf $(PATH_OBJ) rm -f $(PATH_TARGET)$(OUTLIB)