这是我的makefile代码:
CC = gcc
IFLAGS = -Iinclude
CFLAGS = -std=c99 -fPIC -pedantic -Wall -Wextra -c # -march=native -ggdb3
LFLAGS = -shared -lX11 # -march=native -ggdb3
DFLAGS = -L./lib -lOSPOOC
TARGET = lib/libOSPOOC.so
SOURCES = $(shell echo src/*.c)
HEADERS = $(shell echo include/*.h)
OBJECTS = $(patsubst %.c,%.o, $(SOURCES))
# CURLIBPATH = $(PWD)/lib
# LDLIBPATH = $(shell echo $(LD_LIBRARY_PATH) | grep $(CURLIBPATH))
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CC) $(LFLAGS) -o $(TARGET) $(OBJECTS)
*.o: *.c
echo allo
$(CC) $(IFLAGS) $(CFLAGS) -o $@ $<
demo: $(TARGET) demo/windows.c
$(CC) $(IFLAGS) -o bin/windows demo/windows.c $(DFLAGS)
clean:
rm -r */*.o */*.so bin/*
规则* .o未被调用,而且,我不知道如何,但它正确编译...
结果:
make demo
gcc -std=c99 -fPIC -pedantic -Wall -Wextra -c -c -o src/OSPobj.o src/OSPobj.c
gcc -std=c99 -fPIC -pedantic -Wall -Wextra -c -c -o src/OSPutl.o src/OSPutl.c
gcc -std=c99 -fPIC -pedantic -Wall -Wextra -c -c -o src/OSPwin.o src/OSPwin.c
gcc -shared -lX11 -o lib/libOSPOOC.so src/OSPobj.o src/OSPutl.o src/OSPwin.o
gcc -Iinclude -o bin/windows demo/windows.c -L./lib -lOSPOOC
问题是-c被使用了两次,并且echo allo不被称为事件......
我不明白,为什么我会有这种奇怪的行为?
答案 0 :(得分:0)
好吧那不是* .o:* .c但是%。o:%。c
* .o代表bash,%。o代表make