loader: remove shouting from ORB's variable name
[hvf.git] / build.mk
blob715d583d930056c9baf346cbd886edde6762d8b6
2 # Copyright (c) 2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 # SOFTWARE.
23 HVF_VERSION= 0.16-rc3
25 SRCTOP!= hg root
27 OBJCOPY= s390x-linux-objcopy
28 SECTIONS?= .text .data .rodata .rodata.str1.2
30 CC= s390x-linux-gcc
31 CPPFLAGS.ALL= -DVERSION="\"$(HVF_VERSION)\"" \
32 -I $(SRCTOP)/include \
33 -include $(SRCTOP)/include/types.h \
34 $(DEFS)
35 CPPFLAGS.31= $(CPPFLAGS.ALL)
36 CPPFLAGS.64= $(CPPFLAGS.ALL)
37 CFLAGS.OPT?= -O2
38 CFLAGS.ALL= -Wall \
39 $(CFLAGS.OPT) \
40 -g \
41 -m$(BITS) \
42 -mbackchain \
43 -msoft-float \
44 -fno-strict-aliasing \
45 -fno-builtin \
46 -nostartfiles \
47 -nostdlib \
48 -nostdinc
49 CFLAGS.31= $(CFLAGS.ALL) $(CPPFLAGS.31)
50 CFLAGS.64= $(CFLAGS.ALL) $(CPPFLAGS.64)
52 LD= s390x-linux-ld
53 LINKER_SCRIPT= linker.script
54 LDFLAGS.ALL= -T$(LINKER_SCRIPT)
55 LDFLAGS.31= $(LDFLAGS.ALL) -melf_s390
56 LDFLAGS.64= $(LDFLAGS.ALL) -melf64_s390
58 AR= s390x-linux-ar
60 C_SRCS:=${SRCS:M*.c}
61 S_SRCS:=${SRCS:M*.s}
62 Y_SRCS:=${SRCS:M*.y}
63 L_SRCS:=${SRCS:M*.l}
65 GENSRCS:=${Y_SRCS:C/\.y$/.c/} \
66 ${L_SRCS:C/\.l$/.c/}
67 GENHDRS:=${Y_SRCS:C/\.y$/.h/} \
68 ${L_SRCS:C/\.l$/.h/}
70 OBJS:=${C_SRCS:%.c=%.o} \
71 ${S_SRCS:%.s=%.o} \
72 ${GENSRCS:%.c=%.o}
74 all: bin lib
76 clean:
77 .if defined(BIN)
78 rm -f $(BIN) $(BIN).raw
79 .endif
80 .if defined(LIB)
81 rm -f $(LIB).a
82 .endif
83 rm -f $(OBJS) $(CLEANSRCS)
84 .if !empty(GENSRCS) || !empty(GENHDRS)
85 rm -f $(GENSRCS) $(GENHDRS)
86 .endif
88 .if defined(BIN)
89 bin: $(BIN)
90 $(BIN): $(OBJS) $(LINKER_SCRIPT)
91 $(LD) $(LDFLAGS.$(BITS)) -o $(BIN) $(OBJS) $(LD_ADD)
93 $(BIN).raw: $(BIN)
94 $(OBJCOPY) -O binary ${SECTIONS:%=-j %} ${.ALLSRC} ${.TARGET}
95 .else
96 bin:
97 .endif
99 .if defined(LIB)
100 lib: $(LIB).a
101 $(LIB).a: $(OBJS)
102 $(AR) cr ${.TARGET} ${.ALLSRC}
103 .else
104 lib:
105 .endif()
107 # remove built-in .[yl] -> .o rules
108 .y.o:
109 .l.o:
111 .c.o:
112 $(CC) $(CFLAGS.$(BITS)) -c -o ${.TARGET} ${.IMPSRC}
114 .s.o:
115 $(CC) $(CFLAGS.$(BITS)) -D_ASM -x assembler-with-cpp -c -o ${.TARGET} ${.IMPSRC}
117 .y.c:
118 cd ${.IMPSRC:H} && $(SRCTOP)/build/byacc/yacc \
119 -b ${.IMPSRC:T:R} \
120 -d -P -p ${.IMPSRC:T:R:S/grammar//} \
121 -o ${.IMPSRC:T:R}.c ${.IMPSRC:T}
123 .l.c:
124 cd ${.IMPSRC:H} && $(SRCTOP)/build/re2c/re2c \
125 -o ${.IMPSRC:T:R}.c ${.IMPSRC:T}