chore(libft): try submodule

This commit is contained in:
gbrochar 2024-03-13 15:41:03 +01:00
parent e98394cc4c
commit 09440fd042
5 changed files with 27 additions and 4 deletions

3
.gitignore vendored
View File

@ -1,6 +1,9 @@
# ft_nm
ft_nm
# libft
inc/libft.h
# vim
*.swp

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "libft2"]
path = libft2
url = https://git.gaetanbrochard.dev/gbrochar/libft2.git

View File

@ -18,6 +18,8 @@ CC = gcc
CFLAGS = -Wall -Werror -Wextra
LIB_NAME = libft2
RED = \033[31m
GREEN = \033[32m
YELLOW = \033[33m
@ -27,12 +29,16 @@ WHITE = \033[0m
all: $(NAME)
$(NAME): $(OBJ) $(INC)
$(NAME): create_libft $(OBJ) $(INC)
@$(CC) $(CFLAGS) -I $(INC_DIR) -c $(SRC)
@mv $(OBJ_FILES) $(OBJ_DIR)
@$(CC) $(CFLAGS) $(OBJ) -o $(NAME)
@$(CC) $(CFLAGS) $(OBJ) -o $(NAME) ./$(LIB_NAME)/libft.a
@echo "$(GREEN)[OK]$(WHITE) $(NAME)"
create_libft:
@make -C $(LIB_NAME)
@cp $(LIB_NAME)/inc/libft.h inc/libft.h
$(OBJ_DIR)%.o: $(SRC_DIR)%.c
@if [ ! -d ./obj ]; then \
mkdir -p ./obj; \
@ -41,9 +47,12 @@ $(OBJ_DIR)%.o: $(SRC_DIR)%.c
@echo "$(CYAN)[CC]$(WHITE) $<"
clean:
@make -C $(LIB_NAME) clean
@rm -f $(INC_DIR)/libft.h
@rm -rf $(OBJ)
fclean: clean
@make -C $(LIB_NAME) fclean
@rm -f $(NAME)
re: fclean all

View File

@ -7,4 +7,6 @@
# include <elf.h>
# include <stdio.h>
# include "libft.h"
#endif

View File

@ -1,7 +1,13 @@
#include "ft_nm.h"
int main(void) {
int fd = open("ft_nm", O_RDONLY);
int main(int ac, char **av) {
char *path = ft_strdup("a.out");
if (ac > 1) {
free(path);
path = av[1];
}
int fd = open(path, O_RDONLY);
printf("Opening file %s with fd %d\n", path, fd);
void *ptr = NULL;
Elf64_Ehdr *header;