-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
90 lines (66 loc) · 1.88 KB
/
Makefile
File metadata and controls
90 lines (66 loc) · 1.88 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
NAME = libfts.a
ASM = nasm
#ASM_FLAGS = -g
FILE_NAMES = ft_atoi ft_bzero ft_cat ft_itoa ft_isalnum ft_isalpha ft_isascii ft_isdigit ft_islower ft_isprint ft_isspace ft_isupper ft_memcpy ft_memset ft_puts ft_strcat ft_strcmp ft_strdup ft_strlen ft_tolower ft_toupper
UNAME := $(shell uname -s)
SRC_DIR := src/$(UNAME)/
OBJ_DIR = obj/
OBJ_DIR_OS = $(OBJ_DIR)$(UNAME)/
OBJ_FILES = $(addprefix $(OBJ_DIR_OS), $(addsuffix .o, $(FILE_NAMES)))
FC42 := fc42
ifeq ($(UNAME),Linux)
ASM_FLAGS += -f elf64
else ifeq ($(UNAME),Darwin)
ASM_FLAGS += -f macho64
endif
all: $(NAME)
$(NAME): $(OBJ_FILES)
ar -rs $@ $^
$(OBJ_FILES): $(OBJ_DIR_OS)%.o : $(SRC_DIR)%.s | $(OBJ_DIR_OS)
$(ASM) $(ASM_FLAGS) $^ -o $@
$(OBJ_DIR_OS): | $(OBJ_DIR)
mkdir -p $@
$(OBJ_DIR):
mkdir -p $@
clean:
rm -rf $(OBJ_DIR)
fclean: clean testrm
@rm -rf a.out*
rm -f $(NAME)
re: fclean all
list:
@ls -1 $(SRC_DIR)*.s | sed 's/.*\///' | sed 's/\.s//' | tr '\n' ' '
test1: $(NAME)
rm -rf test1*;
gcc -o isX_tests -g tests/isX_tests.c -Iinc/ -L. -lfts
@echo ""
@echo ""
@echo "done, run ./isX_tests .... no verbose output, maybe look in source file: tests/isX_tests.c"
test2: $(NAME)
rm -rf itoa_test*;
gcc -o itoa_test -g tests/itoa_test.c -Iinc/ -L. -lfts
test3: $(NAME)
rm -rf cat_test*;
gcc -o cat_test -g tests/cat_test.c -Iinc/ -L. -lfts
test4: $(NAME)
rm -rf atoi_test*;
gcc -o atoi_test -g tests/atoi_test.c -Iinc/ -L. -lfts
test5: $(NAME)
rm -rf str_test*;
gcc -o str_test -g tests/str_test.c -Iinc/ -L. -lfts
$(FC42):
git clone https://github.com/jgigault/42FileChecker $@
fctest: $(NAME) $(FC42)
dir=`pwd` && cd $(FC42) && sh 42FileChecker.sh --project "libftasm" --path $$dir && cd ..
testfc: fctest
testall: test1 test2 test3 test4 test5
alltest: testall
alltests: testall
testrm:
rm -rf isX_tests*
rm -rf itoa_test*
rm -rf cat_test*
rm -rf atoi_test*
rm -rf str_test*
rmtest: testrm
rmtests: testrm