-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.sh
executable file
·773 lines (719 loc) · 33 KB
/
make.sh
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
##
## github: @maelbcl
## MakefileMaker
## File description:
## To create makefile and had lib and includes
################################################################ Add Makefile #######################################################################
#Add Epitech header
header () {
echo -e "##"
echo -e "## EPITECH PROJECT, 2022"
echo -e "## Makefile"
echo -e "## File description:"
if [ -z "$1" ]; then
echo -e "## Makefile"
else
echo -e "## Makefile for $1"
fi
echo -e "##"
echo ""
}
#Add all variable need by makefile
variable () {
binary=$1
if [ -z "$1" ]; then
echo -e "NAME = a.out"
else
echo -e "NAME = $1"
fi
echo -e ""
echo -e "INCLUDE = -I include/ -I include/lib/ -L lib/ \\
-lmy -lmyprintf -lformatstring -lparser"
echo -e ""
echo -ne "CFLAGS += -Wall -Wextra -pedantic \\
-Wstrict-prototypes -fstack-protector\\
-Wold-style-definition -std=c99 " && echo -e '$(INCLUDE)'
echo -e ""
echo -e "SOURCES = src/"
echo -e ""
if [ -z "$2" ]; then
echo -e "SRC = \c" && echo -e '$(SOURCES)\c' && echo -e "main.c"
else
echo -e "SRC = \c" && echo -e '$(SOURCES)\c' && echo -e "$2.c"
fi
echo -e ""
echo -e 'SRC_COUNT = $(words $(SRC))'
echo -e ""
echo -e "NB = 0"
echo -e ""
echo -e "OBJ = \c" && echo '$(SRC:.c=.o)'
echo -e ""
echo -e "TEMPFILES = *~ *vgcore* #*#"
echo -e ""
echo -e "RM = rm -f"
echo -e ""
echo -e "ECHO = /bin/echo -e"
echo 'DEFAULT = "\033[00m"'
echo 'BOLD = "\e[1m"'
echo 'RED = "\e[31m"'
echo 'GREEN = "\e[32m"'
echo 'LIGHT_BLUE = "\e[94m"'
echo 'WHITE = "\e[1;37m"'
echo ""
}
#Add basic rules of make file
rules () {
echo -e "all:\t\c" && echo '$(NAME)'
echo -e ""
echo -e '$(NAME):\t$(OBJ)'
echo -e "\t\t\t@echo"
echo -e '\t\t\t@($(ECHO) $(BOLD) $(GREEN)✓$(LIGHT_BLUE) \'
echo -e '\t\t\t"SRC files sucessfully build. "$(DEFAULT))'
echo -e '\t\t\t@make -C lib/my/ --no-print-directory'
echo -e '\t\t\t@make -C lib/parser/ --no-print-directory'
echo -e '\t\t\t@make -C lib/myprintf/ --no-print-directory'
echo -e '\t\t\t@make -C lib/formatstring/ --no-print-directory'
echo -e '\t\t\t@gcc -o $(NAME) $(OBJ) $(INCLUDE) \'
echo -e '\t\t\t&& $(ECHO) $(BOLD) $(GREEN)"\c' && echo '\n► BUILD SUCCESS !"$(DEFAULT) \'
echo -e '\t\t\t|| ($(ECHO) $(BOLD) $(RED)"\c' && echo '\n► BUILD FAILED"$(DEFAULT) && exit 1)'
echo -e ""
echo -e 'debug:\t\tCFLAGS += -g3 -pg'
echo -e 'debug:\t\tall'
echo -e ''
echo -e 'clean:'
echo -e '\t\t\t@make -C lib/my/ clean --no-print-directory'
echo -e '\t\t\t@make -C lib/parser/ clean --no-print-directory'
echo -e '\t\t\t@make -C lib/myprintf/ clean --no-print-directory'
echo -e '\t\t\t@make -C lib/formatstring/ clean --no-print-directory'
echo -e '\t\t\t@$(RM) $(OBJ)'
echo -e '\t\t\t@$(RM) $(TEMPFILES)'
echo -e '\t\t\t@($(ECHO) $(BOLD) $(GREEN)✓$(LIGHT_BLUE)" Clean SRC "$(DEFAULT))'
echo -e ''
echo -e 'fclean:\t\tclean'
echo -e '\t\t\t@make -C lib/myprintf/ fclean --no-print-directory'
echo -e '\t\t\t@make -C lib/parser/ fclean --no-print-directory'
echo -e '\t\t\t@make -C lib/formatstring/ fclean --no-print-directory'
echo -e '\t\t\t@make -C lib/my/ fclean --no-print-directory'
echo -e '\t\t\t@$(RM) $(NAME)'
echo -e '\t\t\t@$(RM) $(OBJ)'
echo -e '\t\t\t@$(RM) $(TEMPFILES)'
echo -e '\t\t\t@($(ECHO) $(BOLD) $(GREEN)✓$(LIGHT_BLUE)" Fclean SRC "$(DEFAULT))'
echo -e ''
echo -e 're:'
echo -e '\t\t\t@make fclean --no-print-directory'
echo -e '\t\t\t@make --no-print-directory'
echo -e ''
echo -e '%.o:\t\t%.c'
echo -e '\t\t\t@$(eval NB=$(shell echo $$(($(NB)+1))))'
echo -e '\t\t\t@gcc -c -o $@ $^ $(CFLAGS) && python3 build/build.py $< $(NB) \'
echo -e '\t\t\t$(SRC_COUNT)'
echo -e ''
echo -e '.PHONY: all re clean fclean debug'
}
#Manage all make and create make file
echomake () {
resp=$(echo "yes")
cp -R ~/delivery/Lib/build $PWD
if [ -f "$PWD/Makefile" ]; then
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ \e[0m\e[1mThere is already a Makefile \e[0m\e[33m║"
echo -e " \e[33m║ \e[0m\e[1mWould you overwrite it ? \e[0m\e[33m║"
echo -e " \e[33m║ [Type 'yes' or 'no] ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read resp
fi
clear
if [ "$resp" = "yes" ]; then
{
header $1
variable $1 $2
rules
} > Makefile
makeanim
fi
}
############################################################### Load animations #####################################################################
bar () {
actual=$1
percent=$(( actual * 100 / 30 ))
nbsquare=$(( percent / 3))
if [ "$nbsquare" -gt "$max" ]; then
nbsquare=$(echo "30")
fi
nbspace=$((30 - nbsquare))
echo -e "\e[0m\c"
echo -e "\e[32m\c"
perl -E "print '█' x $nbsquare"
echo -e "\e[0m\c"
perl -E "print '░' x $nbspace"
}
srcanim () {
for (( actual=0; actual<=30; actual++ )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mCreate main... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
}
libanim () {
for (( actual=0; actual<=30; actual++ )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mCreate library... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
}
includeanim () {
for (( actual=0; actual<=30; actual++ )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mCreate include... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
}
ignoreanim () {
for (( actual=0; actual<=30; actual += 2 )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mCreate .gitignore... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
}
makeanim () {
for (( actual=0; actual<=30; actual++ )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mCreate Makefile... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
}
moulianim () {
for (( actual=0; actual<=30; actual++ )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mCreate Moulinette... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
}
pushanim () {
for (( actual=0; actual<=30; actual += 4 )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mGit Add... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
for (( actual=0; actual<=30; actual += 5 )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mGit Commit... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
for (( actual=0; actual<=30; actual += 3 )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mGit Push... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
}
################################################################### To add things ###################################################################
# To add things
addinclude () {
if [ -f "$PWD/include/$include_name.h" ]; then
exit 84
fi
{
echo "/*"
echo "** EPITECH PROJECT, 2022"
echo "** $include_name.c"
echo "** File description:"
echo "** $include_name"
echo "*/"
echo ""
echo "#ifndef $include_ifndef"
echo " #define $include_ifndef"
if [ -f "$PWD/include/my.h" ]; then
echo ' #include "my.h"'
fi
if [ -f "$PWD/include/printf.h" ]; then
echo ' #include "printf.h"'
fi
if [ -f "$PWD/include/formatstring.h" ]; then
echo ' #include "formatstring.h"'
fi
if [ -f "$PWD/include/parser.h" ]; then
echo ' #include "parser.h"'
fi
echo ""
echo " #include <stdbool.h>"
echo " #include <stddef.h>"
if [ ! -z "$libsup" ]; then
echo -e "$libsup"
fi
echo "#endif"
} > $PWD/include/$include_name.h
}
addlib () {
if [ ! -d "$PWD/lib" ]; then
cp -R ~/delivery/Lib/lib $PWD
fi
if [ ! -d "$PWD/include" ]; then
cp -R ~/delivery/Lib/include $PWD
fi
}
addlib_src ()
{
if [ ! -d "$PWD/lib" ]; then
cp -R ~/delivery/Lib/lib/* $PWD/src/
fi
if [ ! -d "$PWD/include" ]; then
cp -R ~/delivery/Lib/include $PWD
fi
}
addmouli () {
cp ~/delivery/Lib/mouli.sh $PWD
cp -R ~/delivery/Lib/tests $PWD
}
addignore () {
{
echo "*.o"
echo "*.a"
echo "*~"
echo "#*#"
echo "*vgcore*"
echo ".vscode"
echo "$binary"
} > $PWD/.gitignore
}
addpush () {
git add --all
git commit -m "feat (lib/,src/,include/): Add lib, include and main"
git push
}
addmain () {
if [ ! -d "$PWD/src" ]; then
mkdir $PWD/src
fi
{
echo "/*"
echo "** EPITECH PROJECT, 2022"
echo "** $main.c"
echo "** File description:"
echo "** $main"
echo "*/"
echo ""
if [[ "$include_name" != "" ]];then
echo -e '#include "\c' && echo -e "$include_name\c" && echo '.h"'
fi
if [ -f "$PWD/include/my.h" ]; then
echo ""
elif [ -f "$PWD/include/printf.h" ]; then
echo ""
elif [ -f "$PWD/include/formatstring.h" ]; then
echo ""
elif [ "$include_name" != "" ]; then
echo ""
fi
echo "int main (UNUSED int ac, UNUSED char **argv, UNUSED char **env)"
echo "{"
echo " return 0;"
echo "}"
} > $PWD/src/$main.c
}
add_cmake ()
{
if [ ! -f "$PWD/CMakeLists.txt" ]; then
{
echo "cmake_minimum_required(VERSION 3.16)"
echo "project($binary C)"
echo "include_directories(include)"
echo "set(INSTALL_DOC ON)"
echo "add_subdirectory(src)"
echo "add_subdirectory(include)"
echo ""
} > $PWD/CMakeLists.txt
fi
if [ ! -f "$PWD/include/CMakeLists.txt" ]; then
{
echo "file(GLOB include_H . *.h)"
echo 'install(FILES ${include_H} DESTINATION include)'
echo ""
} > $PWD/include/CMakeLists.txt
fi
if [ ! -f "$PWD/src/CMakeLists.txt" ]; then
{
echo "include_directories(include)"
echo ""
echo "add_subdirectory(formatstring)"
echo "add_subdirectory(my)"
echo "add_subdirectory(myprintf)"
echo "add_subdirectory(parser)"
echo "SET(PROJECT_LIBS formatstring my myprintf parser)"
echo ""
echo "add_executable($binary main.c)"
echo ""
echo -ne "TARGET_LINK_LIBRARIES($binary " && echo '${PROJECT_LIBS})'
echo "install(TARGETS $binary DESTINATION bin)"
echo ""
} > $PWD/src/CMakeLists.txt
cp -f ~/delivery/Lib/parser.h $PWD/include
cp -f ~/delivery/Lib/parser.h $PWD/src/parser
cp -f ~/delivery/Lib/get_line_pars.c $PWD/src/parser/json/get_line_pars.c
cp -f ~/delivery/Lib/get_update.c $PWD/src/parser/json/get_update.c
cp -f ~/delivery/Lib/builder $PWD/builder
fi
}
################################################################### To get infos ###################################################################
makeanim () {
for (( actual=0; actual<=30; actual++ )); do
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e " \e[33m║ ║"
echo -e " \e[33m║ \e[0m\e[1mCreate Makefile... \e[0m\e[33m║"
echo -e " \e[33m║ \c" && bar $actual && echo -e "\e[33m ║"
echo -e " \e[33m║ ║"
echo -e " \e[33m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
sleep 0.05
clear
done
}
#For the -h
gethelp () {
echo "Smart tool to get lib, include, makefile and main "
echo ""
echo "USAGE :"
echo " launch [OPTIONS]"
echo ""
echo "OPTIONS :"
echo " -a To get only the main"
echo " -cm To build with CMakelists"
echo " -h To have help"
echo " -i To get only the includes"
echo " -l To get only the library"
echo " -m To get only the Makefile"
}
#To get informations
getinfo_push () {
clear
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[0m\e[1mPush it ? \e[0m\e[32m║"
echo -e " \e[32m║ [Type 'yes' or 'no] ║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read push
if [ "$push" == "yes" ]; then
addpush > /dev/null
clear
pushanim
fi
clear
}
getinfo_ignore () {
clear
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[0m\e[1mAdd a .gitignore ? \e[0m\e[32m║"
echo -e " \e[32m║ [Type 'yes' or 'no] ║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read ignore
if [ "$ignore" == "yes" ]; then
addignore
ignoreanim
fi
clear
}
getinfo_mouli () {
clear
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[0m\e[1mAdd a mouli ? \e[0m\e[32m║"
echo -e " \e[32m║ [Type 'yes' or 'no] ║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read mouli
if [ "$mouli" == "yes" ]; then
addmouli
moulianim
fi
clear
}
getinfo_binary () {
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[0m\e[1mInput a name for the binary : \e[0m\e[32m║"
echo -e " \e[32m║ ║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read binary
}
getinfo_include () {
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[0m\e[1mInput a name for the '.h' file : \e[0m\e[32m║"
echo -e " \e[32m║ ║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read include_name
clear
if [ -d "$PWD/include" ]; then
if [ -f "$PWD/include/$include_name.h" ]; then
breakbcl=0
while (($breakbcl == 0)); do
echo -e " \e[31m╬═══════════════════════════════════════╬"
echo -e " \e[31m║ ║"
echo -e " \e[31m║ \e[1mThis file already exist. \e[0m\e[31m║"
echo -e " \e[31m║ \e[1m[Press enter] \e[0m\e[31m║"
echo -e " \e[31m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read tmp
clear
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[0m\e[1mInput a name for the '.h' file : \e[0m\e[32m║"
echo -e " \e[32m║ ║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read include_name
clear
if [ -d "$PWD/include" ]; then
if [ -f "$PWD/include/$include_name.h" ]; then
breakbcl=0
else
breakbcl=1
fi
else
breakbcl=1
fi
done
fi
fi
clear
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[0m\e[1mInput a name for the ifndef : \e[0m\e[32m║"
echo -e " \e[32m║ ║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read include_ifndef
include_ifndef=${include_ifndef^^}
clear
breakbcl=0
while (( $breakbcl == 0 )); do
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[1mInclude a new library ? \e[0m\e[32m║"
echo -e " \e[32m║ \e[1m[Type 'no' or the new lib] \e[0m\e[32m║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read temp
clear
if [ "${temp}" != "no" ]; then
libsup="${libsup} #include <${temp}.h>\n"
else
breakbcl=1
fi
done
}
getinfo_main () {
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[0m\e[1mInput a name for the main file : \e[0m\e[32m║"
echo -e " \e[32m║ ║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read main
clear
if [ -d "$PWD/src" ]; then
if [ -f "$PWD/src/$main.c" ]; then
breakbcl=0
while (($breakbcl == 0)); do
echo -e " \e[31m╬═══════════════════════════════════════╬"
echo -e " \e[31m║ ║"
echo -e " \e[31m║ \e[1mThis file already exist. \e[0m\e[31m║"
echo -e " \e[31m║ \e[1m[Press enter] \e[0m\e[31m║"
echo -e " \e[31m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read tmp
clear
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[0m\e[1mInput a name for the main file : \e[0m\e[32m║"
echo -e " \e[32m║ ║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read main
clear
if [ -d "$PWD/src" ]; then
if [ -f "$PWD/src/$main.c" ]; then
breakbcl=0
else
breakbcl=1
fi
else
breakbcl=1
fi
done
fi
fi
}
ask_for_cmake ()
{
breakbcl=0
while (( $breakbcl == 0 )); do
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[1mUse CMake ? \e[0m\e[32m║"
echo -e " \e[32m║ \e[1m[Type 'yes' or 'no'] \e[0m\e[32m║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read temp
clear
if [ "${temp}" == "yes" ]; then
cmake=1
breakbcl=1
elif [ "${temp}" == "no" ]; then
cmake=0
breakbcl=1
else
breakbcl=0
fi
done
}
################################################################### Main #################################################################################################################
#For to get main
main () {
max=$(echo "30")
if [ "$1" = "-m" ]; then
main=$(echo "main")
getinfo_binary
echomake $binary $main
elif [ "$1" = "-i" ]; then
getinfo_include
addinclude $include
includeanim
elif [ "$1" = "-l" ]; then
addlib
libaanim
elif [ "$1" = "-a" ]; then
getinfo_main
addmain $main
srcanim
elif [[ "$1" = "-cm" ]]; then
clear
getinfo_binary
clear
getinfo_include
clear
getinfo_main
clear
getinfo_ignore
clear
if [ ! -d "$PWD/lib" ]; then
libanim
clear
elif [ ! -d "$PWD/include" ]; then
includeanim
clear
fi
clear
srcanim
clear
addmain
addlib_src
getinfo_mouli
getinfo_push
add_cmake
addinclude
mkdir build
rm -R Makefile
elif [[ "$1" != "" ]]; then
gethelp
exit 0
else
clear
getinfo_binary
clear
getinfo_include
clear
getinfo_main
clear
getinfo_ignore
clear
if [ ! -d "$PWD/lib" ]; then
libanim
clear
elif [ ! -d "$PWD/include" ]; then
libanim
clear
fi
addlib
includeanim
clear
addinclude
srcanim
clear
addmain
echomake $binary $main
getinfo_mouli
getinfo_push
find $PWD -type f -name 'CMakeLists.txt' -delete
fi
clear
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e " \e[32m║ ║"
echo -e " \e[32m║ \e[1mEverything is good. \e[0m\e[32m║"
echo -e " \e[32m║ \e[1m[Press enter] \e[0m\e[32m║"
echo -e " \e[32m╬═══════════════════════════════════════╬"
echo -e "\e[0m"
read tmp
clear
bash
}
main $1