@profoundlogic/codermake 1.6.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,40 @@ $(shell rm -rf tmp/logs && $(MKDIR) -p tmp/logs)
24
24
  -include $(CODERMAKE_RULES_DIR)/rules.mk
25
25
  -include $(CODERMAKE_RULES_DIR)/targets.mk
26
26
 
27
+ # Detect short-flag invocations like `make -n` or `make -t`. MAKEFLAGS lists
28
+ # short flags as the FIRST word with no leading `-` (e.g. "tn"); long options
29
+ # follow with their full `--name` form. We only want to match the short chunk
30
+ # here — looking at MAKEFLAGS as a whole gives false positives because
31
+ # `--output-sync=target` and `--no-builtin-rules` (added by base.mk) contain
32
+ # 't' and 'n' as substrings.
33
+ MAKE_SHORTFLAGS := $(filter-out -%,$(firstword $(MAKEFLAGS)))
34
+
35
+ # Per-library bin dirs computed from TARGETS (Unix-like only).
36
+ # Under `make -t` / `make -n` recipes don't run, so we pre-create these dirs at
37
+ # parse time so dummies inside `build/<lib>.lib/` can be touched. In normal
38
+ # builds, the directory rule in unix.mk creates each one on demand.
39
+ ifneq ($(OS),OS400)
40
+ LIBRARY_BIN_DIRS := $(patsubst %/,%,$(sort $(dir $(filter build/%,$(TARGETS)))))
41
+ ifneq (,$(strip $(LIBRARY_BIN_DIRS)))
42
+ ifneq (,$(findstring t,$(MAKE_SHORTFLAGS))$(findstring n,$(MAKE_SHORTFLAGS)))
43
+ $(shell mkdir -p $(LIBRARY_BIN_DIRS))
44
+ endif
45
+ endif
46
+ endif
47
+
48
+ # In multi-library output mode, SET_LIBL adds every library in
49
+ # CODERMAKE_LIBRARY_LIST to the IBM i library list. Each target's own library
50
+ # is already an order-only prereq, but if any target's recipe references
51
+ # libraries outside its own (via SET_LIBL), those must also exist first.
52
+ # Ensure all libraries used by any target in TARGETS exist before any recipe
53
+ # runs by adding them as order-only prereqs to every target.
54
+ ifdef CODERMAKE_LIBRARY_MAP
55
+ ALL_TARGET_LIB_PATHS := $(patsubst %/,%,$(sort $(dir $(TARGETS))))
56
+ ifneq (,$(strip $(ALL_TARGET_LIB_PATHS)))
57
+ $(TARGETS): | $(ALL_TARGET_LIB_PATHS)
58
+ endif
59
+ endif
60
+
27
61
  # Default target
28
62
  .DEFAULT_GOAL := all
29
63
  .PHONY: all
@@ -13,15 +13,55 @@ MAKEFLAGS += --no-builtin-rules
13
13
  MAKEFLAGS += --output-sync=target
14
14
 
15
15
  ######
