以下是本人在GNUStep环境下写的Makfile文件总结:
- 执行语句前不要有空格,最好以TAB代替空格
- 变量使用方式是$(CC),而不是$CC,%CC%等形式
附Makefile文件内容:
CC=gcc
CFLAGS=-fconstant-string-class=NSConstantString -I/GNUStep/System/Library/Headers
CLIBRARY=-L/GNUStep/System/Library/Libraries/ -lobjc -lgnustep-base
Main: Main.o Shape.o CarParts.o Engine.o Tire.o Slant.o AllWeatherRadial.o
$(CC) -o Main Main.o Shape.o CarParts.o Engine.o Tire.o Slant.o AllWeatherRadial.o $(CLIBRARY)
Main.o: Test.m Shape.h Engine.h Tire.h AllWeatherRadial.h Slant.h CarParts.h
$(CC) -o Main.o -c Test.m $(CFLAGS) -std=c99
Shape.o: Shape.m Shape.h
$(CC) -c Shape.m $(CFLAGS) -std=c99
CarParts.o: CarParts.m CarParts.h Engine.h Tire.h
$(CC) -c CarParts.m $(CFLAGS) -std=c99
Engine.o: Engine.m Engine.h
$(CC) -c Engine.m $(CFLAGS)
Tire.o: Tire.m Tire.h
$(CC) -c Tire.m $(CFLAGS)
Slant.o: Slant.m Slant.h Engine.h
$(CC) -c Slant.m $(CFLAGS)
AllWeatherRadial.o: AllWeatherRadial.m AllWeatherRadial.h Tire.h
$(CC) -c AllWeatherRadial.m $(CFLAGS)
clean:
rm -f *.o
rm -f Main.exe