Go to Post After assisting with the animation last year I realized how cool and useful Inventor was and I started flirting with it. Half a year later I think I have lost all possibility of ever having a girlfriend, and frankly I don't care because I would definately bare the child of this program. - negfrequency [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-01-2007, 04:27
fauxnominal fauxnominal is offline
Registered User
no team
 
Join Date: Jan 2007
Location: n/a
Posts: 7
fauxnominal is an unknown quantity at this point
Makefile

this is on a linux box and i am running the compiler under wine.

i'm trying to make a Makefile that automates building individual parts of the robot code. for example, if i want to just compile the adc code, i can enter make adc in the toplevel src directory.

the problem is, i can't seem to find the equivalent of gcc's -c in the 2.4 compiler (which, for those unfamiliar, allows for compilation, but no linking to occur).

i think that's the issue that's causing compiler errors like this:
Z:\home\fauxnominal\robotics\src\adc\adc.c:0:Error : syntax error

any ideas? i looked at the compiler's --help options, but didn't see anything that worked.
  #2   Spotlight this post!  
Unread 13-01-2007, 19:26
fauxnominal fauxnominal is offline
Registered User
no team
 
Join Date: Jan 2007
Location: n/a
Posts: 7
fauxnominal is an unknown quantity at this point
Re: Makefile

i followed the directions here:
http://www.chiefdelphi.com/forums/sh...ad.php?t=36377

that didn't seem to work either. i still get that error:
Z:\home\fauxnominal\robotics\src\adc\adc.c:0:Error : syntax error

i'm fairly sure it's not an issue with Kevin Watson's code as line 0 (does that imply line 1?) is a comment which can't possibly have a syntax error

it's quite frustrating, any ideas?
  #3   Spotlight this post!  
Unread 13-01-2007, 19:33
chris31 chris31 is offline
Team 2021 Captain
AKA: Chris Davidson
FRC #2021 (FA Robotics)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2006
Location: Atlanta, GA/ Fredericksburg,VA
Posts: 949
chris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond reputechris31 has a reputation beyond repute
Send a message via AIM to chris31
Re: Makefile

Give this a try for making your makefile
PHP Code:
#!/usr/bin/env python

#Auto Makefile Generator
#Copyright under terms of GPL
#Based on Team 245's old Makefile....
#        Copyright (C) 2005  Team 245
#
#        This program is free software; you can redistribute it and/or modify
#        it under the terms of the GNU General Public License as published by
#        the Free Software Foundation; either version 2 of the License, or
#        (at your option) any later version.
#
#        This program is distributed in the hope that it will be useful,
#        but WITHOUT ANY WARRANTY; without even the implied warranty of
#        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#        GNU General Public License for more details.
#
#        You should have received a copy of the GNU General Public License
#        along with this program; if not, write to the Free Software Foundation,
#        Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


import os

DEBUG
=False
VERSION
="0.1.92 (0.2 beta 3)"

def printGPLBanner():
    print 
"Makefile Generator, version "+VERSION+", Copyright (C) 2005 Adam-Bots"
    
print "This software comes with ABSOLUTELY NO WARRANTY"
    
print "This is free software, and you are welcome to redistribute it under certain conditions; See the accompanying license for details"
    
def isCygwin():
    
import os;
    return 
os.platform=='cygwin'

def isLinux():
    
import os;
    return 
os.platform.beginswith('linux')

def mccPath():
    
#Find path to the MCC folder.
    
if isCygwin():
        
pass
def sprint
(msg,level=0):
    
# Prints a message of a given verbosity:
        #Level 0 : Print regardless of status
        #Level 1 : Print if DEBUG is set
    
if level == 0:
        print 
msg
    elif level 
== 1:
        if 
DEBUG:
            print 
"DEBUG:",msg
    
else:
        print 
msg
def mccCommand
():
    return 
"mcc18"
def mccArgs():
    return 
"-D_FRC_BOARD -w3 pa=3 -O+ -nw=2066"
def linkerCommand():
    return 
"mplink"
def mp2hexCommand():
    return 
"mp2hex"
def ifiLoaderCommand():
    return 
"picloader_textmode"
def ifiSerialDevice():
    return 
"/dev/ttyS0"
def ifiReadLogfile():
    return 
"./read.log"
def codePath():
    
unixish_path="Z:"+os.getcwd()+"//"
    
return unixish_path.replace("/","\\")
def libPath():
    return 
"/opt/mcc18/lib"
def includePath():
    return 
"/opt/mcc18/h"
def includePathWindows():
    return 
"Z:\\\\opt\\\\mcc18\\\\h"

printGPLBanner();
print
print
print

