Makefile help please :-(


hi all...

i trying create makefile project. run arduino 1.0 on windows. found makefile here:

http://arduino.cc/forum/index.php?topic=83725.0

and have been modifying it. @ point, can build simple sketch has 1 source module , emit hex file. far good. gets dicy. project has bunch of files, , can't seem find include files. understand it, file emulates arduino environment generating main.cpp file in applet subdirectory, compiles cpp file. that's fine now, although later i'll want modify behavior providing own main.cpp. because when concatenates cpp files, compiler gives me warnings , errors @ line numbers wrong.

anyhow, have tried modifying makefile add -i. , -i.. lines specify search includers. no luck. first few errors are:

code: [select]

applet/main.cpp:6:23: error: constants.h: no such file or directory
applet/main.cpp:14:17: error: i2c.h: no such file or directory
applet/main.cpp:18:19: error: sdfat.h: no such file or directory
applet/main.cpp:19:40: error: sdfatutil.h: no such file or directory
applet/main.cpp:37:94: error: bounce.h: no such file or directory


here make file:

code: [select]

target = $(notdir $(curdir))
# change match arduino installation directory
install_dir = c:/users/jim/desktop/arduino-1.0
port = com17
upload_rate = 115200
avrdude_programmer = stk500v1
mcu = atmega1284p
f_cpu = 16000000

version=100
arduino = $(install_dir)/hardware/maniacbug-mighty-1284p-8f335f8/cores/standard
variants = $(install_dir)/hardware/maniacbug-mighty-1284p-8f335f8/variants/avr_developers
arduino_lib = $(install_dir)/libraries
avr_tools_path = c:/winavr-20100110/bin
avrdude_path = $(install_dir)/hardware/tools

#note if program has dependencies other those
#already listed below, need add them accordingly.
c_modules =  \
$(arduino)/wiring_pulse.c \
$(arduino)/wiring_analog.c \
$(arduino)/wiring.c \
$(arduino)/wiring_digital.c \
$(arduino)/winterrupts.c \
$(arduino)/wiring_shift.c \

cxx_modules = \
$(arduino)/tone.cpp \
$(arduino)/wmath.cpp \
$(arduino)/print.cpp \
$(arduino)/hardwareserial.cpp \
$(arduino)/cdc.cpp \
$(arduino)/hid.cpp \
$(arduino)/ipaddress.cpp \
$(arduino)/new.cpp \
$(arduino)/stream.cpp \
$(arduino)/usbcore.cpp \
$(arduino)/wmath.cpp \
$(arduino)/wstring.cpp \
$(arduino)/main.cpp \

cxx_modules += $(shell find $(arduino_lib)  -maxdepth 2 -mindepth 2 -type f -name *.cpp -exec /bin/echo -n " {}" \;)

cxx_app = main.cpp
modules = $(c_modules) $(cxx_modules)
src = $(c_modules)
cxxsrc = $(cxx_modules) $(cxx_app)
format = ihex

# name of makefile (used "make depend").
makefile = makefile

# debugging format.
# native formats avr-gcc's -g stabs [default], or dwarf-2.
# avr (extended) coff requires stabs, plus avr-objcopy run.
#debug = stabs
debug =

opt = s

# place -d or -u options here
cdefs = -df_cpu=$(f_cpu)l -darduino=$(version)
cxxdefs = -df_cpu=$(f_cpu)l -darduino=$(version)

# place -i options here
cincs = -i$(arduino)  -i$(variants) -i$(arduino_lib)
cxxincs = -i$(arduino) -i$(variants) -i$(arduino_lib)

cincs += $(shell find $(arduino_lib) -mindepth 1 -maxdepth 2 -type d ! -name examples -exec /bin/echo -n " -i{} " \;)
cxxincs += $(shell find $(abduino_lib) -mindepth 1 -maxdepth 2 -type d ! -name examples -exec /bin/echo -n " -i{} " \;)


# compiler flag set c standard level.
# c89   - "ansi" c
# gnu89 - c89 plus gcc extensions
# c99   - iso c99 standard (not yet implemented)
# gnu99 - c99 plus gcc extensions
#cstandard = -std=gnu99
cdebug = -g$(debug)
#cwarn = -wall -wstrict-prototypes
#cwarn = -wall   # show warnings
cwarn = -w #suppress warnings
####ctuning = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
ctuning = -ffunction-sections -fdata-sections
cxxtuning = -fno-exceptions -ffunction-sections -fdata-sections
#cextra = -wa,-adhlns=$(<:.c=.lst)

cflags = $(cdebug) -o$(opt) $(cwarn) $(ctuning) $(cdefs) $(cincs) $(cstandard) $(cextra)
cxxflags = $(cdebug) -o$(opt) $(cwarn) $(cxxtuning) $(cdefs) $(cincs)
#asflags = -wa,-adhlns=$(<:.s=.lst),-gstabs
ldflags = -o$(opt) -lm -wl,--gc-sections


# programming support using avrdude. settings , variables.
avrdude_port = $(port)
avrdude_write_flash = -u flash:w:applet/main.hex

avrdude_flags = -v -f -c $(install_dir)/hardware/tools/avrdude.conf \
-p $(mcu) -p $(avrdude_port) -c $(avrdude_programmer) \
-b $(upload_rate) -d

# program settings
cc = $(avr_tools_path)/avr-gcc
cxx = $(avr_tools_path)/avr-g++
ld = $(avr_tools_path)/avr-gcc
objcopy = $(avr_tools_path)/avr-objcopy
objdump = $(avr_tools_path)/avr-objdump
ar  = $(avr_tools_path)/avr-ar
size = $(avr_tools_path)/avr-size
nm = $(avr_tools_path)/avr-nm
avrdude = $(avrdude_path)/avrdude
remove = rm -f
mv = mv -f

# define object files.
obj = $(src:.c=.o) $(cxxsrc:.cpp=.o) $(asrc:.s=.o)
obj_modules = $(c_modules:.c=.o) $(cxx_modules:.cpp=.o)

# define listing files.
lst = $(asrc:.s=.lst) $(cxxsrc:.cpp=.lst) $(src:.c=.lst)

# combine necessary flags , optional flags.
# add target processor flags.
all_cflags = $(cflags) -mmcu=$(mcu)
all_cxxflags = $(cxxflags) -mmcu=$(mcu)
all_asflags = -x assembler-with-cpp $(asflags) -mmcu=$(mcu)
all_ldflags = $(ldflags) -mmcu=$(mcu)

# default target.
all: applet_files build sizeafter

build: elf hex

applet/main.o:
test -d applet || mkdir applet
echo '#include "arduino.h"' > applet/main.cpp
cat $(target).ino >> applet/main.cpp
cat $(arduino)/main.cpp >> applet/main.cpp
$(cxx) -c $(all_cxxflags) applet/main.cpp -o applet/main.o

elf: applet/main.elf
hex: applet/main.hex
eep: applet/main.eep
lss: applet/main.lss
sym: applet/main.sym

# program device.
upload: applet/main.hex
$(avrdude) $(avrdude_flags) $(avrdude_write_flash)

# display size of file.
hexsize = $(size) --target=$(format) applet/main.hex
elfsize = $(size)  applet/main.elf
sizebefore:
@if [ -f applet/main.elf ]; echo; echo $(msg_size_before); $(hexsize); echo; fi

sizeafter:
@if [ -f applet/main.elf ]; echo; echo $(msg_size_after); $(hexsize); echo; fi


# convert elf coff use in debugging / simulating in avr studio or vmlab.
coffconvert=$(objcopy) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000


coff: applet/main.elf
$(coffconvert) -o coff-avr applet/main.elf main.cof


extcoff: main.elf
$(coffconvert) -o coff-ext-avr applet/main.elf main.cof


.suffixes: .elf .hex .eep .lss .sym

.elf.hex:
$(objcopy) -o $(format) -r .eeprom $< $@

.elf.eep:
$(objcopy) -o $(format) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--no-change-warnings \
--change-section-lma .eeprom=0 $< $@

# create extended listing file elf output file.
.elf.lss:
$(objdump) -h -s $< > $@

# create symbol table elf output file.
.elf.sym:
$(nm) -n $< > $@

# link: create elf output file library.
#applet/$(target).elf: $(target).pde applet/core.a
applet/main.elf: applet/main.o applet/core.a
$(ld) $(all_ldflags) -o $@ applet/main.o applet/core.a

applet/core.a: $(obj_modules)
@for in $(obj_modules); echo $(ar) rcs applet/core.a $$i; $(ar) rcs applet/core.a $$i; done


# compile: create object files c++ source files.
.cpp.o:
$(cxx) -c $(all_cxxflags) $< -o $@

# compile: create object files c source files.
.c.o:
$(cc) -c $(all_cflags) $< -o $@


# compile: create assembler files c source files.
.c.s:
$(cc) -s $(all_cflags) $< -o $@


# assemble: create object files assembler source files.
.s.o:
$(cc) -c $(all_asflags) $< -o $@


# automatic dependencies
%.d: %.c
$(cc) -m $(all_cflags) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@

%.d: %.cpp
$(cxx) -m $(all_cxxflags) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@


# target: clean project.
clean:
$(remove) applet/main.hex applet/main.eep applet/main.cof applet/main.elf \
applet/main.map applet/main.sym applet/main.o applet/main.lss applet/core.a \
$(obj) $(lst) $(src:.c=.s) $(src:.c=.d) $(cxxsrc:.cpp=.s) $(cxxsrc:.cpp=.d) \
applet/main.cpp

.phony: all build elf hex eep lss sym program coff extcoff clean applet_files sizebefore sizeafter

#include $(src:.c=.d)
#include $(cxxsrc:.cpp=.d)




Arduino Forum > Using Arduino > Programming Questions > Makefile help please :-(


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial