summaryrefslogtreecommitdiff
path: root/Makefile.in
blob: 30c38127ce985746b40c8c4f0baa098310f1e9a3 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
include Makefile.inc

srcdir= @srcdir@

INSTALL= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
#LIBEFENCE = -lefence

#DEBUG = -g
installprefix=$(ROOT)

#LIBEFENCE = -lefence

CVSTAG = r$(subst .,-,$(VERSION))

################################### Leave this stuff alone

### These are variables meant to be exported

VPATH = $(srcdir)
WARNINGS = -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes 

BINDIR=$(prefix)/bin
RPMBINDIR=$(subst usr/bin,bin,$(BINDIR))
MANDIR=$(prefix)/man/man8
LIBDIR=$(libdir)
INCDIR=$(prefix)/include/rpm
ETCDIR=$(ROOT)/etc

# -----------------------------------------------------------------------

SUBDIRS = misc lib build tools @PO@
INSTSUBDIRS = lib @PO@
OTHERSUBDIRS = docs autodeps
OBJS = rpm.o query.o install.o verify.o checksig.o ftp.o url.o @GETTEXTSTUB@
PROGS = @RPM@ rpm2cpio
LIBS = @LIBS@ @LIBINTL@ @LIBDL@
LOADLIBES = -lbuild $(topdir)/lib/librpm.a -lmisc 

SOURCES = $(subst .o,.c,$(OBJS))

ifeq (.depend,$(wildcard .depend))
TARGET=everything
else
TARGET=depend everything
endif

all: $(TARGET)

rpm: lib/librpm.a build/libbuild.a misc/libmisc.a $(OBJS) 
	$(CC) -o rpm -static $(LDFLAGS) $(OBJS) $(LOADLIBES) $(LIBS) \
		$(LIBEFENCE)

rpm.shared: lib/librpm.a build/libbuild.a $(OBJS)
	$(CC) -o rpm.shared $(LDFLAGS) $(OBJS) $(LOADLIBES) $(LIBS) \
		$(LIBEFENCE)

# we don't normally build this, so ./configure doesn't try very hard
# to make it work
rpmconvert: lib/librpm.a convertdb.o oldrpmdb.o
	$(CC) -o rpmconvert $(LDFLAGS) convertdb.o oldrpmdb.o -lgdbm \
		$(LOADLIBES) $(LIBS)

rpm2cpio: lib/librpm.a rpm2cpio.o
	$(CC) -o rpm2cpio $(LDFLAGS) rpm2cpio.o $(LOADLIBES) $(LIBS)

rpm.o: rpm.c query.h install.h lib/rpmlib.h Makefile
	$(CC) $(CFLAGS) -DRPMNLSPACKAGE=\"$(RPMNLSPACKAGE)\" \
		-DRPMNLSDIR=\"$(RPMNLSDIR)\" \
		-c $(srcdir)/rpm.c

# these rules should be in here, but they drive me batty
#Makefile: Makefile.in misc/Makefile.in lib/Makefile.in build/Makefile.in \
          #tools/Makefile.in po/Makefile.in config.status
	#sh ./config.status

#config.status: configure
	#sh ./config.status --recheck

#configure: configure.in
	#cd $(srcdir); autoconf

everything: make-subdirs $(PROGS)

make-subdirs:
	for d in $(SUBDIRS); do \
		(cd $$d; $(MAKE)) \
		  || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac;\
	done && test -z "$$fail"

newtree:
	rm -f RCS
	ln -sf /usr/rhs/RCS/rpm-2.0 RCS
	for d in $(SUBDIRS) $(OTHERSUBDIRS); do \
		mkdir -p $$d ;\
		(cd $$d; rm -f RCS; ln -sf /usr/rhs/RCS/rpm-2.0/$$d RCS) \
		  || case "$(MFLAGS)" in *k*) fail=yes;; *) exit 1;; esac;\
	done && test -z "$$fail"

$(PROGS): $(OBJS)

