Skip to content

Commit

Permalink
Add pkg-config support, remove the need for ldconfig, and fix install…
Browse files Browse the repository at this point in the history
…ation into a prefix path containing whitespace.
  • Loading branch information
binki committed Jun 1, 2011
1 parent 3f74842 commit 771eca9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
33 changes: 24 additions & 9 deletions Makefile
Expand Up @@ -7,9 +7,14 @@ SONAME=libapp.so
PREFIX=/usr/local
INCDIR=$(PREFIX)/include/libapp
LIBDIR=$(PREFIX)/lib
PKGCONFIGDIR=$(LIBDIR)/pkgconfig
INSTALL_S = install -s
LN_SF = ln -sf
TESTS=apptest listtest

# Main target
all: $(SONAME) libapp.pc

$(SONAME): $(SONAME).$(VER)

# Dependencies
Expand All @@ -23,16 +28,26 @@ $(SONAME).$(VER): $(OBJS)
.c.o:
$(CC) $(MY_CFLAGS) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

clean:
rm -f $(SONAME).* *.o test/*.o $(TESTS)

install: $(SONAME)
install -d $(LIBDIR)
install -s $(SONAME).$(VER) $(LIBDIR)
install -d $(INCDIR)
install -m 644 -t $(INCDIR) $(HEADERS)
libapp.pc: libapp.pc.in
sed \
-e 's:@PREFIX@:$(PREFIX):g' \
-e 's:@LIBDIR@:$(LIBDIR):g' \
-e 's:@INCLUDEDIR@:$(INCDIR):g' \
-e 's:@PACKAGE_NAME@:libapp:g' \
-e 's:@PACKAGE_VERSION@:$(VER):g' \
$< > $@

@echo "*** Note: you should probably run 'ldconfig'"
clean:
rm -f $(SONAME).* *.o test/*.o *.pc $(TESTS)

install: $(SONAME) libapp.pc
install -d '$(LIBDIR)'
$(INSTALL_S) -t '$(LIBDIR)' $(SONAME).$(VER)
$(LN_SF) $(SONAME).$(VER) '$(LIBDIR)'/$(SONAME)
install -d '$(INCDIR)'
install -m 644 -t '$(INCDIR)' $(HEADERS)
install -d '$(PKGCONFIGDIR)'
install -t '$(PKGCONFIGDIR)' libapp.pc

test: $(SONAME) $(TESTS)

Expand Down
9 changes: 9 additions & 0 deletions libapp.pc.in
@@ -0,0 +1,9 @@
prefix=@PREFIX@
libdir=@LIBDIR@
includedir=@INCLUDEDIR@

Name: @PACKAGE_NAME@
Description: Common routines used by applications
Version: @PACKAGE_VERSION@
Libs: '-L${libdir}' -lapp
Cflags: '-I${includedir}'

0 comments on commit 771eca9

Please sign in to comment.