sonic-buildimage/Makefile

146 lines
6.4 KiB
Makefile
Raw Normal View History

2016-08-04 12:39:33 -05:00
## TODO: if install dev package really happens, rebuild the depending project
## Arguments from make command line
USERNAME=
PASSWORD_ENCRYPTED=
## Select bash for commands
SHELL := /bin/bash
## Capture all the files in SDK directories
MLNX-SDK-DEBS=$(notdir $(wildcard src/mlnx-sdk/*.deb))
BRCM-SDK-DEBS=$(notdir $(wildcard src/brcm-sdk/*.deb))
2016-09-25 23:48:25 -05:00
CAVM-SDK-DEBS=$(notdir $(wildcard src/cavm-sdk/*.deb))
2016-08-04 12:39:33 -05:00
## Function: build_docker, image_name save_file
## build a docker image and save to a file
define build_docker
docker build --no-cache -t $(1) dockers/$(1)
mkdir -p `dirname $(2)`
docker save $(1) | gzip -c > $(2)
endef
## Rules
2016-09-25 23:48:25 -05:00
.phony : brcm-all mlnx-all cavm-all
2016-08-04 12:39:33 -05:00
src/%:
$(MAKE) -C src $(subst src/,,$@)
dockers/docker-fpm/deps/fpmsyncd: src/fpmsyncd
mkdir -p `dirname $@` && cp $< $@
dockers/docker-fpm/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $@
dockers/docker-orchagent-mlnx/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $@
dockers/docker-orchagent-mlnx/deps/%: src/mlnx/%
mkdir -p `dirname $@` && cp $< $@
dockers/docker-orchagent/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $@
dockers/docker-orchagent/deps/%: src/brcm/%
mkdir -p `dirname $@` && cp $< $@
2016-09-25 23:48:25 -05:00
dockers/docker-orchagent-cavm/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $@
dockers/docker-orchagent-cavm/deps/%: src/cavm/%
mkdir -p `dirname $@` && cp $< $@
2016-08-04 12:39:33 -05:00
dockers/docker-%-mlnx/deps/syncd_1.0.0_amd64.deb: src/mlnx/syncd_1.0.0_amd64.deb
mkdir -p `dirname $@` && cp $< $@
dockers/docker-%/deps/syncd_1.0.0_amd64.deb: src/brcm/syncd_1.0.0_amd64.deb
mkdir -p `dirname $@` && cp $< $@
2016-09-25 23:48:25 -05:00
dockers/docker-%-cavm/deps/syncd_1.0.0_amd64.deb: src/cavm/syncd_1.0.0_amd64.deb
mkdir -p `dirname $@` && cp $< $@
2016-08-04 12:39:33 -05:00
dockers/docker-%-mlnx/deps/libsairedis_1.0.0_amd64.deb: src/mlnx/syncd_1.0.0_amd64.deb
mkdir -p `dirname $@` && cp $< $@
dockers/docker-%/deps/libsairedis_1.0.0_amd64.deb: src/brcm/syncd_1.0.0_amd64.deb
mkdir -p `dirname $@` && cp $< $@
2016-09-25 23:48:25 -05:00
dockers/docker-%-cavm/deps/libsairedis_1.0.0_amd64.deb: src/cavm/libsairedis_1.0.0_amd64.deb
mkdir -p `dirname $@` && cp $< $@
2016-08-04 12:39:33 -05:00
$(addprefix dockers/docker-syncd-mlnx/deps/,$(MLNX-SDK-DEBS)) : dockers/docker-syncd-mlnx/deps/%.deb : src/mlnx-sdk/%.deb
mkdir -p `dirname $@` && cp $< $@
$(addprefix dockers/docker-syncd/deps/,$(BRCM-SDK-DEBS)) : dockers/docker-syncd/deps/%.deb : src/brcm-sdk/%.deb
mkdir -p `dirname $@` && cp $< $@
2016-09-25 23:48:25 -05:00
$(addprefix dockers/docker-syncd-cavm/deps/,$(CAVM-SDK-DEBS)) : dockers/docker-syncd-cavm/deps/%.deb : src/cavm-sdk/%.deb
mkdir -p `dirname $@` && cp $< $@
2016-08-04 12:39:33 -05:00
dockers/docker-syncd-mlnx/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $@
dockers/docker-syncd/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $@
2016-09-25 23:48:25 -05:00
dockers/docker-syncd-cavm/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $@
2016-08-04 12:39:33 -05:00
deps/linux-image-3.16.0-4-amd64_%.deb: src/sonic-linux-kernel/linux-image-3.16.0-4-amd64_%.deb
mkdir -p `dirname $@` && cp $< $@
deps/initramfs-tools_%.deb: src/initramfs-tools/initramfs-tools_%.deb
mkdir -p `dirname $@` && cp $< $@
target/docker-base.gz:
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
target/docker-syncd.gz: target/docker-base.gz $(addprefix dockers/docker-syncd/deps/,$(BRCM-SDK-DEBS) libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb syncd_1.0.0_amd64.deb)
## TODO: remove placeholders for the dependencies
touch dockers/docker-syncd/deps/{dsserve,bcmcmd}
docker load < $<
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
target/docker-syncd-mlnx.gz: target/docker-base.gz $(addprefix dockers/docker-syncd-mlnx/deps/,$(MLNX-SDK-DEBS) applibs_1.mlnx.4.2.2100_amd64.deb libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb syncd_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb)
docker load < $<
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
2016-09-25 23:48:25 -05:00
target/docker-syncd-cavm.gz: target/docker-base.gz $(addprefix dockers/docker-syncd-cavm/deps/,$(CAVM-SDK-DEBS) libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb syncd_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb)
docker load < $<
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
2016-08-04 12:39:33 -05:00
target/docker-orchagent.gz: target/docker-base.gz $(addprefix dockers/docker-orchagent/deps/,libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb swss_1.0.0_amd64.deb)
2016-08-04 12:39:33 -05:00
docker load < $<
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
target/docker-orchagent-mlnx.gz: target/docker-base.gz $(addprefix dockers/docker-orchagent-mlnx/deps/,libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb swss_1.0.0_amd64.deb)
2016-08-04 12:39:33 -05:00
docker load < $<
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
2016-09-25 23:48:25 -05:00
target/docker-orchagent-cavm.gz: target/docker-base.gz $(addprefix dockers/docker-orchagent-cavm/deps/,libhiredis0.13_0.13.3-2_amd64.deb libswsscommon_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb orchagent swssconfig portsyncd intfsyncd neighsyncd)
docker load < $<
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
2016-08-04 12:39:33 -05:00
target/docker-fpm.gz: target/docker-base.gz $(addprefix dockers/docker-fpm/deps/,libswsscommon_1.0.0_amd64.deb libhiredis0.13_0.13.3-2_amd64.deb quagga_0.99.24.1-2_amd64.deb fpmsyncd)
docker load < $<
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
target/docker-database.gz: target/docker-base.gz
docker load < $<
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
2016-08-04 12:39:33 -05:00
target/sonic-generic.bin: deps/linux-image-3.16.0-4-amd64_3.16.7-ckt11-2+acs8u2_amd64.deb deps/initramfs-tools_0.120_all.deb
2016-08-04 12:39:33 -05:00
./build_debian.sh "$(USERNAME)" "$(PASSWORD_ENCRYPTED)" && TARGET_MACHINE=generic ./build_image.sh
target/sonic-aboot.bin: deps/linux-image-3.16.0-4-amd64_3.16.7-ckt11-2+acs8u2_amd64.deb deps/initramfs-tools_0.120_all.deb
2016-08-04 12:39:33 -05:00
./build_debian.sh "$(USERNAME)" "$(PASSWORD_ENCRYPTED)" && TARGET_MACHINE=aboot ./build_image.sh
## Note: docker-fpm.gz must be the last to build the implicit dependency fpmsyncd
brcm-all: target/sonic-generic.bin $(addprefix target/,docker-syncd.gz docker-orchagent.gz docker-fpm.gz docker-database.gz)
2016-08-04 12:39:33 -05:00
## Note: docker-fpm.gz must be the last to build the implicit dependency fpmsyncd
mlnx-all: target/sonic-generic.bin $(addprefix target/,docker-syncd-mlnx.gz docker-orchagent-mlnx.gz docker-fpm.gz docker-database.gz)
2016-09-25 23:48:25 -05:00
## Note: docker-fpm.gz must be the last to build the implicit dependency fpmsyncd
cavm-all: $(addprefix target/,docker-syncd-cavm.gz docker-orchagent-cavm.gz docker-fpm.gz docker-database.gz)