Skip to content

Commit

Permalink
build: make deps/clean prefix=dist_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Feb 29, 2024
1 parent 6bc0afa commit 4ee471e
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions deps.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@ export MAKEFLAGS+=" -j$(( $(nproc) + 1)) "
endif

build ?= build
prefix ?= $(rime_root)

rime_deps = glog googletest leveldb marisa-trie opencc yaml-cpp

.PHONY: all clean-src $(rime_deps)
.PHONY: all clean clean-dist clean-src $(rime_deps)

all: $(rime_deps)

# note: this won't clean output files under include/, lib/ and bin/.
clean: clean-src clean-dist

clean-dist:
git rev-parse --is-inside-work-tree > /dev/null && \
find $(prefix)/bin $(prefix)/include $(prefix)/lib $(prefix)/share \
-depth -maxdepth 1 \
-exec bash -c 'git ls-files --error-unmatch "$$0" > /dev/null 2>&1 || rm -rv "$$0"' {} \; || true
rmdir $(prefix) 2> /dev/null || true

# note: this won't clean output files under bin/, include/, lib/ and share/.
clean-src:
for dep in $(rime_deps); do \
rm -r $(src_dir)/$${dep}/$(build) || true; \
Expand All @@ -28,15 +38,15 @@ glog:
-DBUILD_TESTING:BOOL=OFF \
-DWITH_GFLAGS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(rime_root)" \
-DCMAKE_INSTALL_PREFIX:PATH="$(prefix)" \
&& cmake --build $(build) --target install

googletest:
cd $(src_dir)/googletest; \
cmake . -B$(build) \
-DBUILD_GMOCK:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(rime_root)" \
-DCMAKE_INSTALL_PREFIX:PATH="$(prefix)" \
&& cmake --build $(build) --target install

leveldb:
Expand All @@ -45,22 +55,22 @@ leveldb:
-DLEVELDB_BUILD_BENCHMARKS:BOOL=OFF \
-DLEVELDB_BUILD_TESTS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(rime_root)" \
-DCMAKE_INSTALL_PREFIX:PATH="$(prefix)" \
&& cmake --build $(build) --target install

marisa-trie:
cd $(src_dir)/marisa-trie; \
cmake . -B$(build) \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(rime_root)" \
-DCMAKE_INSTALL_PREFIX:PATH="$(prefix)" \
&& cmake --build $(build) --target install

opencc:
cd $(src_dir)/opencc; \
cmake . -B$(build) \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(rime_root)" \
-DCMAKE_INSTALL_PREFIX:PATH="$(prefix)" \
&& cmake --build $(build) --target install

yaml-cpp:
Expand All @@ -70,5 +80,5 @@ yaml-cpp:
-DYAML_CPP_BUILD_TESTS:BOOL=OFF \
-DYAML_CPP_BUILD_TOOLS:BOOL=OFF \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DCMAKE_INSTALL_PREFIX:PATH="$(rime_root)" \
-DCMAKE_INSTALL_PREFIX:PATH="$(prefix)" \
&& cmake --build $(build) --target install

0 comments on commit 4ee471e

Please sign in to comment.