|
| 1 | +# This file is part of the herschel package |
| 2 | +# |
| 3 | +# Copyright (c) 2010-2011 Gregor Klinke |
| 4 | +# All rights reserved. |
| 5 | +# |
| 6 | +# This source code is released under the BSD License. |
| 7 | + |
| 8 | +top_srcdir = . |
| 9 | + |
| 10 | +include $(top_srcdir)/config.mk |
| 11 | + |
| 12 | +#---------------------------------------------------------------------- |
| 13 | + |
| 14 | +SUBDIRS = external bootstrap runtime lib build doc tests |
| 15 | + |
| 16 | +ALL_SUBDIRS = external bootstrap runtime lib |
| 17 | + |
| 18 | +DISTFILES = \ |
| 19 | + AUTHORS \ |
| 20 | + BUGS \ |
| 21 | + LICENSE \ |
| 22 | + INSTALL \ |
| 23 | + NEWS \ |
| 24 | + Makefile \ |
| 25 | + README \ |
| 26 | + TODO \ |
| 27 | + config.mk |
| 28 | + |
| 29 | +include $(top_srcdir)/build/pre.mk |
| 30 | + |
| 31 | +.PHONY: build tests docs |
| 32 | + |
| 33 | +build: $(curdir)version.h $(curdir)config-local.h $(BUILDDIR) $(BUILDDIR)/$(BUILDSTYLE) |
| 34 | + (cd bootstrap && $(MAKE) all) |
| 35 | + |
| 36 | +tests: build |
| 37 | + (cd tests/ && $(MAKE) all) |
| 38 | + |
| 39 | +docs: $(curdir)doc/version.texinfo $(BUILDDIR) |
| 40 | + (cd doc/ && $(MAKE) all) |
| 41 | + |
| 42 | +doxygen: doc/Doxyfile $(BUILDDIR) |
| 43 | + doxygen doc/Doxyfile |
| 44 | + |
| 45 | +ifeq ($(BUILDSTYLE),dist-release) |
| 46 | +RUN_UNITTEST_TARGET = no-unittest-in-release |
| 47 | +else |
| 48 | +RUN_UNITTEST_TARGET = run-unittest |
| 49 | +endif |
| 50 | +all-post: $(RUN_UNITTEST_TARGET) |
| 51 | + |
| 52 | +run-unittest: |
| 53 | + @echo "" |
| 54 | + @echo "**** Running unit tests **********" |
| 55 | + $(BUILDDIR)/$(BUILDSTYLE)/hrc$(APPEXT) -UT |
| 56 | + |
| 57 | +no-unittest-in-release: |
| 58 | + |
| 59 | + |
| 60 | +all-local: $(curdir)version.h $(curdir)config-local.h $(curdir)doc/version.texinfo $(BUILDDIR) $(BUILDDIR)/$(BUILDSTYLE) |
| 61 | + |
| 62 | +TAGS: |
| 63 | + find -E . -regex ".*\.mm$$|.*\.cpp$$|.*\.h$$" -print | etags -o TAGS - |
| 64 | + |
| 65 | +clean-local: |
| 66 | + rm -rf $(distdir) $(info-distdir) $(pdf-distdir) |
| 67 | + |
| 68 | +distclean-post: clean-post |
| 69 | + rm -rf TAGS $(curdir)temp/ $(curdir)auto-config-local.mk $(curdir)version.h $(curdir)config-local.h $(curdir)doc/version.texinfo $(PKGDIR) $(BUILDDIR) |
| 70 | + |
| 71 | + |
| 72 | +#--- doc distribution ------------------------------ |
| 73 | + |
| 74 | +dist-doc-info-prepare: $(BUILDDIR) |
| 75 | + -chmod -R a+w $(BUILDDIR)/$(info-distdir) >/dev/null 2>&1; rm -rf $(BUILDDIR)/$(info-distdir) |
| 76 | + mkdir $(BUILDDIR)/$(info-distdir) |
| 77 | + (cd doc/; \ |
| 78 | + $(MAKE) -k info; \ |
| 79 | + cp -f README.dist-info ../$(BUILDDIR)/$(info-distdir)/README >/dev/null 2>&1; \ |
| 80 | + cp -f -r *.info-[0-9] ../$(BUILDDIR)/$(info-distdir) >/dev/null 2>&1; \ |
| 81 | + cp -f -r *.info ../$(BUILDDIR)/$(info-distdir) >/dev/null 2>&1) |
| 82 | + |
| 83 | +dist-doc-pdf-prepare: $(BUILDDIR) |
| 84 | + -chmod -R a+w $(BUILDDIR)/$(pdf-distdir) >/dev/null 2>&1; rm -rf $(BUILDDIR)/$(pdf-distdir) |
| 85 | + mkdir $(BUILDDIR)/$(pdf-distdir) |
| 86 | + (cd doc/; \ |
| 87 | + $(MAKE) -k pdf; \ |
| 88 | + cp -f README.dist-pdf ../$(BUILDDIR)/$(pdf-distdir)/README >/dev/null 2>&1; \ |
| 89 | + cp -f -r *.pdf ../$(BUILDDIR)/$(pdf-distdir) >/dev/null 2>&1) |
| 90 | + |
| 91 | +dist-doc-info-zip: $(PKGDIR) dist-doc-info-prepare |
| 92 | + (cd $(BUILDDIR); \ |
| 93 | + $(ZIP) -r ../$(PKGDIR)/$(info-doc-pkg-name).zip $(info-distdir)) |
| 94 | + |
| 95 | +dist-doc-pdf-zip: $(PKGDIR) dist-doc-pdf-prepare |
| 96 | + (cd $(BUILDDIR); \ |
| 97 | + $(ZIP) -r ../$(PKGDIR)/$(pdf-doc-pkg-name).zip $(pdf-distdir)) |
| 98 | + |
| 99 | +dist-doc-info-tgz: $(PKGDIR) dist-doc-info-prepare |
| 100 | + (cd $(BUILDDIR); \ |
| 101 | + $(TAR) czvf ../$(PKGDIR)/$(info-doc-pkg-name).tar.gz $(info-distdir)) |
| 102 | + |
| 103 | +dist-doc-pdf-tgz: $(PKGDIR) dist-doc-pdf-prepare |
| 104 | + (cd $(BUILDDIR); \ |
| 105 | + $(TAR) czf ../$(PKGDIR)/$(pdf-doc-pkg-name).tar.gz $(pdf-distdir)) |
| 106 | + |
| 107 | +dist-doc-info: dist-doc-info-zip dist-doc-info-tgz |
| 108 | + |
| 109 | +dist-doc-pdf: dist-doc-pdf-zip dist-doc-pdf-tgz |
| 110 | + |
| 111 | +dist-doc: dist-doc-info dist-doc-pdf |
| 112 | + |
| 113 | + |
| 114 | +#--- src distribution ------------------------------ |
| 115 | + |
| 116 | +dist-src-prepare: $(BUILDDIR) distdir |
| 117 | + |
| 118 | +dist-src-zip: $(PKGDIR) dist-src-prepare |
| 119 | + (cd $(BUILDDIR); \ |
| 120 | + $(ZIP) -r ../$(PKGDIR)/$(src-pkg-name).zip $(PACKAGE)-$(VERSION)) |
| 121 | + |
| 122 | +dist-src-tgz: $(PKGDIR) dist-src-prepare |
| 123 | + (cd $(BUILDDIR); \ |
| 124 | + $(TAR) czf ../$(PKGDIR)/$(src-pkg-name).tar.gz $(PACKAGE)-$(VERSION)) |
| 125 | + |
| 126 | +dist-src: dist-src-zip dist-src-tgz |
| 127 | + |
| 128 | +dist: dist-src |
| 129 | + |
| 130 | + |
| 131 | +#--- binary distribution ------------------------------ |
| 132 | + |
| 133 | +dist-bin-pc: $(BUILDDIR) $(PKGDIR) all-local |
| 134 | + if [ "$(TARGET_OS)" = "win" ]; then \ |
| 135 | + echo "Prepare windows distribution"; \ |
| 136 | + (cd src && $(MAKE) all); \ |
| 137 | + pkg_name=$(PACKAGE)-pc-i386-$(VERSION); \ |
| 138 | + bin_pkgdir=$(BUILDDIR)/$$pkg_name; \ |
| 139 | + mkdir $$bin_pkgdir; \ |
| 140 | + cp doc/README.dist-pc-bin $$bin_pkgdir/README; \ |
| 141 | + cp $(BUILDDIR)/hrc.exe $$bin_pkgdir/hrc.exe; \ |
| 142 | + (cd $(BUILDDIR); \ |
| 143 | + $(ZIP) -r ../$(PKGDIR)/$$pkg_name.zip $$pkg_name); \ |
| 144 | + fi |
| 145 | + |
| 146 | +dist-bin-pkg: all-local |
| 147 | + (cd src && BUILDSTYLE=dist-$(BUILDSTYLE) $(MAKE) all) |
| 148 | + |
| 149 | + |
| 150 | +#---------------------------------------------------------------------- |
| 151 | + |
| 152 | +# windows binary distribution |
| 153 | + |
| 154 | +dist-windows: $(PKGDIR) |
| 155 | + (BUILDSTYLE=release $(MAKE) dist-bin-pkg); \ |
| 156 | + (cd build/dist/win && $(MAKE) all); \ |
| 157 | + cp build/dist/win/hrc-*.exe $(PKGDIR) |
| 158 | + |
| 159 | + |
| 160 | +#---------------------------------------------------------------------- |
| 161 | + |
| 162 | +# mac os-x binary distribution |
| 163 | + |
| 164 | +dist-macosx: $(PKGDIR) |
| 165 | + (BUILDSTYLE=release $(MAKE) dist-bin-pkg); \ |
| 166 | + (cd build/dist/mac && $(MAKE) all) |
| 167 | + |
| 168 | + |
| 169 | +#---------------------------------------------------------------------- |
| 170 | + |
| 171 | +dist-all: dist-src dist-doc |
| 172 | + |
| 173 | + |
| 174 | +$(curdir)version.h: Makefile config.mk |
| 175 | + @echo "/* Don't edit this file. It has been created automatically. */" > $@ |
| 176 | + @echo "#ifndef herschel_version_h" >> $@ |
| 177 | + @echo "#define herschel_version_h" >> $@ |
| 178 | + @echo "#define PACKAGE \"$(PACKAGE)\"" >> $@ |
| 179 | + @echo "#define VERSION \"$(VERSION)\"" >> $@ |
| 180 | + @echo "#define COPYRIGHTYEAR \"$(COPYRIGHTYEAR)\"" >> $@ |
| 181 | + @echo "#define COPYRIGHTOWNER \"$(COPYRIGHTOWNER)\"" >> $@ |
| 182 | + @echo "#define HR_BASE_REVISION \"$(BASE_REVISION)\"" >> $@ |
| 183 | + @echo "#endif" >> $@ |
| 184 | + |
| 185 | +$(curdir)doc: |
| 186 | + @if [ ! -d $@ ]; then mkdir $@; fi |
| 187 | + |
| 188 | +$(curdir)doc/version.texinfo: $(curdir)doc Makefile config.mk |
| 189 | + @echo "@c Don't edit this file. It has been created automatically." > $@ |
| 190 | + @echo "@set VERSION $(LANG_VERSION) " > $@ |
| 191 | + @echo "@set COPYRIGHTYEAR $(COPYRIGHTYEAR) " >> $@ |
| 192 | + @echo "@set COPYRIGHTOWNER $(COPYRIGHTOWNER) " >> $@ |
| 193 | + @echo "@set BASEREVISION $(BASE_REVISION) " >> $@ |
| 194 | + |
| 195 | +$(curdir)config-local.h: Makefile config.mk |
| 196 | + @echo "/* Don't edit this file. It has been created automatically. */" > $@ |
| 197 | + @echo "#ifndef herschel_config_local_h" > $@ |
| 198 | + @echo "#define herschel_config_local_h" >> $@ |
| 199 | + @echo "#define HR_INSTDIR_prefix \"$(prefix)/\"" >> $@ |
| 200 | + @echo "#define HR_INSTDIR_bindir \"$(bindir)/\"" >> $@ |
| 201 | + @echo "#define HR_INSTDIR_libdir \"$(libdir)/\"" >> $@ |
| 202 | + @echo "#define HR_INSTDIR_pkglibdir \"$(pkglibdir)/\"" >> $@ |
| 203 | + @echo "#define HR_INSTDIR_includedir \"$(includedir)/\"" >> $@ |
| 204 | + @echo "#define HR_INSTDIR_pkgincludedir \"$(pkgincludedir)/\"" >> $@ |
| 205 | + @echo "#define HR_INSTDIR_datadir \"$(datadir)/\"" >> $@ |
| 206 | + @echo "#define HR_INSTDIR_pkgdatadir \"$(pkgdatadir)/\"" >> $@ |
| 207 | + @echo "#define HR_LLVM_EXE \"$(LLVM_EXE)\"" >> $@ |
| 208 | + @echo "#endif" >> $@ |
| 209 | + |
| 210 | + |
| 211 | +include $(top_srcdir)/build/generic.mk |
0 commit comments