Skip to content

Commit

Permalink
helpers: Improve Makefile to support isolated build envs
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Mar 7, 2024
1 parent e82c1ac commit 69d3634
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/linux/helpers/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
FRIDA_MONOREPO ?= ../../../..
top_srcdir := ../../..
releng := $(top_srcdir)/releng

BUILDDIR ?= $(top_srcdir)/build
FRIDA_MONOREPO ?= $(top_srcdir)/..

ifdef FRIDA_HOST
host_os := $(shell echo $(FRIDA_HOST) | cut -f1 -d"-")
host_arch := $(shell echo $(FRIDA_HOST) | cut -f2 -d"-")
else
host_os := $(shell $(FRIDA_MONOREPO)/releng/detect-os.sh)
host_arch := $(shell $(FRIDA_MONOREPO)/releng/detect-arch.sh)
host_os := $(shell $(releng)/detect-os.sh)
host_arch := $(shell $(releng)/detect-arch.sh)
endif

build: $(FRIDA_MONOREPO)/build/frida*-$(host_os)-$(host_arch).txt ext/linux/tools/include/nolibc/nolibc.h
crossfile := $(shell test -d "$(BUILDDIR)" \
&& echo "$(BUILDDIR)/frida-$(host_os)-$(host_arch).txt" \
|| echo $(FRIDA_MONOREPO)/build/frida*-$(host_os)-$(host_arch).txt)

build: ext/linux/tools/include/nolibc/nolibc.h
rm -rf build
meson setup --cross-file $< -Db_lto=true build
meson setup --cross-file $(crossfile) -Db_lto=true build
meson compile -C build
cp build/bootstrapper.bin bootstrapper-$(host_arch).bin
cp build/loader.bin loader-$(host_arch).bin
Expand Down

0 comments on commit 69d3634

Please sign in to comment.