BUILD: Improving build system
[tinyx.git] / Makefile
blob386622da5f92b64f38332d1d2c3a90291f446059
1 KFAMILY = 0
2 KVERSION = 0
3 KREVISION = 0
4 KNAME = And we have a coacervate...
6 HOSTCC = gcc
7 HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
9 CROSS_COMPILE ?= arm-linux-
11 ARCH = arm7
12 CPU = lpc2xxx
14 AS = $(CROSS_COMPILE)as
15 LD = $(CROSS_COMPILE)ld
16 CC = $(CROSS_COMPILE)gcc
17 AR = $(CROSS_COMPILE)ar
18 NM = $(CROSS_COMPILE)nm
19 STRIP = $(CROSS_COMPILE)strip
20 OBJCOPY = $(CROSS_COMPILE)objcopy
21 OBJDUMP = $(CROSS_COMPILE)objdump
22 AWK = awk
23 CFLAGS = -Wall -Os -mcpu=arm7tdmi -nostdlib
24 INCLUDES = -Iinclude -Iinclude/libc
26 PYTHON = python
28 MAKEFLAGS += --no-print-directory
30 all-sources = $(shell git-ls-files)
32 export ARCH CPU AS LD CC AR NM STRIP OBJCOPY OBJDUMP AWK CFLAGS PYTHON INCLUDES
34 tinyx.dirs = lib/ arch/ kernel/
36 tinyx.objs = $(patsubst %/, %/tyx_part.o, $(tinyx.dirs))
38 $(shell rm -f $(tinyx.objs) include/asm/arch include/asm)
39 $(shell ln -s asm-$(ARCH) include/asm)
40 $(shell ln -s arch-$(CPU) include/asm/arch)
42 _all:
44 all:
45 @$(MAKE) _dep
46 @$(MAKE) _all
48 _dep:
49 @touch build/tinyx.deps
51 _all: tinyx.hex
53 tinyx.hex: tinyx.elf
54 $(OBJCOPY) -O ihex build/$< build/$@
56 tinyx.elf: $(tinyx.objs)
57 #$(LD) -EL -T arch/$(ARCH)/kernel/kernel.ld -o build/$@ $(tinyx.objs)
58 $(CC) -Xlinker --script=arch/$(ARCH)/kernel/kernel.ld -o build/$@ $(tinyx.objs)
60 $(tinyx.objs):
61 @$(MAKE) target=$@ -f scripts/Makefile.build
63 define xtags
64 ctags -a $(all-sources)
65 endef
67 tags:
68 $(call xtags, ctags)
69 .PHONY: clean
70 clean:
71 @cleandirs="$(shell $(PYTHON) scripts/expandtree.py $(tinyx.dirs))"; \
72 cleanobjs=; \
73 for dir in $$cleandirs; do \
74 cleanobjs="$$cleanobjs $$dir*.o"; \
75 done; \
76 echo "rm -f $$cleanobjs include/asm build/tinyx.hex build/tinyx.elf build/tinyx.deps"; \
77 rm -f include/asm/arch
78 rm -f $$cleanobjs include/asm build/tinyx.hex build/tinyx.elf build/tinyx.deps;