Compare commits

...

3 Commits

Author SHA1 Message Date
gbrochar 673c289b91 chore(Makefile): dl libft before build 2024-03-13 16:00:01 +01:00
gbrochar fec6a59f6b fix(libft2): try submodule 2024-03-13 15:54:42 +01:00
gbrochar 09440fd042 chore(libft): try submodule 2024-03-13 15:41:03 +01:00
6 changed files with 29 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,17 @@ 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:
@git submodule update --init
@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 +48,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

1
libft2 Submodule

@ -0,0 +1 @@
Subproject commit e6177d94293e31fd8e54d568455abb1108ad1f11

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;