Better makefile object build recipe

This commit is contained in:
AntonJ 2025-04-24 14:07:19 +03:00
parent c41f3b0d5f
commit 9aaca16baf
3 changed files with 13 additions and 19 deletions

View File

@ -10,6 +10,9 @@ else
ARMGCC_ROOT := ${shell dirname ${ARMGCC_BIN}}/.. ARMGCC_ROOT := ${shell dirname ${ARMGCC_BIN}}/..
endif endif
# Search for source files that are not in this directory
VPATH = ../common/
OBJECTS = main.o system.o startup.o syscalls.o OBJECTS = main.o system.o startup.o syscalls.o
NAME = lab NAME = lab
@ -47,7 +50,7 @@ LFLAGS = -Wl,-T,../config.lds \
all: $(NAME).out all: $(NAME).out
@echo "SUCCESS: Compilation completed successfully." @echo "SUCCESS: Compilation completed successfully."
main.o: main.c %.o: %.c
@$(CC) $(CFLAGS) -g $< -c -o $@ @$(CC) $(CFLAGS) -g $< -c -o $@
system.o: ../system.c system.o: ../system.c

View File

@ -10,6 +10,9 @@ else
ARMGCC_ROOT := ${shell dirname ${ARMGCC_BIN}}/.. ARMGCC_ROOT := ${shell dirname ${ARMGCC_BIN}}/..
endif endif
# Search for source files that are not in this directory
VPATH = ../common/
OBJECTS = main.o bump.o delay.o clock.o system.o startup.o syscalls.o OBJECTS = main.o bump.o delay.o clock.o system.o startup.o syscalls.o
NAME = lab NAME = lab
@ -47,13 +50,7 @@ LFLAGS = -Wl,-T,../config.lds \
all: $(NAME).out all: $(NAME).out
@echo "SUCCESS: Compilation completed successfully." @echo "SUCCESS: Compilation completed successfully."
main.o: main.c %.o: %.c
@$(CC) $(CFLAGS) -g $< -c -o $@
bump.o: ../common/bump.c
@$(CC) $(CFLAGS) -g $< -c -o $@
delay.o: ../common/delay.c
@$(CC) $(CFLAGS) -g $< -c -o $@ @$(CC) $(CFLAGS) -g $< -c -o $@
clock.o: ../common/clock.c clock.o: ../common/clock.c

View File

@ -10,7 +10,10 @@ else
ARMGCC_ROOT := ${shell dirname ${ARMGCC_BIN}}/.. ARMGCC_ROOT := ${shell dirname ${ARMGCC_BIN}}/..
endif endif
OBJECTS = main.o bump.o delay.o clock.o reflectance.o cpu.o system.o startup.o syscalls.o # Search for source files that are not in this directory
VPATH = ../common/
OBJECTS = main.o bump.o delay.o reflectance.o clock.o cpu.o system.o startup.o syscalls.o
NAME = lab NAME = lab
@ -47,21 +50,12 @@ LFLAGS = -Wl,-T,../config.lds \
all: $(NAME).out all: $(NAME).out
@echo "SUCCESS: Compilation completed successfully." @echo "SUCCESS: Compilation completed successfully."
main.o: main.c %.o: %.c
@$(CC) $(CFLAGS) -g $< -c -o $@
bump.o: ../common/bump.c
@$(CC) $(CFLAGS) -g $< -c -o $@
delay.o: ../common/delay.c
@$(CC) $(CFLAGS) -g $< -c -o $@ @$(CC) $(CFLAGS) -g $< -c -o $@
clock.o: ../common/clock.c clock.o: ../common/clock.c
@$(CC) $(CFLAGS) $< -c -o $@ @$(CC) $(CFLAGS) $< -c -o $@
reflectance.o: ../common/reflectance.c
@$(CC) $(CFLAGS) -g $< -c -o $@
cpu.o: ../common/cpu.c cpu.o: ../common/cpu.c
@$(CC) $(CFLAGS) $< -c -o $@ @$(CC) $(CFLAGS) $< -c -o $@