Reputation: 13
When i compile i receive a error, but the command exist i tested my others projects and works using this same concept of makefile but now in this just dont work i dont know how to fix it, here is output from make command:
make:
mkdir obj
make: mkdir: Command not found
make: *** [Makefile:42: obj/main.o] Error 127
make -w:
make: Entering directory '/mnt/c/project/philo/philo'
mkdir obj
make: mkdir: Command not found
make: *** [Makefile:42: obj/main.o] Error 127
make: Leaving directory '/mnt/c/project/philo/philo'
i dont know why this is appearing but even when a i do a make clean say the same thing to rm, help.
my makefile:
P_INCLUDE = include/
P_SRC = src/
P_OBJ = obj/
#Files
F_SRC = main.c dinner.c legacy.c
OBJ = $(addprefix $(P_OBJ), $(F_SRC:.c=.o))
INC = -I $(P_INCLUDE)
CFLAGS = -Wall -Wextra -Werror
PATH = mkdir $(@D)
RM = rm -rf
cc = clang
NAME = philo
all: $(NAME)
$(NAME): $(OBJ)
@echo '.o created in obj folder'
$(CC) $(CFLAGS) -g $(INC) $(OBJ) -o $(NAME)
@echo 'File(philo) created'
$(P_OBJ)%.o: $(P_SRC)%.c
$(PATH)
$(CC) $(CFLAGS) -g $(INC) -c $< -o $@
clean:
$(RM) $(P_OBJ)
@echo 'All clean'
fclean: clean
$(RM) $(NAME)
re: fclean all
.PHONY: all clean fclean re
Upvotes: 0
Views: 1947
Reputation: 100781
The problem is you have reset the PATH
variable inside your makefile:
PATH = mkdir $(@D)
Now when you run a shell, your $PATH
environment variable contains the text mkdir foo
and so the shell will dutifully try to find the programs you want to run in the directory named mkdir foo
, just as it would try to find them in /usr/bin
if you had PATH = /usr/bin
.
Since there is no directory mkdir foo
, the shell cannot find any programs that it wants to run, including mkdir
.
You should not modify standard system environment variables inside your makefile. Maybe you want to use something like:
MKPATH = mkdir $(@D)
instead.
Upvotes: 3