summaryrefslogtreecommitdiff
path: root/hieronymus/Makefile.am
blob: 5ffb1bdc391c67a2dbcb41e5fc3f35c05f5634a3 (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
# Makefile.am - Makefile for Hieronymus.
# Copyright (C) 2008 Free Software Foundation, Inc.
# Written by Neal H. Walfield.
#
# This file is part of the GNU Hurd.
# 
# The GNU Hurd 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.
#
# This GNU Hurd 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 this program.  If not, see <http://www.gnu.org/licenses/>.

bootdir = $(prefix)/boot
if ! ENABLE_TESTS
boot_PROGRAMS = hieronymus

all-local: hieronymus.stripped
hieronymus.stripped: hieronymus
	strip -o $@ $<
endif

hieronymus_CPPFLAGS = $(USER_CPPFLAGS)
hieronymus_CFLAGS = $(USER_CFLAGS)
hieronymus_LDFLAGS = $(USER_LDFLAGS)
hieronymus_LDADD = $(USER_LDADD) $(addsuffix .o, $(files))

hieronymus_SOURCES = hieronymus.c modules.h

# List of modules to load followed by their priority, weight, and a
# delay (in seconds) at which to start the module.  Each component is
# separated by a !
modules = ruth!1!100
ruth_commandline = -D 3
#modules = activity-distribution!1!100
#modules = shared-memory-distribution
#modules = gcbench!1!200!0 gcbench2!1!400!120

# List of directories relative to the top of the build tree to search
# for binaries.
module_paths = ruth benchmarks

files = $(foreach module,$(modules),$(firstword $(subst !, ,$(module))))

find_binary = \
	$(firstword \
	  $(wildcard \
	    $(addsuffix /$(1),$(addprefix $(top_builddir)/,$(module_paths)))) \
	      $(1):not_found)

md5sum = \
	$(shell md5sum $(1) | awk '{ printf $$1 }' \
		| sed 's/\([0-9a-f]\{2\}\)/0x\1, /g')

tovar = $(subst -,_,$(firstword $(subst !, ,$(1))))

hieronymus.c: modules.h

binaries = $(foreach file,$(files),$(call find_binary,$(file)))

$(files): %: $(binaries) Makefile
	strip -o $@ $<

modules.h: $(files)
modules.h: $(addsuffix .S, $(files)) Makefile
	echo '								\
	  $(foreach module,$(subst -,_,$(modules)),			\
	     extern char $(call tovar,$(module))_start;	\
	     extern char $(call tovar,$(module))_end;)	\
	  struct module modules[] = {					\
	    $(foreach module,$(modules),				\
		{							\
	          "$(firstword $(subst !, ,$(module)))",		\
		  $(wordlist 2, 2, $(subst !, ,$(module))) + 0,		\
		  $(wordlist 3, 3, $(subst !, ,$(module))) + 0,		\
		  $(wordlist 4, 4, $(subst !, ,$(module))) + 0,		\
		  { $(foreach arg,$($(call tovar,$(module))_commandline), \
			"$(arg)", ) },					\
	          &$(call tovar,$(module))_start,			\
	          &$(call tovar,$(module))_end,				\
		  { $(call md5sum,$(firstword $(subst !, ,$(module)))) }\
		},							\
	    )								\
	    };' > $@


$(addsuffix .S, $(files)): %.S: module.S $(binaries) Makefile
	$(CPP) -DMODULE=$(subst -,_,$*) -DBINARY=$(@:.S=) $< -o $@

$(addsuffix .o, $(files)): %.o: %
$(addsuffix .o, $(files)): %.o: %.S
	$(CCAS) $(CCASFLAGS) -c -o $@ $<

CLEANFILES = modules.h hieronymus.striped $(files) $(addsuffix .S, $(files))