Browse Source

Makefile: output formatting changes

Aaron Lindsay 7 years ago
parent
commit
f9244836e1
1 changed files with 30 additions and 27 deletions
  1. 30 27
      Makefile

+ 30 - 27
Makefile

@@ -5,15 +5,16 @@
5 5
 ARCH = arm
6 6
 
7 7
 # Config options concerning the build process itself
8
-VERBOSE = 0 # 1 shows all compiler flags, 0 shows cleaner output
8
+VERBOSE ?= 0 # 1 shows all compiler flags, 0 shows cleaner output
9
+V = $(if $(VERBOSE:1=),@) # Use this to prefix commands that should only be shown when VERBOSE==1
9 10
 
10 11
 # Define the tools to be used
11 12
 TOOL_PREFIX = arm-elf-
12 13
 AS = $(TOOL_PREFIX)as
13 14
 CC = $(TOOL_PREFIX)gcc
14 15
 LD = $(TOOL_PREFIX)ld
15
-OBJCPY = $(TOOL_PREFIX)objcopy
16
-OBJDMP = $(TOOL_PREFIX)objdump
16
+OBJCOPY = $(TOOL_PREFIX)objcopy
17
+OBJDUMP = $(TOOL_PREFIX)objdump
17 18
 
18 19
 # Define the flags we'll need for our tools
19 20
 INCLUDES = -I include
@@ -27,45 +28,47 @@ include boot/Makefile.inc
27 28
 include kernel/Makefile.inc
28 29
 include devices/Makefile.inc
29 30
 
30
-.PHONY: all clean boot
31
+.PHONY: all clean boot boot-gdb
31 32
 
32 33
 all: aedrix-kernel.img aedrix-kernel.elf
33 34
 
34 35
 aedrix-kernel.elf: $(KOBJS)
35
-	$(if $(VERBOSE:1=),@echo '     LD $@')
36
-	$(if $(VERBOSE:1=),@)$(LD) $(KLDFLAGS) -o $@ $(KOBJS) $(EXTRA_LIBS)
36
+	@echo '     LD   $@'
37
+	$(V)$(LD) $(KLDFLAGS) -o $@ $(KOBJS) $(EXTRA_LIBS)
37 38
 
38 39
 aedrix-kernel.objdump: aedrix-kernel.elf
39
-	$(if $(VERBOSE:1=),@echo ' OBJDMP $@')
40
-	$(if $(VERBOSE:1=),@)$(OBJDMP) -D $< > $@
40
+	@echo 'OBJDUMP   $@'
41
+	$(V)$(OBJDUMP) -D $< > $@
41 42
 
42 43
 aedrix-kernel.img: aedrix-kernel.elf
43
-	$(if $(VERBOSE:1=),@echo ' OBJCPY $@')
44
-	$(if $(VERBOSE:1=),@)$(OBJCPY) $< -O binary $@
44
+	@echo 'OBJCOPY   $@'
45
+	$(V)$(OBJCOPY) $< -O binary $@
45 46
 
46 47
 %.o: %.c
47
-	$(if $(VERBOSE:1=),@echo '     CC $@')
48
-	$(if $(VERBOSE:1=),@)$(CC) $(KCFLAGS) -c -o $@ $<
48
+	@echo '     CC   $@'
49
+	$(V)$(CC) $(KCFLAGS) -c -o $@ $<
49 50
 
50 51
 # Assembly files without preprocessor directives
51 52
 %.o: %.s
52
-	$(if $(VERBOSE:1=),@echo '     AS $@')
53
-	$(if $(VERBOSE:1=),@)$(AS) -o $@ $<
53
+	@echo '     AS   $@'
54
+	$(V)$(AS) -o $@ $<
54 55
 
55 56
 # Assembly files with preprocessor directives
56 57
 %.o: %.S
57
-	$(if $(VERBOSE:1=),@echo '     AS $@')
58
-	$(if $(VERBOSE:1=),@)$(AS) -o $@ $<
58
+	@echo '     AS   $@'
59
+	$(V)$(AS) -o $@ $<
59 60
 
60 61
 clean:
61
-	@echo '  CLEAN *.o'
62
-	@rm -f $(KOBJS)
63
-	@echo '  CLEAN aedrix-kernel.elf'
64
-	@rm -f aedrix-kernel.elf
65
-	@echo '  CLEAN aedrix-kernel.objdump'
66
-	@rm -f aedrix-kernel.objdump
67
-	@echo '  CLEAN aedrix-kernel.img'
68
-	@rm -f aedrix-kernel.img
69
-
70
-boot: aedrix-kernel.elf
71
-	@qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.elf -serial stdio
62
+	@echo '  CLEAN   *.o'
63
+	$(V)rm -f $(KOBJS)
64
+	@echo '  CLEAN   aedrix-kernel.elf'
65
+	$(V)rm -f aedrix-kernel.elf
66
+	@echo '  CLEAN   aedrix-kernel.objdump'
67
+	$(V)rm -f aedrix-kernel.objdump
68
+	@echo '  CLEAN   aedrix-kernel.img'
69
+	$(V)rm -f aedrix-kernel.img
70
+
71
+boot: aedrix-kernel.img
72
+	$(V)qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.img -serial stdio
73
+boot-gdb: aedrix-kernel.img
74
+	$(V)qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.img -serial stdio -S -s