特定のターゲットに対してのみincludeディレクティブを使用したいとします。私はmakefileが不必要に生成されているので、ターゲットが必要ないときには他のmakefileを実行したくありません。特定のターゲットに対してmakefileでincludeディレクティブを使用する方法
したがって、ターゲット上で条件付きであるincludeディレクティブを条件付きで使用する方法はありますか?または、何らかの形でincludeディレクティブをターゲットの前提条件にする。ここで
は、私がこれまで持っているものです。
# Flags
INCDIR = $(CURDIR)/include
CFLAGS = -Wall -Wno-overflow -Wno-uninitialized -pedantic -std=c99 -I$(INCDIR) -O3
LFLAGS = -flat_namespace -dynamiclib -undefined dynamic_lookup
# Directory names
# Set vpath search paths
vpath %.h include
vpath %.c src
vpath %.o build
vpath %.d build
# Get files for the core library
CORE_FILES = $(wildcard src/*.c)
CORE_OBJS = $(patsubst src/%.c, build/%.o, $(CORE_FILES))
CORE_DEPS = $(CORE_OBJS:.o=.d)
# Core library target linking
core : $(CORE_OBJS) | bin
$(CC) $(LFLAGS) -o bin/libcbitcoin.2.0.dylib $(CORE_OBJS)
# Include header prerequisites (How to do only for "core" target?)
include $(CORE_DEPS)
# Makefiles for header dependencies.
$(CORE_DEPS): build/%.d: src/%.c | build
rm -f [email protected]; \
$(CC) -I$(INCDIR) -MM $< -MT '$(@:.d=.o) [email protected]' > [email protected]
# Objects depend on directory
$(CORE_OBS) : | build
# Create build directory
build:
mkdir build
# Create bin directory
bin:
mkdir bin
# Core Compilation
$(CORE_OBJS): build/%.o: src/%.c
$(CC) -c $(CFLAGS) $< -o [email protected]
# Depencies require include/CBDependencies.h as a prerequisite
build/CBOpenSSLCrypto.o: include/CBDependencies.h
# Crypto library target linking
crypto : build/CBOpenSSLCrypto.o -lcrypto -lssl | bin
$(CC) $(LFLAGS) -o bin/libcbitcoin-crypto.2.0.dylib build/CBOpenSSLCrypto.o -lcrypto -lssl
# Crypto library compile
build/CBOpenSSLCrypto.o: dependencies/crypto/CBOpenSSLCrypto.c
$(CC) -c $(CFLAGS) $< -o [email protected]
#Clean
clean:
rm -f $(CORE_OBJS) $(CORE_DEPS) build/CBOpenSSLCrypto.o
あなたは、私が 『暗号化』のための「.D」ファイルを含める必要はありませんが、私は 『コア』のために何を伝えることができるはずと(デフォルトゴール)。
ありがとうございました。
これはできますが、*はできません。それはメイクの穀物に逆らって、より良い方法があります。すばやく簡単なアプローチ、あるいは高度で強力なものをご希望ですか? – Beta
それから、私は質問することができます: "穀物"と "これらの"良い方法 "とは何ですか?維持しやすい限り。それが私が望むものです。私は手動でヘッダの前提条件を追加したくありません。 –