| 1 |
#!/usr/bin/icmake -t. |
| 2 |
|
| 3 |
#include "VERSION" |
| 4 |
#include "INSTALL.im" |
| 5 |
|
| 6 |
// Use the next one to see what parser/p_parse() does |
| 7 |
//#define COPT "-O2 -Wall -DEBUG" |
| 8 |
#define COPT "-O2 -Wall -fdiagnostics-color=never " |
| 9 |
// -Werror" |
| 10 |
|
| 11 |
#define STD_CONVERSIONS "html latex man txt xml" |
| 12 |
#define ECHO_REQUEST 1 |
| 13 |
|
| 14 |
// uncomment to show the full gcc commands when compiling |
| 15 |
// #define ECHO_COMPILE |
| 16 |
|
| 17 |
string CLASSES; |
| 18 |
string g_lopt; |
| 19 |
string g_copt; |
| 20 |
string g_cwd; |
| 21 |
string g_wip = "tmp/wip"; // no slash here |
| 22 |
string g_install = "tmp/install"; // no slash here |
| 23 |
|
| 24 |
int g_compiled; |
| 25 |
int g_nClasses; |
| 26 |
list g_classes; |
| 27 |
|
| 28 |
#include "icmake/run" |
| 29 |
#include "icmake/md" |
| 30 |
#include "icmake/clean" |
| 31 |
#include "icmake/stdcpp" |
| 32 |
#include "icmake/stdcompile" |
| 33 |
#include "icmake/compilerss" |
| 34 |
#include "icmake/builtins" |
| 35 |
#include "icmake/program" |
| 36 |
#include "icmake/buildmacros" |
| 37 |
#include "icmake/manualmacrolist" |
| 38 |
#include "icmake/macros" |
| 39 |
#include "icmake/man" |
| 40 |
#include "icmake/manual" |
| 41 |
#include "icmake/install" |
| 42 |
#include "icmake/gitlab" |
| 43 |
|
| 44 |
string setOpt(string install_im, string envvar) |
| 45 |
{ |
| 46 |
list optvar; |
| 47 |
string ret; |
| 48 |
|
| 49 |
optvar = getenv(envvar); |
| 50 |
|
| 51 |
if (optvar[0] == "1") |
| 52 |
ret = optvar[1]; |
| 53 |
else |
| 54 |
ret = install_im; |
| 55 |
|
| 56 |
return ret; |
| 57 |
} |
| 58 |
|
| 59 |
void main(int argc, list argv) |
| 60 |
{ |
| 61 |
string arg1; |
| 62 |
|
| 63 |
echo(ECHO_REQUEST); |
| 64 |
g_cwd = chdir("."); |
| 65 |
|
| 66 |
g_copt = setOpt(COPT + " -g", "CFLAGS"); |
| 67 |
|
| 68 |
#ifdef PROFILING |
| 69 |
g_copt = COPT + " -pg"; |
| 70 |
g_lopt = "-pg"; |
| 71 |
#endif |
| 72 |
|
| 73 |
g_lopt = setOpt(g_lopt, "LDFLAGS"); |
| 74 |
|
| 75 |
#ifdef EXTENSIVE_OPTIONS |
| 76 |
g_copt = "-O0 -g3 -ansi -pedantic -fno-common -pipe -W -Wall -Wcast-align" |
| 77 |
" -Wcast-qual -Wconversion -Wformat=2 -Winline -Wnested-externs" |
| 78 |
" -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef " |
| 79 |
"-Wno-unused-parameter -Waggregate-return -Wnested-externs"; |
| 80 |
#endif |
| 81 |
|
| 82 |
setLocations(); |
| 83 |
|
| 84 |
if ( |
| 85 |
STD_INCLUDE[0] != "/" || BIN[0] != "/" || MAN[0] != "/" || |
| 86 |
DOC[0] != "/" || DOCDOC[0] != "/" ) |
| 87 |
{ |
| 88 |
printf("Check INSTALL.im: BIN, DOC, DOCDOC, MAN, STD_INCLUDE, " |
| 89 |
"must be absolute paths\n"); |
| 90 |
exit(1); |
| 91 |
} |
| 92 |
|
| 93 |
arg1 = argv[1]; |
| 94 |
|
| 95 |
if (arg1 == "clean" || arg1 == "distclean") |
| 96 |
cleanupExit(); |
| 97 |
|
| 98 |
md(g_install + " " + g_wip); |
| 99 |
|
| 100 |
// g_include = " -I.:" + g_install + STD_INCLUDE + ":" + g_wip; |
| 101 |
|
| 102 |
echo(OFF); |
| 103 |
run("rm -f " + g_wip + "/release.yo " + g_wip + "/config.h"); |
| 104 |
echo(ON); |
| 105 |
|
| 106 |
fprintf(g_wip + "/release.yo", "SUBST(_CurVers_)(", VERSION, ")\n", |
| 107 |
"SUBST(_CurYrs_)(", YEARS, ")\n", |
| 108 |
"manttquoted(1)\n"); |
| 109 |
|
| 110 |
fprintf(g_wip + "/config.h", |
| 111 |
"#define STD_INCLUDE \"", STD_INCLUDE, "\"\n" |
| 112 |
"#define VERSION \"" VERSION "\"\n" |
| 113 |
"#define YEARS \"" YEARS "\"\n" |
| 114 |
"#define YODL_BIN \"", BIN, "\"\n" |
| 115 |
); |
| 116 |
|
| 117 |
if (arg1 == "programs") |
| 118 |
programsExit(argv[2]); // icmake/program |
| 119 |
|
| 120 |
if |
| 121 |
( |
| 122 |
arg1 == "yodl" || arg1 == "yodlpost" || arg1 == "yodlverbinsert" || |
| 123 |
arg1 == "yodlstriproff" || arg1 == "yodl2whatever" || arg1 == "programs" |
| 124 |
) |
| 125 |
programExit(arg1, argv[2]); |
| 126 |
|
| 127 |
// requires 'build programs' |
| 128 |
if (arg1 == "macros") // run before 'build man', etc. |
| 129 |
macrosExit(); |
| 130 |
|
| 131 |
if (arg1 == "man") |
| 132 |
manExit(argv[2]); |
| 133 |
|
| 134 |
if (arg1 == "manual") |
| 135 |
manualExit("", argv[2]); |
| 136 |
|
| 137 |
if (arg1 == "html") |
| 138 |
manualExit("html", argv[2]); |
| 139 |
|
| 140 |
if (arg1 == "latex") |
| 141 |
manualExit("latex", argv[2]); |
| 142 |
|
| 143 |
// Debian package construction |
| 144 |
// .gz compresses the man-pages |
| 145 |
// defines .gz links to |
| 146 |
// man1/yodlconverters.1.gz |
| 147 |
if (arg1 == "install") |
| 148 |
installExit(argv[2], argv[3]); // icmake/install |
| 149 |
|
| 150 |
if (arg1 == "gitlab") |
| 151 |
gitlab(); |
| 152 |
|
| 153 |
printf("Usage: build action\n" |
| 154 |
"Where `action' is one of:\n" |
| 155 |
" (dist)clean: clean up\n" |
| 156 |
" programs [strip]: build the programs\n" |
| 157 |
" yodl [strip]: only build `yodl'\n" |
| 158 |
" yodlpost [strip]: only build `yodlpost'\n" |
| 159 |
" yodlverbinsert [strip]: only build `yodlverbinsert'\n" |
| 160 |
" yodlstriproff: only build `yodlstriproff\n" |
| 161 |
" yodl2whatever: only build `yodl2whatever\n" |
| 162 |
" macros: (re)build the standard yodl macros\n" |
| 163 |
" run `build programs' first, run `build macros'\n" |
| 164 |
" before any of the following document-creating " |
| 165 |
" commands\n" |
| 166 |
" man [path]: (re)build the man-pages, optionally specify: " |
| 167 |
"path\n" |
| 168 |
" manual [path]: (re)build the manual, optionally specify: path\n" |
| 169 |
" html [path]: (re)build the html version of the manual\n" |
| 170 |
" (after 'manual' or 'macros')\n" |
| 171 |
" latex [path]: (re)build the latex version of the manual\n" |
| 172 |
" (after 'manual' or 'macros')\n" |
| 173 |
" install programs WHERE: install the programs under WHERE\n" |
| 174 |
" install yodl WHERE: install yodl under WHERE\n" |
| 175 |
" install yodlpost WHERE: install yodlpost under WHERE\n" |
| 176 |
" install yodlverbinsert WHERE: install yodlverbinsert under WHERE\n" |
| 177 |
" install yodlstriproff WHERE: install yodlstriproff under WHERE\n" |
| 178 |
" install yodl2whatever WHERE: install yodl2whatever c.s. under " |
| 179 |
"WHERE\n" |
| 180 |
" install macros WHERE: install the macros under WHERE\n" |
| 181 |
" install man WHERE: install the man-pages under WHERE\n" |
| 182 |
" install mandeb WHERE: install the man-pages for Debian\n" |
| 183 |
" under WHERE\n" |
| 184 |
" install manual WHERE: install the manual under WHERE\n" |
| 185 |
" install docs WHERE: install additional docs under " |
| 186 |
"WHERE\n" |
| 187 |
" gitlab - prepare gitlab's web-pages update\n" |
| 188 |
" (internal use only)\n" |
| 189 |
"`strip': the program(s) will be stripped,\n" |
| 190 |
"`path': yodl is located in $PATH (otherwise just-built programs " |
| 191 |
"are used).\n" |
| 192 |
); |
| 193 |
exit(0); |
| 194 |
} |