Giter Site home page Giter Site logo

justshush / libft_full Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 21 KB

This is the normal libft + ft_printf and get_next_line

Home Page: https://mdinis.pt

Makefile 2.06% C 97.94%
42 42born2code 42cursus 42lisboa 42projects 42school libft libft42

libft_full's Introduction

libft_full

This is the normal libft + ft_printf and get_next_line

Tutorial on how to use this in your projects

1 - So in the makefile you will need to create a var called libdir and give it the name of the lib directory, and then create another variable called LIBFT and assign to it the last var + libft.a. Like this:

libdir = libft
LIBFT = $(libdir)/libft.a

2 - Now before the compiling of the main code (NAME) copy and past this code:

$(LIBFT):
	@make -s -C $(libdir)

3 - Now in the compiling part you will need to add $(LIBFT) after de sources variable. example code

$(NAME): $(LIBFT) $(OBJS)
    @$(CC) $(CFLAGS) $(SRCS) $(LIBFT) -o $(NAME)

4 - Don't forget to also add the lib to the clean and fclean commands:

clean:
#  also add here your way to clean your objects
	@make clean --no-print-directory -C $(libdir)

fclean: clean
	@/bin/rm -rf $(NAME) ${OBJ_DIR} $(LIBFT)

Example of complete code of the Makefile:

NAME = your_project_name

CC = @cc
CFLAGS = -Wall -Wextra -Werror -g

SRC = main.c \
      utils.c \

libdir = libft
LIBFT = $(libdir)/libft.a

OBJ_DIR = obj
SRCS = $(addprefix src/, $(SRC))
OBJS = $(patsubst src/%, $(OBJ_DIR)/%, $(SRCS:%.c=%.o))

all: $(NAME)

$(LIBFT):
	@make -s -C $(libdir)

$(NAME): $(LIBFT) $(OBJS)
    @$(CC) $(CFLAGS) $(SRCS) $(LIBFT) -o $(NAME)

$(OBJ_DIR)/%.o: $(SRCS)
		@mkdir -p $(OBJ_DIR)
		@$(CC) $(CFLAGS) -o $@ -c $<

clean:
  @/bin/rm -rf $(OBJ_DIR)
	@make clean --no-print-directory -C $(libdir)

fclean: clean
	@/bin/rm -rf $(NAME) ${OBJ_DIR} $(LIBFT)

libft_full's People

Contributors

justshush avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.