source: research/2008-displacement/Makefile @ 2763

Last change on this file since 2763 was 2286, checked in by Sam Hocevar, 12 years ago
  • More scripts for part 3.
  • Implemented main.c as a seccomp bytecode for CPUShare.
File size: 1.9 KB
Line 
1ifeq ($(shell uname -m), x86_64)
2ifeq ($(shell [ -d /lib64 ] && echo 64), 64)
3CFLAGS = -m32 -march=i686 -mcpu=pentium4 -fomit-frame-pointer
4CPPFLAGS = -m32
5LDFLAGS = -melf_i386
6endif
7else # ! x86_64
8
9ifeq ($(shell uname -m), i686)
10CFLAGS = -march=i686 -mcpu=i686 -fomit-frame-pointer
11CPPFLAGS = -m32
12LDFLAGS = -melf_i386
13else # ! i686
14
15ifeq ($(shell uname -m), ppc64)
16# mcpu means march and mtune means mcpu, oh well
17CFLAGS = -m32 -mcpu=750 -mtune=970
18CPPFLAGS = -m32
19LDFLAGS = -melf32ppclinux
20else # ! ppc64
21
22ifeq ($(shell uname -m), ppc)
23# mcpu means march and mtune means mcpu, oh well
24CFLAGS = -mcpu=750 -mtune=970
25CPPFLAGS = -m32
26LDFLAGS = -melf32ppclinux
27endif # ppc
28
29endif # ppc64
30endif # i686
31endif # x86_64
32
33CFLAGS += -fno-common -O2 -Wall -Iglibc -I.
34CPPFLAGS += -Iglibc -I.
35LDFLAGS += -O2
36
37CC = $(CROSS_COMPILE)gcc
38CPP = $(CROSS_COMPILE)cpp
39LD = $(CROSS_COMPILE)ld
40
41OBJCOPY = $(CROSS_COMPILE)objcopy
42
43LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
44LIBGCCEH = $(shell $(CC) $(CFLAGS) -print-file-name=libgcc_eh.a)
45LIBM = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
46LIBC = $(shell $(CC) $(CFLAGS) -print-file-name=libc.a)
47
48all: bytecode.text.bin bytecode.data.bin main xy2d vote
49
50bytecode.o: main.c
51        $(CC) -DBYTECODE -c $(CFLAGS) $< -o $@
52
53bytecode.lds.s: bytecode.lds.S
54        $(CPP) $(CPPFLAGS) $< -o $@
55
56bytecode.lds: bytecode.lds.s
57        grep -A100000000 SECTION $< > $@
58
59bytecode: bytecode.o bytecode.lds
60        $(LD) $(LDFLAGS) -static -T bytecode.lds $< --start-group $(LIBGCC) $(LIBC) $(LIBM) $(LIBGCCEH) --end-group -o $@
61
62bytecode.text.bin: bytecode
63        $(OBJCOPY) -O binary $< -j .text $@
64
65bytecode.data.bin: bytecode
66        $(OBJCOPY) -O binary $< -j .data $@
67
68clean:
69        rm -f bytecode bytecode.lds bytecode.lds.s
70        rm -f xy2d vote main
71        rm -f *.pyc *.bin *.o
72
73xy2d: xy2d.c
74        $(CC) -W -Wall $^ -o $@
75
76vote: vote.c
77        $(CC) -W -Wall $^ -o $@
78
79main: main.c
80        $(CC) -Wall -O3 -funroll-loops -ffast-math -W -Wall $^ -o $@ $$(pkg-config --cflags --libs sdl) -lSDL_image -lm
81
82.PHONY: clean
Note: See TracBrowser for help on using the repository browser.