mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
Merge pull request #116 from hagen-i2p/library-build
update buildsystem (cleanup and library build for cmake)
This commit is contained in:
commit
67c4c237a9
17
Makefile
17
Makefile
@ -1,4 +1,6 @@
|
|||||||
UNAME := $(shell uname -s)
|
UNAME := $(shell uname -s)
|
||||||
|
SHLIB := libi2pd.so
|
||||||
|
I2PD := i2p
|
||||||
|
|
||||||
ifeq ($(UNAME),Darwin)
|
ifeq ($(UNAME),Darwin)
|
||||||
include Makefile.osx
|
include Makefile.osx
|
||||||
@ -8,22 +10,25 @@ else
|
|||||||
include Makefile.linux
|
include Makefile.linux
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: obj i2p
|
all: obj $(SHLIB) $(I2PD)
|
||||||
|
|
||||||
i2p: $(OBJECTS:obj/%=obj/%)
|
|
||||||
$(CXX) -o $@ $^ $(LDLIBS) $(LDFLAGS) $(LIBS)
|
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.SUFFIXES: .c .cc .C .cpp .o
|
.SUFFIXES: .c .cc .C .cpp .o
|
||||||
|
|
||||||
obj/%.o : %.cpp
|
obj/%.o : %.cpp
|
||||||
$(CXX) -o $@ $< -c $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS)
|
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $<
|
||||||
|
|
||||||
obj:
|
obj:
|
||||||
mkdir -p obj
|
mkdir -p obj
|
||||||
|
|
||||||
|
$(I2PD): $(OBJECTS:obj/%=obj/%)
|
||||||
|
$(CXX) -o $@ $^ $(LDLIBS) $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
$(SHLIB): $(OBJECTS:obj/%=obj/%) api.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -shared -o $@ $^
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -fr obj i2p
|
rm -fr obj $(I2PD) $(SHLIB)
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
CXXFLAGS = -g -Wall
|
CXXFLAGS = -g -Wall -fPIC
|
||||||
CXXVER := $(shell $(CXX) -dumpversion)
|
CXXVER := $(shell $(CXX) -dumpversion)
|
||||||
|
|
||||||
FGREP = fgrep
|
FGREP = fgrep
|
||||||
|
33
api/Makefile
33
api/Makefile
@ -1,33 +0,0 @@
|
|||||||
UNAME := $(shell uname -s)
|
|
||||||
|
|
||||||
ifeq ($(UNAME),Darwin)
|
|
||||||
include ../Makefile.osx
|
|
||||||
else ifeq ($(UNAME), FreeBSD)
|
|
||||||
include ../Makefile.bsd
|
|
||||||
else
|
|
||||||
include ../Makefile.linux
|
|
||||||
endif
|
|
||||||
|
|
||||||
SHARED_LIB = libi2pd.so
|
|
||||||
all: obj $(SHARED_LIB)
|
|
||||||
|
|
||||||
$(SHARED_LIB): $(OBJECTS:obj/%=obj/%)
|
|
||||||
$(CXX) -shared -o $(SHARED_LIB) $^
|
|
||||||
|
|
||||||
.SUFFIXES:
|
|
||||||
.SUFFIXES: .c .cc .C .cpp .o
|
|
||||||
|
|
||||||
obj/%.o : ../%.cpp
|
|
||||||
$(CXX) -o $@ $< -c $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -I.. -fPIC $(CPU_FLAGS)
|
|
||||||
|
|
||||||
obj/api.o: api.cpp
|
|
||||||
$(CXX) -o obj/api.o api.cpp -c $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -I.. -fPIC $(CPU_FLAGS)
|
|
||||||
|
|
||||||
obj:
|
|
||||||
mkdir -p obj
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -fr obj $(SHARED_LIB)
|
|
||||||
|
|
||||||
.PHONY: all
|
|
||||||
.PHONY: clean
|
|
@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
CPP_FILES := ../CryptoConst.cpp ../base64.cpp ../NTCPSession.cpp ../RouterInfo.cpp \
|
|
||||||
../Transports.cpp ../RouterContext.cpp ../NetDb.cpp ../LeaseSet.cpp Tunnel.cpp \
|
|
||||||
../TunnelEndpoint.cpp ../TunnelGateway.cpp ../TransitTunnel.cpp ../I2NPProtocol.cpp \
|
|
||||||
../Log.cpp ../Garlic.cpp ../Streaming.cpp ../Destination.cpp ../Identity.cpp \
|
|
||||||
../SSU.cpp ../SSUSession.cpp ../SSUData.cpp ../util.cpp ../Reseed.cpp ../SSUData.cpp \
|
|
||||||
../aes.cpp ../TunnelPool.cpp ../AddressBook.cpp ../Datagram.cpp api.cpp
|
|
||||||
|
|
||||||
|
|
||||||
H_FILES := ../CryptoConst.h ../base64.h ../NTCPSession.h ../RouterInfo.h ../Transports.h \
|
|
||||||
../RouterContext.h ../NetDb.h ../LeaseSet.h ../Tunnel.h ../TunnelEndpoint.h \
|
|
||||||
../TunnelGateway.h ../TransitTunnel.h ../I2NPProtocol.h ../Log.h ../Garlic.h \
|
|
||||||
../Streaming.h ../Destination.h ../Identity.h ../SSU.h ../SSUSession.h ../SSUData.h \
|
|
||||||
../util.h ../Reseed.h ../SSUData.h ../aes.h ../TunnelPool.h ../AddressBook.h ../version.h \
|
|
||||||
../Signature.h ../TransportSession.h ../Datagram.h api.h
|
|
||||||
|
|
||||||
OBJECTS = $(addprefix obj/, $(notdir $(CPP_FILES:.cpp=.o)))
|
|
||||||
|
|
@ -4,6 +4,7 @@ project ( "i2pd" )
|
|||||||
# configurale options
|
# configurale options
|
||||||
option(WITH_AESNI "Use AES-NI instructions set" OFF)
|
option(WITH_AESNI "Use AES-NI instructions set" OFF)
|
||||||
option(WITH_HARDENING "Use hardening compiler flags" OFF)
|
option(WITH_HARDENING "Use hardening compiler flags" OFF)
|
||||||
|
option(WITH_SHLIB "Build shared library" OFF)
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
|
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
|
||||||
@ -117,7 +118,7 @@ if(NOT DEFINED CRYPTO++_INCLUDE_DIR)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# load includes
|
# load includes
|
||||||
include_directories( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR})
|
include_directories( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR} "${CMAKE_SOURCE_DIR}/..")
|
||||||
|
|
||||||
# show summary
|
# show summary
|
||||||
message(STATUS "---------------------------------------")
|
message(STATUS "---------------------------------------")
|
||||||
@ -129,6 +130,7 @@ message(STATUS "Install prefix: : ${CMAKE_INSTALL_PREFIX}")
|
|||||||
message(STATUS "Options:")
|
message(STATUS "Options:")
|
||||||
message(STATUS " AESNI : ${WITH_AESNI}")
|
message(STATUS " AESNI : ${WITH_AESNI}")
|
||||||
message(STATUS " HARDENING : ${WITH_HARDENING}")
|
message(STATUS " HARDENING : ${WITH_HARDENING}")
|
||||||
|
message(STATUS " SHARED LIB : ${WITH_SHLIB}")
|
||||||
message(STATUS "---------------------------------------")
|
message(STATUS "---------------------------------------")
|
||||||
|
|
||||||
add_executable ( ${PROJECT_NAME} ${SOURCES} )
|
add_executable ( ${PROJECT_NAME} ${SOURCES} )
|
||||||
@ -140,3 +142,9 @@ endif ()
|
|||||||
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
|
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CRYPTO++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
|
||||||
|
|
||||||
install(TARGETS i2pd RUNTIME DESTINATION "bin")
|
install(TARGETS i2pd RUNTIME DESTINATION "bin")
|
||||||
|
|
||||||
|
if (WITH_SHLIB)
|
||||||
|
list(APPEND SOURCES "${CMAKE_SOURCE_DIR}/api.cpp")
|
||||||
|
add_library("lib${PROJECT_NAME}" SHARED ${SOURCES})
|
||||||
|
install(TARGETS "lib${PROJECT_NAME}" LIBRARY DESTINATION "lib")
|
||||||
|
endif ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user