Skip to content

Commit 3f6adc7

Browse files
authored
Merge pull request tensorflow#3497 from petewarden4prs/master
Calculate dependencies for makefile
2 parents 8a4f6ab + a95211b commit 3f6adc7

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

tensorflow/contrib/makefile/Makefile

+15-1
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,16 @@ LIBDIR := $(GENDIR)lib/
112112
BINDIR := $(GENDIR)bin/
113113
PBTGENDIR := $(GENDIR)proto_text/
114114
PROTOGENDIR := $(GENDIR)proto/
115+
DEPDIR := $(GENDIR)dep/
116+
$(shell mkdir -p $(DEPDIR) >/dev/null)
115117

116118
# Settings for the target compiler.
117119
CXX := $(CC_PREFIX) gcc
118120
OPTFLAGS := -O0
119121
CXXFLAGS := --std=c++11 -DIS_SLIM_BUILD $(OPTFLAGS)
120122
LDFLAGS := \
121123
-L/usr/local/lib
124+
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
122125

123126
INCLUDES := \
124127
-I. \
@@ -349,6 +352,10 @@ ifeq ($(TARGET),IOS)
349352
-L$(GENDIR)protobuf_ios/lib \
350353
-lz
351354
endif
355+
OBJDIR := $(OBJDIR)ios_$(IOS_ARCH)/
356+
LIBDIR := $(LIBDIR)ios_$(IOS_ARCH)/
357+
BINDIR := $(BINDIR)ios_$(IOS_ARCH)/
358+
DEPDIR := $(DEPDIR)ios_$(IOS_ARCH)/
352359
endif
353360

354361
# This library is the main target for this makefile. It will contain a minimal
@@ -444,7 +451,9 @@ $(BENCHMARK_NAME): $(BENCHMARK_OBJS) $(LIB_PATH)
444451
# Matches on the normal hand-written TensorFlow C++ source files.
445452
$(OBJDIR)%.o: %.cc | $(PBT_GEN_FILES)
446453
@mkdir -p $(dir $@)
447-
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
454+
@mkdir -p $(dir $(DEPDIR)$*)
455+
$(CXX) $(CXXFLAGS) $(DEPFLAGS) $(INCLUDES) -c $< -o $@
456+
@mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
448457

449458
# Compiles C++ source files that have been generated by protoc.
450459
$(OBJDIR)%.pb.o: $(PROTOGENDIR)%.pb.cc
@@ -511,3 +520,8 @@ clean:
511520
cleantarget:
512521
rm -rf $(OBJDIR)
513522
rm -rf $(BINDIR)
523+
524+
$(DEPDIR)/%.d: ;
525+
.PRECIOUS: $(DEPDIR)/%.d
526+
527+
-include $(patsubst %,$(DEPDIR)/%.d,$(basename $(TF_CC_SRCS)))

tensorflow/contrib/makefile/build_all_ios.sh

+12
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ rm -rf tensorflow/contrib/makefile/downloads
4242
# Pull down the required versions of the frameworks we need.
4343
tensorflow/contrib/makefile/download_dependencies.sh
4444

45+
# TODO(petewarden) - Some new code in Eigen triggers a clang bug, so work
46+
# around it by patching the source.
47+
sed -e 's#static uint32x4_t p4ui_CONJ_XOR = vld1q_u32( conj_XOR_DATA );#static uint32x4_t p4ui_CONJ_XOR; // = vld1q_u32( conj_XOR_DATA ); - Removed by script#' \
48+
-i '' \
49+
tensorflow/contrib/makefile/downloads/eigen-latest/eigen/src/Core/arch/NEON/Complex.h
50+
sed -e 's#static uint32x2_t p2ui_CONJ_XOR = vld1_u32( conj_XOR_DATA );#static uint32x2_t p2ui_CONJ_XOR;// = vld1_u32( conj_XOR_DATA ); - Removed by scripts#' \
51+
-i '' \
52+
tensorflow/contrib/makefile/downloads/eigen-latest/eigen/src/Core/arch/NEON/Complex.h
53+
sed -e 's#static uint64x2_t p2ul_CONJ_XOR = vld1q_u64( p2ul_conj_XOR_DATA );#static uint64x2_t p2ul_CONJ_XOR;// = vld1q_u64( p2ul_conj_XOR_DATA ); - Removed by script#' \
54+
-i '' \
55+
tensorflow/contrib/makefile/downloads/eigen-latest/eigen/src/Core/arch/NEON/Complex.h
56+
4557
# Compile protobuf for the target iOS device architectures.
4658
tensorflow/contrib/makefile/compile_ios_protobuf.sh ${JOBS_COUNT}
4759

tensorflow/contrib/makefile/compile_ios_tensorflow.sh

