瀏覽代碼

Convert everything to the autotools. Managing source dependencies will be

easier.
legacy
Sam Hocevar sam 14 年之前
父節點
當前提交
097baf0284
共有 12 個檔案被更改,包括 368 行新增41 行删除
  1. +26
    -0
      .gitignore
  2. +0
    -13
      Makefile
  3. +7
    -0
      Makefile.am
  4. +140
    -0
      bootstrap
  5. +85
    -0
      configure.ac
  6. +0
    -7
      gfx/Makefile
  7. +3
    -0
      gfx/Makefile.am
  8. +0
    -0
      gfx/font/Makefile.am
  9. +0
    -21
      src/Makefile
  10. +41
    -0
      src/Makefile.am
  11. +66
    -0
      src/editor.cpp
  12. +0
    -0
      tools/Makefile.am

+ 26
- 0
.gitignore 查看文件

@@ -1,6 +1,32 @@
# Autotools cruft
*.o
*.lo
*.a
*.la
*.exe
*.userprefs
*.usertasks
*.pidb
.auto
.libs
.deps
Makefile
Makefile.in
aclocal.m4
autom4te.cache
config.h.in
config.h
config.log
config.status
configure
libtool
stamp-*
*-stamp
# Our binaries
src/test-map
src/editor
tools/make-font
# Our data
art/*.png
art/test/*.png
gfx/font/*.png

+ 0
- 13
Makefile 查看文件

@@ -1,13 +0,0 @@

all:
cd src && $(MAKE) all
cd tools && $(MAKE) all
cd art && $(MAKE) all
cd gfx && $(MAKE) all

clean:
cd gfx && $(MAKE) clean
cd art && $(MAKE) clean
cd tools && $(MAKE) clean
cd src && $(MAKE) clean


+ 7
- 0
Makefile.am 查看文件

@@ -0,0 +1,7 @@

SUBDIRS = src tools art gfx
DIST_SUBDIRS = $(SUBDIRS)

EXTRA_DIST = bootstrap
AUTOMAKE_OPTIONS = dist-bzip2


+ 140
- 0
bootstrap 查看文件

@@ -0,0 +1,140 @@
#! /bin/sh

# bootstrap: generic bootstrap/autogen.sh script for autotools projects
#
# Copyright (c) 2002-2010 Sam Hocevar <sam@hocevar.net>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
#
# The latest version of this script can be found at the following place:
# http://caca.zoy.org/wiki/build

# Die if an error occurs
set -e

# Guess whether we are using configure.ac or configure.in
if test -f configure.ac; then
conffile="configure.ac"
elif test -f configure.in; then
conffile="configure.in"
else
echo "$0: could not find configure.ac or configure.in"
exit 1
fi

# Check for needed features
auxdir="`sed -ne 's/^[ \t]*A._CONFIG_AUX_DIR *([[ ]*\([^] )]*\).*/\1/p' $conffile`"
pkgconfig="`grep '^[ \t]*PKG_PROG_PKG_CONFIG' $conffile >/dev/null 2>&1 && echo yes || echo no`"
libtool="`grep '^[ \t]*A._PROG_LIBTOOL' $conffile >/dev/null 2>&1 && echo yes || echo no`"
header="`grep '^[ \t]*A._CONFIG_HEADER' $conffile >/dev/null 2>&1 && echo yes || echo no`"
makefile="`[ -f Makefile.am ] && echo yes || echo no`"
aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL_AMFLAGS[ \t]*=//p' Makefile.am 2>/dev/null || :`"

# Check for automake
amvers="no"
for v in 11 10 9 8 7 6 5; do
if automake-1.${v} --version >/dev/null 2>&1; then
amvers="-1.${v}"
break
elif automake1.${v} --version >/dev/null 2>&1; then
amvers="1.${v}"
break
fi
done

if test "${amvers}" = "no" && automake --version > /dev/null 2>&1; then
amvers="`automake --version | sed -e '1s/[^0-9]*//' -e q`"
if expr "$amvers" "<" "1.5" > /dev/null 2>&1; then
amvers="no"
else
amvers=""
fi
fi

if test "$amvers" = "no"; then
echo "$0: you need automake version 1.5 or later"
exit 1
fi

# Check for autoconf
acvers="no"
for v in "" "259" "253"; do
if autoconf${v} --version >/dev/null 2>&1; then
acvers="${v}"
break
fi
done

if test "$acvers" = "no"; then
echo "$0: you need autoconf"
exit 1
fi

