ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Makefile 예시문
    프로그래밍/Etc 2014. 11. 21. 12:51
    728x90
    반응형

    CC          =   gcc -Wall -fPIC
    PAKAGE   =   /home/package/package-name

    EPDIR  = ../../passage/
    INCLUDE     =   -I$(PAKAGE )/include -I$(EPDIR)/include
    LDFLAGS     =   -L$(EPDIR)/lib -lep -L$(PAKAGE)/lib -led

    DEBUG  = -g

    RM          =   rm -f

    LIBDIR      =   ../lib
    BINDIR  = ../bin
    BINS  = sample

    CFLAGS      =   $(TRACE) $(DEBUG) $(OPTIMIZE) $(PROF) $(INCLUDE) $(USEMMAP)


    all: clean compile

    compile:
     for i in  $(BINS); do (  \
            $(CC) $(CFLAGS) -o $(BINDIR)/$$i $${i}.c $(LDFLAGS); \
        );  done

    valgrind:
     cat ../bin/sample.txt | LD_LIBRARY_PATH=$(PAKAGE)/lib:$(EPDIR)lib valgrind --track-origins=yes --leak-check=full --show-reachable=yes -v ../bin/sample

    clean:
     $(RM) *.o

    # vim: sw=4 ts=4 smarttab smartindent


     

     

     

    UTIL_DIR   = /util/
    UTIL_BINDIR  = $(UTIL_DIR)/bin
    UTIL_INCDIR  = $(UTIL_DIR)/include
    UTIL_LIBDIR  = $(UTIL_DIR)/lib
    UTILLIB   = -luf

     

    HTTP_DIR  = /httpd/

    HTTP_INCDIR  = $(HTTP_DIR)/include

    LIB_SRCS  = main.c code1.c code2.c code3.c code4.c


    LIB_OBJS  = $(LIB_SRCS:.c=.o)


    CC    = gcc -Wall -m64 -D_LARGEFILE64_SOURCE
    DEBUGFLAG  = -g
    OPTFLAG   =

    INC    = -I$(HTTP_INCDIR) -I$(UTIL_INCDIR)

    LIBS   = -L$(UTIL_LIBDIR) $(UFLIB) -lfl -lz -lc

     

     

    include ../../../version
    include Makefile.common


    LIB_SRCS        = $(wildcard *.c)
    LIB_OBJS        = $(LIB_SRCS:.c=.o)

    MODULE          = ../binary1 ../binary2 
    CFLAGS          = -c $(DEBUGFLAG) $(OPTFLAG) -fPIC $(INC) -D_LARGEFILE64_SOURCE

    .SUFFIXES: .c .o

    deault: all

    all: $(MODULE) ctags etags

    service:
     make all DEBUGFLAG="-g -DNDEBUG"


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

    $(MODULE): $(LIB_OBJS)
     $(CC) -shared -o $@ $(LIB_OBJS) $(LIBS)

    ctags:
     @find $(HTTP_INCDIR) ./ -name "*.[ch]*" | /usr/bin/ctags -L-


    etags:
     etags -R *


    clean:
     rm -f $(LIB_OBJS) $(MODULE) *.gcov *.gcda *.gcno sc.log app.info tags TAGS .gdbinit

    #EOF


     

     

    728x90
    반응형
Designed by Tistory.