Mercurial > hg > index.cgi
annotate Makefile @ 560:dba08c7dff96
Fix off by one handling MOD directive optional arguments
Fixes an off by one in handling the optional arguments to the MOD directive
as of changeset 928c033c0cd0.
Thanks to Alex Evans <varmfskii@gmail.com> for reporting the problem and a
suggested fix. This fix is different but should be more stable should the
rest of the parsing code be refactored in the future.
author | William Astle <lost@l-w.ca> |
---|---|
date | Fri, 22 Sep 2023 12:15:09 -0600 |
parents | b2ee86298516 |
children |
rev | line source |
---|---|
10
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
1 # define anything system specific here |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
2 # |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
3 # set these variables if needed |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
4 # PROGSUFFIX: suffix added to binaries |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
5 # BUILDTPREFIX: prefix added to build utilities (cc, etc.) for xcompile |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
6 # can also set them when invoking "make" |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
7 #PROGSUFFIX := .exe |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
8 #BUILDTPREFIX=i586-mingw32msvc- |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
9 |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
10 ifeq ($(PREFIX),) |
275
776a076d1afa
Makefile: Allow DESTDIR for distribution package creation
Tormod Volden <debian.tormod@gmail.com>
parents:
272
diff
changeset
|
11 ifneq ($(DESTDIR),) |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
12 PREFIX = /usr |
275
776a076d1afa
Makefile: Allow DESTDIR for distribution package creation
Tormod Volden <debian.tormod@gmail.com>
parents:
272
diff
changeset
|
13 else |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
14 PREFIX = /usr/local |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
15 endif |
275
776a076d1afa
Makefile: Allow DESTDIR for distribution package creation
Tormod Volden <debian.tormod@gmail.com>
parents:
272
diff
changeset
|
16 endif |
270
35b6787a5b39
Allow make install destination to be overridden
William Astle <lost@l-w.ca>
parents:
269
diff
changeset
|
17 |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
18 LIBDIR = $(PREFIX)/lib |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
19 BINDIR = $(PREFIX)/bin |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
20 |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
21 INSTALLDIR = $(DESTDIR)$(PREFIX) |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
22 INSTALLBIN = $(DESTDIR)$(BINDIR) |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
23 INSTALLLIB = $(DESTDIR)$(LIBDIR) |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
24 |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
25 LWCC_LIBDIR = $(LIBDIR)/lwcc/$(PACKAGE_VERSION) |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
26 LWCC_INSTALLLIBDIR = $(DESTDIR)$(LWCC_LIBDIR) |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
27 |
272
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
28 # this are probably pointless but they will make sure |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
29 # the variables are set without overriding the environment |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
30 # or automatic values from make itself. |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
31 CC ?= cc |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
32 AR ?= ar |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
33 RANLIB ?= ranlib |
10
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
34 |
272
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
35 # Set variables for cross compiling |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
36 ifneq ($(BUILDTPREFIX),) |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
37 CC := $(BUILDTPREFIX)$(CC) |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
38 AR := $(BUILDTPREFIX)$(AR) |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
39 RANLIB := $(BUILDTPREFIX)$(RANLIB) |
cfeb196251e4
Fix conditional setting of build tools variables in the makefile
William Astle <lost@l-w.ca>
parents:
271
diff
changeset
|
40 endif |
10
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
41 |
467
a6c9129e5948
Move version header into a common direction to better reflect what it is.
William Astle <lost@l-w.ca>
parents:
376
diff
changeset
|
42 CPPFLAGS += -I lwlib -Icommon |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
43 CPPFLAGS += -DPREFIX=$(PREFIX) -DLWCC_LIBDIR=$(LWCC_LIBDIR) |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
44 CPPFLAGS += -DPROGSUFFIX=$(PROGSUFFIX) |
350
f0910d85f7db
Remove extraneous PWD reference from Makefile.
William Astle <lost@l-w.ca>
parents:
346
diff
changeset
|
45 LDFLAGS += -Llwlib -llw |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
46 |
545
1fa6eca684e5
Silence spurious warning in lwcpp build
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
47 # The format truncation warnings are bleeping stupid when applied to |
1fa6eca684e5
Silence spurious warning in lwcpp build
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
48 # snprintf() and friends. I'm using snprintf() precisely to prevent |
1fa6eca684e5
Silence spurious warning in lwcpp build
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
49 # overflows and I don't care if the string is truncated, so why should |
1fa6eca684e5
Silence spurious warning in lwcpp build
William Astle <lost@l-w.ca>
parents:
519
diff
changeset
|
50 # I need to test the return value? Bleeping stupid. |
557
b2ee86298516
Reduce default optimization level to -O2
William Astle <lost@l-w.ca>
parents:
546
diff
changeset
|
51 |
b2ee86298516
Reduce default optimization level to -O2
William Astle <lost@l-w.ca>
parents:
546
diff
changeset
|
52 # -O3 breaks the build on some compiler/system targets so default to |
b2ee86298516
Reduce default optimization level to -O2
William Astle <lost@l-w.ca>
parents:
546
diff
changeset
|
53 # -O2 which seems okay for now. Ideally identifying what breaks at |
b2ee86298516
Reduce default optimization level to -O2
William Astle <lost@l-w.ca>
parents:
546
diff
changeset
|
54 # -O3 is indicated, but so far, identifying the specific source of |
b2ee86298516
Reduce default optimization level to -O2
William Astle <lost@l-w.ca>
parents:
546
diff
changeset
|
55 # the breakage has been problematic. |
b2ee86298516
Reduce default optimization level to -O2
William Astle <lost@l-w.ca>
parents:
546
diff
changeset
|
56 CFLAGS ?= -O2 -Wno-char-subscripts -Wno-format-truncation |
10
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
57 |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
58 MAIN_TARGETS := lwasm/lwasm$(PROGSUFFIX) \ |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
59 lwlink/lwlink$(PROGSUFFIX) \ |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
60 lwar/lwar$(PROGSUFFIX) \ |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
61 lwlink/lwobjdump$(PROGSUFFIX) \ |
546
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
62 lwcc/lwcc-cpp$(PROGSUFFIX) |
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
63 |
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
64 SECONDARY_TARGETS := lwcc/lwcc$(PROGSUFFIX) \ |
311
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
65 lwcc/lwcc-cc$(PROGSUFFIX) |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
66 |
311
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
67 LWCC_LIBBIN_FILES = lwcc/lwcc-cpp$(PROGSUFFIX) lwcc/lwcc-cc$(PROGSUFFIX) |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
68 LWCC_LIBLIB_FILES = |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
69 LWCC_LIBINC_FILES = |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
70 |
546
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
71 .PHONY: default |
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
72 default: $(MAIN_TARGETS) |
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
73 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
74 .PHONY: all |
546
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
75 all: $(MAIN_TARGETS) $(SECONDARY_TARGETS) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
76 |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
77 lwar_srcs := add.c extract.c list.c lwar.c main.c remove.c replace.c |
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
78 lwar_srcs := $(addprefix lwar/,$(lwar_srcs)) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
79 |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
80 lwlib_srcs := lw_alloc.c lw_realloc.c lw_free.c lw_error.c lw_expr.c \ |
308
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
81 lw_stack.c lw_string.c lw_stringlist.c lw_cmdline.c lw_strbuf.c \ |
519
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
503
diff
changeset
|
82 lw_strpool.c lw_dict.c |
190
20ba68be2cd7
Fixed typos with conversion away from rules.make stuff
lost@l-w.ca
parents:
189
diff
changeset
|
83 lwlib_srcs := $(addprefix lwlib/,$(lwlib_srcs)) |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
84 |
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
85 lwlink_srcs := main.c lwlink.c readfiles.c expr.c script.c link.c output.c map.c |
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
86 lwobjdump_srcs := objdump.c |
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
87 lwlink_srcs := $(addprefix lwlink/,$(lwlink_srcs)) |
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
88 lwobjdump_srcs := $(addprefix lwlink/,$(lwobjdump_srcs)) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
89 |
376 | 90 lwasm_srcs := cycle.c debug.c input.c insn_bitbit.c insn_gen.c insn_indexed.c \ |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
91 insn_inh.c insn_logicmem.c insn_rel.c insn_rlist.c insn_rtor.c insn_tfm.c \ |
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
92 instab.c list.c lwasm.c macro.c main.c os9.c output.c pass1.c pass2.c \ |
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
93 pass3.c pass4.c pass5.c pass6.c pass7.c pragma.c pseudo.c section.c \ |
519
724bcc4508bc
Add SETSTR/INCLUDESTR for some basic code building
William Astle <lost@l-w.ca>
parents:
503
diff
changeset
|
94 strings.c struct.c symbol.c symdump.c unicorns.c |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
95 lwasm_srcs := $(addprefix lwasm/,$(lwasm_srcs)) |
188 | 96 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
97 lwasm_objs := $(lwasm_srcs:.c=.o) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
98 lwlink_objs := $(lwlink_srcs:.c=.o) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
99 lwar_objs := $(lwar_srcs:.c=.o) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
100 lwlib_objs := $(lwlib_srcs:.c=.o) |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
1
diff
changeset
|
101 lwobjdump_objs := $(lwobjdump_srcs:.c=.o) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
102 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
103 lwasm_deps := $(lwasm_srcs:.c=.d) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
104 lwlink_deps := $(lwlink_srcs:.c=.d) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
105 lwar_deps := $(lwar_srcs:.c=.d) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
106 lwlib_deps := $(lwlib_srcs:.c=.d) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
107 lwobjdump_deps := $(lwobjdump_srcs:.c=.d) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
108 |
295 | 109 lwcc_driver_srcs := driver-main.c |
110 lwcc_driver_srcs := $(addprefix lwcc/,$(lwcc_driver_srcs)) | |
288
fc76f1a0dc49
Initial version of lwcc compiler driver and Makefile infrastructure
William Astle <lost@l-w.ca>
parents:
277
diff
changeset
|
111 lwcc_driver_objs := $(lwcc_driver_srcs:.c=.o) |
fc76f1a0dc49
Initial version of lwcc compiler driver and Makefile infrastructure
William Astle <lost@l-w.ca>
parents:
277
diff
changeset
|
112 lwcc_driver_deps := $(lwcc_driver_srcs:.c=.d) |
fc76f1a0dc49
Initial version of lwcc compiler driver and Makefile infrastructure
William Astle <lost@l-w.ca>
parents:
277
diff
changeset
|
113 |
308
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
114 lwcc_cpp_srcs := cpp-main.c |
295 | 115 lwcc_cpp_srcs := $(addprefix lwcc/,$(lwcc_cpp_srcs)) |
292 | 116 lwcc_cpp_objs := $(lwcc_cpp_srcs:.c=.o) |
117 lwcc_cpp_deps := $(lwcc_cpp_srcs:.c=.d) | |
118 | |
499 | 119 lwcc_cc_srcs := cc-main.c tree.c cc-parse.c cc-gencode.c |
311
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
120 lwcc_cc_srcs := $(addprefix lwcc/,$(lwcc_cc_srcs)) |
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
121 lwcc_cc_objs := $(lwcc_cc_srcs:.c=.o) |
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
122 lwcc_cc_deps := $(lwcc_cc_srcs:.c=.d) |
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
123 |
308
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
124 lwcc_cpplib_srcs := cpp.c lex.c token.c preproc.c symbol.c |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
125 lwcc_cpplib_srcs := $(addprefix lwcc/,$(lwcc_cpplib_srcs)) |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
126 lwcc_cpplib_objs := $(lwcc_cpplib_srcs:.c=.o) |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
127 lwcc_cpplib_deps := $(lwcc_cpplib_srcs:.c=.d) |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
128 |
311
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
129 lwcc_deps := $(lwcc_cpp_deps) $(lwcc_driver_deps) $(lwcc_cpplib_deps) $(lwcc_cc_deps) |
295 | 130 |
288
fc76f1a0dc49
Initial version of lwcc compiler driver and Makefile infrastructure
William Astle <lost@l-w.ca>
parents:
277
diff
changeset
|
131 .PHONY: lwlink lwasm lwar lwobjdump lwcc |
10
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
132 lwlink: lwlink/lwlink$(PROGSUFFIX) |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
133 lwasm: lwasm/lwasm$(PROGSUFFIX) |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
134 lwar: lwar/lwar$(PROGSUFFIX) |
127e5b1e01c0
Removed use of asprintf() and added Makefile options for cross compiling; also a bugfix with sizeof{} in lwasm
lost@l-w.ca
parents:
9
diff
changeset
|
135 lwobjdump: lwlink/lwobjdump$(PROGSUFFIX) |
295 | 136 lwcc: lwcc/lwcc$(PROGSUFFIX) |
137 lwcc-cpp: lwcc/lwcc-cpp$(PROGSUFFIX) | |
308
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
138 lwcc-cpplib: lwcc/libcpp.a |
22 | 139 |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
140 lwasm/lwasm$(PROGSUFFIX): $(lwasm_objs) lwlib |
11 | 141 @echo Linking $@ |
142 @$(CC) -o $@ $(lwasm_objs) $(LDFLAGS) | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
143 |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
144 lwlink/lwlink$(PROGSUFFIX): $(lwlink_objs) lwlib |
11 | 145 @echo Linking $@ |
146 @$(CC) -o $@ $(lwlink_objs) $(LDFLAGS) | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
147 |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
148 lwlink/lwobjdump$(PROGSUFFIX): $(lwobjdump_objs) lwlib |
11 | 149 @echo Linking $@ |
150 @$(CC) -o $@ $(lwobjdump_objs) $(LDFLAGS) | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
151 |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
152 lwar/lwar$(PROGSUFFIX): $(lwar_objs) lwlib |
17
4969bd6f3b7d
Fixed up glitch with Makefile causing binaries to always be considered out of date
lost@l-w.ca
parents:
16
diff
changeset
|
153 @echo Linking $@ |
11 | 154 @$(CC) -o $@ $(lwar_objs) $(LDFLAGS) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
155 |
295 | 156 lwcc/lwcc$(PROGSUFFIX): $(lwcc_driver_objs) lwlib |
288
fc76f1a0dc49
Initial version of lwcc compiler driver and Makefile infrastructure
William Astle <lost@l-w.ca>
parents:
277
diff
changeset
|
157 @echo Linking $@ |
fc76f1a0dc49
Initial version of lwcc compiler driver and Makefile infrastructure
William Astle <lost@l-w.ca>
parents:
277
diff
changeset
|
158 @$(CC) -o $@ $(lwcc_driver_objs) $(LDFLAGS) |
fc76f1a0dc49
Initial version of lwcc compiler driver and Makefile infrastructure
William Astle <lost@l-w.ca>
parents:
277
diff
changeset
|
159 |
308
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
160 lwcc/lwcc-cpp$(PROGSUFFIX): $(lwcc_cpp_objs) lwlib lwcc-cpplib |
292 | 161 @echo Linking $@ |
308
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
162 @$(CC) -o $@ $(lwcc_cpp_objs) lwcc/libcpp.a $(LDFLAGS) |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
163 |
311
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
164 lwcc/lwcc-cc$(PROGSUFFIX): $(lwcc_cc_objs) lwlib lwcc-cpplib |
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
165 @echo Linking $@ |
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
166 @$(CC) -o $@ $(lwcc_cc_objs) lwcc/libcpp.a $(LDFLAGS) |
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
167 |
308
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
168 .INTERMEDIATE: lwcc-cpplib |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
169 lwcc-cpplib: lwcc/libcpp.a |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
170 lwcc/libcpp.a: $(lwcc_cpplib_objs) |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
171 @echo Linking $@ |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
172 @$(AR) rc $@ $(lwcc_cpplib_objs) |
670ea8f90212
Converted preproc logic to library and moved some utility stuff to lwlib
William Astle <lost@l-w.ca>
parents:
304
diff
changeset
|
173 @$(RANLIB) $@ |
292 | 174 |
17
4969bd6f3b7d
Fixed up glitch with Makefile causing binaries to always be considered out of date
lost@l-w.ca
parents:
16
diff
changeset
|
175 #.PHONY: lwlib |
4969bd6f3b7d
Fixed up glitch with Makefile causing binaries to always be considered out of date
lost@l-w.ca
parents:
16
diff
changeset
|
176 .INTERMEDIATE: lwlib |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
177 lwlib: lwlib/liblw.a |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
178 |
190
20ba68be2cd7
Fixed typos with conversion away from rules.make stuff
lost@l-w.ca
parents:
189
diff
changeset
|
179 lwlib/liblw.a: $(lwlib_objs) |
11 | 180 @echo Linking $@ |
181 @$(AR) rc $@ $(lwlib_objs) | |
182 @$(RANLIB) $@ | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
183 |
288
fc76f1a0dc49
Initial version of lwcc compiler driver and Makefile infrastructure
William Astle <lost@l-w.ca>
parents:
277
diff
changeset
|
184 alldeps := $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) ($lwobjdump_deps) $(lwcc_deps) |
3 | 185 |
186 -include $(alldeps) | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
187 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
188 extra_clean := $(extra_clean) *~ */*~ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
189 |
11 | 190 %.o: %.c |
181
5350ce9f446f
Arranged for dependencies to be generated when building object files; no more extraneous dependency rebuilds
lost@l-w.ca
parents:
173
diff
changeset
|
191 @echo "Building dependencies for $@" |
503 | 192 @$(CC) -MM $(CPPFLAGS) -o $*.d $< |
181
5350ce9f446f
Arranged for dependencies to be generated when building object files; no more extraneous dependency rebuilds
lost@l-w.ca
parents:
173
diff
changeset
|
193 @mv -f $*.d $*.d.tmp |
5350ce9f446f
Arranged for dependencies to be generated when building object files; no more extraneous dependency rebuilds
lost@l-w.ca
parents:
173
diff
changeset
|
194 @sed -e 's|.*:|$*.o $*.d:|' < $*.d.tmp > $*.d |
5350ce9f446f
Arranged for dependencies to be generated when building object files; no more extraneous dependency rebuilds
lost@l-w.ca
parents:
173
diff
changeset
|
195 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d |
5350ce9f446f
Arranged for dependencies to be generated when building object files; no more extraneous dependency rebuilds
lost@l-w.ca
parents:
173
diff
changeset
|
196 @rm -f $*.d.tmp |
11 | 197 @echo Building $@ |
198 @$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< | |
199 | |
200 | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
201 .PHONY: clean |
22 | 202 clean: $(cleantargs) |
11 | 203 @echo "Cleaning up" |
269
1c70570e3d42
Remove references to lwbasic and lwcc directories from the Makefile
William Astle <lost@l-w.ca>
parents:
260
diff
changeset
|
204 @rm -f lwlib/liblw.a lwasm/lwasm$(PROGSUFFIX) lwlink/lwlink$(PROGSUFFIX) lwlink/lwobjdump$(PROGSUFFIX) lwar/lwar$(PROGSUFFIX) |
546
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
205 @rm -f lwcc/lwcc$(PROGSUFFIX) lwcc/lwcc-cpp$(PROGSUFFIX) lwcc/lwcc-cc$(PROGSUFFIX) lwcc/libcpp.a |
311
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
206 @rm -f $(lwcc_driver_objs) $(lwcc_cpp_objs) $(lwcc_cpplib_objs) $(lwcc_cc_objs) |
269
1c70570e3d42
Remove references to lwbasic and lwcc directories from the Makefile
William Astle <lost@l-w.ca>
parents:
260
diff
changeset
|
207 @rm -f $(lwasm_objs) $(lwlink_objs) $(lwar_objs) $(lwlib_objs) $(lwobjdump_objs) |
11 | 208 @rm -f $(extra_clean) |
20
f4df3bd4b85f
Moved removal of dep files to realclean and properly remove any .exe files
lost@l-w.ca
parents:
17
diff
changeset
|
209 @rm -f */*.exe |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
1
diff
changeset
|
210 |
16
2f98cf1558e1
Added building of manual from docbook source to Makefile
lost@l-w.ca
parents:
11
diff
changeset
|
211 .PHONY: realclean |
22 | 212 realclean: clean $(realcleantargs) |
16
2f98cf1558e1
Added building of manual from docbook source to Makefile
lost@l-w.ca
parents:
11
diff
changeset
|
213 @echo "Cleaning up even more" |
269
1c70570e3d42
Remove references to lwbasic and lwcc directories from the Makefile
William Astle <lost@l-w.ca>
parents:
260
diff
changeset
|
214 @rm -f $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) $(lwobjdump_deps) |
311
7957e90d0a35
Add skeleton compiler target to build
William Astle <lost@l-w.ca>
parents:
309
diff
changeset
|
215 @rm -f $(lwcc_driver_deps) $(lwcc_cpp_deps) $(lwcc_cpplib_deps) $(lwcc_cc_deps) |
16
2f98cf1558e1
Added building of manual from docbook source to Makefile
lost@l-w.ca
parents:
11
diff
changeset
|
216 |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
1
diff
changeset
|
217 print-%: |
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
1
diff
changeset
|
218 @echo $* = $($*) |
3 | 219 |
220 .PHONY: install | |
471
ad0efd5835c3
Cause "make install" to trigger builds for the binaries if needed
William Astle <lost@l-w.ca>
parents:
467
diff
changeset
|
221 install: $(MAIN_TARGETS) |
275
776a076d1afa
Makefile: Allow DESTDIR for distribution package creation
Tormod Volden <debian.tormod@gmail.com>
parents:
272
diff
changeset
|
222 install -d $(INSTALLDIR) |
503 | 223 install -d $(INSTALLBIN) |
224 install $(MAIN_TARGETS) $(INSTALLBIN) | |
546
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
225 |
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
226 .PHONY: install-all |
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
227 install-all: install |
80b21c6b4a6b
Disable building all the lwcc binaries except lwcpp by default
William Astle <lost@l-w.ca>
parents:
545
diff
changeset
|
228 install $(SECONDARY_TARGETS) $(INSTALLBIN) |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
229 install -d $(LWCC_INSTALLLIBDIR) |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
230 install -d $(LWCC_INSTALLLIBDIR)/bin |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
231 install -d $(LWCC_INSTALLLIBDIR)/lib |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
232 install -d $(LWCC_INSTALLLIBDIR)/include |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
233 ifneq ($(LWCC_LIBBIN_FILES),) |
292 | 234 install $(LWCC_LIBBIN_FILES) $(LWCC_INSTALLLIBDIR)/bin |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
235 endif |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
236 ifneq ($(LWCC_LIBLIB_FILES),) |
292 | 237 install $(LWCC_LIBLIB_FILES) $(LWCC_INSTALLLIBDIR)/lib |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
238 endif |
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
239 ifneq ($(LWCC_LIBINC_FILES),) |
292 | 240 install $(LWCC_LIBINC_FILES) $(LWCC_INSTALLLIBDIR)/include |
289
b67a118dbdb7
Updated Makefile to install additonal components of lwcc
William Astle <lost@l-w.ca>
parents:
288
diff
changeset
|
241 endif |
173 | 242 |
243 .PHONY: test | |
244 test: all test/runtests | |
245 @test/runtests | |
189
8a84141ea6dd
Removed rules.make stuff in sub directories - it was not particularly helpful
lost@l-w.ca
parents:
188
diff
changeset
|
246 |