Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #48 from timvideos/makefile-fixes
Makefile refactoring
  • Loading branch information
mithro committed Sep 13, 2015
2 parents bf5323b + ec3091f commit 2e591f1
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 53 deletions.
24 changes: 16 additions & 8 deletions .travis/run.sh
Expand Up @@ -10,23 +10,31 @@ TARGETS="base hdmi2usb"

for BOARD in $BOARDS; do
for TARGET in $TARGETS; do
echo ""
echo ""
echo ""
echo "============================================="
echo "- $BOARD $TARGET"
echo "============================================="
echo ""
echo "- make help"
echo "---------------------------------------------"
BOARD=$BOARD TARGET=$TARGET make help
echo "---------------------------------------------"

# FIXME: Add ability to compile gateware.

BOARD=$BOARD TARGET=$TARGET make lm32-firmware
echo ""
echo ""
echo ""
echo "- make firmware"
echo "---------------------------------------------"
BOARD=$BOARD TARGET=$TARGET make firmware

# FIXME: Remove this once "make all" does what we need
if [ "$TARGET" = "hdmi2usb" ]; then
BOARD=$BOARD TARGET=$TARGET make fx2-firmware
echo "---------------------------------------------"
fi

echo ""
echo ""
echo ""
echo "- make clean"
echo "---------------------------------------------"
BOARD=$BOARD TARGET=$TARGET make clean
echo "============================================="
done
Expand Down
70 changes: 25 additions & 45 deletions Makefile
Expand Up @@ -16,27 +16,32 @@ else
FLTERM = $(MSCDIR)/tools/flterm
endif

include Makefile.$(TARGET)

help:
@echo "Targets avaliable:"
@echo " make gateware"
@echo " make lm32-firmware"
@echo " make fx2-firmware"
@echo " make load-gateware"
@echo " make load-lm32-firmware"
@echo " make load-fx2-firmware"
@echo " make clean"
@echo " make all"
@echo " make connect-lm32"
@echo ""
@echo "Environment:"
@echo " BOARD=atlys OR opsis (current: $(BOARD))"
@echo " TARGET=base OR hdmi2usb OR hdmi2ethernet"
@echo " (current: $(TARGET)"
@echo " MSCDIR=misoc directory (current: $(MSCDIR))"
@echo " (current: $(TARGET))"
@echo " PROG=programmer (current: $(PROG))"
@echo " SERIAL=serial port (current: $(SERIAL))"
@echo ""
@echo "Targets avaliable:"
@echo " make help"
@echo " make gateware"
@echo " make load-gateware"
@echo " make connect-lm32"
@make -s help-$(TARGET)
@echo " make clean"
@echo " make all"

clean: clean-$(TARGET)
cd $(MSCDIR) && $(CMD) clean

load: load-gateware load-$(TARGET)

gateware: lm32-firmware
# Gateware targets
gateware: gateware-$(TARGET)
cd $(MSCDIR) && $(CMD) --csr_csv $(HDMI2USBDIR)/test/csr.csv clean
cp hdl/encoder/vhdl/header.hex $(MSCDIR)/build/header.hex
cd $(MSCDIR) && $(CMD) --csr_csv $(HDMI2USBDIR)/test/csr.csv build-csr-csv build-bitstream
Expand All @@ -47,39 +52,14 @@ load-gateware:
release-gateware:
cd $(MSCDIR)/build && tar -cvzf ../$(HDMI2USBDIR)/$(BOARD)_$(TARGET)_gateware_$(DATE).tar.gz *.bin *.bit


ifeq ($(TARGET), base)
lm32-firmware:
cd $(MSCDIR) && $(CMD) build-headers
echo "No lm32-firmware for base target."
else
lm32-firmware:
cd $(MSCDIR) && $(CMD) build-headers
$(MAKE) -C firmware/lm32 all
endif

load-lm32-firmware: lm32-firmware
$(FLTERM) --port $(SERIAL) --kernel=firmware/lm32/firmware.bin --kernel-adr=0x20000000 --speed 115200
# Firmware targets
firmware: firmware-$(TARGET)
@true