sprint("Opening the Makefile",1)
print
outfile=open('Makefile','w')
outfile.write('#This is automatically generated by the configure.py script\n#Keep your dirty hands off');
outfile.write("\n")
outfile.write('#Run ./configure.py to generate a fresh one.')
outfile.write("\n")
outfile.write('MCC18='+mccCommand())
outfile.write("\n")
outfile.write("PIC=18F8722 # Don't change")
outfile.write("\n")
outfile.write("ARGS="+mccArgs())
outfile.write("\n")
outfile.write("LINKER="+linkerCommand())
outfile.write("\n")
outfile.write("MP2HEX="+mp2hexCommand())
outfile.write("\n")
outfile.write("IFILOAD="+ifiLoaderCommand())
outfile.write("\n")
outfile.write("SERIAL_DEV="+ifiSerialDevice())
outfile.write("\n")
outfile.write("READLOG="+ifiReadLogfile())
outfile.write("\n")
outfile.write("LIB_PATH="+libPath())
outfile.write("\n")
outfile.write("CODE_PATH="+codePath())
outfile.write("\n")
outfile.write("INCLUDE_PATH="+includePath())
outfile.write("\n")
outfile.write("INCLUDE_PATHW="+includePathWindows())
outfile.write("\n")
outfile.write("\n\n\n\n")


