-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Makefile
45 lines (36 loc) · 2.4 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
all: bestline_example bestline_multi
bestline_example: bestline.o example.o
$(CC) $(LDFLAGS) bestline.o example.o -o $@
bestline_multi: bestline.o multi.o
$(CC) $(LDFLAGS) bestline.o multi.o -o $@
bestline.o: bestline.c bestline.h Makefile
example.o: example.c bestline.h Makefile
multi.o: multi.c bestline.h Makefile
libbestline.so: bestline.c
$(CC) $(LDFLAGS) -fPIC -shared bestline.c -o $@
clean:
rm -f bestline_example bestline.o example.o bestline_example.com bestline_example.com.dbg multi.o bestline_multi libbestline.so
################################################################################
# compile on linux the demo as a binary that runs on seven operating systems
bestline_example.com: bestline_example.com.dbg
objcopy -S -O binary $< $@
bestline_example.com.dbg: bestline.c example.c crt.o ape.o ape.lds cosmopolitan.a cosmopolitan.h
gcc -g -Os -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc -fno-omit-frame-pointer -pg -mnop-mcount -o $@ bestline.c example.c -Wl,--gc-sections -fuse-ld=bfd -Wl,-T,ape.lds -include cosmopolitan.h crt.o ape.o cosmopolitan.a
bestline_multi.com: bestline_multi.com.dbg
objcopy -S -O binary $< $@
bestline_multi.com.dbg: bestline.c multi.c crt.o ape.o ape.lds cosmopolitan.a cosmopolitan.h
gcc -g -Os -static -fno-pie -no-pie -mno-red-zone -nostdlib -nostdinc -fno-omit-frame-pointer -pg -mnop-mcount -o $@ bestline.c example.c -Wl,--gc-sections -fuse-ld=bfd -Wl,-T,ape.lds -include cosmopolitan.h crt.o ape.o cosmopolitan.a
crt.o:; wget --compression=gzip https://justine.lol/cosmopolitan/crt.o
ape.o:; wget --compression=gzip https://justine.lol/cosmopolitan/ape.o
ape.lds:; wget --compression=gzip https://justine.lol/cosmopolitan/ape.lds
cosmopolitan.h:; wget --compression=gzip https://justine.lol/cosmopolitan/cosmopolitan.h
cosmopolitan.a:; wget --compression=gzip https://justine.lol/cosmopolitan/cosmopolitan.a
################################################################################
# make sure it compiles in weird environments
check:
gcc -c -Wall -Wextra -O3 -o /tmp/bestline.o bestline.c
g++ -xc++ -c -Wall -Wextra -O3 -o /tmp/bestline.o bestline.c
gcc -pedantic -std=c99 -c -Wall -Wextra -O3 -o /tmp/bestline.o bestline.c
clang -c -Wall -Wextra -Wall -Wextra -O3 -o /tmp/bestline.o bestline.c
clang++ -xc++ -c -Wall -Wextra -Wall -Wextra -O3 -o /tmp/bestline.o bestline.c
clang -pedantic -std=c99 -c -Wall -Wextra -O3 -o /tmp/bestline.o bestline.c