connect-lm32:
$(FLTERM) --port $(SERIAL) --speed 115200

fx2-firmware:
$(MAKE) -C firmware/fx2

load-fx2-firmware: fx2-firmware
firmware/fx2/download.sh firmware/fx2/hdmi2usb.hex

clean:
cd $(MSCDIR) && $(CMD) clean
$(MAKE) -C firmware/lm32 clean
$(MAKE) -C firmware/fx2 clean

load: load-gateware load-lm32-firmware load-fx2-firmware

view:
./scripts/view.sh

all: gateware load-gateware load-fx2-firmware
# All target
all: gateware load-gateware load-$(TARGET)

.PHONY: lm32-firmware load clean
.PHONY: help clean load gateware load-gateware release-gateware connect-lm32 all
16 changes: 16 additions & 0 deletions Makefile.base
@@ -0,0 +1,16 @@
help-base:
@true

gateware-base:
@true

firmware-base:
cd $(MSCDIR) && $(CMD) build-headers

load-base:
@true

clean-base:
@true

.PHONY: help-base gateware-base firmware-base load-base clean-base
31 changes: 31 additions & 0 deletions Makefile.hdmi2ethernet
@@ -0,0 +1,31 @@
help-hdmi2ethernet:
@echo " make lm32-firmware"
@echo " make load-lm32-firmware"

gateware-hdmi2ethernet: lm32-firmware
@true

firmware-hdmi2ethernet: lm32-firmware
@true

load-hdmi2ethernet: load-lm32-firmware
@true

clean-hdmi2ethernet: clean-lm32-firmware
@true

# Firmware for the lm32 softcore
lm32-firmware:
cd $(MSCDIR) && $(CMD) build-headers
$(MAKE) -C firmware/lm32 all

load-lm32-firmware: lm32-firmware
$(FLTERM) --port $(SERIAL) --kernel=firmware/lm32/firmware.bin --kernel-adr=0x20000000 --speed 115200

clean-lm32-firmware:
$(MAKE) -C firmware/lm32 clean

# Utility functions

.PHONY: help-hdmi2ethernet gateware-hdmi2ethernet firmware-hdmi2ethernet load-hdmi2ethernet clean-hdmi2ethernet
.PHONY: lm32-firmware load-lm32-firmware clean-lm32-firmware
47 changes: 47 additions & 0 deletions Makefile.hdmi2usb
@@ -0,0 +1,47 @@
help-hdmi2usb:
@echo " make lm32-firmware"
@echo " make load-lm32-firmware"
@echo " make fx2-firmware"
@echo " make load-fx2-firmware"
@echo " make view"

gateware-hdmi2usb: lm32-firmware
@true

firmware-hdmi2usb: lm32-firmware fx2-firmware
@true

load-hdmi2usb: load-lm32-firmware
@true

clean-hdmi2usb: clean-lm32-firmware clean-fx2-firmware
@true

# Firmware for the lm32 softcore
lm32-firmware:
cd $(MSCDIR) && $(CMD) build-headers
$(MAKE) -C firmware/lm32 all

load-lm32-firmware: lm32-firmware
$(FLTERM) --port $(SERIAL) --kernel=firmware/lm32/firmware.bin --kernel-adr=0x20000000 --speed 115200

clean-lm32-firmware:
$(MAKE) -C firmware/lm32 clean

# Firmware for the Cypress FX2
fx2-firmware:
$(MAKE) -C firmware/fx2

load-fx2-firmware: fx2-firmware
firmware/fx2/download.sh firmware/fx2/hdmi2usb.hex

clean-fx2-firmware:
$(MAKE) -C firmware/fx2 clean

# Utility functions
view:
./scripts/view.sh

.PHONY: help-hdmi2usb gateware-hdmi2usb firmware-hdmi2usb load-hdmi2usb clean-hdmi2usb
.PHONY: lm32-firmware load-lm32-firmware clean-lm32-firmware
.PHONY: fx2-firmware load-fx2-firmware clean-fx2-firmware

0 comments on commit 2e591f1

Please sign in to comment.