diff --git a/CMakeLists.txt b/CMakeLists.txt index de1d2d36..9587ba86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ ############################################################################### cmake_minimum_required(VERSION 3.24) -project(libzoslib CXX C ASM) +project(libzoslib VERSION 4.0.0 LANGUAGES CXX C ASM) include_directories(BEFORE include) @@ -103,3 +103,25 @@ endif() if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) SET(CMAKE_INSTALL_PREFIX "." CACHE PATH "install path" FORCE) endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + +# Configure and install pkgconfig file +set(ZOSLIB_VERSION "${PROJECT_VERSION}") +# Allow users to specify extra flags and libs via CMake variables +if(NOT DEFINED ZOSLIB_EXTRA_CFLAGS) + set(ZOSLIB_EXTRA_CFLAGS "") +endif() +if(NOT DEFINED ZOSLIB_EXTRA_LIBS) + set(ZOSLIB_EXTRA_LIBS "") +endif() +if(NOT DEFINED ZOSLIB_PRIVATE_LIBS) + set(ZOSLIB_PRIVATE_LIBS "") +endif() +configure_file( + ${CMAKE_SOURCE_DIR}/zoslib.pc.in + ${CMAKE_BINARY_DIR}/zoslib.pc + @ONLY +) +install( + FILES ${CMAKE_BINARY_DIR}/zoslib.pc + DESTINATION lib/pkgconfig +) diff --git a/README.md b/README.md index e9d23fc3..b81d93ed 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,12 @@ After ZOSLIB has finished building, install it from `build`: $ cmake --build . --target install ``` +The install step will place: +- Libraries (`libzoslib.a`, `libzoslib.so`, and sidedeck) in `install/lib` +- Header files in `install/include` +- pkg-config file (`zoslib.pc`) in `install/lib/pkgconfig` +- Helper utilities in `install/bin` + ## Quick Start Once we have ZOSLIB built and installed, let's attempt to build our first @@ -196,8 +202,9 @@ In the `main` function, we make use of two ZOSLIB definitions, `__zoslib_version` to obtain the ZOSLIB version, and `getentropy` to generate a list of random values. -3. To compile and link the application, enter the following command: +3. To compile and link the application, enter one of the following commands: +Using explicit paths: ``` bash xlclang++ -qascii -I path/to/zoslib/include -L path/to/build/lib -lzoslib random.cc -o random ``` @@ -206,6 +213,19 @@ or: clang++ -fzos-le-char-mode=ascii -I path/to/zoslib/include -L path/to/build/lib -lzoslib random.cc -o random ``` +Using pkg-config (if zoslib is installed): +``` bash +xlclang++ -qascii $(pkg-config --cflags --libs zoslib) random.cc -o random +``` +or: +``` bash +clang++ -fzos-le-char-mode=ascii $(pkg-config --cflags --libs zoslib) random.cc -o random +``` + +Note: pkg-config automatically includes the following flags: +- Compile flags: `-DZOSLIB_OVERRIDE_CLIB=1 -DZOSLIB_OVERRIDE_CLIB_GETENV=1 -DZOSLIB_OVERRIDE_CLIB_LOCALE_FORCE` +- Libraries: `-lzoslib` and `celquopt.s.o` + 4. To run the application, enter the following command: ``` bash ./random 2 diff --git a/docs/bdwn.png b/docs/bdwn.png index 940a0b95..25e1aa32 100644 Binary files a/docs/bdwn.png and b/docs/bdwn.png differ diff --git a/docs/doc.png b/docs/doc.png index 17edabff..03df57ef 100644 Binary files a/docs/doc.png and b/docs/doc.png differ diff --git a/docs/folderclosed.png b/docs/folderclosed.png index bb8ab35e..b450abb1 100644 Binary files a/docs/folderclosed.png and b/docs/folderclosed.png differ diff --git a/docs/folderopen.png b/docs/folderopen.png index d6c7f676..8e267dcf 100644 Binary files a/docs/folderopen.png and b/docs/folderopen.png differ diff --git a/zoslib.pc.in b/zoslib.pc.in new file mode 100644 index 00000000..1c9033a5 --- /dev/null +++ b/zoslib.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: zoslib +Description: ZOSLIB - A z/OS C/C++ Library providing POSIX APIs, EBCDIC/ASCII conversion, and diagnostic utilities +Version: @ZOSLIB_VERSION@ +URL: https://github.com/ibmruntimes/zoslib +Libs: -L${libdir} -lzoslib ${libdir}/celquopt.s.o@ZOSLIB_EXTRA_LIBS@ +Libs.private:@ZOSLIB_PRIVATE_LIBS@ +Cflags: -I${includedir} -DZOSLIB_OVERRIDE_CLIB=1 -DZOSLIB_OVERRIDE_CLIB_GETENV=1 -DZOSLIB_OVERRIDE_CLIB_LOCALE_FORCE@ZOSLIB_EXTRA_CFLAGS@