From 973cac3240865aa0585fcd03a5aed8f2d8d296f0 Mon Sep 17 00:00:00 2001 From: Ben Blazak Date: Tue, 12 Jun 2012 16:11:18 -0700 Subject: [PATCH] (more makefile modifications) --- .gitignore | 2 -- makefile | 40 ++++++++++++++++++++++++---------------- src/makefile | 32 ++++++++++++++++---------------- 3 files changed, 40 insertions(+), 34 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d77864a..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.zip - diff --git a/makefile b/makefile index 4372346..2d03791 100644 --- a/makefile +++ b/makefile @@ -4,9 +4,9 @@ # This should produce a single file (probably in an archive format) for # distribution, containing everything people will need to use the software. # -# AVAILABILITY: This is unabashedly dependant on various Unix commands, and -# therefore probably won't work in a Windows environment. I'm sorry. I don't -# know a good portable way to write it. +# DEPENDENCIES: This is unabashedly dependant on various Unix commands, and +# therefore probably won't work in a Windows environment. I'm sorry... I +# don't know a good portable way to write it. # # TODO: # - include doc files (and maybe render them in html) @@ -23,10 +23,13 @@ NAME := ergodox-firmware # the branch of the git repo we're currently on BRANCH := $(shell git branch -l | grep '*' | cut -c 3-) # a version identifier -VERSION := $(shell date +'%Y%m%d_%H%M%S') +VERSION := $(shell git log -n 1 | grep 'commit' | cut -c 8-14)--$(shell date +'%Y%m%dT%H%M%S') # name to use for the final distribution file or package -TARGET = $(NAME)--$(BRANCH)--$(VERSION) +TARGET := $(NAME)--$(BRANCH)--$(VERSION) + +# the build dir +BUILD := build # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- @@ -37,17 +40,22 @@ all: dist clean: git clean -dX # remove ignored files and directories + -rm -r '$(BUILD)' -dist: src contrib/UI - -# ----------------------------------------------------------------------------- - -.PHONY: src contrib/UI - -src: +dist: + # set up the build dir + -rm -r '$(BUILD)/$(TARGET)'* + -mkdir -p '$(BUILD)/$(TARGET)' + # make all subprojects cd src; $(MAKE) all - zip '$(TARGET)' src/*.hex src/*.elf src/*.map - -contrib/UI: - # nothing yet + # copy stuff to build dir + # --- from src + ( cd src; \ + cp firmware.hex firmware.eep firmware.map \ + '../$(BUILD)/$(TARGET)' ) + # make into a zip archive + ( cd '$(BUILD)/$(TARGET)'; \ + zip '../$(TARGET).zip' \ + -r * .* \ + -x '..*' ) diff --git a/src/makefile b/src/makefile index 07e03ee..ccdc7ec 100644 --- a/src/makefile +++ b/src/makefile @@ -13,18 +13,18 @@ # ----------------------------------------------------------------------------- -TARGET = firmware # the name we want for our program binary -FORMAT = ihex # the program binary's format -KEYBOARD = ergodox # keyboard model; see "src/keyboard" for what's available -LAYOUT = qwerty # keyboard layout; see "src/keyboard/*/layout" for what's - # available +TARGET := firmware # the name we want for our program binary +FORMAT := ihex # the program binary's format +KEYBOARD := ergodox # keyboard model; see "src/keyboard" for what's available +LAYOUT := qwerty # keyboard layout; see "src/keyboard/*/layout" for what's + # available -MCU = atmega32u4 # processor type (for teensy 2.0); must match real life -BOARD = teensy-2-0 # see the libraries you're using for what's available -F_CPU = 16000000 # processor speed, in Hz +MCU := atmega32u4 # processor type (for teensy 2.0); must match real life +BOARD := teensy-2-0 # see the libraries you're using for what's available +F_CPU := 16000000 # processor speed, in Hz # firmware stuff -SRC = $(wildcard *.c) +SRC := $(wildcard *.c) # keyboard and layout stuff # --- remove whitespace from vars KEYBOARD := $(strip $(KEYBOARD)) @@ -48,7 +48,7 @@ SRC += $(wildcard lib-other/*/*/*.c) OBJ = $(SRC:%.c=%.o) -CFLAGS = -mmcu=$(MCU) # processor type (teensy 2.0); must match real +CFLAGS := -mmcu=$(MCU) # processor type (teensy 2.0); must match real # life CFLAGS += -DF_CPU=$(F_CPU) # processor frequency; must match initialization # in source @@ -76,7 +76,7 @@ CFLAGS += -fdata-sections # / section in the output file if the # unused code. # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -LDFLAGS = -Wl,-Map=$(strip $(TARGET)).map,--cref # generate a link map, with +LDFLAGS := -Wl,-Map=$(strip $(TARGET)).map,--cref # generate a link map, with # a cross reference table LDFLAGS += -Wl,--relax # for some linker optimizations LDFLAGS += -Wl,--gc-sections # discard unused functions and data @@ -85,14 +85,14 @@ LDFLAGS += -Wl,--gc-sections # discard unused functions and data GENDEPFLAGS += -MMD -MP -MF $@.dep # generate dependency files -CC = avr-gcc -OBJCOPY = avr-objcopy -SIZE = avr-size +CC := avr-gcc +OBJCOPY := avr-objcopy +SIZE := avr-size # remove whitespace from some of the variables -TARGET := $(strip $(TARGET)) -FORMAT := $(strip $(FORMAT)) +TARGET := $(strip $(TARGET)) +FORMAT := $(strip $(FORMAT)) # ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------