-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.prg
53 lines (36 loc) · 1.14 KB
/
Makefile.prg
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
46
47
48
49
50
51
52
# makefile template for creating C programs
#################################################################
# sources & dependencies
SRCS := $(wildcard *.c)
HDRS := $(wildcard *.h)
DEP_IN = ${SRCS} ${HDRS}
OBJS := $(patsubst %.c,%.o,$(SRCS))
#################################################################
default: ${NAME}
${NAME}: ${OBJS}
${CC} ${CFLAGS} ${LDFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS}
#################################################################
# common rules
%.o: %.c
${CC} ${CFLAGS} ${INCLUDES} -c $<
.PHONY: install install-static install-shared install-headers install-dirs clean proper
proper: clean
-@rm -f tags ID
clean:
-@rm -f ${NAME} *.o *.d core core.* *~ Makefile.deps
ifneq ($(MAKECMDGOALS),proper)
ifneq ($(MAKECMDGOALS),clean)
-include $(SRCS:.c=.d)
endif
endif
%.d: %.c
@$(CC) -M $(CFLAGS) $(INCLUDES) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
#################################################################
# instalation
install: ${NAME} install-dirs
$(install-bin) $(NAME) $(bin-dir)
install-dirs: $(bin-dir)
$(bin-dir):
mkdir -p $(bin-dir)