summaryrefslogtreecommitdiff
path: root/src/librefetch/librefetchdir/Makefile
blob: 58116bb4af0e91711d58dc5144905ea1765e58b8 (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
#!/usr/bin/env bash
# librefetchdir/Makefile
#
# Copyright (C) 2016 Luke Shumaker <lukeshu@sbcglobal.net>
#
# License: GNU GPLv3+
#
# This file is part of LibreFetch.
#
# LibreFetch is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LibreFetch is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreFetch. If not, see <http://www.gnu.org/licenses/>.

# new = 
librefetchdir := $(dir $(lastword $(MAKEFILE_LIST)))

old_makepkg := $(shell which makepkg)
old_library := $(shell $(shell grep LIBRARY= $(old_makepkg)); echo $$LIBRARY)

new_makepkg = $(new)/makepkg
new_library = $(new)/libmakepkg

targets += $(new_makepkg)
targets += $(patsubst $(old_library)/%,$(new_library)/%,$(shell find $(old_library) -type f))
targets += $(new_library)/tidy/~source_date_epoch.sh

all: $(targets)
.PHONY: all

.SECONDARY:
.DELETE_ON_ERROR:

$(new_makepkg): $(old_makepkg) $(librefetchdir)/makepkg.gen
	<$^ | install -Dm755 /dev/stdin $@

$(new_library)/source.sh: \
$(new_library)/%: $(old_library)/% $(librefetchdir)/libmakepkg/%.gen
	<$^ | install -Dm755 /dev/stdin $@

$(new_library)/tidy/purge.sh $(new_library)/tidy/~source_date_epoch.sh: \
$(new_library)/%: $(librefetchdir)/libmakepkg/%
	mkdir -p $(@D)
	ln -sfT $(abspath $< $@)

$(new_library)/%: $(old_library)/%
	mkdir -p $(@D)
	ln -sfT $(abspath $< $@)