+5-22
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@ GENDIR=tensorflow/contrib/makefile/gen/
2828
LIBDIR=${GENDIR}lib
2929
LIB_PREFIX=libtensorflow-core
3030

31-
# TODO(petewarden) - Some new code in Eigen triggers a clang bug, so work
32-
# around it by patching the source.
33-
sed -e 's#static uint32x4_t p4ui_CONJ_XOR = vld1q_u32( conj_XOR_DATA );#static uint32x4_t p4ui_CONJ_XOR; // = vld1q_u32( conj_XOR_DATA ); - Removed by script#' \
34-
-i '' \
35-
tensorflow/contrib/makefile/downloads/eigen-latest/eigen/src/Core/arch/NEON/Complex.h
36-
sed -e 's#static uint32x2_t p2ui_CONJ_XOR = vld1_u32( conj_XOR_DATA );#static uint32x2_t p2ui_CONJ_XOR;// = vld1_u32( conj_XOR_DATA ); - Removed by scripts#' \
37-
-i '' \
38-
tensorflow/contrib/makefile/downloads/eigen-latest/eigen/src/Core/arch/NEON/Complex.h
39-
sed -e 's#static uint64x2_t p2ul_CONJ_XOR = vld1q_u64( p2ul_conj_XOR_DATA );#static uint64x2_t p2ul_CONJ_XOR;// = vld1q_u64( p2ul_conj_XOR_DATA ); - Removed by script#' \
40-
-i '' \
41-
tensorflow/contrib/makefile/downloads/eigen-latest/eigen/src/Core/arch/NEON/Complex.h
42-
43-
make -f tensorflow/contrib/makefile/Makefile cleantarget
4431
make -f tensorflow/contrib/makefile/Makefile \
4532
TARGET=IOS IOS_ARCH=ARMV7 LIB_NAME=${LIB_PREFIX}-armv7.a OPTFLAGS="$1" $2 $3
4633
if [ $? -ne 0 ]
@@ -49,7 +36,6 @@ then
4936
exit 1
5037
fi
5138

52-
make -f tensorflow/contrib/makefile/Makefile cleantarget
5339
make -f tensorflow/contrib/makefile/Makefile \
5440
TARGET=IOS IOS_ARCH=ARMV7S LIB_NAME=${LIB_PREFIX}-armv7s.a OPTFLAGS="$1" $2 $3
5541
if [ $? -ne 0 ]
@@ -58,7 +44,6 @@ then
5844
exit 1
5945
fi
6046

61-
make -f tensorflow/contrib/makefile/Makefile cleantarget
6247
make -f tensorflow/contrib/makefile/Makefile \
6348
TARGET=IOS IOS_ARCH=ARM64 LIB_NAME=${LIB_PREFIX}-arm64.a OPTFLAGS="$1" $2 $3
6449
if [ $? -ne 0 ]
@@ -67,7 +52,6 @@ then
6752
exit 1
6853
fi
6954

70-
make -f tensorflow/contrib/makefile/Makefile cleantarget
7155
make -f tensorflow/contrib/makefile/Makefile \
7256
TARGET=IOS IOS_ARCH=I386 LIB_NAME=${LIB_PREFIX}-i386.a OPTFLAGS="$1" $2 $3
7357
if [ $? -ne 0 ]
@@ -76,7 +60,6 @@ then
7660
exit 1
7761
fi
7862

79-
make -f tensorflow/contrib/makefile/Makefile cleantarget
8063
make -f tensorflow/contrib/makefile/Makefile \
8164
TARGET=IOS IOS_ARCH=X86_64 LIB_NAME=${LIB_PREFIX}-x86_64.a OPTFLAGS="$1" $2 $3
8265
if [ $? -ne 0 ]
@@ -86,10 +69,10 @@ then
8669
fi
8770

8871
lipo \
89-
${LIBDIR}/${LIB_PREFIX}-armv7.a \
90-
${LIBDIR}/${LIB_PREFIX}-armv7s.a \
91-
${LIBDIR}/${LIB_PREFIX}-arm64.a \
92-
${LIBDIR}/${LIB_PREFIX}-i386.a \
93-
${LIBDIR}/${LIB_PREFIX}-x86_64.a \
72+
${LIBDIR}/ios_ARMV7/${LIB_PREFIX}-armv7.a \
73+
${LIBDIR}/ios_ARMV7S/${LIB_PREFIX}-armv7s.a \
74+
${LIBDIR}/ios_ARM64/${LIB_PREFIX}-arm64.a \
75+
${LIBDIR}/ios_I386/${LIB_PREFIX}-i386.a \
76+
${LIBDIR}/ios_X86_64/${LIB_PREFIX}-x86_64.a \
9477
-create \
9578
-output ${LIBDIR}/${LIB_PREFIX}.a

0 commit comments

Comments
 (0)