16
- # Utility to set library list.
17
- ######
18
- define SET_LIBL
19
- liblist -cd
20
- if liblist | grep -Eiq '^$(LIBRARY)[[:space:]]+'; then
21
- liblist -d $(LIBRARY)
22
- fi
23
- liblist -af $(LIBRARY)
24
- endef
16
+ # Helper: extract the IBM i library name from an output target path.
17
+ #
18
+ # `/qsys.lib/APPLIBA.lib/foo.pgm` -> `APPLIBA`
19
+ # `build/APPLIBA.lib/foo.pgm` -> `APPLIBA`
20
+ ######
21
+ output_lib_of = $(patsubst %.lib,%,$(notdir $(patsubst %/,%,$(dir $(1)))))
22
+
23
+ ######
24
+ # Utility to set the IBM i library list. Three modes selected at parse time:
25
+ #
26
+ # 1. Single-library mode (BUILD_LIBRARY / IBMI_BUILD_LIBRARY set):
27
+ # Today's behavior. Reset to default, remove $(LIBRARY) if already on the
28
+ # list, then add it to the front of the user portion.
29
+ #
30
+ # 2. Multi-library mode without CODERMAKE_LIBRARY_LIST:
31
+ # No-op. The library list is whatever the job/profile inherits.
32
+ #
33
+ # 3. Multi-library mode with CODERMAKE_LIBRARY_LIST:
34
+ # Entirely replace the user portion of the library list with the libraries
35
+ # named in CODERMAKE_LIBRARY_LIST, in order.
36
+ #
37
+ # `liblist` is a PASE shell built-in that mutates the CURRENT shell's library
38
+ # list — subsequent `system "..."` calls inherit it. CHGLIBL would not work
39
+ # because it only affects the spawned job, not the parent shell.
40
+ ######
41
+ ifdef CODERMAKE_LIBRARY_MAP
42
+ ifdef CODERMAKE_LIBRARY_LIST
43
+ define SET_LIBL
44
+ liblist -cd
45
+ LIBS=$$(liblist | grep ' USR[[:space:]]*$$' | cut -c 1-10)
46
+ if [ -n "$$LIBS" ]; then
47
+ liblist -d $$LIBS
48
+ fi
49
+ liblist -al $(CODERMAKE_LIBRARY_LIST)
50
+ endef
51
+ else
52
+ define SET_LIBL
53
+ :
54
+ endef
55
+ endif
56
+ else
57
+ define SET_LIBL
58
+ liblist -cd
59
+ if liblist | grep -Eiq '^$(LIBRARY)[[:space:]]+'; then
60
+ liblist -d $(LIBRARY)
61
+ fi
62
+ liblist -af $(LIBRARY)
63
+ endef
64
+ endif
25
65
 
26
66
  ######
27
67
  # RPG /COPY preprocessor - converts source member style directives to IFS paths
@@ -44,6 +84,27 @@ endef
44
84
  # Binding parameter generation from prerequisites.
45
85
  # Expands to CL parameters when matching prerequisites exist, empty otherwise.
46
86
  # Used by BUILD_MODULE_TO_PGM (CRTPGM) and BUILD_MODULE_TO_SRVPGM (CRTSRVPGM).
87
+ #
88
+ # BNDSRVPGM and BNDDIR stay UNQUALIFIED in both modes by design — runtime
89
+ # library-list resolution is the lever developers use to substitute private
90
+ # library copies of service programs and binding directories without rebuilding
91
+ # consumer programs. CODERMAKE_LIBRARY_LIST is the appropriate way to control
92
+ # resolution when conflicts exist across mapped libraries.
47
93
  ######
48
94
  BNDSRVPGM_PARM = $(if $(filter %.srvpgm,$^ $|),bndsrvpgm($(foreach s,$(filter %.srvpgm,$^ $|),$(basename $(notdir $(s))))),)
49
95
  BNDDIR_PARM = $(if $(filter %.bnddir,$^ $|),bnddir($(foreach d,$(filter %.bnddir,$^ $|),$(basename $(notdir $(d))))),)
96
+
97
+ ######
98
+ # MODULE() parameter for CRTPGM / CRTSRVPGM.
99
+ #
100
+ # Modules are EMBEDDED into the resulting program/srvpgm at link time — there
101
+ # is no runtime resolution of module references. So in multi-library mode we
102
+ # qualify each module's library explicitly (`module((LIB/name) (LIB/name))`),
103
+ # guaranteeing the correct module is bound regardless of library-list order.
104
+ # In single-library mode we keep today's unqualified form.
105
+ ######
106
+ ifdef CODERMAKE_LIBRARY_MAP
107
+ MODULE_PARM = module($(foreach m,$(filter %.module,$^),($(call output_lib_of,$m)/$(basename $(notdir $m)))))
108
+ else
109
+ MODULE_PARM = module($(foreach m,$(filter %.module,$^),$(basename $(notdir $m))))
110
+ endif
@@ -4,20 +4,30 @@
4
4
  ######
