forked from docker-library/hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
28 lines (23 loc) · 836 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
TARGET_ARCH := amd64
C_TARGETS := $(addsuffix hello, $(wildcard $(TARGET_ARCH)/*/))
CC := gcc
CFLAGS := -static -Os -nostartfiles -fno-asynchronous-unwind-tables
STRIP := strip
.PHONY: all
all: $(C_TARGETS)
$(C_TARGETS): hello.c
$(CC) $(CFLAGS) -o '$@' -D DOCKER_IMAGE='"$(notdir $(@D))"' -D DOCKER_GREETING="\"$$(cat 'greetings/$(notdir $(@D)).txt')\"" '$<'
$(STRIP) -R .comment -s '$@'
@if [ '$(TARGET_ARCH)' = 'amd64' ]; then \
mkdir -p '$(@D)/nanoserver'; \
'$@' | sed -e 's/an Ubuntu container/a Nano Server container/g' -e 's!ubuntu bash!microsoft/nanoserver powershell!g' > '$(@D)/nanoserver/hello.txt'; \
fi
.PHONY: clean
clean:
-rm -vrf $(C_TARGETS)
.PHONY: test
test: $(C_TARGETS)
@for b in $^; do \
( set -x && "./$$b" ); \
( set -x && "./$$b" | grep -q '"'"$$(basename "$$(dirname "$$b")")"'"' ); \
done