Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.29 KB | None | 0 0
  1. #----------------------------
  2.  
  3. #Change TARGET to specify the output program name
  4. #Change ICONC to "ICON" to include a custom icon, and "NICON" to not use an icon. Icons use the palette located in \include\ce\pal, and is named iconc.png in your project's root directory.
  5. #Change DEBUGMODE to "DEBUG" in order to compile debug.h functions in, and "NDEBUG" to not compile debugging functions
  6. #Change DESCRIPTION to modify what is displayed within a compatible shell
  7. #Change ARCHIVED to "YES" to mark the output as archived, and "NO" to not
  8. #Change APPVAR to "YES" to create the file as an AppVar, otherwise "NO" for programs
  9.  
  10. #----------------------------
  11. TARGET ?= CATYLIZM
  12. DESCRIPTION ?= "Catylizm for the TI CE calculators"
  13. DEBUGMODE ?= NDEBUG
  14. ARCHIVED ?= NO
  15. APPVAR ?= NO
  16. #----------------------------
  17.  
  18. #These directories specify where source and output should go
  19.  
  20. #----------------------------
  21. SRCDIR := src
  22. OBJDIR := obj
  23. BINDIR := bin
  24. GFXDIR := src/gfx
  25. #----------------------------
  26.  
  27. #Add shared library names to the L varible, for instance:
  28. # L := graphc fileioc keypadc
  29. L := graphc keypadc
  30.  
  31. #----------------------------
  32. #Try not to edit anything below these lines unless you know what you are doing
  33. #----------------------------
  34.  
  35. #----------------------------
  36. empty :=
  37. space := $(empty) $(empty)
  38. comma := ,
  39. TARGETHEX := $(TARGET).hex
  40.  
  41. ICON_PNG := iconc.png
  42. ICON_ASM := iconc.asm
  43. CSTARTUP_ASM := cstartup.asm
  44. LIBHEADER_ASM := libheader.asm
  45.  
  46. ICON_OBJ := $(ICON_ASM:%.asm=%.obj)
  47. CSTARTUP_OBJ := $(CSTARTUP_ASM:%.asm=%.obj)
  48. LIBHEADER_OBJ := $(LIBHEADER_ASM:%.asm=%.obj)
  49.  
  50. LIBHEADER_LOC := $(CEDEV)/include/ce/asm/$(LIBHEADER_ASM)
  51. CSTARTUP_LOC := $(CEDEV)/include/ce/asm/$(CSTARTUP_ASM)
  52. ICON_LOC := .
  53.  
  54. ALLDIRS := $(sort $(dir $(wildcard $(SRCDIR)/*/)))
  55.  
  56. BIN = $(call NATIVEPATH,$(CEDEV)/bin)
  57. ifeq ($(OS),Windows_NT)
  58. NATIVEPATH = $(subst /,\,$(1))
  59. WINPATH = $(NATIVEPATH)
  60. CEDEV ?= $(realpath ..\..)
  61. CC = "$(BIN)eZ80cc"
  62. AS = "$(BIN)eZ80asm"
  63. LD = "$(BIN)eZ80link"
  64. CV = "$(BIN)convhex"
  65. PG = "$(BIN)convpng"
  66. CD = cd
  67. RM = del /F /Q
  68. CP = copy /Y
  69. NULL = >nul 2>&1
  70. else
  71. NATIVEPATH = $(subst \,/,$(1))
  72. WINPATH = $(subst \,\\,$(shell winepath --windows $(1)))
  73. CEDEV ?= $(realpath ../..)
  74. CC = wine "$(BIN)eZ80cc"
  75. LD = wine "$(BIN)eZ80link"
  76. CV = "$(BIN)convhex_linux"
  77. PG = "$(BIN)convpng_linux"
  78. CD = cd
  79. RM = rm -f
  80. CP = cp -f
  81. NULL = >/dev/null
  82. endif
  83. BIN := $(call NATIVEPATH,$(CEDEV)/bin/)
  84.  
  85. ifneq ($(ARCHIVED),NO)
  86. CVFLAGS := -a
  87. endif
  88. ifneq ($(APPVAR),NO)
  89. CVFLAGS += -v
  90. TARGETTYPE := $(TARGET).8xv
  91. else
  92. TARGETTYPE := $(TARGET).8xp
  93. endif
  94.  
  95. ifneq ("$(wildcard $(ICON_PNG))","")
  96. ICONC := ICON
  97. endif
  98.  
  99. SOURCES := $(call WINPATH,$(foreach dir,$(ALLDIRS),$(wildcard $(dir)*.c)))
  100. ASMSOURCES := $(call WINPATH,$(foreach dir,$(ALLDIRS),$(wildcard $(dir)*.asm)))
  101. SOURCES := $(call WINPATH,$(addprefix $(CURDIR)/,$(SOURCES)))
  102. ASMSOURCES := $(call WINPATH,$(addprefix $(CURDIR)/,$(ASMSOURCES)))
  103.  
  104. OBJECTS := $(addprefix $(OBJDIR)/,$(notdir $(SOURCES:%.c=%.obj)))
  105. OBJECTS += $(addprefix $(OBJDIR)/,$(notdir $(ASMSOURCES:%.asm=%.obj)))
  106. OBJECTS += $(OBJDIR)/$(CSTARTUP_OBJ)
  107.  
  108. ifeq ($(ICONC),ICON)
  109. ICON_CONV := $(PG) -c $(DESCRIPTION) && $(CP) $(ICON_ASM) $(OBJDIR) $(NULL) && $(RM) $(ICON_ASM) $(NULL)
  110. OBJECTS += $(OBJDIR)/$(ICON_OBJ)
  111. else
  112. ICON_CONV :=
  113. endif
  114.  
  115. ifdef L
  116. OBJECTS += $(OBJDIR)/$(LIBHEADER_OBJ)
  117. LIBLOC := $(foreach var,$(L),lib/ce/$(var))
  118. LIBS := $(call WINPATH,$(foreach var,$(L),$(CEDEV)/lib/ce/$(var)/$(var).asm))
  119. OBJECTS += $(addprefix $(OBJDIR)/,$(notdir $(LIBS:%.asm=%.obj)))
  120. endif
  121.  
  122. HEADERS := $(subst $(space),;,$(call WINPATH,. $(ALLDIRS) $(addprefix $(CEDEV)/,. include/ce/asm include/ce/c include include/std lib/std/ce lib/ce $(LIBLOC))))
  123. LIBRARIES := $(call WINPATH,$(addprefix $(CEDEV)/lib/std/,ce/ctice.lib ce/cdebug.lib chelp.lib crt.lib crtS.lib nokernel.lib fplib.lib fplibS.lib))
  124. LIBRARIES += $(call WINPATH,$(foreach var,$(L),$(CEDEV)/lib/ce/$(var)/$(var).lib))
  125.  
  126. ASM_FLAGS := \
  127. -define:_EZ80=1 -define:_SIMULATE=1 -define:$(ICONC) -include:$(HEADERS) -NOlist -NOlistmac \
  128. -pagelen:250 -pagewidth:132 -quiet -sdiopt -warn -NOdebug -NOigcase -cpu:EZ80F91
  129.  
  130. CFLAGS := \
  131. -quiet -define:$(DEBUGMODE) -define:_EZ80F91 -define:_EZ80 -define:$(ICONC) -define:_SIMULATE -NOlistinc -NOmodsect -cpu:EZ80F91 -keepasm \
  132. -optspeed -NOreduceopt -NOgenprintf -stdinc:"$(HEADERS)" -usrinc:"." -NOdebug \
  133. -asmsw:"$(ASM_FLAGS)"
  134.  
  135. LDFLAGS := \
  136. -FORMAT=INTEL32 \
  137. -map -maxhexlen=64 -quiet -warnoverlap -xref -unresolved=fatal \
  138. -sort ADDRESS=ascending -warn -NOdebug -NOigcase \
  139. define __copy_code_to_ram = 0 \
  140. range rom $$000000 : $$FFFFFF \
  141. range ram $$D00000 : $$FFFFFF \
  142. range bss $$D031F6 : $$D13FD6 \
  143. change code is ram \
  144. change data is ram \
  145. change text is ram \
  146. change strsect is text \
  147. define __low_bss = base of bss \
  148. define __len_bss = length of bss \
  149. define __heaptop = (highaddr of bss) \
  150. define __heapbot = (top of bss)+1 \
  151. define __stack = $$D1A87E \
  152. locate .header at $$D1A87F \
  153. locate .icon at (top of .header)+1 \
  154. locate .launcher at (top of .icon)+1 \
  155. locate .libs at (top of .launcher)+1
  156.  
  157. ifdef L
  158. LIBNUM := $(words $(L))
  159. LDLIBS := locate .$(word 1,$(L))_header at (top of .libs)+1
  160. LDLIBS += locate .$(word 1,$(L)) at (top of .$(word 1,$(L))_header)+1
  161. ifneq ($(LIBNUM),1)
  162. LDLIBS += locate .$(word 2,$(L))_header at (top of .$(word 1,$(L))+1)
  163. LDLIBS += locate .$(word 2,$(L)) at (top of .$(word 2,$(L))_header)+1
  164. ifneq ($(LIBNUM),2)
  165. LDLIBS += locate .$(word 3,$(L))_header at (top of .$(word 2,$(L))+1)
  166. LDLIBS += locate .$(word 3,$(L)) at (top of .$(word 3,$(L))_header)+1
  167. ifneq ($(LIBNUM),3)
  168. LDLIBS += locate .$(word 4,$(L))_header at (top of .$(word 3,$(L))+1)
  169. LDLIBS += locate .$(word 4,$(L)) at (top of .$(word 4,$(L))_header)+1
  170. ifneq ($(LIBNUM),4)
  171. LDLIBS += locate .$(word 5,$(L))_header at (top of .$(word 4,$(L))+1)
  172. LDLIBS += locate .$(word 5,$(L)) at (top of .$(word 5,$(L))_header)+1
  173. ifneq ($(LIBNUM),5)
  174. LDLIBS += locate .$(word 6,$(L))_header at (top of .$(word 5,$(L))+1)
  175. LDLIBS += locate .$(word 6,$(L)) at (top of .$(word 6,$(L))_header)+1
  176. ifneq ($(LIBNUM),6)
  177. LDLIBS += locate .$(word 7,$(L))_header at (top of .$(word 6,$(L))+1)
  178. LDLIBS += locate .$(word 7,$(L)) at (top of .$(word 7,$(L))_header)+1
  179. ifneq ($(LIBNUM),7)
  180. LDLIBS += locate .$(word 8,$(L))_header at (top of .$(word 7,$(L))+1)
  181. LDLIBS += locate .$(word 8,$(L)) at (top of .$(word 8,$(L))_header)+1
  182. ifneq ($(LIBNUM),8)
  183. LDLIBS += locate .$(word 9,$(L))_header at (top of .$(word 8,$(L))+1)
  184. LDLIBS += locate .$(word 9,$(L)) at (top of .$(word 9,$(L))_header)+1
  185. ifneq ($(LIBNUM),9)
  186. LDLIBS += locate .$(word 10,$(L))_header at (top of .$(word 9,$(L))+1)
  187. LDLIBS += locate .$(word 10,$(L)) at (top of .$(word 10,$(L))_header)+1
  188. ifneq ($(LIBNUM),10)
  189. LDLIBS += locate .$(word 11,$(L))_header at (top of .$(word 10,$(L))+1)
  190. LDLIBS += locate .$(word 11,$(L)) at (top of .$(word 11,$(L))_header)+1
  191. endif
  192. endif
  193. endif
  194. endif
  195. endif
  196. endif
  197. endif
  198. endif
  199. endif
  200. endif
  201. LDFLAGS += $(LDLIBS)
  202. LDLAST := .$(word $(words $(L)),$(L))
  203. else
  204. LDLAST := .libs
  205. endif
  206.  
  207. LDFLAGS += \
  208. locate .startup at (top of $(LDLAST))+1 \
  209. locate code at (top of .startup)+1 \
  210. locate data at (top of code)+1 \
  211. locate text at (top of data)+1
  212.  
  213. all : $(BINDIR)/$(TARGETTYPE)
  214.  
  215. $(BINDIR)/$(TARGETHEX) : $(OBJECTS) $(LIBRARIES)
  216. @$(LD) $(LDFLAGS) $@ = "$(subst $(space),$(comma),$(call WINPATH,$^))" || @$(RM) $(BINDIR)/$(TARGETTYPE) $(BINDIR)/$(TARGETHEX) $(NULL)
  217.  
  218. %.8xv : %.hex
  219. @$(CV) $(CVFLAGS) $(@:%.8xv=%)
  220.  
  221. %.8xp : %.hex
  222. @$(CV) $(CVFLAGS) $(@:%.8xp=%)
  223.  
  224. $(OBJDIR)/$(ICON_OBJ) : $(ICON_PNG)
  225. @$(ICON_CONV) && \
  226. @$(CD) $(OBJDIR) && \
  227. $(AS) $(ASM_FLAGS) $(ICON_ASM)
  228.  
  229. $(OBJDIR)/%.obj : $(SRCDIR)/%.asm
  230. @$(CD) $(OBJDIR) && \
  231. $(AS) $(ASM_FLAGS) $(call WINPATH,$(addprefix $(CURDIR)/,$<))
  232.  
  233. $(OBJDIR)/%.obj : $(SRCDIR)/%.c
  234. @$(CD) $(OBJDIR) && \
  235. $(CC) $(CFLAGS) $(call WINPATH,$(addprefix $(CURDIR)/,$<))
  236.  
  237. $(OBJDIR)/%.obj : $(GFXDIR)/%.c
  238. @$(CD) $(OBJDIR) && \
  239. $(CC) $(CFLAGS) $(call WINPATH,$(addprefix $(CURDIR)/,$<))
  240.  
  241. $(OBJDIR)/$(CSTARTUP_OBJ) : $(CSTARTUP_LOC)
  242. @$(CD) $(OBJDIR) && \
  243. $(AS) $(ASM_FLAGS) $(call WINPATH,$<)
  244.  
  245. $(OBJDIR)/$(LIBHEADER_OBJ) : $(LIBHEADER_LOC)
  246. @$(CD) $(OBJDIR) && \
  247. $(AS) $(ASM_FLAGS) $(call WINPATH,$<)
  248. @$(CD) $(OBJDIR) && \
  249. $(CC) $(CFLAGS) -asm $(LIBS)
  250.  
  251. $(OBJDIR)/%.obj :
  252.  
  253. clean :
  254. @$(RM) $(OBJDIR)\* $(BINDIR)\* $(NULL)
  255.  
  256. .PHONY : all clean
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement