demake 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/demake +574 -212
  3. metadata +22 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4eb15f543506fbb9bee17fa5f368f7ec5af0909ca9332417596bd964b682c8f
4
- data.tar.gz: b2209882106107e8e0597147b003882b671071576402019f01b47e46eceaaba9
3
+ metadata.gz: 26203e52997d7a1856baddeb73d1d10140b37e97aaf809e1f8ba09fbeaeda684
4
+ data.tar.gz: 2aa16613885a325c1a81cf968c8e637ca8535c25c041ff4a66c2f5948f8ec9f5
5
5
  SHA512:
6
- metadata.gz: 4f23fe45f09af7fcdbd78b1b952a2f32dddba4a1181b9cc1ca647836e5027d8646fbf73896b4360ee3074a4a7ed742e31dd8dc57f896c89356b47769f4961673
7
- data.tar.gz: 49d5e3ade0a5c73c1bbf89b2142c5852368e230ab6b056b54b7fe80ee2e43b4fb5bcd32d47f6ebf7e24bbe08227fa45074dd544f55293dca88c7d9b408e2030c
6
+ metadata.gz: d15794d5c2c4c5cc0859a729a440231e677775da91aeb891249641eafb60c3fd62c250adcd3dc2eddfab439c94165d0c3319fd7554c20116f0cc7e5db4bb8f9c
7
+ data.tar.gz: eccd204c1e31f78b80428ea59ffb16d63690e7fb492a2be7b61910874e12da3e9d419db3311fb92c6a0bbdfca2373e99499676fbbe7c526ca8c35051bf4627ac
data/bin/demake CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
  require 'pipetext'
7
7
 
8
- demake_version = "0.1.0"
8
+ demake_version = "0.1.2"
9
9
 
10
10
  @silent = false
11
11
  @compiler = "gcc"
@@ -16,6 +16,14 @@ demake_version = "0.1.0"
16
16
  # Raise if you have more cores and a long compile time
17
17
  @num_threads = 8
18
18
 
19
+ WIDTH = 75
20
+ BOX_WIDTH = WIDTH + "\t@echo".length # To normalize for Makefile format
21
+ SHORT_WIDTH = BOX_WIDTH - 8
22
+
23
+ # Where to install binaries
24
+ @prefix = "/usr/local/bin/"
25
+ @library_prefix = "/usr/local/lib64/"
26
+
19
27
  # Contains code, does not get touched
20
28
  @source_directory = "src"
21
29
 
@@ -33,18 +41,23 @@ demake_version = "0.1.0"
33
41
  @emoji_clean = "|r|[fire]|n "
34
42
  @emoji_debug = "|n|[bug] "
35
43
  @emoji_install = "|s|[nut and bolt]|n "
44
+ @emoji_uninstall = "|y|[wrench]|n "
36
45
  @emoji_test = "|R|[red question mark]|n "
37
46
  @emoji_compile = "|s|[hammer and wrench]|n "
38
47
  @emoji_link = "|B|[link]|n "
39
48
  @emoji_fail = "|R|[cross mark]|n "
49
+ @emoji_success = "|g|[check mark]|n "
40
50
 
41
51
  @pipe = Class.new.extend(PipeText)
42
52
 
43
53
  @flags = String.new
54
+ @debug_flags = "-DDEBUG -g -Wall -Wextra -Wunused-variable -Wundef -Wconversion -Wshadow -Wcast-qual -Wwrite-strings "
44
55
  @linux_flags = String.new
45
56
  @x86_64_flags = String.new
46
57
  @aarch64_flags = String.new
47
58
  @darwin_flags = String.new
59
+ @windows_flags = String.new
60
+ @freebsd_flags = String.new
48
61
  @libraries = String.new
49
62
  @raw_binary_files = String.new
50
63
 
@@ -53,10 +66,12 @@ def strip_emojis!(string)
53
66
  string.gsub!(@emoji_clean, @replace_with)
54
67
  string.gsub!(@emoji_debug, @replace_with)
55
68
  string.gsub!(@emoji_install, @replace_with)
69
+ string.gsub!(@emoji_uninstall, @replace_with)
56
70
  string.gsub!(@emoji_test, @replace_with)
57
71
  string.gsub!(@emoji_compile, @replace_with)
58
72
  string.gsub!(@emoji_link, @replace_with)
59
73
  string.gsub!(@emoji_fail, @replace_with)
74
+ string.gsub!(@emoji_success, @replace_with)
60
75
  # Everything else
61
76
  string.gsub!(/\|\[.*\]/, @replace_with)
62
77
  end
@@ -68,76 +83,370 @@ def notify(string)
68
83
  STDERR.puts(@pipe.pipetext(string))
69
84
  end
70
85
 
86
+ # Used by both example and oreo to show options
87
+ settingsrb = <<-END_OF_STRING
88
+ # Uncomment to use / override
71
89
  #
72
- # !!! If there is a demake/settings.rb file that gets executed NOW as raw code !!!
73
- #
74
- # !!! Incredibly convenient, but potentially a security nightmare -- secure your environment !!!
75
- #
76
- begin
77
- code = File.open('demake/settings.rb').read
78
- if(@emojis == false)
79
- strip_emojis!(code)
90
+ =begin
91
+ @silent = false
92
+ @compiler = "clang"
93
+ @prefix = "/usr/local/bin/"
94
+ @library_prefix = "/usr/lib64/"
95
+ @emojis = false
96
+ @replace_with = "|b*|n"
97
+ @libraries << "-lc"
98
+ @flags << "-ansi -pedantic -D_DEFAULT_SOURCE"
99
+ @linux_flags << "-static" # clang
100
+ @linux_flags << "-static -static-libgcc"
101
+ @x86_64_flags << "-msse2 -mssse3 -msse4.1 -msha"
102
+ @aarch64_flags << "-march=armv8-a+crypto"
103
+ @windows_flags << ""
104
+ @freebsd_flags << ""
105
+ @darwin_flags << "-bundle"
106
+ @debug_flags << "-Wpedantic -Wdeprecated-declarations -Wdiv-by-zero " +
107
+ "-Wimplicit-function-declaration -Wimplicit-int " +
108
+ "-Wpointer-arith -Wwrite-strings -Wold-style-definition " +
109
+ "-Wmissing-noreturn -Wno-cast-function-type " +
110
+ "-Wno-constant-logical-operand -Wno-long-long " +
111
+ "-Wno-missing-field-initializers -Wno-overlength-strings " +
112
+ "-Wno-packed-bitfield-compat -Wno-parentheses-equality " +
113
+ "-Wno-self-assign -Wno-tautological-compare " +
114
+ "-Wno-unused-parameter -Wno-unused-value " +
115
+ "-Wsuggest-attribute=format -Wsuggest-attribute=noreturn"
116
+ @flags = "-g -Wall"
117
+ # No default flags (use only flags in the line above)
118
+ $flags_override = true
119
+ =end
120
+ notify("#{@emoji_success} |gdemake/settings.rb is present|n")
121
+ END_OF_STRING
122
+
123
+ @example = false
124
+ if(ARGV[0] =~ /^example$/)
125
+ if(File.directory?('example') == true)
126
+ notify("\n#{@emoji_fail}|RError|n: |Ydirectory example |Ralready exists, aborting creation|n\n\n" +
127
+ "Delete the directory and try again if you wish to recreate it.\n\n")
128
+ exit!
80
129
  end
