Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
Changes to build system so swiftlib is built as a library and linked …
Browse files Browse the repository at this point in the history
…with the firmware image.
  • Loading branch information
fnoble committed Mar 16, 2012
1 parent 7d15874 commit 88a96a5
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 15 deletions.
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ else
MAKEFLAGS += PRN=$(PRN)
endif

.PHONY: all tests firmware docs
.PHONY: all tests firmware docs libswiftnav

all: firmware tests
all: libswiftnav firmware tests

firmware:
libswiftnav:
@printf "BUILD libswiftnav\n"; \
$(MAKE) -C libswiftnav $(MAKEFLAGS)

firmware: libswiftnav
@printf "BUILD src\n"; \
$(MAKE) -C src $(MAKEFLAGS)

tests:
tests: libswiftnav
$(Q)for i in tests/*; do \
if [ -d $$i ]; then \
printf "BUILD $$i\n"; \
Expand All @@ -31,6 +35,8 @@ tests:
done

clean:
@printf "CLEAN libswiftnav\n"; \
$(MAKE) -C libswiftnav $(MAKEFLAGS) clean
@printf "CLEAN src\n"; \
$(MAKE) -C src $(MAKEFLAGS) clean
$(Q)for i in tests/*; do \
Expand Down
63 changes: 63 additions & 0 deletions libswiftnav/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
##
## This file is part of the libopencm3 project.
##
## Copyright (C) 2009 Uwe Hermann <[email protected]>
## Copyright (C) 2012 Fergus Noble <[email protected]>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##

LIBNAME = libswiftnav

PREFIX ?= arm-none-eabi
CC = $(PREFIX)-gcc
AR = $(PREFIX)-ar
CFLAGS += -O3 -g -Wall -Wextra -Werror \
-mcpu=cortex-m3 -mthumb -Wstrict-prototypes \
-ffunction-sections -fdata-sections -MD \
-fno-common -msoft-float \
-DGIT_VERSION="\"$(GIT_VERSION)\"" -std=gnu99
# ARFLAGS = rcsv
ARFLAGS = rcs
OBJS = linear_algebra.o \
coord_system.o \
pvt.o \
track.o \
nav_msg.o \
ephemeris.o \
tropo.o \

# Be silent per default, but 'make V=1' will show all compiler calls.
ifneq ($(V),1)
Q := @
endif

all: $(LIBNAME).a

$(LIBNAME).a: $(OBJS)
@printf " AR $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(AR) $(ARFLAGS) $@ $^

%.o: %.c
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(CC) $(CFLAGS) -o $@ -c $<

clean:
$(Q)rm -f *.o *.d
$(Q)rm -f $(LIBNAME).a

.PHONY: clean

-include $(OBJS:.o=.d)

9 changes: 0 additions & 9 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
BINARY = swiftnav-firmware

SWIFTLIB_OBJS = ../swiftlib/linear_algebra.o \
../swiftlib/coord_system.o \
../swiftlib/pvt.o \
../swiftlib/track.o \
../swiftlib/nav_msg.o \
../swiftlib/ephemeris.o \
../swiftlib/tropo.o \

OBJS = main.o \
debug.o \
swift_nap_io.o \
Expand All @@ -21,7 +13,6 @@ OBJS = main.o \
hw/leds.o \
hw/spi.o \
hw/usart.o \
$(SWIFTLIB_OBJS)

include ../stm32/Makefile.include

4 changes: 2 additions & 2 deletions stm32/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CFLAGS += -O3 -g -Wall -Wextra -Werror -I$(TOOLCHAIN_DIR)/include -I$(SWIFTNAV_R
-fno-common -mcpu=cortex-m3 -mthumb -msoft-float -MD -DSTM32F2 \
-DGIT_VERSION="\"$(GIT_VERSION)\"" -std=gnu99
LDSCRIPT = $(SWIFTNAV_ROOT)/stm32/swiftnav.ld
LDFLAGS += -lc -lnosys -L$(TOOLCHAIN_DIR)/lib \
LDFLAGS += -lc -lnosys -L$(TOOLCHAIN_DIR)/lib -L$(SWIFTNAV_ROOT)/libswiftnav \
-L$(TOOLCHAIN_DIR)/lib/stm32/f2 \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections \
-mthumb -march=armv7 -mfix-cortex-m3-ldrd -msoft-float -lm
Expand Down Expand Up @@ -81,7 +81,7 @@ flash: $(BINARY).flash

%.elf: $(OBJS)
@printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(LD) -o $(*).elf $(OBJS) -lopencm3_stm32f2 -Xlinker -Map=$(*).map $(LDFLAGS)
$(Q)$(LD) -o $(*).elf $(OBJS) -lopencm3_stm32f2 -lswiftnav -Xlinker -Map=$(*).map $(LDFLAGS)

%.o: %.c Makefile
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
Expand Down

0 comments on commit 88a96a5

Please sign in to comment.