From 708f3c2d67a5ae3926a75fcc5b5a7590a948f2a0 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 30 May 2015 17:58:25 +0900 Subject: [PATCH] replace readline cmake with equivalent pkg-config call --- Makefile | 8 +- contrib/10.readline/CMakeLists.txt | 17 ---- contrib/10.readline/cmake/FindLibedit.cmake | 107 -------------------- contrib/10.readline/nitro.mk | 7 ++ contrib/10.readline/src/readline.c | 6 -- 5 files changed, 11 insertions(+), 134 deletions(-) delete mode 100644 contrib/10.readline/CMakeLists.txt delete mode 100644 contrib/10.readline/cmake/FindLibedit.cmake create mode 100644 contrib/10.readline/nitro.mk diff --git a/Makefile b/Makefile index 29bfd909..8305c3f8 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/contrib/10.readline/CMakeLists.txt b/contrib/10.readline/CMakeLists.txt deleted file mode 100644 index 413e8c19..00000000 --- a/contrib/10.readline/CMakeLists.txt +++ /dev/null @@ -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) diff --git a/contrib/10.readline/cmake/FindLibedit.cmake b/contrib/10.readline/cmake/FindLibedit.cmake deleted file mode 100644 index 9a771988..00000000 --- a/contrib/10.readline/cmake/FindLibedit.cmake +++ /dev/null @@ -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 -# Copyright (c) 2008 Andreas Schneider -# Modified for other libraries by Lasse Kärkkäinen -# -# 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) diff --git a/contrib/10.readline/nitro.mk b/contrib/10.readline/nitro.mk new file mode 100644 index 00000000..91d210b6 --- /dev/null +++ b/contrib/10.readline/nitro.mk @@ -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` diff --git a/contrib/10.readline/src/readline.c b/contrib/10.readline/src/readline.c index fe831ddd..84d3f37f 100644 --- a/contrib/10.readline/src/readline.c +++ b/contrib/10.readline/src/readline.c @@ -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 -#include -#else #include -#include -#endif static pic_value pic_rl_readline(pic_state *pic)