summaryrefslogtreecommitdiff
path: root/debian/rules
blob: e31ccb27e9eb20b8c57d5ad344170223ed60b760 (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
#!/usr/bin/make -f

include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/architecture.mk

LIBDIR := lib/$(DEB_HOST_MULTIARCH)/freebasic 
BUILD_FBC := fbc
OPTIONS := prefix=/usr libdir=$(LIBDIR)

%:
	dh $@

override_dh_auto_build:
	make V=1 CFLAGS="$(CFLAGS)" $(OPTIONS) FBC='$(BUILD_FBC)'

override_dh_auto_install:
	make V=1 DESTDIR=$(CURDIR)/debian/tmp $(OPTIONS) install

override_dh_auto_clean:
	make $(OPTIONS) clean
	make -C tests $(OPTIONS) clean

override_dh_auto_test:
	make -C tests $(OPTIONS) FBC="$(CURDIR)/bin/fbc -i $(CURDIR)/inc" unit-tests

override_dh_compress:
	dh_compress -X /examples/

GIT_REPO     := https://github.com/freebasic/fbc
DEBIAN_PATH  := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
PACKAGE      := $(shell dpkg-parsechangelog -l$(DEBIAN_PATH)/changelog | awk '/^Source:/ {print $$2}')
SRC_VERSION  := $(shell dpkg-parsechangelog -l$(DEBIAN_PATH)/changelog | awk '/^Version:/ {sub(/-[^-]*/, "", $$2); print $$2}')
GIT_REVISION := $(shell echo $(SRC_VERSION) | sed -r 's,.+git\.(\w+).*,\1,')
TARBALL      := $(PACKAGE)_$(SRC_VERSION).orig.tar.xz
DELETE       := \
	contrib \
	doc/build-win32.bat
.PHONY: get-orig-source
get-orig-source:
	rm -rf get-orig-source $(TARBALL) && mkdir get-orig-source
	git clone $(GIT_REPO) get-orig-source/$(PACKAGE)-$(SRC_VERSION)
	git -C get-orig-source/$(PACKAGE)-$(SRC_VERSION) checkout $(GIT_REVISION)
	find get-orig-source/$(PACKAGE)-$(SRC_VERSION) -name '.*' -print0 | xargs -0 --no-run-if-empty rm -rfv
	cd get-orig-source/$(PACKAGE)-$(SRC_VERSION) && \
		rm -rfv $(DELETE) && \
		echo "FBVERSION := $(SRC_VERSION)" > version.mk
	tar cJf $(TARBALL) -C get-orig-source $(PACKAGE)-$(SRC_VERSION)
	rm -rf get-orig-source
	@echo "  "$(TARBALL)" created; move it to the right destination to build the package"