Skip to content

Commit

Permalink
Merge pull request #65 from eguefif/heredoc
Browse files Browse the repository at this point in the history
Setup builtins Makefile
  • Loading branch information
PelletierM authored Nov 22, 2023
2 parents 9f5395f + d1510c8 commit be07f34
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ READLINE = $(READLINE_DIR)/libreadline.a

_SRC_LIB_STATIC = parser.c executer.c cleaner.c lexer.c lexer_get_tokens.c error.c parser_get_commands.c parser_clean_commands1.c parser_clean_commands2.c lexer_count_tokens.c lexer_get_token_size.c parser_get_commands_populate.c \
utils.c executer_getpath.c environment.c signals.c
#_SRC = main.c parser.c executer.c cleaner.c lexer.c lexer_get_tokens.c error.c
_SRC = main.c $(_SRC_LIB_STATIC)
_OBJ = $(_SRC:.c=.o)
_OBJ_LIB_STATIC = $(_SRC_LIB_STATIC:.c=.o)
Expand All @@ -25,9 +24,13 @@ SDIR = ./src/
OBJ = $(addprefix $(ODIR), $(_OBJ))
OBJ_LIB_STATIC = $(addprefix $(ODIR), $(_OBJ_LIB_STATIC))

BUILTIN_DIR = builtins
_BUILTINS = heredoc
BUILTINS = $(addprefix $(BUILTIN_DIR)/, $(_BUILTINS))

all: $(NAME)

$(NAME): $(LIBFT) $(OBJ) $(READLINE)
$(NAME): $(LIBFT) $(OBJ) $(READLINE) $(BUILTINS)
$(CC) $(CFLAGS) $(OBJ) $(LIB) -o $@
cp ./minishell ./test/

Expand All @@ -50,6 +53,9 @@ $(ODIR)%.o: $(SDIR)%.c ./includes/minishell.h
fi
$(CC) $(CFLAGS) -c $< $(INC) -o $@

$(BUILTIN_DIR)/%:
make -C $(BUILTIN_DIR)/srcs_$(subst $(BUILTIN_DIR)/,,$@)

build_test_env:
python3 -m venv ./test/venv
@echo "Type: source ./test/venv/bin/activate && make build_dependencies"
Expand Down
34 changes: 34 additions & 0 deletions builtins/srcs_heredoc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
NAME = heredoc
CC = gcc
CFLAGS = -g -Wall -Werror -Wextra
INC = -I. -I$(LIBFT_DIR)/includes

LIB = -lft -L$(LIBFT_DIR)
LIB_DIR = ../../lib

LIBFT_DIR = $(LIB_DIR)/libft
LIBFT = $(LIBFT_DIR)/libft.a

_SRC = $(NAME).c
OBJ = $(_SRC:.c=.o)

all: $(NAME)

$(NAME): $(LIBFT) $(OBJ)
$(CC) $(CFLAGS) $(OBJ) $(LIB) -o $@
cp $(NAME) ../$(NAME)

%.o: %.c ./$(NAME).h
$(CC) $(CFLAGS) -c $< $(INC) -o $@

$(LIBFT):
make -C $(LIBFT_DIR)

clean:
rm -rf $(OBJ)

fclean: clean
rm -rf $(NAME)
rm -rf ../$(NAME)

re : fclean all
20 changes: 20 additions & 0 deletions builtins/srcs_heredoc/heredoc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* heredoc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maxpelle <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/22 12:36:39 by maxpelle #+# #+# */
/* Updated: 2023/11/22 13:08:44 by maxpelle ### ########.fr */
/* */
/* ************************************************************************** */

#include "heredoc.h"

int main(int argc, char *argv[])
{
(void) argc;
(void) argv;
return (0);
}
18 changes: 18 additions & 0 deletions builtins/srcs_heredoc/heredoc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* heredoc.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maxpelle <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/22 13:02:38 by maxpelle #+# #+# */
/* Updated: 2023/11/22 13:31:25 by maxpelle ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef HEREDOC_H
# define HEREDOC_H

# include "libft.h"

#endif

0 comments on commit be07f34

Please sign in to comment.