25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

83 lines
1.9 KiB

  1. ifeq ($(shell uname -m), x86_64)
  2. ifeq ($(shell [ -d /lib64 ] && echo 64), 64)
  3. CFLAGS = -m32 -march=i686 -mcpu=pentium4 -fomit-frame-pointer
  4. CPPFLAGS = -m32
  5. LDFLAGS = -melf_i386
  6. endif
  7. else # ! x86_64
  8. ifeq ($(shell uname -m), i686)
  9. CFLAGS = -march=i686 -mcpu=i686 -fomit-frame-pointer
  10. CPPFLAGS = -m32
  11. LDFLAGS = -melf_i386
  12. else # ! i686
  13. ifeq ($(shell uname -m), ppc64)
  14. # mcpu means march and mtune means mcpu, oh well
  15. CFLAGS = -m32 -mcpu=750 -mtune=970
  16. CPPFLAGS = -m32
  17. LDFLAGS = -melf32ppclinux
  18. else # ! ppc64
  19. ifeq ($(shell uname -m), ppc)
  20. # mcpu means march and mtune means mcpu, oh well
  21. CFLAGS = -mcpu=750 -mtune=970
  22. CPPFLAGS = -m32
  23. LDFLAGS = -melf32ppclinux
  24. endif # ppc
  25. endif # ppc64
  26. endif # i686
  27. endif # x86_64
  28. CFLAGS += -fno-common -O2 -Wall -Iglibc -I.
  29. CPPFLAGS += -Iglibc -I.
  30. LDFLAGS += -O2
  31. CC = $(CROSS_COMPILE)gcc
  32. CPP = $(CROSS_COMPILE)cpp
  33. LD = $(CROSS_COMPILE)ld
  34. OBJCOPY = $(CROSS_COMPILE)objcopy
  35. LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
  36. LIBGCCEH = $(shell $(CC) $(CFLAGS) -print-file-name=libgcc_eh.a)
  37. LIBM = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
  38. LIBC = $(shell $(CC) $(CFLAGS) -print-file-name=libc.a)
  39. all: bytecode.text.bin bytecode.data.bin main xy2d vote
  40. bytecode.o: main.c
  41. $(CC) -DBYTECODE -c $(CFLAGS) $< -o $@
  42. bytecode.lds.s: bytecode.lds.S
  43. $(CPP) $(CPPFLAGS) $< -o $@
  44. bytecode.lds: bytecode.lds.s
  45. grep -A100000000 SECTION $< > $@
  46. bytecode: bytecode.o bytecode.lds
  47. $(LD) $(LDFLAGS) -static -T bytecode.lds $< --start-group $(LIBGCC) $(LIBC) $(LIBM) $(LIBGCCEH) --end-group -o $@
  48. bytecode.text.bin: bytecode
  49. $(OBJCOPY) -O binary $< -j .text $@
  50. bytecode.data.bin: bytecode
  51. $(OBJCOPY) -O binary $< -j .data $@
  52. clean:
  53. rm -f bytecode bytecode.lds bytecode.lds.s
  54. rm -f xy2d vote main
  55. rm -f *.pyc *.bin *.o
  56. xy2d: xy2d.c
  57. $(CC) -W -Wall $^ -o $@
  58. vote: vote.c
  59. $(CC) -W -Wall $^ -o $@
  60. main: main.c
  61. $(CC) -Wall -O3 -funroll-loops -ffast-math -W -Wall $^ -o $@ $$(pkg-config --cflags --libs sdl) -lSDL_image -lm
  62. .PHONY: clean