From 9a50b6f481f64305c4790127f2870be9fcc87cd3 Mon Sep 17 00:00:00 2001 From: Aleksei Chubukov Date: Sat, 2 Dec 2023 21:26:10 +0400 Subject: [PATCH] add Makefile, add main.[hc], update .gitignore --- .gitignore | 5 +++++ Makefile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ ex00/main.c | 22 ++++++++++++++++++++++ ex00/main.h | 17 +++++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 Makefile create mode 100644 ex00/main.c create mode 100644 ex00/main.h diff --git a/.gitignore b/.gitignore index ec2481e..c6c1ec0 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,8 @@ tags # Persistent undo [._]*.un~ +# ---> cc +# compiled files +*.o +/rush-02 +a.out diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b75b89f --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: achubuko +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2023/12/02 21:33:22 by achubuko #+# #+# # +# Updated: 2023/12/02 21:33:31 by achubuko ### ########.fr # +# # +# **************************************************************************** # + +NAME=rush-02 +_CFLAGS = -Wall -Wextra -Werror +CFLAGS = -g +##################################### +######### MANDATORY RULES ########### +##################################### + +# all: default rule +# norme prerequisite is not mandatory +all: $(NAME) norme + +# clean: Delete *.o for project and libraries +clean: + rm -rdf $(wildcard */*.o) + +# fclean: Delete *.o files and delete named executable +fclean: clean + rm -f $(NAME) + +# re: full clean and recompilation +re: fclean all + +# these targets are not backed by files, therefore, always run when called +.PHONY: all clean fclean re purge norme +##################################### +########## PROJECT RULES ############ +##################################### +norme: + norminette ex00 +cfiles := $(wildcard ex00/*.c) +ofiles = $(foreach f, $(cfiles), $(subst .c,.o,$f)) +%.o: %.c %.h + $(CC) $(_CFLAGS) $(CFLAGS) -c -o $@ $< +$(NAME): $(ofiles) diff --git a/ex00/main.c b/ex00/main.c new file mode 100644 index 0000000..aadc7a2 --- /dev/null +++ b/ex00/main.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* rush-02.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/02 21:01:21 by achubuko #+# #+# */ +/* Updated: 2023/12/02 21:25:56 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "main.h" + +int main(int argc, char **argv) +{ + if (argc > 3) + { + write(1, "Error: program requires 1 or 2 arguments passed!", 48); + return (1); + } + write(1, argv[1], 1); +} diff --git a/ex00/main.h b/ex00/main.h new file mode 100644 index 0000000..629aac5 --- /dev/null +++ b/ex00/main.h @@ -0,0 +1,17 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* rush-02.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: achubuko +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/02 21:14:25 by achubuko #+# #+# */ +/* Updated: 2023/12/02 21:25:18 by achubuko ### ########.fr */ +/* */ +/* ************************************************************************** */ +#ifndef MAIN_H +# define MAIN_H +# include +# include + +#endif