1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _MK_DEFS_H 27 #define _MK_DEFS_H 28 29 /* 30 * Included files 31 */ 32 33 #include <mksh/defs.h> 34 35 /* 36 * Defined macros 37 */ 38 39 #define SKIPSPACE(x) while (*x && \ 40 ((*x == (int)space_char) || \ 41 (*x == (int)tab_char) || \ 42 (*x == (int)comma_char))) { \ 43 x++; \ 44 } 45 46 #define SKIPWORD(x) while (*x && \ 47 (*x != (int)space_char) && \ 48 (*x != (int)tab_char) && \ 49 (*x != (int)newline_char) && \ 50 (*x != (int)comma_char) && \ 51 (*x != (int)equal_char)) { \ 52 x++; \ 53 } 54 55 #define SKIPTOEND(x) while (*x && \ 56 (*x != (int)newline_char)) { \ 57 x++; \ 58 } 59 60 #define PMAKE_DEF_MAX_JOBS 2 /* Default number of parallel jobs. */ 61 62 #define OUT_OF_DATE(a, b) \ 63 (((a) < (b)) || (((a) == file_doesnt_exist) && \ 64 ((b) == file_doesnt_exist))) 65 66 #define OUT_OF_DATE_SEC(a, b) \ 67 (((a).tv_sec < (b).tv_sec) || \ 68 (((a).tv_sec == file_doesnt_exist.tv_sec) && \ 69 ((b).tv_sec == file_doesnt_exist.tv_sec))) 70 71 #define SETVAR(name, value, append) \ 72 setvar_daemon(name, value, append, no_daemon, \ 73 true, debug_level) 74 #define MAX(a, b) (((a) > (b))?(a):(b)) 75 /* 76 * New feature added to SUN5_0 make, invoke the vanilla svr4 make when 77 * the USE_SVR4_MAKE environment variable is set. 78 */ 79 #define SVR4_MAKE "/usr/ccs/lib/svr4.make" 80 #define USE_SVR4_MAKE "USE_SVR4_MAKE" 81 /* 82 * The standard MAXHOSTNAMELEN is 64. We want 32. 83 */ 84 #define MAX_HOSTNAMELEN 32 85 86 87 /* 88 * typedefs & structs 89 */ 90 typedef enum { 91 no_state, 92 scan_name_state, 93 scan_command_state, 94 enter_dependencies_state, 95 enter_conditional_state, 96 enter_equal_state, 97 illegal_bytes_state, 98 illegal_eoln_state, 99 poorly_formed_macro_state, 100 exit_state 101 } Reader_state; 102 103 struct _Name_vector { 104 struct _Name *names[64]; 105 struct _Chain *target_group[64]; 106 short used; 107 struct _Name_vector *next; 108 }; 109 110 struct _Running { 111 struct _Running *next; 112 Doname state; 113 struct _Name *target; 114 struct _Name *true_target; 115 struct _Property *command; 116 struct _Name *sprodep_value; 117 char *sprodep_env; 118 int recursion_level; 119 Boolean do_get; 120 Boolean implicit; 121 Boolean redo; 122 int auto_count; 123 struct _Name **automatics; 124 pid_t pid; 125 int job_msg_id; 126 char *stdout_file; 127 char *stderr_file; 128 struct _Name *temp_file; 129 int conditional_cnt; 130 struct _Name **conditional_targets; 131 Boolean make_refd; 132 }; 133 134 typedef enum { 135 serial_mode, 136 parallel_mode 137 } DMake_mode; 138 139 typedef enum { 140 txt1_mode, 141 txt2_mode, 142 html1_mode 143 } DMake_output_mode; 144 145 struct _Recursive_make { 146 struct _Recursive_make *next; /* Linked list */ 147 wchar_t *target; /* Name of target */ 148 wchar_t *oldline; /* Original line in .nse_depinfo */ 149 wchar_t *newline; /* New line in .nse_depinfo */ 150 /* 151 * string built from value of 152 * conditional macros used by 153 * this target 154 */ 155 wchar_t *cond_macrostring; 156 /* This target is no longer recursive */ 157 Boolean removed; 158 }; 159 160 struct _Dyntarget { 161 struct _Dyntarget *next; 162 struct _Name *name; 163 }; 164 165 166 /* 167 * Typedefs for all structs 168 */ 169 typedef struct _Cmd_line *Cmd_line, Cmd_line_rec; 170 typedef struct _Dependency *Dependency, Dependency_rec; 171 typedef struct _Macro *Macro, Macro_rec; 172 typedef struct _Name_vector *Name_vector, Name_vector_rec; 173 typedef struct _Percent *Percent, Percent_rec; 174 typedef struct _Dyntarget *Dyntarget; 175 typedef struct _Recursive_make *Recursive_make, Recursive_make_rec; 176 typedef struct _Running *Running, Running_rec; 177 178 179 /* 180 * extern declarations for all global variables. 181 * The actual declarations are in globals.cc 182 */ 183 extern Boolean allrules_read; 184 extern Name posix_name; 185 extern Name svr4_name; 186 extern Boolean sdot_target; 187 extern Boolean all_parallel; 188 extern Boolean assign_done; 189 extern Boolean build_failed_seen; 190 extern Name built_last_make_run; 191 extern Name c_at; 192 extern Boolean command_changed; 193 extern Boolean commands_done; 194 extern Chain conditional_targets; 195 extern Name conditionals; 196 extern Boolean continue_after_error; 197 extern Property current_line; 198 extern Name current_make_version; 199 extern Name current_target; 200 extern short debug_level; 201 extern Cmd_line default_rule; 202 extern Name default_rule_name; 203 extern Name default_target_to_build; 204 extern Boolean depinfo_already_read; 205 extern Name dmake_group; 206 extern Name dmake_max_jobs; 207 extern Name dmake_mode; 208 extern DMake_mode dmake_mode_type; 209 extern Name dmake_output_mode; 210 extern DMake_output_mode output_mode; 211 extern Name dmake_odir; 212 extern Name dmake_rcfile; 213 extern Name done; 214 extern Name dot; 215 extern Name dot_keep_state; 216 extern Name dot_keep_state_file; 217 extern Name empty_name; 218 extern Boolean fatal_in_progress; 219 extern int file_number; 220 extern Name force; 221 extern Name ignore_name; 222 extern Boolean ignore_errors; 223 extern Boolean ignore_errors_all; 224 extern Name init; 225 extern int job_msg_id; 226 extern Boolean keep_state; 227 extern Name make_state; 228 extern timestruc_t make_state_before; 229 extern Boolean make_state_locked; 230 extern Dependency makefiles_used; 231 extern Name makeflags; 232 extern Name make_version; 233 extern char mbs_buffer2[]; 234 extern char *mbs_ptr; 235 extern char *mbs_ptr2; 236 extern Boolean no_action_was_taken; 237 extern Boolean no_parallel; 238 extern Name no_parallel_name; 239 extern Name not_auto; 240 extern Boolean only_parallel; 241 extern Boolean parallel; 242 extern Name parallel_name; 243 extern Name localhost_name; 244 extern int parallel_process_cnt; 245 extern Percent percent_list; 246 extern Dyntarget dyntarget_list; 247 extern Name plus; 248 extern Name pmake_machinesfile; 249 extern Name precious; 250 extern Name primary_makefile; 251 extern Boolean quest; 252 extern short read_trace_level; 253 extern Boolean reading_dependencies; 254 extern int recursion_level; 255 extern Name recursive_name; 256 extern short report_dependencies_level; 257 extern Boolean report_pwd; 258 extern Boolean rewrite_statefile; 259 extern Running running_list; 260 extern char *sccs_dir_path; 261 extern Name sccs_get_name; 262 extern Name sccs_get_posix_name; 263 extern Cmd_line sccs_get_rule; 264 extern Cmd_line sccs_get_org_rule; 265 extern Cmd_line sccs_get_posix_rule; 266 extern Name get_name; 267 extern Name get_posix_name; 268 extern Cmd_line get_rule; 269 extern Cmd_line get_posix_rule; 270 extern Boolean all_precious; 271 extern Boolean report_cwd; 272 extern Boolean silent_all; 273 extern Boolean silent; 274 extern Name silent_name; 275 extern char *stderr_file; 276 extern char *stdout_file; 277 extern Boolean stdout_stderr_same; 278 extern Dependency suffixes; 279 extern Name suffixes_name; 280 extern Name sunpro_dependencies; 281 extern Boolean target_variants; 282 extern const char *tmpdir; 283 extern const char *temp_file_directory; 284 extern Name temp_file_name; 285 extern short temp_file_number; 286 extern wchar_t *top_level_target; 287 extern Boolean touch; 288 extern Boolean trace_reader; 289 extern Boolean build_unconditional; 290 extern pathpt vroot_path; 291 extern Name wait_name; 292 extern wchar_t wcs_buffer2[]; 293 extern wchar_t *wcs_ptr; 294 extern wchar_t *wcs_ptr2; 295 extern long int hostid; 296 297 /* 298 * Declarations of system defined variables 299 */ 300 /* On linux this variable is defined in 'signal.h' */ 301 extern char *sys_siglist[]; 302 303 /* 304 * Declarations of system supplied functions 305 */ 306 extern int file_lock(char *, char *, int *, int); 307 308 /* 309 * Declarations of functions declared and used by make 310 */ 311 extern void add_pending(Name target, int recursion_level, 312 Boolean do_get, Boolean implicit, Boolean redo); 313 extern void add_running(Name target, Name true_target, 314 Property command, int recursion_level, int auto_count, 315 Name *automatics, Boolean do_get, Boolean implicit); 316 extern void add_serial(Name target, int recursion_level, 317 Boolean do_get, Boolean implicit); 318 extern void add_subtree(Name target, int recursion_level, 319 Boolean do_get, Boolean implicit); 320 extern void append_or_replace_macro_in_dyn_array( 321 ASCII_Dyn_Array *Ar, char *macro); 322 extern void await_parallel(Boolean waitflg); 323 extern void build_suffix_list(Name target_suffix); 324 extern Boolean check_auto_dependencies(Name target, int auto_count, 325 Name *automatics); 326 extern void check_state(Name temp_file_name); 327 extern void cond_macros_into_string(Name np, String_rec *buffer); 328 extern void construct_target_string(); 329 extern void create_xdrs_ptr(void); 330 extern void depvar_add_to_list(Name name, Boolean cmdline); 331 extern Doname doname(Name target, Boolean do_get, Boolean implicit, 332 Boolean automatic = false); 333 extern Doname doname_check(Name target, Boolean do_get, 334 Boolean implicit, Boolean automatic); 335 extern Doname doname_parallel(Name target, Boolean do_get, 336 Boolean implicit); 337 extern Doname dosys(Name command, Boolean ignore_error, 338 Boolean call_make, Boolean silent_error, Boolean always_exec, 339 Name target); 340 extern void dump_make_state(void); 341 extern void dump_target_list(void); 342 extern void enter_conditional(Name target, Name name, Name value, 343 Boolean append); 344 extern void enter_dependencies(Name target, Chain target_group, 345 Name_vector depes, Cmd_line command, Separator separator); 346 extern void enter_dependency(Property line, Name depe, 347 Boolean automatic); 348 extern void enter_equal(Name name, Name value, Boolean append); 349 extern Percent enter_percent(Name target, Chain target_group, 350 Name_vector depes, Cmd_line command); 351 extern Dyntarget enter_dyntarget(Name target); 352 extern Name_vector enter_name(String string, Boolean tail_present, 353 wchar_t *string_start, wchar_t *string_end, Name_vector current_names, 354 Name_vector *extra_names, Boolean *target_group_seen); 355 extern Boolean exec_vp(char *name, char **argv, char **envp, 356 Boolean ignore_error); 357 extern Doname execute_parallel(Property line, Boolean waitflg, 358 Boolean local = false); 359 extern Doname execute_serial(Property line); 360 extern timestruc_t& exists(Name target); 361 extern void fatal(const char *, ...) __NORETURN; 362 extern void fatal_reader(char *, ...); 363 extern Doname find_ar_suffix_rule(Name target, Name true_target, 364 Property *command, Boolean rechecking); 365 extern Doname find_double_suffix_rule(Name target, Property *command, 366 Boolean rechecking); 367 extern Doname find_percent_rule(Name target, Property *command, 368 Boolean rechecking); 369 extern int find_run_directory(char *cmd, char *cwd, char *dir, 370 char **pgm, char **run, char *path); 371 extern Doname find_suffix_rule(Name target, Name target_body, 372 Name target_suffix, Property *command, Boolean rechecking); 373 extern Chain find_target_groups(Name_vector target_list, int i, 374 Boolean reset); 375 extern void finish_children(Boolean docheck); 376 extern void finish_running(void); 377 extern void free_chain(Name_vector ptr); 378 extern void gather_recursive_deps(void); 379 extern char *get_current_path(void); 380 extern int get_job_msg_id(void); 381 extern wchar_t *getmem_wc(int size); 382 extern void handle_interrupt(int); 383 extern Boolean is_running(Name target); 384 extern void load_cached_names(void); 385 extern Boolean parallel_ok(Name target, Boolean line_prop_must_exists); 386 extern void print_dependencies(Name target, Property line); 387 extern void send_job_start_msg(Property line); 388 extern void send_rsrc_info_msg(int max_jobs, char *hostname, 389 char *username); 390 extern void print_value(Name value, Daemon daemon); 391 extern timestruc_t& read_archive(Name target); 392 extern int read_dir(Name dir, wchar_t *pattern, Property line, 393 wchar_t *library); 394 extern void read_directory_of_file(Name file); 395 extern int read_make_machines(Name make_machines_name); 396 extern Boolean read_simple_file(Name makefile_name, Boolean chase_path, 397 Boolean doname_it, Boolean complain, Boolean must_exist, 398 Boolean report_file, Boolean lock_makefile); 399 extern void remove_recursive_dep(Name target); 400 extern void report_recursive_dep(Name target, char *line); 401 extern void report_recursive_done(void); 402 extern void report_recursive_init(void); 403 extern Recursive_make find_recursive_target(Name target); 404 extern void reset_locals(Name target, Property old_locals, 405 Property conditional, int index); 406 extern void set_locals(Name target, Property old_locals); 407 extern void setvar_append(Name name, Name value); 408 extern void setvar_envvar(void); 409 extern void special_reader(Name target, Name_vector depes, 410 Cmd_line command); 411 extern void startup_rxm(); 412 extern Doname target_can_be_built(Name target); 413 extern char *time_to_string(const timestruc_t &time); 414 extern void update_target(Property line, Doname result); 415 extern void warning(char *, ...); 416 extern void write_state_file(int report_recursive, Boolean exiting); 417 extern Name vpath_translation(Name cmd); 418 extern char *make_install_prefix(void); 419 420 #define DEPINFO_FMT_VERSION "VERS2$" 421 #define VER_LEN strlen(DEPINFO_FMT_VERSION) 422 423 424 #endif /* _MK_DEFS_H */ 425