Makefile学习一

[pillar@apus tab]$ tree
.
|-- Makefile
|-- include
|   `-- queue.h
`-- src
    `-- queue.c

2 directories, 3 files

include/queue.h

  1 #ifndef __QUEUE_H_
  2 #define __QUEUE_H_
  3 #include<stdio.h>
  4 
  5 #endif

src/queue.c

  1 #include"queue.h"
  2 int main()
  3 {
  4 #ifdef DEBUG
  5         printf("this is DEBUG_FLAG\n\n");
  6 #else
  7         printf("this is FLAG\n\n");
  8 #endif
  9         return 0;
 10 }
Makefile

vpath %.c src
vpath %.h include
#VPATH = src include
CFLAGS += -D DEBUG
CC = gcc
#you can try ifeq!!
#ifneq ($(CC),gcc)
#print:
#       echo "haha,this is gcc"
#else
#print:
#       echo "gcc is not here!!"
#endif
#BOOL=
#FOOL=$(BOOL)
#ifdef BOOL
#print1:
#       echo "haha,this is FOOL"
#else
#print1:
#       echo "haha,this is BOOL"
#endif
main:queue.o
        gcc   -o $@  queue.o
queue.o:queue.c queue.h
        gcc $(CFLAGS) -c $<  -Iinclude 

.PHONY:clean
clean:
        -rm queue.o main


你可能感兴趣的:(Makefile学习一)