replace readline cmake with equivalent pkg-config call

This commit is contained in:
Yuichi Nishiwaki 2015-05-30 17:58:25 +09:00
parent c9da23c2ee
commit 708f3c2d67
5 changed files with 11 additions and 134 deletions

View File

@ -26,19 +26,20 @@ CONTRIB_DOCS = $(wildcard contrib/*/docs/*.rst)
CFLAGS += -I./extlib/benz/include
# CFLAGS += -std=c89 -ansi -pedantic
LDFLAGS += -lm
prefix = /usr/local
all: CFLAGS += -O2 -Wall -Wextra
all: bin/picrin
include contrib/*/nitro.mk # nitros define test-foo targets
include contrib/*/nitro.mk
debug: CFLAGS += -O0 -g -DDEBUG=1
debug: bin/picrin
bin/picrin: $(PICRIN_OBJS) $(CONTRIB_OBJS) lib/libbenz.a
$(CC) $(CFLAGS) -o $@ $(PICRIN_OBJS) $(CONTRIB_OBJS) lib/libbenz.a -lm
$(CC) $(CFLAGS) -o $@ $(PICRIN_OBJS) $(CONTRIB_OBJS) lib/libbenz.a $(LDFLAGS)
src/load_piclib.c: $(PICRIN_LIBS) $(CONTRIB_LIBS)
perl etc/mkloader.pl $(PICRIN_LIBS) $(CONTRIB_LIBS) > $@
@ -49,8 +50,7 @@ src/init_contrib.c:
lib/libbenz.a: $(BENZ_OBJS)
$(AR) $(ARFLAGS) $@ $(BENZ_OBJS)
%.o: %.c extlib/benz/include/picrin.h extlib/benz/include/picrin/*.h
$(CC) $(CFLAGS) -c -o $@ $<
%.o: extlib/benz/include/picrin.h extlib/benz/include/picrin/*.h
doc: docs/*.rst docs/contrib.rst
$(MAKE) -C docs html

View File

@ -1,17 +0,0 @@
# readline
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/contrib/10.readline/cmake/")
find_package(Libedit)
if (Libedit_FOUND)
add_definitions(${Libedit_DEFINITIONS} -DPIC_READLINE_FOUND=1 -DPIC_READLINE_INCLUDE_DIR_SUFFIX=${Libedit_INCLUDE_DIR_SUFFIX})
include_directories(${Libedit_INCLUDE_DIR})
file(GLOB PICRIN_READLINE_SOURCES ${PROJECT_SOURCE_DIR}/contrib/10.readline/src/*.c)
list(APPEND PICRIN_CONTRIB_INITS readline)
list(APPEND PICRIN_CONTRIB_LIBRARIES ${Libedit_LIBRARIES})
list(APPEND PICRIN_CONTRIB_SOURCES ${PICRIN_READLINE_SOURCES})
add_custom_target(test-readline for test in ${PROJECT_SOURCE_DIR}/contrib/10.readline/t/*.scm \; do bin/picrin "$$test" \; done DEPENDS repl)
set(CONTRIB_TESTS ${CONTRIB_TESTS} test-readline)
endif(Libedit_FOUND)

View File

@ -1,107 +0,0 @@
# - Try to find libedit
# Once done this will define
#
# Libedit_FOUND - system has libedit
# Libedit_INCLUDE_DIRS - the libedit include directory
# Libedit_LIBRARIES - Link these to use libedit
# Libedit_DEFINITIONS - Compiler switches required for using libedit
#
# Copyright (c) 2014 Yuichi Nishiwaki <yuichi@idylls.jp>
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
# Modified for other libraries by Lasse Kärkkäinen <tronic>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
#
if (Libedit_LIBRARIES AND Libedit_INCLUDE_DIRS)
# in cache already
set(Libedit_FOUND TRUE)
else (Libedit_LIBRARIES AND Libedit_INCLUDE_DIRS)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(libedit _Libedit_INCLUDEDIR _Libedit_LIBDIR _Libedit_LDFLAGS _Libedit_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_LIBEDIT libedit)
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_path(Libedit_EDITLINE_INCLUDE_DIR
NAMES
editline/readline.h
editline/history.h
PATHS
${_Libedit_INCLUDEDIR}
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
if (Libedit_EDITLINE_INCLUDE_DIR)
set(Libedit_INCLUDE_DIR_SUFFIX editline)
set(Libedit_INCLUDE_DIR ${Libedit_EDITLINE_INCLUDE_DIR})
else (Libedit_EDITLINE_INCLUDE_DIR)
find_path(Libedit_READLINE_INCLUDE_DIR
NAMES
readline/readline.h
readline/history.h
PATHS
/usr/include/edit
/usr/local/include/edit
/opt/local/include/edit
/sw/include/edit
)
if (Libedit_READLINE_INCLUDE_DIR)
set(Libedit_INCLUDE_DIR_SUFFIX readline)
set(Libedit_INCLUDE_DIR ${Libedit_READLINE_INCLUDE_DIR})
endif (Libedit_READLINE_INCLUDE_DIR)
endif (Libedit_EDITLINE_INCLUDE_DIR)
find_library(Libedit_LIBRARY
NAMES
edit
PATHS
${_Libedit_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
if (Libedit_LIBRARY)
set(Libedit_FOUND TRUE)
endif (Libedit_LIBRARY)
set(Libedit_INCLUDE_DIRS
${Libedit_INCLUDE_DIR}
)
if (Libedit_FOUND)
set(Libedit_LIBRARIES
${Libedit_LIBRARIES}
${Libedit_LIBRARY}
)
endif (Libedit_FOUND)
if (Libedit_INCLUDE_DIRS AND Libedit_LIBRARIES)
set(Libedit_FOUND TRUE)
endif (Libedit_INCLUDE_DIRS AND Libedit_LIBRARIES)
if (Libedit_FOUND)
if (NOT Libedit_FIND_QUIETLY)
message(STATUS "Found libedit: ${Libedit_LIBRARY}, ${Libedit_INCLUDE_DIR}")
endif (NOT Libedit_FIND_QUIETLY)
else (Libedit_FOUND)
if (Libedit_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libedit")
endif (Libedit_FIND_REQUIRED)
endif (Libedit_FOUND)
# show the Libedit_INCLUDE_DIRS and Libedit_LIBRARIES variables only in the advanced view
mark_as_advanced(Libedit_INCLUDE_DIRS Libedit_LIBRARIES)
endif (Libedit_LIBRARIES AND Libedit_INCLUDE_DIRS)

View File

@ -0,0 +1,7 @@
CONTRIB_SRCS += contrib/10.readline/src/readline.c
CONTRIB_INITS += readline
LDFLAGS += `pkg-config libedit --libs`
contrib/src/readline.o: contrib/src/readline.c
$(CC) $(CFLAGS) -o $@ $< `pkg-config libedit --cflags`

View File

@ -7,13 +7,7 @@ forget to use the C++ extern "C" to get it to compile.
*/
#include "picrin.h"
#if PIC_READLINE_INCLUDE_DIR_SUFFIX == readline
#include <readline/readline.h>
#include <readline/history.h>
#else
#include <editline/readline.h>
#include <editline/history.h>
#endif
static pic_value
pic_rl_readline(pic_state *pic)