Created
April 19, 2019 13:17
-
-
Save kevincharm/9377cf8374edf8413403fa8290e5d1d9 to your computer and use it in GitHub Desktop.
Base Makefile for cross compilation with Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: run | |
# Host rules | |
DOCKER_IMAGE=kevincharm/linux-x86_64-gcc-gdb:8 | |
WORK_DIR=$$(basename `pwd`) | |
ROOT_DIR=`pwd`/.. | |
DOCKER_SH=docker run -it --rm \ | |
-v $(ROOT_DIR):/work -w /work/$(WORK_DIR) \ | |
--security-opt seccomp=unconfined \ | |
$(DOCKER_IMAGE) /bin/bash -c | |
build: | |
$(DOCKER_SH) "make _build" | |
run: | |
$(DOCKER_SH) "make _run" | |
debug: | |
$(DOCKER_SH) "make _debug" | |
login: | |
docker run -it --rm -v $(ROOT_DIR):/work -w /work/$(WORK_DIR) --security-opt seccomp=unconfined $(DOCKER_IMAGE) /bin/bash | |
# Container rules | |
CC=gcc | |
%.o: %.s | |
$(CC) $< -o $@ | |
_build: $(SRC_FILES) | |
$(CC) -o $(OUT) $(SRC_FILES) | |
chmod a+x $(OUT) | |
_build-debug: $(SRC_FILES) | |
$(CC) -no-pie -g -o $(OUT) $(SRC_FILES) | |
chmod a+x $(OUT) | |
_run: _build | |
$(OUT) | |
_debug: _build-debug | |
gdb $(OUT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment