barabo / advanced-shell-history

Advanced command line shell history - save your bash history to sqlite3 automatically!
Apache License 2.0
161 stars 17 forks source link

"make build_c" fails on MacOS 10.12.6 with "undeclared identifier 'clock_nanosleep'" #13

Open korpiq opened 5 years ago

korpiq commented 5 years ago

Build fails with database.cpp:221:16: error: use of undeclared identifier 'clock_nanosleep'.

make build_c:

Generating man pages...
mkdir -p files//usr/share/man/man1
sed -e "s:__VERSION__:Version 0.8r2:" man/_ash_log.1 \
      | sed -e "s:__DATE__:2018-01-03:" \
      | gzip -9 -c > ./files/usr/share/man/man1/_ash_log.1.gz
sed -e "s:__VERSION__:Version 0.8r2:" man/ash_query.1 \
      | sed -e "s:__DATE__:2018-01-03:" \
      | gzip -9 -c > ./files/usr/share/man/man1/ash_query.1.gz
cp -af ./files/usr/share/man/man1/_ash_log.1.gz ./files/usr/share/man/man1/_ash_log.py.1.gz
cp -af ./files/usr/share/man/man1/ash_query.1.gz ./files/usr/share/man/man1/ash_query.py.1.gz
chmod 644 ./files/usr/share/man/man1/*ash*.1.gz
mkdir -p files//usr/local/bin
mkdir -p files//usr/local/etc/advanced-shell-history
mkdir -p files//usr/local/lib/advanced_shell_history/sh
chmod 755 files//usr/local/lib/advanced_shell_history/sh files//usr/local/etc/advanced-shell-history
cp shell/* files//usr/local/lib/advanced_shell_history/sh
cp config queries files//usr/local/etc/advanced-shell-history

Compiling source code...
gcc -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_THREADSAFE=0 -c sqlite3.c
sqlite3.c:15855:17: warning: 'OSAtomicCompareAndSwapPtrBarrier' is deprecated: first deprecated in macOS 10.12 - Use
      atomic_compare_exchange_strong() from <stdatomic.h> instead [-Wdeprecated-declarations]
      success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone, 
                ^
/usr/include/libkern/OSAtomicDeprecated.h:547:6: note: 'OSAtomicCompareAndSwapPtrBarrier' has been explicitly marked
      deprecated here
bool    OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue );
        ^
1 warning generated.
g++ -c -g -Wall -DASH_VERSION="\"0.8r2\"" -ansi -pedantic -O2 -o _ash_log.o _ash_log.cpp -lrt
clang: warning: -lrt: 'linker' input unused [-Wunused-command-line-argument]
g++ -c -g -Wall -DASH_VERSION="\"0.8r2\"" -ansi -pedantic -O2 -o command.o command.cpp -lrt
clang: warning: -lrt: 'linker' input unused [-Wunused-command-line-argument]
g++ -c -g -Wall -DASH_VERSION="\"0.8r2\"" -ansi -pedantic -O2 -o config.o config.cpp -lrt
clang: warning: -lrt: 'linker' input unused [-Wunused-command-line-argument]
g++ -c -g -Wall -DASH_VERSION="\"0.8r2\"" -ansi -pedantic -O2 -o database.o database.cpp -lrt
clang: warning: -lrt: 'linker' input unused [-Wunused-command-line-argument]
database.cpp:221:16: error: use of undeclared identifier 'clock_nanosleep'
    int rval = clock_nanosleep(CLOCK_MONOTONIC, 0, &to_sleep, &remaining);
               ^
1 error generated.
make[1]: *** [database.o] Error 1
make: *** [build_c] Error 2

g++ --version:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
mesopelagique commented 4 years ago

I try to compile it on macOS To make it compile (not work)

alanmiller commented 1 year ago

Thanks Eric Marchand I made those 3 changes and it compiles & works for me on MacOS Ventura. osx-ventura.patch

Then I added to my ~/.zshrc

source /usr/local/etc/advanced-shell-history/config
export ASH_CFG_SYSTEM_QUERY_FILE
source /usr/local/lib/advanced_shell_history/sh/zsh

I also had to copy /usr/local/etc/advanced-shell-history/queries to ~/.ash/queries

[ ~/source/advanced-shell-history| main !3 ] 
> ash_query  -q  RCWD |grep build_c |tail -2
        2023-01-19 17:39:02    ash_query  -q  RCWD |grep build_c
        2023-01-19 17:39:25    history|grep build_c
[ ~/source/advanced-shell-history|  main !3 ]                                                      
> history  |grep build_c |tail -2
11039  2023-01-19 17:39  history|grep build_c
11047  2023-01-19 17:46  ash_query  -q  RCWD |grep build_c |tail -2
barabo commented 1 year ago

I'll take the patch and test it out. FWIW - PR's are always welcome, but if it works I'll merge it myself. Thanks @alanmiller!