Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. VPATH = src
  2. ifndef DEBUG_FLAG
  3. CCBASEFLAGS=-O2 -Wall -Wno-unused-functions
  4. LDFLAGS=-s
  5. else
  6. CCBASEFLAGS=-g -Wall -Wno-switch -DDEBUGGING
  7. LDFLAGS=
  8. endif
  9. ifdef MINGW32
  10. ifeq (Cygwin,$(shell uname -o))
  11. CCBASEFLAGS += -mno-cygwin
  12. LDFLAGS += -mno-cygwin
  13. endif
  14. endif
  15. include ../config.mk
  16. include ../platform.mk
  17. CDEFINES=$(GTC_ARCH_DEFINES) -DINCL_PATH=\"$(prefix)/share/gtc/include\"
  18. CFLAGS=$(CCBASEFLAGS) $(CDEFINES)
  19. SOURCEFILES=$(wildcard src/*.c src/*.h src/gtpack/*)
  20. HEADERS=$(wildcard src/*.h)
  21. OBJFILES=\
  22. analyze.o \
  23. bin2calc.o \
  24. cmain.o \
  25. decl.o \
  26. expr.o \
  27. func.o \
  28. gen68k.o \
  29. genffp.o \
  30. genstmt.o \
  31. getasm.o \
  32. getsym.o \
  33. init.o \
  34. intexpr.o \
  35. memmgt.o \
  36. optimize.o \
  37. out68k_as.o \
  38. peep68k.o \
  39. preproc.o \
  40. reg68k.o \
  41. searchkw.o \
  42. stmt.o \
  43. sunpack.o \
  44. symbol.o \
  45. .PHONY: all clean install
  46. all: gtc
  47. clean:
  48. $(RM) $(OBJFILES) src/tags
  49. distclean: clean
  50. $(RM) gtc$(BIN_SUFFIX)
  51. scratchclean: distclean
  52. install: gtc
  53. mkdir -p $(prefix)/bin
  54. install gtc $(prefix)/bin/gtc
  55. splint:
  56. splint \
  57. -nestcomment -paramuse -nullassign -initallelements -fullinitblock \
  58. +charint +boolint -boolops +ptrnegate -shiftnegative \
  59. -nullret -retvalint -retvalother \
  60. -noeffect \
  61. -globstate -mustfreeonly -mustfreefresh -onlytrans -statictrans -observertrans -dependenttrans -temptrans -branchstate \
  62. $(CDEFINES) $(OBJFILES:%.o=%.c)
  63. # -nestcomment is for '//#define foo bar /* this is a comment */'
  64. # -paramuse is for unused func params
  65. # -nullassign is for 'int x CGLOB;'
  66. # -initallelements is for 'int x[5] CGLOBL;'
  67. # -fullinitblock is for 'TI_SHORT x CGLOBL;'
  68. # +charint is for 'char c = 2+1;' or 'if (c < 2+1)'
  69. # +boolint is for 'int z = (x==y);'
  70. # -boolops is for 'ptr && x'
  71. # +ptrnegate is for '!ptr'
  72. # -shiftnegative is for '1 << my_int' where 'my_int' has no known range
  73. # -noeffect is for '(void)0'
  74. # -nullret is for 'return NULL;' without '/*@null@*/' annotation
  75. # -retvalint is for 'myfunc(x);' without subsequent cast to void
  76. # -retvalother is for 'myfunc(x);' without subsequent cast to void
  77. src/protos.h: src/*.c
  78. ruby -e '' && perl -e '' && (grep "^[^/\#*} ].*(.*{" src/*.c | perl -pe 's/ {/;/ or die $$_' | perl -pe '$$m=$$_;s/\/\*.*?\*\// /g;/(\w+)\(/ or die $$_;print "$$1:";$$_=$$m' | perl -pe 's/\bTYP\b/struct typ/g;s/\bSYM\b/struct sym/g;s/\bTABLE\b/struct stab/g;s/\bHTABLE\b/struct hstab/g;s/\bSTACK_IMAGE\b/struct _stackimg/g;s/\bREGS_IMAGE\b/struct _regsimg/g;s/\b_pc_bcd\b/struct _pc_bcd_s/g' | sort | uniq | ruby script/mkprotos.rb > $@) || echo 1>&2 "warning: unable to rebuild 'protos.h'"
  79. gtc: $(SOURCEFILES)
  80. $(MAKE) gtc-rebuild
  81. #$(OBJFILES): $(HEADERS)
  82. gtc-rebuild: $(OBJFILES)
  83. $(CC) -o gtc $(LDFLAGS) $(OBJFILES)
  84. %.o: %.c vcg.c error.c *.h gtpack/*.h Makefile config.mk
  85. $(CC) -c $(CFLAGS) $<