5
5
 
6
6
  ######
7
- # Bail out if required environment variables are not set properly.
7
+ # Output library configuration. Two modes:
8
+ # - Single-library: BUILD_LIBRARY required (today's behavior).
9
+ # - Multi-library: CODERMAKE_LIBRARY_MAP drives per-target output libraries.
10
+ # LIBRARY is intentionally undefined; recipes use TARGET_LIB
11
+ # (= $(or $(TARGET_LIBRARY),$(LIBRARY))) which resolves via
12
+ # the target-specific TARGET_LIBRARY emitted by the
13
+ # preprocessor for each output rule.
8
14
  ######
9
- ifeq (,$(BUILD_LIBRARY))
10
- $(error Required variable BUILD_LIBRARY is not set.)
11
- endif
12
- ifneq (1,$(words [$(BUILD_LIBRARY)]))
13
- $(error BUILD_LIBRARY variable is not set correctly. Set to a valid library name and try again)
15
+ ifndef CODERMAKE_LIBRARY_MAP
16
+ ifeq (,$(BUILD_LIBRARY))
17
+ $(error Required variable BUILD_LIBRARY is not set.)
18
+ endif
19
+ ifneq (1,$(words [$(BUILD_LIBRARY)]))
20
+ $(error BUILD_LIBRARY variable is not set correctly. Set to a valid library name and try again)
21
+ endif
22
+ LIBRARY := $(BUILD_LIBRARY)
23
+ LIBRARY_PATH := /qsys.lib/$(LIBRARY).lib
14
24
  endif
15
25
 
16
26
  ######
17
- # Output library.
27
+ # Resolved per-recipe library and library path.
18
28
  ######
19
- LIBRARY := $(BUILD_LIBRARY)
20
- LIBRARY_PATH := /qsys.lib/$(LIBRARY).lib
29
+ TARGET_LIB = $(or $(TARGET_LIBRARY),$(LIBRARY))
30
+ TARGET_LIB_PATH = /qsys.lib/$(TARGET_LIB).lib
21
31
 
22
32
  ######
23
33
  # Shell configuration.
@@ -32,9 +42,9 @@ MKDIR := /QOpenSys/usr/bin/mkdir
32
42
  # $(2) = source file name (e.g., qddssrc, qrpglesrc)
33
43
  ######
34
44
  define CREATE_SOURCE_MEMBER
35
- test -e $(LIBRARY_PATH)/$(2).file || system "crtsrcpf file($(LIBRARY)/$(2))"
36
- test -e $(LIBRARY_PATH)/$(2).file/$(basename $(notdir $(1))).mbr || system "addpfm file($(LIBRARY)/$(2)) mbr($(basename $(notdir $(1)))) srctype($(subst .,,$(suffix $(1))))"
37
- cat '$(1)' | Rfile -Qw '$(LIBRARY)/$(2)($(basename $(notdir $(1))))'
45
+ test -e $(TARGET_LIB_PATH)/$(2).file || system "crtsrcpf file($(TARGET_LIB)/$(2))"
46
+ test -e $(TARGET_LIB_PATH)/$(2).file/$(basename $(notdir $(1))).mbr || system "addpfm file($(TARGET_LIB)/$(2)) mbr($(basename $(notdir $(1)))) srctype($(subst .,,$(suffix $(1))))"
47
+ cat '$(1)' | Rfile -Qw '$(TARGET_LIB)/$(2)($(basename $(notdir $(1))))'
38
48
  endef
39
49
 
40
50
  ######
@@ -44,7 +54,7 @@ endef
44
54
  ######
45
55
  define BUILD_FROM_CL_FILE
46
56
  rm -rf '$(1)'
47
- export LIBRARY=$(LIBRARY)
57
+ export LIBRARY=$(TARGET_LIB)
48
58
  export NAME=$(basename $(notdir $(1)))
