-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (32 loc) · 759 Bytes
/
Makefile
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
# Name of the project
PROJ_NAME?=neural_network
# Application File
APP_FILE?=./examples/xor/xor.cpp
# .c files
C_SOURCE=$(wildcard ./src/*.cpp)
# .h files
H_SOURCE=$(wildcard ./include/*.h)
# Object files
OBJ=$(C_SOURCE:.c=.o)
# Compiler
CPP=g++
# Lib Directory
LIB_DIR="./include/"
# Flags for compiler
CC_FLAGS=-c \
-W \
-Wall \
all: $(PROJ_NAME)
$(PROJ_NAME): $(OBJ)
ifneq ("$(wildcard $(dir $(APP_FILE))/Makefile)","")
cd $(dir $(APP_FILE)) && make PROJ_NAME=$(PROJ_NAME)
mv $(dir $(APP_FILE))/$(PROJ_NAME) .
else
$(CPP) -o $@ $^ $(APP_FILE) -I $(LIB_DIR)
endif
%.o: %.c %.h
$(CPP) -o $@ $< $(CC_FLAGS)
main.o: main.c $(H_SOURCE)
$(CPP) -o $@ $< $(CC_FLAGS)
clean:
rm -rf *.o $(PROJ_NAME) *~