forked from x746e/apue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.mk
39 lines (30 loc) · 789 Bytes
/
common.mk
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
.PHONY: test clean
all: $(PROGS) .gitignore
ifndef CFLAGS
CFLAGS = -std=c99 -ggdb3 -Wall
endif
INCLUDES = -I ../..
# Hack to overcome deficiency of `which` on solaris.
PYTHON = $(shell which python2.7 > /dev/null && which python2.7 || which python)
ifeq ($(shell uname),FreeBSD)
CFLAGS += -DBSD -D__BSD_VISIBLE
endif
ifndef CFILES
CFILES += ../../apue.3e/lib/error.c ../../common.c
endif
%: %.c
cc $(CFLAGS) $(INCLUDES) $(CFILES) $(CFILES_$@) $< -o $@ $(LDFLAGS) $(LDFLAGS_$@)
test:
if [ -f test.py ]; then \
PYTHONPATH=../.. $(PYTHON) test.py ; \
fi
.gitignore: $(PROGS)
touch .gitignore
for prog in $(PROGS); do \
if ! grep -sq ^$$prog\$$ .gitignore$ ; then \
echo $$prog >> .gitignore ; \
fi \
done
clean:
rm -f $(PROGS) $(CLEAN_FILES)
.SILENT: .gitignore