Thread: makefile

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    35

    makefile

    heya,

    i have a makefile which is pasted below. on execution i get the following:

    -bash-2.05b$ makefile
    ./makefile: line 1: CC: command not found
    ./makefile: line 2: CFLAGS: command not found
    ./makefile: line 3: LDFLAGS: command not found
    ./makefile: line 4: SOURCE: command not found
    ./makefile: line 5: OBJECTS: command not found
    ./makefile: line 6: PROGRAM: command not found
    ./makefile: line 1: PROGRAM: command not found
    ./makefile: line 8: all:: command not found
    ./makefile: line 1: PROGRAM: command not found
    ./makefile: line 1: OBJECTS: command not found
    ./makefile: line 1: CC: command not found
    ./makefile: line 1: OBJECTS: command not found
    ./makefile: line 1: CFLAGS: command not found
    ./makefile: line 1: LDFLAGS: command not found
    ./makefile: line 1: PROGRAM: command not found
    ./makefile: line 11: -o: command not found
    ./makefile: line 13: fg: no job control
    ./makefile: line 14: syntax error near unexpected token `newline'
    ./makefile: line 14: ` $(CC) $(CFLAGS) -c $

    anyone got any ideas what may be causing this?

    im trying to run the makefile on both unix and linux.

    thanks in adv.

    -twan

    Code:
    CC = g++
    CFLAGS = -ansi -g -pedantic -Wall -Wno-missing-braces
    LDFLAGS =  -lsocket -lnsl -lm
    SOURCE = .cc .h
    OBJECTS = display.o filereader.o program.o
    PROGRAM = pguide
    
    all:    $(PROGRAM)
    
    $(PROGRAM):    $(OBJECTS)
    $(CC) $(OBJECTS) $(CFLAGS) $(LDFLAGS) -o $(PROGRAM)
    
    %.o:    %.cc %.h
    $(CC) $(CFLAGS) -c $<
    
    clean:
    rm -f $(PROGRAM) *.o
    
    tarfile:
    rm -f $(TARFILE)
    tar cf $(TARFILE) $(SOURCE) Makefile

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    from this:
    -bash-2.05b$ makefile

    ....it looks to me like you're trying to execute the make file.

    try:
    prompt>make
    or
    prompt>make -f my_make_file
    in the directory that the makefile is in


    edit: if the above is correct, you will probably want to make "makefile" a non-executable - however, keeping it executable you MIGHT be able to put #!/usr/bin/make in the first line of your file and then executing it, but this is just a guess.
    Last edited by misplaced; 04-08-2005 at 12:17 AM.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    35
    its sorted,

    thanks anyways/

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    For anyone who is wondering:

    The problem with the above make file is that the macros aren't being assigned to correctly. In a makefile you assign to a macro using :=
    Example:
    Code:
    CC := g++
    CCOPS := -Wall -ansi -pedantic

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 11:50 PM
  3. unix makefile won't work but works in Dev C++
    By jk1998 in forum C++ Programming
    Replies: 1
    Last Post: 06-09-2007, 03:54 PM
  4. makefile blues....
    By WaterNut in forum C Programming
    Replies: 6
    Last Post: 05-30-2005, 08:22 PM
  5. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM