-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·77 lines (64 loc) · 1.25 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Compiler serttings
CC = cc
CFLAGS = -Wall -g
LFLAGS = -lm
# Folders
SRC = src
BUILD = build
BIN = bin
# Files
C_FILES = $(wildcard $(SRC)/*.c)
O_FILES = $(C_FILES:.c=.o)
B_FILES = $(addprefix $(BUILD)/, $(notdir $(O_FILES)))
EXE = $(BIN)/conv
INS_EXE = /bin/conv
# Compile
all: create_dir $(O_FILES) $(EXE)
# Compile buffer
%.o : %.c
@echo -n 'Compiling: $^ -> $@ -- '
@ $(CC) -c $^ -o $(BUILD)/$(notdir $@) $(CFLAGS)
@echo done
$(EXE) : $(B_FILES)
@echo -n 'Linking: $(O_FILES) $^ -> $@ -- '
@ $(CC) $^ -o $@ $(CFLAGS) $(LFLAGS)
@echo done
# Create directories
create_dir:
ifeq ("$(wildcard $(BIN))", "")
@echo -n 'Creating $(BIN) folder -- '
@ mkdir $(BIN)
@echo done
endif
ifeq ("$(wildcard $(BUILD))", "")
@echo -n 'Creating $(BUILD) folder -- '
@ mkdir $(BUILD)
@echo done
endif
# Clear folders
clean:
rm $(BIN)/* $(BUILD)/*
# Delete also the directory
cleanall:
ifneq ("$(wildcard $(BIN))", "")
@echo -n 'Cleaning $(BIN) -- '
@ rm -r $(BIN)/
@echo done
endif
ifneq ("$(wildcard $(BUILD))", "")
@echo -n 'Cleaning $(BUILD) -- '
@ rm -r $(BUILD)/
@echo done
endif
ifneq ("$(wildcard *.txt)", "")
@echo -n 'Removing *.txt -- '
@ rm *.txt
@echo done
endif
test:
@ clear
@ make cleanall
@ make
install:
make
mv $(EXE) $(INS_EXE)