如何调用Makefile ,enter to directory A and B,then make them
1. it can work
must be a Makefile and use command make, .sh file maybe can not work!
all:
cd ./A && make all
cd ./B && make all
gcc -c -o main.o main.c
gcc -o math main.o ./A/add.o ./A/sub.o ./B/mul.o ./B/div.o
clean:
rm *.o ./A/*.o ./B/*.o
2. not try
假如在目录M下执行makefile
target1:
make -C A target_n
make -C B target_n
make -C A,进入A目录,执行A目录下的makefile,这时你的工作环境就在A目录,你可以在目录A下makefile中的target_n里面echo `pwd`看下
3. not try
进入到子文件夹运行
SUBDIRS = A B
$(EVERYTHING)::
@for subdir in $(SUBDIRS); \
do \
echo "making $@ in $$subdir"; \
( cd $$subdir && $(MAKE) -f makefile $@ ) || exit 1; \
done
大致就是如此