aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 7a3282e7d8707abe085b5ce2bc0088018c1f93c1 (plain)
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
# **************************************************************************** #
#                                                                              #
#                                                         :::      ::::::::    #
#    Makefile                                           :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: cacharle <marvin@42.fr>                    +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2019/11/22 02:56:22 by cacharle          #+#    #+#              #
#    Updated: 2019/11/25 04:46:29 by cacharle         ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

RM = rm -f
LIB = ar rcs
UNAME = $(shell uname)

CC = gcc
CCFLAGS = -Wall -Wextra -fomit-frame-pointer -fPIC

NASM = nasm
ifeq ($(UNAME),Linux)
	NASMFLAGS = -f elf64
else
	NASMFLAGS = -f macho64
endif

NAME = libasm.a
ASMSRC = ft_strlen.s ft_strcpy.s ft_strcmp.s ft_write.s ft_read.s \
		 ft_strdup.s ft_atoi_base.s #ft_list_push_front.s \
		 # ft_list_size.s ft_list_sort.s ft_list_remove_if.s
ASMOBJ = $(ASMSRC:.s=.o)

TESTNAME = runtest

all: $(NAME)

$(NAME): $(ASMOBJ)
	$(LIB) $(NAME) $(ASMOBJ)

test: all
	$(CC) main.c $(NAME) -o $(TESTNAME)

%.o: %.s
	$(NASM) $(NASMFLAGS) -o $@ $<

clean:
	$(RM) $(ASMOBJ)

fclean: clean
	$(RM) $(NAME)

re: fclean all