49
59
  (
50
60
  $(SET_LIBL)
@@ -56,26 +66,47 @@ endef
56
66
 
57
67
  ######
58
68
  # Utility to output "Creating X..." message and redirect recipe output to log file.
69
+ # In multi-library mode, logs nest under the target's library to avoid collisions
70
+ # when two libraries contain objects with the same short name.
59
71
  ######
72
+ LOG_DIR = tmp/logs$(if $(TARGET_LIBRARY),/$(TARGET_LIBRARY))
60
73
  define SETUP_LOG
61
74
  @echo "Creating $(1)"
62
- /usr/bin/touch -C 1208 'tmp/logs/$(1).log'
63
- exec > 'tmp/logs/$(1).log' 2>&1
75
+ $(MKDIR) -p '$(LOG_DIR)'
76
+ /usr/bin/touch -C 1208 '$(LOG_DIR)/$(1).log'
77
+ exec > '$(LOG_DIR)/$(1).log' 2>&1
64
78
  endef
65
79
 
66
80
  ######
67
- # Prerun actions.
81
+ # Prerun actions and banner.
68
82
  ######
69
83
  $(info ===)
70
- $(info Target library: $(LIBRARY))
84
+ ifdef CODERMAKE_LIBRARY_MAP
85
+ $(info Library map: $(CODERMAKE_RESOLVED_LIBRARY_MAP))
86
+ ifdef CODERMAKE_LIBRARY_LIST
87
+ $(info Library list: $(CODERMAKE_LIBRARY_LIST))
88
+ else
89
+ $(info Library list: (inherited from job/profile))
90
+ endif
91
+ else
92
+ $(info Target library: $(LIBRARY))
93
+ endif
71
94
  $(info ===)
72
95
 
73
96
  ######
74
- # Library creation target
97
+ # Library creation. Single-library mode keeps today's specific-target rule;
98
+ # multi-library mode uses a pattern rule so each mapped library gets created
99
+ # on demand the first time an object targets it.
75
100
  ######
101
+ ifndef CODERMAKE_LIBRARY_MAP
76
102
  $(LIBRARY_PATH):
77
103
  $(call SETUP_LOG,$(notdir $@))
78
104
  system "crtlib $(LIBRARY) *test aut(*use) crtaut(*use)"
105
+ else
106
+ /qsys.lib/%.lib:
107
+ $(call SETUP_LOG,$(notdir $@))
108
+ system "crtlib $* *test aut(*use) crtaut(*use)"
109
+ endif
79
110
 
80
111
  ######
81
112
  # Recipe utilities (callable functions for preprocessor-generated rules)
@@ -84,44 +115,58 @@ $(LIBRARY_PATH):
84
115
  # Build RPGLE program (bound)
85
116
  define BUILD_RPGLE_PGM
86
117
  $(call SETUP_LOG,$(notdir $@))
87
- $(call RPG_PREPROCESS_SOURCES,$< $(filter-out $(LIBRARY_PATH)/%,$^))
118
+ $(call RPG_PREPROCESS_SOURCES,$< $(filter-out $(TARGET_LIB_PATH)/%,$^))
88
119
  $(SET_LIBL)
89
- system "crtbndrpg pgm($(LIBRARY)/$(basename $(@F))) srcstmf('$$RPG_SRC_ROOT/$<') incdir('$$RPG_SRC_ROOT') tgtccsid(*job) output(*print) dbgview(*all)"
120
+ system "crtbndrpg pgm($(TARGET_LIB)/$(basename $(@F))) srcstmf('$$RPG_SRC_ROOT/$<') incdir('$$RPG_SRC_ROOT') tgtccsid(*job) output(*print) dbgview(*all)"
90
121
  $(call RPG_CLEANUP_SOURCES)
91
122
  endef
92
123
 
93
124
  # Build SQL RPGLE program
94
125
  define BUILD_SQLRPGLE_PGM
95
126
  $(call SETUP_LOG,$(notdir $@))
96
- $(call RPG_PREPROCESS_SOURCES,$< $(filter-out $(LIBRARY_PATH)/%,$^))
127
+ $(call RPG_PREPROCESS_SOURCES,$< $(filter-out $(TARGET_LIB_PATH)/%,$^))
97
128
  $(SET_LIBL)
98
- system "crtsqlrpgi obj($(LIBRARY)/$(basename $(@F))) objtype(*pgm) srcstmf('$$RPG_SRC_ROOT/$<') cvtccsid(*job) output(*print) rpgppopt(*lvl2) compileopt('incdir(''$$RPG_SRC_ROOT'') tgtccsid(*job) output(*print)') dbgview(*source)"
129
+ system "crtsqlrpgi obj($(TARGET_LIB)/$(basename $(@F))) objtype(*pgm) srcstmf('$$RPG_SRC_ROOT/$<') cvtccsid(*job) output(*print) rpgppopt(*lvl2) compileopt('incdir(''$$RPG_SRC_ROOT'') tgtccsid(*job) output(*print)') dbgview(*source)"
99
130
  $(call RPG_CLEANUP_SOURCES)
100
131
  endef
101
132
 
102
133
  # Build RPGLE module
103
134
  define BUILD_RPGLE_MODULE
104
135
  $(call SETUP_LOG,$(notdir $@))
105
- $(call RPG_PREPROCESS_SOURCES,$< $(filter-out $(LIBRARY_PATH)/%,$^))
136
+ $(call RPG_PREPROCESS_SOURCES,$< $(filter-out $(TARGET_LIB_PATH)/%,$^))
106
137
  $(SET_LIBL)
107
- system "crtrpgmod module($(LIBRARY)/$(basename $(@F))) srcstmf('$$RPG_SRC_ROOT/$<') incdir('$$RPG_SRC_ROOT') tgtccsid(*job) output(*print) dbgview(*all)"
138
+ system "crtrpgmod module($(TARGET_LIB)/$(basename $(@F))) srcstmf('$$RPG_SRC_ROOT/$<') incdir('$$RPG_SRC_ROOT') tgtccsid(*job) output(*print) dbgview(*all)"
108
139
  $(call RPG_CLEANUP_SOURCES)
109
140
  endef
110
141
 
111
142
  # Build SQL RPGLE module
112
143
  define BUILD_SQLRPGLE_MODULE
113
144
  $(call SETUP_LOG,$(notdir $@))
114
- $(call RPG_PREPROCESS_SOURCES,$< $(filter-out $(LIBRARY_PATH)/%,$^))
145
+ $(call RPG_PREPROCESS_SOURCES,$< $(filter-out $(TARGET_LIB_PATH)/%,$^))
115
146
  $(SET_LIBL)
116
- system "crtsqlrpgi obj($(LIBRARY)/$(basename $(@F))) objtype(*module) srcstmf('$$RPG_SRC_ROOT/$<') cvtccsid(*job) output(*print) rpgppopt(*lvl2) compileopt('incdir(''$$RPG_SRC_ROOT'') tgtccsid(*job) output(*print)') dbgview(*source)"
147
+ system "crtsqlrpgi obj($(TARGET_LIB)/$(basename $(@F))) objtype(*module) srcstmf('$$RPG_SRC_ROOT/$<') cvtccsid(*job) output(*print) rpgppopt(*lvl2) compileopt('incdir(''$$RPG_SRC_ROOT'') tgtccsid(*job) output(*print)') dbgview(*source)"
117
148
  $(call RPG_CLEANUP_SOURCES)
118
149
  endef
119
150
 
151
+ # Build ILE COBOL program (bound)
152
+ define BUILD_CBLLE_PGM
153
+ $(call SETUP_LOG,$(notdir $@))
154
+ $(SET_LIBL)
155
+ system "crtbndcbl pgm($(TARGET_LIB)/$(basename $(@F))) srcstmf('$<') tgtccsid(*job) output(*print) dbgview(*all)"
156
+ endef
157
+
158
+ # Build ILE COBOL module
159
+ define BUILD_CBLLE_MODULE
160
+ $(call SETUP_LOG,$(notdir $@))
161
+ $(SET_LIBL)
162
+ system "crtcblmod module($(TARGET_LIB)/$(basename $(@F))) srcstmf('$<') tgtccsid(*job) output(*print) dbgview(*all)"
163
+ endef
164
+
120
165
  # Build ILE CL program (bound)
121
166
  define BUILD_CLLE_PGM
122
167
  $(call SETUP_LOG,$(notdir $@))
123
168
  $(SET_LIBL)
124
- system "crtbndcl pgm($(LIBRARY)/$(basename $(@F))) srcstmf('$<') incdir('.') tgtccsid(*job) output(*print) dbgview(*all)"
169
+ system "crtbndcl pgm($(TARGET_LIB)/$(basename $(@F))) srcstmf('$<') incdir('.') tgtccsid(*job) output(*print) dbgview(*all)"
125
170
  endef
126
171
 
127
172
  # Build OPM CL program
@@ -129,35 +174,35 @@ define BUILD_CLP_PGM
129
174
  $(call SETUP_LOG,$(notdir $@))
130
175
  $(call CREATE_SOURCE_MEMBER,$<,qclsrc)
131
176
  $(SET_LIBL)
132
- system "crtclpgm pgm($(LIBRARY)/$(basename $(@F))) srcfile($(LIBRARY)/qclsrc) output(*print)"
177
+ system "crtclpgm pgm($(TARGET_LIB)/$(basename $(@F))) srcfile($(TARGET_LIB)/qclsrc) output(*print)"
133
178
  endef
134
179
 
135
180
  # Build ILE CL module
136
181
  define BUILD_CLLE_MODULE
137
182
  $(call SETUP_LOG,$(notdir $@))
138
183
  $(SET_LIBL)
139
- system "crtclmod module($(LIBRARY)/$(basename $(@F))) srcstmf('$<') incdir('.') tgtccsid(*job) output(*print) dbgview(*all)"
184
+ system "crtclmod module($(TARGET_LIB)/$(basename $(@F))) srcstmf('$<') incdir('.') tgtccsid(*job) output(*print) dbgview(*all)"
140
185
  endef
141
186
 
142
187
  # Build program from modules
143
188
  define BUILD_MODULE_TO_PGM
144
189
  $(call SETUP_LOG,$(notdir $@))
145
190
  $(SET_LIBL)
146
- system "crtpgm pgm($(LIBRARY)/$(basename $(@F))) module($(foreach m,$(filter %.module,$^),$(basename $(notdir $(m))))) $(BNDSRVPGM_PARM) $(BNDDIR_PARM)"
191
+ system "crtpgm pgm($(TARGET_LIB)/$(basename $(@F))) $(MODULE_PARM) $(BNDSRVPGM_PARM) $(BNDDIR_PARM)"
147
192
  endef
148
193
 
149
194
  # Build service program from modules
150
195
  define BUILD_MODULE_TO_SRVPGM
151
196
  $(call SETUP_LOG,$(notdir $@))
152
197
  $(SET_LIBL)
153
- system "crtsrvpgm srvpgm($(LIBRARY)/$(basename $(@F))) module($(foreach m,$(filter %.module,$^),$(basename $(notdir $(m))))) export(*srcfile) srcstmf('$(filter %.exports %.bnd,$^)') $(BNDSRVPGM_PARM) $(BNDDIR_PARM)"
198
+ system "crtsrvpgm srvpgm($(TARGET_LIB)/$(basename $(@F))) $(MODULE_PARM) export(*srcfile) srcstmf('$(filter %.exports %.bnd,$^)') $(BNDSRVPGM_PARM) $(BNDDIR_PARM)"
154
199
  endef
155
200
 
156
201
  # Build service program from modules (export all procedures)
157
202
  define BUILD_MODULE_TO_SRVPGM_ALL
158
203
  $(call SETUP_LOG,$(notdir $@))
159
204
  $(SET_LIBL)
160
- system "crtsrvpgm srvpgm($(LIBRARY)/$(basename $(@F))) module($(foreach m,$(filter %.module,$^),$(basename $(notdir $(m))))) export(*all) $(BNDSRVPGM_PARM) $(BNDDIR_PARM)"
205
+ system "crtsrvpgm srvpgm($(TARGET_LIB)/$(basename $(@F))) $(MODULE_PARM) export(*all) $(BNDSRVPGM_PARM) $(BNDDIR_PARM)"
161
206
  endef
162
207
 
163
208
  # Build display file
@@ -165,7 +210,7 @@ define BUILD_DSPF_TO_FILE
165
210
  $(call SETUP_LOG,$(notdir $@))
166
211
  $(call CREATE_SOURCE_MEMBER,$<,qddssrc)
167
212
  $(SET_LIBL)
168
- system "crtdspf file($(LIBRARY)/$(basename $(@F))) srcfile($(LIBRARY)/qddssrc)"
213
+ system "crtdspf file($(TARGET_LIB)/$(basename $(@F))) srcfile($(TARGET_LIB)/qddssrc)"
169
214
  endef
170
215
 
171
216
  # Build display file from RDF (Rich Display File) JSON
@@ -174,7 +219,7 @@ $(call SETUP_LOG,$(notdir $@))
174
219
  '$(CODERMAKE_NODE)' '$(CODERMAKE_PACKAGE_DIR)/bin/rdf-to-dds.js' '$<' 'tmp/$(basename $(@F)).dspf'
175
220
  $(call CREATE_SOURCE_MEMBER,tmp/$(basename $(@F)).dspf,qddssrc)
176
221
  $(SET_LIBL)
177
- system "crtdspf file($(LIBRARY)/$(basename $(@F))) srcfile($(LIBRARY)/qddssrc) enhdsp(*yes)"
222
+ system "crtdspf file($(TARGET_LIB)/$(basename $(@F))) srcfile($(TARGET_LIB)/qddssrc) enhdsp(*yes)"
178
223
  rm -f 'tmp/$(basename $(@F)).dspf'
179
224
  endef
180
225
 
@@ -183,7 +228,7 @@ define BUILD_PF_TO_FILE
183
228
  $(call SETUP_LOG,$(notdir $@))
184
229
  $(call CREATE_SOURCE_MEMBER,$<,qddssrc)
185
230
  $(SET_LIBL)
186
- system "crtpf file($(LIBRARY)/$(basename $(@F))) srcfile($(LIBRARY)/qddssrc) aut(*change)"
231
+ system "crtpf file($(TARGET_LIB)/$(basename $(@F))) srcfile($(TARGET_LIB)/qddssrc) aut(*change)"
187
232
  endef
188
233
 
189
234
  # Build logical file
@@ -191,7 +236,7 @@ define BUILD_LF_TO_FILE
191
236
  $(call SETUP_LOG,$(notdir $@))
192
237
  $(call CREATE_SOURCE_MEMBER,$<,qddssrc)
193
238
  $(SET_LIBL)
194
- system "crtlf file($(LIBRARY)/$(basename $(@F))) srcfile($(LIBRARY)/qddssrc)"
239
+ system "crtlf file($(TARGET_LIB)/$(basename $(@F))) srcfile($(TARGET_LIB)/qddssrc)"
195
240
  endef
196
241
 
197
242
  # Build printer file
@@ -199,35 +244,35 @@ define BUILD_PRTF_TO_FILE
199
244
  $(call SETUP_LOG,$(notdir $@))
200
245
  $(call CREATE_SOURCE_MEMBER,$<,qddssrc)
201
246
  $(SET_LIBL)
202
- system "crtprtf file($(LIBRARY)/$(basename $(@F))) srcfile($(LIBRARY)/qddssrc)"
247
+ system "crtprtf file($(TARGET_LIB)/$(basename $(@F))) srcfile($(TARGET_LIB)/qddssrc)"
203
248
  endef
204
249
 
205
250
  # Build SQL table
206
251
  define BUILD_SQLTABLE_TO_FILE
207
252
  $(call SETUP_LOG,$(notdir $@))
208
253
  $(SET_LIBL)
209
- system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(LIBRARY))"
254
+ system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(TARGET_LIB))"
210
255
  endef
