1
我寫小的makefile,我有目標特定變量的問題,我有這樣的一段代碼:make目標的具體變量
FILE_SOURCE := pliki.c wczytaj_plik.c wypisz_plik.c
CONSOLE_SOURCE := wczytaj_konsola.c wypisz_konsola.c
OTHER_SOURCE := suma.c roznica.c iloczyn.c macierz.c
HEADERS := suma.h roznica.h iloczyn.h wypisz.h wczytaj.h macierz.h
DEFINE_OPT =
NAME=macierze
FILE_OBJECTS := $(FILE_SOURCE:.c=.o)
CONSOLE_OBJECTS := $(CONSOLE_SOURCE:.c=.o)
OTHER_OBJECTS := $(OTHER_SOURCE:.c=.o)
finput: HEADERS+=pliki.h
finput: DEFINE_OPT+=-D WEWY_PLIKI
finput: OTHER_OBJECTS+=$(FILE_OBJECTS)
finput cinput: debug $(NAME)
$(NAME): $(OTHER_OBJECTS) main.o
@echo $^
gcc $(CFLAGS) -o $(NAME) $^
debug:
@echo $(OTHER_OBJECTS)
這是一塊是相關的,當調用
make finput
在目標調試
我得到的所有.o文件,但
@echo $^
只生產
suma.o roznica.o iloczyn.o macierz.o main.o
所以它像不加入FILE_OBJECTS,但在GNU使手動:
There is one more special feature of target-specific variables: when you define a target-specific variable that variable value is also in effect for all prerequisites of this target, and all their prerequisites, etc. (unless those prerequisites override that variable with their own target-specific variable value).
所以這是一個有點怪異的是$(OTHER_OBJECTS)在$(NAME)不包括$ (FILE_OBJECTS),我該如何解決這個問題?
好吧,拼寫出來給我看,我沒有注意到這個細節。 – Andna 2012-03-16 16:46:39