aboutsummaryrefslogtreecommitdiffstats
path: root/community/spim/respect-env.patch
blob: da69699d9beee19e5e863dd963399ecda49df0a0 (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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
This patch has been taken from Gentoo [0] it is required because the
spim build system doesn't pickup our environment variables for
configuring the compilation process (e.g. CC, CFLAGS, LDFLAGS, …).

[0]: https://gitweb.gentoo.org/repo/gentoo.git/tree/app-emulation/spim/files/spim-8.0-r1-respect_env.patch

diff -upr spim-8.0.orig/spim/Makefile spim-8.0/spim/Makefile
--- spim-8.0.orig/spim/Makefile	2018-10-25 17:33:32.657781846 +0200
+++ spim-8.0/spim/Makefile	2018-10-25 17:33:38.627820543 +0200
@@ -66,13 +66,13 @@ DOC_DIR = ../Documentation
 
 
 # Full path for the directory that will hold the executable files:
-BIN_DIR = /usr/local/bin
+BIN_DIR = $(DESTDIR)/usr/bin
 
 # Full path for the directory that will hold the exception handler:
-EXCEPTION_DIR = /usr/local/lib/spim
+EXCEPTION_DIR = $(DESTDIR)/var/lib/spim
 
 # Full path for the directory that will hold the man files:
-MAN_DIR = /usr/local/man/en
+MAN_DIR = $(DESTDIR)/usr/share/man
 
 
 # If you have flex, use it instead of lex.  If you use flex, define this
@@ -104,11 +104,10 @@ ENDIAN=`cat configuration`
 
 DEFINES = $(ENDIAN) $(MEM_SIZES) -DDEFAULT_EXCEPTION_HANDLER="\"$(EXCEPTION_DIR)/exceptions.s\"" -DSPIM_VERSION="\"`cat ../VERSION`\""
 
-CC = gcc
-CFLAGS = -I. -I$(CPU_DIR) $(DEFINES) -g -Wall
+CC ?= gcc
+CFLAGS += -I. -I$(CPU_DIR) $(DEFINES) -Wall
 YFLAGS = -d --file-prefix=y
 YCFLAGS =
-LDFLAGS = -lm
 CSH = bash
 
 # lex.yy.c is usually compiled with -O to speed it up.
@@ -122,10 +121,10 @@ OBJS = spim-utils.o run.o mem.o inst.o d
 
 
 spim:   force
-	make -f Makefile spim2
+	$(MAKE) -f Makefile spim2
 
 spim2:	$(OBJS) spim.o
-	$(CC) -g $(OBJS) spim.o $(LDFLAGS) -o spim -lm
+	$(CC) $(OBJS) spim.o $(LDFLAGS) -o spim -lm
 
 
 force:	configuration
@@ -143,19 +142,19 @@ test:	spim
 	@echo
 	@echo "Testing tt.bare.s:"
 	$(CSH) -c "./spim -delayed_branches -delayed_loads -noexception -file $(TEST_DIR)/tt.bare.s >& test.out"
-	@tail -2 test.out
+	@tail -n2 test.out
 	@echo
 
 	@echo
 	@echo "Testing tt.core.s:"
 	$(CSH) -c "./spim -ef $(CPU_DIR)/exceptions.s -file $(TEST_DIR)/tt.core.s < $(TEST_DIR)/tt.in >& test.out"
-	@tail -2 test.out
+	@tail -n2 test.out
 	@echo
 
 	@echo
 	@echo "Testing tt.endian.s:"
 	$(CSH) -c "./spim -ef $(CPU_DIR)/exceptions.s -file $(TEST_DIR)/tt.endian.s  >& test.out"
-	@tail -2 test.out
+	@tail -n2 test.out
 	@echo
 	@echo
 
@@ -166,13 +165,13 @@ test_bare: spim
 	@echo
 	@echo "Testing tt.alu.bare.s:"
 	$(CSH) -c "./spim -bare -noexception -file $(TEST_DIR)/tt.alu.bare.s >& test.out"
-	@tail -2 test.out
+	@tail -n2 test.out
 	@echo
 
 	@echo
 	@echo "Testing tt.fpt.bare.s:"
 	$(CSH) -c "./spim -bare -noexception -file $(TEST_DIR)/tt.fpu.bare.s >& test.out"
-	@tail -2 test.out
+	@tail -n2 test.out
 	@echo
 	@echo
 
@@ -192,8 +191,6 @@ install: spim
 	install -m 0444 $(CPU_DIR)/exceptions.s $(EXCEPTION_DIR)/exceptions.s
 
 install-man:
-	install -d $(MAN_DIR)
-	install -m 0444 $(DOC_DIR)/spim.man $(MAN_DIR)
 
 very-clean: clean
 	rm -f configuration
diff -upr spim-8.0.orig/xspim/Makefile spim-8.0/xspim/Makefile
--- spim-8.0.orig/xspim/Makefile	2018-10-25 17:33:32.657781846 +0200
+++ spim-8.0/xspim/Makefile	2018-10-25 17:33:38.631153898 +0200
@@ -169,18 +169,18 @@ TCLIBDIR = /usr/lib
 
          VARDBDIR = $(VARDIR)/lib
 
-               AR = ar clq
+               AR = $(AR) clq
 
 # Nice try but useless: make will inherit BOOTSTRAPCFLAGS
 # from  top Makefile
   BOOTSTRAPCFLAGS =
 
-               CC = gcc -m32
-               AS = gcc -m32 -c -x assembler
+               CC ?= gcc -m32
+               AS ?= gcc -m32 -c -x assembler
 
 .SUFFIXES: .cc
 
-              CXX = c++ -m32
+              CXX ?= c++ -m32
 
           CXXFILT = c++filt
 
@@ -199,14 +199,14 @@ CXXEXTRA_INCLUDES =
          COMPRESS = compress
           GZIPCMD = gzip
 
-              CPP = cpp $(STD_CPP_DEFINES)
-           RAWCPP = cpp -undef $(STD_CPP_OPTIONS)
-    PREPROCESSCMD = gcc -m32 -E $(STD_CPP_DEFINES)
+              CPP = $(CPP) $(STD_CPP_DEFINES)
+           RAWCPP = $(CPP) -undef $(STD_CPP_OPTIONS)
+    PREPROCESSCMD = $(CC) -E $(STD_CPP_DEFINES)
 
           INSTALL = install
      INSTALLFLAGS = -c
 
-               LD = gcc -m32 -nostdlib
+               LD ?= $(CC) -nostdlib
 
               LEX = flex -l
                M4 = m4
@@ -270,18 +270,18 @@ CXXEXTRA_INCLUDES =
               COL = col
          COLFLAGS = -b
 
-            MODCC = gcc -m32
+            MODCC ?= $(CC)
 
-           MODCPP = cpp
+           MODCPP = $(CPP)
         MODCFLAGS = $(CFLAGS)
-            MODAS = gcc -m32 -c -x assembler
+            MODAS ?= $(CC) -c -x assembler
        MODASFLAGS =
 
-            MODLD = gcc -m32 -nostdlib
+            MODLD ?= $(CC) -nostdlib
 
        MODLDFLAGS =
 MODLDCOMBINEFLAGS = -r
-            MODAR = ar clq
+            MODAR ?= $(AR) clq
 
         MODRANLIB = ranlib
 
@@ -330,7 +330,7 @@ MODLDCOMBINEFLAGS = -r
 
       ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(INSTALLED_INCLUDES) $(STD_INCLUDES)
        ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(MODULE_DEFINES) $(DEFINES) $(EXTRA_DEFINES)
-           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(MODULE_CFLAGS) $(ALLDEFINES)
+           CFLAGS += $(CCOPTIONS) $(THREADS_CFLAGS) $(MODULE_CFLAGS) $(ALLDEFINES) 
         LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES)
          LDPRELIB =  $(INSTALLED_LIBS)
         LDPOSTLIB =
@@ -339,9 +339,9 @@ MODLDCOMBINEFLAGS = -r
 
            LDLIBS = $(LDPOSTLIBS) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
 
-           CCLINK = $(CC)
+           CCLINK = $(CC) $(LDFLAGS)
 
-          CXXLINK = $(CXX)
+          CXXLINK = $(CXX) $(LDFLAGS)
 
      LDSTRIPFLAGS = -x
    LDCOMBINEFLAGS = -r