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 PFLAGS = c++-module $(TGT) -I./$(TARGET) -fprebuilt-module-path=. -fno-exceptions VPATH = . ./$(TARGET) # zdrojaky -> objekty OBJS = STM32L4x2_startup.o system.o MOBJS = morse.o io.o sys.o main.o BOBJS = $(addprefix $(BLD),$(OBJS)) all: $(BLD) $(PRJ).elf # ... atd. # -include $(BLD)*.d # linker $(PRJ).elf: $(BOBJS) $(MOBJS) -@echo [LLD $(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 [CCC $(TARGET)] $@ @$(CC) -c $(CFLAGS) $< -o $@ $(BLD)%.o: %.cpp -@echo [CXX $(TARGET)] $@ @$(CXX) $(VFLAGS) -c $(CFLAGS) $< -o $@ $(BLD): mkdir $(BLD) tabgen: tabgen.cpp $(CXX) -Oz tabgen.cpp -o tabgen table.cpp: tabgen ./tabgen # MODULES # main.o: main.cpp morse.pcm io.pcm morse.o: morse.cpp table.cpp io.pcm sys.pcm morse.pcm: morse.cpp table.cpp io.pcm sys.pcm %.o: %.cpp -@echo [CXM $(TARGET)] $@ @$(CXX) $(VFLAGS) -c $(MFLAGS) $< -o $@ %.pcm: %.cpp -@echo [PRE $(TARGET)] $@ @$(CXX) $(VFLAGS) -x $(PFLAGS) $< --precompile -o $@ # vycisti clean: rm -f $(BLD)* *.o *.lst *.bin *.elf *.map *.pcm *~ table.cpp tabgen .PHONY: all clean