sonic-buildimage/Makefile

162 lines
9.2 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
2016-09-27 13:42:35 -05:00
LIBNL-DEBS=libnl-3-200_3.2.27-1_amd64.deb libnl-genl-3-200_3.2.27-1_amd64.deb libnl-route-3-200_3.2.27-1_amd64.deb
LIBTEAM-DEBS=libteam5_1.26-1_amd64.deb libteam-dev_1.26-1_amd64.deb libteam-utils_1.26-1_amd64.deb libteamdctl0_1.26-1_amd64.deb
2016-09-27 13:42:35 -05:00
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
2016-09-27 13:42:35 -05:00
## Rules: phony targets
.phony : brcm-all mlnx-all cavm-all p4-all
2016-08-04 12:39:33 -05:00
2016-09-27 13:42:35 -05:00
## Rules: redirect to sub directory
2016-08-04 12:39:33 -05:00
src/%:
$(MAKE) -C src $(subst src/,,$@)
2016-09-27 13:42:35 -05:00
## Rules: docker-fpm
2016-08-04 12:39:33 -05:00
dockers/docker-fpm/deps/fpmsyncd: src/fpmsyncd
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-08-04 12:39:33 -05:00
dockers/docker-fpm/deps/%.deb: src/%.deb
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
## Rules: docker-team
dockers/docker-team/deps/teamsyncd: src/teamsyncd
mkdir -p `dirname $@` && cp $< $(dir $@)
dockers/docker-team/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-08-04 12:39:33 -05:00
2016-09-27 13:42:35 -05:00
## Rules: docker-orchagent-mlnx
$(addprefix dockers/docker-orchagent-mlnx/deps/,libsairedis_1.0.0_amd64.deb libsaimetadata_1.0.0_amd64.deb swss_1.0.0_amd64.deb) : dockers/docker-orchagent-mlnx/deps/%.deb : src/mlnx/%.deb
2016-09-27 19:25:48 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-08-04 12:39:33 -05:00
dockers/docker-orchagent-mlnx/deps/%.deb: src/%.deb
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-08-04 12:39:33 -05:00
2016-09-27 13:42:35 -05:00
## Rules: docker-orchagent-cavm
$(addprefix dockers/docker-orchagent-cavm/deps/,libsairedis_1.0.0_amd64.deb libsaimetadata_1.0.0_amd64.deb swss_1.0.0_amd64.deb) : dockers/docker-orchagent-cavm/deps/%.deb : src/cavm/%.deb
2016-09-27 19:25:48 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-09-25 23:48:25 -05:00
dockers/docker-orchagent-cavm/deps/%.deb: src/%.deb
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-09-25 23:48:25 -05:00
2016-09-27 13:42:35 -05:00
## Rules: docker-orchagent (brcm)
$(addprefix dockers/docker-orchagent/deps/,libsairedis_1.0.0_amd64.deb libsaimetadata_1.0.0_amd64.deb swss_1.0.0_amd64.deb) : dockers/docker-orchagent/deps/%.deb : src/%.deb
2016-09-27 19:25:48 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-09-27 13:42:35 -05:00
dockers/docker-orchagent/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-08-04 12:39:33 -05:00
2016-09-27 13:42:35 -05:00
## Rules: docker-syncd-mlnx
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
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
$(addprefix dockers/docker-syncd-mlnx/deps/,syncd_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb libsaimetadata_1.0.0_amd64.deb) : dockers/docker-syncd-mlnx/deps/%.deb : src/mlnx/%.deb
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-08-04 12:39:33 -05:00
dockers/docker-syncd-mlnx/deps/%.deb: src/%.deb
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
dockers/docker-syncd-mlnx/deps/fw-SPC.mfa: src/mlnx-sdk/fw-SPC.mfa
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-09-27 13:42:35 -05:00
## Rules: docker-syncd-cavm
$(addprefix dockers/docker-syncd-cavm/deps/,$(CAVM-SDK-DEBS)) : dockers/docker-syncd-cavm/deps/%.deb : src/cavm-sdk/%.deb
mkdir -p `dirname $@` && cp $< $(dir $@)
$(addprefix dockers/docker-syncd-cavm/deps/,syncd_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb libsaimetadata_1.0.0_amd64.deb) : dockers/docker-syncd-cavm/deps/%.deb : src/cavm/%.deb
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-09-25 23:48:25 -05:00
dockers/docker-syncd-cavm/deps/%.deb: src/%.deb
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-08-04 12:39:33 -05:00
2016-09-27 13:42:35 -05:00
## Rules: docker-syncd (brcm)
$(addprefix dockers/docker-syncd/deps/,$(BRCM-SDK-DEBS)) : dockers/docker-syncd/deps/%.deb : src/brcm-sdk/%.deb
mkdir -p `dirname $@` && cp $< $(dir $@)
$(addprefix dockers/docker-syncd/deps/,syncd_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb libsaimetadata_1.0.0_amd64.deb): dockers/docker-syncd/deps/%.deb : src/brcm/%.deb
2016-09-27 13:42:35 -05:00
mkdir -p `dirname $@` && cp $< $(dir $@)
dockers/docker-syncd/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-08-04 12:39:33 -05:00
## Rules: docker-sonic (p4)
$(addprefix dockers/docker-sonic-p4/deps/,swss_1.0.0_amd64.deb syncd_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb libsaimetadata_1.0.0_amd64.deb) : dockers/docker-sonic-p4/deps/%.deb : src/p4/%.deb
mkdir -p `dirname $@` && cp $< $(dir $@)
dockers/docker-sonic-p4/deps/%.deb: src/%.deb
mkdir -p `dirname $@` && cp $< $(dir $@)
2016-09-27 13:42:35 -05:00
## Rules: docker images
2016-08-04 12:39:33 -05:00
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 libsaimetadata_1.0.0_amd64.deb $(LIBNL-DEBS))
2016-08-04 12:39:33 -05:00
## 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 libsaimetadata_1.0.0_amd64.deb $(LIBNL-DEBS)) dockers/docker-syncd-mlnx/deps/fw-SPC.mfa
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-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 libsaimetadata_1.0.0_amd64.deb $(LIBNL-DEBS))
2016-09-25 23:48:25 -05:00
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 libsaimetadata_1.0.0_amd64.deb swss_1.0.0_amd64.deb $(LIBNL-DEBS) $(LIBTEAM-DEBS))
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 libsaimetadata_1.0.0_amd64.deb swss_1.0.0_amd64.deb $(LIBNL-DEBS) $(LIBTEAM-DEBS))
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 libsaimetadata_1.0.0_amd64.deb swss_1.0.0_amd64.deb $(LIBNL-DEBS) $(LIBTEAM-DEBS))
2016-09-25 23:48:25 -05:00
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-team.gz: target/docker-base.gz $(addprefix dockers/docker-team/deps/,libswsscommon_1.0.0_amd64.deb libhiredis0.13_0.13.3-2_amd64.deb $(LIBTEAM-DEBS))
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/docker-sonic-p4.gz: target/docker-base.gz $(addprefix dockers/docker-sonic-p4/deps/,libswsscommon_1.0.0_amd64.deb libhiredis0.13_0.13.3-2_amd64.deb quagga_0.99.24.1-2_amd64.deb syncd_1.0.0_amd64.deb swss_1.0.0_amd64.deb libsairedis_1.0.0_amd64.deb libsaimetadata_1.0.0_amd64.deb libthrift-0.9.3_0.9.3-2_amd64.deb redis-server_3.0.7-2_amd64.deb redis-tools_3.0.7-2_amd64.deb p4-bmv2_1.0.0_amd64.deb p4-switch_1.0.0_amd64.deb)
docker load < $<
$(call build_docker,$(patsubst target/%.gz,%,$@),$@)
2016-09-27 13:42:35 -05:00
## Rules: linux image content
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 $< $(dir $@)
deps/initramfs-tools_%.deb: src/initramfs-tools/initramfs-tools_%.deb
mkdir -p `dirname $@` && cp $< $(dir $@)
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-team.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-team.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: target/sonic-generic.bin $(addprefix target/,docker-syncd-cavm.gz docker-orchagent-cavm.gz docker-fpm.gz docker-team.gz docker-database.gz)
p4-all: $(addprefix target/,docker-sonic-p4.gz)