makefile capable dutiliser directement la libft
This commit is contained in:
BIN
.ft_printf.c.swm
BIN
.ft_printf.c.swm
Binary file not shown.
BIN
.ft_printf.c.swn
BIN
.ft_printf.c.swn
Binary file not shown.
33
Makefile
33
Makefile
@@ -2,7 +2,7 @@
|
||||
# variables names #
|
||||
# - - - - - - - - - #
|
||||
|
||||
NAME = ft_printf
|
||||
NAME = libftprintf.a
|
||||
CC = gcc
|
||||
VPATH = srcs
|
||||
|
||||
@@ -30,22 +30,41 @@ LFLAGS = -L$(LDIR) -l$(LIBS)
|
||||
# rules to execute #
|
||||
# - - - - - - - - - - - #
|
||||
|
||||
all: $(ODIR) $(NAME)
|
||||
$(NAME): $(OBJS) $(DEPS)
|
||||
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS)
|
||||
all: $(NAME)
|
||||
|
||||
$(NAME): $(ODIR) $(OBJS) $(DEPS)
|
||||
cp $(LDIR)$(_LIBS) ./
|
||||
mv $(_LIBS) $(NAME)
|
||||
ar -rc $@ $(OBJS)
|
||||
ranlib $@
|
||||
|
||||
$(ODIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(ODIR)/%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
/bin/rm -rf $(ODIR)
|
||||
|
||||
fclean: clean
|
||||
/bin/rm -f $(NAME)
|
||||
|
||||
re: fclean all
|
||||
|
||||
# - - - - - - - - - - - #
|
||||
# rules to test #
|
||||
# with #
|
||||
# main and libft #
|
||||
# - - - - - - - - - - - #
|
||||
|
||||
lib:
|
||||
make -C $(LDIR)
|
||||
cleanlib: lib
|
||||
make fclean -C $(LDIR)
|
||||
fsanitize: $(ODIR) $(OBJS) $(DEPS)
|
||||
$(CC) $(CFLAGS) -o $(NAME) $(OBJS) $(LFLAGS) -fsanitize=address
|
||||
.PHONY: all clean fclean re lib fsanitize
|
||||
main: $(ODIR) $(OBJS) $(DEPS)
|
||||
$(CC) $(CFLAGS) $(OBJS) $(LFLAGS) -fsanitize=address
|
||||
mainfclean: fclean
|
||||
/bin/rm -f out*.txt a.out
|
||||
|
||||
.PHONY: all clean fclean re lib cleanlib main mainfclean
|
||||
|
||||
54
test.c
54
test.c
@@ -1,54 +0,0 @@
|
||||
#include "ft_printf.h"
|
||||
#include <stdio.h> // for printf
|
||||
#include <fcntl.h> // for dup() and dup2()
|
||||
|
||||
//#define PRINT(string) \
|
||||
// dup2(out1, 1); \
|
||||
// ft_printf(string "\n"); \
|
||||
// dup2(out2, 1); \
|
||||
// ft_printf(string "\n"); \
|
||||
// dup2(save, 1); \
|
||||
// ft_printf(string "\n"); \
|
||||
// ft_printf(string "\n\n");
|
||||
|
||||
//#define PRINT(string) \
|
||||
// dup2(out1, 1); \
|
||||
// write(1, "printf :" string "\n", 14); \
|
||||
// dup2(out2, 1); \
|
||||
// write(1, "printf2:" string "\n", 14); \
|
||||
// dup2(save, 1); \
|
||||
// write(1, "printf :" string "\n", 14); \
|
||||
// write(1, "printf2:" string "\n\n", 15); \
|
||||
|
||||
#define PRINT(string) \
|
||||
dup2(out1, 1); \
|
||||
printf("printf :" string "\n"); \
|
||||
dup2(out2, 1); \
|
||||
ft_printf("printf2:" string "\n"); \
|
||||
dup2(save, 1); \
|
||||
printf("printf :" string "\n"); \
|
||||
ft_printf("printf2:" string "\n\n");
|
||||
|
||||
//#define PRINT(string) \
|
||||
// printf("printf :" string "\n"); \
|
||||
// ft_printf("printf2:" string "\n\n"); \
|
||||
// dup2(out1, 1); \
|
||||
// printf("printf :" string "\n"); \
|
||||
// dup2(out2, 1); \
|
||||
// ft_printf("printf2:" string "\n"); \
|
||||
// dup2(save, 1);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int out1 = open("out1.txt", O_WRONLY | O_TRUNC);
|
||||
int out2 = open("out2.txt", O_WRONLY | O_TRUNC);
|
||||
int save = dup(1);
|
||||
|
||||
PRINT("test1");
|
||||
PRINT("test2");
|
||||
|
||||
close(out1);
|
||||
close(out2);
|
||||
close(save);
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user