Professional Web Applications Themes

Simple Makefile question - UNIX Programming

Hi. I just got a simple question about makefile There's file 1_1.c and INC, LIB declaration is fine. and i wanna make executable 1_1.out so this makefile will work fine OBJ = 1_1.out ..SUFFIXES: .c .o all:$(OBJ) ..c.o: $(CC) -c $(INC) $< ..o.out: $(CC) -o $ $? $(LIB) rm $< but what if i wanna make excutable 1_1 ? i mean, how can i set a implicit rule like .c.o when output file has no extension i already tested ..o: ..o.: but it doesn't work either, surely :(...

  1. #1

    Default Simple Makefile question

    Hi. I just got a simple question about makefile
    There's file 1_1.c and INC, LIB declaration is fine.
    and i wanna make executable 1_1.out
    so this makefile will work fine

    OBJ = 1_1.out

    ..SUFFIXES: .c .o

    all:$(OBJ)

    ..c.o:
    $(CC) -c $(INC) $<
    ..o.out:
    $(CC) -o $ $? $(LIB)
    rm $<

    but what if i wanna make excutable 1_1 ?
    i mean, how can i set a implicit rule like .c.o when output file has no
    extension
    i already tested

    ..o:
    ..o.:

    but it doesn't work either, surely :(
    bucket79 Guest

  2. #2

    Default Re: Simple Makefile question

    * Thus spoke bucket79 <net>:

    Hallo,
     
    [...] 

    Do you mean something like:

    | CC = g++
    | LD = g++
    | CC_FLAGS = -Wall -W -ggdb -pg -c -g -DNDEBUG
    | LD_FLAGS = -ggdb -o $(EXEC)
    | ##EXEC = 1_1.out
    | EXEC = 1_1
    |
    | SOURCES = foo.cpp bar.cpp
    |
    | ALL_OBJS = foo.o bar.o
    |
    | all : $(ALL_OBJS)
    | $(LD) $(LD_FLAGS) $(ALL_OBJS)
    |
    | %.o : %.c
    | $(CC) $(CC_FLAGS) $(LD) -o $ $<



    Wolfgang.
    --
    "I can remember the exact instant when I realized that a large part of my life
    from then on was going to be spent in finding mistakes in my own programs."
    -- Maurice Wilkes, 1947
    Wolfgang Guest

  3. #3

    Default Re: Simple Makefile question

    Wolfgang Kaufmann <com> wrote in message news:<theparallax.net>... 
    > [...] 
    >
    > Do you mean something like:
    >
    > | CC = g++
    > | LD = g++
    > | CC_FLAGS = -Wall -W -ggdb -pg -c -g -DNDEBUG
    > | LD_FLAGS = -ggdb -o $(EXEC)
    > | ##EXEC = 1_1.out
    > | EXEC = 1_1
    > |
    > | SOURCES = foo.cpp bar.cpp
    > |
    > | ALL_OBJS = foo.o bar.o
    > |
    > | all : $(ALL_OBJS)
    > | $(LD) $(LD_FLAGS) $(ALL_OBJS)
    > |
    > | %.o : %.c
    > | $(CC) $(CC_FLAGS) $(LD) -o $ $<
    >
    >
    >
    > Wolfgang.[/ref]


    thanks for reply
    but i wanna know the case not using variables like LD_FLAGS but
    implicty rule like .c.o

    ps. sorry, i posted my original message in wrong thread
    i pushed 'reply' button rather than 'post new message' ;(
    bucket79 Guest

Similar Threads

  1. Need Simple Answer to Simple Contribute/Firefox question
    By Adobe nickname in forum Macromedia Contribute General Discussion
    Replies: 2
    Last Post: February 13th, 06:59 PM
  2. Makefile question
    By Neil in forum UNIX Programming
    Replies: 7
    Last Post: February 24th, 05:02 PM
  3. Replies: 0
    Last Post: November 28th, 03:44 AM
  4. A basic Makefile question
    By Suzanne Baker in forum UNIX Programming
    Replies: 1
    Last Post: July 1st, 08:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139