(more makefile modifications)

partial-rewrite
Ben Blazak 2012-06-12 16:11:18 -07:00
parent 5260e7104d
commit 973cac3240
3 changed files with 40 additions and 34 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
*.zip

View File

@ -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 '..*' )

View File

@ -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))
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------