-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
executable file
·52 lines (42 loc) · 1.24 KB
/
makefile
File metadata and controls
executable file
·52 lines (42 loc) · 1.24 KB
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
COMPILER:= gcc
FLAGS := -Wall
FILENAME := main.c
TARGET := bin/pjm
# Getting all sources files in src folder
SOURCES = $(wildcard src/*.c)
# Converting source files names to objects files
OBJECTS = $(patsubst src/%.c, obj/%.o, $(SOURCES))
#Link main.c with every object
$(TARGET) : $(SOURCES) $(OBJECTS)
@echo "-> Linking $(FILENAME) with$(OBJECTS) ..."
@mkdir -p ./bin
@$(COMPILER) $(FILENAME) $(wildcard obj/*.o) -o $(TARGET)
@echo "-> Finished building $(TARGET)."
#computes every object from sources
obj/%.o : src/%.c
@echo "-> Building $^..."
@mkdir -p ./obj
@gcc -c $^ -o $@
#Clear eveything and rebuilds it
re : clear $(TARGET)
#Runs the program
run : $(TARGET)
@echo "-> Executing $(TARGET)."
@./$(TARGET)
#Clear workspace of .o files and executable
clear :
@echo "-> Cleaning the workspace ..."
@rm -f $(OBJECTS)
@rm -f $(TARGET)
@echo "-> Removed executables and .o fles."
#to install the program on the computer
install : $(TARGET)
@echo "-> moving executable to ~/bin"
@mkdir -p ~/bin
@mv $(TARGET) ~/bin/pjm
@echo "-> Project Manager is now installed. Command : pjm"
#to remove the program from the computer
remove :
@echo "Removing..."
@rm -f ~/bin/$(TARGET)
@echo "Project Manager has been removed from your computer."