forked from yeasy/code_snippet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.template
45 lines (37 loc) · 959 Bytes
/
Makefile.template
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
# This is a Makefile template.
# Feel free to distribute or modify the code.:)
# Version: 0.2
# Author: Baohua Yang@THU
# Created: Sep 1, 2008
# Updated: May 31, 2011
CC=gcc
INCLUDES=-I./ -I/usr/include
CFLAGS=$(INCLUDES) -O2 -Wall -g
LDFLAGS=-L/usr/lib -lpcap -lnsl -lm -lpthread
SRCS=$(wildcard *.c)
#SRCS=source.c
OBJS=$(patsubst %.c,%.o, $(SRCS))
DEPS=$(patsubst %.c,%.d, $(SRCS))
TARGET=prog
RM=rm -f
INSTALL_DIR = /usr/bin
all: $(DEPS) $(TARGET)
#all:$(TARGET)
################ below needs no change in most case ################
$(TARGET): $(OBJS)
$(CC) -o $(TARGET) $(OBJS) $(LDFLAGS)
%.o: %.c
$(CC) -c $< -o $@ $(CFLAGS)
%: %.o
$(CC) $< -o $@ $(LDFLAGS)
%.d: %.c
$(CC) -MM $(CFLAGS) $< >$@.$$$$;\
sed 's,\($*\)\.o[ :]*,\1.o $@: ,g' < $@.$$$$ > $@;\
$(RM) $@.$$$$;
.PHONY: all clean install uninstall
clean:
$(RM) $(TARGET) *.o *.bak *.c~ *.h~ *.d
install:
cp -f $(TARGET) $(INSTALL_DIR)/
uninstall:
rm -f $(INSTALL_DIR)/$(TARGET)