Date:2011-02-11 13:42:21 (13 years 1 month ago)
Author:Werner Almesberger
Commit:c1dc00ee44a8e9839f1913029dc21906cd0c0797
Message:fw2/Makefile: dependencies, verbosity control, cleanup

- Makefile (SHELL): require bash for PIPESTATUS used for dependencies
- Makefile: added copyright header
- Makefile: added section titles
- Makefile: added verbosity control
- Makefile: added automatic dependency generation
- Makefile (clean): also remove .d files
Files: atusb/fw2/Makefile (2 diffs)

Change Details

atusb/fw2/Makefile
1#
2# Makefile - Makefile of the ATUSB firmware
3#
4# Written 2010-2011 by Werner Almesberger
5# Copyright 2010-2011 by Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13SHELL = /bin/bash
14
115NAME = atusb
216
317CFLAGS = -g -Wall -Wextra -Wshadow -Werror -Wno-unused \
...... 
2135      -I$(FreakUSB)/usb -I$(FreakUSB)/hw/at90usbxx2 \
2236      -DNUM_EPS=1
2337
38# ----- Verbosity control -----------------------------------------------------
39
40CC_normal := $(CC)
41BUILD_normal :=
42DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
43
44CC_quiet = @echo " CC " $@ && $(CC_normal)
45BUILD_quiet = @echo " BUILD " $@ && $(BUILD_normal)
46DEPEND_quiet = @$(DEPEND_normal)
47
48ifeq ($(V),1)
49    CC = $(CC_normal)
50    BUILD = $(BUILD_normal)
51    DEPEND = $(DEPEND_normal)
52else
53    CC = $(CC_quiet)
54    BUILD = $(BUILD_quiet)
55    DEPEND = $(DEPEND_quiet)
56endif
57
58# ----- Rules -----------------------------------------------------------------
2459
2560.PHONY: all clean upload prog
2661
2762all: $(NAME).bin
2863
29%.o: %.c
30        $(CC) $(CFLAGS) -mmcu=$(CHIP) -Os -c $<
31
3264$(NAME).elf: $(OBJS)
3365        $(CC) $(CFLAGS) -mmcu=$(CHIP) -o $@ $(OBJS)
3466
3567%.bin: %.elf
36        $(OBJCOPY) -j .text -j .data -O binary $< $@
68        $(BUILD) $(OBJCOPY) -j .text -j .data -O binary $< $@
69
70# ----- Cleanup ---------------------------------------------------------------
3771
3872clean:
39        rm -f $(NAME).bin $(NAME).elf $(OBJS)
73        rm -f $(NAME).bin $(NAME).elf $(OBJS) $(OBJS:.o=.d)
74
75# ----- Dependencies ----------------------------------------------------------
76
77%.o: %.c
78        $(CC) $(CFLAGS) -mmcu=$(CHIP) -Os -c $<
79        $(DEPEND) $< | \
80          sed -e \
81            '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
82            -e '$${g;p;}' -e d >$*.d; \
83          [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }
84
85-include $(OBJS:.o=.d)
86
87# ----- Programming and device control ----------------------------------------
4088
4189upload: $(NAME).bin
4290        scp $(NAME).bin jlime:

Archive Download the corresponding diff file



interactive