2
2
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
3
3
# obtain one at https://mozilla.org/MPL/2.0/
4
4
#
5
- # Copyright (C) 2009-2021 , Peter Johnson (gravatar.com/delphidabbler).
5
+ # Copyright (C) 2009-2022 , Peter Johnson (gravatar.com/delphidabbler).
6
6
#
7
7
# Makefile for the CodeSnip project.
8
8
9
9
10
- # Define macros giving relative paths to other directories from location of
11
- # makefile
12
- BIN = ..\Bin
13
- EXE = ..\Exe
10
+ # Define macros relative paths to various directories relative to the repo root
11
+ BUILD_ROOT = _build
12
+ BIN_ROOT = $(BUILD_ROOT ) \bin
13
+ EXE_ROOT = $(BUILD_ROOT ) \exe
14
+ RELEASE_ROOT = $(BUILD_ROOT ) \release
15
+ DOCS_ROOT = Docs
16
+ SRC_ROOT = Src
17
+
18
+ # Defines macros giving directories relative to location of the Makefile
19
+ BIN_REL = ..\$(BIN_ROOT )
20
+ EXE_REL = ..\$(EXE_ROOT )
14
21
15
22
# Check for required environment variables
16
23
@@ -75,11 +82,10 @@ DELPHIDEFINES =
75
82
76
83
# Implicit rules
77
84
78
- # Resource files are compiled to the directory specified by BIN macro, which
79
- # must have been set by the caller.
85
+ # Resource files are compiled to the directory specified by BIN_REL macro.
80
86
.rc.res :
81
87
@echo +++ Compiling Resource file $< +++
82
- @$(BRCC32) $< -fo$(BIN )\$(@F)
88
+ @$(BRCC32) $< -fo$(BIN_REL )\$(@F)
83
89
84
90
# Version info files are compiled by VIEd. A temporary .rc file is left behind
85
91
.vi.rc :
@@ -104,11 +110,12 @@ config:
104
110
@copy /Y CodeSnip.cfg.tplt CodeSnip.cfg
105
111
# Create build folders
106
112
@cd ..
107
- @if exist Bin rmdir /S /Q Bin
108
- @mkdir Bin
109
- @if not exist Exe mkdir Exe
110
- @if not exist Release mkdir Release
111
- @cd Src
113
+ @if not exist $(BUILD_ROOT) mkdir $(BUILD_ROOT)
114
+ @if exist $(BIN_ROOT) rmdir /S /Q $(BIN_ROOT)
115
+ @mkdir $(BIN_ROOT)
116
+ @if not exist $(EXE_ROOT) mkdir $(EXE_ROOT)
117
+ @if not exist $(RELEASE_ROOT) mkdir $(RELEASE_ROOT)
118
+ @cd $(SRC_ROOT)
112
119
113
120
# Builds CodeSnip pascal files and links program
114
121
pascal : CodeSnip.exe
@@ -118,14 +125,14 @@ pascal: CodeSnip.exe
118
125
CodeSnip.exe :
119
126
@echo +++ Compiling Pascal +++
120
127
!ifdef PORTABLE
121
- @if exist $(EXE )\$(@F) copy $(EXE )\$(@F) $(EXE )\$(@F).bak
128
+ @if exist $(EXE_REL )\$(@F) copy $(EXE_REL )\$(@F) $(EXE_REL )\$(@F).bak
122
129
!endif
123
130
@$(DCC32) $(@B).dpr -B $(DELPHIDEFINES)
124
131
!ifdef PORTABLE
125
- @copy $(EXE )\$(@F) $(EXE )\$(@B)-p.exe /Y
126
- @del $(EXE )\$(@F)
127
- @if exist $(EXE )\$(@F).bak copy $(EXE )\$(@F).bak $(EXE )\$(@F)
128
- @if exist $(EXE )\$(@F).bak del $(EXE )\$(@F).bak
132
+ @copy $(EXE_REL )\$(@F) $(EXE_REL )\$(@B)-p.exe /Y
133
+ @del $(EXE_REL )\$(@F)
134
+ @if exist $(EXE_REL )\$(@F).bak copy $(EXE_REL )\$(@F).bak $(EXE_REL )\$(@F)
135
+ @if exist $(EXE_REL )\$(@F).bak del $(EXE_REL )\$(@F).bak
129
136
!endif
130
137
131
138
# Builds help file
@@ -144,49 +151,58 @@ resources: $(VERINFOFILEBASE).res Resources.res HTML.res
144
151
# Compiles HTMLres from .hrc file
145
152
HTML.res : HTML.hrc
146
153
@echo +++ Compiling HTML Resource manifest file +++
147
- @$(HTMLRES) -mHTML.hrc -o$(BIN )\HTML.res -r -q
154
+ @$(HTMLRES) -mHTML.hrc -o$(BIN_REL )\HTML.res -r -q
148
155
149
156
# Compiles type library from IDL
150
157
typelib :
151
- @$(GENTLB) .\ExternalObj.ridl -D$(BIN ) -TExternalObj.tlb
158
+ @$(GENTLB) .\ExternalObj.ridl -D$(BIN_REL ) -TExternalObj.tlb
152
159
153
160
# Builds setup program
154
161
setup :
155
162
!ifndef PORTABLE
156
- @del ..\Exe \CodeSnip-Setup-*
163
+ @del $(EXE_REL) \CodeSnip-Setup-*
157
164
@$(ISCC) Install\CodeSnip.iss
158
165
!else
159
166
@echo **** Portable build - no setup file created ****
160
167
!endif
161
168
162
169
# Creates auto generated files
163
170
autogen :
164
- @$(TLIBIMP) -P+ -Ps+ -D.\AutoGen -FtIntfExternalObj $(BIN )\ExternalObj.tlb
171
+ @$(TLIBIMP) -P+ -Ps+ -D.\AutoGen -FtIntfExternalObj $(BIN_REL )\ExternalObj.tlb
165
172
@if exist .\AutoGen\IntfExternalObj.dcr del .\AutoGen\IntfExternalObj.dcr
166
173
167
174
# Build release files (.zip)
175
+ # If RELEASEFILENAME is defined by caller then it is used as name of zip file
176
+ # otherwise default zip file name is used, which depends on whether PORTABLE
177
+ # is defined.
178
+ # If VERSION is defined by caller then it is appended to RELEASEFILENAME,
179
+ # separated by a dash.
168
180
!ifndef RELEASEFILENAME
169
- RELEASEFILENAME = dd-codesnip
170
- !ifdef PORTABLE
171
- RELEASEFILENAME = $(RELEASEFILENAME ) -portable
181
+ !ifndef PORTABLE
182
+ RELEASEFILENAME = codesnip-exe
183
+ !else
184
+ RELEASEFILENAME = codesnip-portable-exe
185
+ !endif
172
186
!endif
187
+ !ifdef VERSION
188
+ RELEASEFILENAME = $(RELEASEFILENAME ) -$(VERSION )
173
189
!endif
174
- OUTFILE = Release \$(RELEASEFILENAME ) .zip
190
+ OUTFILE = $( RELEASE_ROOT ) \$(RELEASEFILENAME ) .zip
175
191
release :
176
192
@echo ---------------------
177
193
@echo Creating Release File
178
194
@echo ---------------------
179
195
@cd ..
180
196
-@if exist $(OUTFILE) del $(OUTFILE)
181
197
!ifndef PORTABLE
182
- @$(ZIP) -j -9 $(OUTFILE) Exe \CodeSnip-Setup-*.exe Docs \ReadMe.txt
198
+ @$(ZIP) -j -9 $(OUTFILE) $(EXE_ROOT) \CodeSnip-Setup-*.exe $(DOCS_ROOT) \ReadMe.txt
183
199
!else
184
- @$(ZIP) -j -9 $(OUTFILE) Exe \CodeSnip-p.exe
185
- @$(ZIP) -j -9 $(OUTFILE) Exe \CodeSnip.chm
186
- @$(ZIP) -j -9 $(OUTFILE) Docs \ReadMe.txt
187
- @$(ZIP) -j -9 $(OUTFILE) Docs \License.html
200
+ @$(ZIP) -j -9 $(OUTFILE) $(EXE_ROOT) \CodeSnip-p.exe
201
+ @$(ZIP) -j -9 $(OUTFILE) $(EXE_ROOT) \CodeSnip.chm
202
+ @$(ZIP) -j -9 $(OUTFILE) $(DOCS_ROOT) \ReadMe.txt
203
+ @$(ZIP) -j -9 $(OUTFILE) $(DOCS_ROOT) \License.html
188
204
!endif
189
- @cd Src
205
+ @cd $(SRC_ROOT)
190
206
191
207
# Clean up unwanted files
192
208
clean :
@@ -200,4 +216,4 @@ clean:
200
216
-@del /S *.tvsconfig 2>nul
201
217
# remove __history folders
202
218
-@for /F "usebackq" % i in (`dir /S /B /A :D ..\__history`) do @rmdir /S /Q % i
203
- @cd Src
219
+ @cd $(SRC_ROOT)
0 commit comments