TARGET = stm32l4x2 PRJ = example BLD = ./bld/ # clang 18, modules experimental CC = clang CXX = clang++ # arm-none-eabi- toolchain (+gcc) LD = arm-none-eabi-ld SIZE = arm-none-eabi-size DUMP = arm-none-eabi-objdump COPY = arm-none-eabi-objcopy TGT = --target=thumbv7em-none-eabi -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard LDLIBS = -L/usr/lib/gcc/arm-none-eabi/9.2.1/thumb/v7e-m+fp/hard -L./$(TARGET) -Tscript.ld -lgcc CFLAGS = -Wall $(TGT) -Oz -gdwarf-3 -I./$(TARGET) -ffunction-sections -fdata-sections -fno-exceptions LFLAGS = -nostart-files --gc-sections -Map=example.map MFLAGS = $(CFLAGS) -fmodules -fprebuilt-module-path=. VFLAGS = -std=c++20 -fno-rtti VPATH = . ./$(TARGET) # zdrojaky -> objekty OBJS = STM32L4x2_startup.o system.o MOBJS = main.o io.o sys.o BOBJS = $(addprefix $(BLD),$(OBJS)) all: $(BLD) $(PRJ).elf # ... atd. # -include $(BLD)*.d # linker $(PRJ).elf: $(BOBJS) $(MOBJS) -@echo [LD $(TARGET)] $@ @$(LD) $(LFLAGS) -o $(PRJ).elf $(BOBJS) $(MOBJS) $(LDLIBS) -@echo "size:" @$(SIZE) $(PRJ).elf -@echo "listing:" $(DUMP) -d $(PRJ).elf > $(PRJ).lst $(COPY) --strip-unneeded -O binary $(PRJ).elf $(PRJ).bin -@echo "OK." # preloz co je potreba $(BLD)%.o: %.c -@echo [CC $(TARGET)] $@ @$(CC) -c $(CFLAGS) $< -o $@ $(BLD)%.o: %.cpp -@echo [CXX $(TARGET)] $@ @$(CXX) $(VFLAGS) -c $(CFLAGS) $< -o $@ $(BLD): mkdir $(BLD) # MODULES # main.o: main.cpp io.pcm sys.pcm %.o: %.cpp -@echo [CXM $(TARGET)] $@ @$(CXX) $(VFLAGS) -c $(MFLAGS) $< -o $@ %.pcm: %.cpp -@echo [PRE $(TARGET)] $@ @$(CXX) $(VFLAGS) -x c++-module $(TGT) -I./$(TARGET) -fno-exceptions $< --precompile -o $@ # vycisti clean: rm -f $(BLD)* *.o *.lst *.bin *.elf *.map *.pcm *~ .PHONY: all clean