add Makefile, add main.[hc], update .gitignore

This commit is contained in:
Aleksei Chubukov 2023-12-02 21:26:10 +04:00
parent 6919c4c98c
commit 9a50b6f481
4 changed files with 90 additions and 0 deletions

5
.gitignore vendored
View File

@ -19,3 +19,8 @@ tags
# Persistent undo
[._]*.un~
# ---> cc
# compiled files
*.o
/rush-02
a.out

46
Makefile Normal file
View File

@ -0,0 +1,46 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: achubuko <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# 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)

22
ex00/main.c Normal file
View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush-02.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

17
ex00/main.h Normal file
View File

@ -0,0 +1,17 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rush-02.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <unistd.h>
# include <stdlib.h>
#endif