Makefile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #
  2. # This Make file is called from the core Makefile hierarchy with is a hierarchical
  3. # make wwhich uses parent callbacks to implement inheritance. However is luac_cross
  4. # build stands outside this and uses the host toolchain to implement a separate
  5. # host build of the luac.cross image.
  6. #
  7. .NOTPARALLEL:
  8. CCFLAGS:= -I.. -I../../include -I../../libc -I../../uzlib
  9. LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld -lm -ldl -Wl,-Map=mapfile
  10. CCFLAGS += -Wall
  11. DEFINES += -DLUA_CROSS_COMPILER -DLUA_OPTIMIZE_MEMORY=2
  12. TARGET = host
  13. ifeq ($(FLAVOR),debug)
  14. CCFLAGS += -O0 -g
  15. TARGET_LDFLAGS += -O0 -g
  16. else
  17. FLAVOR = release
  18. CCFLAGS += -O2
  19. TARGET_LDFLAGS += -O2
  20. endif
  21. LUACSRC := luac.c lflashimg.c liolib.c loslib.c print.c
  22. LUASRC := lapi.c lauxlib.c lbaselib.c lcode.c ldblib.c ldebug.c \
  23. ldo.c ldump.c lfunc.c lgc.c linit.c llex.c \
  24. lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c lparser.c \
  25. lrotable.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c \
  26. ltm.c lundump.c lvm.c lzio.c
  27. LIBCSRC := c_stdlib.c
  28. UZSRC := uzlib_deflate.c crc32.c
  29. #
  30. # This relies on the files being unique on the vpath
  31. #
  32. SRC := $(LUACSRC) $(LUASRC) $(LIBCSRC) $(UZSRC)
  33. vpath %.c .:..:../../libc:../../uzlib
  34. ODIR := .output/$(TARGET)/$(FLAVOR)/obj
  35. OBJS := $(SRC:%.c=$(ODIR)/%.o)
  36. DEPS := $(SRC:%.c=$(ODIR)/%.d)
  37. CFLAGS = $(CCFLAGS) $(DEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES)
  38. DFLAGS = $(CCFLAGS) $(DDEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES)
  39. CC := gcc
  40. ECHO := echo
  41. IMAGE := ../../../luac.cross
  42. .PHONY: test clean all
  43. all: $(DEPS) $(IMAGE)
  44. $(IMAGE) : $(OBJS)
  45. $(CC) $(OBJS) -o $@ $(LDFLAGS)
  46. test :
  47. @echo CC: $(CC)
  48. @echo SRC: $(SRC)
  49. @echo OBJS: $(OBJS)
  50. @echo DEPS: $(DEPS)
  51. clean :
  52. $(RM) -r $(ODIR)
  53. ifneq ($(MAKECMDGOALS),clean)
  54. -include $(DEPS)
  55. endif
  56. $(ODIR)/%.o: %.c
  57. @mkdir -p $(ODIR);
  58. $(CC) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
  59. $(ODIR)/%.d: %.c
  60. @mkdir -p $(ODIR);
  61. @echo DEPEND: $(CC) -M $(CFLAGS) $<
  62. @set -e; rm -f $@; \
  63. $(CC) -M $(CFLAGS) $< > $@.$$$$; \
  64. sed 's,\($*\.o\)[ :]*,$(ODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
  65. rm -f $@.$$$$