I'm a student and I'm currently working with the Infineon XMC4700 uC and have recently started to programm small "libraries" for for certain hardware components. For that reason, I createded a directory for each project and placed the corresponding files to it to test each component in a separate main.c file. As long as the .h and .c files are located in the same directory as the actual main.c file I know what I have to change in my Makefile.
However, for reasons of clarity and comprehensibility I'd like to place all headers in a "src" directory and all .c-files in a directory "inc". For example, the current directory looks like this
~/EigeneProgramme/XMC4700/ShiftRegister
|_build
|_inc
| |_ project.h
|_src
| |_ project.c
|_main.c
|_Makefile
However, if I do this, the program does no longer compile. My first approach was to extend the VPATH variable to show the compiler the path to the required files.
The code below shows the declaration of certain variables in the currently used Makefile.
CROSS_COMPILE=arm-none-eabi
CC = $(CROSS_COMPILE)-gcc
LD = $(CROSS_COMPILE)-gcc --specs=nosys.specs
AR = $(CROSS_COMPILE)-ar
AS = $(CROSS_COMPILE)-as
OC = $(CROSS_COMPILE)-objcopy
OD = $(CROSS_COMPILE)-objdump
SZ = $(CROSS_COMPILE)-size
ifeq ($(GDB_QUIET),true)
DB = $(CROSS_COMPILE)-gdb -quiet
else
DB = $(CROSS_COMPILE)-gdb
endif
BUILDDIR = build
LIB_BUILDDIR = lib_build
USB_LIBDIR = $(XMC_LIBDIR)/ThirdPartyLibraries/USBlib/USB
XMC_SERIES=4700
XMC_PACKAGE=F100
XMC_SIZE=2048
VPATH += $(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/BasicMathFunctions:$(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/CommonTables:$(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/ComplexMathFunctions:$(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/ControllerFunctions:$(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/FastMathFunctions:$(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/FilteringFunctions:$(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/MatrixFunctions:$(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/StatisticsFunctions:$(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/SupportFunctions:$(XMC_LIBDIR)/CMSIS/DSP_Lib/Source/TransformFunctions:$(XMC_LIBDIR)/CMSIS/Infineon/XMC$(XMC_SERIES)_series/Source:$(XMC_LIBDIR)/CMSIS/RTOS/RTX/SRC:$(XMC_LIBDIR)/CMSIS/RTOS/RTX/SRC/ARM:$(XMC_LIBDIR)/CMSIS/RTOS/RTX/Templates:$(XMC_LIBDIR)/CMSIS/RTOS/RTX/UserCodeTemplates:$(XMC_LIBDIR)/ThirdPartyLibraries/Newlib:$(XMC_LIBDIR)/XMCLib/src:$(USB_LIBDIR)/Class/Common:$(USB_LIBDIR)/Class/Device:$(USB_LIBDIR)/Common:$(USB_LIBDIR)/Core:$(USB_LIBDIR)/Core/XMC4000
CFLAGS = -I$(XMC_LIBDIR)/CMSIS/Include/
CFLAGS += -I$(XMC_LIBDIR)/CMSIS/Infineon/XMC$(XMC_SERIES)_series/Include/
CFLAGS += -I$(XMC_LIBDIR)/XMCLib/inc/
CFLAGS += -I$(USB_LIBDIR)
CFLAGS += -I$(USB_LIBDIR)/Class
CFLAGS += -I$(USB_LIBDIR)/Class/Common
CFLAGS += -I$(USB_LIBDIR)/Class/Device
CFLAGS += -I$(USB_LIBDIR)/Common
CFLAGS += -I$(USB_LIBDIR)/Core
CFLAGS += -I$(USB_LIBDIR)/Core/XMC4000
CFLAGS += -DXMC$(XMC_SERIES)_$(XMC_PACKAGE)x$(XMC_SIZE)
CFLAGS += -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -mthumb
CFLAGS += -g3 -gdwarf-2
CFLAGS += -c
CFLAGS += -Wa,-adhlns="[email protected]"
SFLAGS = $(CFLAGS)
CFLAGS +=$(SCFLAGS)
SFLAGS += -Wall
CFLAGS += -Wall
CFLAGS += -ffunction-sections
SFLAGS += -x assembler-with-cpp
LFLAGS = -T$(BUILDDIR)/$(LD_NAME).ld -nostartfiles
LFLAGS += -L$(XMC_LIBDIR)/CMSIS/Lib/GCC/
LFLAGS += -Wl,-Map,"[email protected]"
LFLAGS += -mcpu=cortex-m4 -mthumb
LFLAGS += -g3 -gdwarf-2
LIBSRCS += startup_XMC$(XMC_SERIES).c system_XMC$(XMC_SERIES).c
LIBSRCS += syscalls.c
OBJS = $(patsubst %.c,$(BUILDDIR)/%.o,$(SRCS))
LIBOBJS = $(patsubst %.c,$(LIB_BUILDDIR)/%.o,$(LIBSRCS))
Unfortunately, I'm not very experienced with Makefiles. For that reason, I'm struggling to adjust the Makefile to compile the program.
So could somebody provide a solution how to adujust the above shown snipped of my current Makefile to compile the program?
Best regards
RadbaldMeyer