v0.1 board believed to be reading Vbat, Pressure, and X/Y/Z correctly now,
[fw/openalt] / Makefile
1 #.SILENT: 
2
3 #
4 #  -D CFG_CONSOLE_USB   for console on USB
5 #  -D CFG_CONSOLE_UART0 for console on UART0
6 #  -D CFG_CONSOLE_UART1 for console on UART1 instead of USB (disables GPS task, baud rate set to 115200)
7 #  -D CFG_USB_MSC       to use SD/MMC as a mass storage class device over USB
8 #
9 export LPC2148DEMO_OPTS=-D CFG_CONSOLE_USB
10
11 #
12 #  These shouldn't need to be changed
13 #
14 export CC=arm-elf-gcc
15 export AR=arm-elf-ar
16 export OBJCOPY=arm-elf-objcopy
17 export OBJDUMP=arm-elf-objdump
18 export CRT0=boot.s
19 export WARNINGS=-Wall -Wextra -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wunused
20 export CFLAGS=$(WARNINGS) -D RUN_MODE=RUN_FROM_ROM -D GCC_ARM7 $(INCLUDES) $(BASEINCLUDE) -mcpu=arm7tdmi -T$(LDSCRIPT) -g -O3 -fomit-frame-pointer $(LPC2148DEMO_OPTS) -DFC1025 -DBDALE
21 export LDSCRIPT=lpc2148-rom.ld
22 export LINKER_FLAGS=$(COMMON)/common.a -Xlinker -olpc2148.elf -Xlinker -M -Xlinker -Map=lpc2148.map
23 export ROOT=$(shell pwd)
24 export BASEINCLUDE=-I$(ROOT) -I$(ROOT)/FreeRTOS/include
25 export COMMON=$(ROOT)/common
26
27 #
28 #  Project sub-directories
29 #
30 SUBDIRS=FreeRTOS adc cpu dac eints fatfs fiq gps i2c iap leds monitor newlib rtc sensors swi uart usb usbmass usbser
31
32 SRC_FILES = main.c
33
34 ARM_OBJ = $(SRC_FILES:.c=.o)
35
36 .PHONY: all
37 all : 
38         @for i in $(SUBDIRS); do \
39         (cd $$i; $(MAKE) $(MFLAGS) $(MYMAKEFLAGS) all); done
40         make lpc2148.hex
41         make lpc2148.bin
42
43 program:        lpc2148.bin
44         sudo openocd -f ./openocd-flash.cfg
45
46 debug:  lpc2148.bin
47         sudo openocd -f ./openocd-debug.cfg
48
49 lpc2148.hex : .depend Makefile lpc2148.elf
50         $(OBJCOPY) lpc2148.elf -O ihex lpc2148.hex
51         @echo "Length is " `grep __"end_of_text__ = ." *.map | cut -b 17-35` "bytes"
52
53 lpc2148.bin : .depend Makefile lpc2148.elf
54         $(OBJCOPY) lpc2148.elf -O binary lpc2148.bin
55         @echo "Length is " `grep __"end_of_text__ = ." *.map | cut -b 17-35` "bytes"
56
57 lpc2148.elf : .depend Makefile $(ARM_OBJ) $(COMMON)/common.a $(CRT0) $(LDSCRIPT)
58         $(CC) $(CFLAGS) $(ARM_OBJ) -nostartfiles $(CRT0) $(LINKER_FLAGS)
59         $(OBJDUMP) -d -S lpc2148.elf >lpc2148.lst
60  
61 $(ARM_OBJ) : %.o : %.c Makefile .depend
62         $(CC) -c $(CFLAGS) $< -o $@
63
64 #
65 #  The .depend files contains the list of header files that the
66 #  various source files depend on.  By doing this, we'll only
67 #  rebuild the .o's that are affected by header files changing.
68 #
69 .depend:
70         $(CC) $(CFLAGS) -M $(SRC_FILES) > .depend
71
72 #
73 #  Utility targets
74 #
75 .PHONY: tags
76 tags :
77         @rm -f ctags
78         find . -name \*.c -exec ctags -a {} \;
79         find . -name \*.h -exec ctags -a {} \;
80
81 .PHONEY: clean
82 clean :
83         find . -name \*.o -exec rm -f {} \;
84         find . -name .depend -exec rm -f {} \;
85         rm -f *.map *.lst *.elf *.hex *.bin .depend $(COMMON)/common.a
86
87 #
88 #
89 #
90 ifeq (.depend,$(wildcard .depend))
91 include .depend
92 endif