81
- eval code
82
- rescue Errno::ENOENT
83
- rescue
84
- notify("\n|YWARNING|n: #{$!}\n\n")
130
+ @example = true
131
+ # C code files used by the example
132
+ helloc = <<-END_OF_STRING
133
+ /*
134
+ The most basic multiple executable example using a shared object/header file.
135
+
136
+ hello.c will generate an executable named hello which that prints hello, world
137
+ */
138
+ #include "string/string.h"
139
+
140
+ int main(void)
141
+ {
142
+ out("hello, world");
143
+ return 0;
144
+ }
145
+ END_OF_STRING
146
+
147
+ goodbyec = <<-END_OF_STRING
148
+ /*
149
+ The most basic multiple executable example using a shared object/header file.
150
+
151
+ goodbye.c will generate an executable named hello which that prints goodbye, world
152
+ */
153
+ #include "string/string.h"
154
+
155
+ int main(void)
156
+ {
157
+ out("goodbye, world");
158
+ return 0;
159
+ }
160
+ END_OF_STRING
161
+
162
+ stringh = <<-END_OF_STRING
163
+ /*
164
+ The most basic multiple executable example using a shared object/header file.
165
+
166
+ string.h includes a simple shared function named out which prints output
167
+ */
168
+
169
+ void out(const char *in);
170
+ END_OF_STRING
171
+
172
+ stringc = <<-END_OF_STRING
173
+ /*
174
+ The most basic multiple executable example using a shared object/header file.
175
+
176
+ string.c creates a simple shared function named out which prints output
177
+ */
178
+ #include <stdio.h>
179
+ #include "string.h"
180
+
181
+ void out(const char *in)
182
+ {
183
+ printf("%s\\n", in);
184
+ }
185
+ END_OF_STRING
186
+
187
+ testtargetrb = <<-END_OF_STRING
188
+ test_target << "\\t@echo\\n"
189
+ test_target << "\\t@echo \\"|YTesting command hello:|n\\"\\n"
190
+ test_target << "\\tbin/hello\\n"
191
+ test_target << "\\t@echo \\"|YTesting command goodbye:|n\\"\\n"
192
+ test_target << "\\tbin/goodbye\\n"
193
+ END_OF_STRING
194
+
195
+ Dir.mkdir('example')
196
+ notify("#{@emoji_success} Created directory: |gexample|n |[open file folder]\n")
197
+ Dir.mkdir('example/src')
198
+ notify("#{@emoji_success} Created directory: |gexample|n/|gsrc|n |[open file folder]\n")
199
+ File.open('example/src/hello.c', 'w').write(helloc)
200
+ notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|yhello.c|n |[page facing up]\n")
201
+ File.open('example/src/goodbye.c', 'w').write(goodbyec)
202
+ notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|ygoodbye.c|n |[page facing up]\n")
203
+ Dir.mkdir('example/src/string')
204
+ notify("#{@emoji_success} Created directory: |gexample|n/|gsrc|n/|gstring|n |[open file folder]\n")
205
+ File.open('example/src/string/string.h', 'w').write(stringh)
206
+ notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|gstring|n/|ystring.h|n |[page facing up]\n")
207
+ File.open('example/src/string/string.c', 'w').write(stringc)
208
+ notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|gstring|n/|ystring.c|n |[page facing up]\n")
209
+ Dir.mkdir('example/demake')
210
+ notify("#{@emoji_success} Created directory: |gexample|n/|gdemake|n |[open file folder]\n")
211
+ File.open('example/demake/applications', 'w').write("hello string\ngoodbye string\n")
212
+ notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|yapplications|n |[page facing up]\n")
213
+ File.open('example/demake/settings.rb', 'w').write(settingsrb)
214
+ notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|ysettings.rb|n |[page facing up]\n")
215
+ File.open('example/demake/test-target.rb', 'w').write(testtargetrb)
216
+ notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|ytest-target.rb|n |[page facing up]\n")
217
+ Dir.chdir('example')
218
+ @working_directory = Dir.pwd
85
219
  end
86
220
 
