cosmopolitan/test/libc/release/test.mk
Justine Tunney da8a08fd58 Provide option to have APE not modify itself
This change introduces ape-no-modify-self.o to the amalgamated release
binaries, which may be used as an alternative to ape.o to make it easier
to use APE in cases where the self-modifying behavior isn't acceptable.

Please note that this alternative copying behavior isn't necessarily
better. It introduces a whole bunch of questions of its own, which are
documented in the ape.S source comment and should be considered by both
the program author as well as the end-user of programs linked this way.

For example, build environments that use read-only file systems and
would prefer to not have a launcher wrapper (like we use in our build)
can use ape-no-modify-self.o instead of ape.o and then set the $TMPDIR
environment variable to point to a sane read-write-exec location.

Fixes #146
See #82
2021-04-07 21:01:57 -07:00

152 lines
4.4 KiB
Makefile

#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
o/$(MODE)/test/libc/release/cosmopolitan.zip: \
o/cosmopolitan.h \
o/$(MODE)/ape/ape.lds \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape.o \
o/$(MODE)/ape/ape-no-modify-self.o \
o/$(MODE)/cosmopolitan.a
@$(COMPILE) -AZIP -T$@ zip -j $@ $^
o/$(MODE)/test/libc/release/smoke.com: \
o/$(MODE)/test/libc/release/smoke.com.dbg
@$(COMPILE) -AOBJCOPY -T$< $(OBJCOPY) -S -O binary $< $@
o/$(MODE)/test/libc/release/smoke.com.dbg: \
test/libc/release/smoke.c \
o/cosmopolitan.h \
o/$(MODE)/ape/ape.lds \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape.o \
o/$(MODE)/cosmopolitan.a
@$(COMPILE) -ACC $(CC) \
-o $@ \
-Os \
-static \
-no-pie \
-fno-pie \
-nostdlib \
-nostdinc \
-mno-red-zone \
-fno-omit-frame-pointer \
-Wl,-T,o/$(MODE)/ape/ape.lds \
-include o/cosmopolitan.h \
test/libc/release/smoke.c \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape.o \
o/$(MODE)/cosmopolitan.a
o/$(MODE)/test/libc/release/smoke-nms.com.dbg: \
test/libc/release/smoke.c \
o/cosmopolitan.h \
o/$(MODE)/ape/ape.lds \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape-no-modify-self.o \
o/$(MODE)/cosmopolitan.a
@$(COMPILE) -ACC $(CC) \
-o $@ \
-Os \
-static \
-no-pie \
-fno-pie \
-nostdlib \
-nostdinc \
-mno-red-zone \
-fno-omit-frame-pointer \
-Wl,-T,o/$(MODE)/ape/ape.lds \
-include o/cosmopolitan.h \
test/libc/release/smoke.c \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape-no-modify-self.o \
o/$(MODE)/cosmopolitan.a
o/$(MODE)/test/libc/release/smokecxx.com: \
o/$(MODE)/test/libc/release/smokecxx.com.dbg
@$(COMPILE) -AOBJCOPY -T$< $(OBJCOPY) -S -O binary $< $@
o/$(MODE)/test/libc/release/smokecxx.com.dbg: \
test/libc/release/smokecxx.cc \
o/cosmopolitan.h \
o/$(MODE)/ape/ape.lds \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape.o \
o/$(MODE)/cosmopolitan.a
@$(COMPILE) -ACXX $(CXX) \
-o $@ \
-Os \
-static \
-no-pie \
-fno-pie \
-nostdlib \
-nostdinc \
-mno-red-zone \
-fno-omit-frame-pointer \
-Wl,-T,o/$(MODE)/ape/ape.lds \
-include o/cosmopolitan.h \
test/libc/release/smokecxx.cc \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape.o \
o/$(MODE)/cosmopolitan.a
o/$(MODE)/test/libc/release/smokeansi.com.dbg: \
test/libc/release/smoke.c \
o/cosmopolitan.h \
o/$(MODE)/ape/ape.lds \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape.o \
o/$(MODE)/cosmopolitan.a
@$(COMPILE) -AANSI $(CC) \
-o $@ \
-Os \
-ansi \
-static \
-no-pie \
-fno-pie \
-nostdlib \
-nostdinc \
-mno-red-zone \
-fno-omit-frame-pointer \
-Wl,-T,o/$(MODE)/ape/ape.lds \
-include o/cosmopolitan.h \
test/libc/release/smoke.c \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape.o \
o/$(MODE)/cosmopolitan.a
o/$(MODE)/test/libc/release/clang.ok: \
test/libc/release/clang.sh \
test/libc/release/smoke.c \
o/cosmopolitan.h \
o/$(MODE)/ape/ape.lds \
o/$(MODE)/libc/crt/crt.o \
o/$(MODE)/ape/ape.o \
o/$(MODE)/cosmopolitan.a
@$(COMPILE) -ASHTEST -T$< $<
o/$(MODE)/test/libc/release/metal.ok: \
test/libc/release/metal.sh \
o/$(MODE)/examples/hello.com \
o/$(MODE)/tool/build/blinkenlights.com.dbg
@$(COMPILE) -ASHTEST -T$< $<
o/$(MODE)/test/libc/release/emulate.ok: \
test/libc/release/emulate.sh \
o/$(MODE)/examples/hello.com \
o/$(MODE)/tool/build/blinkenlights.com.dbg
@$(COMPILE) -ASHTEST -T$< $<
.PHONY: o/$(MODE)/test/libc/release
o/$(MODE)/test/libc/release: \
o/$(MODE)/test/libc/release/smoke.com \
o/$(MODE)/test/libc/release/smoke.com.runs \
o/$(MODE)/test/libc/release/smoke-nms.com \
o/$(MODE)/test/libc/release/smoke-nms.com.runs \
o/$(MODE)/test/libc/release/smokecxx.com \
o/$(MODE)/test/libc/release/smokecxx.com.runs \
o/$(MODE)/test/libc/release/smokeansi.com \
o/$(MODE)/test/libc/release/smokeansi.com.runs \
o/$(MODE)/test/libc/release/clang.ok \
o/$(MODE)/test/libc/release/emulate.ok \
o/$(MODE)/test/libc/release/metal.ok