Switched to the system timer.
[tart.git] / Makefile
blobaf4a1a1c66d7854a9115c4c0eb0debf7de369fc0
1 # OUTELF and OUTBIN.
2 OUTELF := tart
3 OUTBIN := $(OUTELF).bin
5 CCFLAGS ?= -O2
7 # Include the config and rules.
8 include config.mk
9 include target/$(TARGET)/rules.mk
10 include platform/$(PLATFORM)/rules.mk
11 include rules.mk
13 # List of CFLAGS.
14 CFLAGS += -std=c99 -Wall -Wextra -nostdlib -ffreestanding -lgcc $(CCFLAGS)
16 # Includes.
17 CPPFLAGS := -Iinclude -Ikernel/include -Iarch/$(ARCH)/include -Itarget/$(TARGET)/include -Iplatform/$(PLATFORM)/include
19 # Get a list of source files.
20 CSRC := $(shell find arch/$(ARCH) -type f -name "*.c") $(shell find kernel -type f -name "*.c") \
21 $(shell find target/$(TARGET) -type f -name "*.c") $(shell find platform/$(PLATFORM) -type f -name "*.c")
23 ASMSRC := $(shell find arch/$(ARCH) -type f -name "*.S") $(shell find kernel -type f -name "*.S") \
24 $(shell find target/$(TARGET) -type f -name "*.S") $(shell find platform/$(PLATFORM) -type f -name "*.S")
26 # Get the object files.
27 OBJ := $(patsubst %.S,%.o,$(ASMSRC)) $(patsubst %.c,%.o,$(CSRC))
29 # Get the dependancies.
30 DEP := $(patsubst %.S,%.d,$(ASMSRC)) $(patsubst %.c,%.d,$(CSRC))
32 # Linker script.
33 LINK := arch/$(ARCH)/link.ld
35 # Make related files.
36 MAKEDEPS := Makefile rules.mk config.mk target/$(TARGET)/rules.mk platform/$(PLATFORM)/rules.mk
38 # The default target.
39 all: $(OUTFORMAT)
41 # List phony targets.
42 .PHONY: all clean
44 # ELF output.
45 $(OUTELF): $(OBJ) $(LINK)
46 $(HOSTLD) $(OBJ) -T$(LINK) -o $@
48 # Binary output.
49 $(OUTBIN): $(OUTELF)
50 $(HOSTOBJCOPY) $(OUTELF) -O binary $@
52 # Include dependancy files.
53 -include $(DEP)
55 # Clean.
56 clean:
57 -$(RM) $(wildcard $(OBJ) $(DEP) $(OUTELF) $(OUTFORMAT))
59 # Dog.
60 dog:
61 $(warning Experimental dog generator. Don't try it out; the default size isn't set, so-)
63 # CC.
64 %.o: %.c $(MAKEDEPS)
65 $(HOSTCC) $(CFLAGS) $(CPPFLAGS) -MMD -MP -c $< -o $@
67 # AS.
68 %.o: %.S $(MAKEDEPS)
69 $(HOSTCC) $(CFLAGS) $(CPPFLAGS) -MMD -MP -c $< -o $@