|
- ifeq ($(shell uname -m), x86_64)
- ifeq ($(shell [ -d /lib64 ] && echo 64), 64)
- CFLAGS = -m32 -march=i686 -mcpu=pentium4 -fomit-frame-pointer
- CPPFLAGS = -m32
- LDFLAGS = -melf_i386
- endif
- else # ! x86_64
-
- ifeq ($(shell uname -m), i686)
- CFLAGS = -march=i686 -mcpu=i686 -fomit-frame-pointer
- CPPFLAGS = -m32
- LDFLAGS = -melf_i386
- else # ! i686
-
- ifeq ($(shell uname -m), ppc64)
- # mcpu means march and mtune means mcpu, oh well
- CFLAGS = -m32 -mcpu=750 -mtune=970
- CPPFLAGS = -m32
- LDFLAGS = -melf32ppclinux
- else # ! ppc64
-
- ifeq ($(shell uname -m), ppc)
- # mcpu means march and mtune means mcpu, oh well
- CFLAGS = -mcpu=750 -mtune=970
- CPPFLAGS = -m32
- LDFLAGS = -melf32ppclinux
- endif # ppc
-
- endif # ppc64
- endif # i686
- endif # x86_64
-
- CFLAGS += -fno-common -O2 -Wall -Iglibc -I.
- CPPFLAGS += -Iglibc -I.
- LDFLAGS += -O2
-
- CC = $(CROSS_COMPILE)gcc
- CPP = $(CROSS_COMPILE)cpp
- LD = $(CROSS_COMPILE)ld
-
- OBJCOPY = $(CROSS_COMPILE)objcopy
-
- LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
- LIBGCCEH = $(shell $(CC) $(CFLAGS) -print-file-name=libgcc_eh.a)
- LIBM = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
- LIBC = $(shell $(CC) $(CFLAGS) -print-file-name=libc.a)
-
- all: bytecode.text.bin bytecode.data.bin main xy2d vote
-
- bytecode.o: main.c
- $(CC) -DBYTECODE -c $(CFLAGS) $< -o $@
-
- bytecode.lds.s: bytecode.lds.S
- $(CPP) $(CPPFLAGS) $< -o $@
-
- bytecode.lds: bytecode.lds.s
- grep -A100000000 SECTION $< > $@
-
- bytecode: bytecode.o bytecode.lds
- $(LD) $(LDFLAGS) -static -T bytecode.lds $< --start-group $(LIBGCC) $(LIBC) $(LIBM) $(LIBGCCEH) --end-group -o $@
-
- bytecode.text.bin: bytecode
- $(OBJCOPY) -O binary $< -j .text $@
-
- bytecode.data.bin: bytecode
- $(OBJCOPY) -O binary $< -j .data $@
-
- clean:
- rm -f bytecode bytecode.lds bytecode.lds.s
- rm -f xy2d vote main
- rm -f *.pyc *.bin *.o
-
- xy2d: xy2d.c
- $(CC) -W -Wall $^ -o $@
-
- vote: vote.c
- $(CC) -W -Wall $^ -o $@
-
- main: main.c
- $(CC) -Wall -O3 -funroll-loops -ffast-math -W -Wall $^ -o $@ $$(pkg-config --cflags --libs sdl) -lSDL_image -lm
-
- .PHONY: clean
|