@profoundlogic/codermake 1.7.0 → 2.0.1

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,36 +115,36 @@ $(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
 
@@ -121,21 +152,21 @@ endef
121
152
  define BUILD_CBLLE_PGM
122
153
  $(call SETUP_LOG,$(notdir $@))
123
154
  $(SET_LIBL)
124
- system "crtbndcbl pgm($(LIBRARY)/$(basename $(@F))) srcstmf('$<') output(*print) dbgview(*all)"
155
+ system "crtbndcbl pgm($(TARGET_LIB)/$(basename $(@F))) srcstmf('$<') tgtccsid(*job) output(*print) dbgview(*all)"
125
156
  endef
126
157
 
127
158
  # Build ILE COBOL module
128
159
  define BUILD_CBLLE_MODULE
129
160
  $(call SETUP_LOG,$(notdir $@))
130
161
  $(SET_LIBL)
131
- system "crtcblmod module($(LIBRARY)/$(basename $(@F))) srcstmf('$<') output(*print) dbgview(*all)"
162
+ system "crtcblmod module($(TARGET_LIB)/$(basename $(@F))) srcstmf('$<') tgtccsid(*job) output(*print) dbgview(*all)"
132
163
  endef
133
164
 
134
165
  # Build ILE CL program (bound)
135
166
  define BUILD_CLLE_PGM
136
167
  $(call SETUP_LOG,$(notdir $@))
137
168
  $(SET_LIBL)
138
- 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)"
139
170
  endef
140
171
 
141
172
  # Build OPM CL program
@@ -143,35 +174,35 @@ define BUILD_CLP_PGM
143
174
  $(call SETUP_LOG,$(notdir $@))
144
175
  $(call CREATE_SOURCE_MEMBER,$<,qclsrc)
145
176
  $(SET_LIBL)
146
- 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)"
147
178
  endef
148
179
 
149
180
  # Build ILE CL module
150
181
  define BUILD_CLLE_MODULE
151
182
  $(call SETUP_LOG,$(notdir $@))
152
183
  $(SET_LIBL)
153
- 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)"
154
185
  endef
155
186
 
156
187
  # Build program from modules
157
188
  define BUILD_MODULE_TO_PGM
158
189
  $(call SETUP_LOG,$(notdir $@))
159
190
  $(SET_LIBL)
160
- 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)"
161
192
  endef
162
193
 
163
194
  # Build service program from modules
164
195
  define BUILD_MODULE_TO_SRVPGM
165
196
  $(call SETUP_LOG,$(notdir $@))
166
197
  $(SET_LIBL)
167
- 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)"
168
199
  endef
169
200
 
170
201
  # Build service program from modules (export all procedures)
171
202
  define BUILD_MODULE_TO_SRVPGM_ALL
172
203
  $(call SETUP_LOG,$(notdir $@))
173
204
  $(SET_LIBL)
174
- 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)"
175
206
  endef
176
207
 
177
208
  # Build display file
@@ -179,7 +210,7 @@ define BUILD_DSPF_TO_FILE
179
210
  $(call SETUP_LOG,$(notdir $@))
180
211
  $(call CREATE_SOURCE_MEMBER,$<,qddssrc)
181
212
  $(SET_LIBL)
182
- system "crtdspf file($(LIBRARY)/$(basename $(@F))) srcfile($(LIBRARY)/qddssrc)"
213
+ system "crtdspf file($(TARGET_LIB)/$(basename $(@F))) srcfile($(TARGET_LIB)/qddssrc)"
183
214
  endef
184
215
 
185
216
  # Build display file from RDF (Rich Display File) JSON
@@ -188,7 +219,7 @@ $(call SETUP_LOG,$(notdir $@))
188
219
  '$(CODERMAKE_NODE)' '$(CODERMAKE_PACKAGE_DIR)/bin/rdf-to-dds.js' '$<' 'tmp/$(basename $(@F)).dspf'
189
220
  $(call CREATE_SOURCE_MEMBER,tmp/$(basename $(@F)).dspf,qddssrc)
190
221
  $(SET_LIBL)
