Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Makefile): support submodules #126

Merged
merged 5 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dae
outline.json
go-mod/
node_modules/
.gitmodules.d.mk
28 changes: 26 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,35 @@ else
VERSION ?= unstable-$(date).r$(count).$(commit)
endif

.PHONY: clean-ebpf ebpf dae
.PHONY: clean-ebpf ebpf dae submodule submodules

## Begin Dae Build
dae: export GOOS=linux
dae: ebpf
go build -o $(OUTPUT) -trimpath -ldflags "-s -w -X github.com/daeuniverse/dae/cmd.Version=$(VERSION) -X github.com/daeuniverse/dae/common/consts.MaxMatchSetLen_=$(MAX_MATCH_SET_LEN)" .
## End Dae Build

## Begin Git Submodules
.gitmodules.d.mk: .gitmodules
@set -e -o pipefail && \
submodules=( $$(grep '\[submodule "' .gitmodules | cut -d'"' -f2) ) && \
echo "submodule_paths=$${submodules[@]}" > $@

-include .gitmodules.d.mk

$(submodule_paths): .gitmodules.d.mk
git submodule update --init --recursive -- $@ && \
touch $@

submodule submodules: $(submodule_paths)
@if [ -z "$(submodule_paths)" ]; then \
rm -f .gitmodules.mk; \
echo "Failed to generate submodules list. Please try again."; \
exit 1; \
fi
## End Git Submodules

## Begin Ebpf
clean-ebpf:
@rm -f control/bpf_bpf*.go && \
rm -f control/bpf_bpf*.o
Expand All @@ -53,9 +76,10 @@ ebpf: export BPF_CLANG := $(CLANG)
ebpf: export BPF_STRIP_FLAG := $(STRIP_FLAG)
ebpf: export BPF_CFLAGS := $(CFLAGS)
ebpf: export BPF_TARGET := $(TARGET)
ebpf: clean-ebpf
ebpf: submodule clean-ebpf
@unset GOOS && \
unset GOARCH && \
unset GOARM && \
echo $(STRIP_FLAG) && \
go generate ./control/control.go
## End Ebpf