-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (47 loc) · 1.51 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
GCC=gcc
RESULT=main
IFDEF=
#IFDEF+=-DDEBUG
# -Wall — enables all major warnings.
# # -Wextra — enables other important warnings.
# -Werror — make all warnings into errors, causing compilations to fail if any warnings are reported.
#
LIB=$(C11) -Wall -Wextra #-Werror
# if we need to know actual pwd
CPWD:=$(shell pwd)
INC=-I./include
SRC=main.c \
src/fib.c
# @ - allow to hide printing command code which will be called, so only expected output will be printed
help:
@echo ""
@echo " all - normal full compilation to prepare resulting binary file."
@echo " preproc - stop after preprocessing."
@echo " asm - stop after assembler file is ready."
@echo " lnk - stop after linker file is ready."
@echo " lib - compile all (but using static library)"
@echo ""
all: main.c
$(GCC) $(IFDEF) $(LIB) $(SRC) -o $(RESULT) $(INC)
preproc:
echo "Stop process after preprocessing."
$(GCC) -E $(LIB) main.c -o $(RESULT).i $(INC)
asm:
$(GCC) -S $(LIB) main.c -o $(RESULT).s $(INC)
lnk:
$(GCC) $(IFDEF) $(LIB) $(SRC) -e $(RESULT) $(INC)
lib: main.c libfib.a
@echo " This won't work for MAC OS "
@echo " https://stackoverflow.com/questions/3801011/ld-library-not-found-for-lcrt0-o-on-osx-10-6-with-gcc-clang-static-flag "
$(GCC) -static main.c -L. -lfib -o $(RESULT) $(INC)
libfib.a:
$(GCC) -c src/fib.c -o calc_fib.o $(INC)
ar rcs libfib.a calc_fib.o
.PHONY: clean
clean:
@echo "Clean-up dorectory - remove all remporary files."
@rm -rf $(RESULT)
@rm -rf *.o
@rm -rf *.i
@rm -rf *.s
@rm -rf *.a