# Check for libtool
if test "$libtool" = "yes"; then
libtoolize="no"
if glibtoolize --version >/dev/null 2>&1; then
libtoolize="glibtoolize"
else
for v in "16" "15" "" "14"; do
if libtoolize${v} --version >/dev/null 2>&1; then
libtoolize="libtoolize${v}"
break
fi
done
fi

if test "$libtoolize" = "no"; then
echo "$0: you need libtool"
exit 1
fi
fi

# Check for pkg-config
if test "$pkgconfig" = "yes"; then
if ! pkg-config --version >/dev/null 2>&1; then
echo "$0: you need pkg-config"
exit 1
fi
fi

# Remove old cruft
for x in aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh; do rm -f $x autotools/$x; if test -n "$auxdir"; then rm -f "$auxdir/$x"; fi; done
rm -Rf autom4te.cache
if test -n "$auxdir"; then
if test ! -d "$auxdir"; then
mkdir "$auxdir"
fi
aclocalflags="${aclocalflags} -I $auxdir -I ."
fi

# Explain what we are doing from now
set -x

# Bootstrap package
if test "$libtool" = "yes"; then
${libtoolize} --copy --force
if test -n "$auxdir" -a ! "$auxdir" = "." -a -f "ltmain.sh"; then
echo "$0: working around a minor libtool issue"
mv ltmain.sh "$auxdir/"
fi
fi

aclocal${amvers} ${aclocalflags}
autoconf${acvers}
if test "$header" = "yes"; then
autoheader${acvers}
fi
if test "$makefile" = "yes"; then
#add --include-deps if you want to bootstrap with any other compiler than gcc
#automake${amvers} --add-missing --copy --include-deps
automake${amvers} --foreign --add-missing --copy
fi

# Remove cruft that we no longer want
rm -Rf autom4te.cache


+ 85
- 0
configure.ac 查看文件

@@ -0,0 +1,85 @@
# $Id$

AC_INIT(deushax, 0.0)
AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR(.auto)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([no-define tar-ustar])
dnl AM_MAINTAINER_MODE

AM_CONFIG_HEADER(config.h)

AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_RANLIB

AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
AC_LIBTOOL_CXX

AC_C_CONST
AC_C_INLINE

dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
dnl now otherwise it might be set in an obscure if statement. Same thing for
dnl PKG_PROG_PKG_CONFIG which needs to be called first.
AC_EGREP_CPP(yes, foo)
PKG_PROG_PKG_CONFIG()
m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
export PKG_CONFIG_LIBDIR=/dev/null
fi

dnl conditional builds
AC_ARG_ENABLE(debug,
[ --enable-debug build debug versions of the library (default no)])

AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)

# Optimizations
CXXFLAGS="${CXXFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"

AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")

# Use SDL?
ac_cv_my_have_sdl="no"
save_CPPFLAGS="${CPPFLAGS}"
AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
if test "${SDL_CONFIG}" != "no"; then
CPPFLAGS="${CPPFLAGS} `sdl-config --cflags`"
fi
AC_CHECK_HEADERS(SDL_image.h,
[ac_cv_my_have_sdl="yes"],
[ac_cv_my_have_sdl="no"])
CPPFLAGS="${save_CPPFLAGS}"
if test "${ac_cv_my_have_sdl}" != "no"; then
AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL_image)
fi
AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")

if test "${ac_cv_my_have_sdl}" = "no" -a "${ac_cv_my_have_imlib2}" = "no"; then
AC_MSG_ERROR([[cannot find SDL_Image or GTK+, please install one of them]])
fi

if test "${enable_debug}" = "yes"; then
AC_DEFINE(DEBUG, 1, Define to 1 to activate debug)
fi

AC_SUBST(MATH_LIBS)

AC_CONFIG_FILES([
Makefile
src/Makefile
tools/Makefile
art/Makefile
art/test/Makefile
gfx/Makefile
gfx/font/Makefile
])

AC_OUTPUT


+ 0
- 7
gfx/Makefile 查看文件

@@ -1,7 +0,0 @@

all:
cd font && $(MAKE) all

clean:
cd font && $(MAKE) clean


+ 3
- 0
gfx/Makefile.am 查看文件

@@ -0,0 +1,3 @@

SUBDIRS = font


gfx/font/Makefile → gfx/font/Makefile.am 查看文件


+ 0
- 21
src/Makefile 查看文件

@@ -1,21 +0,0 @@

