Makefiles

This is a discussion on Makefiles within the C Programming forums, part of the General Programming Boards category; Hello all o/, I'm starting to move some of my older projects from naf shellscripts which compile my code to ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    68

    Makefiles

    Hello all o/,

    I'm starting to move some of my older projects from naf shellscripts which compile my code to a naf Makefile which compiles the code. For some of the projects which don't use external libraries, it's easy. However for a few I'm stumped. I've got a workaround, but it's a pretty naf one.

    So, essentially. How can I add pkg-config variables to my makefile ?

    Code:
    # Makefile.
    #
    CC=gcc
    CFLAGS=-Wall -pedantic
    PKGCFG=`pkg-config --cflags --libs gtk+-2.0`
    # CC+=${PKGCFG}    # The evil workaround I mentioned.
    
    all: ExcuseGen
    ExcuseGen: main.o
    	${CC} -o ExcuseGen main.o ${PKGCFG}
     
    main.o: main.c
    
    clean:
    	rm -f ExcuseGen *.core *.o
    Any suggestions would be a great help!

  2. #2
    Registered User
    Join Date
    Dec 2003
    Posts
    68
    Fixed. I decided to not to bother with the seperation, and wrote the following instead:

    Code:
    # Makefile.
    #
    CC=gcc
    CFLAGS=-Wall -pedantic
    LIBS += `pkg-config --cflags --libs gtk+-2.0`
    
    all: ExcuseGen
    ExcuseGen: main.c
    	$(CC) $(CFLAGS) -o ExcuseGen main.c $(LIBS) 
     
    clean:
    	rm -f ExcuseGen *.core *.o

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefiles, GCC's -ggdb option, and Valgrind
    By Jesdisciple in forum C Programming
    Replies: 5
    Last Post: 03-14-2009, 05:25 PM
  2. Makefiles
    By TriKri in forum Windows Programming
    Replies: 3
    Last Post: 03-30-2008, 07:57 AM
  3. Benefits of makefiles
    By Ganoosh in forum C++ Programming
    Replies: 2
    Last Post: 06-27-2005, 10:42 PM
  4. programming linux with gcc, emacs, and makefiles
    By Captain Penguin in forum Linux Programming
    Replies: 1
    Last Post: 11-02-2002, 12:04 PM
  5. Help with Makefiles
    By WebmasterMattD in forum Linux Programming
    Replies: 3
    Last Post: 05-24-2002, 09:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21