install: all
	[ -d $(installprefix)/$(RPMBINDIR) ] || \
		mkdir -p $(installprefix)/$(RPMBINDIR)
	[ -d $(installprefix)/$(RPMNLSDIR) ] || \
		mkdir -p $(installprefix)/$(RPMNLSDIR)
	[ -d $(installprefix)/$(BINDIR) ] || mkdir -p $(installprefix)/$(BINDIR)
	[ -d $(installprefix)/$(MANDIR) ] || mkdir -p $(installprefix)/$(MANDIR)
	[ -d $(installprefix)/$(ETCDIR) ] || mkdir -p $(installprefix)/$(ETCDIR)
	[ -d $(installprefix)/$(LIBDIR) ] || mkdir -p $(installprefix)/$(LIBDIR)
	[ -d $(installprefix)/$(INCDIR) ] || mkdir -p $(installprefix)/$(INCDIR)
	if [ -x ./rpm ]; then \
	    $(INSTALL) -s -m 755 rpm $(installprefix)/$(RPMBINDIR); \
	else \
	    $(INSTALL) -s -m 755 rpm.shared $(installprefix)/$(RPMBINDIR)/rpm; \
	fi
	$(INSTALL) -m 755 $(srcdir)/gendiff $(installprefix)/$(BINDIR)
	$(INSTALL) -m 755 $(srcdir)/find-provides.sh $(installprefix)/$(BINDIR)/find-provides
	$(INSTALL) -m 755 $(srcdir)/find-requires.sh $(installprefix)/$(BINDIR)/find-requires
	$(INSTALL) -s -m 755 rpm2cpio $(installprefix)/$(BINDIR)
	$(INSTALL) -m 644 $(srcdir)/rpm.8 $(installprefix)/$(MANDIR)
	$(INSTALL) -m 644 $(srcdir)/rpm2cpio.8 $(installprefix)/$(MANDIR)
	$(INSTALL) -m 644 $(srcdir)/lib-rpmrc $(installprefix)/$(LIBDIR)/rpmrc
	$(INSTALL) -m 644 $(srcdir)/rpmpopt $(installprefix)/$(LIBDIR)/rpmpopt
	(cd lib; $(MAKE) LIBDIR=$(installprefix)/$(LIBDIR) INCDIR=$(installprefix)/$(INCDIR) install)
	for d in $(INSTSUBDIRS); do \
		(cd $$d; $(MAKE) installprefix=$(installprefix) LIBDIR=$(installprefix)/$(LIBDIR) INCDIR=$(installprefix)/$(INCDIR) install) ;\
	done

.PHONY:		clean
clean:
	for d in $(SUBDIRS); do \
		(cd $$d; $(MAKE) $@) ;\
	done
	rm -f *.a *.o core *~ $(PROGS) rpm.shared
	find . -name "*.orig" -exec rm {} \;
	find . -name core -exec rm {} \;

.PHONY:		distclean
distclean:	
	for d in $(SUBDIRS); do \
		(cd $$d; $(MAKE) $@) ;\
	done
	rm -f *.a *.o core *~ $(PROGS) rpm.shared librpmrc find-provides.sh find-requires.sh
	rm -f .depend Makefile Makefile.inc config.h config.cache config.status config.log lib-rpmrc


.PHONY:		depend
depend:
	$(CPP) $(CFLAGS) -M $(srcdir)/$(SOURCES) > .depend
	for d in $(SUBDIRS); do \
		(cd $$d; $(MAKE) $@) ;\
	done

noconfig:
	find . -name "Makefile" -exec rm {} \; 
	rm -f *gz *rpm config.*

archive: 
	@echo " "
	@echo "I hope you checked everything out and made sure it builds"
	@echo "maybe someday Erik will get around to making that automatic."
	@echo
	@echo "This is version $(VERSION)."
	@sleep 5
	cvs tag -F $(CVSTAG) .
	@rm -rf /tmp/rpm-$(VERSION)
	@mkdir /tmp/rpm-$(VERSION)
	@tar cSpf - * | (cd /tmp/rpm-$(VERSION); tar xSpf -)
	@cd /tmp/rpm-$(VERSION); \
	    make distclean; \
	    rm -f *.tar.gz; \
	    rm -rf CVS */CVS
	@cd /tmp; tar czSpf rpm-$(VERSION).tar.gz rpm-$(VERSION)
	@rm -rf /tmp/rpm-$(VERSION)
	@cp /tmp/rpm-$(VERSION).tar.gz .
	@rm -f /tmp/rpm-$(VERSION).tar.gz 
	@echo " "
	@echo "The final archive is ./rpm-$(VERSION).tar.gz."

ifeq (.depend,$(wildcard .depend))
include .depend
endif