sprint("Enumerating Target Object Files...")
import os;
all_targets=""
pipe=os.popen("find . -maxdepth 1 -name \"*.c\" | gawk '{gsub(/\\.c/,\".o\");print}' | uniq",'rt'
line=pipe.readline()
while 
line != "":
    
all_targets+=line[2:-1]
    
all_targets+=" "
    
line=pipe.readline()

all_targets.rstrip()

outfile.write("ALL_TARGETS="+all_targets);
outfile.write("\n")
sprint("Enumerating Header Files...")

pipe=os.popen("find . -name \"*.h\"",'rt')
line=pipe.readline()
headers=""
while line != "":
        
headers+=line[2:-1]
        
headers+=" "
        
line=pipe.readline()
headers.rstrip()


outfile.write("INCLUDE_FILES="+headers);
outfile.write("\n")
outfile.write("############ Targets: ")
outfile.write("\n")
outfile.write("default: FrcCode.hex")
outfile.write("\n")

sprint("Writing static targets...")
outfile.write("""
#Remove all the individual file backup (The files ending with ~)
#NOTE that this does NOT remove your tbz2 backups!
clean-backup-files:
    @echo -e "
Removing all the backup files your annoying editor makes..."
    @find . -name "
*~" |xargs rm -f

#Removes all compiled files from the directory
clean: clean-backup-files clean-deps nohex
    @echo -e "
Cleaning compiler intermediate files..."
    @rm -rf *.o *.err

#Remove deps folder
clean-deps:
    @echo -e "
Cleaning dependency folder..."
    @rm -rf .deps
    @mkdir .deps
    @touch .deps/dummy

#Remove hexfiles
nohex:
    @echo -e "
Cleaning linker output and hex files..."
    @rm -rf *.hex *.cod *.cof

#These all start the IFI Loader.
safeload: prettycode clean check load
load: FrcCode.hex
    $(IFILOAD) FrcCode.hex $(SERIAL_DEV)

read:
    @echo -e "
Monitoring $(SERIAL_DEV) for data"
    @echo -e "
Output will also be logged to $(READLOG)"
    @echo -e "
---------"
    @cat $(SERIAL_DEV) | tee $(READLOG) || /bin/true
    
    
prettycode:
    @echo -e "
Using indent to autoformat your .and .h files..."
    @indent *.c *.h
all: clean FrcCode.hex
%.o: %.c
    @echo -e "
Compiling $@..."
    @echo -e "
1.   Checking Dependencies for $@"
    @cpp -nostdinc -isystem $(INCLUDE_PATH) -M -MP $< -MF .deps/$*.deps
    @echo -e "
2.   Launching Compiler..."
    @echo -n "
A thought to keep you occupied:  "
    @fortune -s || echo "
GET FORTUNE"
    @$(MCC18) -p=$(PIC) -fo $@ $< /i\\""$(INCLUDE_PATHW)"
\\" $(ARGS) 
    @echo -e "
Done with $@."




FrcCode.hex :  $(ALL_TARGETS) $(INCLUDE_FILES)
    @echo -e "
Linking..."
    $(LINKER) /l\\""$(LIB_PATH)"
\\" \\""18f8722.lkr"\\" $(ALL_TARGETS) \\""$(CODE_PATH)FRC_library.lib"\\" /m\\""FrcCode.map"\\" /o\\""FrcCode.cof"\\"
    $(MP2HEX) FrcCode.cof



.deps/*: 
    @echo -e "
Creating Dependency Makefiles..."
    @mkdir -p .deps
    @touch .deps/dummy
    @echo -e "
Done!"

include .deps/*
"""
)
print
print

sprint("Makefile is generated, setting up working directory....")
os.system('rm -rf .deps')
os.system('mkdir .deps')
os.system('touch .deps/dummy')

print
print
print

sprint("Finished. To build, run 'make'"
  #4   Spotlight this post!  
Unread 16-01-2007, 02:37
fauxnominal fauxnominal is offline
Registered User
no team
 
Join Date: Jan 2007
Location: n/a
Posts: 7
fauxnominal is an unknown quantity at this point
Re: Makefile

hi chris31,

i appreciate your help; however, that didn't work either. i still get the same error message (the fact that i get a compiler error message tells you that i didn't have any issues setting that stuff up).

any other thoughts? i doesn't even make sense that a line 0 would be at fault for a compilation.
  #5   Spotlight this post!  
Unread 16-01-2007, 16:04
ScottWalls ScottWalls is offline
Registered User
FRC #0245 (AdamBots)
Team Role: Leadership
 
Join Date: Mar 2006
Rookie Year: 2003
Location: Rochester Hills
Posts: 31
ScottWalls will become famous soon enoughScottWalls will become famous soon enough
Re: Makefile

What version of MCC are you using? What version of GCC are you using? Also, if you could post just a little bit more of the method you're using to do this, I might be able to shed some more light.
  #6   Spotlight this post!  
Unread 17-01-2007, 09:41
rodgadashruba rodgadashruba is offline
Registered User
FRC #0611
 
Join Date: Jan 2006
Location: McLean
Posts: 17
rodgadashruba is an unknown quantity at this point
Re: Makefile

what was posted was not a Makefile, but a python script that will create a make file. Just cpy all of that, save it as configure.py . move it into your project directory, and in the terminal run python configure.py

if u did that, then please elaborate with what you did exactly
  #7   Spotlight this post!  
Unread 17-01-2007, 13:20
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Makefile

Lines start at 1. The compiler uses "syntax error" (w/o an error number) to mean "I'm confused. I'm giving up." Line 0 means before it even really starts reading the file. Maybe a permissions issue?

Check line endings, although that should not affect it. Also try running it through cpp18 (the preprocessor) and see if it tosses an error. (It probably won't but it's worth a shot.)

Unlike gcc, MCC18 requires separate compiling and linking stages. The linker is mplink.
  #8   Spotlight this post!  
Unread 18-01-2007, 03:15
fauxnominal fauxnominal is offline
Registered User
no team
 
Join Date: Jan 2007
Location: n/a
Posts: 7
fauxnominal is an unknown quantity at this point
Re: Makefile

hi all, thanks for the input.

as far as what version of the compiler i'm using, like i said before, i am using the 2.4 compiler using wine.

the makefile was properly generated using the python script, and like i said the makefile also threw out the same error. if i try to compile by hand without a makefile, then i still get the same error.

the preprocessor doesn't throw any errors out.

i'm much more familiar with gcc, and being the purist that i am, tend to compile source files into individual object files and then link them anyway, so having a separate compiler and a separate linker is no issue.

i have a feeling this has to do with line endings more than anything else, but how would i fix the line endings on linux in emacs?
  #9   Spotlight this post!  
Unread 21-01-2007, 00:00
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Makefile

The files come with windows line endings from IFI. I would think that emacs at least preserves line endings, although I don't actually use it.
  #10   Spotlight this post!  
Unread 21-01-2007, 16:31
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Makefile

I got those line 0 errors with wine 0.9.22 that comes with Ubuntu Edgy. When I installed the latest 0.9.29, it works.
  #11   Spotlight this post!  
Unread 21-01-2007, 18:16
ScottWalls ScottWalls is offline
Registered User
FRC #0245 (AdamBots)
Team Role: Leadership
 
Join Date: Mar 2006
Rookie Year: 2003
Location: Rochester Hills
Posts: 31
ScottWalls will become famous soon enoughScottWalls will become famous soon enough
Re: Makefile

Yes, that's true. There is a known bug with wine 0.9.22.

Which version of WINE are you using, what version of Linux, etc.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code::Blocks IDE interface (Tutorial/Makefile) Cjmovie Programming 8 25-01-2008 02:18
Using Eclipse IDE & makefile as MPLAB replacement RoboPhantom Programming 0 27-02-2005 19:05
Makefile and stripped down compiler Venkatesh Programming 0 09-01-2005 18:55
Adambots-Live Linux Makefile -- version 0.1 RELEASE jdong Programming 4 17-11-2004 18:41
Makefile for programming under Windows with cygwin wun Programming 17 20-09-2004 00:44


All times are GMT -5. The time now is 01:19.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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