-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
101 lines (78 loc) · 2.65 KB
/
Makefile
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
# Version Numbers, generally to be passed to RPMBUILD
VERSION:=0.25
RELEASE:=dev
# Organize phony Targets
CLEANING_T:=ims3clean mostlyclean clean distclean
PYTHON_T:=python-rpms
DB_T:=ims3 ims3clean
.PHONY: distclean rpms dist $(CLEANING_T) $(PYTHON_T) $(DB_T)
# Paths to this or that
PYTHONPATH:=python
IMS_CONFIG:=./ims.json
SQL_DIR:=./sql
RPMDIR:=rpmbuild
# Commands
IMS22IMS3=PYTHONPATH=$(PYTHONPATH) $(PYTHONPATH)/ims22ims3 --config=$(IMS_CONFIG) --sql-dir=$(SQL_DIR)
RPMBUILD=rpmbuild --define '_topdir $(CURDIR)/$(RPMDIR)' \
--define '%version $(VERSION)' \
--define '%release $(RELEASE)' \
--define 'ims_wwwdir /usr/share/ims/html' \
--define 'ims_phpdir /usr/share/php/ims'
# /var/www and /usr/share/php gotta be defined is some RPM macro
# someplace!
# To generate an IMS3 RPM file
DIST_NAME:=BioGRID-IMS3
DIR_NAME=${DIST_NAME}-${VERSION}
TAR_FILE=${DIR_NAME}.tar.gz
RPM_FILE=${DIR_NAME}-${RELEASE}.noarch.rpm
SPEC=$(DIST_NAME).spec
MANIFEST=README.md Makefile ims.json-template $(SPEC) www
DIST_FILES=$(foreach MAN,$(MANIFEST),$(DIR_NAME)/$(MAN))
VERSION_PHP=www/ims/version.php
$(VERSION_PHP): Makefile
echo -e '<?php\ndefine("IMS3_VERSION","${VERSION}-${RELEASE}");' > $@
# Creates python and IMS3 rpms.
rpms: python-rpms rpm
rpm: $(RPM_FILE) $(VERSION_PHP)
# Create IMS3 RPM file
$(RPM_FILE): $(TAR_FILE)
$(RPMBUILD) --target=noarch -tb $<
mv $(RPMDIR)/RPMS/noarch/$@ $@
# Pass making python RPM file to python
python-rpms: $(PYTHONPATH)/sql
(cd $(PYTHONPATH); python setup.py bdist_rpm --doc-files=README.txt)
mv $(PYTHONPATH)/dist/*.rpm .
# Port the IMS2 database to the IMS3 database
ims3:
$(IMS22IMS3) --stage=1
$(IMS22IMS3) --stage=2
$(IMS22IMS3) --stage=3
# This should wipe out the IMS3 database, so use wisely. Needs to run
# in reverse order then making it.
ims3clean:
$(IMS22IMS3) --stage=3 --clean
$(IMS22IMS3) --stage=2 --clean
$(IMS22IMS3) --stage=1 --clean
# Copy the sql directory into the python directory so it can be
# included in the python RPM
$(PYTHONPATH)/sql: sql
mkdir $@
cp $</*.sql $@
# Well, doesn't include SQL or python stuff
dist: $(TAR_FILE)
# Create a tar file with with RPM spec file it it to easily create
# ims3 rpm.
$(TAR_FILE): ${DIR_NAME} ${SPEC} ${VERSION_PHP}
tar -zcvf $@ --exclude=*~ $(DIST_FILES)
# Create a link to ourself with the name we want the tar file to be.
${DIR_NAME}:
ln -s . ${DIR_NAME}
mostlyclean:
$(RM) $(TAR_FILE)
$(RM) -r $(PYTHONPATH)/sql
(cd $(PYTHONPATH); python setup.py clean)
clean: mostlyclean
$(RM) -r $(PYTHONPATH)/build $(PYTHONPATH)/dist ${RPMDIR}
$(RM) *.rpm $(PYTHONPATH)/MANIFEST $(DIR_NAME) $(VERSION_PHP)
distclean: clean
find $(PYTHONPATH)/BioGRID -name \*.pyc | xargs $(RM)