-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (39 loc) · 1.03 KB
/
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
48
CC := gcc
CFLAGS := -Wall -Wextra -g
LFLAGS := -lm -lxmemtools
OUTPUT := output
SRC := src
INCLUDE := include lib
LIB := lib
RM := rm -rf
MD := mkdir -p
CTAGS := ctags
CTAGSFLAGS := -R
CTAGSDIRECTORIES := $(SRC) $(INCLUDE) $(LIB)
MAIN := numconv
SOURCEDIRS := $(shell find $(SRC) -type d)
INCLUDEDIRS := $(shell find $(INCLUDE) -type d)
LIBDIRS := $(shell find $(LIB) -type d)
INCLUDES := $(patsubst %,-I%, $(INCLUDEDIRS:%/=%))
LIBS := $(patsubst %,-L%, $(LIBDIRS:%/=%))
SOURCES := $(wildcard $(patsubst %,%/*.c, $(SOURCEDIRS)))
OBJECTS := $(SOURCES:.c=.o)
OUTPUTMAIN := $(OUTPUT)/$(MAIN)
all: $(OUTPUT) $(MAIN)
@echo Compilation successful
$(OUTPUT):
$(MD) $(OUTPUT)
$(MAIN): $(OBJECTS)
$(MAKE) -C $(LIB)/xmemtools
$(CC) $(CFLAGS) $(INCLUDES) -o $(OUTPUTMAIN) $(OBJECTS) $(LFLAGS) $(LIBS)
$(CTAGS) $(CTAGSFLAGS) $(CTAGSDIRECTORIES)
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
run: all
./$(OUTPUTMAIN)
@echo Execution successful
.PHONY: clean
clean:
$(MAKE) -C $(LIB)/xmemtools clean
$(RM) $(OUTPUT) $(OBJECTS)
@echo Clean successful