From e452c176b40e8f9e2ccb833986c0c01fe69bcfa0 Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Tue, 13 Jan 2015 20:07:17 -0500 Subject: [PATCH] Remove MSVC support code. Simplified makefile --- BSDmakefile | 130 ----------------------------- Makefile | 169 ++++++-------------------------------- include.mk | 143 -------------------------------- msvc.c | 231 ---------------------------------------------------- 4 files changed, 23 insertions(+), 650 deletions(-) delete mode 100644 BSDmakefile delete mode 100644 include.mk delete mode 100644 msvc.c diff --git a/BSDmakefile b/BSDmakefile deleted file mode 100644 index 44a742a..0000000 --- a/BSDmakefile +++ /dev/null @@ -1,130 +0,0 @@ -# -# This is the Makefile for the BSD flavor -# -.include "include.mk" - -GITTEST != git describe --always 2>/dev/null -VALTEST != valgrind --version 2>/dev/null -GITINFO := - -.if $(GITTEST) - GITINFO != git describe --always -.endif - -.if $(CC) == clang - CFLAGS += -Weverything\ - -Wno-padded\ - -Wno-format-nonliteral\ - -Wno-disabled-macro-expansion\ - -Wno-conversion\ - -Wno-float-equal\ - -Wno-unknown-warning-option\ - -Wno-cast-align\ - -Wno-assign-enum\ - -Wno-empty-body\ - -Wno-date-time\ - -pedantic-errors -.else -. if $(CC) != g++ - CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -. endif - -. if $(CC) != tcc - CFLAGS += -pedantic-errors -. else - CFLAGS += -Wno-pointer-sign -fno-common -. endif -.endif - -.if !$(VALTEST) - CFLAGS += -DNVALGRIND -.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 -GMQCC = gmqcc -TESTSUITE = testsuite -PAK = gmqpak - -#standard rules -c.o: ${.IMPSRC} - $(CC) -c ${.IMPSRC} -o ${.TARGET} $(CFLAGS) $(CPPFLAGS) - -$(QCVM): $(OBJ_X) - $(CC) -o ${.TARGET} ${.IMPSRC} $(LDFLAGS) $(LIBS) $(OBJ_X) - -$(GMQCC): $(OBJ_C) - $(CC) -o ${.TARGET} ${.IMPSRC} $(LDFLAGS) $(LIBS) $(OBJ_C) - -$(TESTSUITE): $(OBJ_T) - $(CC) -o ${.TARGET} ${.IMPSRC} $(LDFLAGS) $(LIBS) $(OBJ_T) - -$(PAK): $(OBJ_P) - $(CC) -o ${.TARGET} ${.IMPSRC} $(LDFLAGS) $(OBJ_P) - -all: $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK) - -check: all - @ ./$(TESTSUITE) -test: all - @ ./$(TESTSUITE) - -strip: $(GMQCC) $(QCVM) $(TESTSUITE) - strip $(GMQCC) - strip $(QCVM) - strip $(TESTSUITE) - -clean: - rm -rf *.o $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK) *.dat gource.mp4 *.exe gm-qcc.tgz ./cov-int - -depend: - @makedepend -Y -f BSDmakefile -w 65536 2> /dev/null ${DEPS:C/\.o/.c/g} - -coverity: - @cov-build --dir cov-int $(MAKE) -f BSDmakefile - @tar czf gm-qcc.tgz cov-int - @rm -rf cov-int - @echo gm-qcc.tgz generated, submit for analysis - -install: install-gmqcc install-qcvm install-gmqpak install-doc -install-gmqcc: $(GMQCC) - install -d -m755 $(DESTDIR)$(BINDIR) - install -m755 $(GMQCC) $(DESTDIR)$(BINDIR)/$(GMQCC) -install-qcvm: $(QCVM) - install -d -m755 $(DESTDIR)$(BINDIR) - install -m755 $(QCVM) $(DESTDIR)$(BINDIR)/$(QCVM) -install-gmqpak: $(PAK) - install -d -m755 $(DESTDIR)$(BINDIR) - install -m755 $(PAK) $(DESTDIR)$(BINDIR)/$(PAK) -install-doc: - install -d -m755 $(DESTDIR)$(MANDIR)/man1 - install -m644 doc/gmqcc.1 $(DESTDIR)$(MANDIR)/man1/ - install -m644 doc/qcvm.1 $(DESTDIR)$(MANDIR)/man1/ - install -m644 doc/gmqpak.1 $(DESTDIR)$(MANDIR)/man1/ - -# DO NOT DELETE - -ansi.o: platform.h gmqcc.h opts.def -ast.o: gmqcc.h opts.def ast.h ir.h parser.h lexer.h -code.o: gmqcc.h opts.def -conout.o: gmqcc.h opts.def -correct.o: gmqcc.h opts.def -exec.o: gmqcc.h opts.def -fold.o: ast.h ir.h gmqcc.h opts.def parser.h lexer.h -fs.o: gmqcc.h opts.def platform.h -ftepp.o: gmqcc.h opts.def lexer.h -hash.o: gmqcc.h opts.def -intrin.o: parser.h gmqcc.h opts.def lexer.h ast.h ir.h -ir.o: gmqcc.h opts.def ir.h -lexer.o: gmqcc.h opts.def lexer.h -main.o: gmqcc.h opts.def lexer.h -opts.o: gmqcc.h opts.def -pak.o: gmqcc.h opts.def -parser.o: parser.h gmqcc.h opts.def lexer.h ast.h ir.h -stat.o: gmqcc.h opts.def -test.o: gmqcc.h opts.def platform.h -utf8.o: gmqcc.h opts.def -util.o: gmqcc.h opts.def platform.h diff --git a/Makefile b/Makefile index 142f16d..145c4a7 100644 --- a/Makefile +++ b/Makefile @@ -1,157 +1,34 @@ -include include.mk +CC ?= clang +CFLAGS = -MD -Wall -Wextra -pedantic-errors +LDFLAGS = -lm -UNAME ?= $(shell uname) -CYGWIN = $(findstring CYGWIN, $(UNAME)) -MINGW = $(findstring MINGW, $(UNAME)) +CSRCS = ansi.c ast.c code.c conout.c fold.c fs.c ftepp.c hash.c intrin.c ir.c lexer.c main.c opts.c parser.c stat.c utf8.c util.c +TSRCS = ansi.c conout.c fs.c hash.c opts.c stat.c test.c util.c -# turn on tons of warnings if clang is present -# but also turn off the STUPID ONES -ifeq ($(CC), clang) - CFLAGS += \ - -Weverything \ - -Wno-padded \ - -Wno-format-nonliteral \ - -Wno-disabled-macro-expansion \ - -Wno-conversion \ - -Wno-float-equal \ - -Wno-unknown-warning-option \ - -Wno-cast-align \ - -Wno-assign-enum \ - -Wno-empty-body \ - -Wno-date-time \ - -pedantic-errors -else - ifneq ($(CC), g++) - CFLAGS += -Wmissing-prototypes -Wstrict-prototypes - endif +COBJS = $(CSRCS:.c=.o) +TOBJS = $(TSRCS:.c=.o) - ifneq ($(CC), tcc) - CFLAGS += -pedantic-errors - else - CFLAGS += -Wno-pointer-sign -fno-common - endif -endif +CDEPS = $(CSRCS:.c=.d) +TDEPS = $(TSRCS:.c=.d) -ifneq ($(shell git describe --always 2>/dev/null),) - CFLAGS += -DGMQCC_GITINFO="\"$(shell git describe --always)\"" -endif +CBIN = gmqcc +TBIN = testsuite -ifeq ($(shell valgrind --version 2>/dev/null),) - CFLAGS += -DNVALGRIND -endif +all: $(CBIN) $(TBIN) -# do this last otherwise there is whitespace in the command output and -# it makes my OCD act up -CFLAGS += $(OPTIONAL_CFLAGS) -LDFLAGS += $(OPTIONAL_LDFLAGS) +$(CBIN): $(COBJS) + $(CC) $(LDFLAGS) $(COBJS) -o $@ -#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 -RMDUP = $(if $1,$(firstword $1) $(call RMDUP,$(filter-out $(firstword $1),$1))) -DEPS := $(call RMDUP, $(OBJ_P) $(OBJ_T) $(OBJ_C) $(OBJ_X)) +$(TBIN): $(TOBJS) + $(CC) $(LDFLAGS) $(TOBJS) -o $@ -ifneq ("$(CYGWIN)", "") - #nullify the common variables that - #most *nix systems have (for windows) - PREFIX := - BINDIR := - DATADIR := - MANDIR := - QCVM = qcvm.exe - GMQCC = gmqcc.exe - TESTSUITE = testsuite.exe - CFLAGS += -DNVALGRIND -else -ifneq ("$(MINGW)", "") - #nullify the common variables that - #most *nix systems have (for windows) - PREFIX := - BINDIR := - DATADIR := - MANDIR := - QCVM = qcvm.exe - GMQCC = gmqcc.exe - TESTSUITE = testsuite.exe - CFLAGS += -DNVALGRIND -else - QCVM = qcvm - GMQCC = gmqcc - TESTSUITE = testsuite -endif -endif +.c.o: + $(CC) -c $(CFLAGS) $< -o $@ -#standard rules -c.o: - $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) - -$(QCVM): $(OBJ_X) - $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) - -$(GMQCC): $(OBJ_C) $(OBJ_D) - $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) - -$(TESTSUITE): $(OBJ_T) - $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) - -all: $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK) - -check: all - @ ./$(TESTSUITE) -test: all - @ ./$(TESTSUITE) - -strip: $(GMQCC) $(QCVM) $(TESTSUITE) - strip $(GMQCC) - strip $(QCVM) - strip $(TESTSUITE) +test: $(CBIN) $(TBIN) + @./$(TBIN) clean: - rm -rf *.o $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK) *.dat gource.mp4 *.exe gm-qcc.tgz ./cov-int - -depend: - @ makedepend -Y -w 65536 2> /dev/null $(subst .o,.c,$(DEPS)) - - -coverity: - @cov-build --dir cov-int $(MAKE) - @tar czf gm-qcc.tgz cov-int - @rm -rf cov-int - @echo gm-qcc.tgz generated, submit for analysis - -#install rules -install: install-gmqcc install-qcvm install-gmqpak install-doc -install-gmqcc: $(GMQCC) - install -d -m755 $(DESTDIR)$(BINDIR) - install -m755 $(GMQCC) $(DESTDIR)$(BINDIR)/$(GMQCC) -install-qcvm: $(QCVM) - install -d -m755 $(DESTDIR)$(BINDIR) - install -m755 $(QCVM) $(DESTDIR)$(BINDIR)/$(QCVM) -install-doc: - install -d -m755 $(DESTDIR)$(MANDIR)/man1 - install -m644 doc/gmqcc.1 $(DESTDIR)$(MANDIR)/man1/ - install -m644 doc/qcvm.1 $(DESTDIR)$(MANDIR)/man1/ - install -m644 doc/gmqpak.1 $(DESTDIR)$(MANDIR)/man1/ - -# DO NOT DELETE - -ansi.o: platform.h gmqcc.h opts.def -util.o: gmqcc.h opts.def platform.h -hash.o: gmqcc.h opts.def -stat.o: gmqcc.h opts.def -fs.o: gmqcc.h opts.def platform.h -opts.o: gmqcc.h opts.def -conout.o: gmqcc.h opts.def -test.o: gmqcc.h opts.def platform.h -main.o: gmqcc.h opts.def lexer.h -lexer.o: gmqcc.h opts.def lexer.h -parser.o: parser.h gmqcc.h opts.def lexer.h ast.h ir.h -code.o: gmqcc.h opts.def -ast.o: gmqcc.h opts.def ast.h ir.h parser.h lexer.h -ir.o: gmqcc.h opts.def ir.h -ftepp.o: gmqcc.h opts.def lexer.h -utf8.o: gmqcc.h opts.def -correct.o: gmqcc.h opts.def -fold.o: ast.h ir.h gmqcc.h opts.def parser.h lexer.h -intrin.o: parser.h gmqcc.h opts.def lexer.h ast.h ir.h -exec.o: gmqcc.h opts.def + rm -f *.d + rm -f $(COBJS) $(CDEPS) $(CBIN) + rm -f $(TOBJS) $(TDEPS) $(TBIN) diff --git a/include.mk b/include.mk deleted file mode 100644 index 7352ecb..0000000 --- a/include.mk +++ /dev/null @@ -1,143 +0,0 @@ -# default directories and paths -DESTDIR := -PREFIX := /usr/local -BINDIR := $(PREFIX)/bin -DATADIR := $(PREFIX)/share -MANDIR := $(DATADIR)/man - -# default flags -CFLAGS += -Wall -Wextra -Werror -Wstrict-aliasing -Wno-attributes -O2 - -# compiler -CC ?= clang - -# linker flags and optional additional libraries if required -LDFLAGS += -LIBS += -lm - -#common objects -COMMON = ansi.o util.o hash.o stat.o fs.o opts.o conout.o - -#optional flags -OPTIONAL_CFLAGS := -OPTIONAL_LDFLAGS := - -#objects -OBJ_C = $(COMMON) main.o lexer.o parser.o code.o ast.o ir.o ftepp.o utf8.o fold.o intrin.o -OBJ_T = $(COMMON) test.o -OBJ_X = $(COMMON) exec.o - -#gource flags -GOURCEFLAGS = \ - --date-format "%d %B, %Y" \ - --seconds-per-day 0.01 \ - --auto-skip-seconds 1 \ - --title "GMQCC" \ - --key \ - --camera-mode overview \ - --highlight-all-users \ - --file-idle-time 0 \ - --hide progress,mouse \ - --stop-at-end \ - --max-files 99999999999 \ - --max-file-lag 0.000001 \ - --bloom-multiplier 1.3 \ - --logo doc/html/gmqcc.png \ - -1280x720 - -#ffmpeg flags for gource -FFMPEGFLAGS= \ - -y \ - -r 60 \ - -f image2pipe \ - -vcodec ppm \ - -i - \ - -vcodec libx264 \ - -preset ultrafast \ - -crf 1 \ - -threads 0 \ - -bf 0 - -#splint flags -SPLINTFLAGS = \ - -preproc \ - -redef \ - -noeffect \ - -nullderef \ - -usedef \ - -type \ - -mustfreeonly \ - -nullstate \ - -varuse \ - -mustfreefresh \ - -compdestroy \ - -compmempass \ - -nullpass \ - -onlytrans \ - -predboolint \ - -boolops \ - -incondefs \ - -macroredef \ - -retvalint \ - -nullret \ - -predboolothers \ - -globstate \ - -dependenttrans \ - -branchstate \ - -compdef \ - -temptrans \ - -usereleased \ - -warnposix \ - +charindex \ - -kepttrans \ - -unqualifiedtrans \ - +matchanyintegral \ - +voidabstract \ - -nullassign \ - -unrecog \ - -casebreak \ - -retvalbool \ - -retvalother \ - -mayaliasunique \ - -realcompare \ - -observertrans \ - -abstract \ - -statictrans \ - -castfcnptr \ - -shiftimplementation \ - -shiftnegative \ - -boolcompare \ - -infloops \ - -sysunrecog - -#always the right rule -default: all - -#uninstall rule -uninstall: - rm -f $(DESTDIR)$(BINDIR)/gmqcc - rm -f $(DESTDIR)$(BINDIR)/qcvm - rm -f $(DESTDIR)$(BINDIR)/gmqpak - rm -f $(DESTDIR)$(MANDIR)/man1/gmqcc.1 - rm -f $(DESTDIR)$(MANDIR)/man1/qcvm.1 - rm -f $(DESTDIR)$(MANDIR)/man1/gmqpak.1 - -#style rule -STYLE_MATCH = \( -name '*.[ch]' -or -name '*.def' -or -name '*.qc' \) - -# splint cannot parse the MSVC source -SPLINT_MATCH = \( -name '*.[ch]' -and ! -name 'msvc.c' -and ! -path './doc/*' \) - -style: - find . -type f $(STYLE_MATCH) -exec sed -i 's/ *$$//' '{}' ';' - find . -type f $(STYLE_MATCH) -exec sed -i -e '$$a\' '{}' ';' - find . -type f $(STYLE_MATCH) -exec sed -i 's/\t/ /g' '{}' ';' - -splint: - @splint $(SPLINTFLAGS) `find . -type f $(SPLINT_MATCH)` - -gource: - @gource $(GOURCEFLAGS) - -gource-record: - @gource $(GOURCEFLAGS) -o - | ffmpeg $(FFMPEGFLAGS) gource.mp4 diff --git a/msvc.c b/msvc.c deleted file mode 100644 index cb13cc2..0000000 --- a/msvc.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (C) 2012, 2013, 2014, 2015 - * Dale Weiler - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is furnished to do - * so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#define GMQCC_PLATFORM_HEADER -#include -#include - -#include "platform.h" - -#define CTIME_BUFFER 64 -#define GETENV_BUFFER 4096 -#define STRERROR_BUFFER 128 - -static void **platform_mem_pool = NULL; -static void platform_mem_atexit() { - size_t i; - for (i = 0; i < vec_size(platform_mem_pool); i++) - mem_d(platform_mem_pool[i]); - vec_free(platform_mem_pool); -} - -static void *platform_mem_allocate(size_t bytes) { - void *mem = NULL; - if (!platform_mem_pool) { - atexit(&platform_mem_atexit); - vec_push(platform_mem_pool, NULL); - } - - mem = mem_a(bytes); - vec_push(platform_mem_pool, mem); - - return mem; -} - -int platform_vsnprintf(char *buffer, size_t bytes, const char *format, va_list arg) { - return vsnprintf_s(buffer, bytes, bytes, format, arg); -} - -int platform_vsscanf(const char *str, const char *format, va_list va) { - return vsscanf_s(str, format, va); -} - -const struct tm *platform_localtime(const time_t *timer) { - struct tm *t; - t = (struct tm*)platform_mem_allocate(sizeof(struct tm)); - localtime_s(&t, timer); - return t; -} - -const char *platform_ctime(const time_t *timer) { - char *buffer = (char *)platform_mem_allocate(CTIME_BUFFER); - ctime_s(buffer, CTIME_BUFFER, timer); - return buffer; -} - -char *platform_strncat(char *dest, const char *src, size_t num) { - return strncat_s(dest, num, src, _TRUNCATE); -} - -const char *platform_getenv(const char *var) { - char *buffer = (char *)platform_mem_allocate(GETENV_BUFFER); - size_t size; - getenv_s(&size, buffer, GETENV_BUFFER, var); - return buffer; -} - -/* - * TODO: this isn't exactly 'accurate' for MSVC but it seems to work, - * at least to some extent. - */ -int platform_vasprintf(char **dat, const char *fmt, va_list args) { - int ret; - int len; - char *tmp = NULL; - - if ((len = _vscprintf(fmt, args)) < 0) { - *dat = NULL; - return -1; - } - - tmp = (char*)mem_a(len + 1); - if ((ret = _vsnprintf_s(tmp, len+1, len+1, fmt, args)) != len) { - mem_d(tmp); - *dat = NULL; - return -1; - } - *dat = tmp; - return len; -} - -char *platform_strcat(char *dest, const char *src) { - strcat_s(dest, strlen(src), src); - return dest; -} - -char *platform_strncpy(char *dest, const char *src, size_t num) { - strncpy_s(dest, num, src, num); - return dest; -} - -const char *platform_strerror(int err) { - char *buffer = (char*)platform_mem_allocate(STRERROR_BUFFER); - strerror_s(buffer, STRERROR_BUFFER, err); - return buffer; -} - -FILE *platform_fopen(const char *filename, const char *mode) { - FILE *handle; - return (fopen_s(&handle, filename, mode) != 0) ? NULL : handle; -} - -size_t platform_fread(void *ptr, size_t size, size_t count, FILE *stream) { - return fread_s(ptr, size, size, count, stream); -} - -size_t platform_fwrite(const void *ptr, size_t size, size_t count, FILE *stream) { - return fwrite(ptr, size, count, stream); -} - -int platform_fflush(FILE *stream) { - return fflush(stream); -} - -int platform_vfprintf(FILE *stream, const char *format, va_list arg) { - return vfprintf_s(stream, format, arg); -} - -int platform_fclose(FILE *stream) { - return fclose(stream); -} - -int platform_ferror(FILE *stream) { - return ferror(stream); -} - -int platform_fgetc(FILE *stream) { - return fgetc(stream); -} - -int platform_fputs(const char *str, FILE *stream) { - return fputs(str, stream); -} - -int platform_fseek(FILE *stream, long offset, int origin) { - return fseek(stream, offset, origin); -} - -long platform_ftell(FILE *stream) { - return ftell(stream); -} - -int platform_mkdir(const char *path, int mode) { - return mkdir(path, mode); -} - -DIR *platform_opendir(const char *path) { - DIR *dir = (DIR*)mem_a(sizeof(DIR) + strlen(path)); - if (!dir) - return NULL; - - platform_strncpy(dir->dd_name, path, strlen(path)); - return dir; -} - -int platform_closedir(DIR *dir) { - FindClose((HANDLE)dir->dd_handle); - mem_d((void*)dir); - return 0; -} - -struct dirent *platform_readdir(DIR *dir) { - WIN32_FIND_DATA info; - struct dirent *data; - int ret; - - if (!dir->dd_handle) { - char *dirname; - if (*dir->dd_name) { - size_t n = strlen(dir->dd_name); - if ((dir = (char*)mem_a(n+5))) { - platform_strncpy(dirname, dir->dd_name, n); - platform_strncpy(dirname + n, "\\*.*", 4); - } - } else { - if (!(dirname = util_strdup("\\*.*"))) - return NULL; - } - - dir->dd_handle = (long)FindFirstFile(dirname, &info); - mem_d(dirname); - ret = !(!dir->dd_handle); - } else if (dir->dd_handle != -11) { - ret = FindNextFile((HANDLE)dir->dd_handle, &info); - } else { - ret = 0; - } - - if (!ret) - return NULL; - - if ((data = (struct dirent*)mem_a(sizeof(struct dirent)))) { - platform_strncpy(data->d_name, info.cFileName, FILENAME_MAX - 1); - data->d_name[FILENAME_MAX - 1] = '\0'; - data->d_namelen = strlen(data->d_name); - } - - return data; -} - -int platform_istty(int fd) { - return _isatty(fd); -} -- 2.39.2