From f3de2dbaf657f9040a4da448c57267de0fef7d33 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 6 Aug 2016 21:03:43 +0200 Subject: CMake: Add basic CMake build system Introduce an initial CMake buildsystem. This build system can build a fully working apt system without translation or documentation. The FindBerkelyDB module is from kdelibs, with some small adjustements to also look in db5 directories. Initial work on this CMake build system started in 2009, and was resumed in August 2016. --- apt-pkg/CMakeLists.txt | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 apt-pkg/CMakeLists.txt (limited to 'apt-pkg') diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt new file mode 100644 index 000000000..ec78f49c4 --- /dev/null +++ b/apt-pkg/CMakeLists.txt @@ -0,0 +1,46 @@ +# Include apt-pkg directly, as some files have #include +include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg) + +add_definitions("-DAPT_PKG_EXPOSE_STRING_VIEW") + +# Set the version of the library +execute_process(COMMAND awk -v ORS=. "/^\#define APT_PKG_M/ {print \$3}" + COMMAND sed "s/\\.\$//" + INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h + OUTPUT_VARIABLE MAJOR OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process(COMMAND grep "^#define APT_PKG_RELEASE" + COMMAND cut -d " " -f 3 + INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h + OUTPUT_VARIABLE MINOR OUTPUT_STRIP_TRAILING_WHITESPACE) + +message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})") +set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt + +# Definition of the C++ files used to build the library +file(GLOB_RECURSE library "*.cc") +file(GLOB_RECURSE headers "*.h") + +# Create a library using the C++ files +add_library(apt-pkg SHARED ${library}) +add_dependencies(apt-pkg apt-pkg-versionscript) +# Link the library and set the SONAME +target_include_directories(apt-pkg + PRIVATE ${ZLIB_INCLUDE_DIRS} + ${BZIP2_INCLUDE_DIRS} + ${LZMA_INCLUDE_DIRS} + ${LZ4_INCLUDE_DIRS}) +target_link_libraries(apt-pkg + PRIVATE -lutil -ldl -lresolv + ${CMAKE_THREAD_LIBS_INIT} + ${ZLIB_LIBRARIES} + ${BZIP2_LIBRARIES} + ${LZMA_LIBRARIES} + ${LZ4_LIBRARIES}) +set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR}) +set_target_properties(apt-pkg PROPERTIES SOVERSION ${MAJOR}) +add_version_script(apt-pkg) + +# Install the library and the header files +install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg) +flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}") -- cgit v1.2.3 From 8c1dbbef35bea4082eacfe4e626e7726b9e84349 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Aug 2016 14:56:53 +0200 Subject: CMake: Check for ptsname_r() again This was dropped in autotools as I found no use of the HAVE_PTSNAME_R macro. Turns out it was typoed as HAVE_PTS_NAME_R. Fix the #ifdef and add checks to CMake for it. Closes: #833674 --- apt-pkg/deb/dpkgpm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index c1b9a28f4..ccfc77d6a 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1086,7 +1086,7 @@ void pkgDPkgPM::StartPtyMagic() /*{{{*/ _error->Errno("unlockpt", "Unlocking the slave of master fd %d failed!", d->master); else { -#ifdef HAVE_PTS_NAME_R +#ifdef HAVE_PTSNAME_R char slave_name[64]; // 64 is used by bionic if (ptsname_r(d->master, slave_name, sizeof(slave_name)) != 0) #else -- cgit v1.2.3 From c85c4bed0a4b32ee2dcbd86ea819e39f3d8beb84 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Aug 2016 17:40:01 +0200 Subject: Get rid of the old buildsystem Bye, bye, old friend. --- apt-pkg/makefile | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 apt-pkg/makefile (limited to 'apt-pkg') diff --git a/apt-pkg/makefile b/apt-pkg/makefile deleted file mode 100644 index 789d3f2fd..000000000 --- a/apt-pkg/makefile +++ /dev/null @@ -1,37 +0,0 @@ -# -*- make -*- -BASE=.. -SUBDIR=apt-pkg - -# Header location -SUBDIRS = deb edsp contrib -HEADER_TARGETDIRS = apt-pkg - -# Bring in the default rules -include ../buildlib/defaults.mak - -# The library name and version (indirectly used from init.h) -include ../buildlib/libversion.mak - -CPPFLAGS+=-DAPT_PKG_EXPOSE_STRING_VIEW -LIBRARY=apt-pkg -MAJOR=$(LIBAPTPKG_MAJOR) -MINOR=$(LIBAPTPKG_RELEASE) -SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil -ldl -lresolv -ifeq ($(HAVE_ZLIB),yes) -SLIBS+= -lz -endif -ifeq ($(HAVE_BZ2),yes) -SLIBS+= -lbz2 -endif -ifeq ($(HAVE_LZMA),yes) -SLIBS+= -llzma -endif -ifeq ($(HAVE_LZ4),yes) -SLIBS+= -llz4 -endif -APT_DOMAIN:=libapt-pkg$(LIBAPTPKG_MAJOR) - -SOURCE = $(sort $(wildcard *.cc */*.cc)) -HEADERS = $(addprefix apt-pkg/,$(notdir $(sort $(wildcard *.h */*.h)))) - -include $(LIBRARY_H) -- cgit v1.2.3