build: compile_flags lib executable
+install: install-bin install-lib
+
+install-bin: compile_flags executable
+ mv cgo /usr/local/bin
+
+install-lib: compile_flags lib
+ mv libcgo.a /usr/local/lib
+ mkdir -p /usr/local/include/cgo
+ cp include/* /usr/local/include/cgo
+
#compile_flags_gtk:
# echo "-Iinclude `pkg-config --cflags gtk4` -lm -fopenmp `pkg-config --libs gtk4`" | perl -pe 's|(-.*?)\s|\1\n|g' > compile_flags.txt
# echo "-o cgo" >> compile_flags.txt
--- /dev/null
+cgo: collection of generic optimizers
+
+!!! HOW TO INSTALL !!!
+
+Running `sudo make install` (or your flavour of privilege elevation) at project root
+places library/header/executable files in /usr/local. The program may then be
+launched using `cgo` in any shell, or its functions may be included in your project by
+linking against `cgo` (-lcgo for gcc) and including its headers (e.g. <cgo/de.h>).
+
+`sudo make install-lib` only does the library/header portion of this and skips the binary.
+`sudo make install-bin` only installs the binary.
--- /dev/null
+#include <argp.h>
+
+enum algorithm {
+ de,
+ pso
+};
+struct arguments {
+ enum algorithm algorithm;
+ char *outfile;
+};
+static struct argp argp;
+++ /dev/null
-#include "de.h"
-#include "pso.h"
-#include "vector.h"
--- /dev/null
+#include <string.h>
+#include "argph.h"
+
+static char doc[] = "cgo: collection of generic optimizers";
+static char args_doc[] = "FILE";
+static struct argp_option options[] = {
+ {"algorithm", 'a', "{de,pso}", 0, "optimization algorithm (default: de)"}
+};
+static error_t parse_opt(int key, char *arg, struct argp_state *state) {
+ struct arguments *args = state->input;
+ switch (key) {
+ case 'a':
+ if (strcmp(arg, "de") == 0) args->algorithm = de;
+ else if (strcmp(arg, "pso") == 0) args->algorithm = pso;
+ else argp_usage(state);
+ break;
+ case ARGP_KEY_ARG:
+ if (state->arg_num > 0) argp_usage(state);
+ args->outfile = arg;
+ break;
+ case ARGP_KEY_END:
+ // if (state->arg_num < 2) argp_usage(state);
+ break;
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+static struct argp argp = { options, parse_opt, args_doc, doc };
-#include <argp.h>
-#include <string.h>
#include <math.h>
-#include "cgo.h"
-
-enum algorithm {
- de,
- pso
-};
-
-static char doc[] = "cgo: collection of generic optimizers";
-static char args_doc[] = "FILE";
-static struct argp_option options[] = {
- {"algorithm", 'a', "{de,pso}", 0, "optimization algorithm (default: de)"}
-};
-struct arguments {
- enum algorithm algorithm;
- char *outfile;
-};
-
-static error_t parse_opt(int key, char *arg, struct argp_state *state) {
- struct arguments *args = state->input;
- switch (key) {
- case 'a':
- if (strcmp(arg, "de") == 0) args->algorithm = de;
- else if (strcmp(arg, "pso") == 0) args->algorithm = pso;
- else argp_usage(state);
- break;
- case ARGP_KEY_ARG:
- if (state->arg_num > 0) argp_usage(state);
- args->outfile = arg;
- break;
- case ARGP_KEY_END:
- // if (state->arg_num < 2) argp_usage(state);
- break;
- default:
- return ARGP_ERR_UNKNOWN;
- }
- return 0;
-}
-
-static struct argp argp = { options, parse_opt, args_doc, doc };
+#include "argph.h"
+#include "vector.h"
+#include "de.h"
double b0(double *x) {
return -x[0];