summaryrefslogtreecommitdiff
path: root/pkgtools/libnbcompat/files/Makefile.in
blob: 4f3ac1e8421e02c577db2f4240c9279faa49eaeb (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# $NetBSD: Makefile.in,v 1.25 2004/08/16 17:24:56 jlam 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/fnmatch.h \
		nbcompat/fts.h \
		nbcompat/getopt.h \
		nbcompat/glob.h \
		nbcompat/grp.h \
		nbcompat/limits.h \
		nbcompat/md5.h \
		nbcompat/nbconfig.h \
		nbcompat/nbtypes.h \
		nbcompat/paths.h \
		nbcompat/poll.h \
		nbcompat/pwd.h \
		nbcompat/queue.h \
		nbcompat/regex.h \
		nbcompat/rmd160.h \
		nbcompat/sha1.h \
		nbcompat/stat.h \
		nbcompat/statvfs.h \
		nbcompat/stdio.h \
		nbcompat/stdlib.h \
		nbcompat/string.h \
		nbcompat/time.h \
		nbcompat/tzfile.h \
		nbcompat/unistd.h \
		nbcompat/util.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