COMMON = test-map.cpp \
game.cpp tiler.cpp tileset.cpp scene.cpp \
font.cpp layer.cpp map.cpp joystick.cpp
TEST_SRC = test-map.cpp sdlvideo.cpp $(COMMON)
EDITOR_SRC = editor.cpp gtkvideo.cpp $(COMMON)

all: test-map

test-map: $(TEST_SRC:%.cpp=%.o)
g++ -g -Wall -O3 $^ -o $@ `pkg-config --libs sdl gl SDL_image`

editor-map: $(EDITOR_SRC:%.cpp=%.o)
g++ -g -Wall -O3 $^ -o $@ `pkg-config --libs sdl gl SDL_image`

%.o: %.cpp
g++ -g -Wall -O3 -c $^ -o $@ `pkg-config --cflags sdl gl SDL_image`

clean:
rm -f *.o test-map


+ 41
- 0
src/Makefile.am 查看文件

@@ -0,0 +1,41 @@

noinst_PROGRAMS = test-map editor

noinst_LIBRARIES = libcommon.a

libcommon_a_SOURCES = \
game.cpp tiler.cpp tileset.cpp scene.cpp \
font.cpp layer.cpp map.cpp joystick.cpp
libcommon_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image`

test_map_SOURCES = test-map.cpp sdlvideo.cpp
test_map_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image`
test_map_LDADD = libcommon.a
test_map_LDFLAGS = `pkg-config --libs sdl gl SDL_image`

editor_SOURCES = editor.cpp gtkvideo.cpp
editor_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image gtk+-2.0 gtkgl-2.0`
editor_LDADD = libcommon.a
editor_LDFLAGS = `pkg-config --libs sdl gl gtk+-2.0 gtkgl-2.0 SDL_image`

#COMMON = $(libcommon_a_SOURCES)
#
#TEST_SRC = test-map.cpp sdlvideo.cpp $(COMMON)
#EDITOR_SRC = editor.cpp gtkvideo.cpp $(COMMON)
#
#CPPFLAGS = `pkg-config --cflags sdl gl SDL_image gtk+-2.0 gtkgl-2.0`
#CXXFLAGS = -g -O3 -Wall \
# -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare
#
#test-map: $(TEST_SRC:%.cpp=%.o)
# g++ $(CXXFLAGS) $^ -o $@ `pkg-config --libs sdl gl SDL_image`
#
#editor: $(EDITOR_SRC:%.cpp=%.o)
# g++ $(CXXFLAGS) $^ -o $@ `pkg-config --libs sdl gl gtk+-2.0 gtkgl-2.0 SDL_image`
#
#%.o: %.cpp
# g++ -c $^ -o $@ $(CXXFLAGS) $(CPPFLAGS)
#
#clean:
# rm -f *.o test-map editor


+ 66
- 0
src/editor.cpp 查看文件

@@ -0,0 +1,66 @@
#include <SDL.h>

#include <stdio.h>
#include <math.h>

#include "gtkvideo.h"
#include "game.h"

#include <math.h>
#include <gtk/gtk.h>
#include <gtkgl/gtkglarea.h>
#include <GL/gl.h>

volatile int quit = 0;

static gint main_quit(GtkWidget *widget, GdkEventExpose *event)
{
quit = 1;
return FALSE;
}

int main(int argc, char **argv)
{
GtkWidget *window, *glarea;

/* initialize gtk */
gtk_init(&argc, &argv);

/* Create new top level window. */
window = gtk_window_new( GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Simple");
gtk_container_set_border_width(GTK_CONTAINER(window), 10);

/* Quit form main if got delete event */
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(main_quit), NULL);


/* You should always delete gtk_gl_area widgets before exit or else
GLX contexts are left undeleted, this may cause problems (=core dump)
in some systems.
Destroy method of objects is not automatically called on exit.
You need to manually enable this feature. Do gtk_quit_add_destroy()
for all your top level windows unless you are certain that they get
destroy signal by other means.
*/
gtk_quit_add_destroy(1, GTK_OBJECT(window));


/* Create new OpenGL widget. */
GtkVideo *video = new GtkVideo("LOL", 640, 480);
glarea = GTK_WIDGET(video->GetWidget());


/* put glarea into window and show it all */
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(glarea));
gtk_widget_show(GTK_WIDGET(glarea));
gtk_widget_show(GTK_WIDGET(window));

while (!quit)
{
while (g_main_context_iteration(NULL, FALSE));
}

return 0;
}

tools/Makefile → tools/Makefile.am 查看文件


Loading…
取消
儲存