211
256
 
212
257
  # Build SQL index
213
258
  define BUILD_SQLINDEX_TO_FILE
214
259
  $(call SETUP_LOG,$(notdir $@))
215
260
  $(SET_LIBL)
216
- system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(LIBRARY))"
261
+ system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(TARGET_LIB))"
217
262
  endef
218
263
 
219
264
  # Build SQL view
220
265
  define BUILD_SQLVIEW_TO_FILE
221
266
  $(call SETUP_LOG,$(notdir $@))
222
267
  $(SET_LIBL)
223
- system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(LIBRARY))"
268
+ system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(TARGET_LIB))"
224
269
  endef
225
270
 
226
271
  # Build SQL procedure
227
272
  define BUILD_SQLPROC_TO_PGM
228
273
  $(call SETUP_LOG,$(notdir $@))
229
274
  $(SET_LIBL)
230
- system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(LIBRARY))"
275
+ system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(TARGET_LIB))"
231
276
  endef
232
277
 
233
278
  # Build message file from CL commands
@@ -246,22 +291,30 @@ endef
246
291
  define BUILD_MENU
247
292
  $(call SETUP_LOG,$(notdir $@))
248
293
  $(SET_LIBL)
249
- system "crtmnu menu($(LIBRARY)/$(basename $(@F))) type(*dspf) dspf($(basename $(notdir $(filter %.file,$^)))) msgf($(basename $(notdir $(filter %.msgf,$^)))) cmdlin(*none) dspkey(*no)"
294
+ system "crtmnu menu($(TARGET_LIB)/$(basename $(@F))) type(*dspf) dspf($(basename $(notdir $(filter %.file,$^)))) msgf($(basename $(notdir $(filter %.msgf,$^)))) cmdlin(*none) dspkey(*no)"
250
295
  endef
