Thu, 23 Nov 2023 23:33:09 +0100
add update-rules script
Makefile | file | annotate | diff | comparison | revisions | |
make/update-rules.sh | file | annotate | diff | comparison | revisions | |
src/Makefile | file | annotate | diff | comparison | revisions |
1.1 --- a/Makefile Wed Oct 18 21:07:02 2023 +0200 1.2 +++ b/Makefile Thu Nov 23 23:33:09 2023 +0100 1.3 @@ -57,7 +57,7 @@ 1.4 @cd src && $(MAKE) static 1.5 1.6 check: test-compile FORCE 1.7 - $(build_dir)/tests/ucxtest 1.8 + test "$(WITH_TESTS)" = "yes" && $(build_dir)/tests/ucxtest 1.9 1.10 test-compile: 1.11 @(test "$(WITH_TESTS)" = "yes" && cd tests && $(MAKE)) \ 1.12 @@ -69,4 +69,7 @@ 1.13 @(test "$(WITH_DOCS_HTML)" = "yes" && cd docs && $(MAKE) all-html) \ 1.14 || echo "[ Generation of HTML Docs disabled - skipped ]" 1.15 1.16 +update-rules: 1.17 + make/update-rules.sh src 1.18 + 1.19 FORCE:
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/make/update-rules.sh Thu Nov 23 23:33:09 2023 +0100 2.3 @@ -0,0 +1,48 @@ 2.4 +#!/bin/sh 2.5 + 2.6 +dir="$1" 2.7 + 2.8 +if [ -z "$dir" ]; then 2.9 + echo "Usage: $0 <src_dir>" 2.10 + exit 1 2.11 +fi 2.12 + 2.13 +if [ -d "$dir" ]; then 2.14 + : 2.15 +else 2.16 + echo "'$dir' is not a directory" 2.17 + exit 1 2.18 +fi 2.19 + 2.20 +if [ -z "$CC" ]; then 2.21 + for cc in gcc clang ; do 2.22 + if command -v "$cc" > /dev/null ; then 2.23 + CC="$cc" 2.24 + break 2.25 + fi 2.26 + done 2.27 +fi 2.28 + 2.29 +if [ -z "$CC" ]; then 2.30 + echo "No suitable compiler found to generate make rules" 2.31 + exit 1 2.32 +fi 2.33 + 2.34 +if command -v sed > /dev/null ; then 2.35 + : 2.36 +else 2.37 + echo "You need the 'sed' program for this script to work." 2.38 + exit 1 2.39 +fi 2.40 + 2.41 +cd "$dir" 2.42 + 2.43 +mv Makefile Makefile.old 2.44 +sed '/FORCE:/q' Makefile.old > Makefile 2.45 +echo >> Makefile 2.46 +for file in `ls *.c` ; do 2.47 + "$CC" -MT "\$(build_dir)/${file/.c/\$(OBJ_EXT)}" -MM $CFLAGS "$file" 2.48 + printf '\t@echo "Compiling $<"\n' 2.49 + printf '\t$(CC) -o $@ $(CFLAGS) -c $<\n\n' 2.50 +done >> Makefile 2.51 +rm Makefile.old
3.1 --- a/src/Makefile Wed Oct 18 21:07:02 2023 +0200 3.2 +++ b/src/Makefile Thu Nov 23 23:33:09 2023 +0100 3.3 @@ -49,65 +49,72 @@ 3.4 $(SYMLINK) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR) 3.5 $(SYMLINK) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR) $(libdir)/libucx$(SHLIB_EXT) 3.6 3.7 +FORCE: 3.8 + 3.9 $(build_dir)/allocator$(OBJ_EXT): allocator.c cx/allocator.h cx/common.h 3.10 - echo "Compiling $<" 3.11 + @echo "Compiling $<" 3.12 $(CC) -o $@ $(CFLAGS) -c $< 3.13 3.14 $(build_dir)/array_list$(OBJ_EXT): array_list.c cx/array_list.h cx/list.h \ 3.15 cx/common.h cx/collection.h cx/allocator.h cx/iterator.h 3.16 - echo "Compiling $<" 3.17 + @echo "Compiling $<" 3.18 $(CC) -o $@ $(CFLAGS) -c $< 3.19 3.20 -$(build_dir)/buffer$(OBJ_EXT): buffer.c cx/buffer.h cx/common.h cx/allocator.h \ 3.21 - cx/utils.h 3.22 - echo "Compiling $<" 3.23 +$(build_dir)/buffer$(OBJ_EXT): buffer.c cx/buffer.h cx/common.h \ 3.24 + cx/allocator.h cx/utils.h 3.25 + @echo "Compiling $<" 3.26 $(CC) -o $@ $(CFLAGS) -c $< 3.27 3.28 $(build_dir)/compare$(OBJ_EXT): compare.c cx/compare.h cx/common.h 3.29 - echo "Compiling $<" 3.30 + @echo "Compiling $<" 3.31 $(CC) -o $@ $(CFLAGS) -c $< 3.32 3.33 $(build_dir)/hash_key$(OBJ_EXT): hash_key.c cx/hash_key.h cx/common.h 3.34 - echo "Compiling $<" 3.35 + @echo "Compiling $<" 3.36 $(CC) -o $@ $(CFLAGS) -c $< 3.37 3.38 -$(build_dir)/hash_map$(OBJ_EXT): hash_map.c cx/hash_map.h cx/map.h cx/common.h \ 3.39 - cx/collection.h cx/allocator.h cx/iterator.h cx/string.h cx/hash_key.h \ 3.40 - cx/utils.h 3.41 - echo "Compiling $<" 3.42 +$(build_dir)/hash_map$(OBJ_EXT): hash_map.c cx/hash_map.h cx/map.h \ 3.43 + cx/common.h cx/collection.h cx/allocator.h cx/iterator.h cx/string.h \ 3.44 + cx/hash_key.h cx/utils.h 3.45 + @echo "Compiling $<" 3.46 $(CC) -o $@ $(CFLAGS) -c $< 3.47 3.48 -$(build_dir)/linked_list$(OBJ_EXT): linked_list.c cx/linked_list.h cx/common.h \ 3.49 - cx/list.h cx/collection.h cx/allocator.h cx/iterator.h cx/utils.h 3.50 - echo "Compiling $<" 3.51 +$(build_dir)/linked_list$(OBJ_EXT): linked_list.c cx/linked_list.h \ 3.52 + cx/common.h cx/list.h cx/collection.h cx/allocator.h cx/iterator.h \ 3.53 + cx/utils.h 3.54 + @echo "Compiling $<" 3.55 $(CC) -o $@ $(CFLAGS) -c $< 3.56 3.57 $(build_dir)/list$(OBJ_EXT): list.c cx/list.h cx/common.h cx/collection.h \ 3.58 cx/allocator.h cx/iterator.h 3.59 - echo "Compiling $<" 3.60 + @echo "Compiling $<" 3.61 $(CC) -o $@ $(CFLAGS) -c $< 3.62 3.63 $(build_dir)/map$(OBJ_EXT): map.c cx/map.h cx/common.h cx/collection.h \ 3.64 cx/allocator.h cx/iterator.h cx/string.h cx/hash_key.h 3.65 - echo "Compiling $<" 3.66 + @echo "Compiling $<" 3.67 $(CC) -o $@ $(CFLAGS) -c $< 3.68 3.69 -$(build_dir)/mempool$(OBJ_EXT): mempool.c cx/mempool.h cx/common.h cx/allocator.h \ 3.70 - cx/utils.h 3.71 - echo "Compiling $<" 3.72 +$(build_dir)/mempool$(OBJ_EXT): mempool.c cx/mempool.h cx/common.h \ 3.73 + cx/allocator.h cx/utils.h 3.74 + @echo "Compiling $<" 3.75 $(CC) -o $@ $(CFLAGS) -c $< 3.76 3.77 -$(build_dir)/printf$(OBJ_EXT): printf.c cx/printf.h cx/common.h cx/string.h \ 3.78 - cx/allocator.h 3.79 - echo "Compiling $<" 3.80 +$(build_dir)/printf$(OBJ_EXT): printf.c cx/printf.h cx/common.h \ 3.81 + cx/string.h cx/allocator.h 3.82 + @echo "Compiling $<" 3.83 $(CC) -o $@ $(CFLAGS) -c $< 3.84 3.85 -$(build_dir)/string$(OBJ_EXT): string.c cx/string.h cx/common.h cx/allocator.h \ 3.86 - cx/utils.h 3.87 - echo "Compiling $<" 3.88 +$(build_dir)/string$(OBJ_EXT): string.c cx/string.h cx/common.h \ 3.89 + cx/allocator.h cx/utils.h 3.90 + @echo "Compiling $<" 3.91 + $(CC) -o $@ $(CFLAGS) -c $< 3.92 + 3.93 +$(build_dir)/szmul$(OBJ_EXT): szmul.c 3.94 + @echo "Compiling $<" 3.95 $(CC) -o $@ $(CFLAGS) -c $< 3.96 3.97 $(build_dir)/utils$(OBJ_EXT): utils.c cx/utils.h cx/common.h 3.98 - echo "Compiling $<" 3.99 + @echo "Compiling $<" 3.100 $(CC) -o $@ $(CFLAGS) -c $< 3.101