191
- 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)"
192
223
  rm -f 'tmp/$(basename $(@F)).dspf'
193
224
  endef
194
225
 
@@ -197,7 +228,7 @@ define BUILD_PF_TO_FILE
197
228
  $(call SETUP_LOG,$(notdir $@))
198
229
  $(call CREATE_SOURCE_MEMBER,$<,qddssrc)
199
230
  $(SET_LIBL)
200
- 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)"
201
232
  endef
202
233
 
203
234
  # Build logical file
@@ -205,7 +236,7 @@ define BUILD_LF_TO_FILE
205
236
  $(call SETUP_LOG,$(notdir $@))
206
237
  $(call CREATE_SOURCE_MEMBER,$<,qddssrc)
207
238
  $(SET_LIBL)
208
- system "crtlf file($(LIBRARY)/$(basename $(@F))) srcfile($(LIBRARY)/qddssrc)"
239
+ system "crtlf file($(TARGET_LIB)/$(basename $(@F))) srcfile($(TARGET_LIB)/qddssrc)"
209
240
  endef
210
241
 
211
242
  # Build printer file
@@ -213,35 +244,35 @@ define BUILD_PRTF_TO_FILE
213
244
  $(call SETUP_LOG,$(notdir $@))
214
245
  $(call CREATE_SOURCE_MEMBER,$<,qddssrc)
215
246
  $(SET_LIBL)
216
- system "crtprtf file($(LIBRARY)/$(basename $(@F))) srcfile($(LIBRARY)/qddssrc)"
247
+ system "crtprtf file($(TARGET_LIB)/$(basename $(@F))) srcfile($(TARGET_LIB)/qddssrc)"
217
248
  endef
218
249
 
219
250
  # Build SQL table
220
251
  define BUILD_SQLTABLE_TO_FILE
221
252
  $(call SETUP_LOG,$(notdir $@))
222
253
  $(SET_LIBL)
223
- system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(LIBRARY))"
254
+ system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(TARGET_LIB))"
224
255
  endef
225
256
 
226
257
  # Build SQL index
227
258
  define BUILD_SQLINDEX_TO_FILE
228
259
  $(call SETUP_LOG,$(notdir $@))
229
260
  $(SET_LIBL)
230
- system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(LIBRARY))"
261
+ system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(TARGET_LIB))"
231
262
  endef
232
263
 
233
264
  # Build SQL view
234
265
  define BUILD_SQLVIEW_TO_FILE
235
266
  $(call SETUP_LOG,$(notdir $@))
236
267
  $(SET_LIBL)
237
- system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(LIBRARY))"
268
+ system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(TARGET_LIB))"
238
269
  endef
239
270
 
240
271
  # Build SQL procedure
241
272
  define BUILD_SQLPROC_TO_PGM
242
273
  $(call SETUP_LOG,$(notdir $@))
243
274
  $(SET_LIBL)
244
- system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(LIBRARY))"
275
+ system "runsqlstm srcstmf('$<') commit(*none) dftrdbcol($(TARGET_LIB))"
245
276
  endef
246
277
 
247
278
  # Build message file from CL commands
@@ -260,22 +291,30 @@ endef
260
291
  define BUILD_MENU
261
292
  $(call SETUP_LOG,$(notdir $@))
262
293
  $(SET_LIBL)
263
- 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)"
264
295
  endef
265
296
 
266
297
  ######
267
- # 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).
268
301
  ######
269
302
  .PHONY: platform-clean
270
303
  platform-clean:
271
304
  @rm -rf tmp/rpg-pp-*
272
- if [ -n "$(TARGETS)" ] && [ -d $(LIBRARY_PATH) ]; then
305
+ if [ -n "$(TARGETS)" ]; then
273
306
  for pass in 1 2; do
274
307
  for target in $(TARGETS); do
275
- if [ "$${target%.file}" != "$$target" ]; then
276
- (system "dltf $(LIBRARY)/$$(basename $$target .file)" > /dev/null 2>&1) || true
277
- else
278
- 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
279
318
  fi
280
319
  done
281
320
  done