251
296
 
252
297
  ######
253
- # Platform-specific clean
298
+ # Platform-specific clean. Each target's path encodes its library, so the
299
+ # library segment is extracted per-target. Works for both modes — in
300
+ # single-library mode every target's library is $(LIBRARY).
254
301
  ######
255
302
  .PHONY: platform-clean
256
303
  platform-clean:
257
304
  @rm -rf tmp/rpg-pp-*
258
- if [ -n "$(TARGETS)" ] && [ -d $(LIBRARY_PATH) ]; then
305
+ if [ -n "$(TARGETS)" ]; then
259
306
  for pass in 1 2; do
260
307
  for target in $(TARGETS); do
261
- if [ "$${target%.file}" != "$$target" ]; then
262
- (system "dltf $(LIBRARY)/$$(basename $$target .file)" > /dev/null 2>&1) || true
263
- else
264
- rm -rf "$$target"
308
+ lib_part=$${target#/qsys.lib/}
309
+ lib=$${lib_part%%/*}
310
+ lib=$${lib%.lib}
311
+ obj=$$(basename "$$target")
312
+ if [ -d "/qsys.lib/$$lib.lib" ]; then
313
+ if [ "$${obj%.file}" != "$$obj" ]; then
314
+ (system "dltf $$lib/$${obj%.file}" > /dev/null 2>&1) || true
315
+ else
316
+ rm -rf "/qsys.lib/$$lib.lib/$$obj" 2>/dev/null || true
317
+ fi
265
318
  fi
266
319
  done
267
320
  done