87
- # Applications to build
88
- no_applications_file = true
89
- @applications = Hash.new
90
- begin
91
- # The expected format is the application followed by a list of its dependencies
92
- # all on the same line separated by space, : or tab and # for comments
93
- application_and_dependencies = File.open('demake/applications').read.split(/\n/)
94
- no_applications_file = false
95
- application_and_dependencies.each do |app|
96
- if(app !~ /^#/ && app !~ /^[ \t]*#/)
97
- if(app =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
98
- application = $1
99
- dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
100
- @applications[application] = dependencies
101
- else
102
- @applications[app] = Array.new
103
- end
104
- end
221
+ @oreo = false
222
+ if(ARGV[0] =~ /^oreo$/)
223
+ if(File.directory?('oreo') == true)
224
+ notify("\n#{@emoji_fail}|RError|n: |Ydirectory oreo |Ralready exists, aborting creation|n\n\n" +
225
+ "Delete the directory and try again if you wish to recreate it.\n\n")
226
+ exit!
105
227
  end
106
- rescue
228
+ @oreo = true
229
+ # C code file used by oreo
230
+ oreoc = <<-END_OF_STRING
231
+ /*
232
+ oreo.c -- A simple c program that reads data piped in, issued as arguments or from a file and echos output
233
+
234
+ Program main entry point: main/_start
235
+ */
236
+
237
+ #include <stdio.h>
238
+ #include <stdlib.h>
239
+ #include <string.h>
240
+ #ifndef __WIN32__
241
+ #include <sys/ioctl.h>
242
+ #else
243
+ #include <windows.h>
244
+ #endif
245
+
246
+ #define FALSE 0
247
+ #define TRUE 1
248
+
249
+ #define READ_BUFFER_SIZE 4096
250
+
251
+ /* Read all the text from a file and put it into a string */
252
+ char *read_file(FILE *file, unsigned int *total_bytes)
253
+ {
254
+ size_t bytes = 0, count = 0;
255
+ char buffer[READ_BUFFER_SIZE + 1], *text = NULL;
256
+
257
+ *total_bytes = 0;
258
+
259
+ if(file == NULL)
260
+ return NULL;
261
+
262
+ bytes = fread(buffer, sizeof(char), READ_BUFFER_SIZE, file);
263
+ while(bytes) {
264
+ if(text) {
265
+ text = realloc(text, *total_bytes + bytes + 1);
266
+ count = 0;
267
+ while(count < bytes) {
268
+ *(text + *total_bytes + count) = buffer[count];
269
+ count++;
270
+ }
271
+ } else {
272
+ text = calloc(bytes + 1, sizeof(char));
273
+ count = 0;
274
+ while(count < bytes) {
275
+ *(text + *total_bytes + count) = buffer[count];
276
+ count++;
277
+ }
278
+ }
279
+ *total_bytes += (unsigned int)bytes;
280
+ *(text + *total_bytes) = '\\0';
281
+ bytes = fread(buffer, sizeof(char), READ_BUFFER_SIZE, file);
282
+ }
283
+ return text;
284
+ }
285
+
286
+ int main(int argc, char **argv)
287
+ {
288
+ FILE *file = NULL;
289
+ unsigned int total_bytes = 0, l = 0;
290
+ int n = 0;
291
+ unsigned char *string = NULL, displayed = FALSE;
292
+ #ifdef __WIN32__
293
+ HANDLE stdin_handle = GetStdHandle(STD_INPUT_HANDLE);
294
+ DWORD bytes;
295
+
296
+ if(PeekNamedPipe(stdin_handle, NULL, 0, NULL, &bytes, NULL) && bytes > 0) {
297
+ #else
298
+ if(ioctl(0, FIONREAD, &n) == 0 && n > 0) {
299
+ #endif
300
+ string = (unsigned char *)read_file(stdin, &total_bytes);
301
+ #ifdef DEBUG
302
+ printf("From stdin:\\r\\n");
303
+ #endif
304
+ printf("oreo: %s\\r\\n", string);
305
+ free(string);
306
+ string = NULL;
307
+ displayed = TRUE;
308
+ }
309
+ if(argv[1] != NULL) {
310
+ file = fopen(argv[1], "r");
311
+ if(file == NULL) {
312
+ /* We need to manually recreate the command input based on arguments with spaces */
313
+ for(n = 1; n < argc; n++) {
314
+ if(string != NULL) {
315
+ l = (unsigned int)strlen(argv[n]);
316
+ total_bytes += l + 1; /* +1 for space */
317
+ string = realloc(string, (size_t)total_bytes + 1); /* +1 for \\0 */
318
+ strncat((char *)string, " ", (size_t)2); /* 2 for space and \\0 */
319
+ strncat((char *)string, argv[n], l);
320
+ } else {
321
+ total_bytes = (unsigned int)strlen(argv[n]);
322
+ string = calloc(total_bytes + 1, sizeof(char)); /* +1 for \\0 */
323
+ strncpy((char *)string, argv[n], total_bytes);
324
+ }
325
+ }
326
+ #ifdef DEBUG
327
+ printf("From argument:\\r\\n");
328
+ #endif
329
+ printf("oreo: %s\\r\\n", string);
330
+ free(string);
331
+ string = NULL;
332
+ } else {
333
+ #ifdef DEBUG
334
+ printf("From file: %s\\r\\n", argv[1]);
335
+ #endif
336
+ string = (unsigned char *)read_file(file, &total_bytes);
337
+ printf("oreo: %s\\r\\n", string);
338
+ free(string);
339
+ string = NULL;
340
+ }
341
+ } else if(!displayed) {
342
+ #ifdef DEBUG
343
+ printf("No input provided.\\r\\n");
344
+ #endif
345
+ }
346
+
347
+ return 0;
348
+ }
349
+ END_OF_STRING
350
+
351
+ testtargetrb = <<-END_OF_STRING
352
+ test_target << "\\t@echo\\n"
353
+ test_target << "\\t@echo \\"|YBasic functional testing of command oreo:|n\\"\\n"
354
+ test_target << "\\tbin/oreo Test 1\\n"
355
+ test_target << "\\techo -n \\"Test 2\\" || bin/oreo\\n"
356
+ test_target << "\\techo -n \\"Test 3\\" || bin/oreo Test 4\\n"
357
+ END_OF_STRING
358
+
359
+ Dir.mkdir('oreo')
360
+ notify("#{@emoji_success} Created directory: |goreo|n |[open file folder]\n")
361
+ Dir.mkdir('oreo/src')
362
+ notify("#{@emoji_success} Created directory: |goreo|n/|gsrc|n |[open file folder]\n")
363
+ File.open('oreo/src/oreo.c', 'w').write(oreoc)
364
+ notify("#{@emoji_success} Created file: |goreo|n/|gsrc|n/|yoreo.c|n |[page facing up]\n")
365
+ Dir.mkdir('oreo/demake')
366
+ notify("#{@emoji_success} Created directory: |goreo|n/|gdemake|n |[open file folder]\n")
367
+ File.open('oreo/demake/applications', 'w').write("oreo\n")
368
+ notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|yapplications|n |[page facing up]\n")
369
+ File.open('oreo/demake/settings.rb', 'w').write(settingsrb)
370
+ notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|ysettings.rb|n |[page facing up]\n")
371
+ File.open('oreo/demake/test-target.rb', 'w').write(testtargetrb)
372
+ notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|ytest-target.rb|n |[page facing up]\n")
373
+ Dir.chdir('oreo')
374
+ @working_directory = Dir.pwd
107
375
  end
108
376
 
109
- # Libraries to build
110
- no_libraries_file = true
377
+ @applications = Hash.new
111
378
  @build_libraries = Hash.new
112
- begin
113
- # The expected format is the application followed by a list of its dependencies
114
- # all on the same line separated by space, : or tab and # for comments
115
- libraries_and_dependencies = File.open('demake/libraries').read.split(/\n/)
116
- no_libraries_file = false
117
- libraries_and_dependencies.each do |lib|
118
- if(lib !~ /^#/ && lib !~ /^[ \t]*#/)
119
- if(lib =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
120
- library = $1
121
- dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
122
- @build_libraries[library] = dependencies
123
- else
124
- @build_libraries[lib] = Array.new
379
+
380
+ if(@example == false && @oreo == false)
381
+ # Check for settings override
382
+ begin
383
+ code = File.open('demake/settings.rb').read
384
+ if(@emojis == false)
385
+ strip_emojis!(code)
386
+ end
387
+ eval code
388
+ rescue Errno::ENOENT
389
+ rescue
390
+ notify("\n|YWARNING|n: #{$!}\n\n")
391
+ end
392
+
393
+ # Applications to build
394
+ no_applications_file = true
395
+ begin
396
+ # The expected format is the application followed by a list of its dependencies
397
+ # all on the same line separated by space, : or tab and # for comments
398
+ application_and_dependencies = File.open('demake/applications').read.split(/\n/)
399
+ no_applications_file = false
400
+ application_and_dependencies.each do |app|
401
+ if(app !~ /^#/ && app !~ /^[ \t]*#/)
402
+ if(app =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
403
+ application = $1
404
+ dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
405
+ @applications[application] = dependencies
406
+ else
407
+ @applications[app] = Array.new
408
+ end
125
409
  end
126
410
  end
411
+ rescue
127
412
  end
128
- rescue
129
- end
130
413
 
131
- if(no_applications_file && no_libraries_file)
132
- notify("\n|RError|n: |Yapplications file|n |Rdoes not exist|n\n\n" +
133
- "You must create a file named |Yapplications|n which contains a list of\n" +
134
- "executeable application names and any dependencies to be compiled.\n\n")
135
- exit!
136
- elsif(@applications == {} && @build_libraries == {})
137
- notify("\n|RError|n: |Yapplications file|n |Rcannot be empty|n\n\n" +
138
- "You must create a file named |Yapplications|n which contains a list of\n" +
139
- "executeable application names and any dependencies to be compiled.\n\n")
140
- exit!
414
+ # Libraries to build
415
+ no_libraries_file = true
416
+ begin
417
+ # The expected format is the application followed by a list of its dependencies
418
+ # all on the same line separated by space, : or tab and # for comments
419
+ libraries_and_dependencies = File.open('demake/libraries').read.split(/\n/)
420
+ no_libraries_file = false
421
+ libraries_and_dependencies.each do |lib|
422
+ if(lib !~ /^#/ && lib !~ /^[ \t]*#/)
423
+ if(lib =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
424
+ library = $1
425
+ dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
426
+ @build_libraries[library] = dependencies
427
+ else
428
+ @build_libraries[lib] = Array.new
429
+ end
430
+ end
431
+ end
432
+ rescue
433
+ end
434
+ if(no_applications_file && no_libraries_file)
435
+ notify("\n#{@emoji_fail}|RError|n: |Yapplications file|n |Rdoes not exist|n\n\n" +
436
+ "You must create a file named |Yapplications|n which contains a list of\n" +
437
+ "executeable application names and any dependencies to be compiled.\n\n")
438
+ exit!
439
+ elsif(@applications == {} && @build_libraries == {})
440
+ notify("\n#{@emoji_fail}|RError|n: |Yapplications file|n |Rcannot be empty|n\n\n" +
441
+ "You must create a file named |Yapplications|n which contains a list of\n" +
442
+ "executeable application names and any dependencies to be compiled.\n\n")
443
+ exit!
444
+ end
445
+ elsif(@oreo == true)
446
+ @applications['oreo'] = Array.new
447
+ elsif(@example == true)
448
+ @applications['hello'] = ['string']
449
+ @applications['goodbye'] = ['string']
141
450
  end
142
451
 
143
452
  @output = <<-END_OF_STRING
@@ -158,6 +467,8 @@ CC = #{@compiler}
158
467
  OS := $(shell uname)
159
468
  PROCESSOR := $(shell uname -p)
160
469
  MACHINE := $(shell uname -m)
470
+ PREFIX = #{@prefix}
471
+ LIBRARY_PREFIX = #{@library_prefix}
161
472
  END_OF_STRING
162
473
 
163
474
  @output << compiler_settings
@@ -168,6 +479,16 @@ if(@linux_flags != "")
168
479
  compiler_flags << " FLAGS += #{@linux_flags}\n"
169
480
  compiler_flags << "endif\n"
170
481
  end
482
+ if(@freebsd_flags != "")
483
+ compiler_flags << "ifeq '$(OS)' 'FreeBSD'\n"
484
+ compiler_flags << " FLAGS += #{@freebsd_flags}\n"
485
+ compiler_flags << "endif\n"
486
+ end
487
+ if(@windows_flags != "")
488
+ compiler_flags << "ifeq '$(OS)' 'Windows_NT'\n"
489
+ compiler_flags << " FLAGS += #{@windows_flags}\n"
490
+ compiler_flags << "endif\n"
491
+ end
171
492
  if(@darwin_flags != "")
172
493
  compiler_flags << "ifeq '$(OS)' 'Darwin'\n"
173
494
  compiler_flags << " FLAGS += #{@darwin_flags}\n"
@@ -184,11 +505,7 @@ if(@x86_64_flags != "")
184
505
  compiler_flags << "endif\n"
185
506
  end
186
507
  compiler_flags += <<-END_OF_STRING
187
- ifeq '$(CC)' 'gcc'
188
- DEBUG_FLAGS = $(FLAGS) -g -Wall -Wpedantic -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef -Wconversion -Wshadow -Wcast-qual -Wwrite-strings
189
- else
190
- DEBUG_FLAGS = $(FLAGS) -g -Wall -Wpedantic -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef -Wconversion -Wshadow -Wcast-qual -Wwrite-strings
191
- endif
508
+ DEBUG_FLAGS = #{@debug_flags}
192
509
  FLAGS += -O2
193
510
  CFLAGS = $(FLAGS)
194
511
  END_OF_STRING
@@ -200,9 +517,9 @@ end
200
517
  @output << compiler_flags
201
518
 
202
519
  if(compiler_flags =~ /-static/)
203
- library_extension = '.a'
520
+ @library_extension = '.a'
204
521
  else
205
- library_extension = '.so'
522
+ @library_extension = '.so'
206
523
  end
207
524
 
208
525
  compiler_directories = <<-END_OF_STRING
@@ -223,12 +540,12 @@ debug_file_list = String.new
223
540
  @applications.each do |app|
224
541
  counter += 1
225
542
  file_list << "#\n# #{app[0]} - File List (FL#{counter})\n#\n"
226
- debug_file_list << "#\n# #{app[0]}-debug - Debug File List (DFL#{counter})\n#\n"
543
+ debug_file_list << "#\n# #{app[0]}_debug - Debug File List (DFL#{counter})\n#\n"
227
544
  # test to see if there is a app.c and we need app.o
228
545
  begin
229
546
  File.open(@source_directory + '/' + "#{app[0]}.c")
230
547
  file_list << "FL#{counter} = #{app[0]}.o"
231
- debug_file_list << "DFL#{counter} = #{app[0]}-debug.o"
548
+ debug_file_list << "DFL#{counter} = #{app[0]}_debug.o"
232
549
  rescue Errno::ENOENT
233
550
  file_list << "FL#{counter} ="
234
551
  debug_file_list << "DFL#{counter} ="
@@ -239,7 +556,7 @@ debug_file_list = String.new
239
556
  Dir.chdir(@source_directory + '/' + app[0]) do
240
557
  if(File.directory?(e) == false)
241
558
  file_list << " " + app[0] + '/' + $1 + '.o'
242
- debug_file_list << " " + app[0] + '/' + $1 + '-debug.o'
559
+ debug_file_list << " " + app[0] + '/' + $1 + '_debug.o'
243
560
  end
244
561
  end
245
562
  end
@@ -252,14 +569,14 @@ debug_file_list = String.new
252
569
  Dir.chdir(@source_directory + '/' + dep) do
253
570
  if(File.directory?(e) == false)
254
571
  file_list << " " + dep + '/' + $1 + '.o'
255
- debug_file_list << " " + dep + '/' + $1 + '-debug.o'
572
+ debug_file_list << " " + dep + '/' + $1 + '_debug.o'
256
573
  end
257
574
  end
258
575
  end
259
576
  end
260
577
  else
261
578
  file_list << " " + dep.sub(/\.cp?p?$/, '.o')
262
- debug_file_list << " " + dep.sub(/\.o$/, '-debug.o').sub(/\.cp?p?$/, '-debug.o')
579
+ debug_file_list << " " + dep.sub(/\.o$/, '_debug.o').sub(/\.cp?p?$/, '_debug.o')
263
580
  end
264
581
  end
265
582
  file_list << "\n"
@@ -267,7 +584,7 @@ debug_file_list = String.new
267
584
  file_list << "OL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(FL#{counter}))\n"
268
585
  @output << file_list
269
586
  debug_file_list << "\n"
270
- debug_file_list << "#\n# #{app[0]}-debug - Debug Object List (DOL#{counter})\n#\n"
587
+ debug_file_list << "#\n# #{app[0]}_debug - Debug Object List (DOL#{counter})\n#\n"
271
588
  debug_file_list << "DOL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(DFL#{counter}))\n"
272
589
  @output << debug_file_list
273
590
  end
@@ -276,13 +593,13 @@ file_list = String.new
276
593
  debug_file_list = String.new
277
594
  @build_libraries.each do |lib|
278
595
  counter += 1
279
- file_list << "#\n# #{lib[0]}#{library_extension} - File List (FL#{counter})\n#\n"
280
- debug_file_list << "#\n# #{lib[0]}-debug#{library_extension} - Debug File List (DFL#{counter})\n#\n"
596
+ file_list << "#\n# #{lib[0]}#{@library_extension} - File List (FL#{counter})\n#\n"
597
+ debug_file_list << "#\n# #{lib[0]}_debug#{@library_extension} - Debug File List (DFL#{counter})\n#\n"
281
598
  # test to see if there is a lib.c and we need lib.o
282
599
  begin
283
600
  File.open(@source_directory + '/' + "#{lib[0]}.c")
284
601
  file_list << "FL#{counter} = #{lib[0]}.o"
285
- debug_file_list << "DFL#{counter} = #{lib[0]}-debug.o"
602
+ debug_file_list << "DFL#{counter} = #{lib[0]}_debug.o"
286
603
  rescue Errno::ENOENT
287
604
  file_list << "FL#{counter} ="
288
605
  debug_file_list << "DFL#{counter} ="
@@ -293,7 +610,7 @@ debug_file_list = String.new
293
610
  Dir.chdir(@source_directory + '/' + lib[0]) do
294
611
  if(File.directory?(e) == false)
295
612
  file_list << " " + lib[0] + '/' + $1 + '.o'
296
- debug_file_list << " " + lib[0] + '/' + $1 + '-debug.o'
613
+ debug_file_list << " " + lib[0] + '/' + $1 + '_debug.o'
297
614
  end
298
615
  end
299
616
  end
@@ -306,22 +623,22 @@ debug_file_list = String.new
306
623
  Dir.chdir(@source_directory + '/' + dep) do
307
624
  if(File.directory?(e) == false)
308
625
  file_list << " " + dep + '/' + $1 + '.o'
309
- debug_file_list << " " + dep + '/' + $1 + '-debug.o'
626
+ debug_file_list << " " + dep + '/' + $1 + '_debug.o'
310
627
  end
311
628
  end
312
629
  end
313
630
  end
314
631
  else
315
632
  file_list << " " + dep.sub(/\.cp?p?$/, '.o')
316
- debug_file_list << " " + dep.sub(/\.o$/, '-debug.o').sub(/\.cp?p?$/, '-debug.o')
633
+ debug_file_list << " " + dep.sub(/\.o$/, '_debug.o').sub(/\.cp?p?$/, '_debug.o')
317
634
  end
318
635
  end
319
636
  file_list << "\n"
320
- file_list << "#\n# #{lib[0]}#{library_extension} - Object List (OL#{counter})\n#\n"
637
+ file_list << "#\n# #{lib[0]}#{@library_extension} - Object List (OL#{counter})\n#\n"
321
638
  file_list << "OL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(FL#{counter}))\n"
322
639
  @output << file_list
323
640
  debug_file_list << "\n"
324
- debug_file_list << "#\n# #{lib[0]}-debug#{library_extension} - Debug Object List (DOL#{counter})\n#\n"
641
+ debug_file_list << "#\n# #{lib[0]}_debug#{@library_extension} - Debug Object List (DOL#{counter})\n#\n"
325
642
  debug_file_list << "DOL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(DFL#{counter}))\n"
326
643
  @output << debug_file_list
327
644
  end
@@ -329,25 +646,26 @@ end
329
646
  menu_target = <<-END_OF_STRING
330
647
  .PHONY : menu
331
648
  menu :
332
- \t@echo "|]78|=[|70-]|O"
649
+ \t@echo "|]#{BOX_WIDTH}|=[|#{SHORT_WIDTH}-]|O"
333
650
  \t@echo "|=!|;!|O"
334
- \t@echo "|=!|26 Make targets:|;!|O"
651
+ \t@echo "|=!|27 Make targets:|;!|O"
335
652
  \t@echo "|=!|;!|O"
336
- \t@echo "|=!|28 #{@emoji_build} |cbuild|n|;!|O"
337
- \t@echo "|=!|28 #{@emoji_clean} |cclean|n|;!|O"
338
- \t@echo "|=!|28 #{@emoji_debug} |cdebug|n|;!|O"
339
- \t@echo "|=!|28 #{@emoji_install} |cinstall|n|;!|O"
340
- \t@echo "|=!|28 #{@emoji_test} |ctest|n|;!|O"
653
+ \t@echo "|=!|29 #{@emoji_build} |cbuild|n|;!|O"
654
+ \t@echo "|=!|29 #{@emoji_clean} |cclean|n|;!|O"
655
+ \t@echo "|=!|29 #{@emoji_debug} |cdebug|n|;!|O"
656
+ \t@echo "|=!|29 #{@emoji_install} |cinstall|n|;!|O"
657
+ \t@echo "|=!|29 #{@emoji_uninstall} |cuninstall|n|;!|O"
658
+ \t@echo "|=!|29 #{@emoji_test} |ctest|n|;!|O"
341
659
  \t@echo "|=!|;!|O"
342
- \t@echo "|=>|70-<|O"
660
+ \t@echo "|=>|#{SHORT_WIDTH}-<|O"
343
661
  END_OF_STRING
344
662
  @applications.each do |app|
345
- menu_target << "\t@echo \"|=!|]78 Executable: bin/|g#{app[0]}|n|;!|O\"\n"
663
+ menu_target << "\t@echo \"|=!|]#{BOX_WIDTH} Executable: bin/|O|g#{app[0]}|n|=|;!|O\"\n"
346
664
  end
347
665
  @build_libraries.each do |lib|
348
- menu_target << "\t@echo \"|=!|]78 Library: bin/|g#{lib[0]}#{library_extension}|n|;!|O\"\n"
666
+ menu_target << "\t@echo \"|=!|]#{BOX_WIDTH} Library: bin/|O|g#{lib[0]}#{@library_extension}|n|=|;!|O\"\n"
349
667
  end
350
- menu_target << "\t@echo \"|={|70-}|O\"\n"
668
+ menu_target << "\t@echo \"|={|#{SHORT_WIDTH}-}|O\"\n"
351
669
  @output << "\n"
352
670
  if(@emojis == false)
353
671
  strip_emojis!(menu_target)
@@ -361,9 +679,9 @@ END_OF_STRING
361
679
 
362
680
  @applications.each do |app|
363
681
  executable_target = <<-END_OF_STRING
364
- \t@echo "|=[|70-]|O"
365
- \t@echo "|]78|=! #{@emoji_build} Building executable: bin/|g#{app[0]}|n|;!|O"
366
- \t@echo "|={|70-}|O"
682
+ \t@echo "|=[|#{SHORT_WIDTH}-]|O"
683
+ \t@echo "|]#{BOX_WIDTH}|=! #{@emoji_build} Building executable: bin/|O|g#{app[0]}|n|=|;!|O"
684
+ \t@echo "|={|#{SHORT_WIDTH}-}|O"
367
685
  \t@$(MAKE) $(BINARY)/#{app[0]}
368
686
  END_OF_STRING
369
687
  if(@emojis == false)
@@ -374,10 +692,10 @@ end
374
692
 
375
693
  @build_libraries.each do |lib|
376
694
  library_target = <<-END_OF_STRING
377
- \t@echo "|=[|70-]|O"
378
- \t@echo "|]78|=! #{@emoji_build} Building library: bin/|g#{lib[0]}|n|;!|O"
379
- \t@echo "|={|70-}|O"
380
- \t@$(MAKE) $(BINARY)/#{lib[0]}#{library_extension}
695
+ \t@echo "|=[|#{SHORT_WIDTH}-]|O"
696
+ \t@echo "|]#{BOX_WIDTH}|=! #{@emoji_build} Building library: bin/|O|g#{lib[0]}|n|=|;!|O"
697
+ \t@echo "|={|#{SHORT_WIDTH}-}|O"
698
+ \t@$(MAKE) $(BINARY)/#{lib[0]}#{@library_extension}
381
699
  END_OF_STRING
382
700
  if(@emojis == false)
383
701
  strip_emojis!(library_target)
@@ -388,48 +706,49 @@ end
388
706
  @output << "\n"
389
707
  @output << build_target
390
708
 
709
+ def add_dependencies_from_file(dependencies, filename, path)
710
+ File.readlines(filename).each do |line|
711
+ if(line =~ /#include \"(.*)\"/)
712
+ included_filename = @working_directory + '/' + @source_directory + path + $1
713
+ begin
714
+ File.open(included_filename)
715
+ add_dependencies_from_file(dependencies, included_filename, path)
716
+ rescue Errno::ENOENT
717
+ notify("|YWARNING|n: included dependency does not exist - Removing #{filename}:#{included_filename}\n")
718
+ next
719
+ rescue
720
+ notify("|YWARNING|n: #{$!} - Removing #{filename}:#{included_filename}\n")
721
+ next
722
+ end
723
+ dependencies << "\t\\\n\t$(SOURCE)#{path}#{$1}"
724
+ end
725
+ end
726
+ end
727
+
391
728
  def add_dependencies(filename, path)
392
729
  begin
393
730
  dependencies = String.new
394
- File.readlines(filename).each do |line|
395
- if(line =~ /^#include \"(.*)\"/)
396
- file_name = @working_directory + '/' + @source_directory + path + $1
397
- begin
398
- File.open(file_name)
399
- rescue Errno::ENOENT
400
- notify("|YWARNING|n: included dependency does not exist - Removing #{filename}:#{file_name}\n")
401
- next
402
- rescue
403
- notify("|YWARNING|n: #{$!} - Removing #{filename}:#{file_name}\n")
404
- next
405
- end
406
- dependencies << "\t\\\n\t$(SOURCE)#{path}#{$1}"
407
- end
408
- end
731
+ add_dependencies_from_file(dependencies, filename, path)
409
732
  if(dependencies != "")
410
733
  dependency_targets = <<-END_OF_STRING
411
734
  # Dependencies
412
735
  $(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')} : $(SOURCE)#{path}#{filename}#{dependencies}
413
736
  \t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')}|n"
414
- ifeq '$(OS)' 'Linux'
415
- \t@mkdir -p $(OBJECT)#{path}
416
- else ifeq '$(OS)' 'FreeBSD'
417
- \t@mkdir -p $(OBJECT)#{path}
737
+ ifeq '$(OS)' 'Windows_NT'
738
+ \t@test -d $(OBJECT)#{path} |||| mkdir $(OBJECT)#{path}
418
739
  else
419
- \t@if not exist $(OBJECT)#{path} @mkdir $(OBJECT)#{path}
740
+ \t@mkdir -p $(OBJECT)#{path}
420
741
  endif
421
- \t$(CC) $(CFLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '.o')}
742
+ \t$(CC) $(LIBS) $(CFLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '.o')}
422
743
  # Dependencies for debug
423
- $(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '-debug.o')} : $(SOURCE)#{path}#{filename}#{dependencies}
424
- \t@echo "|=!|O #{@emoji_debug} #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '-debug.o')}|n"
425
- ifeq '$(OS)' 'Linux'
426
- \t@mkdir -p $(OBJECT)#{path}
427
- else ifeq '$(OS)' 'FreeBSD'
428
- \t@mkdir -p $(OBJECT)#{path}
744
+ $(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '_debug.o')} : $(SOURCE)#{path}#{filename}#{dependencies}
745
+ \t@echo "|=!|O #{@emoji_debug} #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '_debug.o')}|n"
746
+ ifeq '$(OS)' 'Windows_NT'
747
+ \t@test -d $(OBJECT)#{path} |||| mkdir $(OBJECT)#{path}
429
748
  else
430
- \t@if not exist $(OBJECT)#{path} @mkdir $(OBJECT)#{path}
749
+ \t@mkdir -p $(OBJECT)#{path}
431
750
  endif
432
- \t$(CC) $(DEBUG_FLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '-debug.o')}
751
+ \t$(CC) $(LIBS) $(DEBUG_FLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '_debug.o')}
433
752
  END_OF_STRING
434
753
  if(@emojis == false)
435
754
  strip_emojis!(dependency_targets)
@@ -456,7 +775,7 @@ def add_all_dependencies(directory, path)
456
775
  Dir.entries(directory).each do |e|
457
776
  if(e != '.' && e != '..')
458
777
  Dir.chdir(directory) do
459
- if(File.directory?(e) == false)
778
+ if(File.directory?(e) == false && (e =~ /.c$/ || e =~ /.cpp$/))
460
779
  add_dependencies(e, path)
461
780
  end
462
781
  end
@@ -471,17 +790,15 @@ counter = 0
471
790
  counter += 1
472
791
  executable_target = <<-END_OF_STRING
473
792
  $(BINARY)/#{app[0]} : $(OL#{counter})
474
- \t@echo "|=[|70-]|O"
475
- \t@echo "|]78|=! #{@emoji_link} Linking Files...|O bin/|g#{app[0]}|=|n|;!|O"
476
- \t@echo "|={|70-}|O"
477
- ifeq '$(OS)' 'Linux'
478
- \t@mkdir -p $(BINARY)
479
- else ifeq '$(OS)' 'FreeBSD'
480
- \t@mkdir -p $(BINARY)
793
+ \t@echo "|=[|#{SHORT_WIDTH}-]|O"
794
+ \t@echo "|]#{BOX_WIDTH}|=! #{@emoji_link} Linking Files...|O bin/|g#{app[0]}|=|n|;!|O"
795
+ \t@echo "|={|#{SHORT_WIDTH}-}|O"
796
+ ifeq '$(OS)' 'Windows_NT'
797
+ \t@test -d $(BINARY) |||| mkdir $(BINARY)
481
798
  else
482
- \t@if not exist $(BINARY) @mkdir $(BINARY)
799
+ \t@mkdir -p $(BINARY)
483
800
  endif
484
- \t$(CC) $(CFLAGS) $(LIBS) -o $(BINARY)/#{app[0]} $(OL#{counter})#{@raw_binary_files}
801
+ \t$(CC) $(LIBS) $(CFLAGS) -o $(BINARY)/#{app[0]} $(OL#{counter})#{@raw_binary_files}
485
802
  END_OF_STRING
486
803
  @output << "\n"
487
804
  if(@emojis == false)
@@ -490,7 +807,7 @@ END_OF_STRING
490
807
  @output << @pipe.pipetext(executable_target)
491
808
  end
492
809
 
493
- if(library_extension == ".so")
810
+ if(@library_extension == ".so")
494
811
  shared = " -shared"
495
812
  else
496
813
  shared = String.new
@@ -499,18 +816,16 @@ end
499
816
  @build_libraries.each do |lib|
500
817
  counter += 1
501
818
  library_target = <<-END_OF_STRING
502
- $(BINARY)/#{lib[0]}#{library_extension} : $(OL#{counter})
503
- \t@echo "|=[|70-]|O"
504
- \t@echo "|]78|=! #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}#{library_extension}|=|n|;!|O"
505
- \t@echo "|={|70-}|O"
506
- ifeq '$(OS)' 'Linux'
507
- \t@mkdir -p $(BINARY)
508
- else ifeq '$(OS)' 'FreeBSD'
509
- \t@mkdir -p $(BINARY)
819
+ $(BINARY)/#{lib[0]}#{@library_extension} : $(OL#{counter})
820
+ \t@echo "|=[|#{SHORT_WIDTH}-]|O"
821
+ \t@echo "|]#{BOX_WIDTH}|=! #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}#{@library_extension}|=|n|;!|O"
822
+ \t@echo "|={|#{SHORT_WIDTH}-}|O"
823
+ ifeq '$(OS)' 'Windows_NT'
824
+ \t@test -d $(BINARY) |||| mkdir $(BINARY)
510
825
  else
511
- \t@if not exist $(BINARY) @mkdir $(BINARY)
826
+ \t@mkdir -p $(BINARY)
512
827
  endif
513
- \t$(CC)#{shared} $(CFLAGS) $(LIBS) -o $(BINARY)/#{lib[0]}#{library_extension} $(OL#{counter})#{@raw_binary_files}
828
+ \t$(CC)#{shared} $(LIBS) $(CFLAGS) -o $(BINARY)/#{lib[0]}#{@library_extension} $(OL#{counter})#{@raw_binary_files}
514
829
  END_OF_STRING
515
830
  @output << "\n"
516
831
  if(@emojis == false)
@@ -524,18 +839,16 @@ counter = 0
524
839
  @applications.each do |app|
525
840
  counter += 1
526
841
  debug_executable_target = <<-END_OF_STRING
527
- $(BINARY)/#{app[0]}-debug : $(DOL#{counter})
528
- \t@echo "|=[|70-]|O"
529
- \t@echo "|]78|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{app[0]}-debug|=|n|;!|O"
530
- \t@echo "|={|70-}|O"
531
- ifeq '$(OS)' 'Linux'
532
- \t@mkdir -p $(BINARY)
533
- else ifeq '$(OS)' 'FreeBSD'
534
- \t@mkdir -p $(BINARY)
842
+ $(BINARY)/#{app[0]}_debug : $(DOL#{counter})
843
+ \t@echo "|=[|#{SHORT_WIDTH}-]|O"
844
+ \t@echo "|]#{BOX_WIDTH}|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{app[0]}_debug|=|n|;!|O"
845
+ \t@echo "|={|#{SHORT_WIDTH}-}|O"
846
+ ifeq '$(OS)' 'Windows_NT'
847
+ \t@test -d $(BINARY) |||| mkdir $(BINARY)
535
848
  else
536
- \t@if not exist $(BINARY) @mkdir $(BINARY)
849
+ \t@mkdir -p $(BINARY)
537
850
  endif
538
- \t$(CC) $(DEBUG_FLAGS) $(LIBS) -o $(BINARY)/#{app[0]}-debug $(DOL#{counter})#{@raw_binary_files}
851
+ \t$(CC) $(LIBS) $(DEBUG_FLAGS) -o $(BINARY)/#{app[0]}_debug $(DOL#{counter})#{@raw_binary_files}
539
852
  END_OF_STRING
540
853
  @output << "\n"
541
854
  if(@emojis == false)
@@ -547,18 +860,16 @@ end
547
860
  @build_libraries.each do |lib|
548
861
  counter += 1
549
862
  debug_library_target = <<-END_OF_STRING
550
- $(BINARY)/#{lib[0]}-debug#{library_extension} : $(DOL#{counter})
551
- \t@echo "|=[|70-]|O"
552
- \t@echo "|]78|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}-debug#{library_extension}|=|n|;!|O"
553
- \t@echo "|={|70-}|O"
554
- ifeq '$(OS)' 'Linux'
555
- \t@mkdir -p $(BINARY)
556
- else ifeq '$(OS)' 'FreeBSD'
557
- \t@mkdir -p $(BINARY)
863
+ $(BINARY)/#{lib[0]}_debug#{@library_extension} : $(DOL#{counter})
864
+ \t@echo "|=[|#{SHORT_WIDTH}-]|O"
865
+ \t@echo "|]#{BOX_WIDTH}|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}_debug#{@library_extension}|=|n|;!|O"
866
+ \t@echo "|={|#{SHORT_WIDTH}-}|O"
867
+ ifeq '$(OS)' 'Windows_NT'
868
+ \t@test -d $(BINARY) |||| mkdir $(BINARY)
558
869
  else
559
- \t@if not exist $(BINARY) @mkdir $(BINARY)
870
+ \t@mkdir -p $(BINARY)
560
871
  endif
561
- \t$(CC)#{shared} $(DEBUG_FLAGS) $(LIBS) -o $(BINARY)/#{lib[0]}-debug#{library_extension} $(DOL#{counter})#{@raw_binary_files}
872
+ \t$(CC)#{shared} $(LIBS) $(DEBUG_FLAGS) -o $(BINARY)/#{lib[0]}_debug#{@library_extension} $(DOL#{counter})#{@raw_binary_files}
562
873
  END_OF_STRING
563
874
  @output << "\n"
564
875
  if(@emojis == false)
@@ -571,31 +882,25 @@ dependency_targets = <<-END_OF_STRING
571
882
  # General Auto-Dependencies
572
883
  $(OBJECT)/%.o : $(SOURCE)/%.c
573
884
  \t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(@)|n"
574
- ifeq '$(OS)' 'Linux'
575
- \t@mkdir -p $(BINARY)
576
- \t@mkdir -p $(OBJECT)
577
- else ifeq '$(OS)' 'FreeBSD'
885
+ ifeq '$(OS)' 'Windows_NT'
886
+ \t@test -d $(BINARY) |||| mkdir $(BINARY)
887
+ \t@test -d $(OBJECT) |||| mkdir $(OBJECT)
888
+ else
578
889
  \t@mkdir -p $(BINARY)
579
890
  \t@mkdir -p $(OBJECT)
580
- else
581
- \t@if not exist $(BINARY) @mkdir $(BINARY)
582
- \t@if not exist $(OBJECT) @mkdir $(OBJECT)
583
891
  endif
584
- \t$(CC) $(CFLAGS) -c $< -o $@
892
+ \t$(CC) $(LIBS) $(CFLAGS) -c $< -o $@
585
893
  # General Auto-Dependencies for debug
586
- $(OBJECT)/%-debug.o : $(SOURCE)/%.c
894
+ $(OBJECT)/%_debug.o : $(SOURCE)/%.c
587
895
  \t@echo "|=!|O #{@emoji_debug} #{@emoji_compile} Compiling... |Y$(@)|n"
588
- ifeq '$(OS)' 'Linux'
589
- \t@mkdir -p $(BINARY)
590
- \t@mkdir -p $(OBJECT)
591
- else ifeq '$(OS)' 'FreeBSD'
896
+ ifeq '$(OS)' 'Windows_NT'
897
+ \t@test -d $(BINARY) |||| mkdir $(BINARY)
898
+ \t@test -d $(OBJECT) |||| mkdir $(OBJECT)
899
+ else
592
900
  \t@mkdir -p $(BINARY)
593
901
  \t@mkdir -p $(OBJECT)
594
- else
595
- \t@if not exist $(BINARY) @mkdir $(BINARY)
596
- \t@if not exist $(OBJECT) @mkdir $(OBJECT)
597
902
  endif
598
- \t$(CC) $(DEBUG_FLAGS) -c $< -o $@
903
+ \t$(CC) $(LIBS) $(DEBUG_FLAGS) -c $< -o $@
599
904
  END_OF_STRING
600
905
  if(@emojis == false)
601
906
  strip_emojis!(dependency_targets)
@@ -606,16 +911,7 @@ clean_target = <<-END_OF_STRING
606
911
  .PHONY : clean
607
912
  clean :
608
913
  \t@echo "#{@emoji_clean} Removed |Yeverything|n from |R$(OBJECT)|n and |R$(BINARY)|n directories"
609
- ifeq '$(OS)' 'Linux'
610
- \t@rm -rf $(OBJECT) $(BINARY)
611
- else ifeq '$(OS)' 'FreeBSD'
612
914
  \t@rm -rf $(OBJECT) $(BINARY)
613
- else
614
- \t@if exist $(OBJECT)\*.* erase /Q $(OBJECT)\*.*
615
- \t@if exist $(OBJECT) rmdir $(OBJECT)
616
- \t@if exist $(BINARY)\*.* erase /Q $(BINARY)\*.*
617
- \t@if exist $(BINARY) rmdir $(BINARY)
618
- endif
619
915
  END_OF_STRING
620
916
  if(@emojis == false)
621
917
  strip_emojis!(clean_target)
@@ -629,10 +925,10 @@ END_OF_STRING
629
925
 
630
926
  @applications.each do |app|
631
927
  executable_debug_target = <<-END_OF_STRING
632
- \t@echo "|=[|70-]|O"
633
- \t@echo "|]78|=! #{@emoji_debug} #{@emoji_build} |nBuilding executable:|O bin/|g#{app[0]}-debug|=|n|;!|O"
634
- \t@echo "|={|70-}|O"
635
- \t@$(MAKE) $(BINARY)/#{app[0]}-debug
928
+ \t@echo "|=[|#{SHORT_WIDTH}-]|O"
929
+ \t@echo "|]#{BOX_WIDTH}|=! #{@emoji_debug} #{@emoji_build} |nBuilding executable:|O bin/|g#{app[0]}_debug|=|n|;!|O"
930
+ \t@echo "|={|#{SHORT_WIDTH}-}|O"
931
+ \t@$(MAKE) $(BINARY)/#{app[0]}_debug
636
932
  END_OF_STRING
637
933
  if(@emojis == false)
638
934
  strip_emojis!(executable_debug_target)
@@ -642,10 +938,10 @@ end
642
938
 
643
939
  @build_libraries.each do |lib|
644
940
  library_debug_target = <<-END_OF_STRING
645
- \t@echo "|=[|70-]|O"
646
- \t@echo "|]78|=! #{@emoji_debug} #{@emoji_build} Building library:|O bin/|g#{lib[0]}-debug#{library_extension}|=|n|;!|O"
647
- \t@echo "|={|70-}|O"
648
- \t@$(MAKE) $(BINARY)/#{lib[0]}-debug#{library_extension}
941
+ \t@echo "|=[|#{SHORT_WIDTH}-]|O"
942
+ \t@echo "|]#{BOX_WIDTH}|=! #{@emoji_debug} #{@emoji_build} Building library:|O bin/|g#{lib[0]}_debug#{@library_extension}|=|n|;!|O"
943
+ \t@echo "|={|#{SHORT_WIDTH}-}|O"
944
+ \t@$(MAKE) $(BINARY)/#{lib[0]}_debug#{@library_extension}
649
945
  END_OF_STRING
650
946
  if(@emojis == false)
651
947
  strip_emojis!(library_debug_target)
@@ -656,6 +952,11 @@ end
656
952
  @output << "\n"
657
953
  @output << debug_target
658
954
 
955
+ def default_test_target(test_target)
956
+ test_target << "\t@echo\n"
957
+ test_target << "\t@echo \"#{@emoji_fail} |rWARNING: No tests have been created!|n\""
958
+ end
959
+
659
960
  test_target = <<-END_OF_STRING
660
961
  test :
661
962
  \t@echo -n "#{@emoji_test} Running tests"
@@ -667,11 +968,6 @@ begin
667
968
  end
668
969
  eval code
669
970
  rescue Errno::ENOENT
670
- test_targets = <<-END_OF_STRING
671
- \t@echo
672
- \t@echo "#{@emoji_fail} |rWARNING: No tests have been created!|n"
673
- END_OF_STRING
674
- test_target << test_targets
675
971
  rescue
676
972
  notify("\n|YWARNING|n: #{$!}\n\n")
677
973
  end
@@ -680,6 +976,22 @@ if(@emojis == false)
680
976
  end
681
977
  @output << "\n" + @pipe.pipetext(test_target)
682
978
 
979
+ def default_install_target(install_target)
980
+ if(@applications != {})
981
+ install_target << "\tinstall -d $(PREFIX)\n"
982
+ end
983
+ @applications.each do |app|
984
+ install_target << "\tinstall -m 755 bin/#{app[0]} $(PREFIX)\n"
985
+ end
986
+ if(@build_libraries != {})
987
+ install_target << "\tinstall -d $(LIBRARY_PREFIX)\n"
988
+ end
989
+ @build_libraries.each do |lib|
990
+ install_target << "\tinstall -m 644 bin/#{lib[0]}#{@library_extension} $(LIBRARY_PREFIX)\n"
991
+ end
992
+ install_target << "\t@echo \"#{@emoji_install} #{@emoji_success} |gInstallation Finished|n\"\n"
993
+ end
994
+
683
995
  install_target = <<-END_OF_STRING
684
996
  .PHONY : install
685
997
  install :
@@ -692,10 +1004,7 @@ begin
692
1004
  end
693
1005
  eval code
694
1006
  rescue Errno::ENOENT
695
- install_targets = <<-END_OF_STRING
696
- \t@echo "#{@emoji_fail} |rNo install scripts have been executed|n"
697
- END_OF_STRING
698
- install_target << install_targets
1007
+ default_install_target(install_target)
699
1008
  rescue
700
1009
  notify("\n|YWARNING|n: #{$!}\n\n")
701
1010
  end
@@ -704,4 +1013,57 @@ if(@emojis == false)
704
1013
  end
705
1014
  @output << "\n" + @pipe.pipetext(install_target)
706
1015
 
707
- puts @output
1016
+ def default_uninstall_target(uninstall_target)
1017
+ @applications.each do |app|
1018
+ uninstall_target << "\trm -f $(PREFIX)#{app[0]}\n"
1019
+ end
1020
+ if(@applications != {})
1021
+ uninstall_target << "ifneq '$(OS)' 'FreeBSD'\n"
1022
+ uninstall_target << "\trmdir --ignore-fail-on-non-empty $(PREFIX)\n"
1023
+ uninstall_target << "endif\n"
1024
+ end
1025
+ @build_libraries.each do |lib|
1026
+ uninstall_target << "\trm -f $(LIBRARY_PREFIX)#{lib[0]}#{@library_extension}\n"
1027
+ end
1028
+ if(@build_libraries != {})
1029
+ uninstall_target << "ifneq '$(OS)' 'FreeBSD'\n"
1030
+ uninstall_target << "\trmdir --ignore-fail-on-non-empty $(LIBRARY_PREFIX)\n"
1031
+ uninstall_target << "endif\n"
1032
+ end
1033
+ uninstall_target << "\t@echo \"#{@emoji_uninstall} #{@emoji_success} |gUninstall Finished|n\"\n"
1034
+ end
1035
+
1036
+ uninstall_target = <<-END_OF_STRING
1037
+ .PHONY : uninstall
1038
+ uninstall :
1039
+ \t@echo "#{@emoji_uninstall} Starting uninstall..."
1040
+ END_OF_STRING
1041
+ begin
1042
+ code = File.open('demake/uninstall-target.rb').read
1043
+ if(@emojis == false)
1044
+ strip_emojis!(code)
1045
+ end
1046
+ eval code
1047
+ rescue Errno::ENOENT
1048
+ default_uninstall_target(uninstall_target)
1049
+ rescue
1050
+ notify("\n|YWARNING|n: #{$!}\n\n")
1051
+ end
1052
+ if(@emojis == false)
1053
+ strip_emojis!(uninstall_target)
1054
+ end
1055
+ @output << "\n" + @pipe.pipetext(uninstall_target)
1056
+
1057
+ if(@example || @oreo)
1058
+ File.open('Makefile', 'w').write(@output)
1059
+ if(@example)
1060
+ notify("#{@emoji_success} Created file: |gexample|n/|yMakefile|n |[page facing up]\n\n" +
1061
+ "Suggestion: |Ccd example ; make ; make build ; make test|n\n")
1062
+ elsif(@oreo)
1063
+ notify("#{@emoji_success} Created file: |goreo|n/|yMakefile|n |[page facing up]\n\n" +
1064
+ "Suggestion: |Ccd oreo ; make ; make build ; make test|n\n")
1065
+ end
1066
+ Dir.chdir('..')
1067
+ else
1068
+ puts @output
1069
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: demake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minaswan Nakamoto
@@ -30,15 +30,27 @@ dependencies:
30
30
  - !ruby/object:Gem::Version
31
31
  version: 0.1.3
32
32
  description: |
33
- == Develop, Decorate and manage Dependencies for C Makefiles easily with a Ruby script.
33
+ == Develop, Decorate and manage Dependencies for C (GNU) Makefiles easily with a Ruby script.
34
34
 
35
35
  Install using the Ruby Gem:
36
36
 
37
37
  > gem install demake
38
38
 
39
+ To create an example with multiple sample applications:
40
+
41
+ > demake example
42
+
43
+ This will create a directory named example containing the example.
44
+
45
+ To create an example with a single sample application:
46
+
47
+ > demake oreo
48
+
49
+ This will create a directory named oreo containing the example.
50
+
39
51
  It requires a demake directory and application file containing the application
40
52
  names followed by depencencies separated by spaces and with a new line to indicate
41
- a different application. Something like:
53
+ a different application. Something like (from the example):
42
54
 
43
55
  > mkdir demake
44
56
  > echo "hello string" > demake/applications
@@ -48,21 +60,17 @@ description: |
48
60
  For customization, optionally include (see example):
49
61
  demake/settings.rb, demake/test-target.rb, demake/install-target.rb
50
62
 
51
- The gem uses a command line interface:
63
+ The output of the command by itself is a (GNU style) Makefile:
52
64
 
53
65
  > demake > Makefile
54
66
 
55
67
  You can also clone from git for a more complete example:
56
68
 
57
69
  > git clone https://github.com/MinaswanNakamoto/demake.git
58
- > cd demake/bin
59
- > chmod +x demake
60
- > cd ../example
61
- > ../bin/demake > Makefile
62
- > make
63
- > make build
64
- > bin/hello
65
- > bin/goodbye
70
+ > chmod +x demake/bin/demake
71
+ > cd demake
72
+ > bin/demake example
73
+ > cd example ; make ; make build ; make test
66
74
 
67
75
  If you have an existing C application and you want to generate a Makefile for it,
68
76
  you might try the gen_application shell script.
@@ -95,6 +103,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
103
  requirements: []
96
104
  rubygems_version: 3.6.9
97
105
  specification_version: 4
98
- summary: Develop, Decorate and manage Dependencies for C Makefiles easily with a Ruby
99
- script.
106
+ summary: Develop, Decorate and manage Dependencies for C (GNU) Makefiles easily with
107
+ a Ruby script.
100
108
  test_files: []