This repository was archived by the owner on Nov 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhbcmake.csh
executable file
·178 lines (158 loc) · 3.82 KB
/
hbcmake.csh
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#! /bin/csh -fe
# hbcmake - make for Haskell programs
# Author: Thomas Hallgren, [email protected]
if ($?LMLDIR) then
set lib = $LMLDIR/bin
else
set lib = /usr/local/lib/lmlc/bin
endif
#set exec = 'csh -ef'
set exec = 'sh -e'
set hversion
set usehlibs
set modules = ( )
set flags = ( )
set rtflags = ( ) # run-time flags for lmlmk
set xdgflags = ( )
setenv LMLMK_LANG hbc
if ( ! $?LMLMK ) setenv LMLMK $lib/lmlmk
if ( ! -x $LMLMK ) setenv LMLMK /usr/local/lib/lmlc/bin/lmlmk
if ( ! $?OLDER ) setenv OLDER $lib/older
if ( ! -x $OLDER ) setenv OLDER /usr/local/lib/lmlc/bin/older
#if ( ! $?HBC ) setenv HBC $lib/hbcmakehbc
#if ( ! -x $HBC ) setenv HBC /usr/local/lib/lmlc/bin/hbcmakehbc
if ( ! $?HBC ) setenv HBC hbc
setenv LMLINCLUDE . # list of source directories (misleading var name!!)
if ( ! $?LMLDIR ) setenv LMLDIR /usr/local/lib/lmlc # Or vlmlc ...
if ( ! $?HBCINCPATH ) then
setenv HBCINCPATH ''
else
unset usehlibs
endif
# Take compiler/linker flags from the environment
if ( ! $?HBCFLAGS ) then
setenv HBCFLAGS ''
endif
if ( ! $?LDFLAGS ) then
setenv LDFLAGS ''
endif
while ( $#argv > 0 )
switch ( $1 )
case -1.2:
set hversion = -1.2
breaksw
case -1.3:
set hversion = -1.3
breaksw
case -xdg:
# Show dependency graph with xhbdg instead of compiling
set xdg
breaksw
case -t:
case -g
set quiet
case -P:
case -debug:
case -n:
set exec = cat
case -s:
set flags = ( $flags $1 )
breaksw
case -[AHhBSX]*:
case -gc*:
#Any more useful run-time flags?
set rtflags = ( $rtflags $1 )
breaksw
case -f:
shift
set makefile = $1
breaksw
case -d:
#-d switches on distributed make. Needs distcom to work.
setenv LMLMKDISTR ''
breaksw
case -C:
shift
setenv HBCFLAGS "$HBCFLAGS $1"
breaksw
case -nd:
case -strip:
breaksw
case -nostrip:
set nostrip
breaksw
case -[xy]space:
set xdgflags = ( $xdgflags $1 $2 )
shift
breaksw
case -o:
shift
setenv LDFLAGS "$LDFLAGS -o $1"
breaksw
case *.so:
case *.a:
case -l*:
setenv LDFLAGS "$LDFLAGS $1"
breaksw
case -i:
unset usehlibs
breaksw
case -i*:
setenv HBCINCPATH "`echo $1 | sed -e s/-i//`:$HBCINCPATH"
breaksw
case -I:
shift
setenv LMLINCLUDE "${LMLINCLUDE}:$1"
setenv HBCFLAGS "$HBCFLAGS -i$1" # should not be used when linking !!!
breaksw
case -T:
setenv HBCFLAGS "$HBCFLAGS $1"
set nostrip
breaksw
case -*:
setenv HBCFLAGS "$HBCFLAGS $1"
breaksw
default:
set modules = ( $modules $1 )
breaksw
endsw
shift
end
if ( $?usehlibs ) then
if ($hversion == -1.2) then
setenv HBCINCPATH "$HBCINCPATH":.:$LMLDIR/hbc_library
else
setenv HBCINCPATH "$HBCINCPATH":.:$LMLDIR/hbc_library1.3:$LMLDIR/hlib1.3/
endif
endif
if(! $?nostrip) setenv LDFLAGS "$LDFLAGS -s"
if ( $#modules < 1 ) then
echo 'Usage: hbcmake [-n] [-t] [-g] [-s] [-d] [-f makefile] modules'
exit 1
endif
if ( ! $?makefile ) then
if ( -r Makefile ) then
set makefile = Makefile
else
set makefile = makefile
endif
endif
# Also try to extract compiler/linker flags from a Makefile
if ( -r $makefile ) then
setenv HBCFLAGS "$HBCFLAGS `grep '^[ ]*HBCFLAGS[ ]*=' $makefile | sed 's/.*=//'`"
setenv LDFLAGS "$LDFLAGS `grep '^[ ]*LDFLAGS[ ]*=' $makefile | sed 's/.*=//'`"
endif
setenv HBCFLAGS "$hversion $HBCFLAGS"
#if ( ! $?quiet ) then
# echo setenv HBCFLAGS $HBCFLAGS
# echo setenv LDFLAGS $LDFLAGS
# echo setenv OLDER $OLDER
# echo setenv HBCINCPATH $HBCINCPATH
#endif
#Here we go...
if ( $?xdg ) then
echo xhbdg $rtflags $modules $xdgflags
xhbdg $rtflags $modules $xdgflags
else
$LMLMK $rtflags - $flags $modules | $exec
endif