From 22b6291669ca0cea6c622c1f4466e35ba5e3250a Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Fri, 8 Mar 2013 08:05:28 +0100 Subject: [PATCH] Emacs: custom ldflags option for C compilation. Emacs: GLSL mode. Switchdriver: update to match mesa packages. --- .emacs.d/modes.el | 49 ++++++++++++++++++++++++++++++------------- .scripts/switchdriver | 8 +++---- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/.emacs.d/modes.el b/.emacs.d/modes.el index 087423c0..5a070cba 100644 --- a/.emacs.d/modes.el +++ b/.emacs.d/modes.el @@ -379,24 +379,35 @@ properly escaped with double-quotes in case it has spaces." ;; Identation style (setq c-default-style "linux" c-basic-offset 4) +(defcustom c-compile-ldflags nil +"[Local variable] Custom linker flags for C compilation." +:safe 'stringp) + +(defun c-compile () + (interactive) + (progn + (unless (or (file-exists-p "Makefile") (file-exists-p "makefile") (file-exists-p "GNUMakefile")) + (set (make-local-variable 'compile-command) + ;; Emulate make's .c.o implicit pattern rule, but with + ;; different defaults for the CC, CPPFLAGS, and CFLAGS + ;; variables: + ;; $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $< + ;; (setq compile-command + (let + ((file (file-name-nondirectory buffer-file-name))) + (format "%s -o %s %s %s %s %s" + (or (getenv "CC") "gcc") + (file-name-sans-extension file) + (or (getenv "CPPFLAGS") "-DDEBUG=9") + (or (getenv "CFLAGS") "-ansi -pedantic -std=c99 -Wall -Wextra -Wshadow -g3 -O0") + (or (getenv "LDFLAGS") c-compile-ldflags) + file)))) + (compile compile-command))) + (add-hook 'c-mode-hook (lambda () - (unless (file-exists-p "Makefile") - (set (make-local-variable 'compile-command) - ;; emulate make's .c.o implicit pattern rule, but with - ;; different defaults for the CC, CPPFLAGS, and CFLAGS - ;; variables: - ;; $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $< - (let ((file (file-name-nondirectory buffer-file-name))) - (format "%s -o %s %s %s %s" - (or (getenv "CC") "gcc") - (file-name-sans-extension file) - (or (getenv "CPPFLAGS") "-DDEBUG=9") - (or (getenv "CFLAGS") "-ansi -pedantic -std=c99 -Wall -Wextra -Wshadow -lm -pthread -g3 -O0") - file)))) - - (local-set-key (kbd "C-c C-c") 'compile) + (local-set-key (kbd "C-c C-c") 'c-compile) (local-set-key (kbd "M-TAB") 'semantic-complete-analyze-inline) (local-set-key "." 'semantic-complete-self-insert) (local-set-key ">" 'semantic-complete-self-insert) @@ -478,3 +489,11 @@ properly escaped with double-quotes in case it has spaces." ;; Indent comments. (setq sh-indent-comment t) + +;;============================================================================== +;; GLSL +;;============================================================================== + +(autoload 'glsl-mode "glsl-mode" nil t) +(add-to-list 'auto-mode-alist '("\\.vert\\'" . glsl-mode)) +(add-to-list 'auto-mode-alist '("\\.frag\\'" . glsl-mode)) diff --git a/.scripts/switchdriver b/.scripts/switchdriver index b9f1ce17..736f693d 100755 --- a/.scripts/switchdriver +++ b/.scripts/switchdriver @@ -15,7 +15,7 @@ fi if [ $(pacman -Qi catalyst-utils 2>/dev/null|wc -l) -ge 2 ]; then pacman -Rdd --noconfirm catalyst-utils catalyst-dkms lib32-catalyst-utils rm -f "/etc/X11/xorg.conf" - pacman -S --noconfirm ati-dri lib32-ati-dri xf86-video-ati + pacman -S --noconfirm ati-dri lib32-ati-dri xf86-video-ati if [ -f "/boot/syslinux/syslinux.cfg" ]; then sed -i 's/nomodeset//' "/boot/syslinux/syslinux.cfg" echo @@ -26,11 +26,11 @@ if [ $(pacman -Qi catalyst-utils 2>/dev/null|wc -l) -ge 2 ]; then echo "You have to remove 'nomodeset' kernel parameter manually." fi else - pacman -Rs --noconfirm ati-dri lib32-ati-dri xf86-video-ati - pacman -Rdd --noconfirm libgl lib32-libgl + pacman -Rs --noconfirm ati-dri lib32-ati-dri xf86-video-ati + pacman -Rdd --noconfirm mesa-libgl lib32-mesa-libgl pacman -S --noconfirm catalyst-utils catalyst-dkms lib32-catalyst-utils aticonfig --initial - if [ -f "/boot/syslinux/syslinux.cfg" ]; then + if [ $? -eq 0 ] && [ -f "/boot/syslinux/syslinux.cfg" ]; then sed -i '/^LABEL arch$/{n;n;n;s/$/ nomodeset/}' "/boot/syslinux/syslinux.cfg" echo echo "#### Syslinux entry:"