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../../../include -I ../../libc
  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. #
  29. # This relies on the files being unique on the vpath
  30. #
  31. SRC := $(LUACSRC) $(LUASRC) $(LIBCSRC)
  32. vpath %.c .:..:../../libc
  33. ODIR := .output/$(TARGET)/$(FLAVOR)/obj
  34. OBJS := $(SRC:%.c=$(ODIR)/%.o)
  35. DEPS := $(SRC:%.c=$(ODIR)/%.d)
  36. CFLAGS = $(CCFLAGS) $(DEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES)
  37. DFLAGS = $(CCFLAGS) $(DDEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES)
  38. CC := $(WRAPCC) gcc
  39. ECHO := echo
  40. IMAGE := ../../../luac.cross
  41. .PHONY: test clean all
  42. all: $(DEPS) $(IMAGE)
  43. $(IMAGE) : $(OBJS)
  44. $(CC) $(OBJS) -o $@ $(LDFLAGS)
  45. test :
  46. @echo CC: $(CC)
  47. @echo SRC: $(SRC)
  48. @echo OBJS: $(OBJS)
  49. @echo DEPS: $(DEPS)
  50. clean :
  51. $(RM) -r $(ODIR)
  52. ifneq ($(MAKECMDGOALS),clean)
  53. -include $(DEPS)
  54. endif
  55. $(ODIR)/%.o: %.c
  56. @mkdir -p $(ODIR);
  57. $(CC) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
  58. $(ODIR)/%.d: %.c
  59. @mkdir -p $(ODIR);
  60. @echo DEPEND: $(CC) -M $(CFLAGS) $<
  61. @set -e; rm -f $@; \
  62. $(CC) -M $(CFLAGS) $< > $@.$$$$; \
  63. sed 's,\($*\.o\)[ :]*,$(ODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
  64. rm -f $@.$$$$