makefile compile gsl and numerical recipes

Discussion in 'Shell Script' started by habib_parisa, Aug 28, 2010.

  1. habib_parisa

    habib_parisa New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I am using Ubuntu-gcc and have a large C code which uses routines from numerical recipes and GNU scientific library.
    It needs a compilation compilation because each library, i.e. nr and GNUsl, needs its own flags for gcc.

    Therefore I use a makefile. It works well when the code is only one file. But when the code is distributed into many files it does not work!

    My question is that what should I write as the TARGET in the makefile. Either *.c or complete list of files do not work.

    The scripts is :

    CC = gcc
    CFLAGS = -Wall -lgsl -lgslcblas
    INSTALL_INCLUDEDIR = /usr/include/nr
    INSTALL_LIBDIR = /usr/lib/nr
    INSTALL_LIB = nr2c

    INCLUDEDIR = $(INSTALL_INCLUDEDIR)
    INCLUDES = -I$(INSTALL_INCLUDEDIR)
    LIBDIR = -L$(INSTALL_LIBDIR)

    LIBS = -l$(INSTALL_LIB) -lm

    #### What should I write here ????????? ####

    TARGET = build_grid.c cheb_2D_tring.c headers.c interp_tring.c nr_test.c polin2.c polint.c pre_proc.c read.c utilities.c

    OBJS = $(TARGET).o

    $(TARGET): $(OBJS)
    $(CC) $(OBJS) $(LIBDIR) $(LIBS) -o $(TARGET)

    .c.o:
    $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

    clean:
    rm -f $(OBJS) $(TARGET)
    Please help me !

    Thanks in advance.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice