-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
123 lines (104 loc) · 3.17 KB
/
makefile
File metadata and controls
123 lines (104 loc) · 3.17 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
CC = g++ -O3 -Wall -Werror -ansi -pedantic --std=c++17
FLAGS = -g -c
SOURCEDIR = sources
BUILDDIR = obj
BINDIR = bin
ARCHIVE = sortie.zip
CREATE_DIR = mkdir $(BUILDDIR) $(BINDIR)
PROG=manage_prg
TARGET_ARCHIVE=sources/*.cpp header/*.hpp makefile
MSG_CLEAN=:Suppresion du programme executable $(PROG) et du fichier archive $(ARCHIVE)
MSG_BUILD_ZIP=Generation du fichier archive $(ARCHIVE)
MSG_CLEAN_O_FILE:=Suppresion des fichiers $(BUILDDIR)/.o
SOURCES = $(wildcard $(SOURCEDIR)/*.cpp)
OBJECTS = $(patsubst $(SOURCEDIR)/%.cpp, $(BUILDDIR)/%.o, $(SOURCES))
CLEAN =:
TROUVE =: NON
help:
@echo ' '
@echo ' '
@echo Possible targets:
@echo ' '
@echo make - print contain this section
@echo make clean - delete bin and obj directories
@echo make mrproper - delete bin, obj directories and zip file contain all code project if exists
@echo make dir - create bin and obj directories
@echo make zip - create zip $(ARCHIVE) file contain sources/*.hpp, header/*.cpp and makefile
@echo make binary - create all obj/*.o files from all sources/*.cpp files and binary bin/$(PROG) file
@echo ' '
@echo Informations project
@echo ' '
@echo sources files - sources directory contain all sources/*.cpp files
@echo header files - header directory contain all header/*.hpp files
@echo ' '
@echo ' '
@echo Binary file name
@echo $(PROG)
@echo ' '
@echo ' '
OSFLAG :=
OS_DETAILS :=
ifeq ($(OS),Windows_NT)
OSFLAG := WIN
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
OS_DETAILS:=WIN_AMD64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
OS_DETAILS:=WIN_X86
endif
else
OSFLAG := $(shell uname -s | tr A-Z a-z)
OS_DETAILS := $(OSFLAG)
endif
ifeq ($(OSFLAG), WIN)
COMPIL:=Compilation sous windows
DELETE:=del $(ARCHIVE)
ZIP:=tar -cvzf $(ARCHIVE) $(TARGET_ARCHIVE)
CLEAN = rmdir /q /s $(BUILDDIR) $(BINDIR)
TROUVE:=OUI
MSG_BUILD_END=Fin build des fichiers $(BUILDDIR)/.o et generation du fichier executable $(BINDIR)/$(PROG).exe
endif
ifeq ($(OSFLAG), linux)
COMPIL:=Compilation sous Linux
DELETE:=rm $(ARCHIVE)
ZIP:=tar -cvzf $(ARCHIVE) $(TARGET_ARCHIVE)
CLEAN:=rm -rf $(BUILDDIR) $(BINDIR) $(ARCHIVE)
MSG_BUILD_END=Fin build des fichiers $(BUILDDIR)/.o et generation du fichier executable $(BINDIR)/$(PROG)
endif
ifeq ($(OSFLAG), darwin)
COMPIL:=Compilation sous MacOs
DELETE:=rm $(ARCHIVE)
ZIP:=tar -cvzf $(ARCHIVE) $(TARGET_ARCHIVE)
CLEAN:=rm -rf $(BUILDDIR) $(BINDIR) $(ARCHIVE)
MSG_BUILD_END=Fin build des fichiers $(BUILDDIR)/.o et generation du fichier executable $(BINDIR)/$(PROG)
endif
ifeq ($(OSFLAG), WIN)
CLEANER=rmdir /s /q $(BUILDDIR) $(BINDIR)
else
CLEANER=rm -rf $(BUILDDIR) $(BINDIR)
endif
infos:
@echo $(COMPIL)
@echo $(MSG_BUILD_END)
binary: dir $(BINDIR)/$(PROG)
dir:
$(CLEANER)
$(CREATE_DIR)
create_dir:
$(CREATE_DIR)
$(BINDIR)/$(PROG): $(OBJECTS)
@echo $(COMPIL)
@echo $(MSG_BUILD_END)
$(CC) $^ -o $@
$(OBJECTS): $(BUILDDIR)/%.o : $(SOURCEDIR)/%.cpp
$(CC) $(FLAGS) $< -o $@
clean:
$(DELETE)
$(CLEANER)
$(CREATE_DIR)
mrproper:
$(CLEAN)
$(CREATE_DIR)
zip:
@echo $(MSG_BUILD_ZIP)
$(ZIP)