From 5be965deec0527b48b393b7aca9cb2a76aec2a99 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 27 Dec 2017 14:01:54 +0100 Subject: [PATCH] Simplify and clarify example Signed-off-by: Joachim Nilsson --- README.md | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5815210..5be8090 100644 --- a/README.md +++ b/README.md @@ -70,39 +70,51 @@ availble in the source tree. } ``` -3. Compile the example, either by hard-coding the paths to the include - file and the library: +3. Compile the example: cd ~/src/ make LDLIBS=-leditline example -In this example I use `make` and rely on its implicit (built-in) rules -to handle all the magic with `gcc`, but you may want to create your own -Makefile for the project. In particular if you don't change the default -prefix (above), because then you need to specify the search path for the -include file(s) and the library manually. A simple `~/src/Makefile`: +Here I use `make` and rely on its implicit (built-in) rules to handle +all the compiler magic, but you may want to create your own Makefile for +the project. In particular if you don't change the default prefix +(above), because then you need to specify the search path for the +include file(s) and the library manually. + +A simple `~/src/Makefile` could look like this: CFLAGS = -I/usr/local/include LDFLAGS = -L/usr/local/lib LDLIBS = -leditline + EXEC = example + OBJS = example.o - all: example + all: $(EXEC) + + $(EXEC): $(OBJS) + + clean: + $(RM) $(OBJS) $(EXEC) + + distclean: clean + $(RM) *.o *~ *.bak Then simply type `make` from your `~/src/` directory. You can also use -`pkg-config` for your `~/src/Makefile`: +`pkg-config` for your `~/src/Makefile`, replace the following lines: CFLAGS = $(shell pkg-config --cflags libeditline) LDFLAGS = $(shell pkg-config --libs-only-L libeditline) LDLIBS = $(shell pkg-config --libs-only-l libeditline) - all: example +Then simply type make, like above. -Then simply type make, like above. However, in most `.rpm` -based distributions `pkg-config` doesn't search in `/usr/local` anymore, -so you need to call make like this: +However, most `.rpm` based distributions `pkg-config` doesn't search in +`/usr/local` anymore, so you need to call make like this: PKG_CONFIG_LIBDIR=/usr/local/lib/pkgconfig make +Debian/Ubuntu based systems do not have this problem. + API ---