summaryrefslogtreecommitdiff
path: root/pkgtools/libnbcompat/files/Makefile.in
blob: 75d4208ec5d564aa7d298c580a0a07cf3ae02c4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# $NetBSD: Makefile.in,v 1.22 2003/12/10 07:21:20 grant Exp $
#

srcdir=		@srcdir@
prefix= 	@prefix@
VPATH=		@srcdir@
SHELL=		/bin/sh

CC=		@CC@
CFLAGS=		-I$(srcdir) -I. @INCLUDES@ @CFLAGS@
CPPFLAGS=	@CPPFLAGS@
DEFS=		@DEFS@
INSTALL=	@INSTALL@
LDFLAGS=	@LDFLAGS@

AWK=		@AWK@
AR=		@AR@
RANLIB=		@RANLIB@

LIB=		libnbcompat.a

INCS=		nbcompat.h nbcompat/err.h nbcompat/fts.h nbcompat/getopt.h \
		nbcompat/glob.h nbcompat/md5.h nbcompat/nbconfig.h \
		nbcompat/nbtypes.h nbcompat/poll.h nbcompat/rmd160.h \
		nbcompat/sha1.h nbcompat/statfs.h nbcompat/vis.h

# always use our local glob() implementation.
OBJS=		glob.o @LIBOBJS@

LINK=		$(CCLD) $(CFLAGS) $(LDFLAGS) -o $@
COMPILE=	$(CC) $(CPPFLAGS) $(CFLAGS)

.PHONY: all install clean distclean

all: nbcompat/nbtypes.h nbcompat/nbconfig.h $(LIB)

.c.o: nbcompat/nbtypes.h
	$(COMPILE) $(DEFS) -c $<

$(LIB): $(OBJS)
	$(AR) cr $@ $(OBJS)
	$(RANLIB) $@

nbcompat/nbconfig.h: nbcompat/config.h
	$(AWK) '							\
		BEGIN { process = 1 }					\
		/NBCOMPAT template section follows\./ { process = 0 }	\
		/^\#[ 	]*define[ 	]+PACKAGE_.*/ { next }		\
		/^\#[ 	]*define[ 	]+/ {				\
			if (process == 1) {				\
				guard = $$0;				\
				sub("^#[ 	]*define[ 	]+", "", guard); \
				sub("[ 	]+.*", "", guard);		\
				print "#ifndef " guard;			\
				print $$0;				\
				print "#endif";				\
				next;					\
			}						\
		}							\
		{ print }						\
	' nbcompat/config.h > $@

nbcompat/nbtypes.h: bits
	./bits $@

bits: bits.c
	$(CC) -o bits bits.c

install:
	$(INSTALL) -m 755 -d $(prefix)/lib
	$(INSTALL) -m 555 ${LIB} $(prefix)/lib
	$(RANLIB) $(prefix)/lib/$(LIB)
	$(INSTALL) -m 755 -d $(prefix)/include
	$(INSTALL) -m 755 -d $(prefix)/include/nbcompat
	@for file in $(INCS); do \
		echo "$(INSTALL) -m 444 $$file $(prefix)/include/$$file"; \
		$(INSTALL) -m 444 $$file $(prefix)/include/$$file; \
	done

clean:
	rm -f *.a *.o bits nbcompat/nbtypes.h nbcompat/nbcompat.h

distclean: clean
	rm -f Makefile config.log config.status configure.lineno
	rm -f nbcompat/config.h nbcompat/nbconfig.h