-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsub.mk
executable file
·49 lines (38 loc) · 882 Bytes
/
sub.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
40
41
42
43
44
45
46
47
48
49
# directories
## the directory of "MyRecipes" project
NR_DIR=../../MyRecipes
## the directory of include file NR.h
NR_INC_DIR=$(NR_DIR)/include
## the directory of library file lNR.a
NR_LIB_DIR=$(NR_DIR)/lib
## include directory
INC_DIR=../include
# common source files in dir "src"
SRCFILES=$(wildcard ../src/*.c)
# flags
CFLAGS=-Wall -g -std=c11
IFLAGS=-I $(INC_DIR) -I $(NR_INC_DIR)
LFLAGS=-lNR -L $(NR_LIB_DIR) -lm
ALLFLAGS=$(SRCFILES) $(CFLAGS) $(IFLAGS) $(LFLAGS)
# gcc & python
CC=gcc
PYTHON=python
# source files
SRC=$(wildcard *.c)
# target
BIN=$(basename $(SRC))
# text files
TXT=$(subst .c,.txt,$(SRC))
#python scripts
PYFILES=$(wildcard *.py)
.PHONY:all bin run py test
all:$(BIN)
%:%.c
$(CC) -o $@ $< $(ALLFLAGS)
run:$(TXT)
$(TXT):%.txt:%
./$< > $@
py:
for pyfile in $(PYFILES); do $(PYTHON) $$pyfile; done
test:
@echo $(CC) -o $(BIN) $(SRC) $(ALLFLAGS)