View Single Post
  #5   Spotlight this post!  
Unread 24-04-2004, 21:16
jdong jdong is offline
Linux Nerd
AKA: John D
#0245 (Adam-Bots)
Team Role: Programmer
 
Join Date: Apr 2004
Location: Rochester, MI
Posts: 98
jdong will become famous soon enoughjdong will become famous soon enough
Re: Makefile for programming under Windows with cygwin

During Nationals, I modded this makefile, and mine is a bit 'fancier'. It's well-commented, and needs a bit of editing to remove 245-specific code (i.e. trig.c arm.c arm.h, etc)


Oh yeah, try "make me a sandwich". DONT ASK!!!

Code:
#Team 245 Adam-Bots
#Makefile -- Designed to make the robot's .hex file under Cygwin
#Created by John Dong -- Team 245 jdong@wideopenwest.com
# Based on WUN's code on ChiefDelphi

MCC18=/cygdrive/c/mcc18/bin/mcc18.exe #Don't change
PIC=18F8520 #Also don't change -- will cause compiles to fail.
 


#Common Arg flags
#-D_FRC_BOARD -- Enables FIRST extensions -- must be on!
#Oi -- Enable Integer Promotions
#w  -- warning level (3 highest, 1 lowest)
#O-  -- Disable all optimizations
#pa=? -- Procedural abstraction passes.

ARGS=-D_FRC_BOARD -Oi -w3  -pa=3


LINKER=/cygdrive/c/mcc18/bin/mplink.exe
IFILOAD=/cygdrive/c/Program\ Files/IFI_Loader/IFI_Loader.exe

#Change this to the place where your code is stored (to windows - you cant use the cyg directory)			
#NOTE -- Add an ending \\ to the folder name -- required later!
CODE_PATH=C:\\jd-code-cygwin\\
	#you gotta have the two \\ or make thinks they are escape codes

#OPTIONAL -- Recompile when hfiles change.
INCLUDE_FILES=arm.h bits.h deadreckon.h delays.h ifi_aliases.h ifi_picdefs.h ifi_utilities.h interrupts.h printf_lib.h pwm_curve.h trig.h user_routines.h
#You should not need to change the following two.
LIB_PATH=C:\\mcc18\\lib
INCLUDE_PATH=C:\\mcc18\\h

abcd:make

me:
	@echo "What kind?"
a:
	@echo "You're too slow....."
sandwich:
	@echo "Here you go!"
	@echo -n
	@echo -n
	@echo " =========      <-- BREAD"
	@echo "~~~~~~~~~~~     <-- mmm, CHEESE"
	@echo " ^^^^^^^^^      <-- Use your imagination..."
	@echo " *********      <-- Like this could be meat..."
	@echo " =========      <-- well, at least this is BREAD"
	@echo -n
	@echo -n


#Default -- make the hex file
make: FrcCode.hex

#Saves a timestamped tbz2 backup
backup: FrcCode.hex
	./backup.sh
#Checks default libs
check:
	./chklib.sh
#Remove all the individual file backup (The files ending with ~)
#NOTE that this does NOT remove your tbz2 backups!
clean-backup-files:
	rm -rf *~

#Removes all compiled files from the directory
clean:
	rm -rf *.o Frccode.hex *.cod *.cof *.err *~ *.rej

#Remove hexfiles
nohex:
	rm -rf *.hex *.cod *.cof

auton_test:
	patch -f < auton-test.patch
auton_notest:
	patch -Rf < auton-test.patch
#These all start the IFI Loader.
safeload: prettycode clean check load

load: FrcCode.hex
	echo ${CODE_PATH}FrcCode.hex > /cygdrive/c/Program\ Files/IFI_Loader/LastHexFile.txt

	unix2dos /cygdrive/c/Program\ Files/IFI_Loader/LastHexFile.txt
 
	kill `ps -s | grep IFI_Loader`>crap > crap || true > crap > crap
	rm crap || true
	nice -n 5 $(IFILOAD) & 

prettycode:
	indent *.c *.h && rm *~

all: clean FrcCode.hex



FrcCode.hex :  ${INCLUDE_FILES} main.o user_routines_fast.o user_routines.o printf_lib.o ifi_utilities.o ifi_startup.o arm.o bits.o deadreckon.o interrupts.o pwm_curve.o trig.o
	$(LINKER) /l"$(LIB_PATH)" "18f8520user.lkr" "$(CODE_PATH)main.o" "$(CODE_PATH)user_routines_fast.o" "$(CODE_PATH)user_routines.o" "$(CODE_PATH)printf_lib.o" "$(CODE_PATH)ifi_utilities.o" "$(CODE_PATH)ifi_startup.o" "$(CODE_PATH)arm.o" "$(CODE_PATH)bits.o" "$(CODE_PATH)deadreckon.o" "$(CODE_PATH)interrupts.o" "$(CODE_PATH)pwm_curve.o" "$(CODE_PATH)trig.o" "$(CODE_PATH)FRC_library.lib" /m"FrcCode.map" /o"FrcCode.cof"



printf_lib.o : printf_lib.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "printf_lib.c" -fo="printf_lib.o" /i"$(INCLUDE_PATH)"

user_routines.o : user_routines.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "user_routines.c" -fo="user_routines.o" /i"$(INCLUDE_PATH)" $(ARGS)

user_routines_fast.o : user_routines_fast.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "user_routines_fast.c" -fo="user_routines_fast.o" /i"$(INCLUDE_PATH)" $(ARGS)

main.o : main.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "main.c" -fo="main.o" /i"$(INCLUDE_PATH)" $(ARGS)

ifi_utilities.o : ifi_utilities.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "ifi_utilities.c" -fo="ifi_utilities.o" /i"$(INCLUDE_PATH)" $(ARGS)

ifi_startup.o : ifi_startup.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "ifi_startup.c" -fo="ifi_startup.o" /i"$(INCLUDE_PATH)"$(ARGS)

arm.o : arm.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "arm.c" -fo="arm.o" /i"$(INCLUDE_PATH)" $(ARGS)

bits.o : bits.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "bits.c" -fo="bits.o" /i"$(INCLUDE_PATH)" $(ARGS)

deadreckon.o : deadreckon.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "deadreckon.c" -fo="deadreckon.o" /i"$(INCLUDE_PATH)" $(ARGS)

interrupts.o : interrupts.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "interrupts.c" -fo="interrupts.o" /i"$(INCLUDE_PATH)" $(ARGS)

pwm_curve.o : pwm_curve.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "pwm_curve.c" -fo="pwm_curve.o" /i"$(INCLUDE_PATH)" $(ARGS)

trig.o : trig.c ${INCLUDE_FILES}
	$(MCC18) -p=$(PIC) "trig.c" -fo="trig.o" /i"$(INCLUDE_PATH)" $(ARGS)
__________________
John Dong
Co-Captain, Webmaster / Programmer
Team 245 -- Rochester Adams Robotics