From a622d5163b9852c66d8399e05e5731d3a538d43b Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Fri, 16 Aug 2013 03:28:02 +0000 Subject: [PATCH] Rework some build stuff for better output and to enable strict prototypes --- BSDmakefile | 18 +++++++++++------- Makefile | 31 ++++++++++++++++--------------- code.c | 4 +++- exec.c | 6 +++--- fold.c | 6 +++--- ftepp.c | 1 + pak.c | 4 +++- parser.c | 5 ++--- stat.c | 2 +- 9 files changed, 43 insertions(+), 34 deletions(-) diff --git a/BSDmakefile b/BSDmakefile index c33c796..b537444 100644 --- a/BSDmakefile +++ b/BSDmakefile @@ -10,7 +10,7 @@ GITINFO := GITINFO != git describe --always .endif -CFLAGS += -Wall -Wextra -Werror -fno-strict-aliasing -DGMQCC_GITINFO=\"$(GITINFO)\"$(OPTIONAL) +CFLAGS += -Wall -Wextra -Werror -Wstrict-aliasing .if $(CC) == clang CFLAGS += -Weverything\ @@ -18,19 +18,23 @@ CFLAGS += -Wall -Wextra -Werror -fno-strict-aliasing -DGMQCC_GITINFO=\"$(GITI -Wno-format-nonliteral\ -Wno-disabled-macro-expansion\ -Wno-conversion\ - -Wno-missing-prototypes\ -Wno-float-equal\ -Wno-unknown-warning-option\ -Wno-cast-align\ - -Wstrict-prototypes + -pedantic-errors .else -. if $(CC) == tcc - CFLAGS += -Wstrict-prototypes -pedantic-errors +. if $(CC) != g++ + CFLAGS += -Wmissing-prototypes -Wstrict-prototypes +. endif + +. if $(CC) != tcc + CFLAGS += -pedantic-errors . else CFLAGS += -Wno-pointer-sign -fno-common . endif .endif +CFLAGS += -DGMQCC_GITINFO=\"$(GITINFO)\" $(OPTIONAL) DEPS != for i in $(OBJ_C) $(OBJ_P) $(OBJ_T) $(OBJ_X); do echo $$i; done | sort | uniq QCVM = qcvm @@ -40,10 +44,10 @@ PAK = gmqpak #standard rules c.o: ${.IMPSRC} - $(CC) -c ${.IMPSRC} -o ${.TARGET} $(CPPFLAGS) $(CFLAGS) + $(CC) -c ${.IMPSRC} -o ${.TARGET} $(CFLAGS) $(CPPFLAGS) exec-standalone.o: exec.c - $(CC) -c ${.ALLSRC} -o ${.TARGET} $(CPPFLAGS) $(CFLAGS) -DQCVM_EXECUTOR=1 + $(CC) -c ${.ALLSRC} -o ${.TARGET} $(CFLAGS) $(CPPFLAGS) -DQCVM_EXECUTOR=1 $(QCVM): $(OBJ_X) $(CC) -o ${.TARGET} ${.IMPSRC} $(LDFLAGS) $(LIBS) $(OBJ_X) diff --git a/Makefile b/Makefile index 82cef3a..6ba6a34 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,7 @@ UNAME ?= $(shell uname) CYGWIN = $(findstring CYGWIN, $(UNAME)) MINGW = $(findstring MINGW32, $(UNAME)) -CFLAGS += -O3 -Wall -Wextra -Wstrict-aliasing -Werror $(OPTIONAL) -ifneq ($(shell git describe --always 2>/dev/null),) - CFLAGS += -DGMQCC_GITINFO="\"$(shell git describe --always)\"" -endif +CFLAGS += -Wall -Wextra -Werror -Wstrict-aliasing #turn on tons of warnings if clang is present # but also turn off the STUPID ONES ifeq ($(CC), clang) @@ -17,26 +14,30 @@ ifeq ($(CC), clang) -Wno-format-nonliteral \ -Wno-disabled-macro-expansion \ -Wno-conversion \ - -Wno-missing-prototypes \ -Wno-float-equal \ -Wno-unknown-warning-option \ -Wno-cast-align \ - -Wstrict-prototypes + -pedantic-errors else - #Tiny C Compiler doesn't know what -pedantic-errors is - # and instead of ignoring .. just errors. + ifneq ($(CC), g++) + CFLAGS += -Wmissing-prototypes -Wstrict-prototypes + endif + ifneq ($(CC), tcc) CFLAGS += -pedantic-errors else CFLAGS += -Wno-pointer-sign -fno-common endif - - #-Wstrict-prototypes is not valid in g++ - ifneq ($(CC), g++) - CFLAGS += -Wstrict-prototypes - endif endif +ifneq ($(shell git describe --always 2>/dev/null),) + CFLAGS += -DGMQCC_GITINFO="\"$(shell git describe --always)\"" +endif + +# do this last otherwise there is whitespace in the command output and +# it makes my OCD act up +CFLAGS += $(OPTIONAL) + #we have duplicate object files when dealing with creating a simple list #for dependinces. To combat this we use some clever recrusive-make to #filter the list and remove duplicates which we use for make depend @@ -76,10 +77,10 @@ endif #standard rules %.o: %.c - $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) + $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) exec-standalone.o: exec.c - $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) -DQCVM_EXECUTOR=1 + $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) -DQCVM_EXECUTOR=1 $(QCVM): $(OBJ_X) $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) diff --git a/code.c b/code.c index 5c62efb..d114a23 100644 --- a/code.c +++ b/code.c @@ -256,7 +256,8 @@ static void code_stats(const char *filename, const char *lnofile, code_t *code, * directly out to allocated memory. Which is actually very useful for the future library support * we're going to add. */ -bool code_write_memory(code_t *code, uint8_t **datmem, size_t *sizedat, uint8_t **lnomem, size_t *sizelno) { +#if 0 +static bool code_write_memory(code_t *code, uint8_t **datmem, size_t *sizedat, uint8_t **lnomem, size_t *sizelno) GMQCC_UNUSED { prog_header_t code_header; uint32_t offset = 0; @@ -319,6 +320,7 @@ bool code_write_memory(code_t *code, uint8_t **datmem, size_t *sizedat, uint8_t code_stats("<>", (lnomem) ? "<>" : NULL, code, &code_header); return true; } +#endif /*!#if 0 reenable when ready to be used */ #undef WRITE_CHUNK bool code_write(code_t *code, const char *filename, const char *lnofile) { diff --git a/exec.c b/exec.c index da79a05..de917db 100644 --- a/exec.c +++ b/exec.c @@ -206,7 +206,7 @@ qcany_t* prog_getedict(qc_program_t *prog, qcint_t e) { return (qcany_t*)(prog->entitydata + (prog->entityfields * e)); } -qcint_t prog_spawn_entity(qc_program_t *prog) { +static qcint_t prog_spawn_entity(qc_program_t *prog) { char *data; qcint_t e; for (e = 0; e < (qcint_t)vec_size(prog->entitypool); ++e) { @@ -223,7 +223,7 @@ qcint_t prog_spawn_entity(qc_program_t *prog) { return e; } -void prog_free_entity(qc_program_t *prog, qcint_t e) { +static void prog_free_entity(qc_program_t *prog, qcint_t e) { if (!e) { prog->vmerror++; fprintf(stderr, "Trying to free world entity\n"); @@ -903,7 +903,7 @@ static void prog_main_setparams(qc_program_t *prog) { } } -void escapestring(char* dest, const char* src) { +static void escapestring(char* dest, const char* src) { char c; while ((c = *(src++))) { switch(c) { diff --git a/fold.c b/fold.c index c51e7fc..500e9d6 100644 --- a/fold.c +++ b/fold.c @@ -483,7 +483,7 @@ static GMQCC_INLINE ast_expression *fold_op_rshift(fold_t *fold, ast_value *a, a return NULL; } -static GMQCC_INLINE ast_expression *fold_op_andor(fold_t *fold, ast_value *a, ast_value *b, float or) { +static GMQCC_INLINE ast_expression *fold_op_andor(fold_t *fold, ast_value *a, ast_value *b, float expr) { if (fold_can_2(a, b)) { if (OPTS_FLAG(PERL_LOGIC)) { if (fold_immediate_true(fold, a)) @@ -491,8 +491,8 @@ static GMQCC_INLINE ast_expression *fold_op_andor(fold_t *fold, ast_value *a, as } else { return fold_constgen_float ( fold, - ((or) ? (fold_immediate_true(fold, a) || fold_immediate_true(fold, b)) - : (fold_immediate_true(fold, a) && fold_immediate_true(fold, b))) + ((expr) ? (fold_immediate_true(fold, a) || fold_immediate_true(fold, b)) + : (fold_immediate_true(fold, a) && fold_immediate_true(fold, b))) ? 1 : 0 ); diff --git a/ftepp.c b/ftepp.c index 613b5c7..a28bbec 100644 --- a/ftepp.c +++ b/ftepp.c @@ -226,6 +226,7 @@ static GMQCC_INLINE int ftepp_predef_index(const char *name) { return -1; } +bool ftepp_predef_exists(const char *name); bool ftepp_predef_exists(const char *name) { return ftepp_predef_index(name) != -1; } diff --git a/pak.c b/pak.c index 4bf7e5f..f2f2252 100644 --- a/pak.c +++ b/pak.c @@ -396,7 +396,8 @@ err: * Like pak_insert_one, except this collects files in all directories * from a root directory, and inserts them all. */ -bool pak_insert_all(pak_file_t *pak, const char *dir) { +#if 0 +static bool pak_insert_all(pak_file_t *pak, const char *dir) { DIR *dp; struct dirent *dirp; @@ -416,6 +417,7 @@ bool pak_insert_all(pak_file_t *pak, const char *dir) { fs_dir_close(dp); return true; } +#endif /*!if 0 renable when ready to use */ static bool pak_close(pak_file_t *pak) { size_t itr; diff --git a/parser.c b/parser.c index 1c453f3..fbe7257 100644 --- a/parser.c +++ b/parser.c @@ -1448,8 +1448,7 @@ static ast_expression* parse_vararg(parser_t *parser) } /* not to be exposed */ -extern bool ftepp_predef_exists(const char *name); - +bool ftepp_predef_exists(const char *name); static bool parse_sya_operand(parser_t *parser, shunt *sy, bool with_labels) { if (OPTS_FLAG(TRANSLATABLE_STRINGS) && @@ -5430,7 +5429,7 @@ skipvar: parseerror(parser, "error parsing break definition"); break; } - (void)!!parsewarning(parser, WARN_BREAKDEF, "break definition ignored (suggest removing it)"); + (void)!parsewarning(parser, WARN_BREAKDEF, "break definition ignored (suggest removing it)"); } else { parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser)); break; diff --git a/stat.c b/stat.c index 170b9dd..efe234e 100644 --- a/stat.c +++ b/stat.c @@ -206,7 +206,6 @@ void *stat_mem_reallocate(void *ptr, size_t size, size_t line, const char *file) stat_mem_peak = stat_mem_high; free(oldinfo); - return newinfo + 1; } @@ -514,6 +513,7 @@ void *util_htget(hash_table_t *ht, const char *key) { return util_htgeth(ht, key, util_hthash(ht, key)); } +void *code_util_str_htgeth(hash_table_t *ht, const char *key, size_t bin); void *code_util_str_htgeth(hash_table_t *ht, const char *key, size_t bin) { hash_node_t *pair; size_t len, keylen; -- 2.39.2