Makefile 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. # Hey Emacs, this is a -*- makefile -*-
  2. # Define version number
  3. MAJOR = 0
  4. MINOR = 0
  5. PATCHLEVEL = 1
  6. FIX =
  7. # Forces bootloader version to 0, comment out for release
  8. #PRERELEASE =
  9. #----------------------------------------------------------------------------
  10. # WinAVR Makefile Template written by Eric B. Weddington, Joerg Wunsch, et al.
  11. #
  12. # Released to the Public Domain
  13. #
  14. # Additional material for this makefile was written by:
  15. # Peter Fleury
  16. # Tim Henigan
  17. # Colin O'Flynn
  18. # Reiner Patommel
  19. # Markus Pfaff
  20. # Sander Pool
  21. # Frederik Rouleau
  22. # Carlos Lamas
  23. #
  24. #
  25. # Extensively modified for sd2iec by Ingo Korb
  26. #
  27. # To rebuild project do "make clean" then "make all".
  28. #----------------------------------------------------------------------------
  29. # Read configuration file
  30. ifdef CONFIG
  31. CONFIGSUFFIX = $(CONFIG:config%=%)
  32. else
  33. CONFIG = config
  34. CONFIGSUFFIX =
  35. endif
  36. # Enable verbose compilation with "make V=1"
  37. ifdef V
  38. Q :=
  39. E := @:
  40. else
  41. Q := @
  42. E := @echo
  43. endif
  44. # Include the configuration file
  45. include $(CONFIG)
  46. # Set MCU name and length of binary for bootloader
  47. # WARNING: Fuse settings not tested!
  48. MCU := $(CONFIG_MCU)
  49. ifeq ($(MCU),atmega128)
  50. BINARY_LENGTH = 0x1f000
  51. # EFUSE = 0xff
  52. # HFUSE = 0x91
  53. # LFUSE = 0xaf
  54. else ifeq ($(MCU),atmega1281)
  55. BINARY_LENGTH = 0x1f000
  56. BOOTLDRSIZE = 0x0800
  57. EFUSE = 0xff
  58. HFUSE = 0xd2
  59. LFUSE = 0xfc
  60. else ifeq ($(MCU),atmega2561)
  61. BINARY_LENGTH = 0x3f000
  62. EFUSE = 0xfd
  63. HFUSE = 0x93
  64. LFUSE = 0xef
  65. else ifeq ($(MCU),atmega644)
  66. BINARY_LENGTH = 0xf000
  67. EFUSE = 0xfd
  68. HFUSE = 0x91
  69. LFUSE = 0xef
  70. else ifeq ($(MCU),atmega644p)
  71. BINARY_LENGTH = 0xf000
  72. EFUSE = 0xfd
  73. HFUSE = 0x91
  74. LFUSE = 0xef
  75. else
  76. .PHONY: nochip
  77. nochip:
  78. @echo '=============================================================='
  79. @echo 'No known target chip specified.'
  80. @echo
  81. @echo 'Please edit the Makefile.'
  82. @exit 1
  83. endif
  84. # Directory for all generated files
  85. OBJDIR := obj-$(CONFIG_MCU:atmega%=m%)$(CONFIGSUFFIX)
  86. # Output format. (can be srec, ihex, binary)
  87. FORMAT = ihex
  88. # Target file name (without extension).
  89. TARGET = $(OBJDIR)/sd2snes
  90. # List C source files here. (C dependencies are automatically generated.)
  91. SRC = main.c ff.c utils.c timer.c led.c diskio.c sdcard.c spi.c crc7.c snes.c fpga.c memory.c crc16.c fileops.c fpga_spi.c
  92. ifeq ($(CONFIG_UART_DEBUG),y)
  93. SRC += uart.c
  94. endif
  95. # List Assembler source files here.
  96. # Make them always end in a capital .S. Files ending in a lowercase .s
  97. # will not be considered source files but generated files (assembler
  98. # output from the compiler), and will be deleted upon "make clean"!
  99. # Even though the DOS/Win* filesystem matches both .s and .S the same,
  100. # it will preserve the spelling of the filenames, and gcc itself does
  101. # care about how the name is spelled on its command-line.
  102. ASRC =
  103. # Optimization level, can be [0, 1, 2, 3, s].
  104. # 0 = turn off optimization. s = optimize for size.
  105. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
  106. # Use s -mcall-prologues when you really need size...
  107. #OPT = 2
  108. OPT = 3 -finline-functions
  109. # Debugging format.
  110. # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
  111. # AVR Studio 4.10 requires dwarf-2.
  112. # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
  113. DEBUG = dwarf-2
  114. # List any extra directories to look for include files here.
  115. # Each directory must be seperated by a space.
  116. # Use forward slashes for directory separators.
  117. # For a directory that has spaces, enclose it in quotes.
  118. EXTRAINCDIRS =
  119. # Compiler flag to set the C Standard level.
  120. # c89 = "ANSI" C
  121. # gnu89 = c89 plus GCC extensions
  122. # c99 = ISO C99 standard (not yet fully implemented)
  123. # gnu99 = c99 plus GCC extensions
  124. CSTANDARD = -std=gnu99
  125. # Place -D or -U options here
  126. CDEFS = -DF_CPU=$(CONFIG_MCU_FREQ)UL
  127. # Calculate bootloader version
  128. ifdef PRERELEASE
  129. BOOT_VERSION := 0
  130. else
  131. BOOT_VERSION := 0x$(MAJOR)$(MINOR)$(PATCHLEVEL)$(FIX)
  132. endif
  133. # Create a version number define
  134. ifdef PATCHLEVEL
  135. ifdef FIX
  136. PROGRAMVERSION := $(MAJOR).$(MINOR).$(PATCHLEVEL).$(FIX)
  137. else
  138. PROGRAMVERSION := $(MAJOR).$(MINOR).$(PATCHLEVEL)
  139. BOOT_VERSION := $(BOOT_VERSION)0
  140. endif
  141. else
  142. PROGRAMVERSION := $(MAJOR).$(MINOR)
  143. BOOT_VERSION := $(BOOT_VERSION)00
  144. endif
  145. ifdef PRERELEASE
  146. PROGRAMVERSION := $(PROGRAMVERSION)$(PRERELEASE)
  147. endif
  148. LONGVERSION := -$(CONFIG_MCU:atmega%=m%)$(CONFIGSUFFIX)
  149. CDEFS += -DVERSION=\"$(PROGRAMVERSION)\" -DLONGVERSION=\"$(LONGVERSION)\"
  150. # Place -I options here
  151. CINCS =
  152. # Define programs and commands.
  153. # CC must be defined here to generate the correct CFLAGS
  154. SHELL = sh
  155. CC = avr-gcc
  156. OBJCOPY = avr-objcopy
  157. OBJDUMP = avr-objdump
  158. SIZE = avr-size
  159. NM = avr-nm
  160. AVRDUDE = avrdude
  161. REMOVE = rm -f
  162. COPY = cp
  163. WINSHELL = cmd
  164. #---------------- Compiler Options ----------------
  165. # -g*: generate debugging information
  166. # -O*: optimization level
  167. # -f...: tuning, see GCC manual and avr-libc documentation
  168. # -Wall...: warning level
  169. # -Wa,...: tell GCC to pass this to the assembler.
  170. # -adhlns...: create assembler listing
  171. CFLAGS = -g$(DEBUG)
  172. CFLAGS += $(CDEFS) $(CINCS)
  173. CFLAGS += -O$(OPT)
  174. CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
  175. CFLAGS += -Wall -Wstrict-prototypes -Werror
  176. CFLAGS += -Wa,-adhlns=$(OBJDIR)/$(<:.c=.lst)
  177. CFLAGS += -I$(OBJDIR)
  178. CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
  179. CFLAGS += $(CSTANDARD)
  180. CFLAGS += -ffunction-sections -fdata-sections
  181. #CFLAGS += -mcall-prologues
  182. # these are needed for GCC 4.3.2, which is more aggressive at inlining
  183. # gcc-4.2 knows one of those, but it tends to increase code size
  184. ifeq ($(shell $(CC) --version|gawk -f gcctest.awk),YES)
  185. CFLAGS += --param inline-call-cost=3
  186. CFLAGS += -fno-inline-small-functions
  187. CFLAGS += -fno-move-loop-invariants
  188. CFLAGS += -fno-split-wide-types
  189. # turn these on to keep the functions in the same order as in the source
  190. # this is only useful if you're looking at disassembly
  191. #CFLAGS += -fno-reorder-blocks
  192. #CFLAGS += -fno-reorder-blocks-and-partition
  193. #CFLAGS += -fno-reorder-functions
  194. #CFLAGS += -fno-toplevel-reorder
  195. endif
  196. ifeq ($(CONFIG_STACK_TRACKING),y)
  197. CFLAGS += -finstrument-functions
  198. endif
  199. #---------------- Assembler Options ----------------
  200. # -Wa,...: tell GCC to pass this to the assembler.
  201. # -ahlms: create listing
  202. # -gstabs: have the assembler create line number information; note that
  203. # for use in COFF files, additional information about filenames
  204. # and function names needs to be present in the assembler source
  205. # files -- see avr-libc docs [FIXME: not yet described there]
  206. ASFLAGS = -Wa,-adhlns=$(OBJDIR)/$(<:.S=.lst),-gstabs -I$(OBJDIR)
  207. #---------------- Library Options ----------------
  208. # Minimalistic printf version
  209. PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
  210. # Floating point printf version (requires MATH_LIB = -lm below)
  211. PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
  212. # If this is left blank, then it will use the Standard printf version.
  213. PRINTF_LIB =
  214. #PRINTF_LIB = $(PRINTF_LIB_MIN)
  215. #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
  216. # Minimalistic scanf version
  217. SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
  218. # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
  219. SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
  220. # If this is left blank, then it will use the Standard scanf version.
  221. SCANF_LIB =
  222. #SCANF_LIB = $(SCANF_LIB_MIN)
  223. #SCANF_LIB = $(SCANF_LIB_FLOAT)
  224. MATH_LIB = -lm
  225. #---------------- External Memory Options ----------------
  226. # 64 KB of external RAM, starting after internal RAM (ATmega128!),
  227. # used for variables (.data/.bss) and heap (malloc()).
  228. #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
  229. # 64 KB of external RAM, starting after internal RAM (ATmega128!),
  230. # only used for heap (malloc()).
  231. #EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
  232. EXTMEMOPTS =
  233. #---------------- Linker Options ----------------
  234. # -Wl,...: tell GCC to pass this to linker.
  235. # -Map: create map file
  236. # --cref: add cross reference to map file
  237. LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
  238. LDFLAGS += $(EXTMEMOPTS)
  239. LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
  240. LDFLAGS += -Wl,--gc-sections
  241. ifeq ($(CONFIG_LINKER_RELAX),y)
  242. LDFLAGS += -Wl,-O9,--relax
  243. endif
  244. #---------------- Programming Options (avrdude) ----------------
  245. # Programming hardware: alf avr910 avrisp bascom bsd
  246. # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 stk500v2
  247. #
  248. # Type: avrdude -c ?
  249. # to get a full listing.
  250. #
  251. AVRDUDE_PROGRAMMER = stk200
  252. # com1 = serial port. Use lpt1 to connect to parallel port.
  253. AVRDUDE_PORT = /dev/parport0 # programmer connected to serial device
  254. AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
  255. # AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
  256. # Allow fuse overrides from the config file
  257. ifdef CONFIG_EFUSE
  258. EFUSE := CONFIG_EFUSE
  259. endif
  260. ifdef CONFIG_HFUSE
  261. HFUSE := CONFIG_HFUSE
  262. endif
  263. ifdef CONFIG_LFUSE
  264. LFUSE := CONFIG_LFUSE
  265. endif
  266. # Calculate command line arguments for fuses
  267. AVRDUDE_WRITE_FUSES :=
  268. ifdef EFUSE
  269. AVRDUDE_WRITE_FUSES += -U efuse:w:$(EFUSE):m
  270. endif
  271. ifdef HFUSE
  272. AVRDUDE_WRITE_FUSES += -U hfuse:w:$(HFUSE):m
  273. endif
  274. ifdef LFUSE
  275. AVRDUDE_WRITE_FUSES += -U lfuse:w:$(LFUSE):m
  276. endif
  277. # Uncomment the following if you want avrdude's erase cycle counter.
  278. # Note that this counter needs to be initialized first using -Yn,
  279. # see avrdude manual.
  280. #AVRDUDE_ERASE_COUNTER = -y
  281. # Uncomment the following if you do /not/ wish a verification to be
  282. # performed after programming the device.
  283. #AVRDUDE_NO_VERIFY = -V
  284. # Increase verbosity level. Please use this when submitting bug
  285. # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
  286. # to submit bug reports.
  287. #AVRDUDE_VERBOSE = -v -v
  288. AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
  289. AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
  290. AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
  291. AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
  292. #---------------- Debugging Options ----------------
  293. # For simulavr only - target MCU frequency.
  294. DEBUG_MFREQ = $(CONFIG_MCU_FREQ)
  295. # Set the DEBUG_UI to either gdb or insight.
  296. # DEBUG_UI = gdb
  297. DEBUG_UI = insight
  298. # Set the debugging back-end to either avarice, simulavr.
  299. DEBUG_BACKEND = avarice
  300. #DEBUG_BACKEND = simulavr
  301. # GDB Init Filename.
  302. GDBINIT_FILE = __avr_gdbinit
  303. # When using avarice settings for the JTAG
  304. JTAG_DEV = /dev/com1
  305. # Debugging port used to communicate between GDB / avarice / simulavr.
  306. DEBUG_PORT = 4242
  307. # Debugging host used to communicate between GDB / avarice / simulavr, normally
  308. # just set to localhost unless doing some sort of crazy debugging when
  309. # avarice is running on a different computer.
  310. DEBUG_HOST = localhost
  311. #============================================================================
  312. # De-dupe the list of C source files
  313. CSRC := $(sort $(SRC))
  314. # Define all object files.
  315. OBJ := $(patsubst %,$(OBJDIR)/%,$(CSRC:.c=.o) $(ASRC:.S=.o))
  316. # Define all listing files.
  317. LST := $(patsubst %,$(OBJDIR)/%,$(CSRC:.c=.lst) $(ASRC:.S=.lst))
  318. # Compiler flags to generate dependency files.
  319. GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
  320. # Combine all necessary flags and optional flags.
  321. # Add target processor to flags.
  322. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
  323. ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) $(CDEFS)
  324. # Default target.
  325. all: build
  326. build: elf bin hex
  327. $(E) " SIZE $(TARGET).elf"
  328. $(Q)$(ELFSIZE)|grep -v debug
  329. elf: $(TARGET).elf
  330. bin: $(TARGET).bin
  331. hex: $(TARGET).hex
  332. eep: $(TARGET).eep
  333. lss: $(TARGET).lss
  334. sym: $(TARGET).sym
  335. # A little helper target for the maintainer =)
  336. copy2card:
  337. mount /mnt
  338. cp $(TARGET).bin /mnt
  339. umount /mnt
  340. sync
  341. # Doxygen output:
  342. doxygen:
  343. -rm -rf doxyinput
  344. mkdir doxyinput
  345. cp *.h *.c doxyinput
  346. src2doxy.pl doxyinput/*.h doxyinput/*.c
  347. doxygen doxygen.conf
  348. # Display size of file.
  349. HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
  350. ELFSIZE = $(SIZE) -A $(TARGET).elf
  351. AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
  352. # Program the device.
  353. program: bin hex eep
  354. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
  355. # Set fuses of the device
  356. fuses: $(CONFIG)
  357. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FUSES)
  358. # Generate avr-gdb config/init file which does the following:
  359. # define the reset signal, load the target file, connect to target, and set
  360. # a breakpoint at main().
  361. gdb-config:
  362. @$(REMOVE) $(GDBINIT_FILE)
  363. @echo define reset >> $(GDBINIT_FILE)
  364. @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
  365. @echo end >> $(GDBINIT_FILE)
  366. @echo file $(TARGET).elf >> $(GDBINIT_FILE)
  367. @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
  368. ifeq ($(DEBUG_BACKEND),simulavr)
  369. @echo load >> $(GDBINIT_FILE)
  370. endif
  371. @echo break main >> $(GDBINIT_FILE)
  372. debug: gdb-config $(TARGET).elf
  373. ifeq ($(DEBUG_BACKEND), avarice)
  374. @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
  375. @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
  376. $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
  377. @$(WINSHELL) /c pause
  378. else
  379. @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
  380. $(DEBUG_MFREQ) --port $(DEBUG_PORT)
  381. endif
  382. @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
  383. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  384. COFFCONVERT=$(OBJCOPY) --debugging \
  385. --change-section-address .data-0x800000 \
  386. --change-section-address .bss-0x800000 \
  387. --change-section-address .noinit-0x800000 \
  388. --change-section-address .eeprom-0x810000
  389. coff: $(TARGET).elf
  390. $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
  391. extcoff: $(TARGET).elf
  392. $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
  393. # Generate autoconf.h from config
  394. .PRECIOUS : $(OBJDIR)/autoconf.h
  395. $(OBJDIR)/autoconf.h: $(CONFIG) | $(OBJDIR)
  396. $(E) " CONF2H $(CONFIG)"
  397. $(Q)gawk -f conf2h.awk $(CONFIG) > $(OBJDIR)/autoconf.h
  398. # Create final output files (.hex, .eep) from ELF output file.
  399. ifeq ($(CONFIG_BOOTLOADER),y)
  400. $(OBJDIR)/%.bin: $(OBJDIR)/%.elf
  401. $(E) " BIN $@"
  402. $(Q)$(OBJCOPY) -O binary -R .eeprom $< $@
  403. $(E) " CRCGEN $@"
  404. -$(Q)crcgen-new $@ $(BINARY_LENGTH) $(CONFIG_BOOT_DEVID) $(BOOT_VERSION)
  405. $(E) " COPY $(CONFIG_HARDWARE_NAME)-firmware-$(PROGRAMVERSION).bin"
  406. $(Q)$(COPY) $@ $(OBJDIR)/$(CONFIG_HARDWARE_NAME)-firmware-$(PROGRAMVERSION).bin
  407. else
  408. $(OBJDIR)/%.bin: $(OBJDIR)/%.elf
  409. $(E) " BIN $@"
  410. $(Q)$(OBJCOPY) -O binary -R .eeprom $< $@
  411. endif
  412. $(OBJDIR)/%.hex: $(OBJDIR)/%.elf
  413. $(E) " HEX $@"
  414. $(Q)$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  415. $(OBJDIR)/%.eep: $(OBJDIR)/%.elf
  416. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  417. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  418. # Create extended listing file from ELF output file.
  419. $(OBJDIR)/%.lss: $(OBJDIR)/%.elf
  420. $(E) " LSS $<"
  421. $(Q)$(OBJDUMP) -h -S $< > $@
  422. # Create a symbol table from ELF output file.
  423. $(OBJDIR)/%.sym: $(OBJDIR)/%.elf
  424. $(E) " SYM $<"
  425. $(E)$(NM) -n $< > $@
  426. # Link: create ELF output file from object files.
  427. .SECONDARY : $(TARGET).elf
  428. .PRECIOUS : $(OBJ)
  429. $(OBJDIR)/%.elf: $(OBJ)
  430. $(E) " LINK $@"
  431. $(Q)$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
  432. # Compile: create object files from C source files.
  433. $(OBJDIR)/%.o : %.c | $(OBJDIR) $(OBJDIR)/autoconf.h
  434. $(E) " CC $<"
  435. $(Q)$(CC) -c $(ALL_CFLAGS) $< -o $@
  436. # Compile: create assembler files from C source files.
  437. $(OBJDIR)/%.s : %.c | $(OBJDIR) $(OBJDIR)/autoconf.h
  438. $(CC) -S $(ALL_CFLAGS) $< -o $@
  439. # Assemble: create object files from assembler source files.
  440. $(OBJDIR)/%.o : %.S | $(OBJDIR) $(OBJDIR)/autoconf.h
  441. $(E) " AS $<"
  442. $(Q)$(CC) -c $(ALL_ASFLAGS) $< -o $@
  443. # Create preprocessed source for use in sending a bug report.
  444. $(OBJDIR)/%.i : %.c | $(OBJDIR) $(OBJDIR)/autoconf.h
  445. $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
  446. # Create the output directory
  447. $(OBJDIR):
  448. $(E) " MKDIR $(OBJDIR)"
  449. $(Q)mkdir $(OBJDIR)
  450. # Target: clean project.
  451. clean: begin clean_list end
  452. clean_list :
  453. $(E) " CLEAN"
  454. $(Q)$(REMOVE) $(TARGET).hex
  455. $(Q)$(REMOVE) $(TARGET).bin
  456. $(Q)$(REMOVE) $(TARGET).eep
  457. $(Q)$(REMOVE) $(TARGET).cof
  458. $(Q)$(REMOVE) $(TARGET).elf
  459. $(Q)$(REMOVE) $(TARGET).map
  460. $(Q)$(REMOVE) $(TARGET).sym
  461. $(Q)$(REMOVE) $(TARGET).lss
  462. $(Q)$(REMOVE) $(OBJ)
  463. $(Q)$(REMOVE) $(OBJDIR)/autoconf.h
  464. $(Q)$(REMOVE) $(OBJDIR)/*.bin
  465. $(Q)$(REMOVE) $(LST)
  466. $(Q)$(REMOVE) $(CSRC:.c=.s)
  467. $(Q)$(REMOVE) $(CSRC:.c=.d)
  468. $(Q)$(REMOVE) .dep/*
  469. $(Q)$(REMOVE) -rf codedoc
  470. $(Q)$(REMOVE) -rf doxyinput
  471. -$(Q)rmdir $(OBJDIR)
  472. # Include the dependency files.
  473. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  474. # Manual dependency for the assembler module
  475. # $(OBJDIR)/fastloader-ll.o: config.h $(OBJDIR)/autoconf.h
  476. # Listing of phony targets.
  477. .PHONY : all begin finish end sizebefore sizeafter gccversion \
  478. build elf hex eep lss sym coff extcoff \
  479. clean clean_list program debug gdb-config doxygen