forked from buserror/touchstream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.common
67 lines (58 loc) · 1.81 KB
/
Makefile.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
# Makefile.common
#
# Copyright 2011 Michel Pollet <buserror@gmail.com>
#
# This file is part of touchstream.
#
# touchstream 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 3 of the License, or
# (at your option) any later version.
#
# touchstream is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with touchstream. If not, see <http://www.gnu.org/licenses/>.
DESTDIR ?= /usr/local
CFLAGS ?= -O2 -g -Wall #-Werror
OBJ := obj-$(shell $(CC) -dumpmachine)
EXTRA_CFLAGS += --std=gnu99
EXTRA_CFLAGS += -ffunction-sections -fdata-sections
EXTRA_CFLAGS += ${patsubst %,-I%,${subst :, ,${IPATH}}}
#
# Generic rules
#
$(OBJ):
@mkdir -p $(OBJ)
$(OBJ)/%.a :
ifeq ($(V),1)
$(AR) cru $@ $^
ranlib $@
else
@echo " LIB ${@}"
@$(AR) cru $@ $^ \
|| echo Error: $(AR) cru $@ $^
endif
${OBJ}/%.o: %.c
ifeq ($(V),1)
${CC} -MD ${EXTRA_CFLAGS} ${CPPFLAGS} ${CFLAGS} ${CFLAGS_TARGET} -c -o ${@} ${<}
else
@echo " CC ${<}"
@${CC} -MD ${EXTRA_CFLAGS} ${CPPFLAGS} ${CFLAGS} ${CFLAGS_TARGET} -c -o ${@} ${<} \
|| echo Error: ${CC} -MD ${EXTRA_CFLAGS} ${CPPFLAGS} ${CFLAGS} ${CFLAGS_TARGET} -c -o ${@} ${<}
endif
${OBJ}/%.bin:
ifeq ($(V),1)
${CC} -o ${@} ${^} ${LDFLAGS_TARGET} ${EXTRA_LDFLAGS} ${LDFLAGS}
else
@echo " LD ${*}"
@${CC} -o ${@} ${^} ${LDFLAGS_TARGET} ${EXTRA_LDFLAGS} ${LDFLAGS} \
|| echo Error: ${CC} -o ${@} ${^} ${LDFLAGS_TARGET} ${EXTRA_LDFLAGS} ${LDFLAGS}
endif
clean:
rm -rf obj-*
# Include autogenerated dependencies
-include ${OBJ}/*.d