Makefile 16 KB

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