Makefile 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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
  10. CCFLAGS += -Wall
  11. DEFINES += -DLUA_CROSS_COMPILER
  12. TARGET = host
  13. ifeq ($(FLAVOR),release)
  14. CCFLAGS += -O2
  15. TARGET_LDFLAGS += -O2
  16. else
  17. FLAVOR = debug
  18. CCFLAGS += -O2 -g
  19. TARGET_LDFLAGS += -O2 -g
  20. endif
  21. LUACSRC := luac.c lflashimg.c loslib.c print.c
  22. LUASRC := lapi.c lauxlib.c lbaselib.c lcode.c ldblib.c \
  23. ldebug.c ldo.c ldump.c lfunc.c lgc.c \
  24. llex.c lmathlib.c lmem.c loadlib.c lobject.c \
  25. lopcodes.c lparser.c lrotable.c lstate.c lstring.c \
  26. lstrlib.c ltable.c ltablib.c ltm.c lundump.c \
  27. lvm.c lzio.c
  28. LIBCSRC := c_stdlib.c
  29. #
  30. # This relies on the files being unique on the vpath
  31. #
  32. SRC := $(LUACSRC) $(LUASRC) $(LIBCSRC)
  33. vpath %.c .:..:../../libc
  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. -include $(DEPS)
  54. $(ODIR)/%.o: %.c
  55. @mkdir -p $(ODIR);
  56. $(CC) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
  57. $(ODIR)/%.d: %.c
  58. @mkdir -p $(ODIR);
  59. @echo DEPEND: $(CC) -M $(CFLAGS) $<
  60. @set -e; rm -f $@; \
  61. $(CC) -M $(CFLAGS) $< > $@.$$$$; \
  62. sed 's,\($*\.o\)[ :]*,$(ODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
  63. rm -f $@.$$$$
  64. # echo 's,\($*\.o\)[ :]*,$(ODIR)/\1 $@ : ,g'; \