]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Rework some build stuff for better output and to enable strict prototypes
authorDale Weiler <killfieldengine@gmail.com>
Fri, 16 Aug 2013 03:28:02 +0000 (03:28 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 16 Aug 2013 03:28:02 +0000 (03:28 +0000)
BSDmakefile
Makefile
code.c
exec.c
fold.c
ftepp.c
pak.c
parser.c
stat.c

index c33c796916d27dfa22bf9b0122cd40667eb4b1d2..b537444355078447c89bc397c8a73a12ea69caf4 100644 (file)
@@ -10,7 +10,7 @@ GITINFO  :=
     GITINFO != git describe --always
 .endif
 
     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\
 
 .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-format-nonliteral\
                 -Wno-disabled-macro-expansion\
                 -Wno-conversion\
-                -Wno-missing-prototypes\
                 -Wno-float-equal\
                 -Wno-unknown-warning-option\
                 -Wno-cast-align\
                 -Wno-float-equal\
                 -Wno-unknown-warning-option\
                 -Wno-cast-align\
-                -Wstrict-prototypes
+                -pedantic-errors
 .else
 .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
 
 .    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
 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} 
 
 #standard rules
 c.o: ${.IMPSRC} 
-       $(CC) -c ${.IMPSRC} -o ${.TARGET} $(CPPFLAGS) $(CFLAGS)
+       $(CC) -c ${.IMPSRC} -o ${.TARGET} $(CFLAGS) $(CPPFLAGS) 
 
 exec-standalone.o: exec.c
 
 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)
 
 $(QCVM): $(OBJ_X)
        $(CC) -o ${.TARGET} ${.IMPSRC} $(LDFLAGS) $(LIBS) $(OBJ_X)
index 82cef3a97e52483ae17a6ed345db1488096ddf87..6ba6a3474054a32c4e75b5ebbeb7b50d639ee790 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,10 +4,7 @@ UNAME  ?= $(shell uname)
 CYGWIN  = $(findstring CYGWIN,  $(UNAME))
 MINGW   = $(findstring MINGW32, $(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)
 #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-format-nonliteral             \
            -Wno-disabled-macro-expansion      \
            -Wno-conversion                    \
-           -Wno-missing-prototypes            \
            -Wno-float-equal                   \
            -Wno-unknown-warning-option        \
            -Wno-cast-align                    \
            -Wno-float-equal                   \
            -Wno-unknown-warning-option        \
            -Wno-cast-align                    \
-           -Wstrict-prototypes
+           -pedantic-errors
 else
 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
        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
 
 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
 #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
 
 #standard rules
 %.o: %.c
-       $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
+       $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) 
 
 exec-standalone.o: exec.c
 
 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)
 
 $(QCVM): $(OBJ_X)
        $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
diff --git a/code.c b/code.c
index 5c62efb82603357a51ee39826a3d68ab45aeb34b..d114a2356da39e92a19d250b68b41bbac43a5966 100644 (file)
--- 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.
  */
  * 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;
 
     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("<<memory>>", (lnomem) ? "<<memory>>" : NULL, code, &code_header);
     return true;
 }
     code_stats("<<memory>>", (lnomem) ? "<<memory>>" : 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) {
 #undef WRITE_CHUNK
 
 bool code_write(code_t *code, const char *filename, const char *lnofile) {
diff --git a/exec.c b/exec.c
index da79a05e941f3439392f57b2e4bc391d3412c85f..de917db4f896ae4b7202761895f229c92c00baf8 100644 (file)
--- 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));
 }
 
     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) {
     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;
 }
 
     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");
     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) {
   char c;
   while ((c = *(src++))) {
     switch(c) {
diff --git a/fold.c b/fold.c
index c51e7fcb546f57b3f56d361187affea50b87c3a1..500e9d65494e9edd972a459755ca2982e9c5ed67 100644 (file)
--- 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;
 }
 
     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))
     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, 
         } 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
             );
                             ? 1
                             : 0
             );
diff --git a/ftepp.c b/ftepp.c
index 613b5c7d422f39ce9dbe031628903e4a02933263..a28bbec862720fa75dacdbb0e0dd9c4a1212a3bb 100644 (file)
--- a/ftepp.c
+++ b/ftepp.c
@@ -226,6 +226,7 @@ static GMQCC_INLINE int ftepp_predef_index(const char *name) {
     return -1;
 }
 
     return -1;
 }
 
+bool ftepp_predef_exists(const char *name);
 bool ftepp_predef_exists(const char *name) {
     return ftepp_predef_index(name) != -1;
 }
 bool ftepp_predef_exists(const char *name) {
     return ftepp_predef_index(name) != -1;
 }
diff --git a/pak.c b/pak.c
index 4bf7e5f423f4f96666b72009ec5f1f7763b062d9..f2f2252d4fd615fdd440ff4358dbe7e1e6c0b546 100644 (file)
--- 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.
  */
  * 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;
 
     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;
 }
     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;
 
 static bool pak_close(pak_file_t *pak) {
     size_t itr;
index 1c453f3d577763f51974d6882379a8deeb4b5d66..fbe725789c25d0358a88d3f04ca8c407d043ebeb 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1448,8 +1448,7 @@ static ast_expression* parse_vararg(parser_t *parser)
 }
 
 /* not to be exposed */
 }
 
 /* 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) &&
 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;
                     }
                         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;
                 } else {
                     parseerror(parser, "missing semicolon or initializer, got: `%s`", parser_tokval(parser));
                     break;
diff --git a/stat.c b/stat.c
index 170b9dd813ade51a5fce4dea3f2e0053604b70a9..efe234e4119a0d71a8e5ec33c35291711f267560 100644 (file)
--- 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);
         stat_mem_peak = stat_mem_high;
 
     free(oldinfo);
-
     return newinfo + 1;
 }
 
     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));
 }
 
     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;
 void *code_util_str_htgeth(hash_table_t *ht, const char *key, size_t bin) {
     hash_node_t *pair;
     size_t len, keylen;