Skip to content

Commit 73f760b

Browse files
author
elkaboussi
committed
refactor: remove the hard coded readline library path for macos in Makefile
move srcs to helpers/
1 parent 48add94 commit 73f760b

File tree

10 files changed

+19
-18
lines changed

10 files changed

+19
-18
lines changed

Makefile

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,36 @@ RM = rm -rf
44
MKDIR = mkdir -p
55
USERS = $(USER)
66

7-
OS = $(shell uname -s)
7+
OS := $(shell uname -s)
88
ifeq ($(OS),Linux)
9-
LINK = -lreadline
9+
READLINE_LINK := -lreadline
1010
else
11-
COMP = -L/goinfre/$(USERS)/.brew/opt/readline/lib
12-
LINK = -I/goinfre/$(USERS)/.brew/opt/readline/include
11+
READLINE_DIR := $(shell brew --prefix readline)
12+
READLINE_COMP := -L$(READLINE_DIR)/lib
13+
READLINE_LINK := -I$(READLINE_DIR)/include
1314
endif
1415

15-
SRCS = srcs/ft_close.c srcs/ft_dups.c srcs/ft_execve.c srcs/ft_fork.c srcs/ft_open.c srcs/ft_pipe.c srcs/ft_waits.c builtins/cd.c builtins/echo.c builtins/env.c builtins/export.c builtins/helpers.c builtins/pwd.c builtins/shell_exit.c builtins/unset.c builtins/utils.c execution/environment.c execution/execute.c execution/heredoc.c execution/misc.c execution/paths.c execution/shell.c execution/signals.c parsing/commands.c parsing/commands_list.c parsing/env.c parsing/expand.c parsing/expand_env.c parsing/free.c parsing/heredoc.c parsing/lexer.c parsing/operator.c parsing/parser.c parsing/heredoc_expansion.c parsing/parsing_utils.c parsing/token_list.c parsing/word_spliting.c utils/alpha.c utils/contains.c utils/fatal.c utils/ft_atoi.c utils/ft_calloc.c utils/ft_exit.c utils/ft_free.c utils/ft_itoa.c utils/ft_memcpy.c utils/ft_split.c utils/ft_strcmp.c utils/ft_strdup.c utils/ft_strjoins.c utils/ft_strlen.c utils/ft_substr.c utils/prints.c main.c
16+
SRCS = helpers/ft_close.c helpers/ft_dups.c helpers/ft_execve.c helpers/ft_fork.c helpers/ft_open.c helpers/ft_pipe.c helpers/ft_waits.c builtins/cd.c builtins/echo.c builtins/env.c builtins/export.c builtins/helpers.c builtins/pwd.c builtins/shell_exit.c builtins/unset.c builtins/utils.c execution/environment.c execution/execute.c execution/heredoc.c execution/misc.c execution/paths.c execution/shell.c execution/signals.c parsing/commands.c parsing/commands_list.c parsing/env.c parsing/expand.c parsing/expand_env.c parsing/free.c parsing/heredoc.c parsing/lexer.c parsing/operator.c parsing/parser.c parsing/heredoc_expansion.c parsing/parsing_utils.c parsing/token_list.c parsing/word_spliting.c utils/alpha.c utils/contains.c utils/fatal.c utils/ft_atoi.c utils/ft_calloc.c utils/ft_exit.c utils/ft_free.c utils/ft_itoa.c utils/ft_memcpy.c utils/ft_split.c utils/ft_strcmp.c utils/ft_strdup.c utils/ft_strjoins.c utils/ft_strlen.c utils/ft_substr.c utils/prints.c main.c
1617
SRCS_DIRS = $(dir $(SRCS))
1718

18-
BIN_DIR = bin/
19+
BIN_DIR = build/
1920

2021
OBJS = $(SRCS:%.c=$(BIN_DIR)%.o)
2122
OBJS_DIRS = $(dir $(OBJS))
2223

23-
INCLUDES = includes/builtin.h includes/execution.h includes/minishell.h includes/parsing.h includes/srcs.h includes/utils.h
24+
INCLUDES = includes/builtin.h includes/execution.h includes/minishell.h includes/parsing.h includes/helpers.h includes/utils.h
2425

2526
NAME = minishell
2627

2728

2829
all: $(NAME)
2930

3031
$(NAME): $(OBJS)
31-
@$(CC) $(OBJS) -o $(NAME) $(LINK)
32+
@$(CC) $(OBJS) -o $(NAME) $(READLINE_LINK)
3233

3334
$(BIN_DIR)%.o: %.c $(INCLUDES)
3435
@$(MKDIR) $(OBJS_DIRS)
35-
$(CC) $(COMP) $(CFLAGS) -c $< -o $@
36+
$(CC) $(READLINE_COMP) $(CFLAGS) -c $< -o $@
3637

3738
clean:
3839
@$(RM) $(BIN_DIR)

srcs/ft_close.c helpers/ft_close.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "srcs.h"
13+
#include "helpers.h"
1414

1515
void ft_close(int fd)
1616
{

srcs/ft_dups.c helpers/ft_dups.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "srcs.h"
13+
#include "helpers.h"
1414

1515
void ft_dup(int fd)
1616
{

srcs/ft_execve.c helpers/ft_execve.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "srcs.h"
13+
#include "helpers.h"
1414

1515
void ft_execve(char *path, char **argv)
1616
{

srcs/ft_fork.c helpers/ft_fork.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "srcs.h"
13+
#include "helpers.h"
1414

1515
int ft_fork(void)
1616
{

srcs/ft_open.c helpers/ft_open.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "srcs.h"
13+
#include "helpers.h"
1414

1515
int ft_open(char *path, int flags, int mode)
1616
{

srcs/ft_pipe.c helpers/ft_pipe.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "srcs.h"
13+
#include "helpers.h"
1414

1515
void ft_pipe(int fd[2])
1616
{

srcs/ft_waits.c helpers/ft_waits.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "srcs.h"
13+
#include "helpers.h"
1414

1515
void ft_waitpid(pid_t pid)
1616
{

includes/srcs.h includes/helpers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ************************************************************************** */
22
/* */
33
/* ::: :::::::: */
4-
/* srcs.h :+: :+: :+: */
4+
/* helpers.h :+: :+: :+: */
55
/* +:+ +:+ +:+ */
66
/* By: relkabou <[email protected]> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */

includes/minishell.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# include "builtin.h"
2929
# include "parsing.h"
3030
# include "execution.h"
31-
# include "srcs.h"
31+
# include "helpers.h"
3232
# include "utils.h"
3333

3434
# define TRUE 1

0 commit comments

Comments
 (0)