/
Makefile
205 lines (162 loc) · 3.26 KB
/
Makefile
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
UNAME_KERNEL := $(shell uname -s)
UNAME_MACHINE := $(shell uname -m)
INSTALLDIR := /u/tsjlc/bin
# To make everything be rebuilt if the Makefile changes, uncomment
#ALL_DEPEND := Makefile
ifeq "${UNAME_KERNEL}" "OS/390"
OSTYPE := zOS
else
ifeq "${UNAME_KERNEL}" "Linux"
ifeq "${UNAME_MACHINE}" "s390x"
OSTYPE := zLinux
else
OSTYPE := Linux
endif
else
$(error "Unknown kernel type ${UNAME_KERNEL}")
endif
endif
EMPTY =
#DEBUG = -g
ifneq "${DEBUG}" "-g"
OPT = -O2
DEBUG = -DNDEBUG
endif
ifeq "${OSTYPE}" "zLinux"
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
CPPFLAGS = \
-I. \
-m32 \
-Wall \
-D__STDC_FORMAT_MACROS \
-D_XOPEN_SOURCE=600 \
${SORT_DEFINITIONS} \
${EMPTY}
CC = gcc
CFLAGS = \
${OPT} ${DEBUG} \
-std=c99 \
${EMPTY}
CXX = g++
CXXFLAGS = \
${OPT} ${DEBUG} \
${EMPTY}
LINK = g++ -m32 -lpthread ${DEBUG}
endif
ifeq "${OSTYPE}" "zOS"
LOADLIB := x.load
DEPFLAGS = -MT $@ -MG -qmakedep=gcc -MF $(DEPDIR)/$*.Td
SYS_INCLUDE = /usr/include
CPPFLAGS = \
-I. \
-I${SYS_INCLUDE} \
-D${OSTYPE} \
-D_ENHANCED_ASCII_EXT=0x42010000 \
-D_XOPEN_SOURCE=600 \
-D_XOPEN_SOURCE_EXTENDED=1 \
-D__STDC_FORMAT_MACROS \
-D__MV17195__ \
${EMPTY}
ASCII := -qebcdic
CC = xlc \
-q32 \
${ASCII} \
-qasm \
-qlanglvl=extc99 \
-qseverity=e=CCN3296 -qseverity=e=CCN3950 \
-qnocse -qnosearch \
${EMPTY}
ifneq "${LIST}" ""
LISTOPT = -V -qlist=${basename $<}.lst
endif
CFLAGS = \
${OPT} ${DEBUG} ${LISTOPT} \
-qsuppress=CCN4108\
${EMPTY}
CXX := xlC \
-q32 \
${ASCII} \
-qasm \
-qasmlib="//'SYS1.MACLIB'" \
-Wc,xplink -Wl,xplink \
-qlanglvl=longlong \
${EMPTY}
CXXFLAGS = \
${OPT} ${DEBUG} ${LISTOPT} \
-qsuppress=CCN6639 \
${EMPTY}
# Assembly code stuff
AS := as
ASLIST := -aegmrsx
ASOPTS := \
-mgoff \
-mobject \
-msectalgn=4096 \
-mflag=nocont \
--"TERM,LC(0)" \
-g \
--gadata \
-I vendor.xdc.xdcmacs \
-I . \
${EMPTY}
ASDEPEND := \
${EMPTY}
# Assemble a .s source file if the corresponding .o is older
%.o : %.s ${ASDEPEND}
${AS} ${ASLIST}=$(basename $<).lst ${ASOPTS} -o $@ $<
LINK = xlC ${DEBUG} ${ASCII} -q32
endif
ifeq "${OSTYPE}" "zOS"
ZOS_SRCS = \
${EMPTY}
endif
# List all source files (NOT headers) in SRCS; these will be
# processed to have dependencies auto-generated
SRCS = \
smp.c \
sample.c \
${EMPTY}
# Targets start here
ifeq "${OSTYPE}" "zOS"
PROGRAMS := smp sample
endif
ifeq "${OSTYPE}" "zLinux"
PROGRAMS :=
endif
default: smp
ifeq "${OSTYPE}" "zOS"
MVSOBJS := \
${EMPTY}
endif
smp: smp.o \
${MVSOBJS} \
${EMPTY}
${LINK} -o $@ $^
# cp -X $@ //x.load
sample: sample.o \
${MVSOBJS} \
${EMPTY}
${LINK} -o $@ $^
install: smp
cp ./smp ${INSTALLDIR}/smp
clean:
rm -f ${PROGRAMS} *.o *~ *.dbg *.lst *.ad $(DEPDIR)/*
veryclean: clean
rmdir $(DEPDIR)
# Stolen dependency generation code
DEPDIR := .d
$(shell mkdir -p $(DEPDIR) >/dev/null)
COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
POSTCOMPILE = mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
%.o : %.c
%.o : %.c $(DEPDIR)/%.d ${ALL_DEPEND}
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(POSTCOMPILE)
%.o : %.cpp
%.o : %.cpp $(DEPDIR)/%.d ${ALL_DEPEND}
$(COMPILE.cc) $(OUTPUT_OPTION) $<
$(POSTCOMPILE)
$(DEPDIR)/%.d: ;
.PRECIOUS: $(DEPDIR)/%.d
-include $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS)))