libbsd/Makefile

131 lines
3.4 KiB
Makefile
Raw Normal View History

2005-07-25 01:35:23 +02:00
#
# libbsd
#
LIB_NAME = libbsd
LIB_VERSION_MAJOR = 0
LIB_VERSION_MINOR = 0
2008-07-12 05:35:45 +02:00
LIB_VERSION := $(LIB_VERSION_MAJOR).$(LIB_VERSION_MINOR)
2008-07-12 05:46:18 +02:00
LIB_PKGCONFIG := $(LIB_NAME).pc
LIB_STATIC := $(LIB_NAME).a
LIB_SHARED_SO := $(LIB_NAME).so
LIB_SONAME := $(LIB_SHARED_SO).$(LIB_VERSION_MAJOR)
LIB_SHARED := $(LIB_SONAME).$(LIB_VERSION_MINOR)
2008-07-12 05:35:45 +02:00
TAR_NAME := $(LIB_NAME)-$(LIB_VERSION)
TAR_FILE := $(TAR_NAME).tar.gz
2008-07-09 07:47:09 +02:00
2008-07-12 06:37:13 +02:00
LIB_DIST := Makefile README ChangeLog Versions $(LIB_PKGCONFIG).in
2008-07-09 07:47:09 +02:00
2006-08-25 15:39:32 +02:00
LIB_SRCS := arc4random.c bsd_getopt.c err.c fgetln.c heapsort.c \
humanize_number.c inet_net_pton.c \
hash/md5.c hash/md5hl.c \
setmode.c \
strlcat.c strlcpy.c fmtcheck.c progname.c vis.c unvis.c
2006-02-14 06:39:29 +01:00
LIB_SRCS := $(patsubst %,src/%,$(LIB_SRCS))
2005-07-25 01:35:23 +02:00
LIB_GEN_SRCS := \
man/md5.3 \
src/hash/md5hl.c
2006-03-19 11:25:49 +01:00
LIB_INCLUDES := bsd/err.h bsd/getopt.h bsd/ip_icmp.h bsd/random.h bsd/queue.h bsd/md5.h bsd/string.h \
bsd/bsd.h bsd/cdefs.h bsd/stdlib.h vis.h libutil.h
2005-12-20 21:29:47 +01:00
LIB_MANS := arc4random.3 strlcpy.3 fgetln.3 fmtcheck.3 setmode.3 md5.3
2006-02-14 06:33:38 +01:00
LIB_MANS := $(patsubst %,man/%,$(LIB_MANS))
2005-07-25 01:35:23 +02:00
LIB_STATIC_OBJS = $(LIB_SRCS:%.c=%.o)
LIB_SHARED_OBJS = $(LIB_SRCS:%.c=%.lo)
MK_CFLAGS = -Iinclude/ -include bsd/bsd.h -D_GNU_SOURCE -D__REENTRANT
2005-07-25 01:35:23 +02:00
2008-07-12 06:29:24 +02:00
prefix := /usr
exec_prefix :=
libdir := ${exec_prefix}/lib
usrlibdir := ${prefix}/lib
includedir := ${prefix}/include
pkgconfigdir := ${usrlibdir}/pkgconfig
mandir := ${prefix}/share/man
2008-07-12 06:41:07 +02:00
.PHONY: libs
2005-07-25 01:35:23 +02:00
libs: $(LIB_STATIC) $(LIB_SHARED_SO)
2008-07-12 06:41:07 +02:00
.PHONY: man
man: $(LIB_MANS)
2005-07-25 01:35:23 +02:00
%.lo: %.c
$(CC) -o $@ $(MK_CFLAGS) $(CFLAGS) -DPIC -fPIC -c $<
%.o: %.c
$(CC) -o $@ $(MK_CFLAGS) $(CFLAGS) -c $<
man/md5.3: man/mdX.3
sed -e 's/mdX/md5/g' -e 's/mdY/md4/g' -e 's/MDX/MD5/g' $< > $@
src/hash/md5hl.c: src/hash/helper.c
sed -e 's:hashinc:bsd/md5.h:g' -e 's:HASH:MD5:g' $< > $@
# FIXME: the variables should be preserved unexpanded in the .pc file
$(LIB_PKGCONFIG): $(LIB_PKGCONFIG).in
sed -e 's:@VERSION@:$(LIB_VERSION):' \
-e 's:@prefix@:$(prefix):' \
-e 's:@exec_prefix@:$(exec_prefix):' \
-e 's:@libdir@:$(libdir):' \
-e 's:@includedir@:$(includedir):' \
$< > $@
2005-07-25 01:35:23 +02:00
$(LIB_STATIC): $(LIB_STATIC_OBJS)
ar rcs $@ $^
$(LIB_SHARED_SO): $(LIB_SONAME)
ln -fs $^ $@
$(LIB_SONAME): $(LIB_SHARED)
ln -fs $^ $@
$(LIB_SHARED): $(LIB_SHARED_OBJS)
2005-07-25 01:55:15 +02:00
gcc -shared \
-Wl,-soname -Wl,$(LIB_SONAME) \
-Wl,--version-script=Versions \
-o $@ $^
2005-07-25 01:35:23 +02:00
.PHONY: ChangeLog
ChangeLog:
-git log --stat -C >$@
2008-07-12 06:41:07 +02:00
.PHONY: dist
dist: ChangeLog
2008-07-09 07:47:09 +02:00
mkdir $(TAR_NAME)
cp -a include src man $(LIB_DIST) $(TAR_NAME)
tar czf $(TAR_FILE) $(TAR_NAME)
2008-07-09 07:47:09 +02:00
rm -rf $(TAR_NAME)
gpg -a -b $(TAR_FILE)
2008-07-09 07:47:09 +02:00
2008-07-12 06:41:07 +02:00
.PHONY: install
install: libs man $(LIB_PKGCONFIG)
2008-07-12 06:29:24 +02:00
mkdir -p $(DESTDIR)/$(libdir)
mkdir -p $(DESTDIR)/$(usrlibdir)
mkdir -p $(DESTDIR)/$(includedir)/bsd/
mkdir -p $(DESTDIR)/$(mandir)/man3
mkdir -p $(DESTDIR)/$(pkgconfigdir)
install -m644 $(LIB_STATIC) $(DESTDIR)/$(usrlibdir)
install -m644 $(LIB_SHARED) $(DESTDIR)/$(libdir)
for i in $(LIB_INCLUDES); do \
install -m644 include/$$i $(DESTDIR)/$(includedir)/$$i; \
done
install -m644 $(LIB_MANS) $(DESTDIR)/$(mandir)/man3
install -m644 $(LIB_PKGCONFIG) $(DESTDIR)/$(pkgconfigdir)
ln -sf $(libdir)/$(LIB_SHARED) $(DESTDIR)/$(usrlibdir)/$(LIB_SHARED_SO)
ln -sf $(LIB_SHARED) $(DESTDIR)/$(libdir)/$(LIB_SONAME)
2005-07-25 01:35:23 +02:00
2008-07-12 06:41:07 +02:00
.PHONY: clean
2005-07-25 01:35:23 +02:00
clean:
rm -f $(LIB_PKGCONFIG)
rm -f $(LIB_GEN_SRCS)
2005-07-25 01:35:23 +02:00
rm -f $(LIB_STATIC_OBJS)
rm -f $(LIB_STATIC)
rm -f $(LIB_SHARED_OBJS)
rm -f $(LIB_SHARED) $(LIB_SONAME) $(LIB_SHARED_SO)
2005-07-25 00:51:34 +02:00