Compare commits
No commits in common. "49535cb998d9bec44b078f0af7d8299f9a3184d1" and "2365171e8e07cd5f9569586ba605fe48efd68d08" have entirely different histories.
49535cb998
...
2365171e8e
108
Makefile
108
Makefile
@ -1,111 +1,44 @@
|
||||
CC = clang
|
||||
|
||||
SRC_DIR := src
|
||||
SRC := $(wildcard $(SRC_DIR)/*.c)
|
||||
SRC := $(SRC_DIR)/main.c
|
||||
|
||||
BUILD_DIR := build
|
||||
|
||||
ASSETS := assets
|
||||
TARGET := $(BUILD_DIR)/hello
|
||||
|
||||
INCLUDE := /usr/include/
|
||||
|
||||
CTOOLS := $(SRC_DIR)/ctools
|
||||
LIBFT_DIR := $(CTOOLS)/libft
|
||||
LIBFT := $(LIBFT_DIR)/lib/libft.a
|
||||
|
||||
LIB := $(LIBFT) $(LIBGPIOD)
|
||||
LIB := $(LIBFT)
|
||||
|
||||
TOOLCHAIN_DIR := $(HOME)/.local/toolchains
|
||||
TOOLCHAIN := $(TOOLCHAIN_DIR)/aarch64-linux-musl-cross
|
||||
TOOLCHAIN_BIN := $(TOOLCHAIN)/bin
|
||||
MUSL_LD := $(TOOLCHAIN_BIN)/aarch64-linux-musl-ld
|
||||
CC := $(TOOLCHAIN_BIN)/aarch64-linux-musl-gcc
|
||||
CFLAGS := -Wall -Wextra -Werror --target=arm-linux-gnueabihf
|
||||
|
||||
LIBGPIOD_INCLUDE := $(TOOLCHAIN)/include
|
||||
LIBGPIOD := $(TOOLCHAIN)/lib/libgpiod.a
|
||||
|
||||
CFLAGS := -Wall -Wextra -Werror -I$(LIBGPIOD_INCLUDE)
|
||||
|
||||
DOCKER_CMD := /bin/sh #-c 'hello "host.docker.internal" "8000"'
|
||||
DOCKER_CMD := /bin/sh -c 'hello "host.docker.internal" "8000"'
|
||||
|
||||
MINIROOTFS := $(ASSETS)/minirootfs.tar.gz
|
||||
|
||||
|
||||
LINKER_FLAGS := -L$(TOOLCHAIN)/lib -lgpiod
|
||||
|
||||
ALPINE := alpine
|
||||
ALPINE_KERNEL := alpine/boot/vmlinuz-rpi
|
||||
ALPINE_INITFRAM_FS := alpine/boot/initramfs-rpi
|
||||
ALPINE := alpine/
|
||||
ALPINE_BIN := $(ALPINE)/bin
|
||||
ALPINE_TAR := $(ASSETS)/alpine-rpi-aarch64.gz
|
||||
ALPINE_HEADLESS := $(ASSETS)/headless.apkovl.tar.gz
|
||||
|
||||
ALPINE_CUSTOM_IMG := $(BUILD_DIR)/alpine-custom.img
|
||||
get: $(ALPINE) $(ASSETS)
|
||||
wget https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/armhf/alpine-minirootfs-3.22.1-armhf.tar.gz -O $(MINIROOTFS)
|
||||
tar xvf $(MINIROOTFS) -C $^
|
||||
|
||||
PLATFORM := arm64
|
||||
QEMU_VM := qemu-system-aarch64
|
||||
QEMU_IMG := qemu-img
|
||||
|
||||
SSH_AUTH_KEYS := $(ALPINE)/authorized_keys
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(SRC) $(BUILD_DIR) $(LIB) $(LIBGPIOD)
|
||||
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LIB) $(LIBGPIOD)
|
||||
|
||||
get: $(ASSETS) $(ALPINE_TAR) $(ALPINE_HEADLESS)
|
||||
rm -rf $(ALPINE)/*
|
||||
tar xvf $(ALPINE_TAR) -C $(ALPINE)
|
||||
cp $(ALPINE_HEADLESS) $(ALPINE)
|
||||
|
||||
sync: $(TARGET)
|
||||
rsync -avz root@pi:/media/mmcblk0p1/ ./image
|
||||
rsync -avz ./build/* root@pi:/root/build/
|
||||
|
||||
img: get $(ALPINE) $(BUILD_DIR)
|
||||
$(QEMU_IMG) create -f raw $(ALPINE_CUSTOM_IMG) 512M
|
||||
mformat -i $(ALPINE_CUSTOM_IMG) -F ::
|
||||
mcopy -i $(ALPINE_CUSTOM_IMG) -s $(ALPINE)/* ::
|
||||
|
||||
$(SSH_AUTH_KEYS):
|
||||
cp ~/.ssh/authorized_keys $(ALPINE)
|
||||
|
||||
bootable: $(ALPINE) $(WPA_CONFIG) get
|
||||
tar czf $(MINIROOTFS) -C $(ALPINE) ./
|
||||
|
||||
$(ALPINE_HEADLESS):
|
||||
wget https://github.com/macmpi/alpine-linux-headless-bootstrap/raw/98728731299f262eab270941c522138d6c5cea73/headless.apkovl.tar.gz -O $(ALPINE_HEADLESS)
|
||||
|
||||
$(LIBGPIOD): $(TOOLCHAIN)
|
||||
rm -f $(LIBGPIOD)
|
||||
git clone https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git && \
|
||||
cd libgpiod && \
|
||||
export ac_cv_func_malloc_0_nonnull=yes && \
|
||||
export ac_cv_func_realloc_0_nonnull=yes && \
|
||||
./autogen.sh && \
|
||||
./configure --host=aarch64-linux-musl \
|
||||
--prefix=$(TOOLCHAIN) \
|
||||
--enable-tools=no \
|
||||
--enable-bindings-cxx=no \
|
||||
--disable-shared \
|
||||
--enable-static && \
|
||||
make && make install && \
|
||||
cd .. && \
|
||||
rm -rf libgpiod
|
||||
all: $(SRC) $(BUILD_DIR) $(LIB)
|
||||
$(CC) $(CFLAGS) -o $(TARGET) -static $(SRC) $(LIB)
|
||||
cp $(TARGET) $(ALPINE_BIN)
|
||||
tar czf $(MINIROOTFS) -C alpine ./
|
||||
docker import --platform linux/arm/v7 $(MINIROOTFS) alpine-custom:latest
|
||||
|
||||
|
||||
$(TOOLCHAIN): | $(TOOLCHAIN_DIR)
|
||||
wget https://musl.cc/aarch64-linux-musl-cross.tgz
|
||||
tar xvf aarch64-linux-musl-cross.tgz -C $(TOOLCHAIN_DIR)
|
||||
rm aarch64-linux-musl-cross.tgz
|
||||
|
||||
$(TOOLCHAIN_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(ALPINE_TAR):
|
||||
wget https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/aarch64/alpine-rpi-3.22.1-aarch64.tar.gz -O $(ALPINE_TAR)
|
||||
run: all
|
||||
docker run --add-host=host.docker.internal:host-gateway --platform linux/arm/v7 -it alpine-custom $(DOCKER_CMD)
|
||||
|
||||
$(LIB):
|
||||
make aarch64 -C $(LIBFT_DIR)
|
||||
make -C $(LIBFT_DIR)
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $@
|
||||
@ -117,7 +50,4 @@ $(ASSETS):
|
||||
mkdir -p $@
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) $(ALPINE) $(ASSETS)
|
||||
make fclean -C $(LIBFT_DIR)
|
||||
|
||||
.PHONY: sync
|
||||
rm -rf $(BUILD_DIR)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user