|
1 | | -TARGET := dphp-linux-* |
2 | | -BIN_PATH := ../bin |
3 | | -DOCKER_IMAGE := builder |
4 | | -DOCKER_TARGET := cli-base-alpine |
5 | | -BUILD_PATH := /go/src/app/cli/dist |
| 1 | +# Variables |
| 2 | +PHP_INCLUDES := $(shell php-config --includes) |
| 3 | +PHP_LDFLAGS := $(shell php-config --ldflags) |
| 4 | +PHP_LIBS := $(shell php-config --libs) |
6 | 5 |
|
7 | | -${BIN_PATH}/${TARGET}: cli.go */* go.mod build.sh build-php.sh ../Dockerfile |
8 | | - mkdir -p ${BIN_PATH} |
9 | | - cd .. && docker buildx build --pull --load --target ${DOCKER_TARGET} -t ${DOCKER_IMAGE} . |
10 | | - docker create --name ${DOCKER_IMAGE} ${DOCKER_IMAGE} || ( docker rm -f ${DOCKER_IMAGE} && false ) |
11 | | - docker cp ${DOCKER_IMAGE}:${BUILD_PATH}/dphp ${BIN_PATH}/ || ( docker rm -f ${DOCKER_IMAGE} && false ) |
12 | | - docker rm -f ${DOCKER_IMAGE} |
13 | | - upx -9 --force-pie ../bin/dphp-* |
| 6 | +XCADDY_FLAGS := -ldflags='-w -s' -tags=nobadger,nomysql,nopgx,nodphp,nobrotli |
14 | 7 |
|
15 | | -../dist: ${BIN_PATH}/${TARGET} |
16 | | - docker create --name builder builder |
17 | | - docker cp ${DOCKER_IMAGE}:${BUILD_PATH} ../dist |
| 8 | +LOCAL_MODULE := /home/withinboredom/code/durable-php/cli |
| 9 | + |
| 10 | +# Targets |
| 11 | +frankenphp: ext/build/ext.go |
| 12 | + CGO_ENABLED=1 \ |
| 13 | + XCADDY_GO_BUILD_FLAGS="$(XCADDY_FLAGS)" \ |
| 14 | + CGO_CFLAGS="$(PHP_INCLUDES)" \ |
| 15 | + CGO_LDFLAGS="$(PHP_LDFLAGS) $(PHP_LIBS)" \ |
| 16 | + xcaddy build \ |
| 17 | + --output frankenphp \ |
| 18 | + --with github.com/dunglas/frankenphp/caddy \ |
| 19 | + --with github.com/bottledcode/durable-php/cli=$(LOCAL_MODULE) |
| 20 | + |
| 21 | +ext/build/ext.go: ext/ext.go |
| 22 | + GEN_STUB_SCRIPT=/home/withinboredom/code/php-src/build/gen_stub.php \ |
| 23 | + frankenphp extension-init ext/ext.go |
| 24 | + |
| 25 | +.PHONY: frankenphp |
0 commit comments