Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Makefile for programming under Windows with cygwin (http://www.chiefdelphi.com/forums/showthread.php?t=25567)

wun 18-02-2004 20:11

Makefile for programming under Windows with cygwin
 
1 Attachment(s)
I have been forced into the unfortunate situation of having to program the robot under Windows this year. I also can not stand the MPLAB IDE. This is why I wrote this makefile, so I could program the robot with Vim, and use cygwin/make to compile it. (For those of you who don't know, cygwin allows you to use most common Linux commands from Windows. You can get it here: http://www.cygwin.com/)
If my server is up, you can see an pretty HTML version of the makefile here --> http://wolever.no-ip.com/makefile.html
If its down, I have attached the original makefile so you can use that.
You shouldent have to modify it too much - the only thing you will have to change for sure is the path to your code (unless you keep your code in c:\robotics\FrcCode\)
I hope this helps!

MikeDubreuil 21-04-2004 05:26

Re: Makefile for programming under Windows with cygwin
 
Very cool, thanks for you help guys.

Ryan M. 21-04-2004 06:57

Re: Makefile for programming under Windows with cygwin
 
Thanks a ton. I strongly disliked the IDE too, but never was able to write makefiles that worked for unknown reasons... :)

Astronouth7303 21-04-2004 07:30

Re: Makefile for programming under Windows with cygwin
 
I don't like MPLAB much, but it's good enough. (I've worked with worse; BrixCC, MSW LOGO, Notepad...). But I do need an excuse to learn Linux.

jdong 24-04-2004 21:16

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)


wun 29-04-2004 20:57

Re: Makefile for programming under Windows with cygwin
 
nice work *gives thumbs up*
When I get to it with my grade 9ns who I am teaching C (this year I was the only programmer on our team) I will fix up my version to support sandwitch and header files (I didnt do much work with header files, so I forgot I had to include them).
Im glad you guys like it thou

phrontist 29-04-2004 21:04

Re: Makefile for programming under Windows with cygwin
 
Very, very, nice work.

I should be able to convince the Windows-Nazi Administration at my school to LFS (yeah, I guess that's a verb now) the laptop they gave me.

If not, this will provide me solice.

Oh, and while I'm at it:

Emacs sucks

Anyone care to start the editor holy war thread? ;)

wun 29-04-2004 21:11

Re: Makefile for programming under Windows with cygwin
 
Quote:

Originally Posted by phrontist
Emacs sucks

Anyone care to start the editor holy war thread? ;)

I totally agree

Astronouth7303 30-04-2004 14:25

Re: Makefile for programming under Windows with cygwin
 
But I would love to scrape the Apple logo off and run Redhat. (And OS X is unix based)

jdong 09-05-2004 11:08

Re: Makefile for programming under Windows with cygwin
 
Quote:

Originally Posted by Astronouth7303
But I would love to scrape the Apple logo off and run Redhat. (And OS X is unix based)

Correction... OSX _IS_ Unix...

jdong 03-09-2004 11:33

Re: Makefile for programming under Windows with cygwin
 
In preparation for the new FIRST season, I'm rewriting the makefile to run under Linux, calling MCC with wine when necessary. I'm also working on a LiveCD that'll include the PBASIC Stamp editor and MCC (in some fashion) and wine.

Rickertsen2 03-09-2004 19:11

Re: Makefile for programming under Windows with cygwin
 
Quote:

Originally Posted by jdong
In preparation for the new FIRST season, I'm rewriting the makefile to run under Linux, calling MCC with wine when necessary. I'm also working on a LiveCD that'll include the PBASIC Stamp editor and MCC (in some fashion) and wine.

Now that would be NICEE!!!

Dave Flowerday 03-09-2004 22:32

Re: Makefile for programming under Windows with cygwin
 
Quote:

Originally Posted by jdong
I'm also working on a LiveCD that'll include the PBASIC Stamp editor and MCC (in some fashion) and wine.

Keep in mind that you would not be able to distribute such a CD if you finish it, since MCC is a commercial product that you're not allowed to redistribute (unless I'm mistaken).

Rickertsen2 04-09-2004 14:35

Re: Makefile for programming under Windows with cygwin
 
Quote:

Originally Posted by Dave Flowerday
Keep in mind that you would not be able to distribute such a CD if you finish it, since MCC is a commercial product that you're not allowed to redistribute (unless I'm mistaken).

It seems to me that we all have legit C18 licences and as long as we don't violate our licences he would not be doing anyhting illegal. Besides do you think any of us or anyone at microchip for that matter even care? We are not defrauding them of anyhting. *hides in fear of flames*

jdong 16-09-2004 21:38

Re: Makefile for programming under Windows with cygwin
 
Quote:

Originally Posted by Dave Flowerday
Keep in mind that you would not be able to distribute such a CD if you finish it, since MCC is a commercial product that you're not allowed to redistribute (unless I'm mistaken).


The version of C18 that they provided us (C-Bot) is a stripped version of mcc -- its hex files are IFI-specific -- they will not run on any old PIC18Fxxxx

Furthermore it does _NOT_ come with a license agreement on the CD. I've contacted both IFI and Microchip, asking about licensing & permission to distribute the .exe on a LiveCD.

jdong 16-09-2004 21:39

Re: Makefile for programming under Windows with cygwin
 
BTW, my Sourceforge project is called adambots-live, it'll host all this stuff once I finish, plus an RTOS, with Frc default code ported (likely to be based on Freertos).

Dave Flowerday 16-09-2004 21:59

Re: Makefile for programming under Windows with cygwin
 
Quote:

Originally Posted by jdong
The version of C18 that they provided us (C-Bot) is a stripped version of mcc -- its hex files are IFI-specific -- they will not run on any old PIC18Fxxxx

Can you provide a source for this information? I haven't seen anything yet that would lead me to that conclusion.
Quote:

Furthermore it does _NOT_ come with a license agreement on the CD. I've contacted both IFI and Microchip, asking about licensing & permission to distribute the .exe on a LiveCD.
I wouldn't get your hopes up. First, this page refers to your licensed copy of the compiler, and this page at IFI offers to sell you the Microchip compiler for $49.95. If they are willing to let you redistribute it, I think they would also offer it as a free download on their site. Unfortunately I don't have the documentation that came with our KOP last year, but I'd be a little surprised if there wasn't a license agreement in there some where (one of the manuals, perhaps?).

wun 20-09-2004 00:44

Re: Makefile for programming under Windows with cygwin
 
Quote:

Originally Posted by jdong
BTW, my Sourceforge project is called adambots-live, it'll host all this stuff once I finish, plus an RTOS, with Frc default code ported (likely to be based on Freertos).

While I'm not too sure of the whole MCC legality issue, but I don't think hosting the project on SourceForge would be quite appropriate. I do think this CD is a *VERY* good idea thou, and I don't think IFI or the microchip guys would have TOO much of a problem if you just distributed the CD around FIRST (after all, we all have a copy of the software).
Alternately, what you could do (and I have seen done before) is distribute all the tools you would need to build the CD image, just leave out the MCC/IFI binaries. Then, when people want to make it, they put in their own, build the ISO and everyone is happy. Sort of like what GeeXBox does.
Oh, and if there is anything I could do to help make this CD, please tell me. I would love to be a part of it (I have always been a big fan of Linux live-on-cd and I have been toying with the idea of making my own for a while now)


All times are GMT -5. The time now is 15:47.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi