forked from akshmakov/eeshow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.c-common
executable file
·80 lines (62 loc) · 2.02 KB
/
Makefile.c-common
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#
# common/Makefile.c-common - Common Makefile items for C
#
# Written 2013-2016 by Werner Almesberger
# Copyright 2013-2016 by Werner Almesberger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
SHELL = /bin/bash
OBJ_SUFFIX ?= .o
# Make sure "all" comes first
all::
# ----- YACC settings ---------------------------------------------------------
YACC = bison -y
YYFLAGS = -v
# ----- Verbosity control -----------------------------------------------------
CC_normal := $(CC)
AS_normal := $(AS)
CPP_normal := $(CPP)
LEX_normal := $(LEX)
YACC_normal := $(YACC)
DEPEND_normal = $(CPP_normal) $(CFLAGS) -MM -MG
ifeq ($(V),1)
CC = $(CC_normal)
AS = $(AS_normal)
LEX = $(LEX_normal)
YACC = $(YACC_normal)
BUILD =
DEPEND = $(DEPEND_normal)
else
CC = @echo " CC " $@ && $(CC_normal)
AS = @echo " AS " $@ && $(AS_normal)
LEX = @echo " LEX " $@ && $(LEX_normal)
YACC = @echo " YACC " $@ && $(YACC_normal)
BUILD = @echo " BUILD " $@ &&
DEPEND = @$(DEPEND_normal)
endif
# ----- Dependencies ----------------------------------------------------------
-include $(OBJS:$(OBJ_SUFFIX)=.d)
MKDEP = \
$(DEPEND) $< | \
sed \
-e 's|^$(basename $(notdir $<))\$(OBJ_SUFFIX):|$@:|' \
-e '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
-e '$${g;p;}' \
-e d >$(basename $@).d; \
[ "$${PIPESTATUS[*]}" = "0 0" ] || \
{ rm -f $(basename $@).d; exit 1; }
#
# See
# http://stackoverflow.com/questions/5229561/gnu-make-generating-automatic-dependencies-with-generated-header-files
#
.PHONY: generated_headers
%$(OBJ_SUFFIX): %.c | generated_headers
$(CC) $(CFLAGS) -c -o $@ $<
$(MKDEP)
# ----- Cleanup ---------------------------------------------------------------
clean::
rm -f $(OBJS) $(OBJS:$(OBJ_SUFFIX)=.d)